From 653d16b269f609d9de0c523d9f3bd56930e29302 Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Sat, 29 Mar 2025 21:09:15 +0100 Subject: [PATCH] new action: launch other launchers --- .../java/de/jrpie/android/launcher/Functions.kt | 2 +- .../android/launcher/actions/LauncherAction.kt | 15 +++++++++++++++ app/src/main/res/drawable/baseline_home_24.xml | 11 +++++++++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/baseline_home_24.xml diff --git a/app/src/main/java/de/jrpie/android/launcher/Functions.kt b/app/src/main/java/de/jrpie/android/launcher/Functions.kt index df57008..afc2c31 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Functions.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Functions.kt @@ -61,7 +61,7 @@ fun setDefaultHomeScreen(context: Context, checkDefault: Boolean = false) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && context is Activity - && !isDefault // using role manager only works when µLauncher is not already the default. + && checkDefault // using role manager only works when µLauncher is not already the default. ) { val roleManager = context.getSystemService(RoleManager::class.java) context.startActivityForResult( diff --git a/app/src/main/java/de/jrpie/android/launcher/actions/LauncherAction.kt b/app/src/main/java/de/jrpie/android/launcher/actions/LauncherAction.kt index ee9502c..6ba467e 100644 --- a/app/src/main/java/de/jrpie/android/launcher/actions/LauncherAction.kt +++ b/app/src/main/java/de/jrpie/android/launcher/actions/LauncherAction.kt @@ -154,6 +154,12 @@ enum class LauncherAction( R.drawable.baseline_flashlight_on_24, ::toggleTorch, ), + LAUNCH_OTHER_LAUNCHER( + "launcher_other_launcher", + R.string.list_other_launch_other_launcher, + R.drawable.baseline_home_24, + ::launchOtherLauncher + ), NOP("nop", R.string.list_other_nop, R.drawable.baseline_not_interested_24, {}); override fun invoke(context: Context, rect: Rect?): Boolean { @@ -258,6 +264,15 @@ private fun expandSettingsPanel(context: Context) { } } +private fun launchOtherLauncher(context: Context) { + context.startActivity( + Intent.createChooser( + Intent(Intent.ACTION_MAIN).also { it.addCategory(Intent.CATEGORY_HOME) }, + context.getString(R.string.list_other_launch_other_launcher) + ) + ) +} + private fun openSettings(context: Context) { context.startActivity(Intent(context, SettingsActivity::class.java)) } diff --git a/app/src/main/res/drawable/baseline_home_24.xml b/app/src/main/res/drawable/baseline_home_24.xml new file mode 100644 index 0000000..935d1b6 --- /dev/null +++ b/app/src/main/res/drawable/baseline_home_24.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 83b963b..a8bc9b3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -256,6 +256,7 @@ Do nothing Lock Screen Toggle Torch + Launch other Home Screen Add Shortcut