From 52bf19ad8ece1a4857a0e6b4e54f73cbeaaf53e0 Mon Sep 17 00:00:00 2001 From: DeathKhan Date: Thu, 12 Nov 2026 11:10:32 -0600 Subject: [PATCH] feat(home): choose the page the Home button opens (#2493) * feat(home): choose the page the Home button opens As the Home app, DroidDeck always came back to whichever page was last open, and a cold start landed on Steam. A new choice under Setup > Launcher, shown while "Use as Home screen" is on, lets Home open the Android apps page instead. The default stays Steam, which keeps the current behaviour. * fix(home): a Home request for the apps page closes a page open over the rail --- .../droiddeck/launcher/FrontEndActivity.kt | 12 ++++++++++++ .../com/droiddeck/launcher/HomeActivity.kt | 6 ++++++ .../com/droiddeck/launcher/core/AppUiPrefs.kt | 19 +++++++++++++++++++ .../droiddeck/launcher/ui/FrontEndScreen.kt | 10 ++++++++++ .../droiddeck/launcher/ui/FrontEndSetup.kt | 5 +++++ app/src/main/res/values/strings.xml | 2 ++ .../com/droiddeck/launcher/ui/AppScaleTest.kt | 8 ++++++++ 7 files changed, 62 insertions(+) diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index 699dd9643b..23171a6c17 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -196,6 +196,7 @@ class FrontEndActivity : ComponentActivity() { private var stretch16x9 by mutableStateOf(false) private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) private var launcherOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER) + private var homePage by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM) private var launcherFullscreen by mutableStateOf(true) private var downloadSource by mutableStateOf(DownloadSource.MODE_AUTO) private var downloadMirror by mutableStateOf("") @@ -829,6 +830,10 @@ class FrontEndActivity : ComponentActivity() { private fun readGameIntent(request: Intent) { request.getStringExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV)?.let { navRequest = it; request.removeExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV) } + if (navRequest == com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_APPS) { + homeAppSelected = HomeApp.isHomeScreenEnabled(this) && HomeApp.isDefault(this) + if (!homeAppSelected) navRequest = null + } shortcutPicker = request.action == Intent.ACTION_CREATE_SHORTCUT if (shortcutPicker) { steamGames = emptyList() @@ -1122,6 +1127,7 @@ class FrontEndActivity : ComponentActivity() { orientation = SessionPrefs.orientation(this) launcherOrientation = com.droiddeck.launcher.core.AppUiPrefs.orientation(this) requestedOrientation = launcherOrientation + homePage = com.droiddeck.launcher.core.AppUiPrefs.homePage(this) launcherFullscreen = SessionPrefs.launcherFullscreen(this) downloadSource = DownloadSource.mode(this) downloadMirror = DownloadSource.mirror(this) @@ -1218,6 +1224,7 @@ class FrontEndActivity : ComponentActivity() { showPhantomGate = showPhantomGate, orientation = orientation, launcherOrientation = launcherOrientation, + homePage = homePage, launcherFullscreen = launcherFullscreen, downloadSource = downloadSource, downloadMirror = downloadMirror, @@ -1515,6 +1522,10 @@ class FrontEndActivity : ComponentActivity() { launcherOrientation = value requestedOrientation = value }, + onHomePage = { value -> + com.droiddeck.launcher.core.AppUiPrefs.setHomePage(this, value) + homePage = value + }, onLauncherFullscreen = { on -> SessionPrefs.setLauncherFullscreen(this, on) launcherFullscreen = on @@ -1907,6 +1918,7 @@ class FrontEndActivity : ComponentActivity() { orientation = SessionPrefs.orientation(this) launcherOrientation = com.droiddeck.launcher.core.AppUiPrefs.orientation(this) requestedOrientation = launcherOrientation + homePage = com.droiddeck.launcher.core.AppUiPrefs.homePage(this) SteamIntegration.syncShortcutsListing(this) refreshWifiDiscovery() com.droiddeck.launcher.stores.StoresState.refresh(this) diff --git a/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt b/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt index 59e10c48e7..3947263c03 100644 --- a/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt @@ -25,6 +25,12 @@ class HomeActivity : Activity() { } else { Intent(this, FrontEndActivity::class.java) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) + .apply { + val page = com.droiddeck.launcher.core.AppUiPrefs.homePage(this@HomeActivity) + if (page != com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM) { + putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, page) + } + } } startActivity(destination) finish() diff --git a/app/src/main/java/com/droiddeck/launcher/core/AppUiPrefs.kt b/app/src/main/java/com/droiddeck/launcher/core/AppUiPrefs.kt index 7b8536202d..3f308636db 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/AppUiPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/AppUiPrefs.kt @@ -27,6 +27,25 @@ object AppUiPrefs { context.getSharedPreferences("app-ui", Context.MODE_PRIVATE).edit().putInt("orientation", value).apply() } + const val HOME_PAGE_STEAM = "steam" + const val HOME_PAGE_APPS = "android-apps" + + val homePageOptions = listOf( + HOME_PAGE_STEAM to R.string.rail_steam, + HOME_PAGE_APPS to R.string.content_android_apps, + ) + + fun homePage(context: Context): String = + context.getSharedPreferences("app-ui", Context.MODE_PRIVATE) + .getString("home-page", null) + .takeIf { value -> homePageOptions.any { it.first == value } } + ?: HOME_PAGE_STEAM + + fun setHomePage(context: Context, value: String) { + require(homePageOptions.any { it.first == value }) + context.getSharedPreferences("app-ui", Context.MODE_PRIVATE).edit().putString("home-page", value).apply() + } + internal fun normalizeScale(percent: Int): Int = percent.takeIf { it in scales } ?: DEFAULT_SCALE fun scale(context: Context): Int = normalizeScale( diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt index 1e4aaa88b0..3cc28e1890 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt @@ -171,6 +171,7 @@ class FrontEndState( val showPhantomGate: Boolean = false, val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, val launcherOrientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER, + val homePage: String = com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM, val launcherFullscreen: Boolean = true, val downloadSource: String = DownloadSource.MODE_AUTO, val downloadMirror: String = "", @@ -271,6 +272,7 @@ class FrontEndActions( val onLauncherIcon: (String) -> Unit = {}, val onOrientation: (Int) -> Unit = {}, val onLauncherOrientation: (Int) -> Unit = {}, + val onHomePage: (String) -> Unit = {}, val onLauncherFullscreen: (Boolean) -> Unit = {}, val onAnimationsEnabled: (Boolean) -> Unit = {}, val onLowStorageWarning: (Boolean) -> Unit = {}, @@ -466,6 +468,14 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com "setup:launcher" -> { SetupTabs.openLauncher = true; selected = "setup" } com.droiddeck.launcher.sync.SyncthingService.NAV -> com.droiddeck.launcher.sync.Syncthing.requestOpen() "setup:integration" -> { SetupTabs.openOverview = true; selected = "setup" } + com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_APPS -> { + // Home lands on the apps page itself, so a page open over the rail (Components, Performance) closes first. + if (s.pageKey != null) a.onPageBack() + Hops.origin = null + Hops.restore = null + Hops.sinking = null + selected = target + } else -> selected = target } a.onNavigated() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index f90cf1b26b..bfdbd7ecef 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -473,6 +473,11 @@ internal fun SetupPanel( ) { a.onHomeScreen(it) } if (s.homeScreenEnabled) { ActionRow(stringResource(R.string.setup_default_home), s.defaultHomeLabel ?: stringResource(R.string.setup_choose_home), stringResource(R.string.setup_choose), a.onHomeApp) + ChoiceRow( + host, "home-page", stringResource(R.string.setup_home_page), stringResource(R.string.setup_home_page_hint), + com.droiddeck.launcher.core.AppUiPrefs.homePageOptions.map { (value, label) -> value to stringResource(label) }, + s.homePage, onPick = a.onHomePage, + ) } ChoiceRow( host, "launcher-orientation", stringResource(R.string.setup_launcher_orientation), null, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cc8da5f577..c5acad050c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -982,6 +982,8 @@ Use as Home screen DroidDeck can be the Home app DroidDeck is never offered as a Home app + Home button opens + The page shown when DroidDeck is the Home app and you press Home In Add Games, set DroidDeck to Include Orientation Launcher orientation diff --git a/app/src/test/java/com/droiddeck/launcher/ui/AppScaleTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/AppScaleTest.kt index 56a6db50b5..e3e741b65a 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/AppScaleTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/AppScaleTest.kt @@ -87,4 +87,12 @@ class AppScaleTest { assertEquals(540, base.screenHeightDp) assertEquals(320, base.densityDpi) } + + @Test fun homePageDefaultsToSteamAndIgnoresAnUnknownStoredPage() { + assertEquals(AppUiPrefs.HOME_PAGE_STEAM, AppUiPrefs.homePage(context)) + AppUiPrefs.setHomePage(context, AppUiPrefs.HOME_PAGE_APPS) + assertEquals(AppUiPrefs.HOME_PAGE_APPS, AppUiPrefs.homePage(context)) + context.getSharedPreferences("app-ui", Context.MODE_PRIVATE).edit().putString("home-page", "gone").commit() + assertEquals(AppUiPrefs.HOME_PAGE_STEAM, AppUiPrefs.homePage(context)) + } }