From b15673b8a2ac7baf7c422035a53845b7db35514f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 21 Sep 2023 12:16:14 +0200 Subject: [PATCH] Pin shortcuts only on successful accept --- .../launcher/activities/MainActivity.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt index 5d8f2e2..3a0cee5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt @@ -234,11 +234,12 @@ class MainActivity : SimpleActivity(), FlingListener { if (resultCode == Activity.RESULT_OK && resultData != null) { val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps val item = launcherApps.getPinItemRequest(resultData) - item.accept() - val shortcutId = item.shortcutInfo?.id!! - val label = item.shortcutInfo.getLabel() - val icon = launcherApps.getShortcutBadgedIconDrawable(item.shortcutInfo!!, resources.displayMetrics.densityDpi) - mActionOnAddShortcut?.invoke(shortcutId, label, icon) + if (item.accept()) { + val shortcutId = item.shortcutInfo?.id!! + val label = item.shortcutInfo.getLabel() + val icon = launcherApps.getShortcutBadgedIconDrawable(item.shortcutInfo!!, resources.displayMetrics.densityDpi) + mActionOnAddShortcut?.invoke(shortcutId, label, icon) + } } } }