Pin shortcuts only on successful accept

This commit is contained in:
Ensar Sarajčić 2023-09-21 12:16:14 +02:00
parent 6766e46c37
commit b15673b8a2
1 changed files with 6 additions and 5 deletions

View File

@ -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)
}
}
}
}