From 093a00c572a29d292bc6bbb09559611cb61e1331 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 30 Dec 2021 00:26:05 +0100 Subject: Add themes Add a "Theme" option to choose between a dark and light theme. The light theme uses the colors of the dark theme with the luminance inversed. The reloading after a configuration change is changed slightly: - Special handling is needed when the Theme is changed (recreate the views) - The default implementation of 'onConfigurationChanged' is used Which triggers more refresh (but don't recreate the views) - 'onCreateInputView' is no longer needed --- srcs/juloo.keyboard2/Config.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'srcs/juloo.keyboard2/Config.java') diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 73c43be..fdac104 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -29,6 +29,7 @@ final class Config public boolean preciseRepeat; public float characterSize; // Ratio public int accents; // Values are R.values.pref_accents_v_* + public int theme; // Values are R.style.* // Dynamically set public boolean shouldOfferSwitchingToNextInputMethod; @@ -85,6 +86,7 @@ final class Config preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat); characterSize = prefs.getFloat("character_size", characterSize); accents = Integer.valueOf(prefs.getString("accents", "1")); + theme = themeId_of_string(prefs.getString("theme", "")); } private float getDipPref(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def) @@ -121,6 +123,15 @@ final class Config } } + public static int themeId_of_string(String name) + { + switch (name) + { + case "light": return R.style.Light; + default: case "dark": return R.style.Dark; + } + } + private static Config _globalConfig = null; public static void initGlobalConfig(Context context, IKeyEventHandler handler) -- cgit v1.2.3