From ae3e25dbf973771073f01ec94647c6df3dc2ce66 Mon Sep 17 00:00:00 2001 From: qimiko <25387744+qimiko@users.noreply.github.com> Date: Sun, 18 Feb 2024 05:32:49 -0700 Subject: [PATCH] block launch on outdated game versions --- .../java/com/geode/launcher/MainActivity.kt | 57 +++++++++++-------- app/src/main/res/values/strings.xml | 1 + 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/geode/launcher/MainActivity.kt b/app/src/main/java/com/geode/launcher/MainActivity.kt index 07ee646e..c9160e1e 100644 --- a/app/src/main/java/com/geode/launcher/MainActivity.kt +++ b/app/src/main/java/com/geode/launcher/MainActivity.kt @@ -744,7 +744,6 @@ fun PlayButton( } } - if (showSafeModeDialog) { SafeModeDialog( onDismiss = { @@ -762,6 +761,20 @@ fun PlayButton( } } +@Composable +fun LaunchBlockedLabel(text: String) { + val context = LocalContext.current + + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text(text, modifier = Modifier.padding(12.dp)) + OutlinedButton(onClick = { onSettings(context) }) { + Icon(Icons.Filled.Settings, contentDescription = null) + Spacer(Modifier.size(ButtonDefaults.IconSpacing)) + Text(context.getString(R.string.launcher_settings)) + } + } +} + @Composable fun MainScreen( gdInstalled: Boolean = true, @@ -772,7 +785,6 @@ fun MainScreen( val context = LocalContext.current val shouldUpdate by PreferenceUtils.useBooleanPreference(PreferenceUtils.Key.UPDATE_AUTOMATICALLY) - val autoUpdateState by releaseViewModel.uiState.collectAsState() val geodeJustInstalled = (autoUpdateState as? ReleaseViewModel.ReleaseUIState.Finished) @@ -834,15 +846,23 @@ fun MainScreen( when { gdInstalled && geodeInstalled -> { - val stopLaunch = releaseViewModel.isInUpdate || hasError - PlayButton( - stopAutomaticLaunch = stopLaunch, - blockLaunch = releaseViewModel.isInUpdate, - onPlayGame = { safeMode -> - launchInSafeMode = safeMode - beginLaunch = true - }, - ) + val gdVersion = remember { + LaunchUtils.getGeometryDashVersionCode(context.packageManager) + } + + if (gdVersion < Constants.SUPPORTED_VERSION_CODE) { + LaunchBlockedLabel(stringResource(R.string.game_outdated)) + } else { + val stopLaunch = releaseViewModel.isInUpdate || hasError + PlayButton( + stopAutomaticLaunch = stopLaunch, + blockLaunch = releaseViewModel.isInUpdate, + onPlayGame = { safeMode -> + launchInSafeMode = safeMode + beginLaunch = true + }, + ) + } } gdInstalled -> { Text( @@ -871,20 +891,7 @@ fun MainScreen( } } } - else -> { - Text( - context.getString(R.string.game_not_found), - modifier = Modifier.padding(12.dp) - ) - OutlinedButton(onClick = { onSettings(context) }) { - Icon( - Icons.Filled.Settings, - contentDescription = context.getString(R.string.launcher_settings_icon_alt) - ) - Spacer(Modifier.size(ButtonDefaults.IconSpacing)) - Text(context.getString(R.string.launcher_settings)) - } - } + else -> LaunchBlockedLabel(stringResource(R.string.game_not_found)) } UpdateCard( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0342efc4..6757feb1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,6 +14,7 @@ settings icon retry icon Geode is not installed. + A Geometry Dash update is required. Geode is downloading. Please wait. Automatically launching game in %1$d second.