Merge "Remove colorScheme attribute from KeyboardView"

main
Tadashi G. Takaoka 2011-06-22 08:51:36 -07:00 committed by Android (Google) Code Review
commit 3edc97b275
12 changed files with 50 additions and 116 deletions

View File

@ -16,6 +16,13 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <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. --> <!-- Toggle keys. Use checkable/checked state. -->
<item android:state_checkable="true" android:state_checked="true" <item android:state_checkable="true" android:state_checked="true"

View File

@ -90,13 +90,6 @@
<enum name="italic" value="2" /> <enum name="italic" value="2" />
<enum name="boldItalic" value="3" /> <enum name="boldItalic" value="3" />
</attr> </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>
<declare-styleable name="CandidateView"> <declare-styleable name="CandidateView">

View File

@ -59,7 +59,6 @@
<item name="shadowColor">#BB000000</item> <item name="shadowColor">#BB000000</item>
<item name="shadowRadius">2.75</item> <item name="shadowRadius">2.75</item>
<item name="backgroundDimAmount">0.5</item> <item name="backgroundDimAmount">0.5</item>
<item name="colorScheme">white</item>
</style> </style>
<style name="KeyPreviewStyle"> <style name="KeyPreviewStyle">
<item name="android:background">@drawable/keyboard_key_feedback</item> <item name="android:background">@drawable/keyboard_key_feedback</item>
@ -107,7 +106,6 @@
<item name="keyTextColor">@color/latinkeyboard_key_color_black</item> <item name="keyTextColor">@color/latinkeyboard_key_color_black</item>
<item name="keyTextInactivatedColor">#FF808080</item> <item name="keyTextInactivatedColor">#FF808080</item>
<item name="shadowColor">@color/latinkeyboard_key_color_white</item> <item name="shadowColor">@color/latinkeyboard_key_color_white</item>
<item name="colorScheme">black</item>
</style> </style>
<style name="PopupMiniKeyboardView.Stone" parent="PopupMiniKeyboardView"> <style name="PopupMiniKeyboardView.Stone" parent="PopupMiniKeyboardView">
<item name="keyBackground">@drawable/btn_keyboard_key_stone</item> <item name="keyBackground">@drawable/btn_keyboard_key_stone</item>

View File

@ -22,21 +22,9 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
> >
<!-- Base key style for the functional key --> <!-- Base key style for the functional key -->
<switch> <key-style
<case latin:styleName="functionalKeyStyle"
latin:colorScheme="white" latin:isFunctional="true" />
>
<key-style
latin:styleName="functionalKeyStyle"
latin:isFunctional="true" />
</case>
<case
latin:colorScheme="black"
>
<key-style
latin:styleName="functionalKeyStyle" />
</case>
</switch>
<!-- Functional key styles --> <!-- Functional key styles -->
<key-style <key-style
latin:styleName="shiftKeyStyle" latin:styleName="shiftKeyStyle"

View File

@ -22,21 +22,9 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
> >
<!-- Functional key styles --> <!-- Functional key styles -->
<switch> <key-style
<case latin:styleName="functionalKeyStyle"
latin:colorScheme="white" latin:isFunctional="true" />
>
<key-style
latin:styleName="functionalKeyStyle"
latin:isFunctional="true" />
</case>
<case
latin:colorScheme="black"
>
<key-style
latin:styleName="functionalKeyStyle" />
</case>
</switch>
<key-style <key-style
latin:styleName="shiftKeyStyle" latin:styleName="shiftKeyStyle"
latin:code="@integer/key_shift" latin:code="@integer/key_shift"

View File

@ -22,21 +22,9 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
> >
<!-- Base key style for the functional key --> <!-- Base key style for the functional key -->
<switch> <key-style
<case latin:styleName="functionalKeyStyle"
latin:colorScheme="white" latin:isFunctional="true" />
>
<key-style
latin:styleName="functionalKeyStyle"
latin:isFunctional="true" />
</case>
<case
latin:colorScheme="black"
>
<key-style
latin:styleName="functionalKeyStyle" />
</case>
</switch>
<!-- Base key style for the key which may have settings key as popup key --> <!-- Base key style for the key which may have settings key as popup key -->
<switch> <switch>
<case <case

View File

@ -42,7 +42,6 @@ public class KeyboardId {
public final int mWidth; public final int mWidth;
public final int mMode; public final int mMode;
public final int mXmlId; public final int mXmlId;
public final int mColorScheme;
public final boolean mNavigateAction; public final boolean mNavigateAction;
public final boolean mPasswordInput; public final boolean mPasswordInput;
public final boolean mHasSettingsKey; public final boolean mHasSettingsKey;
@ -56,9 +55,9 @@ public class KeyboardId {
private final int mHashCode; private final int mHashCode;
public KeyboardId(String xmlName, int xmlId, int colorScheme, Locale locale, int orientation, public KeyboardId(String xmlName, int xmlId, Locale locale, int orientation, int width,
int width, int mode, EditorInfo attribute, boolean hasSettingsKey, int mode, EditorInfo attribute, boolean hasSettingsKey, boolean voiceKeyEnabled,
boolean voiceKeyEnabled, boolean hasVoiceKey, boolean enableShiftLock) { boolean hasVoiceKey, boolean enableShiftLock) {
final int inputType = (attribute != null) ? attribute.inputType : 0; final int inputType = (attribute != null) ? attribute.inputType : 0;
final int imeOptions = (attribute != null) ? attribute.imeOptions : 0; final int imeOptions = (attribute != null) ? attribute.imeOptions : 0;
this.mLocale = locale; this.mLocale = locale;
@ -66,7 +65,6 @@ public class KeyboardId {
this.mWidth = width; this.mWidth = width;
this.mMode = mode; this.mMode = mode;
this.mXmlId = xmlId; this.mXmlId = xmlId;
this.mColorScheme = colorScheme;
// Note: Turn off checking navigation flag to show TAB key for now. // Note: Turn off checking navigation flag to show TAB key for now.
this.mNavigateAction = InputTypeCompatUtils.isWebInputType(inputType); this.mNavigateAction = InputTypeCompatUtils.isWebInputType(inputType);
// || EditorInfoCompatUtils.hasFlagNavigateNext(imeOptions) // || EditorInfoCompatUtils.hasFlagNavigateNext(imeOptions)
@ -91,7 +89,6 @@ public class KeyboardId {
width, width,
mode, mode,
xmlId, xmlId,
colorScheme,
mNavigateAction, mNavigateAction,
mPasswordInput, mPasswordInput,
hasSettingsKey, hasSettingsKey,
@ -103,15 +100,15 @@ public class KeyboardId {
} }
public KeyboardId cloneWithNewLayout(String xmlName, int xmlId) { public KeyboardId cloneWithNewLayout(String xmlName, int xmlId) {
return new KeyboardId(xmlName, xmlId, mColorScheme, mLocale, mOrientation, mWidth, mMode, return new KeyboardId(xmlName, xmlId, mLocale, mOrientation, mWidth, mMode, mAttribute,
mAttribute, mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock); mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
} }
public KeyboardId cloneWithNewGeometry(int width) { public KeyboardId cloneWithNewGeometry(int width) {
if (mWidth == width) if (mWidth == width)
return this; return this;
return new KeyboardId(mXmlName, mXmlId, mColorScheme, mLocale, mOrientation, width, mMode, return new KeyboardId(mXmlName, mXmlId, mLocale, mOrientation, width, mMode, mAttribute,
mAttribute, mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock); mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
} }
public int getXmlId() { public int getXmlId() {
@ -145,7 +142,6 @@ public class KeyboardId {
&& other.mWidth == this.mWidth && other.mWidth == this.mWidth
&& other.mMode == this.mMode && other.mMode == this.mMode
&& other.mXmlId == this.mXmlId && other.mXmlId == this.mXmlId
&& other.mColorScheme == this.mColorScheme
&& other.mNavigateAction == this.mNavigateAction && other.mNavigateAction == this.mNavigateAction
&& other.mPasswordInput == this.mPasswordInput && other.mPasswordInput == this.mPasswordInput
&& other.mHasSettingsKey == this.mHasSettingsKey && other.mHasSettingsKey == this.mHasSettingsKey
@ -162,13 +158,12 @@ public class KeyboardId {
@Override @Override
public String toString() { 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, mXmlName,
mLocale, mLocale,
(mOrientation == 1 ? "port" : "land"), mWidth, (mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode), modeName(mMode),
EditorInfoCompatUtils.imeOptionsName(mImeAction), EditorInfoCompatUtils.imeOptionsName(mImeAction),
colorSchemeName(mColorScheme),
(mNavigateAction ? " navigateAction" : ""), (mNavigateAction ? " navigateAction" : ""),
(mPasswordInput ? " passwordInput" : ""), (mPasswordInput ? " passwordInput" : ""),
(mHasSettingsKey ? " hasSettingsKey" : ""), (mHasSettingsKey ? " hasSettingsKey" : ""),
@ -189,12 +184,4 @@ public class KeyboardId {
} }
return null; 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;
}
} }

View File

@ -258,7 +258,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private KeyboardId getKeyboardId(EditorInfo attribute, boolean isSymbols) { private KeyboardId getKeyboardId(EditorInfo attribute, boolean isSymbols) {
final int mode = Utils.getKeyboardMode(attribute); final int mode = Utils.getKeyboardMode(attribute);
final boolean hasVoiceKey = hasVoiceKey(isSymbols); final boolean hasVoiceKey = hasVoiceKey(isSymbols);
final int charColorId = getColorScheme();
final int xmlId; final int xmlId;
final boolean enableShiftLock; final boolean enableShiftLock;
@ -291,9 +290,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mKeyboardWidth = res.getDisplayMetrics().widthPixels; mKeyboardWidth = res.getDisplayMetrics().widthPixels;
final Locale locale = mSubtypeSwitcher.getInputLocale(); final Locale locale = mSubtypeSwitcher.getInputLocale();
return new KeyboardId( return new KeyboardId(
res.getResourceEntryName(xmlId), xmlId, charColorId, locale, orientation, res.getResourceEntryName(xmlId), xmlId, locale, orientation, mKeyboardWidth,
mKeyboardWidth, mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock);
enableShiftLock);
} }
private KeyboardId makeSiblingKeyboardId(KeyboardId base, int alphabet, int phone) { 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) { public void onAutoCorrectionStateChanged(boolean isAutoCorrection) {
if (mIsAutoCorrectionActive != isAutoCorrection) { if (mIsAutoCorrectionActive != isAutoCorrection) {
mIsAutoCorrectionActive = isAutoCorrection; mIsAutoCorrectionActive = isAutoCorrection;

View File

@ -62,7 +62,6 @@ import java.util.WeakHashMap;
* presses and touch movements. * presses and touch movements.
* *
* @attr ref R.styleable#KeyboardView_backgroundDimAmount * @attr ref R.styleable#KeyboardView_backgroundDimAmount
* @attr ref R.styleable#KeyboardView_colorScheme
* @attr ref R.styleable#KeyboardView_keyBackground * @attr ref R.styleable#KeyboardView_keyBackground
* @attr ref R.styleable#KeyboardView_keyHysteresisDistance * @attr ref R.styleable#KeyboardView_keyHysteresisDistance
* @attr ref R.styleable#KeyboardView_keyLetterRatio * @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_LONGPRESS = true;
private static final boolean ENABLE_CAPSLOCK_BY_DOUBLETAP = 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 // Timing constants
private final int mKeyRepeatInterval; private final int mKeyRepeatInterval;
@ -109,7 +105,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private final float mKeyLabelRatio; private final float mKeyLabelRatio;
private final float mKeyHintLetterRatio; private final float mKeyHintLetterRatio;
private final float mKeyUppercaseLetterRatio; private final float mKeyUppercaseLetterRatio;
private final int mColorScheme;
private final int mShadowColor; private final int mShadowColor;
private final float mShadowRadius; private final float mShadowRadius;
private final Drawable mKeyBackground; private final Drawable mKeyBackground;
@ -356,7 +351,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f); mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f);
// TODO: Use Theme (android.R.styleable.Theme_backgroundDimAmount) // TODO: Use Theme (android.R.styleable.Theme_backgroundDimAmount)
mBackgroundDimAmount = a.getFloat(R.styleable.KeyboardView_backgroundDimAmount, 0.5f); mBackgroundDimAmount = a.getFloat(R.styleable.KeyboardView_backgroundDimAmount, 0.5f);
mColorScheme = a.getInt(R.styleable.KeyboardView_colorScheme, COLOR_SCHEME_WHITE);
a.recycle(); a.recycle();
final Resources res = getResources(); final Resources res = getResources();
@ -565,10 +559,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
return mShowKeyPreviewPopup; return mShowKeyPreviewPopup;
} }
public int getColorScheme() {
return mColorScheme;
}
/** /**
* When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key * When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key
* codes for adjacent keys. When disabled, only the primary key code will be * codes for adjacent keys. When disabled, only the primary key code will be

View File

@ -16,13 +16,17 @@
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.keyboard.internal;
import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.Log;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
public class KeyboardIconsSet { public class KeyboardIconsSet {
private static final String TAG = KeyboardIconsSet.class.getSimpleName();
public static final int ICON_UNDEFINED = 0; public static final int ICON_UNDEFINED = 0;
// This should be aligned with Keyboard.keyIcon enum. // This should be aligned with Keyboard.keyIcon enum.
@ -130,9 +134,13 @@ public class KeyboardIconsSet {
final int attrIndex = keyboardAttrs.getIndex(i); final int attrIndex = keyboardAttrs.getIndex(i);
final int iconId = getIconId(attrIndex); final int iconId = getIconId(attrIndex);
if (iconId != ICON_UNDEFINED) { if (iconId != ICON_UNDEFINED) {
final Drawable icon = keyboardAttrs.getDrawable(attrIndex); try {
Keyboard.setDefaultBounds(icon); final Drawable icon = keyboardAttrs.getDrawable(attrIndex);
mIcons[iconId] = icon; Keyboard.setDefaultBounds(icon);
mIcons[iconId] = icon;
} catch (Resources.NotFoundException e) {
Log.w(TAG, "Drawable resource for icon #" + iconId + " not found");
}
} }
} }
} }

View File

@ -90,14 +90,14 @@ import java.util.List;
* You can declare Key style and specify styles within Key tags. * You can declare Key style and specify styles within Key tags.
* <pre> * <pre>
* &gt;switch&lt; * &gt;switch&lt;
* &gt;case colorScheme="white"&lt; * &gt;case mode="email"&lt;
* &gt;key-style styleName="shift-key" parentStyle="modifier-key" * &gt;key-style styleName="f1-key" parentStyle="modifier-key"
* keyIcon="@drawable/sym_keyboard_shift" * keyLabel=".com"
* /&lt; * /&lt;
* &gt;/case&lt; * &gt;/case&lt;
* &gt;case colorScheme="black"&lt; * &gt;case mode="url"&lt;
* &gt;key-style styleName="shift-key" parentStyle="modifier-key" * &gt;key-style styleName="f1-key" parentStyle="modifier-key"
* keyIcon="@drawable/sym_bkeyboard_shift" * keyLabel="http://"
* /&lt; * /&lt;
* &gt;/case&lt; * &gt;/case&lt;
* &gt;/switch&lt; * &gt;/switch&lt;
@ -487,8 +487,6 @@ public class KeyboardParser {
R.styleable.Keyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled); R.styleable.Keyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled);
final boolean voiceKeyMatched = matchBoolean(a, final boolean voiceKeyMatched = matchBoolean(a,
R.styleable.Keyboard_Case_hasVoiceKey, id.mHasVoiceKey); 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 // 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_MASK_ACTION} and
// {@link android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION}. So matching // {@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()); R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
final boolean selected = modeMatched && navigateActionMatched && passwordInputMatched final boolean selected = modeMatched && navigateActionMatched && passwordInputMatched
&& settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched && settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched
&& colorSchemeMatched && imeActionMatched && localeCodeMatched && imeActionMatched && localeCodeMatched && languageCodeMatched
&& languageCodeMatched && countryCodeMatched; && 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(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_navigateAction, "navigateAction"),
booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"), booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"),
booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"), booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"),

View File

@ -16,15 +16,14 @@
package com.android.inputmethod.latin; 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.AssetFileDescriptor;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.keyboard.KeyboardId;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.Locale; import java.util.Locale;
@ -41,8 +40,8 @@ public class SuggestTestsBase extends AndroidTestCase {
protected KeyboardId createKeyboardId(Locale locale) { protected KeyboardId createKeyboardId(Locale locale) {
final int displayWidth = getContext().getResources().getDisplayMetrics().widthPixels; final int displayWidth = getContext().getResources().getDisplayMetrics().widthPixels;
return new KeyboardId(locale.toString() + " keyboard", return new KeyboardId(locale.toString() + " keyboard",
com.android.inputmethod.latin.R.xml.kbd_qwerty, KeyboardView.COLOR_SCHEME_WHITE, com.android.inputmethod.latin.R.xml.kbd_qwerty, locale,
locale, Configuration.ORIENTATION_LANDSCAPE, displayWidth, KeyboardId.MODE_TEXT, Configuration.ORIENTATION_LANDSCAPE, displayWidth, KeyboardId.MODE_TEXT,
new EditorInfo(), false, false, false, false); new EditorInfo(), false, false, false, false);
} }