make sure casual static shortcuts work too
This commit is contained in:
parent
fd9c7b3787
commit
417deef01c
|
@ -391,12 +391,17 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
if (clickedGridItem.type == ITEM_TYPE_ICON) {
|
if (clickedGridItem.type == ITEM_TYPE_ICON) {
|
||||||
launchApp(clickedGridItem.packageName)
|
launchApp(clickedGridItem.packageName)
|
||||||
} else if (clickedGridItem.type == ITEM_TYPE_SHORTCUT) {
|
} else if (clickedGridItem.type == ITEM_TYPE_SHORTCUT) {
|
||||||
val id = clickedGridItem.shortcutId
|
if (clickedGridItem.intent.isNotEmpty()) {
|
||||||
val packageName = clickedGridItem.packageName
|
launchShortcutIntent(clickedGridItem)
|
||||||
val userHandle = android.os.Process.myUserHandle()
|
} else {
|
||||||
val shortcutBounds = home_screen_grid.getClickableRect(clickedGridItem)
|
// launch pinned shortcuts
|
||||||
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
val id = clickedGridItem.shortcutId
|
||||||
launcherApps.startShortcut(packageName, id, shortcutBounds, null, userHandle)
|
val packageName = clickedGridItem.packageName
|
||||||
|
val userHandle = android.os.Process.myUserHandle()
|
||||||
|
val shortcutBounds = home_screen_grid.getClickableRect(clickedGridItem)
|
||||||
|
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
|
launcherApps.startShortcut(packageName, id, shortcutBounds, null, userHandle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ fun Activity.uninstallApp(packageName: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// launch static or dynamic shortcuts that have intents as string
|
||||||
fun Activity.launchShortcutIntent(item: HomeScreenGridItem) {
|
fun Activity.launchShortcutIntent(item: HomeScreenGridItem) {
|
||||||
try {
|
try {
|
||||||
val intent = Intent.parseUri(item.intent, 0)
|
val intent = Intent.parseUri(item.intent, 0)
|
||||||
|
|
Loading…
Reference in New Issue