diff options
author | 2011-05-24 21:08:20 +0900 | |
---|---|---|
committer | 2011-05-25 18:59:00 +0900 | |
commit | 13a741999480343ccebd81ff6349b572bde17b07 (patch) | |
tree | 2f53327a78cfd8c16b1263d8165effe7f8fe1c4f /java/src/com/android/inputmethod | |
parent | 6c4add55f94ff729ef1aa35c4f8df3b086344f8a (diff) | |
download | latinime-13a741999480343ccebd81ff6349b572bde17b07.tar.gz latinime-13a741999480343ccebd81ff6349b572bde17b07.tar.xz latinime-13a741999480343ccebd81ff6349b572bde17b07.zip |
Use custom theme for Keyboard theme switch
This change reduces the number of layout files and make these
theme-generic. This might be very helpful to re-design suggestion
strip.
Bug: 4175031
Change-Id: Idca10a4aa0bf7ac496eedd1879311e59780a423b
Diffstat (limited to 'java/src/com/android/inputmethod')
3 files changed, 17 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 34973105e..195c929fa 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -20,6 +20,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.util.Log; +import android.view.ContextThemeWrapper; import android.view.InflateException; import android.view.LayoutInflater; import android.view.View; @@ -45,12 +46,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private static String sConfigDefaultKeyboardThemeId; public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20100902"; private static final int[] KEYBOARD_THEMES = { - R.layout.input_basic, - R.layout.input_basic_highcontrast, - R.layout.input_stone_normal, - R.layout.input_stone_bold, - R.layout.input_gingerbread, - R.layout.input_honeycomb, + R.style.KeyboardTheme, + R.style.KeyboardTheme_HighContrast, + R.style.KeyboardTheme_Stone, + R.style.KeyboardTheme_Stone_Bold, + R.style.KeyboardTheme_Gingerbread, + R.style.KeyboardTheme_Honeycomb, }; private SubtypeSwitcher mSubtypeSwitcher; @@ -730,8 +731,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha boolean tryGC = true; for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { - mCurrentInputView = LayoutInflater.from(mInputMethodService).inflate( - KEYBOARD_THEMES[themeIndex], null); + final Context themeContext = new ContextThemeWrapper(mInputMethodService, + KEYBOARD_THEMES[themeIndex]); + mCurrentInputView = LayoutInflater.from(themeContext).inflate( + R.layout.input_view, null); tryGC = false; } catch (OutOfMemoryError e) { Log.w(TAG, "load keyboard failed: " + e); diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 583b997ee..185f1f8f7 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -16,10 +16,6 @@ package com.android.inputmethod.keyboard; -import com.android.inputmethod.deprecated.VoiceProxy; -import com.android.inputmethod.latin.LatinImeLogger; -import com.android.inputmethod.latin.Utils; - import android.content.Context; import android.graphics.Canvas; import android.text.TextUtils; @@ -27,6 +23,10 @@ import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; +import com.android.inputmethod.deprecated.VoiceProxy; +import com.android.inputmethod.latin.LatinImeLogger; +import com.android.inputmethod.latin.Utils; + // TODO: We should remove this class public class LatinKeyboardView extends KeyboardView { private static final String TAG = LatinKeyboardView.class.getSimpleName(); @@ -47,7 +47,7 @@ public class LatinKeyboardView extends KeyboardView { private int mLastY; public LatinKeyboardView(Context context, AttributeSet attrs) { - this(context, attrs, 0); + super(context, attrs); } public LatinKeyboardView(Context context, AttributeSet attrs, int defStyle) { diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java index 62a32cf3c..fa2aa874c 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java @@ -41,7 +41,7 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { private long mDownTime; public PopupMiniKeyboardView(Context context, AttributeSet attrs) { - this(context, attrs, R.attr.keyboardViewStyle); + this(context, attrs, R.attr.popupMiniKeyboardViewStyle); } public PopupMiniKeyboardView(Context context, AttributeSet attrs, int defStyle) { |