Merge pull request #142 from esensar/fix/shortcut-pin-crash
Do a check for shortcut host permissions before pinning a shortcut
This commit is contained in:
commit
bb90255e34
1 changed files with 8 additions and 6 deletions
|
@ -233,12 +233,14 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
REQUEST_CREATE_SHORTCUT -> {
|
REQUEST_CREATE_SHORTCUT -> {
|
||||||
if (resultCode == Activity.RESULT_OK && resultData != null) {
|
if (resultCode == Activity.RESULT_OK && resultData != null) {
|
||||||
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
val item = launcherApps.getPinItemRequest(resultData)
|
if (launcherApps.hasShortcutHostPermission()) {
|
||||||
if (item.accept()) {
|
val item = launcherApps.getPinItemRequest(resultData)
|
||||||
val shortcutId = item.shortcutInfo?.id!!
|
if (item.accept()) {
|
||||||
val label = item.shortcutInfo.getLabel()
|
val shortcutId = item.shortcutInfo?.id!!
|
||||||
val icon = launcherApps.getShortcutBadgedIconDrawable(item.shortcutInfo!!, resources.displayMetrics.densityDpi)
|
val label = item.shortcutInfo.getLabel()
|
||||||
mActionOnAddShortcut?.invoke(shortcutId, label, icon)
|
val icon = launcherApps.getShortcutBadgedIconDrawable(item.shortcutInfo!!, resources.displayMetrics.densityDpi)
|
||||||
|
mActionOnAddShortcut?.invoke(shortcutId, label, icon)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue