aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-06-22 08:51:36 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-22 08:51:36 -0700
commit3edc97b275749d4d28a9dd3b0f57c8c4e7baf2cd (patch)
treef75ec7f6ad014ebf7b5757b56243c524ad1bd428 /java/src/com/android/inputmethod
parenta7eed902f1b0d6871d416412b3c6f91163fa2578 (diff)
parenta93d27d6b87c29cb6292d1dd1223a4e42cca07d9 (diff)
downloadlatinime-3edc97b275749d4d28a9dd3b0f57c8c4e7baf2cd.tar.gz
latinime-3edc97b275749d4d28a9dd3b0f57c8c4e7baf2cd.tar.xz
latinime-3edc97b275749d4d28a9dd3b0f57c8c4e7baf2cd.zip
Merge "Remove colorScheme attribute from KeyboardView"
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java29
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java11
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java10
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java14
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java23
5 files changed, 30 insertions, 57 deletions
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 c372281c2..4b162142d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -62,7 +62,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
@@ -91,9 +90,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;
@@ -109,7 +105,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;
@@ -356,7 +351,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();
@@ -565,10 +559,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>
* &gt;switch&lt;
- * &gt;case colorScheme="white"&lt;
- * &gt;key-style styleName="shift-key" parentStyle="modifier-key"
- * keyIcon="@drawable/sym_keyboard_shift"
+ * &gt;case mode="email"&lt;
+ * &gt;key-style styleName="f1-key" parentStyle="modifier-key"
+ * keyLabel=".com"
* /&lt;
* &gt;/case&lt;
- * &gt;case colorScheme="black"&lt;
- * &gt;key-style styleName="shift-key" parentStyle="modifier-key"
- * keyIcon="@drawable/sym_bkeyboard_shift"
+ * &gt;case mode="url"&lt;
+ * &gt;key-style styleName="f1-key" parentStyle="modifier-key"
+ * keyLabel="http://"
* /&lt;
* &gt;/case&lt;
* &gt;/switch&lt;
@@ -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"),