forked from geode-sdk/android-launcher
crash ui tweaks
This commit is contained in:
2 files changed
+36
-21
No files matched your search
@@ -619,6 +619,32 @@ fun onSettings(context: Context) {
|
||||
context.startActivity(launchIntent)
|
||||
}
|
||||
|
||||
suspend fun showFailureSnackbar(
|
||||
context: Context,
|
||||
loadFailureInfo: LoadFailureInfo,
|
||||
snackbarHostState: SnackbarHostState,
|
||||
onActionPerformed: () -> Unit
|
||||
) {
|
||||
val message = if (loadFailureInfo.title == LaunchUtils.LauncherError.CRASHED) {
|
||||
context.getString(R.string.launcher_crashed)
|
||||
} else {
|
||||
context.getString(R.string.launcher_failed_to_load)
|
||||
}
|
||||
|
||||
val res = snackbarHostState.showSnackbar(
|
||||
message = message,
|
||||
actionLabel = context.getString(R.string.launcher_error_more),
|
||||
duration = SnackbarDuration.Indefinite,
|
||||
)
|
||||
|
||||
when (res) {
|
||||
SnackbarResult.ActionPerformed -> {
|
||||
onActionPerformed()
|
||||
}
|
||||
SnackbarResult.Dismissed -> {}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MainScreen(
|
||||
gdInstalled: Boolean = true,
|
||||
@@ -654,27 +680,16 @@ fun MainScreen(
|
||||
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
|
||||
var showErrorInfo by remember { mutableStateOf(false) }
|
||||
// automatically show load failed dialog (but not crash)
|
||||
var showErrorInfo by remember { mutableStateOf(
|
||||
loadFailureInfo != null && loadFailureInfo.title != LaunchUtils.LauncherError.CRASHED
|
||||
)}
|
||||
|
||||
val hasError = loadFailureInfo != null
|
||||
LaunchedEffect(hasError) {
|
||||
if (loadFailureInfo != null) {
|
||||
val message = if (loadFailureInfo.title == LaunchUtils.LauncherError.CRASHED) {
|
||||
context.getString(R.string.launcher_crashed)
|
||||
} else {
|
||||
context.getString(R.string.launcher_failed_to_load)
|
||||
}
|
||||
|
||||
val res = snackbarHostState.showSnackbar(
|
||||
message = message,
|
||||
actionLabel = context.getString(R.string.launcher_error_more),
|
||||
duration = SnackbarDuration.Indefinite,
|
||||
)
|
||||
|
||||
when (res) {
|
||||
SnackbarResult.ActionPerformed -> {
|
||||
showErrorInfo = true
|
||||
}
|
||||
SnackbarResult.Dismissed -> {}
|
||||
LaunchedEffect(hasError, showErrorInfo) {
|
||||
if (!showErrorInfo && loadFailureInfo != null) {
|
||||
showFailureSnackbar(context, loadFailureInfo, snackbarHostState) {
|
||||
showErrorInfo = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<string name="safe_mode_enable_description">Safe mode disables loading of all mods, allowing one to remove problematic mods or diagnose crashes. If you\'re not experiencing issues with Geode, you should probably not be using safe mode.</string>
|
||||
<string name="launcher_failed_to_load">Geode failed to load.</string>
|
||||
<string name="launcher_crashed">Geode crashed.</string>
|
||||
<string name="launcher_error_more">Learn more</string>
|
||||
<string name="launcher_error_more">Help</string>
|
||||
<string name="launcher_error_details">Error details</string>
|
||||
<string name="launcher_error_view_logs">View logs</string>
|
||||
<string name="launcher_error_copy_error_alt">Copy</string>
|
||||
|
||||
Reference in new issue
Block a user