mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-08 15:47:43 +00:00
fix unexpected dialog dismisses
This commit is contained in:
parent
b31d6d0051
commit
2700c3428a
9 changed files with 9 additions and 4 deletions
|
@ -121,6 +121,7 @@ fun CustomizeIconsDialog(
|
||||||
},
|
},
|
||||||
neutralButtonText = if (customIconNames(prefs).contains(iconName)) stringResource(R.string.button_default) else null,
|
neutralButtonText = if (customIconNames(prefs).contains(iconName)) stringResource(R.string.button_default) else null,
|
||||||
onNeutral = {
|
onNeutral = {
|
||||||
|
showIconDialog = null
|
||||||
runCatching {
|
runCatching {
|
||||||
val icons2 = customIconNames(prefs).toMutableMap()
|
val icons2 = customIconNames(prefs).toMutableMap()
|
||||||
icons2.remove(iconName)
|
icons2.remove(iconName)
|
||||||
|
|
|
@ -52,7 +52,7 @@ fun <T: Any> ReorderDialog(
|
||||||
ThreeButtonAlertDialog(
|
ThreeButtonAlertDialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
onConfirmed = { onConfirmed(reorderableItems) },
|
onConfirmed = { onConfirmed(reorderableItems) },
|
||||||
onNeutral = onNeutral,
|
onNeutral = { onDismissRequest(); onNeutral() },
|
||||||
neutralButtonText = neutralButtonText,
|
neutralButtonText = neutralButtonText,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
title = title,
|
title = title,
|
||||||
|
|
|
@ -36,7 +36,7 @@ fun SliderDialog(
|
||||||
ThreeButtonAlertDialog(
|
ThreeButtonAlertDialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
neutralButtonText = if (showDefault) stringResource(R.string.button_default) else null,
|
neutralButtonText = if (showDefault) stringResource(R.string.button_default) else null,
|
||||||
onNeutral = onDefault,
|
onNeutral = { onDismissRequest(); onDefault() },
|
||||||
onConfirmed = { onDone(sliderPosition) },
|
onConfirmed = { onDone(sliderPosition) },
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
title = title,
|
title = title,
|
||||||
|
|
|
@ -61,7 +61,7 @@ fun TextInputDialog(
|
||||||
confirmButtonText = confirmButtonText,
|
confirmButtonText = confirmButtonText,
|
||||||
checkOk = { checkTextValid(value.text) },
|
checkOk = { checkTextValid(value.text) },
|
||||||
neutralButtonText = neutralButtonText,
|
neutralButtonText = neutralButtonText,
|
||||||
onNeutral = onNeutral,
|
onNeutral = { onDismissRequest(); onNeutral() },
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
title = title,
|
title = title,
|
||||||
text = {
|
text = {
|
||||||
|
|
|
@ -74,7 +74,7 @@ fun ThreeButtonAlertDialog(
|
||||||
Row {
|
Row {
|
||||||
if (neutralButtonText != null)
|
if (neutralButtonText != null)
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = { onDismissRequest(); onNeutral() }
|
onClick = onNeutral
|
||||||
) { Text(neutralButtonText) }
|
) { Text(neutralButtonText) }
|
||||||
Spacer(modifier.weight(1f))
|
Spacer(modifier.weight(1f))
|
||||||
TextButton(onClick = onDismissRequest) { Text(cancelButtonText) }
|
TextButton(onClick = onDismissRequest) { Text(cancelButtonText) }
|
||||||
|
|
|
@ -114,6 +114,7 @@ private fun ToolbarKeyCustomizer(
|
||||||
stringResource(R.string.button_default)
|
stringResource(R.string.button_default)
|
||||||
else null,
|
else null,
|
||||||
onNeutral = {
|
onNeutral = {
|
||||||
|
onDismissRequest()
|
||||||
val keys = readCustomKeyCodes(prefs).toMutableMap()
|
val keys = readCustomKeyCodes(prefs).toMutableMap()
|
||||||
keys.remove(key.name)
|
keys.remove(key.name)
|
||||||
prefs.edit().putString(Settings.PREF_TOOLBAR_CUSTOM_KEY_CODES, Json.encodeToString(keys)).apply()
|
prefs.edit().putString(Settings.PREF_TOOLBAR_CUSTOM_KEY_CODES, Json.encodeToString(keys)).apply()
|
||||||
|
|
|
@ -193,6 +193,7 @@ fun BackupRestorePreference(setting: Setting) {
|
||||||
confirmButtonText = stringResource(R.string.button_backup),
|
confirmButtonText = stringResource(R.string.button_backup),
|
||||||
neutralButtonText = stringResource(R.string.button_restore),
|
neutralButtonText = stringResource(R.string.button_restore),
|
||||||
onNeutral = {
|
onNeutral = {
|
||||||
|
showDialog = false
|
||||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
.setType("application/zip")
|
.setType("application/zip")
|
||||||
|
|
|
@ -63,6 +63,7 @@ fun CustomFontPreference(setting: Setting) {
|
||||||
onDismissRequest = { showDialog = false },
|
onDismissRequest = { showDialog = false },
|
||||||
onConfirmed = { launcher.launch(intent) },
|
onConfirmed = { launcher.launch(intent) },
|
||||||
onNeutral = {
|
onNeutral = {
|
||||||
|
showDialog = false
|
||||||
fontFile.delete()
|
fontFile.delete()
|
||||||
Settings.clearCachedTypeface()
|
Settings.clearCachedTypeface()
|
||||||
keyboardNeedsReload = true
|
keyboardNeedsReload = true
|
||||||
|
|
|
@ -82,6 +82,7 @@ fun LoadGestureLibPreference(setting: Setting) {
|
||||||
ConfirmationDialog(
|
ConfirmationDialog(
|
||||||
onDismissRequest = { showDialog = false },
|
onDismissRequest = { showDialog = false },
|
||||||
onConfirmed = {
|
onConfirmed = {
|
||||||
|
showDialog = false
|
||||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
.setType("application/octet-stream")
|
.setType("application/octet-stream")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue