mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-20 14:19:08 +00:00
use simplified way of setting prefs
also allows for adding animation in a single place instead of at each pref
This commit is contained in:
parent
0d9619f562
commit
a7f14c1229
12 changed files with 322 additions and 387 deletions
|
@ -18,6 +18,7 @@ import androidx.compose.material3.Icon
|
|||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -48,29 +49,21 @@ import helium314.keyboard.settings.dialogs.ReorderDialog
|
|||
import helium314.keyboard.settings.dialogs.SliderDialog
|
||||
import helium314.keyboard.settings.screens.GetIcon
|
||||
|
||||
// taken from StreetComplete (and a bit SCEE)
|
||||
// partially taken from StreetComplete / SCEE
|
||||
|
||||
@Composable
|
||||
fun PreferenceCategory(
|
||||
title: String?,
|
||||
title: String,
|
||||
modifier: Modifier = Modifier,
|
||||
content: @Composable ColumnScope.() -> Unit
|
||||
) {
|
||||
Column {
|
||||
HorizontalDivider()
|
||||
if (title != null) {
|
||||
Text(
|
||||
text = title,
|
||||
modifier = modifier.padding(top = 12.dp, start = 16.dp, end = 8.dp, bottom = 8.dp),
|
||||
color = MaterialTheme.colorScheme.secondary,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
}
|
||||
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyLarge) {
|
||||
Column {
|
||||
content()
|
||||
}
|
||||
}
|
||||
Text(
|
||||
text = title,
|
||||
modifier = modifier.padding(top = 12.dp, start = 16.dp, end = 8.dp, bottom = 8.dp),
|
||||
color = MaterialTheme.colorScheme.secondary,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +88,7 @@ fun Preference(
|
|||
if (icon != null)
|
||||
Icon(painterResource(icon), name, modifier = Modifier.size(36.dp))
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(text = name)
|
||||
Text(text = name, style = MaterialTheme.typography.bodyLarge)
|
||||
if (description != null) {
|
||||
CompositionLocalProvider(
|
||||
LocalTextStyle provides MaterialTheme.typography.bodyMedium,
|
||||
|
@ -304,46 +297,6 @@ fun ReorderSwitchPreference(def: PrefDef, default: String) {
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ToolbarKeyReorderDialog(
|
||||
prefKey: String,
|
||||
default: String,
|
||||
title: String,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
val ctx = LocalContext.current
|
||||
val prefs = ctx.prefs()
|
||||
val items = prefs.getString(prefKey, default)!!.split(";").mapTo(ArrayList()) {
|
||||
val both = it.split(",")
|
||||
KeyAndState(both.first(), both.last().toBoolean())
|
||||
}
|
||||
ReorderDialog(
|
||||
onConfirmed = { reorderedItems ->
|
||||
val value = reorderedItems.joinToString(";") { it.name + "," + it.state }
|
||||
prefs.edit().putString(prefKey, value).apply()
|
||||
keyboardNeedsReload = true
|
||||
},
|
||||
onDismissRequest = onDismiss,
|
||||
onNeutral = { prefs.edit().remove(prefKey).apply() },
|
||||
neutralButtonText = if (prefs.contains(prefKey)) stringResource(R.string.button_default) else null,
|
||||
items = items,
|
||||
title = { Text(title) },
|
||||
displayItem = { item ->
|
||||
var checked by remember { mutableStateOf(item.state) }
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
KeyboardIconsSet.instance.GetIcon(item.name)
|
||||
val text = item.name.lowercase().getStringResourceOrName("", ctx)
|
||||
Text(text, Modifier.weight(1f))
|
||||
Switch(
|
||||
checked = checked,
|
||||
onCheckedChange = { item.state = it; checked = it }
|
||||
)
|
||||
}
|
||||
},
|
||||
getKey = { it.name }
|
||||
)
|
||||
}
|
||||
|
||||
private class KeyAndState(var name: String, var state: Boolean)
|
||||
|
||||
private fun <T: Any> getPrefOfType(prefs: SharedPreferences, key: String, default: T): T =
|
||||
|
@ -371,59 +324,62 @@ private fun <T: Any> putPrefOfType(prefs: SharedPreferences, key: String, value:
|
|||
@Preview
|
||||
@Composable
|
||||
private fun PreferencePreview() {
|
||||
PreferenceCategory("Preference Category") {
|
||||
Preference(
|
||||
name = "Preference",
|
||||
onClick = {},
|
||||
)
|
||||
Preference(
|
||||
name = "Preference with icon",
|
||||
onClick = {},
|
||||
icon = R.drawable.ic_settings_about_foreground
|
||||
)
|
||||
SliderPreference(
|
||||
name = "SliderPreference",
|
||||
pref = "",
|
||||
default = 1,
|
||||
description = { it.toString() },
|
||||
range = -5f..5f
|
||||
)
|
||||
Preference(
|
||||
name = "Preference with icon and description",
|
||||
description = "some text",
|
||||
onClick = {},
|
||||
icon = R.drawable.ic_settings_about_foreground
|
||||
)
|
||||
Preference(
|
||||
name = "Preference with switch",
|
||||
onClick = {}
|
||||
) {
|
||||
Switch(checked = true, onCheckedChange = {})
|
||||
}
|
||||
SwitchPreference(
|
||||
name = "SwitchPreference",
|
||||
pref = "none",
|
||||
default = true
|
||||
)
|
||||
Preference(
|
||||
name = "Preference",
|
||||
onClick = {},
|
||||
description = "A long description which may actually be several lines long, so it should wrap."
|
||||
) {
|
||||
Icon(painterResource(R.drawable.ic_arrow_left), null)
|
||||
}
|
||||
Preference(
|
||||
name = "Long preference name that wraps",
|
||||
onClick = {},
|
||||
) {
|
||||
Text("Long preference value")
|
||||
}
|
||||
Preference(
|
||||
name = "Long preference name 2",
|
||||
onClick = {},
|
||||
description = "hello I am description"
|
||||
) {
|
||||
Text("Long preference value")
|
||||
Surface {
|
||||
Column {
|
||||
PreferenceCategory("Preference Category")
|
||||
Preference(
|
||||
name = "Preference",
|
||||
onClick = {},
|
||||
)
|
||||
Preference(
|
||||
name = "Preference with icon",
|
||||
onClick = {},
|
||||
icon = R.drawable.ic_settings_about_foreground
|
||||
)
|
||||
SliderPreference(
|
||||
name = "SliderPreference",
|
||||
pref = "",
|
||||
default = 1,
|
||||
description = { it.toString() },
|
||||
range = -5f..5f
|
||||
)
|
||||
Preference(
|
||||
name = "Preference with icon and description",
|
||||
description = "some text",
|
||||
onClick = {},
|
||||
icon = R.drawable.ic_settings_about_foreground
|
||||
)
|
||||
Preference(
|
||||
name = "Preference with switch",
|
||||
onClick = {}
|
||||
) {
|
||||
Switch(checked = true, onCheckedChange = {})
|
||||
}
|
||||
SwitchPreference(
|
||||
name = "SwitchPreference",
|
||||
pref = "none",
|
||||
default = true
|
||||
)
|
||||
Preference(
|
||||
name = "Preference",
|
||||
onClick = {},
|
||||
description = "A long description which may actually be several lines long, so it should wrap."
|
||||
) {
|
||||
Icon(painterResource(R.drawable.ic_arrow_left), null)
|
||||
}
|
||||
Preference(
|
||||
name = "Long preference name that wraps",
|
||||
onClick = {},
|
||||
) {
|
||||
Text("Long preference value")
|
||||
}
|
||||
Preference(
|
||||
name = "Long preference name 2",
|
||||
onClick = {},
|
||||
description = "hello I am description"
|
||||
) {
|
||||
Text("Long preference value")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package helium314.keyboard.settings
|
|||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
|
@ -15,8 +16,6 @@ import androidx.compose.foundation.layout.safeDrawing
|
|||
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
|
@ -49,12 +48,26 @@ import helium314.keyboard.latin.R
|
|||
fun SearchPrefScreen(
|
||||
onClickBack: () -> Unit,
|
||||
title: String,
|
||||
content: @Composable ColumnScope.() -> Unit
|
||||
prefs: List<Any>,
|
||||
content: @Composable (ColumnScope.() -> Unit)? = null // overrides prefs if not null
|
||||
) {
|
||||
SearchScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = title,
|
||||
content = content,
|
||||
content = {
|
||||
if (content != null) content()
|
||||
else LazyColumn {
|
||||
items(prefs, key = { it }) {
|
||||
Box(Modifier.animateItem()) {
|
||||
if (it is Int)
|
||||
PreferenceCategory(stringResource(it))
|
||||
else
|
||||
SettingsActivity2.allPrefs.map[it]!!.Preference()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
filteredItems = { SettingsActivity2.allPrefs.filter(it) },
|
||||
itemContent = { it.Preference() }
|
||||
)
|
||||
|
@ -125,7 +138,6 @@ fun <T: Any> SearchScreen(
|
|||
if (searchText.text.isBlank() && content != null) {
|
||||
Column(
|
||||
Modifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.windowInsetsPadding(
|
||||
WindowInsets.safeDrawing.only(
|
||||
WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom
|
||||
|
|
|
@ -25,16 +25,12 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||
// there is a lot more ambiguous naming...
|
||||
// animations when stuff (dis)appears
|
||||
// LaunchedEffect, AnimatedVisibility
|
||||
// bg image inconsistent about being on toolbar or not
|
||||
// bg image inconsistent about being on toolbar or not (is this new?)
|
||||
// maybe move some large prefs out of their screens into separate files (backup/restore!)
|
||||
// performance
|
||||
// find a nice way of testing (probably add logs for measuring time and recompositions)
|
||||
// consider that stuff in composables can get called quite often on any changes
|
||||
// -> use remember for things that are slow, but be careful about things that can change (e.g. values derived from prefs)
|
||||
// improve performance when loading screens with many settings (lazyColumn?)
|
||||
// first check whether it's really necessary (test advanced or correction screen normal and with lazyColumn)
|
||||
// screens could have a lazy column of preferences and category separators, and the list has an if-setting-then-null for hiding
|
||||
// lazyColumn also has a "key", this should be used and be the pref name (or maybe title because that's also for category separators)
|
||||
// -> use remember for things that are slow, but be careful they don't change from outside the composable
|
||||
// dialogs should be rememberSaveable to survive display orientation change and stuff?
|
||||
// try making old fragment back stuff work better, and try the different themes (with and without top bar, it should only appear for old fragments)
|
||||
// PRs adding prefs -> need to do before continuing
|
||||
|
|
|
@ -43,17 +43,19 @@ import kotlinx.coroutines.launch
|
|||
fun AboutScreen(
|
||||
onClickBack: () -> Unit,
|
||||
) {
|
||||
val items = listOf(
|
||||
NonSettingsPrefs.APP,
|
||||
NonSettingsPrefs.VERSION,
|
||||
NonSettingsPrefs.LICENSE,
|
||||
NonSettingsPrefs.HIDDEN_FEATURES,
|
||||
NonSettingsPrefs.GITHUB,
|
||||
NonSettingsPrefs.SAVE_LOG
|
||||
)
|
||||
SearchPrefScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = stringResource(R.string.settings_screen_about),
|
||||
) {
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.APP]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.VERSION]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.LICENSE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.HIDDEN_FEATURES]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.GITHUB]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.SAVE_LOG]!!.Preference()
|
||||
}
|
||||
prefs = items
|
||||
)
|
||||
}
|
||||
|
||||
fun createAboutPrefs(context: Context) = listOf(
|
||||
|
|
|
@ -97,39 +97,35 @@ fun AdvancedSettingsScreen(
|
|||
onClickBack: () -> Unit,
|
||||
) {
|
||||
val prefs = LocalContext.current.prefs()
|
||||
val items = listOfNotNull(
|
||||
Settings.PREF_ALWAYS_INCOGNITO_MODE,
|
||||
Settings.PREF_KEY_LONGPRESS_TIMEOUT,
|
||||
Settings.PREF_SPACE_HORIZONTAL_SWIPE,
|
||||
Settings.PREF_SPACE_VERTICAL_SWIPE,
|
||||
Settings.PREF_DELETE_SWIPE,
|
||||
Settings.PREF_SPACE_TO_CHANGE_LANG,
|
||||
Settings.PREFS_LONG_PRESS_SYMBOLS_FOR_NUMPAD,
|
||||
Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY,
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) Settings.PREF_SHOW_SETUP_WIZARD_ICON else null,
|
||||
Settings.PREF_ABC_AFTER_SYMBOL_SPACE,
|
||||
Settings.PREF_ABC_AFTER_EMOJI,
|
||||
Settings.PREF_ABC_AFTER_CLIP,
|
||||
Settings.PREF_CUSTOM_CURRENCY_KEY,
|
||||
Settings.PREF_MORE_POPUP_KEYS,
|
||||
NonSettingsPrefs.CUSTOM_SYMBOLS_NUMBER_LAYOUTS,
|
||||
NonSettingsPrefs.CUSTOM_FUNCTIONAL_LAYOUTS,
|
||||
NonSettingsPrefs.BACKUP_RESTORE,
|
||||
if (BuildConfig.DEBUG || prefs.getBoolean(DebugSettings.PREF_SHOW_DEBUG_SETTINGS, false)) NonSettingsPrefs.DEBUG_SETTINGS else null,
|
||||
R.string.settings_category_experimental,
|
||||
Settings.PREF_EMOJI_MAX_SDK,
|
||||
Settings.PREF_URL_DETECTION,
|
||||
if (BuildConfig.BUILD_TYPE != "nouserlib") NonSettingsPrefs.LOAD_GESTURE_LIB else null
|
||||
)
|
||||
SearchPrefScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = stringResource(R.string.settings_screen_advanced),
|
||||
) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ALWAYS_INCOGNITO_MODE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_KEY_LONGPRESS_TIMEOUT]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SPACE_HORIZONTAL_SWIPE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SPACE_VERTICAL_SWIPE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_DELETE_SWIPE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SPACE_TO_CHANGE_LANG]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREFS_LONG_PRESS_SYMBOLS_FOR_NUMPAD]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY]!!.Preference()
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_SETUP_WIZARD_ICON]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ABC_AFTER_SYMBOL_SPACE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ABC_AFTER_EMOJI]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ABC_AFTER_CLIP]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_CUSTOM_CURRENCY_KEY]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_MORE_POPUP_KEYS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.CUSTOM_SYMBOLS_NUMBER_LAYOUTS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.CUSTOM_FUNCTIONAL_LAYOUTS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.BACKUP_RESTORE]!!.Preference()
|
||||
if (BuildConfig.DEBUG || prefs.getBoolean(DebugSettings.PREF_SHOW_DEBUG_SETTINGS, false))
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.DEBUG_SETTINGS]!!.Preference() // todo: maybe move to main screen?
|
||||
PreferenceCategory(
|
||||
stringResource(R.string.settings_category_experimental)
|
||||
) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_EMOJI_MAX_SDK]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_URL_DETECTION]!!.Preference()
|
||||
if (BuildConfig.BUILD_TYPE != "nouserlib")
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.LOAD_GESTURE_LIB]!!.Preference()
|
||||
}
|
||||
}
|
||||
prefs = items
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
|
|
|
@ -41,7 +41,6 @@ import helium314.keyboard.settings.ListPreference
|
|||
import helium314.keyboard.settings.NonSettingsPrefs
|
||||
import helium314.keyboard.settings.PrefDef
|
||||
import helium314.keyboard.settings.Preference
|
||||
import helium314.keyboard.settings.PreferenceCategory
|
||||
import helium314.keyboard.settings.SearchPrefScreen
|
||||
import helium314.keyboard.settings.SettingsActivity2
|
||||
import helium314.keyboard.settings.SliderPreference
|
||||
|
@ -66,40 +65,37 @@ fun AppearanceScreen(
|
|||
if ((b?.value ?: 0) < 0)
|
||||
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
||||
val dayNightMode = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && Settings.readDayNightPref(prefs, ctx.resources)
|
||||
val lightTheme = prefs.getString(Settings.PREF_THEME_COLORS, KeyboardTheme.THEME_LIGHT)
|
||||
val darkTheme = prefs.getString(Settings.PREF_THEME_COLORS_NIGHT, KeyboardTheme.THEME_DARK)
|
||||
val items = listOfNotNull(
|
||||
R.string.settings_screen_theme,
|
||||
Settings.PREF_THEME_STYLE,
|
||||
Settings.PREF_ICON_STYLE,
|
||||
Settings.PREF_CUSTOM_ICON_NAMES,
|
||||
Settings.PREF_THEME_COLORS,
|
||||
if (prefs.getString(Settings.PREF_THEME_COLORS, KeyboardTheme.THEME_LIGHT) == KeyboardTheme.THEME_USER)
|
||||
NonSettingsPrefs.ADJUST_COLORS else null,
|
||||
Settings.PREF_THEME_KEY_BORDERS,
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
Settings.PREF_THEME_DAY_NIGHT else null,
|
||||
if (dayNightMode) Settings.PREF_THEME_COLORS_NIGHT else null,
|
||||
if (dayNightMode && prefs.getString(Settings.PREF_THEME_COLORS_NIGHT, KeyboardTheme.THEME_DARK) == KeyboardTheme.THEME_USER_NIGHT)
|
||||
NonSettingsPrefs.ADJUST_COLORS_NIGHT else null,
|
||||
Settings.PREF_NAVBAR_COLOR,
|
||||
NonSettingsPrefs.BACKGROUND_IMAGE,
|
||||
NonSettingsPrefs.BACKGROUND_IMAGE_LANDSCAPE,
|
||||
R.string.settings_category_miscellaneous,
|
||||
Settings.PREF_ENABLE_SPLIT_KEYBOARD,
|
||||
Settings.PREF_SPLIT_SPACER_SCALE,
|
||||
Settings.PREF_NARROW_KEY_GAPS,
|
||||
Settings.PREF_KEYBOARD_HEIGHT_SCALE,
|
||||
Settings.PREF_BOTTOM_PADDING_SCALE,
|
||||
Settings.PREF_SPACE_BAR_TEXT,
|
||||
NonSettingsPrefs.CUSTOM_FONT
|
||||
)
|
||||
SearchPrefScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = stringResource(R.string.settings_screen_appearance),
|
||||
) {
|
||||
PreferenceCategory(stringResource(R.string.settings_screen_theme)) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_THEME_STYLE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ICON_STYLE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_CUSTOM_ICON_NAMES]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_THEME_COLORS]!!.Preference()
|
||||
if (lightTheme == KeyboardTheme.THEME_USER)
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.ADJUST_COLORS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_THEME_KEY_BORDERS]!!.Preference()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_THEME_DAY_NIGHT]!!.Preference()
|
||||
if (dayNightMode)
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_THEME_COLORS_NIGHT]!!.Preference()
|
||||
if (dayNightMode && darkTheme == KeyboardTheme.THEME_USER_NIGHT)
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.ADJUST_COLORS_NIGHT]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_NAVBAR_COLOR]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.BACKGROUND_IMAGE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.BACKGROUND_IMAGE_LANDSCAPE]!!.Preference()
|
||||
}
|
||||
PreferenceCategory(stringResource(R.string.settings_category_miscellaneous)) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ENABLE_SPLIT_KEYBOARD]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SPLIT_SPACER_SCALE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_NARROW_KEY_GAPS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_KEYBOARD_HEIGHT_SCALE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_BOTTOM_PADDING_SCALE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SPACE_BAR_TEXT]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.CUSTOM_FONT]!!.Preference()
|
||||
}
|
||||
}
|
||||
prefs = items
|
||||
)
|
||||
}
|
||||
|
||||
fun createAppearancePrefs(context: Context) = listOf(
|
||||
|
|
|
@ -23,7 +23,6 @@ import helium314.keyboard.latin.utils.prefs
|
|||
import helium314.keyboard.settings.AllPrefs
|
||||
import helium314.keyboard.settings.PrefDef
|
||||
import helium314.keyboard.settings.Preference
|
||||
import helium314.keyboard.settings.PreferenceCategory
|
||||
import helium314.keyboard.settings.SearchPrefScreen
|
||||
import helium314.keyboard.settings.SettingsActivity2
|
||||
import helium314.keyboard.settings.SwitchPreference
|
||||
|
@ -35,22 +34,19 @@ import helium314.keyboard.settings.keyboardNeedsReload
|
|||
fun DebugScreen(
|
||||
onClickBack: () -> Unit,
|
||||
) {
|
||||
val items = listOfNotNull(
|
||||
if (!BuildConfig.DEBUG) DebugSettings.PREF_SHOW_DEBUG_SETTINGS else null,
|
||||
DebugSettings.PREF_DEBUG_MODE,
|
||||
DebugSettings.PREF_SHOW_SUGGESTION_INFOS,
|
||||
DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH,
|
||||
DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW,
|
||||
R.string.prefs_dump_dynamic_dicts
|
||||
) + DictionaryFacilitator.DYNAMIC_DICTIONARY_TYPES.map { DebugSettingsFragment.PREF_KEY_DUMP_DICT_PREFIX + it }
|
||||
SearchPrefScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = stringResource(R.string.debug_settings_title),
|
||||
) {
|
||||
if (!BuildConfig.DEBUG)
|
||||
SettingsActivity2.allPrefs.map[DebugSettings.PREF_SHOW_DEBUG_SETTINGS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[DebugSettings.PREF_DEBUG_MODE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[DebugSettings.PREF_SHOW_SUGGESTION_INFOS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW]!!.Preference()
|
||||
PreferenceCategory(stringResource(R.string.prefs_dump_dynamic_dicts)) {
|
||||
DictionaryFacilitator.DYNAMIC_DICTIONARY_TYPES.forEach {
|
||||
SettingsActivity2.allPrefs.map[DebugSettingsFragment.PREF_KEY_DUMP_DICT_PREFIX + it]!!.Preference()
|
||||
}
|
||||
}
|
||||
}
|
||||
prefs = items
|
||||
)
|
||||
}
|
||||
|
||||
fun createDebugPrefs(context: Context) = listOf(
|
||||
|
|
|
@ -30,25 +30,25 @@ fun GestureTypingScreen(
|
|||
val b = (LocalContext.current.getActivity() as? SettingsActivity2)?.prefChanged?.collectAsState()
|
||||
if ((b?.value ?: 0) < 0)
|
||||
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
||||
val gestureEnabled = prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true)
|
||||
val gestureTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true)
|
||||
val gestureFloatingPreviewEnabled = prefs.getBoolean(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true)
|
||||
val items = listOf(Settings.PREF_GESTURE_INPUT) +
|
||||
if (prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true))
|
||||
listOfNotNull(
|
||||
Settings.PREF_GESTURE_PREVIEW_TRAIL,
|
||||
Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT,
|
||||
if (gestureFloatingPreviewEnabled)
|
||||
Settings.PREF_GESTURE_FLOATING_PREVIEW_DYNAMIC else null,
|
||||
Settings.PREF_GESTURE_SPACE_AWARE,
|
||||
Settings.PREF_GESTURE_FAST_TYPING_COOLDOWN,
|
||||
if (prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true) || gestureFloatingPreviewEnabled)
|
||||
Settings.PREF_GESTURE_TRAIL_FADEOUT_DURATION else null
|
||||
)
|
||||
else emptyList()
|
||||
SearchPrefScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = stringResource(R.string.settings_screen_gesture),
|
||||
) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_GESTURE_INPUT]!!.Preference()
|
||||
if (gestureEnabled) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_GESTURE_PREVIEW_TRAIL]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT]!!.Preference()
|
||||
if (gestureFloatingPreviewEnabled)
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_GESTURE_FLOATING_PREVIEW_DYNAMIC]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_GESTURE_SPACE_AWARE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_GESTURE_FAST_TYPING_COOLDOWN]!!.Preference()
|
||||
if (gestureTrailEnabled || gestureFloatingPreviewEnabled)
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_GESTURE_TRAIL_FADEOUT_DURATION]!!.Preference()
|
||||
}
|
||||
}
|
||||
prefs = items
|
||||
)
|
||||
}
|
||||
|
||||
fun createGestureTypingPrefs(context: Context) = listOf(
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
package helium314.keyboard.settings.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -42,45 +45,13 @@ fun MainSettingsScreen(
|
|||
SearchPrefScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = stringResource(R.string.ime_settings),
|
||||
prefs = emptyList(),
|
||||
) {
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_preferences),
|
||||
onClick = onClickPreferences,
|
||||
icon = R.drawable.ic_settings_preferences_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_appearance),
|
||||
onClick = onClickAppearance,
|
||||
icon = R.drawable.ic_settings_appearance_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_toolbar),
|
||||
onClick = onClickToolbar,
|
||||
icon = R.drawable.ic_settings_toolbar_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
if (JniUtils.sHaveGestureLib)
|
||||
Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_gesture),
|
||||
onClick = onClickGestureTyping,
|
||||
icon = R.drawable.ic_settings_gesture_foreground
|
||||
name = stringResource(R.string.settings_screen_preferences),
|
||||
onClick = onClickPreferences,
|
||||
icon = R.drawable.ic_settings_preferences_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
|
@ -88,42 +59,74 @@ fun MainSettingsScreen(
|
|||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_correction),
|
||||
onClick = onClickTextCorrection,
|
||||
icon = R.drawable.ic_settings_correction_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_advanced),
|
||||
onClick = onClickAdvanced,
|
||||
icon = R.drawable.ic_settings_advanced_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_about),
|
||||
onClick = onClickAbout,
|
||||
icon = R.drawable.ic_settings_about_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
PreferenceCategory(
|
||||
title = "old screens"
|
||||
) {
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_appearance),
|
||||
onClick = onClickAppearance,
|
||||
icon = R.drawable.ic_settings_appearance_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_toolbar),
|
||||
onClick = onClickToolbar,
|
||||
icon = R.drawable.ic_settings_toolbar_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
if (JniUtils.sHaveGestureLib)
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_gesture),
|
||||
onClick = onClickGestureTyping,
|
||||
icon = R.drawable.ic_settings_gesture_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_correction),
|
||||
onClick = onClickTextCorrection,
|
||||
icon = R.drawable.ic_settings_correction_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_advanced),
|
||||
onClick = onClickAdvanced,
|
||||
icon = R.drawable.ic_settings_advanced_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Preference(
|
||||
name = stringResource(R.string.settings_screen_about),
|
||||
onClick = onClickAbout,
|
||||
icon = R.drawable.ic_settings_about_foreground
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_arrow_left),
|
||||
modifier = Modifier.scale(-1f, 1f),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
PreferenceCategory(title = "old screens")
|
||||
Preference(
|
||||
name = stringResource(R.string.language_and_layouts_title),
|
||||
onClick = { ctx.getActivity()?.switchTo(LanguageSettingsFragment()) }
|
||||
|
|
|
@ -25,7 +25,6 @@ import helium314.keyboard.latin.utils.prefs
|
|||
import helium314.keyboard.settings.AllPrefs
|
||||
import helium314.keyboard.settings.ListPreference
|
||||
import helium314.keyboard.settings.PrefDef
|
||||
import helium314.keyboard.settings.PreferenceCategory
|
||||
import helium314.keyboard.settings.ReorderSwitchPreference
|
||||
import helium314.keyboard.settings.SearchPrefScreen
|
||||
import helium314.keyboard.settings.SettingsActivity2
|
||||
|
@ -38,46 +37,44 @@ import helium314.keyboard.settings.keyboardNeedsReload
|
|||
fun PreferencesScreen(
|
||||
onClickBack: () -> Unit,
|
||||
) {
|
||||
val prefs = LocalContext.current.prefs()
|
||||
val b = (LocalContext.current.getActivity() as? SettingsActivity2)?.prefChanged?.collectAsState()
|
||||
if ((b?.value ?: 0) < 0)
|
||||
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
||||
val items = listOfNotNull(
|
||||
R.string.settings_category_input,
|
||||
Settings.PREF_SHOW_HINTS,
|
||||
if (prefs.getBoolean(Settings.PREF_SHOW_HINTS, true))
|
||||
Settings.PREF_POPUP_KEYS_LABELS_ORDER else null,
|
||||
Settings.PREF_POPUP_KEYS_ORDER,
|
||||
Settings.PREF_SHOW_POPUP_HINTS,
|
||||
Settings.PREF_POPUP_ON,
|
||||
Settings.PREF_VIBRATE_ON,
|
||||
if (prefs.getBoolean(Settings.PREF_VIBRATE_ON, true))
|
||||
Settings.PREF_VIBRATION_DURATION_SETTINGS else null,
|
||||
if (prefs.getBoolean(Settings.PREF_VIBRATE_ON, true))
|
||||
Settings.PREF_VIBRATE_IN_DND_MODE else null,
|
||||
Settings.PREF_SOUND_ON,
|
||||
if (prefs.getBoolean(Settings.PREF_SOUND_ON, true))
|
||||
Settings.PREF_KEYPRESS_SOUND_VOLUME else null,
|
||||
R.string.settings_category_additional_keys,
|
||||
Settings.PREF_SHOW_NUMBER_ROW,
|
||||
if (getEnabledSubtypes(prefs, true).any { it.locale().language in localesWithLocalizedNumberRow })
|
||||
Settings.PREF_LOCALIZED_NUMBER_ROW else null,
|
||||
Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY,
|
||||
Settings.PREF_LANGUAGE_SWITCH_KEY,
|
||||
Settings.PREF_SHOW_EMOJI_KEY,
|
||||
Settings.PREF_REMOVE_REDUNDANT_POPUPS,
|
||||
R.string.settings_category_clipboard_history,
|
||||
Settings.PREF_ENABLE_CLIPBOARD_HISTORY,
|
||||
if (prefs.getBoolean(Settings.PREF_ENABLE_CLIPBOARD_HISTORY, true))
|
||||
Settings.PREF_CLIPBOARD_HISTORY_RETENTION_TIME else null
|
||||
)
|
||||
SearchPrefScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = stringResource(R.string.settings_screen_preferences),
|
||||
) {
|
||||
val prefs = LocalContext.current.prefs()
|
||||
val b = (LocalContext.current.getActivity() as? SettingsActivity2)?.prefChanged?.collectAsState()
|
||||
if ((b?.value ?: 0) < 0)
|
||||
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
||||
PreferenceCategory(stringResource(R.string.settings_category_input)) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_HINTS]!!.Preference()
|
||||
if (prefs.getBoolean(Settings.PREF_SHOW_HINTS, true))
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_POPUP_KEYS_LABELS_ORDER]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_POPUP_KEYS_ORDER]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_POPUP_HINTS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_POPUP_ON]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_VIBRATE_ON]!!.Preference()
|
||||
if (prefs.getBoolean(Settings.PREF_VIBRATE_ON, true))
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_VIBRATION_DURATION_SETTINGS]!!.Preference()
|
||||
if (prefs.getBoolean(Settings.PREF_VIBRATE_ON, true))
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_VIBRATE_IN_DND_MODE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SOUND_ON]!!.Preference()
|
||||
if (prefs.getBoolean(Settings.PREF_SOUND_ON, true))
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_KEYPRESS_SOUND_VOLUME]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_CLIPBOARD_HISTORY_RETENTION_TIME]!!.Preference()
|
||||
}
|
||||
PreferenceCategory(stringResource(R.string.settings_category_additional_keys)) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_NUMBER_ROW]!!.Preference()
|
||||
if (getEnabledSubtypes(prefs, true).any { it.locale().language in localesWithLocalizedNumberRow })
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_LOCALIZED_NUMBER_ROW]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_LANGUAGE_SWITCH_KEY]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_EMOJI_KEY]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_REMOVE_REDUNDANT_POPUPS]!!.Preference()
|
||||
}
|
||||
PreferenceCategory(stringResource(R.string.settings_category_clipboard_history)) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ENABLE_CLIPBOARD_HISTORY]!!.Preference()
|
||||
if (prefs.getBoolean(Settings.PREF_ENABLE_CLIPBOARD_HISTORY, true))
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_CLIPBOARD_HISTORY_RETENTION_TIME]!!.Preference()
|
||||
}
|
||||
}
|
||||
prefs = items
|
||||
)
|
||||
}
|
||||
|
||||
fun createPreferencesPrefs(context: Context) = listOf(
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.Manifest
|
|||
import android.content.Context
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
|
@ -35,7 +33,6 @@ import helium314.keyboard.settings.ListPreference
|
|||
import helium314.keyboard.settings.NonSettingsPrefs
|
||||
import helium314.keyboard.settings.PrefDef
|
||||
import helium314.keyboard.settings.Preference
|
||||
import helium314.keyboard.settings.PreferenceCategory
|
||||
import helium314.keyboard.settings.SearchPrefScreen
|
||||
import helium314.keyboard.settings.SettingsActivity2
|
||||
import helium314.keyboard.settings.SwitchPreference
|
||||
|
@ -52,46 +49,34 @@ fun TextCorrectionScreen(
|
|||
if ((b?.value ?: 0) < 0)
|
||||
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
||||
val autocorrectEnabled = prefs.getBoolean(Settings.PREF_AUTO_CORRECTION, true)
|
||||
val personalizedSuggestionsEnabled = prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true)
|
||||
val suggestionsEnabled = prefs.getBoolean(Settings.PREF_SHOW_SUGGESTIONS, true)
|
||||
val items = listOfNotNull(
|
||||
NonSettingsPrefs.EDIT_PERSONAL_DICTIONARY,
|
||||
R.string.settings_category_correction,
|
||||
Settings.PREF_BLOCK_POTENTIALLY_OFFENSIVE,
|
||||
Settings.PREF_AUTO_CORRECTION,
|
||||
if (autocorrectEnabled) Settings.PREF_MORE_AUTO_CORRECTION else null,
|
||||
if (autocorrectEnabled) Settings.PREF_AUTOCORRECT_SHORTCUTS else null,
|
||||
if (autocorrectEnabled) Settings.PREF_AUTO_CORRECTION_CONFIDENCE else null,
|
||||
Settings.PREF_AUTO_CAP,
|
||||
Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD,
|
||||
Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION,
|
||||
R.string.settings_category_suggestions,
|
||||
Settings.PREF_SHOW_SUGGESTIONS,
|
||||
if (suggestionsEnabled) Settings.PREF_ALWAYS_SHOW_SUGGESTIONS else null,
|
||||
if (suggestionsEnabled) Settings.PREF_CENTER_SUGGESTION_TEXT_TO_ENTER else null,
|
||||
Settings.PREF_KEY_USE_PERSONALIZED_DICTS,
|
||||
Settings.PREF_BIGRAM_PREDICTIONS,
|
||||
Settings.PREF_SUGGEST_CLIPBOARD_CONTENT,
|
||||
Settings.PREF_USE_CONTACTS,
|
||||
if (prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true))
|
||||
Settings.PREF_ADD_TO_PERSONAL_DICTIONARY else null
|
||||
)
|
||||
SearchPrefScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = stringResource(R.string.settings_screen_correction),
|
||||
) {
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.EDIT_PERSONAL_DICTIONARY]!!.Preference()
|
||||
PreferenceCategory(stringResource(R.string.settings_category_correction)) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_BLOCK_POTENTIALLY_OFFENSIVE]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_AUTO_CORRECTION]!!.Preference()
|
||||
AnimatedVisibility(visible = autocorrectEnabled, modifier = Modifier.fillMaxWidth()) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_MORE_AUTO_CORRECTION]!!.Preference()
|
||||
}
|
||||
AnimatedVisibility(visible = autocorrectEnabled, modifier = Modifier.fillMaxWidth()) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_AUTOCORRECT_SHORTCUTS]!!.Preference()
|
||||
}
|
||||
AnimatedVisibility(visible = autocorrectEnabled, modifier = Modifier.fillMaxWidth()) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_AUTO_CORRECTION_CONFIDENCE]!!.Preference()
|
||||
}
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_AUTO_CAP]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION]!!.Preference()
|
||||
}
|
||||
PreferenceCategory(stringResource(R.string.settings_category_suggestions)) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_SUGGESTIONS]!!.Preference()
|
||||
AnimatedVisibility(visible = suggestionsEnabled, modifier = Modifier.fillMaxWidth()) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ALWAYS_SHOW_SUGGESTIONS]!!.Preference()
|
||||
}
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_KEY_USE_PERSONALIZED_DICTS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_BIGRAM_PREDICTIONS]!!.Preference()
|
||||
AnimatedVisibility(visible = suggestionsEnabled, modifier = Modifier.fillMaxWidth()) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_CENTER_SUGGESTION_TEXT_TO_ENTER]!!.Preference()
|
||||
}
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_SUGGEST_CLIPBOARD_CONTENT]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_USE_CONTACTS]!!.Preference()
|
||||
AnimatedVisibility(visible = personalizedSuggestionsEnabled, modifier = Modifier.fillMaxWidth()) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_ADD_TO_PERSONAL_DICTIONARY]!!.Preference()
|
||||
}
|
||||
}
|
||||
}
|
||||
prefs = items
|
||||
)
|
||||
}
|
||||
|
||||
fun createCorrectionPrefs(context: Context) = listOf(
|
||||
|
|
|
@ -4,13 +4,10 @@ package helium314.keyboard.settings.screens
|
|||
import android.content.Context
|
||||
import android.graphics.drawable.VectorDrawable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
|
@ -32,8 +29,6 @@ import helium314.keyboard.latin.settings.Settings
|
|||
import helium314.keyboard.latin.utils.defaultClipboardToolbarPref
|
||||
import helium314.keyboard.latin.utils.defaultPinnedToolbarPref
|
||||
import helium314.keyboard.latin.utils.defaultToolbarPref
|
||||
import helium314.keyboard.latin.utils.getStringResourceOrName
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.AllPrefs
|
||||
import helium314.keyboard.settings.NonSettingsPrefs
|
||||
import helium314.keyboard.settings.PrefDef
|
||||
|
@ -43,7 +38,6 @@ import helium314.keyboard.settings.SearchPrefScreen
|
|||
import helium314.keyboard.settings.SettingsActivity2
|
||||
import helium314.keyboard.settings.SwitchPreference
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.dialogs.ReorderDialog
|
||||
import helium314.keyboard.settings.dialogs.ToolbarKeysCustomizer
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
|
||||
|
@ -51,19 +45,21 @@ import helium314.keyboard.settings.keyboardNeedsReload
|
|||
fun ToolbarScreen(
|
||||
onClickBack: () -> Unit,
|
||||
) {
|
||||
val items = listOf(
|
||||
Settings.PREF_TOOLBAR_KEYS,
|
||||
Settings.PREF_PINNED_TOOLBAR_KEYS,
|
||||
Settings.PREF_CLIPBOARD_TOOLBAR_KEYS,
|
||||
NonSettingsPrefs.CUSTOM_KEY_CODES,
|
||||
Settings.PREF_QUICK_PIN_TOOLBAR_KEYS,
|
||||
Settings.PREF_AUTO_SHOW_TOOLBAR,
|
||||
Settings.PREF_AUTO_HIDE_TOOLBAR,
|
||||
Settings.PREF_VARIABLE_TOOLBAR_DIRECTION
|
||||
)
|
||||
SearchPrefScreen(
|
||||
onClickBack = onClickBack,
|
||||
title = stringResource(R.string.settings_screen_toolbar),
|
||||
) {
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_TOOLBAR_KEYS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_PINNED_TOOLBAR_KEYS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_CLIPBOARD_TOOLBAR_KEYS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[NonSettingsPrefs.CUSTOM_KEY_CODES]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_QUICK_PIN_TOOLBAR_KEYS]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_AUTO_SHOW_TOOLBAR]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_AUTO_HIDE_TOOLBAR]!!.Preference()
|
||||
SettingsActivity2.allPrefs.map[Settings.PREF_VARIABLE_TOOLBAR_DIRECTION]!!.Preference()
|
||||
}
|
||||
prefs = items
|
||||
)
|
||||
}
|
||||
|
||||
fun createToolbarPrefs(context: Context) = listOf(
|
||||
|
@ -83,7 +79,7 @@ fun createToolbarPrefs(context: Context) = listOf(
|
|||
onClick = { showDialog = true },
|
||||
)
|
||||
if (showDialog)
|
||||
// todo: CUSTOM_KEY_CODES vs the 2 actual prefs that are changed...
|
||||
// todo (later): CUSTOM_KEY_CODES vs the 2 actual prefs that are changed...
|
||||
ToolbarKeysCustomizer(
|
||||
onDismissRequest = { showDialog = false }
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue