mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-24 00:26:22 +00:00
move getting custom colors to a separate function
and rename some more variables to "custom" wip: navigation bar color currently broken
This commit is contained in:
parent
c6411777ab
commit
ca2b671f26
13 changed files with 125 additions and 73 deletions
|
@ -553,7 +553,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
// set background color here, otherwise there is a narrow white line between keyboard and suggestion strip
|
||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
||||
if (settingsValues.mCustomTheme)
|
||||
mKeyboardViewWrapper.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
|
||||
mKeyboardViewWrapper.getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
||||
|
||||
return mCurrentInputView;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.util.Log;
|
|||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -38,7 +37,7 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
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_USER = "User-defined";
|
||||
public static final String THEME_VARIANT_CUSTOM = "User-defined";
|
||||
public static final String THEME_VARIANT_HOLO_USER = "User-defined (Holo)";
|
||||
|
||||
public static final String[] THEME_FAMILIES = {THEME_FAMILY_MATERIAL, THEME_FAMILY_HOLO};
|
||||
|
@ -46,7 +45,7 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
|
||||
static {
|
||||
THEME_VARIANTS.put(THEME_FAMILY_MATERIAL,
|
||||
new String[] {THEME_VARIANT_LIGHT, THEME_VARIANT_DARK, THEME_VARIANT_USER});
|
||||
new String[] {THEME_VARIANT_LIGHT, THEME_VARIANT_DARK, THEME_VARIANT_CUSTOM});
|
||||
THEME_VARIANTS.put(THEME_FAMILY_HOLO,
|
||||
new String[] {THEME_VARIANT_WHITE, THEME_VARIANT_BLUE, THEME_VARIANT_HOLO_USER});
|
||||
}
|
||||
|
@ -60,7 +59,7 @@ public final class KeyboardTheme implements Comparable<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_USER = 13;
|
||||
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;
|
||||
|
@ -69,8 +68,8 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
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_USER = 11;
|
||||
public static final int THEME_ID_LXX_USER_BORDER = 12;
|
||||
public static final int THEME_ID_LXX_CUSTOM = 11;
|
||||
public static final int THEME_ID_LXX_CUSTOM_BORDER = 12;
|
||||
public static final int DEFAULT_THEME_ID = THEME_ID_LXX_DARK_BORDER;
|
||||
|
||||
private static KeyboardTheme[] AVAILABLE_KEYBOARD_THEMES;
|
||||
|
@ -107,13 +106,13 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
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_USER, "LXXUser", R.style.KeyboardTheme_LXX_Light,
|
||||
new KeyboardTheme(THEME_ID_LXX_CUSTOM, "LXXUser", R.style.KeyboardTheme_LXX_Light,
|
||||
// This has never been selected as default theme.
|
||||
VERSION_CODES.LOLLIPOP),
|
||||
new KeyboardTheme(THEME_ID_LXX_USER_BORDER, "LXXUserBorder", R.style.KeyboardTheme_LXX_Light_Border,
|
||||
new KeyboardTheme(THEME_ID_LXX_CUSTOM_BORDER, "LXXUserBorder", R.style.KeyboardTheme_LXX_Light_Border,
|
||||
// This has never been selected as default theme.
|
||||
VERSION_CODES.LOLLIPOP),
|
||||
new KeyboardTheme(THEME_ID_KLP_USER, "KLPUser", R.style.KeyboardTheme_KLP,
|
||||
new KeyboardTheme(THEME_ID_KLP_CUSTOM, "KLPUser", R.style.KeyboardTheme_KLP,
|
||||
// This has never been selected as default theme.
|
||||
VERSION_CODES.BASE),
|
||||
};
|
||||
|
@ -251,7 +250,7 @@ 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_USER) return THEME_FAMILY_HOLO;
|
||||
if (themeId == THEME_ID_ICS || themeId == THEME_ID_KLP || themeId == THEME_ID_KLP_CUSTOM) return THEME_FAMILY_HOLO;
|
||||
return THEME_FAMILY_MATERIAL;
|
||||
}
|
||||
|
||||
|
@ -268,10 +267,10 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
return THEME_VARIANT_WHITE;
|
||||
case THEME_ID_ICS:
|
||||
return THEME_VARIANT_BLUE;
|
||||
case THEME_ID_LXX_USER:
|
||||
case THEME_ID_LXX_USER_BORDER:
|
||||
return THEME_VARIANT_USER;
|
||||
case THEME_ID_KLP_USER:
|
||||
case THEME_ID_LXX_CUSTOM:
|
||||
case THEME_ID_LXX_CUSTOM_BORDER:
|
||||
return THEME_VARIANT_CUSTOM;
|
||||
case THEME_ID_KLP_CUSTOM:
|
||||
return THEME_VARIANT_HOLO_USER;
|
||||
default:
|
||||
return null;
|
||||
|
@ -283,7 +282,7 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
case THEME_ID_LXX_DARK_BORDER:
|
||||
case THEME_ID_LXX_LIGHT_BORDER:
|
||||
case THEME_ID_LXX_AUTO_BORDER:
|
||||
case THEME_ID_LXX_USER_BORDER:
|
||||
case THEME_ID_LXX_CUSTOM_BORDER:
|
||||
case THEME_ID_ICS:
|
||||
case THEME_ID_KLP:
|
||||
return true;
|
||||
|
@ -292,11 +291,11 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean getIsUser(int themeId) {
|
||||
public static boolean getIsCustom(int themeId) {
|
||||
switch (themeId) {
|
||||
case THEME_ID_LXX_USER:
|
||||
case THEME_ID_LXX_USER_BORDER:
|
||||
case THEME_ID_KLP_USER:
|
||||
case THEME_ID_LXX_CUSTOM:
|
||||
case THEME_ID_LXX_CUSTOM_BORDER:
|
||||
case THEME_ID_KLP_CUSTOM:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -328,7 +327,7 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
boolean keyBorders, boolean dayNight, boolean amoledMode) {
|
||||
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_USER;
|
||||
if (THEME_VARIANT_HOLO_USER.equals(variant)) return THEME_ID_KLP_CUSTOM;
|
||||
return THEME_ID_KLP;
|
||||
}
|
||||
if (dayNight) {
|
||||
|
@ -341,9 +340,9 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
|
|||
if (amoledMode) return THEME_ID_LXX_DARK_AMOLED;
|
||||
return THEME_ID_LXX_DARK;
|
||||
}
|
||||
if (THEME_VARIANT_USER.equals(variant)) {
|
||||
if (keyBorders) return THEME_ID_LXX_USER_BORDER;
|
||||
return THEME_ID_LXX_USER;
|
||||
if (THEME_VARIANT_CUSTOM.equals(variant)) {
|
||||
if (keyBorders) return THEME_ID_LXX_CUSTOM_BORDER;
|
||||
return THEME_ID_LXX_CUSTOM;
|
||||
}
|
||||
if (keyBorders) return THEME_ID_LXX_LIGHT_BORDER;
|
||||
return THEME_ID_LXX_LIGHT;
|
||||
|
|
|
@ -182,7 +182,7 @@ public class KeyboardView extends View {
|
|||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
||||
mCustomTheme = settingsValues.mCustomTheme;
|
||||
if (mCustomTheme) {
|
||||
getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
|
||||
getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
||||
|
||||
keyBgFilter = settingsValues.mCustomKeyBackgroundColorFilter;
|
||||
keyHintTextColorFilter = settingsValues.mCustomHintTextColorFilter;
|
||||
|
|
|
@ -65,7 +65,7 @@ class ClipboardHistoryRecyclerView @JvmOverloads constructor(
|
|||
paint.strokeWidth = dividerHeight.toFloat()
|
||||
val settingsValues = Settings.getInstance().current
|
||||
if (settingsValues.mCustomTheme)
|
||||
paint.colorFilter = settingsValues.mBackgroundColorFilter
|
||||
paint.colorFilter = settingsValues.mCustomBackgroundColorFilter
|
||||
}
|
||||
|
||||
override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: State) {
|
||||
|
|
|
@ -105,7 +105,7 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
|||
alphabetKey.background.colorFilter = settingsValues.mCustomFunctionalKeyBackgroundColorFilter
|
||||
alphabetKey.setTextColor(settingsValues.mCustomKeyTextColor)
|
||||
clearKey.colorFilter = settingsValues.mCustomKeyTextColorFilter
|
||||
background.colorFilter = settingsValues.mBackgroundColorFilter
|
||||
background.colorFilter = settingsValues.mCustomBackgroundColorFilter
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.content.Context;
|
|||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -166,7 +165,7 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
iconView.setBackgroundColor(mCategoryPageIndicatorBackground);
|
||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
||||
if (settingsValues.mCustomTheme) {
|
||||
iconView.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
|
||||
iconView.getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
||||
iconView.setColorFilter(settingsValues.mCustomKeyTextColorFilter);
|
||||
}
|
||||
iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
|
||||
|
@ -275,9 +274,9 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
mAlphabetKeyLeft.getBackground().setColorFilter(settingsValues.mCustomFunctionalKeyBackgroundColorFilter);
|
||||
mSpacebar.getBackground().setColorFilter(settingsValues.mCustomSpaceBarBackgroundColorFilter);
|
||||
mDeleteKey.getBackground().setColorFilter(settingsValues.mCustomFunctionalKeyBackgroundColorFilter);
|
||||
getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
|
||||
mEmojiCategoryPageIndicatorView.setColors(settingsValues.mCustomThemeColorAccent, settingsValues.mBackgroundColor);
|
||||
findViewById(R.id.emoji_tab_strip).getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
|
||||
getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
||||
mEmojiCategoryPageIndicatorView.setColors(settingsValues.mCustomThemeColorAccent, settingsValues.mCustomBackgroundColor);
|
||||
findViewById(R.id.emoji_tab_strip).getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
||||
}
|
||||
mEmojiLayoutParams.setKeyProperties(mSpacebar);
|
||||
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
|
||||
|
|
|
@ -69,7 +69,7 @@ public class GestureFloatingTextDrawingPreview extends AbstractDrawingPreview {
|
|||
R.styleable.MainKeyboardView_gestureFloatingPreviewTextColor, 0);
|
||||
mGesturePreviewTextOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
|
||||
R.styleable.MainKeyboardView_gestureFloatingPreviewTextOffset, 0);
|
||||
mGesturePreviewColor = sv.mCustomTheme ? sv.mBackgroundColor : mainKeyboardViewAttr.getColor(
|
||||
mGesturePreviewColor = sv.mCustomTheme ? sv.mCustomBackgroundColor : mainKeyboardViewAttr.getColor(
|
||||
R.styleable.MainKeyboardView_gestureFloatingPreviewColor, 0);
|
||||
mGesturePreviewHorizontalPadding = mainKeyboardViewAttr.getDimension(
|
||||
R.styleable.MainKeyboardView_gestureFloatingPreviewHorizontalPadding, 0.0f);
|
||||
|
|
|
@ -121,7 +121,7 @@ public final class KeyPreviewChoreographer {
|
|||
keyPreviewView.setPreviewBackground(hasMoreKeys, keyPreviewPosition);
|
||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
||||
if (settingsValues.mCustomTheme) {
|
||||
keyPreviewView.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
|
||||
keyPreviewView.getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
||||
keyPreviewView.setTextColor(settingsValues.mCustomKeyTextColor);
|
||||
}
|
||||
// The key preview is placed vertically above the top edge of the parent key with an
|
||||
|
|
|
@ -2018,17 +2018,30 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
|
||||
// slightly modified from Simple Keyboard: https://github.com/rkkr/simple-keyboard/blob/master/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java
|
||||
// todo: this is currently broken, make it work again (and consider dayNight themes)
|
||||
/*
|
||||
final int background; // need to return correct background color for navBar, other colors not used
|
||||
if (KeyboardTheme.THEME_VARIANT_LIGHT.equals(KeyboardTheme.getThemeVariant(keyboardThemeId))) {
|
||||
background = Color.rgb(236, 239, 241);
|
||||
} else if (keyboardThemeId == KeyboardTheme.THEME_ID_LXX_DARK) {
|
||||
background = Color.rgb(38, 50, 56);
|
||||
} else {
|
||||
// dark border is 13/13/13, but that's ok
|
||||
background = Color.BLACK;
|
||||
}
|
||||
|
||||
*/
|
||||
private void setNavigationBarColor() {
|
||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || !settingsValues.mNavBarColor)
|
||||
return;
|
||||
final int color;
|
||||
if (settingsValues.mCustomTheme) {
|
||||
final int c = settingsValues.mBackgroundColor;
|
||||
final int c = settingsValues.mCustomBackgroundColor;
|
||||
// slightly adjust so color is same as keyboard background
|
||||
color = Color.rgb((int) (Color.red(c) * 0.925), (int) (Color.green(c) * 0.9379), (int) (Color.blue(c) * 0.945));
|
||||
} else
|
||||
color = settingsValues.mBackgroundColor;
|
||||
color = settingsValues.mCustomBackgroundColor;
|
||||
final Window window = getWindow().getWindow();
|
||||
if (window == null)
|
||||
return;
|
||||
|
|
|
@ -117,7 +117,7 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
|
|||
amoledModePref.apply {
|
||||
isEnabled = !isLegacyFamily && variant != KeyboardTheme.THEME_VARIANT_LIGHT
|
||||
&& !KeyboardTheme.getHasKeyBorders(selectedThemeId)
|
||||
&& !KeyboardTheme.getIsUser(selectedThemeId)
|
||||
&& !KeyboardTheme.getIsCustom(selectedThemeId)
|
||||
isChecked = !isLegacyFamily && KeyboardTheme.getIsAmoledMode(selectedThemeId)
|
||||
}
|
||||
dayNightPref?.apply {
|
||||
|
@ -125,7 +125,7 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
|
|||
isChecked = !isLegacyFamily && KeyboardTheme.getIsDayNight(selectedThemeId)
|
||||
}
|
||||
userColorsPref.apply {
|
||||
isEnabled = KeyboardTheme.getIsUser(selectedThemeId)
|
||||
isEnabled = KeyboardTheme.getIsCustom(selectedThemeId)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,12 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import android.view.Gravity;
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme;
|
||||
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
|
@ -36,7 +38,6 @@ import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
|||
import org.dslul.openboard.inputmethod.latin.utils.JniUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.RunInLocale;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.StatsUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -541,4 +542,59 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
return null;
|
||||
}
|
||||
|
||||
public static CustomColors getCustomColors(final SharedPreferences prefs) {
|
||||
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)
|
||||
);
|
||||
if (!KeyboardTheme.getIsCustom(keyboardThemeId))
|
||||
return new CustomColors();
|
||||
|
||||
// we have a custom theme, which is user only (at the moment)
|
||||
final int accent = prefs.getInt(Settings.PREF_THEME_USER_COLOR_ACCENT, Color.BLUE);
|
||||
final int keyBgColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_KEYS, Color.LTGRAY);
|
||||
final int keyTextColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_TEXT, Color.WHITE);
|
||||
final int hintTextColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_HINT_TEXT, Color.WHITE);
|
||||
final int background = prefs.getInt(Settings.PREF_THEME_USER_COLOR_BACKGROUND, Color.DKGRAY);
|
||||
|
||||
return new CustomColors(accent, background, keyBgColor, keyBgColor, keyBgColor, keyTextColor, hintTextColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// class for forwarding custom colors to SettingsValues
|
||||
// (kotlin data class could be 3 lines...)
|
||||
// actually this could contain the color filters too, which would allow more flexibility (only do if needed)
|
||||
class CustomColors {
|
||||
boolean isCustom;
|
||||
int accent;
|
||||
int background;
|
||||
int keyBackground;
|
||||
int functionalKey; // this color will appear darker than set, as it is applied using a color filter in modulate mode
|
||||
int spaceBar;
|
||||
int keyText;
|
||||
int keyHintText;
|
||||
public CustomColors(int acc, int bg, int k, int fun, int space, int kt, int kht) {
|
||||
isCustom = true;
|
||||
accent = acc;
|
||||
background = bg;
|
||||
keyBackground = k;
|
||||
functionalKey = fun;
|
||||
spaceBar = space;
|
||||
keyText = kt;
|
||||
keyHintText = kht;
|
||||
}
|
||||
public CustomColors() {
|
||||
isCustom = false;
|
||||
accent = 0;
|
||||
background = 0;
|
||||
keyBackground = 0;
|
||||
functionalKey = 0;
|
||||
spaceBar = 0;
|
||||
keyText = 0;
|
||||
keyHintText = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.util.Log;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
|
@ -30,7 +29,6 @@ import androidx.core.graphics.BlendModeColorFilterCompat;
|
|||
import androidx.core.graphics.BlendModeCompat;
|
||||
|
||||
import org.dslul.openboard.inputmethod.compat.AppWorkaroundsUtils;
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme;
|
||||
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager;
|
||||
|
@ -133,8 +131,8 @@ public class SettingsValues {
|
|||
public final ColorFilter mCustomKeyBackgroundColorFilter;
|
||||
public final ColorFilter mCustomFunctionalKeyBackgroundColorFilter;
|
||||
public final ColorFilter mCustomSpaceBarBackgroundColorFilter;
|
||||
public final int mBackgroundColor;
|
||||
public final ColorFilter mBackgroundColorFilter;
|
||||
public final int mCustomBackgroundColor;
|
||||
public final ColorFilter mCustomBackgroundColorFilter;
|
||||
public final ColorFilter mCustomKeyTextColorFilter;
|
||||
public final ColorFilter mCustomHintTextColorFilter;
|
||||
public final int mCustomThemeColorAccent;
|
||||
|
@ -266,37 +264,24 @@ public class SettingsValues {
|
|||
mOneHandedModeGravity = Settings.readOneHandedModeGravity(prefs);
|
||||
mSecondaryLocale = Settings.getSecondaryLocale(prefs, RichInputMethodManager.getInstance().getCurrentSubtypeLocale().toString());
|
||||
|
||||
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)
|
||||
);
|
||||
mCustomTheme = KeyboardTheme.getIsUser(keyboardThemeId);
|
||||
mCustomThemeColorAccent = prefs.getInt(Settings.PREF_THEME_USER_COLOR_ACCENT, Color.BLUE);
|
||||
final int keyBgColor;
|
||||
if (prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false))
|
||||
keyBgColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_KEYS, Color.LTGRAY);
|
||||
else
|
||||
keyBgColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_BACKGROUND, Color.DKGRAY);
|
||||
mCustomKeyBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(keyBgColor, BlendModeCompat.MODULATE);
|
||||
mCustomHintTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(prefs.getInt(Settings.PREF_THEME_USER_COLOR_HINT_TEXT, Color.WHITE), BlendModeCompat.SRC_ATOP);
|
||||
mCustomFunctionalKeyBackgroundColorFilter = mCustomKeyBackgroundColorFilter;
|
||||
mCustomSpaceBarBackgroundColorFilter = mCustomKeyBackgroundColorFilter;
|
||||
mCustomKeyTextColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_TEXT, Color.WHITE);
|
||||
mCustomKeyTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mCustomKeyTextColor, BlendModeCompat.SRC_ATOP);
|
||||
if (mCustomTheme) {
|
||||
mBackgroundColor = prefs.getInt(Settings.PREF_THEME_USER_COLOR_BACKGROUND, Color.DKGRAY);
|
||||
} else if (KeyboardTheme.THEME_VARIANT_LIGHT.equals(KeyboardTheme.getThemeVariant(keyboardThemeId))) {
|
||||
mBackgroundColor = Color.rgb(236, 239, 241);
|
||||
} else if (keyboardThemeId == KeyboardTheme.THEME_ID_LXX_DARK) {
|
||||
mBackgroundColor = Color.rgb(38, 50, 56);
|
||||
final CustomColors colors = Settings.getCustomColors(prefs);
|
||||
mCustomTheme = colors.isCustom;
|
||||
mCustomThemeColorAccent = colors.accent;
|
||||
mCustomKeyTextColor = colors.keyText;
|
||||
mCustomBackgroundColor = colors.background;
|
||||
mCustomBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mCustomBackgroundColor, BlendModeCompat.MODULATE);
|
||||
if (prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false)) {
|
||||
mCustomKeyBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colors.keyBackground, BlendModeCompat.MODULATE);
|
||||
mCustomFunctionalKeyBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colors.functionalKey, BlendModeCompat.MODULATE);
|
||||
mCustomSpaceBarBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colors.spaceBar, BlendModeCompat.MODULATE);
|
||||
} else {
|
||||
// dark border is 13/13/13, but that's ok
|
||||
mBackgroundColor = Color.BLACK;
|
||||
// need to set color to background if key borders are disabled, or there will be ugly keys
|
||||
mCustomKeyBackgroundColorFilter = mCustomBackgroundColorFilter;
|
||||
mCustomFunctionalKeyBackgroundColorFilter = mCustomBackgroundColorFilter;
|
||||
mCustomSpaceBarBackgroundColorFilter = mCustomBackgroundColorFilter;
|
||||
}
|
||||
mBackgroundColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mBackgroundColor, BlendModeCompat.MODULATE);
|
||||
mCustomHintTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colors.keyHintText, BlendModeCompat.SRC_ATOP);
|
||||
mCustomKeyTextColorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(mCustomKeyTextColor, BlendModeCompat.SRC_ATOP);
|
||||
|
||||
mAddToPersonalDictionary = prefs.getBoolean(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, false);
|
||||
mUseContactsDictionary = prefs.getBoolean(AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY, false);
|
||||
|
|
|
@ -183,7 +183,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
|
||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
||||
if (settingsValues.mCustomTheme) {
|
||||
mStripVisibilityGroup.mSuggestionStripView.getBackground().setColorFilter(settingsValues.mBackgroundColorFilter);
|
||||
mStripVisibilityGroup.mSuggestionStripView.getBackground().setColorFilter(settingsValues.mCustomBackgroundColorFilter);
|
||||
mClipboardKey.setColorFilter(settingsValues.mCustomKeyTextColor);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue