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">
<!-- 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"

View File

@ -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">

View File

@ -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>

View File

@ -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>
<!-- Functional key styles -->
<key-style
latin:styleName="shiftKeyStyle"

View File

@ -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="shiftKeyStyle"
latin:code="@integer/key_shift"

View File

@ -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>
<!-- Base key style for the key which may have settings key as popup key -->
<switch>
<case

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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

View File

@ -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) {
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");
}
}
}
}

View File

@ -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"),

View File

@ -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);
}