make sure holo white is not selectable without holo style

This commit is contained in:
Helium314 2025-02-05 05:42:10 +01:00
parent 22878578a7
commit 2d38cf0805
5 changed files with 23 additions and 10 deletions

View file

@ -136,7 +136,7 @@ fun SwitchPreference(
val ctx = LocalContext.current
val prefs = ctx.prefs()
val b = (ctx.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")
var value = prefs.getBoolean(pref, default)
fun switched(newValue: Boolean) {
@ -194,7 +194,7 @@ fun <T: Number> SliderPreference(
val ctx = LocalContext.current
val prefs = ctx.prefs()
val b = (ctx.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")
val initialValue = if (default is Int || default is Float)
getPrefOfType(prefs, pref, default)

View file

@ -16,9 +16,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
// todo (roughly in order)
// make all prefs actually work
// appearance
// holo white selectable for non-holo style if we had selected holo theme before
// the list just stays the old one after changing the setting
// also, even if selected it should not be used...
// click on bg image does nothing when already set (but works after reload)
// split spacer scale setting does not reload?
// narrow key gaps setting is not changing properly?
@ -29,6 +26,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
// try moving the recomposition of pref change somewhere else, so it's not duplicated everywhere
// make the pref lists more compact (compare with old settings)
// try making text size similar to old state (also in dialogs)
// more similar dialog style args (for all dialogs, or for none)
// check whether dialogs have the same colors, i think currently it's a bit inconsistent
// see all the properties for each alertDialog -> any way to set it in a single place?
// title too huge for bg image and text on spacebar dialogs, also maybe somewhere else -> where to set in one place?

View file

@ -60,7 +60,7 @@ fun AppearanceScreen(
val ctx = LocalContext.current
val prefs = ctx.prefs()
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")
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)
@ -102,6 +102,7 @@ fun AppearanceScreen(
fun createAppearancePrefs(context: Context) = listOf(
PrefDef(context, Settings.PREF_THEME_STYLE, R.string.theme_style) { def ->
val ctx = LocalContext.current
val prefs = ctx.prefs()
val items = KeyboardTheme.STYLES.map {
it.getStringResourceOrName("style_name_", ctx) to it
}
@ -109,7 +110,15 @@ fun createAppearancePrefs(context: Context) = listOf(
def,
items,
KeyboardTheme.STYLE_MATERIAL
)
) {
if (it != KeyboardTheme.STYLE_HOLO) {
// todo: use defaults once they exist
if (prefs.getString(Settings.PREF_THEME_COLORS, "") == KeyboardTheme.THEME_HOLO_WHITE)
prefs.edit().putString(Settings.PREF_THEME_COLORS, KeyboardTheme.THEME_LIGHT).apply()
if (prefs.getString(Settings.PREF_THEME_COLORS_NIGHT, "") == KeyboardTheme.THEME_HOLO_WHITE)
prefs.edit().putString(Settings.PREF_THEME_COLORS_NIGHT, KeyboardTheme.THEME_DARK).apply()
}
}
},
PrefDef(context, Settings.PREF_ICON_STYLE, R.string.icon_style) { def ->
val ctx = LocalContext.current
@ -138,6 +147,9 @@ fun createAppearancePrefs(context: Context) = listOf(
},
PrefDef(context, Settings.PREF_THEME_COLORS, R.string.theme_colors) { def ->
val ctx = LocalContext.current
val b = (ctx.getActivity() as? SettingsActivity2)?.prefChanged?.collectAsState()
if ((b?.value ?: 0) < 0)
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
val currentStyle = ctx.prefs().getString(Settings.PREF_THEME_STYLE, KeyboardTheme.STYLE_MATERIAL)
val items = KeyboardTheme.COLORS.mapNotNull {
if (it == KeyboardTheme.THEME_HOLO_WHITE && currentStyle != KeyboardTheme.STYLE_HOLO)
@ -152,8 +164,11 @@ fun createAppearancePrefs(context: Context) = listOf(
},
PrefDef(context, Settings.PREF_THEME_COLORS_NIGHT, R.string.theme_colors_night) { def ->
val ctx = LocalContext.current
val b = (ctx.getActivity() as? SettingsActivity2)?.prefChanged?.collectAsState()
if ((b?.value ?: 0) < 0)
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
val currentStyle = ctx.prefs().getString(Settings.PREF_THEME_STYLE, KeyboardTheme.STYLE_MATERIAL)
val items = KeyboardTheme.COLORS.mapNotNull {
val items = KeyboardTheme.COLORS_DARK.mapNotNull {
if (it == KeyboardTheme.THEME_HOLO_WHITE && currentStyle == KeyboardTheme.STYLE_HOLO)
return@mapNotNull null
it.getStringResourceOrName("theme_name_", ctx) to it

View file

@ -28,7 +28,7 @@ fun GestureTypingScreen(
) {
val prefs = LocalContext.current.prefs()
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")
val gestureEnabled = prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true)
val gestureTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true)

View file

@ -49,7 +49,7 @@ fun TextCorrectionScreen(
) {
val prefs = LocalContext.current.prefs()
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")
val autocorrectEnabled = prefs.getBoolean(Settings.PREF_AUTO_CORRECTION, true)
val personalizedSuggestionsEnabled = prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true)