Skip to content

Commit ae3e25d

Browse files
committed
block launch on outdated game versions
1 parent 189350c commit ae3e25d

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

app/src/main/java/com/geode/launcher/MainActivity.kt

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,6 @@ fun PlayButton(
744744
}
745745
}
746746

747-
748747
if (showSafeModeDialog) {
749748
SafeModeDialog(
750749
onDismiss = {
@@ -762,6 +761,20 @@ fun PlayButton(
762761
}
763762
}
764763

764+
@Composable
765+
fun LaunchBlockedLabel(text: String) {
766+
val context = LocalContext.current
767+
768+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
769+
Text(text, modifier = Modifier.padding(12.dp))
770+
OutlinedButton(onClick = { onSettings(context) }) {
771+
Icon(Icons.Filled.Settings, contentDescription = null)
772+
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
773+
Text(context.getString(R.string.launcher_settings))
774+
}
775+
}
776+
}
777+
765778
@Composable
766779
fun MainScreen(
767780
gdInstalled: Boolean = true,
@@ -772,7 +785,6 @@ fun MainScreen(
772785
val context = LocalContext.current
773786

774787
val shouldUpdate by PreferenceUtils.useBooleanPreference(PreferenceUtils.Key.UPDATE_AUTOMATICALLY)
775-
776788
val autoUpdateState by releaseViewModel.uiState.collectAsState()
777789

778790
val geodeJustInstalled = (autoUpdateState as? ReleaseViewModel.ReleaseUIState.Finished)
@@ -834,15 +846,23 @@ fun MainScreen(
834846

835847
when {
836848
gdInstalled && geodeInstalled -> {
837-
val stopLaunch = releaseViewModel.isInUpdate || hasError
838-
PlayButton(
839-
stopAutomaticLaunch = stopLaunch,
840-
blockLaunch = releaseViewModel.isInUpdate,
841-
onPlayGame = { safeMode ->
842-
launchInSafeMode = safeMode
843-
beginLaunch = true
844-
},
845-
)
849+
val gdVersion = remember {
850+
LaunchUtils.getGeometryDashVersionCode(context.packageManager)
851+
}
852+
853+
if (gdVersion < Constants.SUPPORTED_VERSION_CODE) {
854+
LaunchBlockedLabel(stringResource(R.string.game_outdated))
855+
} else {
856+
val stopLaunch = releaseViewModel.isInUpdate || hasError
857+
PlayButton(
858+
stopAutomaticLaunch = stopLaunch,
859+
blockLaunch = releaseViewModel.isInUpdate,
860+
onPlayGame = { safeMode ->
861+
launchInSafeMode = safeMode
862+
beginLaunch = true
863+
},
864+
)
865+
}
846866
}
847867
gdInstalled -> {
848868
Text(
@@ -871,20 +891,7 @@ fun MainScreen(
871891
}
872892
}
873893
}
874-
else -> {
875-
Text(
876-
context.getString(R.string.game_not_found),
877-
modifier = Modifier.padding(12.dp)
878-
)
879-
OutlinedButton(onClick = { onSettings(context) }) {
880-
Icon(
881-
Icons.Filled.Settings,
882-
contentDescription = context.getString(R.string.launcher_settings_icon_alt)
883-
)
884-
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
885-
Text(context.getString(R.string.launcher_settings))
886-
}
887-
}
894+
else -> LaunchBlockedLabel(stringResource(R.string.game_not_found))
888895
}
889896

890897
UpdateCard(

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<string name="launcher_settings_icon_alt">settings icon</string>
1515
<string name="launcher_retry_icon_alt">retry icon</string>
1616
<string name="geode_download_title">Geode is not installed.</string>
17+
<string name="game_outdated">A Geometry Dash update is required.</string>
1718
<string name="geode_download_description">Geode is downloading. Please wait.</string>
1819
<plurals name="automatically_load_countdown">
1920
<item quantity="one">Automatically launching game in %1$d second.</item>

0 commit comments

Comments
 (0)