Merge "Revert "Add autoGenerateFromAlphabet enum to KeyboardSet.Element.elementKeyboard""

This commit is contained in:
Tadashi Takaoka 2012-01-24 15:22:25 -08:00 committed by Android (Google) Code Review
commit af4efd5a3e
34 changed files with 134 additions and 143 deletions

View file

@ -345,21 +345,20 @@
<declare-styleable name="KeyboardSet_Element">
<!-- This should be aligned with KeyboardId.ELEMENT_* -->
<attr name="elementName" format="enum">
<enum name="alphabet" value="0" />
<enum name="alphabetManualShifted" value="1" />
<enum name="alphabetAutomaticShifted" value="2" />
<enum name="alphabetShiftLocked" value="3" />
<enum name="alphabetShiftLockShifted" value="4" />
<enum name="symbols" value="5" />
<enum name="symbolsShifted" value="6" />
<enum name="phone" value="7" />
<enum name="phoneShifted" value="8" />
<enum name="number" value="9" />
</attr>
<attr name="elementKeyboard" format="reference|enum">
<!-- This should be aligned with KeyboardSet.ELEMENT_KEYBOARD_* -->
<enum name="autoGenerateFromAlphabet" value="1"/>
<enum name="alphabet" value="0" />
<!-- TODO: Implement alphabet variant shift keyboards
<enum name="alphabetManualTemporaryShift" value="1" />
<enum name="alphabetAutomaticTemporaryShift" value="2" />
<enum name="alphabetShiftLock" value="3" />
<enum name="alphabetShiftLockShift" value="4" />
-->
<enum name="symbols" value="5" />
<enum name="symbolsShift" value="6" />
<enum name="phone" value="7" />
<enum name="phoneShift" value="8" />
<enum name="number" value="9" />
</attr>
<attr name="elementKeyboard" format="reference" />
<!-- TODO: Add setShifted and setShiftLocked attribute. -->
</declare-styleable>
</resources>

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -28,13 +28,13 @@
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementName="symbolsShift"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneShifted"
latin:elementName="phoneShift"
latin:elementKeyboard="@xml/kbd_phone_shift" />
<Element
latin:elementName="number"

View file

@ -39,14 +39,16 @@ public class KeyboardId {
public static final int MODE_NUMBER = 5;
public static final int ELEMENT_ALPHABET = 0;
public static final int ELEMENT_ALPHABET_MANUAL_SHIFTED = 1;
public static final int ELEMENT_ALPHABET_AUTOMATIC_SHIFTED = 2;
public static final int ELEMENT_ALPHABET_SHIFT_LOCKED = 3;
public static final int ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED = 4;
/* TODO: Implement alphabet variant shift keyboard.
public static final int ELEMENT_ALPHABET_MANUAL_TEMPORARY_SHIFT = 1;
public static final int ELEMENT_ALPHABET_AUTOMATIC_TEMPORARY_SHIFT = 2;
public static final int ELEMENT_ALPHABET_SHIFT_LOCK = 3;
public static final int ELEMENT_ALPHABET_SHIFT_LOCK_SHIFT = 4;
*/
public static final int ELEMENT_SYMBOLS = 5;
public static final int ELEMENT_SYMBOLS_SHIFTED = 6;
public static final int ELEMENT_SYMBOLS_SHIFT = 6;
public static final int ELEMENT_PHONE = 7;
public static final int ELEMENT_PHONE_SHIFTED = 8;
public static final int ELEMENT_PHONE_SHIFT = 8;
public static final int ELEMENT_NUMBER = 9;
private static final int F2KEY_MODE_NONE = 0;
@ -58,7 +60,7 @@ public class KeyboardId {
public final int mOrientation;
public final int mWidth;
public final int mMode;
public final int mElement;
public final int mElementState;
private final int mInputType;
private final int mImeOptions;
private final boolean mSettingsKeyEnabled;
@ -68,14 +70,14 @@ public class KeyboardId {
private final int mHashCode;
public KeyboardId(int element, Locale locale, int orientation, int width, int mode,
public KeyboardId(int elementState, Locale locale, int orientation, int width, int mode,
int inputType, int imeOptions, boolean settingsKeyEnabled, boolean clobberSettingsKey,
boolean shortcutKeyEnabled, boolean hasShortcutKey) {
this.mLocale = locale;
this.mOrientation = orientation;
this.mWidth = width;
this.mMode = mode;
this.mElement = element;
this.mElementState = elementState;
this.mInputType = inputType;
this.mImeOptions = imeOptions;
this.mSettingsKeyEnabled = settingsKeyEnabled;
@ -89,7 +91,7 @@ public class KeyboardId {
private static int hashCode(KeyboardId id) {
return Arrays.hashCode(new Object[] {
id.mOrientation,
id.mElement,
id.mElementState,
id.mMode,
id.mWidth,
id.navigateAction(),
@ -107,7 +109,7 @@ public class KeyboardId {
if (other == this)
return true;
return other.mOrientation == this.mOrientation
&& other.mElement == this.mElement
&& other.mElementState == this.mElementState
&& other.mMode == this.mMode
&& other.mWidth == this.mWidth
&& other.navigateAction() == this.navigateAction()
@ -121,19 +123,19 @@ public class KeyboardId {
}
public boolean isAlphabetKeyboard() {
return mElement < ELEMENT_SYMBOLS;
return mElementState < ELEMENT_SYMBOLS;
}
public boolean isSymbolsKeyboard() {
return mElement == ELEMENT_SYMBOLS || mElement == ELEMENT_SYMBOLS_SHIFTED;
return mElementState == ELEMENT_SYMBOLS || mElementState == ELEMENT_SYMBOLS_SHIFT;
}
public boolean isPhoneKeyboard() {
return mElement == ELEMENT_PHONE || mElement == ELEMENT_PHONE_SHIFTED;
return mElementState == ELEMENT_PHONE || mElementState == ELEMENT_PHONE_SHIFT;
}
public boolean isPhoneShiftKeyboard() {
return mElement == ELEMENT_PHONE_SHIFTED;
return mElementState == ELEMENT_PHONE_SHIFT;
}
public boolean navigateAction() {
@ -188,7 +190,7 @@ public class KeyboardId {
@Override
public String toString() {
return String.format("[%s %s %s%d %s %s %s%s%s%s%s%s%s]",
elementToString(mElement),
elementStateToString(mElementState),
mLocale,
(mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode),
@ -211,17 +213,19 @@ public class KeyboardId {
&& TextUtils.equals(a.privateImeOptions, b.privateImeOptions);
}
public static String elementToString(int element) {
switch (element) {
public static String elementStateToString(int elementState) {
switch (elementState) {
case ELEMENT_ALPHABET: return "alphabet";
case ELEMENT_ALPHABET_MANUAL_SHIFTED: return "alphabetManualShifted";
case ELEMENT_ALPHABET_AUTOMATIC_SHIFTED: return "alphabetAutomaticShifted";
case ELEMENT_ALPHABET_SHIFT_LOCKED: return "alphabetShiftLocked";
case ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED: return "alphabetShiftLockShifted";
/* TODO: Implement alphabet variant shift keyboard.
case ELEMENT_ALPHABET_MANUAL_TEMPORARY_SHIFT: return "alphabetManualTemporaryShift";
case ELEMENT_ALPHABET_AUTOMATIC_TEMPORARY_SHIFT: return "alphabetAutomaticTemporaryShift";
case ELEMENT_ALPHABET_SHIFT_LOCK: return "alphabetShiftLock";
case ELEMENT_ALPHABET_SHIFT_LOCK_SHIFT: return "alphabetShiftLockShift";
*/
case ELEMENT_SYMBOLS: return "symbols";
case ELEMENT_SYMBOLS_SHIFTED: return "symbolsShifted";
case ELEMENT_SYMBOLS_SHIFT: return "symbolsShift";
case ELEMENT_PHONE: return "phone";
case ELEMENT_PHONE_SHIFTED: return "phoneShifted";
case ELEMENT_PHONE_SHIFT: return "phoneShift";
case ELEMENT_NUMBER: return "number";
default: return null;
}

View file

@ -22,7 +22,6 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.Log;
import android.util.TypedValue;
import android.util.Xml;
import android.view.inputmethod.EditorInfo;
@ -55,12 +54,10 @@ public class KeyboardSet {
private static final String TAG_KEYBOARD_SET = TAG;
private static final String TAG_ELEMENT = "Element";
private static final int ELEMENT_KEYBOARD_AUTO_GENERATE_FROM_ALPHABET = 1;
private final Context mContext;
private final Params mParams;
static class Params {
private static class Params {
int mMode;
int mInputType;
int mImeOptions;
@ -107,18 +104,16 @@ public class KeyboardSet {
}
private Keyboard getKeyboard(boolean isSymbols, boolean isShift) {
final int element = KeyboardSet.getElement(mParams.mMode, isSymbols, isShift);
// TODO: If xmlId is ELEMENT_KEYBOARD_AUTO_GENERATE_FROM_ALPHABET, auto generate the
// keyboard based on base main alphabet keyboard considering element.
final int xmlId = mParams.mElementKeyboards.get(element);
final KeyboardId id = KeyboardSet.getKeyboardId(element, isSymbols, mParams);
final int elementState = Builder.getElementState(mParams.mMode, isSymbols, isShift);
final int xmlId = mParams.mElementKeyboards.get(elementState);
final KeyboardId id = Builder.getKeyboardId(elementState, isSymbols, mParams);
final Keyboard keyboard = getKeyboard(mContext, xmlId, id);
return keyboard;
}
public KeyboardId getMainKeyboardId() {
final int element = KeyboardSet.getElement(mParams.mMode, false, false);
return KeyboardSet.getKeyboardId(element, false, mParams);
final int elementState = Builder.getElementState(mParams.mMode, false, false);
return Builder.getKeyboardId(elementState, false, mParams);
}
private Keyboard getKeyboard(Context context, int xmlId, KeyboardId id) {
@ -152,30 +147,6 @@ public class KeyboardSet {
return keyboard;
}
private static int getElement(int mode, boolean isSymbols, boolean isShift) {
switch (mode) {
case KeyboardId.MODE_PHONE:
return (isSymbols && isShift)
? KeyboardId.ELEMENT_PHONE_SHIFTED : KeyboardId.ELEMENT_PHONE;
case KeyboardId.MODE_NUMBER:
return KeyboardId.ELEMENT_NUMBER;
default:
if (isSymbols) {
return isShift
? KeyboardId.ELEMENT_SYMBOLS_SHIFTED : KeyboardId.ELEMENT_SYMBOLS;
}
return KeyboardId.ELEMENT_ALPHABET;
}
}
private static KeyboardId getKeyboardId(int element, boolean isSymbols, Params params) {
final boolean hasShortcutKey = params.mVoiceKeyEnabled
&& (isSymbols != params.mVoiceKeyOnMain);
return new KeyboardId(element, params.mLocale, params.mOrientation, params.mWidth,
params.mMode, params.mInputType, params.mImeOptions, params.mSettingsKeyEnabled,
params.mNoSettingsKey, params.mVoiceKeyEnabled, hasShortcutKey);
}
public static class Builder {
private final Context mContext;
private final String mPackageName;
@ -247,6 +218,31 @@ public class KeyboardSet {
return new KeyboardSet(mContext, mParams);
}
// TODO: Move this method to KeyboardSet
static KeyboardId getKeyboardId(int elementState, boolean isSymbols, Params params) {
final boolean hasShortcutKey = params.mVoiceKeyEnabled
&& (isSymbols != params.mVoiceKeyOnMain);
return new KeyboardId(elementState, params.mLocale, params.mOrientation, params.mWidth,
params.mMode, params.mInputType, params.mImeOptions, params.mSettingsKeyEnabled,
params.mNoSettingsKey, params.mVoiceKeyEnabled, hasShortcutKey);
}
// TODO: Move this method to KeyboardSet
static int getElementState(int mode, boolean isSymbols, boolean isShift) {
switch (mode) {
case KeyboardId.MODE_PHONE:
return (isSymbols && isShift)
? KeyboardId.ELEMENT_PHONE_SHIFT : KeyboardId.ELEMENT_PHONE;
case KeyboardId.MODE_NUMBER:
return KeyboardId.ELEMENT_NUMBER;
default:
if (isSymbols) {
return isShift ? KeyboardId.ELEMENT_SYMBOLS_SHIFT : KeyboardId.ELEMENT_SYMBOLS;
}
return KeyboardId.ELEMENT_ALPHABET;
}
}
private void parseKeyboardSet(Resources res, int resId) throws XmlPullParserException,
IOException {
final XmlResourceParser parser = res.getXml(resId);
@ -304,14 +300,8 @@ public class KeyboardSet {
final int elementName = a.getInt(
R.styleable.KeyboardSet_Element_elementName, 0);
final int index = R.styleable.KeyboardSet_Element_elementKeyboard;
final TypedValue v = a.peekValue(index);
final int elementKeyboard;
if (v.type == TypedValue.TYPE_REFERENCE) {
elementKeyboard = a.getResourceId(index, 0);
} else {
elementKeyboard = a.getInt(index, 0);
}
final int elementKeyboard = a.getResourceId(
R.styleable.KeyboardSet_Element_elementKeyboard, 0);
mParams.mElementKeyboards.put(elementName, elementKeyboard);
} finally {
a.recycle();

View file

@ -43,8 +43,6 @@ public class KeyboardState {
public void setAlphabetManualShiftedKeyboard();
public void setAlphabetAutomaticShiftedKeyboard();
public void setAlphabetShiftLockedKeyboard();
// TODO: Add this.
//public void setAlphabetShiftLockShiftedKeyboard();
public void setSymbolsKeyboard();
public void setSymbolsShiftedKeyboard();