aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2013-11-11 20:39:03 +0900
committerThe Android Automerger <android-build@android.com>2013-11-22 17:26:33 -0800
commitdb86a6f271e5ca446382061f219928c5eb6b9f01 (patch)
tree9e6379c318d6cce1906acacb86e0997f58c1d1e9 /java/src/com
parent51352009b5ac418d20826e034e5989705131aeca (diff)
downloadlatinime-db86a6f271e5ca446382061f219928c5eb6b9f01.tar.gz
latinime-db86a6f271e5ca446382061f219928c5eb6b9f01.tar.xz
latinime-db86a6f271e5ca446382061f219928c5eb6b9f01.zip
Add keyboard color switch option
Bug: 11622614 Change-Id: I25aa1ff7376fe72fd94ab2cb7190c61d7a98a1af
Diffstat (limited to 'java/src/com')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java20
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java1
-rw-r--r--java/src/com/android/inputmethod/latin/settings/DebugSettings.java4
3 files changed, 19 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index f893636ad..a6b293f2f 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -27,6 +27,7 @@ import android.view.View;
import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
+import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetException;
import com.android.inputmethod.keyboard.internal.KeyboardState;
import com.android.inputmethod.latin.InputView;
@@ -75,6 +76,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private EmojiPalettesView mEmojiPalettesView;
private LatinIME mLatinIME;
private Resources mResources;
+ private boolean mIsHardwareAcceleratedDrawingEnabled;
private KeyboardState mState;
@@ -108,7 +110,16 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mPrefs = prefs;
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mState = new KeyboardState(this);
- setContextThemeWrapper(latinIme, getKeyboardTheme(latinIme, prefs));
+ mIsHardwareAcceleratedDrawingEnabled =
+ InputMethodServiceCompatUtils.enableHardwareAcceleration(mLatinIME);
+ }
+
+ public void updateKeyboardTheme() {
+ final boolean themeUpdated = updateKeyboardThemeAndContextThemeWrapper(
+ mLatinIME, getKeyboardTheme(mLatinIME, mPrefs));
+ if (themeUpdated && mKeyboardView != null) {
+ mLatinIME.setInputView(onCreateInputView(mIsHardwareAcceleratedDrawingEnabled));
+ }
}
private static KeyboardTheme getKeyboardTheme(final Context context,
@@ -128,12 +139,15 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
return KEYBOARD_THEMES[Integer.valueOf(defaultIndex)];
}
- private void setContextThemeWrapper(final Context context, final KeyboardTheme keyboardTheme) {
+ private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context,
+ final KeyboardTheme keyboardTheme) {
if (mThemeContext == null || mKeyboardTheme.mThemeId != keyboardTheme.mThemeId) {
mKeyboardTheme = keyboardTheme;
mThemeContext = new ContextThemeWrapper(context, keyboardTheme.mStyleId);
KeyboardLayoutSet.clearKeyboardCache();
+ return true;
}
+ return false;
}
public void loadKeyboard(final EditorInfo editorInfo, final SettingsValues settingsValues) {
@@ -365,7 +379,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mKeyboardView.closing();
}
- setContextThemeWrapper(mLatinIME, mKeyboardTheme);
+ 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/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index fc07ce730..32e5e833e 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -811,6 +811,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
super.onStartInputView(editorInfo, restarting);
mRichImm.clearSubtypeCaches();
final KeyboardSwitcher switcher = mKeyboardSwitcher;
+ switcher.updateKeyboardTheme();
final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView();
// If we are starting input in a different text field from before, we'll have to reload
// settings, so currentSettingsValues can't be final.
diff --git a/java/src/com/android/inputmethod/latin/settings/DebugSettings.java b/java/src/com/android/inputmethod/latin/settings/DebugSettings.java
index 1b592b565..da1fb73fe 100644
--- a/java/src/com/android/inputmethod/latin/settings/DebugSettings.java
+++ b/java/src/com/android/inputmethod/latin/settings/DebugSettings.java
@@ -113,9 +113,7 @@ public final class DebugSettings extends PreferenceFragment
mServiceNeedsRestart = true;
}
} else if (key.equals(PREF_FORCE_NON_DISTINCT_MULTITOUCH)
- || key.equals(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT)) {
- mServiceNeedsRestart = true;
- } else if (key.equals(PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG)) {
+ || key.equals(PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG)) {
mServiceNeedsRestart = true;
}
}