From 19688b584bb903192559196a0e3836bc4c957696 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 8 May 2014 12:04:36 +0900 Subject: [PATCH] Refactor KeyboardTheme This CL introduces two preference keys in addition to the existing one. - pref_keyboard_theme: The new preference key that is used only in the preference settings. - pref_keyboard_layout_20110916: The previous preference key that holds keyboard color scheme settings. This is superseded by the next key. - pref_keyboard_theme_20140509: The new preference key that holds keyboard theme settings. This value is forcibly reset to LMP theme on a LMP device. On a KitKat and previous device, the settings of the pref_keyboard_layout_20110916 is carried on into this preference. This CL must be checked in together with Ifcedeabbec. Change-Id: Ibe75146e2c1c7eebf964ca86550baf244fedb79a --- java/res/values/config-common.xml | 3 - java/res/values/keyboard-themes.xml | 34 +++++ java/res/xml/prefs.xml | 5 +- .../keyboard/KeyboardSwitcher.java | 7 +- .../inputmethod/keyboard/KeyboardTheme.java | 126 +++++++++++++++--- .../inputmethod/latin/settings/Settings.java | 2 +- .../latin/settings/SettingsFragment.java | 25 +++- .../keyboard/KeyboardLayoutSetTestsBase.java | 8 +- .../keyboard/KeyboardThemeTests.java | 93 +++++++++++++ 9 files changed, 269 insertions(+), 34 deletions(-) create mode 100644 java/res/values/keyboard-themes.xml create mode 100644 tests/src/com/android/inputmethod/keyboard/KeyboardThemeTests.java diff --git a/java/res/values/config-common.xml b/java/res/values/config-common.xml index 3fe4b947c..1962c0d45 100644 --- a/java/res/values/config-common.xml +++ b/java/res/values/config-common.xml @@ -24,9 +24,6 @@ at input history to suggest a hopefully helpful suggestions for the next word? --> true - - 2 - 100 1100 diff --git a/java/res/values/keyboard-themes.xml b/java/res/values/keyboard-themes.xml new file mode 100644 index 000000000..0325f5be0 --- /dev/null +++ b/java/res/values/keyboard-themes.xml @@ -0,0 +1,34 @@ + + + + + + @string/keyboard_color_scheme_white + @string/keyboard_color_scheme_blue + + Quantum + + + + 2 + 0 + 3 + + diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index 7d86dbd5d..61ebb6992 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -158,12 +158,11 @@ android:persistent="true" android:defaultValue="false" /> + android:entries="@array/keyboard_theme_names" /> () { + @Override + public int compare(final KeyboardTheme lhs, final KeyboardTheme rhs) { + if (lhs.mMinApiVersion > rhs.mMinApiVersion) return -1; + if (lhs.mMinApiVersion < rhs.mMinApiVersion) return 1; + return 0; + } + }); + } public final int mThemeId; public final int mStyleId; + final int mMinApiVersion; // Note: The themeId should be aligned with "themeId" attribute of Keyboard style - // in values/style.xml. - public KeyboardTheme(final int themeId, final int styleId) { + // in values/themes-