mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
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
This commit is contained in:
1 parent
bd022f04be
commit
52bf19ad8e
7 files changed
+62
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user