mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-21 16:32:39 +00:00
fix update warning dismiss
This commit is contained in:
1 file changed
+43
-42
@@ -234,15 +234,13 @@ fun LoadFailedDialog(returnTitle: String, returnMessage: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UpdateWarning(inSafeMode: Boolean = false) {
|
fun UpdateWarning(inSafeMode: Boolean = false, onDismiss: () -> Unit) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val packageManager = context.packageManager
|
val packageManager = context.packageManager
|
||||||
|
|
||||||
val gdVersionCode = remember { LaunchUtils.getGeometryDashVersionCode(packageManager) }
|
val gdVersionCode = remember { LaunchUtils.getGeometryDashVersionCode(packageManager) }
|
||||||
val gdVersionString = remember { LaunchUtils.getGeometryDashVersionString(packageManager) }
|
val gdVersionString = remember { LaunchUtils.getGeometryDashVersionString(packageManager) }
|
||||||
|
|
||||||
var showUpdateWarning by remember { mutableStateOf(true) }
|
|
||||||
|
|
||||||
var lastDismissedVersion by PreferenceUtils.useLongPreference(
|
var lastDismissedVersion by PreferenceUtils.useLongPreference(
|
||||||
preferenceKey = PreferenceUtils.Key.DISMISSED_GJ_UPDATE
|
preferenceKey = PreferenceUtils.Key.DISMISSED_GJ_UPDATE
|
||||||
)
|
)
|
||||||
@@ -251,46 +249,44 @@ fun UpdateWarning(inSafeMode: Boolean = false) {
|
|||||||
val shouldDismiss = canDismissRelease && gdVersionCode == lastDismissedVersion
|
val shouldDismiss = canDismissRelease && gdVersionCode == lastDismissedVersion
|
||||||
|
|
||||||
if (gdVersionCode != Constants.SUPPORTED_VERSION_CODE && !shouldDismiss) {
|
if (gdVersionCode != Constants.SUPPORTED_VERSION_CODE && !shouldDismiss) {
|
||||||
if (showUpdateWarning) {
|
AlertDialog(
|
||||||
AlertDialog(
|
icon = {
|
||||||
icon = {
|
Icon(
|
||||||
Icon(
|
Icons.Filled.Warning,
|
||||||
Icons.Filled.Warning,
|
contentDescription = stringResource(R.string.launcher_warning_icon_alt)
|
||||||
contentDescription = stringResource(R.string.launcher_warning_icon_alt)
|
)
|
||||||
)
|
},
|
||||||
},
|
title = {
|
||||||
title = {
|
Text(stringResource(R.string.launcher_unsupported_version_title))
|
||||||
Text(stringResource(R.string.launcher_unsupported_version_title))
|
},
|
||||||
},
|
text = {
|
||||||
text = {
|
val message = if (gdVersionCode >= Constants.SUPPORTED_VERSION_CODE) {
|
||||||
val message = if (gdVersionCode >= Constants.SUPPORTED_VERSION_CODE) {
|
R.string.launcher_unsupported_version_description
|
||||||
R.string.launcher_unsupported_version_description
|
} else {
|
||||||
} else {
|
R.string.launcher_outdated_version_description
|
||||||
R.string.launcher_outdated_version_description
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Text(stringResource(
|
Text(stringResource(
|
||||||
message, gdVersionString, Constants.SUPPORTED_VERSION_STRING
|
message, gdVersionString, Constants.SUPPORTED_VERSION_STRING
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
showUpdateWarning = false
|
onDismiss()
|
||||||
lastDismissedVersion = gdVersionCode
|
lastDismissedVersion = gdVersionCode
|
||||||
|
|
||||||
onLaunch(context, inSafeMode)
|
onLaunch(context, inSafeMode)
|
||||||
}) {
|
}) {
|
||||||
Text(stringResource(R.string.message_box_accept))
|
Text(stringResource(R.string.message_box_accept))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(onClick = { showUpdateWarning = false }) {
|
TextButton(onClick = { onDismiss() }) {
|
||||||
Text(stringResource(R.string.message_box_cancel))
|
Text(stringResource(R.string.message_box_cancel))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDismissRequest = { showUpdateWarning = false }
|
onDismissRequest = { onDismiss() }
|
||||||
)
|
)
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LaunchedEffect(gdVersionCode) {
|
LaunchedEffect(gdVersionCode) {
|
||||||
onLaunch(context, inSafeMode)
|
onLaunch(context, inSafeMode)
|
||||||
@@ -621,7 +617,10 @@ fun MainScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (beginLaunch) {
|
if (beginLaunch) {
|
||||||
UpdateWarning(launchInSafeMode)
|
UpdateWarning(launchInSafeMode) {
|
||||||
|
beginLaunch = false
|
||||||
|
launchInSafeMode = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showSafeModeDialog) {
|
if (showSafeModeDialog) {
|
||||||
@@ -632,6 +631,8 @@ fun MainScreen(
|
|||||||
onLaunch = {
|
onLaunch = {
|
||||||
launchInSafeMode = true
|
launchInSafeMode = true
|
||||||
beginLaunch = true
|
beginLaunch = true
|
||||||
|
|
||||||
|
showSafeModeDialog = false
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user