From d47dca429e74b47cfbf4200dd23c8f5a1e5791ec Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Fri, 9 May 2014 11:28:19 +0000 Subject: Revert "Refactor KeyboardTheme" This reverts commit 19688b584bb903192559196a0e3836bc4c957696. Build breakage. Change-Id: I95d4be1578824eaee5a2fb08ec277250727ac668 --- .../inputmethod/keyboard/KeyboardSwitcher.java | 7 +- .../inputmethod/keyboard/KeyboardTheme.java | 126 +++------------------ .../inputmethod/latin/settings/Settings.java | 2 +- .../latin/settings/SettingsFragment.java | 25 +--- 4 files changed, 24 insertions(+), 136 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 4a46a4a46..1cd6ef249 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -64,7 +64,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { * what user actually typed. */ private boolean mIsAutoCorrectionActive; - private KeyboardTheme mKeyboardTheme; + private KeyboardTheme mKeyboardTheme = KeyboardTheme.getDefaultKeyboardTheme(); private Context mThemeContext; private static final KeyboardSwitcher sInstance = new KeyboardSwitcher(); @@ -101,7 +101,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context, final KeyboardTheme keyboardTheme) { - if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme)) { + if (mThemeContext == null || mKeyboardTheme.mThemeId != keyboardTheme.mThemeId) { mKeyboardTheme = keyboardTheme; mThemeContext = new ContextThemeWrapper(context, keyboardTheme.mStyleId); KeyboardLayoutSet.clearKeyboardCache(); @@ -342,8 +342,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mKeyboardView.closing(); } - updateKeyboardThemeAndContextThemeWrapper( - mLatinIME, KeyboardTheme.getKeyboardTheme(mPrefs)); + updateKeyboardThemeAndContextThemeWrapper(mLatinIME, mKeyboardTheme); mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate( R.layout.input_view, null); mMainKeyboardFrame = mCurrentInputView.findViewById(R.id.main_keyboard_frame); diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java b/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java index 5034540cf..4db72ad4d 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java @@ -17,86 +17,34 @@ package com.android.inputmethod.keyboard; import android.content.SharedPreferences; -import android.os.Build; -import android.os.Build.VERSION_CODES; import android.util.Log; import com.android.inputmethod.latin.R; - -import java.util.Arrays; -import java.util.Comparator; +import com.android.inputmethod.latin.settings.Settings; public final class KeyboardTheme { private static final String TAG = KeyboardTheme.class.getSimpleName(); - static final String KITKAT_KEYBOARD_THEME_KEY = "pref_keyboard_layout_20110916"; - static final String KEYBOARD_THEME_KEY = "pref_keyboard_theme_20140509"; - - static final int THEME_ID_ICS = 0; - static final int THEME_ID_KLP = 2; - static final int THEME_ID_LMP = 3; - static final int DEFAULT_THEME_ID = THEME_ID_KLP; + public static final int THEME_ID_ICS = 0; + public static final int THEME_ID_KLP = 2; + private static final int DEFAULT_THEME_ID = THEME_ID_KLP; private static final KeyboardTheme[] KEYBOARD_THEMES = { - new KeyboardTheme(THEME_ID_ICS, R.style.KeyboardTheme_ICS, - VERSION_CODES.ICE_CREAM_SANDWICH), - new KeyboardTheme(THEME_ID_KLP, R.style.KeyboardTheme_KLP, - VERSION_CODES.KITKAT), - // TODO: Update to LMP style. - new KeyboardTheme(THEME_ID_LMP, R.style.KeyboardTheme_KLP, - // TODO: Update this constant once the *next* version becomes available. - VERSION_CODES.CUR_DEVELOPMENT), + new KeyboardTheme(THEME_ID_ICS, R.style.KeyboardTheme_ICS), + new KeyboardTheme(THEME_ID_KLP, R.style.KeyboardTheme_KLP), }; - static { - // Sort {@link #KEYBOARD_THEME} by descending order of {@link #mMinApiVersion}. - Arrays.sort(KEYBOARD_THEMES, new Comparator() { - @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/themes-