make popup order prefs shorter

This commit is contained in:
Helium314 2025-02-16 22:45:48 +01:00
parent 56c7748dff
commit 12f1e20d9f
5 changed files with 22 additions and 12 deletions

View file

@ -13,8 +13,8 @@ android {
applicationId = "helium314.keyboard"
minSdk = 21
targetSdk = 34
versionCode = 2307
versionName = "2.3+dev6"
versionCode = 2308
versionName = "2.3+dev7"
ndk {
abiFilters.clear()
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64"))

View file

@ -447,6 +447,13 @@ fun checkVersionUpgrade(context: Context) {
prefs.edit().putString(key, new).apply()
}
}
if (oldVersion <= 2307) {
prefs.all.keys.forEach {
if (!it.startsWith(Settings.PREF_POPUP_KEYS_ORDER) && !it.startsWith(Settings.PREF_POPUP_KEYS_LABELS_ORDER))
return@forEach
prefs.edit().putString(it, prefs.getString(it, "")!!.replace("popup_keys_", "")).apply()
}
}
upgradeToolbarPrefs(prefs)
LayoutUtilsCustom.onLayoutFileChanged() // just to be sure
prefs.edit { putInt(Settings.PREF_VERSION_CODE, BuildConfig.VERSION_CODE) }

View file

@ -8,6 +8,7 @@ import android.view.Gravity
import helium314.keyboard.keyboard.KeyboardTheme
import helium314.keyboard.latin.BuildConfig
import helium314.keyboard.latin.common.Constants.Separators
import helium314.keyboard.latin.common.Constants.Subtype.ExtraValue
import helium314.keyboard.latin.utils.JniUtils
import helium314.keyboard.latin.utils.LayoutType
import helium314.keyboard.latin.utils.POPUP_KEYS_LABEL_DEFAULT
@ -73,9 +74,9 @@ object Defaults {
const val PREF_LANGUAGE_SWITCH_KEY = "internal"
const val PREF_SHOW_EMOJI_KEY = false
const val PREF_VARIABLE_TOOLBAR_DIRECTION = true
const val PREF_ADDITIONAL_SUBTYPES = "de${Separators.SET}qwerty${Separators.SET}AsciiCapable${Separators.SETS}" +
"fr${Separators.SET}qwertz${Separators.SET}AsciiCapable${Separators.SETS}" +
"hu${Separators.SET}qwerty${Separators.SET}AsciiCapable"
const val PREF_ADDITIONAL_SUBTYPES = "de${Separators.SET}${ExtraValue.KEYBOARD_LAYOUT_SET}=qwerty${Separators.SETS}" +
"fr${Separators.SET}${ExtraValue.KEYBOARD_LAYOUT_SET}=qwertz${Separators.SETS}" +
"hu${Separators.SET}${ExtraValue.KEYBOARD_LAYOUT_SET}=qwerty"
const val PREF_ENABLE_SPLIT_KEYBOARD = false
const val PREF_ENABLE_SPLIT_KEYBOARD_LANDSCAPE = false
const val PREF_SPLIT_SPACER_SCALE = SettingsValues.DEFAULT_SIZE_SCALE

View file

@ -9,11 +9,11 @@ import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyLabel.rtlL
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.PopupSet
import helium314.keyboard.latin.common.Constants.Separators
const val POPUP_KEYS_NUMBER = "popup_keys_number"
private const val POPUP_KEYS_LANGUAGE_PRIORITY = "popup_keys_language_priority"
const val POPUP_KEYS_LAYOUT = "popup_keys_layout"
private const val POPUP_KEYS_SYMBOLS = "popup_keys_symbols"
private const val POPUP_KEYS_LANGUAGE = "popup_keys_language"
const val POPUP_KEYS_NUMBER = "number"
private const val POPUP_KEYS_LANGUAGE_PRIORITY = "language_priority"
const val POPUP_KEYS_LAYOUT = "layout"
private const val POPUP_KEYS_SYMBOLS = "symbols"
private const val POPUP_KEYS_LANGUAGE = "language"
const val POPUP_KEYS_LABEL_DEFAULT = POPUP_KEYS_NUMBER + Separators.KV + true + Separators.ENTRY + POPUP_KEYS_LANGUAGE_PRIORITY +
Separators.KV + false + Separators.ENTRY + POPUP_KEYS_LAYOUT + Separators.KV + true + Separators.ENTRY +
POPUP_KEYS_SYMBOLS + Separators.KV + true + Separators.ENTRY + POPUP_KEYS_LANGUAGE + Separators.KV + false

View file

@ -34,7 +34,7 @@ fun ReorderSwitchPreference(setting: Setting, default: String) {
if (showDialog) {
val ctx = LocalContext.current
val prefs = ctx.prefs()
val items = prefs.getString(setting.key, default)!!.split(Separators.ENTRY).mapTo(ArrayList()) {
val items = prefs.getString(setting.key, default)!!.split(Separators.ENTRY).map {
val both = it.split(Separators.KV)
KeyAndState(both.first(), both.last().toBoolean())
}
@ -54,7 +54,9 @@ fun ReorderSwitchPreference(setting: Setting, default: String) {
Row(verticalAlignment = Alignment.CenterVertically) {
KeyboardIconsSet.instance.GetIcon(item.name)
val text = item.name.lowercase().getStringResourceOrName("", ctx)
Text(text, Modifier.weight(1f))
val actualText = if (text != item.name.lowercase()) text
else item.name.lowercase().getStringResourceOrName("popup_keys_", ctx)
Text(actualText, Modifier.weight(1f))
Switch(
checked = checked,
onCheckedChange = { item.state = it; checked = it }