mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-16 23:12:47 +00:00
Expose more colors to users (only for user-defined themes) (#239)
This commit is contained in:
parent
9a7968ea14
commit
02a3fe2d19
7 changed files with 47 additions and 11 deletions
|
@ -134,17 +134,23 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
case THEME_USER:
|
||||
final int accent = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_ACCENT_SUFFIX, false);
|
||||
final int keyBgColor = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_KEYS_SUFFIX, false);
|
||||
final int functionalKeyBgColor = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_FUNCTIONAL_KEYS_SUFFIX, false);
|
||||
final int spaceBarBgColor = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_SPACEBAR_SUFFIX, false);
|
||||
final int keyTextColor = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_TEXT_SUFFIX, false);
|
||||
final int hintTextColor = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_HINT_TEXT_SUFFIX, false);
|
||||
final int spaceBarTextColor = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_SPACEBAR_TEXT_SUFFIX, false);
|
||||
final int background = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_BACKGROUND_SUFFIX, false);
|
||||
return new Colors(themeStyle, hasBorders, accent, background, keyBgColor, ColorUtilKt.brightenOrDarken(keyBgColor, true), keyBgColor, keyTextColor, hintTextColor);
|
||||
return new Colors(themeStyle, hasBorders, accent, background, keyBgColor, functionalKeyBgColor, spaceBarBgColor, keyTextColor, hintTextColor, spaceBarTextColor);
|
||||
case THEME_USER_NIGHT:
|
||||
final int accent2 = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_ACCENT_SUFFIX, true);
|
||||
final int keyBgColor2 = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_KEYS_SUFFIX, true);
|
||||
final int functionalKeyBgColor2 = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_FUNCTIONAL_KEYS_SUFFIX, true);
|
||||
final int spaceBarBgColor2 = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_SPACEBAR_SUFFIX, true);
|
||||
final int keyTextColor2 = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_TEXT_SUFFIX, true);
|
||||
final int hintTextColor2 = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_HINT_TEXT_SUFFIX, true);
|
||||
final int spaceBarTextColor2 = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_SPACEBAR_TEXT_SUFFIX, true);
|
||||
final int background2 = Settings.readUserColor(prefs, context, Settings.PREF_COLOR_BACKGROUND_SUFFIX, true);
|
||||
return new Colors(themeStyle, hasBorders, accent2, background2, keyBgColor2, ColorUtilKt.brightenOrDarken(keyBgColor2, true), keyBgColor2, keyTextColor2, hintTextColor2);
|
||||
return new Colors(themeStyle, hasBorders, accent2, background2, keyBgColor2, functionalKeyBgColor2, spaceBarBgColor2, keyTextColor2, hintTextColor2, spaceBarTextColor2);
|
||||
case THEME_DARK:
|
||||
return new Colors(
|
||||
themeStyle,
|
||||
|
@ -156,7 +162,8 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
Color.parseColor("#2d393f"),
|
||||
Color.parseColor("#364248"),
|
||||
ContextCompat.getColor(context, R.color.key_text_color_lxx_dark),
|
||||
ContextCompat.getColor(context, R.color.key_hint_letter_color_lxx_dark)
|
||||
ContextCompat.getColor(context, R.color.key_hint_letter_color_lxx_dark),
|
||||
ContextCompat.getColor(context, R.color.spacebar_letter_color_lxx_dark)
|
||||
);
|
||||
case THEME_HOLO_WHITE:
|
||||
return new Colors(
|
||||
|
@ -169,6 +176,7 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
Color.parseColor("#444444"), // should be 222222, but the key drawable is already grey
|
||||
Color.parseColor("#FFFFFF"),
|
||||
Color.parseColor("#FFFFFF"),
|
||||
Color.parseColor("#282828"),
|
||||
Color.parseColor("#282828")
|
||||
);
|
||||
case THEME_DARKER:
|
||||
|
@ -181,7 +189,8 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
ContextCompat.getColor(context, R.color.key_background_functional_lxx_dark_border),
|
||||
ContextCompat.getColor(context, R.color.key_background_normal_lxx_dark_border),
|
||||
ContextCompat.getColor(context, R.color.key_text_color_lxx_dark),
|
||||
ContextCompat.getColor(context, R.color.key_hint_letter_color_lxx_dark)
|
||||
ContextCompat.getColor(context, R.color.key_hint_letter_color_lxx_dark),
|
||||
ContextCompat.getColor(context, R.color.spacebar_letter_color_lxx_dark)
|
||||
);
|
||||
case THEME_BLACK:
|
||||
return new Colors(
|
||||
|
@ -193,7 +202,8 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
ContextCompat.getColor(context, R.color.background_amoled_dark),
|
||||
ContextCompat.getColor(context, R.color.background_amoled_dark),
|
||||
ContextCompat.getColor(context, R.color.key_text_color_lxx_dark),
|
||||
ContextCompat.getColor(context, R.color.key_hint_letter_color_lxx_dark)
|
||||
ContextCompat.getColor(context, R.color.key_hint_letter_color_lxx_dark),
|
||||
ContextCompat.getColor(context, R.color.spacebar_letter_color_lxx_dark)
|
||||
);
|
||||
case THEME_LIGHT:
|
||||
default:
|
||||
|
@ -206,7 +216,8 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
ContextCompat.getColor(context, R.color.key_background_functional_lxx_light_border),
|
||||
ContextCompat.getColor(context, R.color.key_background_normal_lxx_light_border),
|
||||
ContextCompat.getColor(context, R.color.key_text_color_lxx_light),
|
||||
ContextCompat.getColor(context, R.color.key_hint_letter_color_lxx_light)
|
||||
ContextCompat.getColor(context, R.color.key_hint_letter_color_lxx_light),
|
||||
ContextCompat.getColor(context, R.color.spacebar_letter_color_lxx_light)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ class Colors (
|
|||
val functionalKey: Int,
|
||||
val spaceBar: Int,
|
||||
val keyText: Int,
|
||||
val keyHintText: Int
|
||||
val keyHintText: Int,
|
||||
val spaceBarText: Int
|
||||
) {
|
||||
val navBar: Int
|
||||
/** brightened or darkened variant of [background], to be used if exact background color would be
|
||||
|
@ -45,7 +46,6 @@ class Colors (
|
|||
val doubleAdjustedBackground: Int
|
||||
/** brightened or darkened variant of [keyText] */
|
||||
val adjustedKeyText: Int
|
||||
val spaceBarText: Int
|
||||
|
||||
val backgroundFilter: ColorFilter
|
||||
val adjustedBackgroundFilter: ColorFilter
|
||||
|
@ -74,11 +74,9 @@ class Colors (
|
|||
val darkerBackground = adjustLuminosityAndKeepAlpha(background, -0.2f)
|
||||
navBar = darkerBackground
|
||||
keyboardBackground = GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(background, darkerBackground))
|
||||
spaceBarText = keyText
|
||||
} else {
|
||||
navBar = background
|
||||
keyboardBackground = null
|
||||
spaceBarText = keyHintText
|
||||
}
|
||||
|
||||
// create color filters
|
||||
|
|
|
@ -33,8 +33,11 @@ open class ColorsSettingsFragment : Fragment(R.layout.color_settings) {
|
|||
private val colorPrefs = listOf(
|
||||
Settings.PREF_COLOR_BACKGROUND_SUFFIX,
|
||||
Settings.PREF_COLOR_KEYS_SUFFIX,
|
||||
Settings.PREF_COLOR_FUNCTIONAL_KEYS_SUFFIX,
|
||||
Settings.PREF_COLOR_SPACEBAR_SUFFIX,
|
||||
Settings.PREF_COLOR_TEXT_SUFFIX,
|
||||
Settings.PREF_COLOR_HINT_TEXT_SUFFIX,
|
||||
Settings.PREF_COLOR_SPACEBAR_TEXT_SUFFIX,
|
||||
Settings.PREF_COLOR_ACCENT_SUFFIX,
|
||||
)
|
||||
|
||||
|
@ -65,8 +68,11 @@ open class ColorsSettingsFragment : Fragment(R.layout.color_settings) {
|
|||
val colorPrefNames = listOf(
|
||||
R.string.select_color_background,
|
||||
R.string.select_color_key_background,
|
||||
R.string.select_color_functional_key_background,
|
||||
R.string.select_color_spacebar_background,
|
||||
R.string.select_color_key,
|
||||
R.string.select_color_key_hint,
|
||||
R.string.select_color_spacebar_text,
|
||||
R.string.select_color_accent,
|
||||
).map { requireContext().getString(it) }
|
||||
val prefPrefix = if (isNight) Settings.PREF_THEME_USER_COLOR_NIGHT_PREFIX else Settings.PREF_THEME_USER_COLOR_PREFIX
|
||||
|
|
|
@ -62,6 +62,9 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
public static final String PREF_THEME_USER_COLOR_PREFIX = "theme_color_";
|
||||
public static final String PREF_THEME_USER_COLOR_NIGHT_PREFIX = "theme_dark_color_";
|
||||
public static final String PREF_COLOR_KEYS_SUFFIX = "keys";
|
||||
public static final String PREF_COLOR_FUNCTIONAL_KEYS_SUFFIX = "functional_keys";
|
||||
public static final String PREF_COLOR_SPACEBAR_SUFFIX = "spacebar";
|
||||
public static final String PREF_COLOR_SPACEBAR_TEXT_SUFFIX = "spacebar_text";
|
||||
public static final String PREF_COLOR_ACCENT_SUFFIX = "accent";
|
||||
public static final String PREF_COLOR_TEXT_SUFFIX = "text";
|
||||
public static final String PREF_COLOR_HINT_TEXT_SUFFIX = "hint_text";
|
||||
|
@ -511,9 +514,16 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
else return Color.WHITE;
|
||||
case PREF_COLOR_HINT_TEXT_SUFFIX:
|
||||
if (ColorUtilKt.isBrightColor(readUserColor(prefs, context, PREF_COLOR_KEYS_SUFFIX, isNight))) return Color.DKGRAY;
|
||||
else return Color.LTGRAY;
|
||||
else return readUserColor(prefs, context, PREF_COLOR_TEXT_SUFFIX, isNight);
|
||||
case PREF_COLOR_KEYS_SUFFIX:
|
||||
return ColorUtilKt.brightenOrDarken(readUserColor(prefs, context, PREF_COLOR_BACKGROUND_SUFFIX, isNight), isNight);
|
||||
case PREF_COLOR_FUNCTIONAL_KEYS_SUFFIX:
|
||||
return ColorUtilKt.brightenOrDarken(readUserColor(prefs, context, PREF_COLOR_KEYS_SUFFIX, isNight), true);
|
||||
case PREF_COLOR_SPACEBAR_SUFFIX:
|
||||
return readUserColor(prefs, context, PREF_COLOR_KEYS_SUFFIX, isNight);
|
||||
case PREF_COLOR_SPACEBAR_TEXT_SUFFIX:
|
||||
if (ColorUtilKt.isBrightColor(readUserColor(prefs, context, PREF_COLOR_SPACEBAR_SUFFIX, isNight))) return Color.DKGRAY;
|
||||
else return readUserColor(prefs, context, PREF_COLOR_TEXT_SUFFIX, isNight);
|
||||
case PREF_COLOR_BACKGROUND_SUFFIX:
|
||||
default:
|
||||
return ContextCompat.getColor(getDayNightContext(context, isNight), R.color.keyboard_background);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue