mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-22 15:19:10 +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.LocalContentColor
|
||||||
import androidx.compose.material3.LocalTextStyle
|
import androidx.compose.material3.LocalTextStyle
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -48,17 +49,15 @@ import helium314.keyboard.settings.dialogs.ReorderDialog
|
||||||
import helium314.keyboard.settings.dialogs.SliderDialog
|
import helium314.keyboard.settings.dialogs.SliderDialog
|
||||||
import helium314.keyboard.settings.screens.GetIcon
|
import helium314.keyboard.settings.screens.GetIcon
|
||||||
|
|
||||||
// taken from StreetComplete (and a bit SCEE)
|
// partially taken from StreetComplete / SCEE
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PreferenceCategory(
|
fun PreferenceCategory(
|
||||||
title: String?,
|
title: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
content: @Composable ColumnScope.() -> Unit
|
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
if (title != null) {
|
|
||||||
Text(
|
Text(
|
||||||
text = title,
|
text = title,
|
||||||
modifier = modifier.padding(top = 12.dp, start = 16.dp, end = 8.dp, bottom = 8.dp),
|
modifier = modifier.padding(top = 12.dp, start = 16.dp, end = 8.dp, bottom = 8.dp),
|
||||||
|
@ -66,12 +65,6 @@ fun PreferenceCategory(
|
||||||
style = MaterialTheme.typography.titleSmall
|
style = MaterialTheme.typography.titleSmall
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyLarge) {
|
|
||||||
Column {
|
|
||||||
content()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -95,7 +88,7 @@ fun Preference(
|
||||||
if (icon != null)
|
if (icon != null)
|
||||||
Icon(painterResource(icon), name, modifier = Modifier.size(36.dp))
|
Icon(painterResource(icon), name, modifier = Modifier.size(36.dp))
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
Text(text = name)
|
Text(text = name, style = MaterialTheme.typography.bodyLarge)
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalTextStyle provides MaterialTheme.typography.bodyMedium,
|
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 class KeyAndState(var name: String, var state: Boolean)
|
||||||
|
|
||||||
private fun <T: Any> getPrefOfType(prefs: SharedPreferences, key: String, default: T): T =
|
private fun <T: Any> getPrefOfType(prefs: SharedPreferences, key: String, default: T): T =
|
||||||
|
@ -371,7 +324,9 @@ private fun <T: Any> putPrefOfType(prefs: SharedPreferences, key: String, value:
|
||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
private fun PreferencePreview() {
|
private fun PreferencePreview() {
|
||||||
PreferenceCategory("Preference Category") {
|
Surface {
|
||||||
|
Column {
|
||||||
|
PreferenceCategory("Preference Category")
|
||||||
Preference(
|
Preference(
|
||||||
name = "Preference",
|
name = "Preference",
|
||||||
onClick = {},
|
onClick = {},
|
||||||
|
@ -427,3 +382,4 @@ private fun PreferencePreview() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package helium314.keyboard.settings
|
||||||
|
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
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.layout.windowInsetsPadding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
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.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
@ -49,12 +48,26 @@ import helium314.keyboard.latin.R
|
||||||
fun SearchPrefScreen(
|
fun SearchPrefScreen(
|
||||||
onClickBack: () -> Unit,
|
onClickBack: () -> Unit,
|
||||||
title: String,
|
title: String,
|
||||||
content: @Composable ColumnScope.() -> Unit
|
prefs: List<Any>,
|
||||||
|
content: @Composable (ColumnScope.() -> Unit)? = null // overrides prefs if not null
|
||||||
) {
|
) {
|
||||||
SearchScreen(
|
SearchScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
title = title,
|
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) },
|
filteredItems = { SettingsActivity2.allPrefs.filter(it) },
|
||||||
itemContent = { it.Preference() }
|
itemContent = { it.Preference() }
|
||||||
)
|
)
|
||||||
|
@ -125,7 +138,6 @@ fun <T: Any> SearchScreen(
|
||||||
if (searchText.text.isBlank() && content != null) {
|
if (searchText.text.isBlank() && content != null) {
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
.verticalScroll(rememberScrollState())
|
|
||||||
.windowInsetsPadding(
|
.windowInsetsPadding(
|
||||||
WindowInsets.safeDrawing.only(
|
WindowInsets.safeDrawing.only(
|
||||||
WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom
|
WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom
|
||||||
|
|
|
@ -25,16 +25,12 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
// there is a lot more ambiguous naming...
|
// there is a lot more ambiguous naming...
|
||||||
// animations when stuff (dis)appears
|
// animations when stuff (dis)appears
|
||||||
// LaunchedEffect, AnimatedVisibility
|
// 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!)
|
// maybe move some large prefs out of their screens into separate files (backup/restore!)
|
||||||
// performance
|
// performance
|
||||||
// find a nice way of testing (probably add logs for measuring time and recompositions)
|
// 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
|
// 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)
|
// -> use remember for things that are slow, but be careful they don't change from outside the composable
|
||||||
// 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)
|
|
||||||
// dialogs should be rememberSaveable to survive display orientation change and stuff?
|
// 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)
|
// 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
|
// PRs adding prefs -> need to do before continuing
|
||||||
|
|
|
@ -43,17 +43,19 @@ import kotlinx.coroutines.launch
|
||||||
fun AboutScreen(
|
fun AboutScreen(
|
||||||
onClickBack: () -> Unit,
|
onClickBack: () -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val items = listOf(
|
||||||
|
NonSettingsPrefs.APP,
|
||||||
|
NonSettingsPrefs.VERSION,
|
||||||
|
NonSettingsPrefs.LICENSE,
|
||||||
|
NonSettingsPrefs.HIDDEN_FEATURES,
|
||||||
|
NonSettingsPrefs.GITHUB,
|
||||||
|
NonSettingsPrefs.SAVE_LOG
|
||||||
|
)
|
||||||
SearchPrefScreen(
|
SearchPrefScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
title = stringResource(R.string.settings_screen_about),
|
title = stringResource(R.string.settings_screen_about),
|
||||||
) {
|
prefs = items
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createAboutPrefs(context: Context) = listOf(
|
fun createAboutPrefs(context: Context) = listOf(
|
||||||
|
|
|
@ -97,39 +97,35 @@ fun AdvancedSettingsScreen(
|
||||||
onClickBack: () -> Unit,
|
onClickBack: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val prefs = LocalContext.current.prefs()
|
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(
|
SearchPrefScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
title = stringResource(R.string.settings_screen_advanced),
|
title = stringResource(R.string.settings_screen_advanced),
|
||||||
) {
|
prefs = items
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
|
|
|
@ -41,7 +41,6 @@ import helium314.keyboard.settings.ListPreference
|
||||||
import helium314.keyboard.settings.NonSettingsPrefs
|
import helium314.keyboard.settings.NonSettingsPrefs
|
||||||
import helium314.keyboard.settings.PrefDef
|
import helium314.keyboard.settings.PrefDef
|
||||||
import helium314.keyboard.settings.Preference
|
import helium314.keyboard.settings.Preference
|
||||||
import helium314.keyboard.settings.PreferenceCategory
|
|
||||||
import helium314.keyboard.settings.SearchPrefScreen
|
import helium314.keyboard.settings.SearchPrefScreen
|
||||||
import helium314.keyboard.settings.SettingsActivity2
|
import helium314.keyboard.settings.SettingsActivity2
|
||||||
import helium314.keyboard.settings.SliderPreference
|
import helium314.keyboard.settings.SliderPreference
|
||||||
|
@ -66,40 +65,37 @@ fun AppearanceScreen(
|
||||||
if ((b?.value ?: 0) < 0)
|
if ((b?.value ?: 0) < 0)
|
||||||
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
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 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 items = listOfNotNull(
|
||||||
val darkTheme = prefs.getString(Settings.PREF_THEME_COLORS_NIGHT, KeyboardTheme.THEME_DARK)
|
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(
|
SearchPrefScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
title = stringResource(R.string.settings_screen_appearance),
|
title = stringResource(R.string.settings_screen_appearance),
|
||||||
) {
|
prefs = items
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createAppearancePrefs(context: Context) = listOf(
|
fun createAppearancePrefs(context: Context) = listOf(
|
||||||
|
|
|
@ -23,7 +23,6 @@ import helium314.keyboard.latin.utils.prefs
|
||||||
import helium314.keyboard.settings.AllPrefs
|
import helium314.keyboard.settings.AllPrefs
|
||||||
import helium314.keyboard.settings.PrefDef
|
import helium314.keyboard.settings.PrefDef
|
||||||
import helium314.keyboard.settings.Preference
|
import helium314.keyboard.settings.Preference
|
||||||
import helium314.keyboard.settings.PreferenceCategory
|
|
||||||
import helium314.keyboard.settings.SearchPrefScreen
|
import helium314.keyboard.settings.SearchPrefScreen
|
||||||
import helium314.keyboard.settings.SettingsActivity2
|
import helium314.keyboard.settings.SettingsActivity2
|
||||||
import helium314.keyboard.settings.SwitchPreference
|
import helium314.keyboard.settings.SwitchPreference
|
||||||
|
@ -35,22 +34,19 @@ import helium314.keyboard.settings.keyboardNeedsReload
|
||||||
fun DebugScreen(
|
fun DebugScreen(
|
||||||
onClickBack: () -> Unit,
|
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(
|
SearchPrefScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
title = stringResource(R.string.debug_settings_title),
|
title = stringResource(R.string.debug_settings_title),
|
||||||
) {
|
prefs = items
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createDebugPrefs(context: Context) = listOf(
|
fun createDebugPrefs(context: Context) = listOf(
|
||||||
|
|
|
@ -30,25 +30,25 @@ fun GestureTypingScreen(
|
||||||
val b = (LocalContext.current.getActivity() as? SettingsActivity2)?.prefChanged?.collectAsState()
|
val b = (LocalContext.current.getActivity() as? SettingsActivity2)?.prefChanged?.collectAsState()
|
||||||
if ((b?.value ?: 0) < 0)
|
if ((b?.value ?: 0) < 0)
|
||||||
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
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 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(
|
SearchPrefScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
title = stringResource(R.string.settings_screen_gesture),
|
title = stringResource(R.string.settings_screen_gesture),
|
||||||
) {
|
prefs = items
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createGestureTypingPrefs(context: Context) = listOf(
|
fun createGestureTypingPrefs(context: Context) = listOf(
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
package helium314.keyboard.settings.screens
|
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.Icon
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -42,7 +45,9 @@ fun MainSettingsScreen(
|
||||||
SearchPrefScreen(
|
SearchPrefScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
title = stringResource(R.string.ime_settings),
|
title = stringResource(R.string.ime_settings),
|
||||||
|
prefs = emptyList(),
|
||||||
) {
|
) {
|
||||||
|
Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||||
Preference(
|
Preference(
|
||||||
name = stringResource(R.string.settings_screen_preferences),
|
name = stringResource(R.string.settings_screen_preferences),
|
||||||
onClick = onClickPreferences,
|
onClick = onClickPreferences,
|
||||||
|
@ -121,9 +126,7 @@ fun MainSettingsScreen(
|
||||||
contentDescription = null
|
contentDescription = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
PreferenceCategory(
|
PreferenceCategory(title = "old screens")
|
||||||
title = "old screens"
|
|
||||||
) {
|
|
||||||
Preference(
|
Preference(
|
||||||
name = stringResource(R.string.language_and_layouts_title),
|
name = stringResource(R.string.language_and_layouts_title),
|
||||||
onClick = { ctx.getActivity()?.switchTo(LanguageSettingsFragment()) }
|
onClick = { ctx.getActivity()?.switchTo(LanguageSettingsFragment()) }
|
||||||
|
|
|
@ -25,7 +25,6 @@ import helium314.keyboard.latin.utils.prefs
|
||||||
import helium314.keyboard.settings.AllPrefs
|
import helium314.keyboard.settings.AllPrefs
|
||||||
import helium314.keyboard.settings.ListPreference
|
import helium314.keyboard.settings.ListPreference
|
||||||
import helium314.keyboard.settings.PrefDef
|
import helium314.keyboard.settings.PrefDef
|
||||||
import helium314.keyboard.settings.PreferenceCategory
|
|
||||||
import helium314.keyboard.settings.ReorderSwitchPreference
|
import helium314.keyboard.settings.ReorderSwitchPreference
|
||||||
import helium314.keyboard.settings.SearchPrefScreen
|
import helium314.keyboard.settings.SearchPrefScreen
|
||||||
import helium314.keyboard.settings.SettingsActivity2
|
import helium314.keyboard.settings.SettingsActivity2
|
||||||
|
@ -37,47 +36,45 @@ import helium314.keyboard.settings.keyboardNeedsReload
|
||||||
@Composable
|
@Composable
|
||||||
fun PreferencesScreen(
|
fun PreferencesScreen(
|
||||||
onClickBack: () -> Unit,
|
onClickBack: () -> Unit,
|
||||||
) {
|
|
||||||
SearchPrefScreen(
|
|
||||||
onClickBack = onClickBack,
|
|
||||||
title = stringResource(R.string.settings_screen_preferences),
|
|
||||||
) {
|
) {
|
||||||
val prefs = LocalContext.current.prefs()
|
val prefs = LocalContext.current.prefs()
|
||||||
val b = (LocalContext.current.getActivity() as? SettingsActivity2)?.prefChanged?.collectAsState()
|
val b = (LocalContext.current.getActivity() as? SettingsActivity2)?.prefChanged?.collectAsState()
|
||||||
if ((b?.value ?: 0) < 0)
|
if ((b?.value ?: 0) < 0)
|
||||||
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
||||||
PreferenceCategory(stringResource(R.string.settings_category_input)) {
|
val items = listOfNotNull(
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_HINTS]!!.Preference()
|
R.string.settings_category_input,
|
||||||
|
Settings.PREF_SHOW_HINTS,
|
||||||
if (prefs.getBoolean(Settings.PREF_SHOW_HINTS, true))
|
if (prefs.getBoolean(Settings.PREF_SHOW_HINTS, true))
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_POPUP_KEYS_LABELS_ORDER]!!.Preference()
|
Settings.PREF_POPUP_KEYS_LABELS_ORDER else null,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_POPUP_KEYS_ORDER]!!.Preference()
|
Settings.PREF_POPUP_KEYS_ORDER,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_POPUP_HINTS]!!.Preference()
|
Settings.PREF_SHOW_POPUP_HINTS,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_POPUP_ON]!!.Preference()
|
Settings.PREF_POPUP_ON,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_VIBRATE_ON]!!.Preference()
|
Settings.PREF_VIBRATE_ON,
|
||||||
if (prefs.getBoolean(Settings.PREF_VIBRATE_ON, true))
|
if (prefs.getBoolean(Settings.PREF_VIBRATE_ON, true))
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_VIBRATION_DURATION_SETTINGS]!!.Preference()
|
Settings.PREF_VIBRATION_DURATION_SETTINGS else null,
|
||||||
if (prefs.getBoolean(Settings.PREF_VIBRATE_ON, true))
|
if (prefs.getBoolean(Settings.PREF_VIBRATE_ON, true))
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_VIBRATE_IN_DND_MODE]!!.Preference()
|
Settings.PREF_VIBRATE_IN_DND_MODE else null,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_SOUND_ON]!!.Preference()
|
Settings.PREF_SOUND_ON,
|
||||||
if (prefs.getBoolean(Settings.PREF_SOUND_ON, true))
|
if (prefs.getBoolean(Settings.PREF_SOUND_ON, true))
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_KEYPRESS_SOUND_VOLUME]!!.Preference()
|
Settings.PREF_KEYPRESS_SOUND_VOLUME else null,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_CLIPBOARD_HISTORY_RETENTION_TIME]!!.Preference()
|
R.string.settings_category_additional_keys,
|
||||||
}
|
Settings.PREF_SHOW_NUMBER_ROW,
|
||||||
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 })
|
if (getEnabledSubtypes(prefs, true).any { it.locale().language in localesWithLocalizedNumberRow })
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_LOCALIZED_NUMBER_ROW]!!.Preference()
|
Settings.PREF_LOCALIZED_NUMBER_ROW else null,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY]!!.Preference()
|
Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_LANGUAGE_SWITCH_KEY]!!.Preference()
|
Settings.PREF_LANGUAGE_SWITCH_KEY,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_EMOJI_KEY]!!.Preference()
|
Settings.PREF_SHOW_EMOJI_KEY,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_REMOVE_REDUNDANT_POPUPS]!!.Preference()
|
Settings.PREF_REMOVE_REDUNDANT_POPUPS,
|
||||||
}
|
R.string.settings_category_clipboard_history,
|
||||||
PreferenceCategory(stringResource(R.string.settings_category_clipboard_history)) {
|
Settings.PREF_ENABLE_CLIPBOARD_HISTORY,
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_ENABLE_CLIPBOARD_HISTORY]!!.Preference()
|
|
||||||
if (prefs.getBoolean(Settings.PREF_ENABLE_CLIPBOARD_HISTORY, true))
|
if (prefs.getBoolean(Settings.PREF_ENABLE_CLIPBOARD_HISTORY, true))
|
||||||
SettingsActivity2.allPrefs.map[Settings.PREF_CLIPBOARD_HISTORY_RETENTION_TIME]!!.Preference()
|
Settings.PREF_CLIPBOARD_HISTORY_RETENTION_TIME else null
|
||||||
}
|
)
|
||||||
}
|
SearchPrefScreen(
|
||||||
|
onClickBack = onClickBack,
|
||||||
|
title = stringResource(R.string.settings_screen_preferences),
|
||||||
|
prefs = items
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createPreferencesPrefs(context: Context) = listOf(
|
fun createPreferencesPrefs(context: Context) = listOf(
|
||||||
|
|
|
@ -5,8 +5,6 @@ import android.Manifest
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
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.Icon
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
@ -35,7 +33,6 @@ import helium314.keyboard.settings.ListPreference
|
||||||
import helium314.keyboard.settings.NonSettingsPrefs
|
import helium314.keyboard.settings.NonSettingsPrefs
|
||||||
import helium314.keyboard.settings.PrefDef
|
import helium314.keyboard.settings.PrefDef
|
||||||
import helium314.keyboard.settings.Preference
|
import helium314.keyboard.settings.Preference
|
||||||
import helium314.keyboard.settings.PreferenceCategory
|
|
||||||
import helium314.keyboard.settings.SearchPrefScreen
|
import helium314.keyboard.settings.SearchPrefScreen
|
||||||
import helium314.keyboard.settings.SettingsActivity2
|
import helium314.keyboard.settings.SettingsActivity2
|
||||||
import helium314.keyboard.settings.SwitchPreference
|
import helium314.keyboard.settings.SwitchPreference
|
||||||
|
@ -52,46 +49,34 @@ fun TextCorrectionScreen(
|
||||||
if ((b?.value ?: 0) < 0)
|
if ((b?.value ?: 0) < 0)
|
||||||
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
|
||||||
val autocorrectEnabled = prefs.getBoolean(Settings.PREF_AUTO_CORRECTION, true)
|
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 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(
|
SearchPrefScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
title = stringResource(R.string.settings_screen_correction),
|
title = stringResource(R.string.settings_screen_correction),
|
||||||
) {
|
prefs = items
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createCorrectionPrefs(context: Context) = listOf(
|
fun createCorrectionPrefs(context: Context) = listOf(
|
||||||
|
|
|
@ -4,13 +4,10 @@ package helium314.keyboard.settings.screens
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.drawable.VectorDrawable
|
import android.graphics.drawable.VectorDrawable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Switch
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
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.defaultClipboardToolbarPref
|
||||||
import helium314.keyboard.latin.utils.defaultPinnedToolbarPref
|
import helium314.keyboard.latin.utils.defaultPinnedToolbarPref
|
||||||
import helium314.keyboard.latin.utils.defaultToolbarPref
|
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.AllPrefs
|
||||||
import helium314.keyboard.settings.NonSettingsPrefs
|
import helium314.keyboard.settings.NonSettingsPrefs
|
||||||
import helium314.keyboard.settings.PrefDef
|
import helium314.keyboard.settings.PrefDef
|
||||||
|
@ -43,7 +38,6 @@ import helium314.keyboard.settings.SearchPrefScreen
|
||||||
import helium314.keyboard.settings.SettingsActivity2
|
import helium314.keyboard.settings.SettingsActivity2
|
||||||
import helium314.keyboard.settings.SwitchPreference
|
import helium314.keyboard.settings.SwitchPreference
|
||||||
import helium314.keyboard.settings.Theme
|
import helium314.keyboard.settings.Theme
|
||||||
import helium314.keyboard.settings.dialogs.ReorderDialog
|
|
||||||
import helium314.keyboard.settings.dialogs.ToolbarKeysCustomizer
|
import helium314.keyboard.settings.dialogs.ToolbarKeysCustomizer
|
||||||
import helium314.keyboard.settings.keyboardNeedsReload
|
import helium314.keyboard.settings.keyboardNeedsReload
|
||||||
|
|
||||||
|
@ -51,19 +45,21 @@ import helium314.keyboard.settings.keyboardNeedsReload
|
||||||
fun ToolbarScreen(
|
fun ToolbarScreen(
|
||||||
onClickBack: () -> Unit,
|
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(
|
SearchPrefScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
title = stringResource(R.string.settings_screen_toolbar),
|
title = stringResource(R.string.settings_screen_toolbar),
|
||||||
) {
|
prefs = items
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createToolbarPrefs(context: Context) = listOf(
|
fun createToolbarPrefs(context: Context) = listOf(
|
||||||
|
@ -83,7 +79,7 @@ fun createToolbarPrefs(context: Context) = listOf(
|
||||||
onClick = { showDialog = true },
|
onClick = { showDialog = true },
|
||||||
)
|
)
|
||||||
if (showDialog)
|
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(
|
ToolbarKeysCustomizer(
|
||||||
onDismissRequest = { showDialog = false }
|
onDismissRequest = { showDialog = false }
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue