Skip to content

Commit 417deef

Browse files
committed
make sure casual static shortcuts work too
1 parent fd9c7b3 commit 417deef

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,17 @@ class MainActivity : SimpleActivity(), FlingListener {
391391
if (clickedGridItem.type == ITEM_TYPE_ICON) {
392392
launchApp(clickedGridItem.packageName)
393393
} else if (clickedGridItem.type == ITEM_TYPE_SHORTCUT) {
394-
val id = clickedGridItem.shortcutId
395-
val packageName = clickedGridItem.packageName
396-
val userHandle = android.os.Process.myUserHandle()
397-
val shortcutBounds = home_screen_grid.getClickableRect(clickedGridItem)
398-
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
399-
launcherApps.startShortcut(packageName, id, shortcutBounds, null, userHandle)
394+
if (clickedGridItem.intent.isNotEmpty()) {
395+
launchShortcutIntent(clickedGridItem)
396+
} else {
397+
// launch pinned shortcuts
398+
val id = clickedGridItem.shortcutId
399+
val packageName = clickedGridItem.packageName
400+
val userHandle = android.os.Process.myUserHandle()
401+
val shortcutBounds = home_screen_grid.getClickableRect(clickedGridItem)
402+
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
403+
launcherApps.startShortcut(packageName, id, shortcutBounds, null, userHandle)
404+
}
400405
}
401406
}
402407
}

app/src/main/kotlin/com/simplemobiletools/launcher/extensions/Activity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ fun Activity.uninstallApp(packageName: String) {
3838
}
3939
}
4040

41+
// launch static or dynamic shortcuts that have intents as string
4142
fun Activity.launchShortcutIntent(item: HomeScreenGridItem) {
4243
try {
4344
val intent = Intent.parseUri(item.intent, 0)

0 commit comments

Comments
 (0)