mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-11 00:49:33 +00:00
remove unused layout edit preference, read layout edit errors immediately
This commit is contained in:
parent
682a4ae911
commit
5ccc117ae1
2 changed files with 1 additions and 62 deletions
|
@ -54,7 +54,6 @@ fun LayoutEditDialog(
|
||||||
|| isNameValid(LayoutUtilsCustom.getCustomLayoutName(displayNameValue.text))
|
|| isNameValid(LayoutUtilsCustom.getCustomLayoutName(displayNameValue.text))
|
||||||
)
|
)
|
||||||
|
|
||||||
val keyboardHeight = WindowInsets.ime.getBottom(LocalDensity.current)
|
|
||||||
TextInputDialog(
|
TextInputDialog(
|
||||||
onDismissRequest = {
|
onDismissRequest = {
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
|
@ -85,10 +84,10 @@ fun LayoutEditDialog(
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
job = scope.launch {
|
job = scope.launch {
|
||||||
delay(3000)
|
|
||||||
val message = Log.getLog(10)
|
val message = Log.getLog(10)
|
||||||
.lastOrNull { it.tag == "LayoutUtilsCustom" }?.message
|
.lastOrNull { it.tag == "LayoutUtilsCustom" }?.message
|
||||||
?.split("\n")?.take(2)?.joinToString("\n")
|
?.split("\n")?.take(2)?.joinToString("\n")
|
||||||
|
delay(3000)
|
||||||
Toast.makeText(ctx, ctx.getString(R.string.layout_error, message), Toast.LENGTH_LONG).show()
|
Toast.makeText(ctx, ctx.getString(R.string.layout_error, message), Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
package helium314.keyboard.settings.preferences
|
|
||||||
/*
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
|
||||||
import helium314.keyboard.latin.utils.CUSTOM_LAYOUT_PREFIX
|
|
||||||
import helium314.keyboard.latin.utils.getCustomLayoutFiles
|
|
||||||
import helium314.keyboard.settings.Setting
|
|
||||||
import helium314.keyboard.settings.dialogs.LayoutEditDialog
|
|
||||||
import helium314.keyboard.settings.dialogs.ListPickerDialog
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun LayoutEditPreference(
|
|
||||||
setting: Setting,
|
|
||||||
items: List<String>,
|
|
||||||
getItemName: @Composable (String) -> String,
|
|
||||||
getDefaultLayout: @Composable (String?) -> String?,
|
|
||||||
) {
|
|
||||||
var showDialog by rememberSaveable { mutableStateOf(false) }
|
|
||||||
val ctx = LocalContext.current
|
|
||||||
var layout: String? by rememberSaveable { mutableStateOf(null) }
|
|
||||||
Preference(
|
|
||||||
name = setting.title,
|
|
||||||
onClick = { showDialog = true }
|
|
||||||
)
|
|
||||||
if (showDialog) {
|
|
||||||
ListPickerDialog(
|
|
||||||
onDismissRequest = { showDialog = false },
|
|
||||||
showRadioButtons = false,
|
|
||||||
confirmImmediately = true,
|
|
||||||
items = items,
|
|
||||||
getItemName = getItemName,
|
|
||||||
onItemSelected = { layout = it },
|
|
||||||
title = { Text(setting.title) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (layout != null) {
|
|
||||||
val customLayoutName = getCustomLayoutFiles(ctx).firstOrNull {
|
|
||||||
if (layout!!.startsWith(CUSTOM_LAYOUT_PREFIX))
|
|
||||||
it.name.startsWith("$layout.")
|
|
||||||
else it.name.startsWith("$CUSTOM_LAYOUT_PREFIX$layout.")
|
|
||||||
}?.name
|
|
||||||
// todo: never set originalLayout null if custom layout file does not exist!
|
|
||||||
val originalLayout = if (customLayoutName != null) null
|
|
||||||
else getDefaultLayout(layout)?.let { ctx.assets.open("layouts" + File.separator + it).reader().readText() }
|
|
||||||
LayoutEditDialog(
|
|
||||||
layoutName = customLayoutName ?: "$CUSTOM_LAYOUT_PREFIX$layout.",
|
|
||||||
startContent = originalLayout,
|
|
||||||
displayName = getItemName(layout!!),
|
|
||||||
onDismissRequest = { layout = null }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
Loading…
Add table
Add a link
Reference in a new issue