Squashed commit of the following:

change appearance preferences so only holo and new custom themes are accessible
remove old lxx themes and many of the drawables only used there (still a bunch left)
(internally) rename holo themes to match test in preferences: ICS -> HoloBlue, KLP -> HoloWhite to
This commit is contained in:
Helium314 2023-08-26 22:58:51 +02:00
parent e04bb1eaa6
commit fabc940c46
252 changed files with 250 additions and 2013 deletions

View file

@ -36,25 +36,31 @@ import java.util.Map;
public final class KeyboardTheme implements Comparable<KeyboardTheme> {
// old themes
public static final String THEME_FAMILY_MATERIAL = "Material";
public static final String THEME_FAMILY_HOLO = "Holo (Legacy)";
public static final String THEME_VARIANT_LIGHT = "Light";
public static final String THEME_VARIANT_DARK = "Dark";
public static final String THEME_VARIANT_WHITE = "White";
public static final String THEME_VARIANT_BLUE = "Blue";
public static final String THEME_VARIANT_HOLO_WHITE = "White";
public static final String THEME_VARIANT_HOLO_BLUE = "Blue";
public static final String THEME_VARIANT_CUSTOM = "User-defined";
public static final String THEME_VARIANT_HOLO_USER = "User-defined (Holo)";
// new themes using the custom colors
public static final String THEME_LIGHT = "light";
public static final String THEME_DARK = "dark";
public static final String THEME_DARKER = "darker";
public static final String THEME_BLACK = "black";
public static final String THEME_USER = "user";
public static final String THEME_USER_DARK = "user_dark";
public static final String[] CUSTOM_THEME_VARIANTS = new String[] { THEME_LIGHT, THEME_DARK, THEME_DARKER, THEME_BLACK, THEME_USER };
public static final String[] CUSTOM_THEME_VARIANTS_DARK = new String[] { THEME_DARK, THEME_DARKER, THEME_BLACK, THEME_USER_DARK };
public static final String[] THEME_FAMILIES = {THEME_FAMILY_MATERIAL, THEME_FAMILY_HOLO};
public static final Map<String, String[]> THEME_VARIANTS = new HashMap<>();
static {
THEME_VARIANTS.put(THEME_FAMILY_MATERIAL,
new String[] {THEME_VARIANT_LIGHT, THEME_VARIANT_DARK, THEME_VARIANT_CUSTOM});
THEME_VARIANTS.put(THEME_FAMILY_MATERIAL, CUSTOM_THEME_VARIANTS);
THEME_VARIANTS.put(THEME_FAMILY_HOLO,
new String[] {THEME_VARIANT_WHITE, THEME_VARIANT_BLUE, THEME_VARIANT_HOLO_USER});
THEME_VARIANTS.put(THEME_FAMILY_HOLO,
new String[] {THEME_VARIANT_WHITE, THEME_VARIANT_BLUE, THEME_VARIANT_HOLO_USER});
new String[] {THEME_VARIANT_HOLO_WHITE, THEME_VARIANT_HOLO_BLUE, THEME_VARIANT_HOLO_USER});
}
private static final String TAG = KeyboardTheme.class.getSimpleName();
@ -64,64 +70,30 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
// These should be aligned with Keyboard.themeId and Keyboard.Case.keyboardTheme
// attributes' values in attrs.xml.
public static final int THEME_ID_ICS = 0;
public static final int THEME_ID_KLP = 2;
public static final int THEME_ID_KLP_CUSTOM = 13;
public static final int THEME_ID_LXX_LIGHT = 3;
public static final int THEME_ID_LXX_DARK_AMOLED = 4;
public static final int THEME_ID_LXX_AUTO_AMOLED = 10;
public static final int THEME_ID_LXX_LIGHT_BORDER = 5;
public static final int THEME_ID_LXX_DARK_BORDER = 6;
public static final int THEME_ID_LXX_DARK = 7;
public static final int THEME_ID_LXX_AUTO = 9;
public static final int THEME_ID_LXX_AUTO_BORDER = 8;
public static final int THEME_ID_LXX_CUSTOM = 11;
public static final int THEME_ID_LXX_CUSTOM_BORDER = 12;
public static final int THEME_ID_LXX_BASE = 14;
public static final int THEME_ID_LXX_BASE_BORDER = 15;
public static final int DEFAULT_THEME_ID = THEME_ID_LXX_DARK_BORDER;
private static KeyboardTheme[] AVAILABLE_KEYBOARD_THEMES;
public static final int THEME_ID_HOLO_BLUE = 0;
public static final int THEME_ID_HOLO_WHITE = 1;
public static final int THEME_ID_HOLO_CUSTOM = 2; // todo: custom <-> white?
public static final int THEME_ID_LXX_BASE = 3;
public static final int THEME_ID_LXX_BASE_BORDER = 4;
public static final int THEME_ID_LXX_CUSTOM = 5; // todo: custom <-> base?
public static final int THEME_ID_LXX_CUSTOM_BORDER = 6;
public static final int DEFAULT_THEME_ID = THEME_ID_LXX_CUSTOM;
/* package private for testing */
static final KeyboardTheme[] KEYBOARD_THEMES = {
new KeyboardTheme(THEME_ID_ICS, "ICS", R.style.KeyboardTheme_ICS,
new KeyboardTheme(THEME_ID_HOLO_BLUE, "HoloBlue", R.style.KeyboardTheme_HoloBlue,
// This has never been selected because we support ICS or later.
VERSION_CODES.BASE),
new KeyboardTheme(THEME_ID_KLP, "KLP", R.style.KeyboardTheme_KLP,
new KeyboardTheme(THEME_ID_HOLO_WHITE, "HoloWhite", R.style.KeyboardTheme_HoloWhite,
// Default theme for ICS, JB, and KLP.
VERSION_CODES.ICE_CREAM_SANDWICH),
new KeyboardTheme(THEME_ID_LXX_LIGHT, "LXXLight", R.style.KeyboardTheme_LXX_Light,
// Default theme for LXX.
VERSION_CODES.BASE),
new KeyboardTheme(THEME_ID_LXX_DARK, "LXXDark", R.style.KeyboardTheme_LXX_Dark,
// This has never been selected as default theme.
VERSION_CODES.BASE),
new KeyboardTheme(THEME_ID_LXX_DARK_AMOLED, "LXXDarkAmoled", R.style.KeyboardTheme_LXX_Dark_Amoled,
// This has never been selected as default theme.
VERSION_CODES.BASE),
new KeyboardTheme(THEME_ID_LXX_LIGHT_BORDER, "LXXLightBorder", R.style.KeyboardTheme_LXX_Light_Border,
// This has never been selected as default theme.
Build.VERSION_CODES.BASE),
new KeyboardTheme(THEME_ID_LXX_DARK_BORDER, "LXXDarkBorder", R.style.KeyboardTheme_LXX_Dark_Border,
// This has never been selected as default theme.
VERSION_CODES.LOLLIPOP),
new KeyboardTheme(THEME_ID_LXX_AUTO_BORDER, "LXXAutoBorder", R.style.KeyboardTheme_LXX_Auto_Border,
// This has never been selected as default theme.
VERSION_CODES.LOLLIPOP),
new KeyboardTheme(THEME_ID_LXX_AUTO, "LXXAuto", R.style.KeyboardTheme_LXX_Auto,
// This has never been selected as default theme.
VERSION_CODES.LOLLIPOP),
new KeyboardTheme(THEME_ID_LXX_AUTO_AMOLED, "LXXAutoAmoled", R.style.KeyboardTheme_LXX_Auto_Amoled,
// This has never been selected as default theme.
VERSION_CODES.LOLLIPOP),
new KeyboardTheme(THEME_ID_LXX_CUSTOM, "LXXCustom", R.style.KeyboardTheme_LXX_Base,
// This has never been selected as default theme.
VERSION_CODES.LOLLIPOP),
new KeyboardTheme(THEME_ID_LXX_CUSTOM_BORDER, "LXXCustomBorder", R.style.KeyboardTheme_LXX_Base_Border,
// This has never been selected as default theme.
VERSION_CODES.LOLLIPOP),
new KeyboardTheme(THEME_ID_KLP_CUSTOM, "KLPCustom", R.style.KeyboardTheme_KLP,
new KeyboardTheme(THEME_ID_HOLO_CUSTOM, "HoloCustom", R.style.KeyboardTheme_HoloWhite,
// This has never been selected as default theme.
VERSION_CODES.BASE),
new KeyboardTheme(THEME_ID_LXX_BASE, "LXXBase", R.style.KeyboardTheme_LXX_Base,
@ -265,27 +237,20 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
}
public static String getThemeFamily(int themeId) {
if (themeId == THEME_ID_ICS || themeId == THEME_ID_KLP || themeId == THEME_ID_KLP_CUSTOM) return THEME_FAMILY_HOLO;
if (themeId == THEME_ID_HOLO_BLUE || themeId == THEME_ID_HOLO_WHITE || themeId == THEME_ID_HOLO_CUSTOM) return THEME_FAMILY_HOLO;
return THEME_FAMILY_MATERIAL;
}
public static String getThemeVariant(int themeId) {
switch (themeId) {
case THEME_ID_LXX_DARK:
case THEME_ID_LXX_DARK_AMOLED:
case THEME_ID_LXX_DARK_BORDER:
return THEME_VARIANT_DARK;
case THEME_ID_LXX_LIGHT:
case THEME_ID_LXX_LIGHT_BORDER:
return THEME_VARIANT_LIGHT;
case THEME_ID_KLP:
return THEME_VARIANT_WHITE;
case THEME_ID_ICS:
return THEME_VARIANT_BLUE;
case THEME_ID_HOLO_WHITE:
return THEME_VARIANT_HOLO_WHITE;
case THEME_ID_HOLO_BLUE:
return THEME_VARIANT_HOLO_BLUE;
case THEME_ID_LXX_CUSTOM:
case THEME_ID_LXX_CUSTOM_BORDER:
return THEME_VARIANT_CUSTOM;
case THEME_ID_KLP_CUSTOM:
case THEME_ID_HOLO_CUSTOM:
return THEME_VARIANT_HOLO_USER;
default:
return null;
@ -294,12 +259,9 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
public static boolean getHasKeyBorders(int themeId) {
switch (themeId) {
case THEME_ID_LXX_DARK_BORDER:
case THEME_ID_LXX_LIGHT_BORDER:
case THEME_ID_LXX_AUTO_BORDER:
case THEME_ID_LXX_CUSTOM_BORDER:
case THEME_ID_ICS:
case THEME_ID_KLP:
case THEME_ID_HOLO_BLUE:
case THEME_ID_HOLO_WHITE:
return true;
default:
return false;
@ -310,28 +272,7 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
switch (themeId) {
case THEME_ID_LXX_CUSTOM:
case THEME_ID_LXX_CUSTOM_BORDER:
case THEME_ID_KLP_CUSTOM:
return true;
default:
return false;
}
}
public static boolean getIsDayNight(int themeId) {
switch (themeId) {
case THEME_ID_LXX_AUTO:
case THEME_ID_LXX_AUTO_AMOLED:
case THEME_ID_LXX_AUTO_BORDER:
return true;
default:
return false;
}
}
public static boolean getIsAmoledMode(int themeId) {
switch (themeId) {
case THEME_ID_LXX_DARK_AMOLED:
case THEME_ID_LXX_AUTO_AMOLED:
case THEME_ID_HOLO_CUSTOM:
return true;
default:
return false;
@ -339,39 +280,15 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
}
public static int getThemeForParameters(String family, String variant,
boolean keyBorders, boolean dayNight, boolean amoledMode) {
boolean keyBorders) {
if (THEME_FAMILY_HOLO.equals(family)) {
if (THEME_VARIANT_BLUE.equals(variant)) return THEME_ID_ICS;
if (THEME_VARIANT_HOLO_USER.equals(variant)) return THEME_ID_KLP_CUSTOM;
return THEME_ID_KLP;
if (THEME_VARIANT_HOLO_BLUE.equals(variant)) return THEME_ID_HOLO_BLUE;
if (THEME_VARIANT_HOLO_USER.equals(variant)) return THEME_ID_HOLO_CUSTOM;
return THEME_ID_HOLO_WHITE;
}
// check custom before dayNight, because now both can match
if (THEME_VARIANT_CUSTOM.equals(variant)) {
if (keyBorders) return THEME_ID_LXX_CUSTOM_BORDER;
return THEME_ID_LXX_CUSTOM;
}
if (dayNight) {
if (keyBorders) return THEME_ID_LXX_AUTO_BORDER;
if (amoledMode) return THEME_ID_LXX_AUTO_AMOLED;
return THEME_ID_LXX_AUTO;
}
if (THEME_VARIANT_DARK.equals(variant)) {
if (keyBorders) return THEME_ID_LXX_DARK_BORDER;
if (amoledMode) return THEME_ID_LXX_DARK_AMOLED;
return THEME_ID_LXX_DARK;
}
if (keyBorders) return THEME_ID_LXX_LIGHT_BORDER;
return THEME_ID_LXX_LIGHT;
}
public static final String THEME_LIGHT = "light";
public static final String THEME_DARK = "dark";
public static final String THEME_DARKER = "darker";
public static final String THEME_BLACK = "black";
public static final String THEME_USER = "user";
public static final String THEME_USER_DARK = "user_dark";
public static final String[] CUSTOM_THEME_VARIANTS = new String[] { THEME_LIGHT, THEME_DARK, THEME_DARKER, THEME_BLACK, THEME_USER };
public static final String[] CUSTOM_THEME_VARIANTS_DARK = new String[] { THEME_DARK, THEME_DARKER, THEME_BLACK, THEME_USER_DARK };
// todo (later): material you, system accent, ...
// todo: copies of original themes might need adjustments, though maybe it's only Colors that needs to be adjusted

View file

@ -17,6 +17,7 @@
package org.dslul.openboard.inputmethod.keyboard;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@ -31,6 +32,8 @@ import android.graphics.drawable.NinePatchDrawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import org.dslul.openboard.inputmethod.keyboard.internal.KeyDrawParams;
@ -41,9 +44,11 @@ import org.dslul.openboard.inputmethod.latin.common.Colors;
import org.dslul.openboard.inputmethod.latin.common.Constants;
import org.dslul.openboard.inputmethod.latin.settings.Settings;
import org.dslul.openboard.inputmethod.latin.suggestions.MoreSuggestionsView;
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
import org.dslul.openboard.inputmethod.latin.utils.TypefaceUtils;
import java.util.HashSet;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -383,7 +388,7 @@ public class KeyboardView extends View {
final Rect padding = mKeyBackgroundPadding;
bgWidth = keyWidth + padding.left + padding.right;
// absurdly horrible workaround, because it's not possible to set padding as percentage of height in btn_keyboard_spacebar_lxx_base
if (mColors.isCustom && key.getBackgroundType() == Key.BACKGROUND_TYPE_SPACEBAR) {
if (mColors.isCustom && key.getBackgroundType() == Key.BACKGROUND_TYPE_SPACEBAR && !isHoloTheme()) {
Rect p = new Rect();
background.getPadding(p);
if (p.top != 0) {
@ -407,6 +412,16 @@ public class KeyboardView extends View {
canvas.translate(-bgX, -bgY);
}
private boolean isHoloTheme() {
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(getContext());
final int keyboardThemeId = KeyboardTheme.getThemeForParameters(
prefs.getString(Settings.PREF_THEME_FAMILY, ""),
prefs.getString(Settings.PREF_THEME_VARIANT, ""),
prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false)
);
return KeyboardTheme.getThemeFamily(keyboardThemeId).equals(KeyboardTheme.THEME_FAMILY_HOLO);
}
// Draw key top visuals.
protected void onDrawKeyTopVisuals(@Nonnull final Key key, @Nonnull final Canvas canvas,
@Nonnull final Paint paint, @Nonnull final KeyDrawParams params) {

View file

@ -55,23 +55,10 @@ public class Colors {
}
// todo (later): remove this and isCustom, once the old themes can be completely replaced
// for now there are the holo themes left, which don't require any of themeId and isNight
public Colors(int themeId, final boolean isNight) {
isCustom = false;
if (KeyboardTheme.getIsDayNight(themeId)) {
if (!isNight)
navBar = Color.rgb(236, 239, 241);
else if (themeId == KeyboardTheme.THEME_ID_LXX_DARK)
navBar = Color.rgb(38, 50, 56);
else
navBar = Color.BLACK;
} else if (KeyboardTheme.THEME_VARIANT_LIGHT.equals(KeyboardTheme.getThemeVariant(themeId))) {
navBar = Color.rgb(236, 239, 241);
} else if (themeId == KeyboardTheme.THEME_ID_LXX_DARK) {
navBar = Color.rgb(38, 50, 56);
} else {
// dark border is 13/13/13, but that's ok
navBar = Color.BLACK;
}
accent = 0;
background = 0;
keyBackground = 0;

View file

@ -37,7 +37,8 @@ import java.util.*
* "Appearance" settings sub screen.
*/
@Suppress("Deprecation") // yes everything here is deprecated, but only work on this if really necessary
// todo: simplify when removing old themes
// todo: simplify when removing old themes (or migrating holo to same style as user themes)
// there is a bunch of ugly things in the theme settings, and mostly for historic reasons...
// idea for color selection
// left: which color (background, key, text,...)
// right: color preview (always the correct one, even if determined automatically)
@ -56,10 +57,8 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
private lateinit var themeFamilyPref: ListPreference
private lateinit var themeVariantPref: ListPreference
private lateinit var customThemeVariantPref: ListPreference
private lateinit var customThemeVariantNightPref: ListPreference
private lateinit var keyBordersPref: TwoStatePreference
private lateinit var amoledModePref: TwoStatePreference
private var dayNightPref: TwoStatePreference? = null
private lateinit var userColorsPref: Preference
@ -160,11 +159,9 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
private fun saveSelectedThemeId(
family: String = themeFamilyPref.value,
variant: String = themeVariantPref.value,
keyBorders: Boolean = keyBordersPref.isChecked,
dayNight: Boolean = dayNightPref?.isChecked ?: false,
amoledMode: Boolean = amoledModePref.isChecked
keyBorders: Boolean = keyBordersPref.isChecked
) {
selectedThemeId = KeyboardTheme.getThemeForParameters(family, variant, keyBorders, dayNight, amoledMode)
selectedThemeId = KeyboardTheme.getThemeForParameters(family, variant, keyBorders)
KeyboardTheme.saveKeyboardThemeId(selectedThemeId, sharedPreferences)
}
@ -178,45 +175,31 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
}
}
val variants = KeyboardTheme.THEME_VARIANTS[themeFamily]!!
val variant = KeyboardTheme.getThemeVariant(selectedThemeId)
val variant = if (isLegacyFamily) KeyboardTheme.getThemeVariant(selectedThemeId)
else sharedPreferences.getString(Settings.PREF_CUSTOM_THEME_VARIANT, KeyboardTheme.THEME_LIGHT)
if (!skipThemeVariant) {
themeVariantPref.apply {
entries = variants
entryValues = variants
value = variant ?: variants[0]
summary = variant ?: "Auto"
isEnabled = isLegacyFamily || !KeyboardTheme.getIsDayNight(selectedThemeId)
}
}
customThemeVariantPref.apply {
val variant = sharedPreferences.getString(Settings.PREF_CUSTOM_THEME_VARIANT, KeyboardTheme.THEME_LIGHT)
// todo (idea): re-work setting to actually see preview of theme colors... but that's a lot of work
val variants = KeyboardTheme.CUSTOM_THEME_VARIANTS
entries = variants.map {
entries = if (isLegacyFamily) variants // todo: translatable string for holo, not internal name
else variants.map {
val resId = resources.getIdentifier("theme_name_$it", "string", activity.packageName)
if (resId == 0) it else getString(resId)
}.toTypedArray()
entryValues = variants
value = variant
value = variant ?: variants[0]
summary = if (isLegacyFamily) variant
else {
val resId = resources.getIdentifier("theme_name_$variant", "string", activity.packageName)
summary = if (resId == 0) variant else getString(resId)
isEnabled = true
if (resId == 0) variant else getString(resId)
}
}
}
keyBordersPref.apply {
isEnabled = !isLegacyFamily && !KeyboardTheme.getIsAmoledMode(selectedThemeId)
isEnabled = !isLegacyFamily
isChecked = isLegacyFamily || KeyboardTheme.getHasKeyBorders(selectedThemeId)
}
amoledModePref.apply {
isEnabled = !isLegacyFamily && variant != KeyboardTheme.THEME_VARIANT_LIGHT
&& !KeyboardTheme.getHasKeyBorders(selectedThemeId)
&& !KeyboardTheme.getIsCustom(selectedThemeId)
isChecked = !isLegacyFamily && KeyboardTheme.getIsAmoledMode(selectedThemeId)
}
dayNightPref?.apply {
isEnabled = !isLegacyFamily
isChecked = !isLegacyFamily && (KeyboardTheme.getIsDayNight(selectedThemeId)
|| (KeyboardTheme.getIsCustom(selectedThemeId) && sharedPreferences.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false))
)
isChecked = !isLegacyFamily && KeyboardTheme.getIsCustom(selectedThemeId) && sharedPreferences.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false)
}
}
@ -234,9 +217,19 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
}
themeVariantPref = preferenceScreen.findPreference(Settings.PREF_THEME_VARIANT) as ListPreference
themeVariantPref.apply {
title = "$title old (to be removed)" // todo: remove, this is just a workaround while there are still 2 ways of selecting variant
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
summary = entries[entryValues.indexOfFirst { it == value }]
if (themeFamilyPref.value == KeyboardTheme.THEME_FAMILY_MATERIAL) {
// not so nice workaround, could be removed in the necessary re-work: new value seems
// to be stored only after this method call, but we update the summary and user-defined color enablement in here -> store it now
if (value == sharedPreferences.getString(Settings.PREF_CUSTOM_THEME_VARIANT, KeyboardTheme.THEME_LIGHT))
return@OnPreferenceChangeListener true // avoid infinite loop
sharedPreferences.edit { putString(Settings.PREF_CUSTOM_THEME_VARIANT, value as String) }
summary = entries[entryValues.indexOfFirst { it == value }]
needsReload = true
}
saveSelectedThemeId(variant = value as String)
updateThemePreferencesState(skipThemeFamily = true, skipThemeVariant = true)
true
@ -248,44 +241,14 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
updateThemePreferencesState(skipThemeFamily = true)
true
}
amoledModePref = preferenceScreen.findPreference(Settings.PREF_THEME_AMOLED_MODE) as TwoStatePreference
amoledModePref.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
saveSelectedThemeId(amoledMode = value as Boolean)
updateThemePreferencesState(skipThemeFamily = true)
true
}
dayNightPref = preferenceScreen.findPreference(Settings.PREF_THEME_DAY_NIGHT) as? TwoStatePreference
dayNightPref?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
saveSelectedThemeId(dayNight = value as Boolean)
updateThemePreferencesState(skipThemeFamily = true)
true
}
customThemeVariantPref = preferenceScreen.findPreference(Settings.PREF_CUSTOM_THEME_VARIANT) as ListPreference
customThemeVariantPref.apply {
title = "$title new" // todo: remove, this is just a workaround while there are still 2 ways of selecting variant
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
// not so nice workaround, could be removed in the necessary re-work: new value seems
// to be stored only after this method call, but we update the summary and user-defined color enablement in here -> store it now
if (value == sharedPreferences.getString(Settings.PREF_CUSTOM_THEME_VARIANT, KeyboardTheme.THEME_LIGHT))
return@OnPreferenceChangeListener true // avoid infinite loop
sharedPreferences.edit { putString(Settings.PREF_CUSTOM_THEME_VARIANT, value as String) }
summary = entries[entryValues.indexOfFirst { it == value }]
needsReload = true
// always switch to user-defined theme variant
val themeFamily = KeyboardTheme.getThemeFamily(selectedThemeId)
val variants = KeyboardTheme.THEME_VARIANTS[themeFamily]!!
val userVariant = variants.first { it.contains("user", true) }
saveSelectedThemeId(variant = userVariant as String)
updateThemePreferencesState(skipThemeFamily = true)
true
}
}
customThemeVariantNightPref = preferenceScreen.findPreference(Settings.PREF_CUSTOM_THEME_VARIANT_NIGHT) as ListPreference
customThemeVariantNightPref.apply {
title = "$title new (night)" // todo: remove, this is just a workaround while there are still 2 ways of selecting variant
title = "$title (night)" // todo: string resource
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
// not so nice workaround, could be removed in the necessary re-work: new value seems
// to be stored only after this method call, but we update the summary and user-defined color enablement in here -> store it now

View file

@ -67,7 +67,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_CUSTOM_THEME_VARIANT_NIGHT = "custom_theme_variant_night";
public static final String PREF_THEME_KEY_BORDERS = "theme_key_borders";
public static final String PREF_THEME_DAY_NIGHT = "theme_auto_day_night";
public static final String PREF_THEME_AMOLED_MODE = "theme_amoled_mode";
public static final String PREF_THEME_USER = "theme_select_colors";
public static final String PREF_THEME_USER_COLOR_TEXT = "theme_color_text";
public static final String PREF_THEME_USER_COLOR_HINT_TEXT = "theme_color_hint_text";
@ -576,9 +575,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
final int keyboardThemeId = KeyboardTheme.getThemeForParameters(
prefs.getString(Settings.PREF_THEME_FAMILY, ""),
prefs.getString(Settings.PREF_THEME_VARIANT, ""),
prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false),
prefs.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false),
prefs.getBoolean(Settings.PREF_THEME_AMOLED_MODE, false)
prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false)
);
// todo: night mode can be unspecified -> maybe need to adjust for correct behavior on some devices?
final boolean isNight = (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;

View file

@ -83,6 +83,12 @@ public final class SettingsFragment extends PreferenceFragment {
if (actionBar != null && screenTitle != null) {
actionBar.setTitle(screenTitle);
}
// todo: got a crash because it wasn't initialized...
// but sometimes wrong languages are returned when not initializing on creation of LatinIME
// maybe wait until some user actually encounters this bug, initializing here is really rare
SubtypeSettingsKt.init(getActivity());
findPreference("screen_languages").setSummary(getEnabledSubtypesLabel());
if (BuildConfig.DEBUG)
askAboutCrashReports();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 937 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 B

Some files were not shown because too many files have changed in this diff Show more