diff options
-rw-r--r-- | java/res/drawable/btn_keyboard_key_stone.xml | 7 | ||||
-rw-r--r-- | java/res/values/attrs.xml | 7 | ||||
-rw-r--r-- | java/res/values/styles.xml | 2 | ||||
-rw-r--r-- | java/res/xml-sw600dp/kbd_key_styles.xml | 18 | ||||
-rw-r--r-- | java/res/xml-sw768dp/kbd_key_styles.xml | 18 | ||||
-rw-r--r-- | java/res/xml/kbd_key_styles.xml | 18 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardId.java | 29 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java | 11 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardView.java | 10 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java | 14 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java | 23 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/SuggestTestsBase.java | 9 |
12 files changed, 50 insertions, 116 deletions
diff --git a/java/res/drawable/btn_keyboard_key_stone.xml b/java/res/drawable/btn_keyboard_key_stone.xml index a6040a04e..27932e8da 100644 --- a/java/res/drawable/btn_keyboard_key_stone.xml +++ b/java/res/drawable/btn_keyboard_key_stone.xml @@ -16,6 +16,13 @@ <selector xmlns:android="http://schemas.android.com/apk/res/android"> + <!-- Functional keys. --> + + <item android:state_single="true" android:state_pressed="true" + android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> + <item android:state_single="true" + android:drawable="@drawable/btn_keyboard_key_normal_stone" /> + <!-- Toggle keys. Use checkable/checked state. --> <item android:state_checkable="true" android:state_checked="true" diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index c88049e14..d8d31e334 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -90,13 +90,6 @@ <enum name="italic" value="2" /> <enum name="boldItalic" value="3" /> </attr> - - <attr name="colorScheme" format="enum"> - <!-- This should be aligned with KeyboardView.COLOR_SCHEME_* --> - <enum name="white" value="0" /> - <enum name="black" value="1" /> - </attr> - </declare-styleable> <declare-styleable name="CandidateView"> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 3780fe3d2..1363f64d8 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -59,7 +59,6 @@ <item name="shadowColor">#BB000000</item> <item name="shadowRadius">2.75</item> <item name="backgroundDimAmount">0.5</item> - <item name="colorScheme">white</item> </style> <style name="KeyPreviewStyle"> <item name="android:background">@drawable/keyboard_key_feedback</item> @@ -107,7 +106,6 @@ <item name="keyTextColor">@color/latinkeyboard_key_color_black</item> <item name="keyTextInactivatedColor">#FF808080</item> <item name="shadowColor">@color/latinkeyboard_key_color_white</item> - <item name="colorScheme">black</item> </style> <style name="PopupMiniKeyboardView.Stone" parent="PopupMiniKeyboardView"> <item name="keyBackground">@drawable/btn_keyboard_key_stone</item> diff --git a/java/res/xml-sw600dp/kbd_key_styles.xml b/java/res/xml-sw600dp/kbd_key_styles.xml index 988f5c490..dbff293ba 100644 --- a/java/res/xml-sw600dp/kbd_key_styles.xml +++ b/java/res/xml-sw600dp/kbd_key_styles.xml @@ -22,21 +22,9 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > <!-- Base key style for the functional key --> - <switch> - <case - latin:colorScheme="white" - > - <key-style - latin:styleName="functionalKeyStyle" - latin:isFunctional="true" /> - </case> - <case - latin:colorScheme="black" - > - <key-style - latin:styleName="functionalKeyStyle" /> - </case> - </switch> + <key-style + latin:styleName="functionalKeyStyle" + latin:isFunctional="true" /> <!-- Functional key styles --> <key-style latin:styleName="shiftKeyStyle" diff --git a/java/res/xml-sw768dp/kbd_key_styles.xml b/java/res/xml-sw768dp/kbd_key_styles.xml index ecfacc25b..5d8c081a6 100644 --- a/java/res/xml-sw768dp/kbd_key_styles.xml +++ b/java/res/xml-sw768dp/kbd_key_styles.xml @@ -22,21 +22,9 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > <!-- Functional key styles --> - <switch> - <case - latin:colorScheme="white" - > - <key-style - latin:styleName="functionalKeyStyle" - latin:isFunctional="true" /> - </case> - <case - latin:colorScheme="black" - > - <key-style - latin:styleName="functionalKeyStyle" /> - </case> - </switch> + <key-style + latin:styleName="functionalKeyStyle" + latin:isFunctional="true" /> <key-style latin:styleName="shiftKeyStyle" latin:code="@integer/key_shift" diff --git a/java/res/xml/kbd_key_styles.xml b/java/res/xml/kbd_key_styles.xml index fbc4c920f..0c59fd8a6 100644 --- a/java/res/xml/kbd_key_styles.xml +++ b/java/res/xml/kbd_key_styles.xml @@ -22,21 +22,9 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > <!-- Base key style for the functional key --> - <switch> - <case - latin:colorScheme="white" - > - <key-style - latin:styleName="functionalKeyStyle" - latin:isFunctional="true" /> - </case> - <case - latin:colorScheme="black" - > - <key-style - latin:styleName="functionalKeyStyle" /> - </case> - </switch> + <key-style + latin:styleName="functionalKeyStyle" + latin:isFunctional="true" /> <!-- Base key style for the key which may have settings key as popup key --> <switch> <case diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index d97bb6730..2497eeb7b 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -42,7 +42,6 @@ public class KeyboardId { public final int mWidth; public final int mMode; public final int mXmlId; - public final int mColorScheme; public final boolean mNavigateAction; public final boolean mPasswordInput; public final boolean mHasSettingsKey; @@ -56,9 +55,9 @@ public class KeyboardId { private final int mHashCode; - public KeyboardId(String xmlName, int xmlId, int colorScheme, Locale locale, int orientation, - int width, int mode, EditorInfo attribute, boolean hasSettingsKey, - boolean voiceKeyEnabled, boolean hasVoiceKey, boolean enableShiftLock) { + public KeyboardId(String xmlName, int xmlId, Locale locale, int orientation, int width, + int mode, EditorInfo attribute, boolean hasSettingsKey, boolean voiceKeyEnabled, + boolean hasVoiceKey, boolean enableShiftLock) { final int inputType = (attribute != null) ? attribute.inputType : 0; final int imeOptions = (attribute != null) ? attribute.imeOptions : 0; this.mLocale = locale; @@ -66,7 +65,6 @@ public class KeyboardId { this.mWidth = width; this.mMode = mode; this.mXmlId = xmlId; - this.mColorScheme = colorScheme; // Note: Turn off checking navigation flag to show TAB key for now. this.mNavigateAction = InputTypeCompatUtils.isWebInputType(inputType); // || EditorInfoCompatUtils.hasFlagNavigateNext(imeOptions) @@ -91,7 +89,6 @@ public class KeyboardId { width, mode, xmlId, - colorScheme, mNavigateAction, mPasswordInput, hasSettingsKey, @@ -103,15 +100,15 @@ public class KeyboardId { } public KeyboardId cloneWithNewLayout(String xmlName, int xmlId) { - return new KeyboardId(xmlName, xmlId, mColorScheme, mLocale, mOrientation, mWidth, mMode, - mAttribute, mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock); + return new KeyboardId(xmlName, xmlId, mLocale, mOrientation, mWidth, mMode, mAttribute, + mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock); } public KeyboardId cloneWithNewGeometry(int width) { if (mWidth == width) return this; - return new KeyboardId(mXmlName, mXmlId, mColorScheme, mLocale, mOrientation, width, mMode, - mAttribute, mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock); + return new KeyboardId(mXmlName, mXmlId, mLocale, mOrientation, width, mMode, mAttribute, + mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock); } public int getXmlId() { @@ -145,7 +142,6 @@ public class KeyboardId { && other.mWidth == this.mWidth && other.mMode == this.mMode && other.mXmlId == this.mXmlId - && other.mColorScheme == this.mColorScheme && other.mNavigateAction == this.mNavigateAction && other.mPasswordInput == this.mPasswordInput && other.mHasSettingsKey == this.mHasSettingsKey @@ -162,13 +158,12 @@ public class KeyboardId { @Override public String toString() { - return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s%s]", + return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s]", mXmlName, mLocale, (mOrientation == 1 ? "port" : "land"), mWidth, modeName(mMode), EditorInfoCompatUtils.imeOptionsName(mImeAction), - colorSchemeName(mColorScheme), (mNavigateAction ? " navigateAction" : ""), (mPasswordInput ? " passwordInput" : ""), (mHasSettingsKey ? " hasSettingsKey" : ""), @@ -189,12 +184,4 @@ public class KeyboardId { } return null; } - - public static String colorSchemeName(int colorScheme) { - switch (colorScheme) { - case KeyboardView.COLOR_SCHEME_WHITE: return "white"; - case KeyboardView.COLOR_SCHEME_BLACK: return "black"; - } - return null; - } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 157337cca..7c7016840 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -258,7 +258,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private KeyboardId getKeyboardId(EditorInfo attribute, boolean isSymbols) { final int mode = Utils.getKeyboardMode(attribute); final boolean hasVoiceKey = hasVoiceKey(isSymbols); - final int charColorId = getColorScheme(); final int xmlId; final boolean enableShiftLock; @@ -291,9 +290,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mKeyboardWidth = res.getDisplayMetrics().widthPixels; final Locale locale = mSubtypeSwitcher.getInputLocale(); return new KeyboardId( - res.getResourceEntryName(xmlId), xmlId, charColorId, locale, orientation, - mKeyboardWidth, mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, - enableShiftLock); + res.getResourceEntryName(xmlId), xmlId, locale, orientation, mKeyboardWidth, + mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock); } private KeyboardId makeSiblingKeyboardId(KeyboardId base, int alphabet, int phone) { @@ -788,11 +786,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } } - private int getColorScheme() { - return (mKeyboardView != null) - ? mKeyboardView.getColorScheme() : KeyboardView.COLOR_SCHEME_WHITE; - } - public void onAutoCorrectionStateChanged(boolean isAutoCorrection) { if (mIsAutoCorrectionActive != isAutoCorrection) { mIsAutoCorrectionActive = isAutoCorrection; diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 4c6f29a92..3891230d2 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -63,7 +63,6 @@ import java.util.WeakHashMap; * presses and touch movements. * * @attr ref R.styleable#KeyboardView_backgroundDimAmount - * @attr ref R.styleable#KeyboardView_colorScheme * @attr ref R.styleable#KeyboardView_keyBackground * @attr ref R.styleable#KeyboardView_keyHysteresisDistance * @attr ref R.styleable#KeyboardView_keyLetterRatio @@ -92,9 +91,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { private static final boolean ENABLE_CAPSLOCK_BY_LONGPRESS = true; private static final boolean ENABLE_CAPSLOCK_BY_DOUBLETAP = true; - public static final int COLOR_SCHEME_WHITE = 0; - public static final int COLOR_SCHEME_BLACK = 1; - // Timing constants private final int mKeyRepeatInterval; @@ -110,7 +106,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { private final float mKeyLabelRatio; private final float mKeyHintLetterRatio; private final float mKeyUppercaseLetterRatio; - private final int mColorScheme; private final int mShadowColor; private final float mShadowRadius; private final Drawable mKeyBackground; @@ -357,7 +352,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f); // TODO: Use Theme (android.R.styleable.Theme_backgroundDimAmount) mBackgroundDimAmount = a.getFloat(R.styleable.KeyboardView_backgroundDimAmount, 0.5f); - mColorScheme = a.getInt(R.styleable.KeyboardView_colorScheme, COLOR_SCHEME_WHITE); a.recycle(); final Resources res = getResources(); @@ -566,10 +560,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { return mShowKeyPreviewPopup; } - public int getColorScheme() { - return mColorScheme; - } - /** * When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key * codes for adjacent keys. When disabled, only the primary key code will be diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java index 7be738ceb..9916af5da 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java @@ -16,13 +16,17 @@ package com.android.inputmethod.keyboard.internal; +import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; +import android.util.Log; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.latin.R; public class KeyboardIconsSet { + private static final String TAG = KeyboardIconsSet.class.getSimpleName(); + public static final int ICON_UNDEFINED = 0; // This should be aligned with Keyboard.keyIcon enum. @@ -130,9 +134,13 @@ public class KeyboardIconsSet { final int attrIndex = keyboardAttrs.getIndex(i); final int iconId = getIconId(attrIndex); if (iconId != ICON_UNDEFINED) { - final Drawable icon = keyboardAttrs.getDrawable(attrIndex); - Keyboard.setDefaultBounds(icon); - mIcons[iconId] = icon; + try { + final Drawable icon = keyboardAttrs.getDrawable(attrIndex); + Keyboard.setDefaultBounds(icon); + mIcons[iconId] = icon; + } catch (Resources.NotFoundException e) { + Log.w(TAG, "Drawable resource for icon #" + iconId + " not found"); + } } } } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java index 9525b0e00..78546f879 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java @@ -90,14 +90,14 @@ import java.util.List; * You can declare Key style and specify styles within Key tags. * <pre> * >switch< - * >case colorScheme="white"< - * >key-style styleName="shift-key" parentStyle="modifier-key" - * keyIcon="@drawable/sym_keyboard_shift" + * >case mode="email"< + * >key-style styleName="f1-key" parentStyle="modifier-key" + * keyLabel=".com" * /< * >/case< - * >case colorScheme="black"< - * >key-style styleName="shift-key" parentStyle="modifier-key" - * keyIcon="@drawable/sym_bkeyboard_shift" + * >case mode="url"< + * >key-style styleName="f1-key" parentStyle="modifier-key" + * keyLabel="http://" * /< * >/case< * >/switch< @@ -487,8 +487,6 @@ public class KeyboardParser { R.styleable.Keyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled); final boolean voiceKeyMatched = matchBoolean(a, R.styleable.Keyboard_Case_hasVoiceKey, id.mHasVoiceKey); - final boolean colorSchemeMatched = matchInteger(viewAttr, - R.styleable.KeyboardView_colorScheme, id.mColorScheme); // As noted at {@link KeyboardId} class, we are interested only in enum value masked by // {@link android.view.inputmethod.EditorInfo#IME_MASK_ACTION} and // {@link android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION}. So matching @@ -503,14 +501,11 @@ public class KeyboardParser { R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry()); final boolean selected = modeMatched && navigateActionMatched && passwordInputMatched && settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched - && colorSchemeMatched && imeActionMatched && localeCodeMatched - && languageCodeMatched && countryCodeMatched; + && imeActionMatched && localeCodeMatched && languageCodeMatched + && countryCodeMatched; - if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE, + if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE, textAttr(a.getString(R.styleable.Keyboard_Case_mode), "mode"), - textAttr(KeyboardId.colorSchemeName( - viewAttr.getInt( - R.styleable.KeyboardView_colorScheme, -1)), "colorScheme"), booleanAttr(a, R.styleable.Keyboard_Case_navigateAction, "navigateAction"), booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"), booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"), diff --git a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java index 28766c21f..bb2a6fe40 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java @@ -16,15 +16,14 @@ package com.android.inputmethod.latin; -import com.android.inputmethod.keyboard.KeyboardId; -import com.android.inputmethod.keyboard.KeyboardView; - import android.content.res.AssetFileDescriptor; import android.content.res.Configuration; import android.test.AndroidTestCase; import android.text.TextUtils; import android.view.inputmethod.EditorInfo; +import com.android.inputmethod.keyboard.KeyboardId; + import java.io.File; import java.io.InputStream; import java.util.Locale; @@ -41,8 +40,8 @@ public class SuggestTestsBase extends AndroidTestCase { protected KeyboardId createKeyboardId(Locale locale) { final int displayWidth = getContext().getResources().getDisplayMetrics().widthPixels; return new KeyboardId(locale.toString() + " keyboard", - com.android.inputmethod.latin.R.xml.kbd_qwerty, KeyboardView.COLOR_SCHEME_WHITE, - locale, Configuration.ORIENTATION_LANDSCAPE, displayWidth, KeyboardId.MODE_TEXT, + com.android.inputmethod.latin.R.xml.kbd_qwerty, locale, + Configuration.ORIENTATION_LANDSCAPE, displayWidth, KeyboardId.MODE_TEXT, new EditorInfo(), false, false, false, false); } |