mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-22 00:42:38 +00:00
safe mode option
This commit is contained in:
2 files changed
+29
-6
No files matched your search
@@ -158,12 +158,13 @@ fun mapCancelReasonToInfo(cancelReason: LaunchViewModel.LaunchCancelReason): Lau
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun mapLaunchStatusToInfo(state: LaunchViewModel.LaunchUIState): LaunchStatusInfo {
|
fun mapLaunchStatusToInfo(state: LaunchViewModel.LaunchUIState, inSafeMode: Boolean = false): LaunchStatusInfo {
|
||||||
return when (state) {
|
return when (state) {
|
||||||
is LaunchViewModel.LaunchUIState.Initial,
|
is LaunchViewModel.LaunchUIState.Initial,
|
||||||
is LaunchViewModel.LaunchUIState.Working,
|
is LaunchViewModel.LaunchUIState.Working,
|
||||||
is LaunchViewModel.LaunchUIState.Ready -> LaunchStatusInfo(
|
is LaunchViewModel.LaunchUIState.Ready -> LaunchStatusInfo(
|
||||||
title = stringResource(R.string.launcher_starting_game)
|
title = stringResource(R.string.launcher_starting_game),
|
||||||
|
details = if (inSafeMode) stringResource(R.string.launcher_in_safe_mode) else null
|
||||||
)
|
)
|
||||||
is LaunchViewModel.LaunchUIState.UpdateCheck -> LaunchStatusInfo(
|
is LaunchViewModel.LaunchUIState.UpdateCheck -> LaunchStatusInfo(
|
||||||
title = stringResource(R.string.release_fetch_in_progress)
|
title = stringResource(R.string.release_fetch_in_progress)
|
||||||
@@ -255,11 +256,14 @@ fun LaunchProgressCard(
|
|||||||
uiState: LaunchViewModel.LaunchUIState,
|
uiState: LaunchViewModel.LaunchUIState,
|
||||||
crashInfo: LoadFailureInfo?,
|
crashInfo: LoadFailureInfo?,
|
||||||
onCancel: () -> Unit,
|
onCancel: () -> Unit,
|
||||||
onResume: () -> Unit,
|
onResume: (safeMode: Boolean) -> Unit,
|
||||||
onMore: () -> Unit,
|
onMore: () -> Unit,
|
||||||
|
safeModeEnabled: Boolean,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val status = mapLaunchStatusToInfo(uiState)
|
var showSafeModeDialog by remember { mutableStateOf(false) }
|
||||||
|
val status = mapLaunchStatusToInfo(uiState, safeModeEnabled)
|
||||||
|
|
||||||
Card(modifier = modifier) {
|
Card(modifier = modifier) {
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(16.dp), modifier = Modifier.padding(16.dp)) {
|
Column(verticalArrangement = Arrangement.spacedBy(16.dp), modifier = Modifier.padding(16.dp)) {
|
||||||
if (uiState is LaunchViewModel.LaunchUIState.Cancelled) {
|
if (uiState is LaunchViewModel.LaunchUIState.Cancelled) {
|
||||||
@@ -271,7 +275,9 @@ fun LaunchProgressCard(
|
|||||||
|
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
if (uiState.reason.allowsRetry()) {
|
if (uiState.reason.allowsRetry()) {
|
||||||
Button(onClick = onResume) {
|
LongPressButton(onClick = { onResume(false) }, onLongPress = {
|
||||||
|
showSafeModeDialog = true
|
||||||
|
}) {
|
||||||
Icon(
|
Icon(
|
||||||
Icons.Filled.Refresh,
|
Icons.Filled.Refresh,
|
||||||
contentDescription = null
|
contentDescription = null
|
||||||
@@ -301,6 +307,18 @@ fun LaunchProgressCard(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showSafeModeDialog) {
|
||||||
|
SafeModeDialog(
|
||||||
|
onDismiss = {
|
||||||
|
showSafeModeDialog = false
|
||||||
|
},
|
||||||
|
onLaunch = {
|
||||||
|
onResume(true)
|
||||||
|
showSafeModeDialog = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -336,6 +354,7 @@ fun AltMainScreen(
|
|||||||
val launchUIState by launchViewModel.uiState.collectAsState()
|
val launchUIState by launchViewModel.uiState.collectAsState()
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
var launchInSafeMode by remember { mutableStateOf(false) }
|
var launchInSafeMode by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
var showErrorInfo by remember { mutableStateOf(false) }
|
var showErrorInfo by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
@@ -355,7 +374,9 @@ fun AltMainScreen(
|
|||||||
launchViewModel.cancelLaunch()
|
launchViewModel.cancelLaunch()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onResume = {
|
onResume = { safeMode ->
|
||||||
|
launchInSafeMode = safeMode
|
||||||
|
|
||||||
launchViewModel.clearCrashInfo()
|
launchViewModel.clearCrashInfo()
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
launchViewModel.beginLaunchFlow()
|
launchViewModel.beginLaunchFlow()
|
||||||
@@ -364,6 +385,7 @@ fun AltMainScreen(
|
|||||||
onMore = {
|
onMore = {
|
||||||
showErrorInfo = true
|
showErrorInfo = true
|
||||||
},
|
},
|
||||||
|
safeModeEnabled = launchInSafeMode,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
.offset(y = 90.dp)
|
.offset(y = 90.dp)
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
<string name="launcher_cancelled_error">Could not start Geode.</string>
|
<string name="launcher_cancelled_error">Could not start Geode.</string>
|
||||||
<string name="launcher_cancelled_outdated">A Geometry Dash update is required.</string>
|
<string name="launcher_cancelled_outdated">A Geometry Dash update is required.</string>
|
||||||
<string name="launcher_cancelled_restart">Restart</string>
|
<string name="launcher_cancelled_restart">Restart</string>
|
||||||
|
<string name="launcher_in_safe_mode">Starting in safe mode…</string>
|
||||||
|
|
||||||
<!-- Updater strings -->
|
<!-- Updater strings -->
|
||||||
<string name="release_fetch_failed">Update failed.\n%1$s</string>
|
<string name="release_fetch_failed">Update failed.\n%1$s</string>
|
||||||
|
|||||||
Reference in new issue
Block a user