diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 73f62c6f1..c88049e14 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -141,6 +141,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -163,8 +192,6 @@
-
-
@@ -182,11 +209,47 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
diff --git a/java/res/values/keyboard-icons-black.xml b/java/res/values/keyboard-icons-black.xml
new file mode 100644
index 000000000..f11a9c4d6
--- /dev/null
+++ b/java/res/values/keyboard-icons-black.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
diff --git a/java/res/values/keyboard-icons-holo.xml b/java/res/values/keyboard-icons-holo.xml
new file mode 100644
index 000000000..5f396ca71
--- /dev/null
+++ b/java/res/values/keyboard-icons-holo.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
diff --git a/java/res/values/keyboard-icons-white.xml b/java/res/values/keyboard-icons-white.xml
new file mode 100644
index 000000000..f25f7d44a
--- /dev/null
+++ b/java/res/values/keyboard-icons-white.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
diff --git a/java/res/values/themes-basic-highcontrast.xml b/java/res/values/themes-basic-highcontrast.xml
new file mode 100644
index 000000000..8122e4eb0
--- /dev/null
+++ b/java/res/values/themes-basic-highcontrast.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
diff --git a/java/res/values/themes-basic.xml b/java/res/values/themes-basic.xml
new file mode 100644
index 000000000..50b52de32
--- /dev/null
+++ b/java/res/values/themes-basic.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
diff --git a/java/res/values/themes-gingerbread.xml b/java/res/values/themes-gingerbread.xml
new file mode 100644
index 000000000..cdb10c81a
--- /dev/null
+++ b/java/res/values/themes-gingerbread.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
diff --git a/java/res/values/themes-honeycomb.xml b/java/res/values/themes-honeycomb.xml
new file mode 100644
index 000000000..07f5b83c0
--- /dev/null
+++ b/java/res/values/themes-honeycomb.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
diff --git a/java/res/values/themes-stone-bold.xml b/java/res/values/themes-stone-bold.xml
new file mode 100644
index 000000000..4955f2286
--- /dev/null
+++ b/java/res/values/themes-stone-bold.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
diff --git a/java/res/values/themes-stone.xml b/java/res/values/themes-stone.xml
new file mode 100644
index 000000000..39a011bd9
--- /dev/null
+++ b/java/res/values/themes-stone.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
diff --git a/java/res/values/themes.xml b/java/res/values/themes.xml
deleted file mode 100644
index 728ce5a02..000000000
--- a/java/res/values/themes.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/java/res/xml-sw600dp/kbd_key_styles.xml b/java/res/xml-sw600dp/kbd_key_styles.xml
index a38887910..988f5c490 100644
--- a/java/res/xml-sw600dp/kbd_key_styles.xml
+++ b/java/res/xml-sw600dp/kbd_key_styles.xml
@@ -38,137 +38,66 @@
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -176,7 +176,7 @@
diff --git a/java/res/xml-sw600dp/kbd_numkey_styles.xml b/java/res/xml-sw600dp/kbd_numkey_styles.xml
deleted file mode 100644
index b10dc9333..000000000
--- a/java/res/xml-sw600dp/kbd_numkey_styles.xml
+++ /dev/null
@@ -1,150 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/java/res/xml-sw600dp/kbd_phone.xml b/java/res/xml-sw600dp/kbd_phone.xml
index 20b284923..133983d2a 100644
--- a/java/res/xml-sw600dp/kbd_phone.xml
+++ b/java/res/xml-sw600dp/kbd_phone.xml
@@ -109,7 +109,7 @@
diff --git a/java/res/xml-sw600dp/kbd_phone_symbols.xml b/java/res/xml-sw600dp/kbd_phone_symbols.xml
index a5ae9456c..73b7e4da6 100644
--- a/java/res/xml-sw600dp/kbd_phone_symbols.xml
+++ b/java/res/xml-sw600dp/kbd_phone_symbols.xml
@@ -118,7 +118,7 @@
diff --git a/java/res/xml-sw600dp/kbd_qwerty_row4.xml b/java/res/xml-sw600dp/kbd_qwerty_row4.xml
index 49e377fa7..958a7ed8f 100644
--- a/java/res/xml-sw600dp/kbd_qwerty_row4.xml
+++ b/java/res/xml-sw600dp/kbd_qwerty_row4.xml
@@ -155,7 +155,7 @@
diff --git a/java/res/xml-sw600dp/kbd_symbols.xml b/java/res/xml-sw600dp/kbd_symbols.xml
index 4d3e7d3a2..fca97c737 100644
--- a/java/res/xml-sw600dp/kbd_symbols.xml
+++ b/java/res/xml-sw600dp/kbd_symbols.xml
@@ -210,7 +210,7 @@
diff --git a/java/res/xml-sw600dp/kbd_symbols_shift.xml b/java/res/xml-sw600dp/kbd_symbols_shift.xml
index 1743c0ff2..c23681d4e 100644
--- a/java/res/xml-sw600dp/kbd_symbols_shift.xml
+++ b/java/res/xml-sw600dp/kbd_symbols_shift.xml
@@ -148,7 +148,7 @@
latin:keyXPos="30.750%p"
latin:keyWidth="39.750%p" />
diff --git a/java/res/xml-sw768dp/kbd_key_styles.xml b/java/res/xml-sw768dp/kbd_key_styles.xml
index 4388e8959..ecfacc25b 100644
--- a/java/res/xml-sw768dp/kbd_key_styles.xml
+++ b/java/res/xml-sw768dp/kbd_key_styles.xml
@@ -29,110 +29,59 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/java/res/xml-sw768dp/kbd_numkey_styles.xml b/java/res/xml-sw768dp/kbd_numkey_styles.xml
deleted file mode 100644
index e27db94c7..000000000
--- a/java/res/xml-sw768dp/kbd_numkey_styles.xml
+++ /dev/null
@@ -1,148 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/java/res/xml-sw768dp/kbd_phone.xml b/java/res/xml-sw768dp/kbd_phone.xml
index 69169ffd1..b0d9337de 100644
--- a/java/res/xml-sw768dp/kbd_phone.xml
+++ b/java/res/xml-sw768dp/kbd_phone.xml
@@ -123,7 +123,7 @@
latin:voiceKeyEnabled="true"
>
diff --git a/java/res/xml-sw768dp/kbd_phone_symbols.xml b/java/res/xml-sw768dp/kbd_phone_symbols.xml
index e95579c0a..120a149d4 100644
--- a/java/res/xml-sw768dp/kbd_phone_symbols.xml
+++ b/java/res/xml-sw768dp/kbd_phone_symbols.xml
@@ -134,7 +134,7 @@
latin:voiceKeyEnabled="true"
>
diff --git a/java/res/xml-sw768dp/kbd_qwerty_row4.xml b/java/res/xml-sw768dp/kbd_qwerty_row4.xml
index fba2a65dd..00eabab9e 100644
--- a/java/res/xml-sw768dp/kbd_qwerty_row4.xml
+++ b/java/res/xml-sw768dp/kbd_qwerty_row4.xml
@@ -132,7 +132,7 @@
latin:voiceKeyEnabled="true"
>
diff --git a/java/res/xml-sw768dp/kbd_symbols.xml b/java/res/xml-sw768dp/kbd_symbols.xml
index d1a83c479..0e6103ab9 100644
--- a/java/res/xml-sw768dp/kbd_symbols.xml
+++ b/java/res/xml-sw768dp/kbd_symbols.xml
@@ -186,7 +186,7 @@
latin:voiceKeyEnabled="true"
>
diff --git a/java/res/xml-sw768dp/kbd_symbols_shift.xml b/java/res/xml-sw768dp/kbd_symbols_shift.xml
index dde144fdf..b36814104 100644
--- a/java/res/xml-sw768dp/kbd_symbols_shift.xml
+++ b/java/res/xml-sw768dp/kbd_symbols_shift.xml
@@ -166,7 +166,7 @@
latin:voiceKeyEnabled="true"
>
diff --git a/java/res/xml/kbd_key_styles.xml b/java/res/xml/kbd_key_styles.xml
index 201bff6e7..fbc4c920f 100644
--- a/java/res/xml/kbd_key_styles.xml
+++ b/java/res/xml/kbd_key_styles.xml
@@ -23,7 +23,7 @@
>
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
+
-
\ No newline at end of file
+
diff --git a/java/res/xml/kbd_numkey_styles.xml b/java/res/xml/kbd_numkey_styles.xml
index 2f9ae325a..f53046aa2 100644
--- a/java/res/xml/kbd_numkey_styles.xml
+++ b/java/res/xml/kbd_numkey_styles.xml
@@ -21,130 +21,61 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/res/xml/kbd_qwerty_f1.xml b/java/res/xml/kbd_qwerty_f1.xml
index 45cc8f550..51b9800e0 100644
--- a/java/res/xml/kbd_qwerty_f1.xml
+++ b/java/res/xml/kbd_qwerty_f1.xml
@@ -48,7 +48,7 @@
latin:hasVoiceKey="true"
>
@@ -93,7 +93,7 @@
latin:hasVoiceKey="true"
>
+ latin:keyStyle="shortcutKeyStyle" />
@@ -49,7 +49,7 @@
latin:hasVoiceKey="true"
>
+ latin:keyStyle="shortcutKeyStyle" />
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 36f36de2b..889d54bf3 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable;
import android.util.Log;
import com.android.inputmethod.keyboard.internal.Key;
+import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParser;
import com.android.inputmethod.keyboard.internal.KeyboardShiftState;
import com.android.inputmethod.latin.R;
@@ -54,7 +55,7 @@ import java.util.Map;
*
*/
public class Keyboard {
- private static final String TAG = "Keyboard";
+ private static final String TAG = Keyboard.class.getSimpleName();
public static final int EDGE_LEFT = 0x01;
public static final int EDGE_RIGHT = 0x02;
@@ -133,6 +134,8 @@ public class Keyboard {
public final KeyboardId mId;
+ public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
+
// Variables for pre-computing nearest keys.
// TODO: Change GRID_WIDTH and GRID_HEIGHT to private.
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index d8d2bffbe..1d70481f4 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -16,6 +16,11 @@
package com.android.inputmethod.keyboard;
+import android.content.res.Resources;
+import android.os.SystemClock;
+import android.util.Log;
+import android.view.MotionEvent;
+
import com.android.inputmethod.keyboard.KeyboardView.UIHandler;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.PointerTrackerKeyState;
@@ -24,11 +29,6 @@ import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
-import android.content.res.Resources;
-import android.os.SystemClock;
-import android.util.Log;
-import android.view.MotionEvent;
-
import java.util.Arrays;
import java.util.List;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/Key.java b/java/src/com/android/inputmethod/keyboard/internal/Key.java
index c5946ef00..5470067dc 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/Key.java
@@ -16,11 +16,6 @@
package com.android.inputmethod.keyboard.internal;
-import com.android.inputmethod.keyboard.Keyboard;
-import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle;
-import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException;
-import com.android.inputmethod.latin.R;
-
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
@@ -28,6 +23,11 @@ import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Xml;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle;
+import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException;
+import com.android.inputmethod.latin.R;
+
import java.util.ArrayList;
/**
@@ -165,7 +165,7 @@ public class Key {
mLabel = PopupCharactersParser.getLabel(popupSpecification);
mOutputText = PopupCharactersParser.getOutputText(popupSpecification);
mCode = PopupCharactersParser.getCode(res, popupSpecification);
- mIcon = PopupCharactersParser.getIcon(res, popupSpecification);
+ mIcon = keyboard.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpecification));
// Horizontal gap is divided equally to both sides of the key.
mX = x + mGap / 2;
mY = y;
@@ -263,13 +263,18 @@ public class Key {
mEdgeFlags = style.getFlag(keyAttr, R.styleable.Keyboard_Key_keyEdgeFlags, 0)
| row.mRowEdgeFlags;
+ final KeyboardIconsSet iconsSet = mKeyboard.mIconsSet;
mVisualInsetsLeft = KeyboardParser.getDimensionOrFraction(keyAttr,
R.styleable.Keyboard_Key_visualInsetsLeft, mKeyboard.getDisplayHeight(), 0);
mVisualInsetsRight = KeyboardParser.getDimensionOrFraction(keyAttr,
R.styleable.Keyboard_Key_visualInsetsRight, mKeyboard.getDisplayHeight(), 0);
- mPreviewIcon = style.getDrawable(keyAttr, R.styleable.Keyboard_Key_iconPreview);
+ mPreviewIcon = iconsSet.getIcon(style.getInt(
+ keyAttr, R.styleable.Keyboard_Key_keyIconPreview,
+ KeyboardIconsSet.ICON_UNDEFINED));
Keyboard.setDefaultBounds(mPreviewIcon);
- mIcon = style.getDrawable(keyAttr, R.styleable.Keyboard_Key_keyIcon);
+ mIcon = iconsSet.getIcon(style.getInt(
+ keyAttr, R.styleable.Keyboard_Key_keyIcon,
+ KeyboardIconsSet.ICON_UNDEFINED));
Keyboard.setDefaultBounds(mIcon);
mHintLetter = style.getText(keyAttr, R.styleable.Keyboard_Key_keyHintLetter);
@@ -288,8 +293,9 @@ public class Key {
mCode = Keyboard.CODE_DUMMY;
}
- final Drawable shiftedIcon = style.getDrawable(keyAttr,
- R.styleable.Keyboard_Key_shiftedIcon);
+ final Drawable shiftedIcon = iconsSet.getIcon(style.getInt(
+ keyAttr, R.styleable.Keyboard_Key_keyIconShifted,
+ KeyboardIconsSet.ICON_UNDEFINED));
if (shiftedIcon != null)
mKeyboard.getShiftedIcons().put(this, shiftedIcon);
} finally {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
index dc2f4a15a..983f0649d 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
@@ -16,14 +16,13 @@
package com.android.inputmethod.keyboard.internal;
-import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException;
-import com.android.inputmethod.latin.R;
-
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
-import android.graphics.drawable.Drawable;
import android.util.Log;
+import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException;
+import com.android.inputmethod.latin.R;
+
import java.util.ArrayList;
import java.util.HashMap;
@@ -37,7 +36,6 @@ public class KeyStyles {
public interface KeyStyle {
public CharSequence[] getTextArray(TypedArray a, int index);
- public Drawable getDrawable(TypedArray a, int index);
public CharSequence getText(TypedArray a, int index);
public int getInt(TypedArray a, int index, int defaultValue);
public int getFlag(TypedArray a, int index, int defaultValue);
@@ -54,11 +52,6 @@ public class KeyStyles {
return parseTextArray(a, index);
}
- @Override
- public Drawable getDrawable(TypedArray a, int index) {
- return a.getDrawable(index);
- }
-
@Override
public CharSequence getText(TypedArray a, int index) {
return a.getText(index);
@@ -139,12 +132,6 @@ public class KeyStyles {
? super.getTextArray(a, index) : (CharSequence[])mAttributes.get(index);
}
- @Override
- public Drawable getDrawable(TypedArray a, int index) {
- return a.hasValue(index)
- ? super.getDrawable(a, index) : (Drawable)mAttributes.get(index);
- }
-
@Override
public CharSequence getText(TypedArray a, int index) {
return a.hasValue(index)
@@ -177,25 +164,20 @@ public class KeyStyles {
// TODO: Currently not all Key attributes can be declared as style.
readInt(keyAttr, R.styleable.Keyboard_Key_code);
readText(keyAttr, R.styleable.Keyboard_Key_keyLabel);
- readFlag(keyAttr, R.styleable.Keyboard_Key_keyLabelOption);
- readTextArray(keyAttr, R.styleable.Keyboard_Key_popupCharacters);
- readInt(keyAttr, R.styleable.Keyboard_Key_maxPopupKeyboardColumn);
readText(keyAttr, R.styleable.Keyboard_Key_keyOutputText);
- readDrawable(keyAttr, R.styleable.Keyboard_Key_keyIcon);
- readDrawable(keyAttr, R.styleable.Keyboard_Key_iconPreview);
readText(keyAttr, R.styleable.Keyboard_Key_keyHintLetter);
- readDrawable(keyAttr, R.styleable.Keyboard_Key_shiftedIcon);
+ readTextArray(keyAttr, R.styleable.Keyboard_Key_popupCharacters);
+ readFlag(keyAttr, R.styleable.Keyboard_Key_keyLabelOption);
+ readInt(keyAttr, R.styleable.Keyboard_Key_keyIcon);
+ readInt(keyAttr, R.styleable.Keyboard_Key_keyIconPreview);
+ readInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted);
+ readInt(keyAttr, R.styleable.Keyboard_Key_maxPopupKeyboardColumn);
readBoolean(keyAttr, R.styleable.Keyboard_Key_isFunctional);
readBoolean(keyAttr, R.styleable.Keyboard_Key_isSticky);
readBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable);
readBoolean(keyAttr, R.styleable.Keyboard_Key_enabled);
}
- private void readDrawable(TypedArray a, int index) {
- if (a.hasValue(index))
- mAttributes.put(index, a.getDrawable(index));
- }
-
private void readText(TypedArray a, int index) {
if (a.hasValue(index))
mAttributes.put(index, a.getText(index));
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
new file mode 100644
index 000000000..7be738ceb
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.latin.R;
+
+public class KeyboardIconsSet {
+ public static final int ICON_UNDEFINED = 0;
+
+ // This should be aligned with Keyboard.keyIcon enum.
+ private static final int ICON_SHIFT_KEY = 1;
+ private static final int ICON_TO_SYMBOL_KEY = 2;
+ private static final int ICON_TO_SYMBOL_KEY_WITH_SHORTCUT = 3;
+ private static final int ICON_DELETE_KEY = 4;
+ private static final int ICON_SETTINGS_KEY = 5;
+ private static final int ICON_SHORTCUT_KEY = 6;
+ private static final int ICON_SPACE_KEY = 7;
+ private static final int ICON_RETURN_KEY = 8;
+ private static final int ICON_SEARCH_KEY = 9;
+ private static final int ICON_TAB_KEY = 10;
+ private static final int ICON_NUM1_KEY = 11;
+ private static final int ICON_NUM2_KEY = 12;
+ private static final int ICON_NUM3_KEY = 13;
+ private static final int ICON_NUM4_KEY = 14;
+ private static final int ICON_NUM5_KEY = 15;
+ private static final int ICON_NUM6_KEY = 16;
+ private static final int ICON_NUM7_KEY = 17;
+ private static final int ICON_NUM8_KEY = 18;
+ private static final int ICON_NUM9_KEY = 19;
+ private static final int ICON_NUM0_KEY = 20;
+ private static final int ICON_NUM_STAR_KEY = 21;
+ private static final int ICON_NUM_POUND_KEY = 22;
+ private static final int ICON_NUM_ALT_KEY = 23;
+ // This should be aligned with Keyboard.keyIconShifted enum.
+ private static final int ICON_SHIFTED_SHIFT_KEY = 24;
+ // This should be aligned with Keyboard.keyIconPreview enum.
+ private static final int ICON_PREVIEW_SPACE_KEY = 25;
+ private static final int ICON_PREVIEW_TAB_KEY = 26;
+ private static final int ICON_PREVIEW_SETTINGS_KEY = 27;
+ private static final int ICON_PREVIEW_SHORTCUT_KEY = 28;
+
+ private static final int ICON_LAST = 28;
+
+ private final Drawable mIcons[] = new Drawable[ICON_LAST + 1];
+
+ private static final int getIconId(int attrIndex) {
+ switch (attrIndex) {
+ case R.styleable.Keyboard_iconShiftKey:
+ return ICON_SHIFT_KEY;
+ case R.styleable.Keyboard_iconToSymbolKey:
+ return ICON_TO_SYMBOL_KEY;
+ case R.styleable.Keyboard_iconToSymbolKeyWithShortcut:
+ return ICON_TO_SYMBOL_KEY_WITH_SHORTCUT;
+ case R.styleable.Keyboard_iconDeleteKey:
+ return ICON_DELETE_KEY;
+ case R.styleable.Keyboard_iconSettingsKey:
+ return ICON_SETTINGS_KEY;
+ case R.styleable.Keyboard_iconShortcutKey:
+ return ICON_SHORTCUT_KEY;
+ case R.styleable.Keyboard_iconSpaceKey:
+ return ICON_SPACE_KEY;
+ case R.styleable.Keyboard_iconReturnKey:
+ return ICON_RETURN_KEY;
+ case R.styleable.Keyboard_iconSearchKey:
+ return ICON_SEARCH_KEY;
+ case R.styleable.Keyboard_iconTabKey:
+ return ICON_TAB_KEY;
+ case R.styleable.Keyboard_iconNum1Key:
+ return ICON_NUM1_KEY;
+ case R.styleable.Keyboard_iconNum2Key:
+ return ICON_NUM2_KEY;
+ case R.styleable.Keyboard_iconNum3Key:
+ return ICON_NUM3_KEY;
+ case R.styleable.Keyboard_iconNum4Key:
+ return ICON_NUM4_KEY;
+ case R.styleable.Keyboard_iconNum5Key:
+ return ICON_NUM5_KEY;
+ case R.styleable.Keyboard_iconNum6Key:
+ return ICON_NUM6_KEY;
+ case R.styleable.Keyboard_iconNum7Key:
+ return ICON_NUM7_KEY;
+ case R.styleable.Keyboard_iconNum8Key:
+ return ICON_NUM8_KEY;
+ case R.styleable.Keyboard_iconNum9Key:
+ return ICON_NUM9_KEY;
+ case R.styleable.Keyboard_iconNum0Key:
+ return ICON_NUM0_KEY;
+ case R.styleable.Keyboard_iconNumStarKey:
+ return ICON_NUM_STAR_KEY;
+ case R.styleable.Keyboard_iconNumPoundKey:
+ return ICON_NUM_POUND_KEY;
+ case R.styleable.Keyboard_iconNumAltKey:
+ return ICON_NUM_ALT_KEY;
+ case R.styleable.Keyboard_iconShiftedShiftKey:
+ return ICON_SHIFTED_SHIFT_KEY;
+ case R.styleable.Keyboard_iconPreviewSpaceKey:
+ return ICON_PREVIEW_SPACE_KEY;
+ case R.styleable.Keyboard_iconPreviewTabKey:
+ return ICON_PREVIEW_TAB_KEY;
+ case R.styleable.Keyboard_iconPreviewSettingsKey:
+ return ICON_PREVIEW_SETTINGS_KEY;
+ case R.styleable.Keyboard_iconPreviewShortcutKey:
+ return ICON_PREVIEW_SHORTCUT_KEY;
+ default:
+ return ICON_UNDEFINED;
+ }
+ }
+
+ public void loadIcons(TypedArray keyboardAttrs) {
+ final int count = keyboardAttrs.getIndexCount();
+ for (int i = 0; i < count; i++) {
+ 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;
+ }
+ }
+ }
+
+ public Drawable getIcon(int iconId) {
+ if (iconId == ICON_UNDEFINED)
+ return null;
+ if (iconId < 0 || iconId >= mIcons.length)
+ throw new IllegalArgumentException("icon id is out of range: " + iconId);
+ return mIcons[iconId];
+ }
+}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
index f54cf0bea..9525b0e00 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
@@ -232,6 +232,8 @@ public class KeyboardParser {
keyboard.setMaxPopupKeyboardColumn(keyAttr.getInt(
R.styleable.Keyboard_Key_maxPopupKeyboardColumn, 5));
+
+ mKeyboard.mIconsSet.loadIcons(keyboardAttr);
} finally {
keyAttr.recycle();
keyboardAttr.recycle();
diff --git a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
index 7eb3e4623..01faae61d 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
@@ -16,16 +16,16 @@
package com.android.inputmethod.keyboard.internal;
-import com.android.inputmethod.keyboard.Keyboard;
-import com.android.inputmethod.keyboard.KeyboardView;
-import com.android.inputmethod.keyboard.MiniKeyboard;
-import com.android.inputmethod.latin.R;
-
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Rect;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.KeyboardView;
+import com.android.inputmethod.keyboard.MiniKeyboard;
+import com.android.inputmethod.latin.R;
+
import java.util.List;
public class MiniKeyboardBuilder {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/PopupCharactersParser.java b/java/src/com/android/inputmethod/keyboard/internal/PopupCharactersParser.java
index 3b9a08322..8276f5d78 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/PopupCharactersParser.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/PopupCharactersParser.java
@@ -16,29 +16,32 @@
package com.android.inputmethod.keyboard.internal;
+import android.content.res.Resources;
+import android.text.TextUtils;
+import android.util.Log;
+
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.R;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.text.TextUtils;
-
/**
* String parser of popupCharacters attribute of Key.
* The string is comma separated texts each of which represents one popup key.
* Each popup key text is one of the following:
* - A single letter (Letter)
* - Label optionally followed by keyOutputText or code (keyLabel|keyOutputText).
- * - Icon followed by keyOutputText or code (@drawable/icon|@integer/key_code)
+ * - Icon followed by keyOutputText or code (@icon/icon_number|@integer/key_code)
* Special character, comma ',' backslash '\', and bar '|' can be escaped by '\'
* character.
* Note that the character '@' and '\' are also parsed by XML parser and CSV parser as well.
+ * See {@link KeyboardIconsSet} about icon_number.
*/
public class PopupCharactersParser {
+ private static final String TAG = PopupCharactersParser.class.getSimpleName();
+
private static final char ESCAPE = '\\';
private static final String LABEL_END = "|";
private static final String PREFIX_AT = "@";
- private static final String PREFIX_ICON = PREFIX_AT + "drawable/";
+ private static final String PREFIX_ICON = PREFIX_AT + "icon/";
private static final String PREFIX_CODE = PREFIX_AT + "integer/";
private PopupCharactersParser() {
@@ -151,13 +154,18 @@ public class PopupCharactersParser {
return Keyboard.CODE_DUMMY;
}
- public static Drawable getIcon(Resources res, String popupSpec) {
+ public static int getIconId(String popupSpec) {
if (hasIcon(popupSpec)) {
int end = popupSpec.indexOf(LABEL_END, PREFIX_ICON.length() + 1);
- int resId = getResourceId(res, popupSpec.substring(PREFIX_AT.length(), end));
- return res.getDrawable(resId);
+ final String iconId = popupSpec.substring(PREFIX_ICON.length(), end);
+ try {
+ return Integer.valueOf(iconId);
+ } catch (NumberFormatException e) {
+ Log.w(TAG, "illegal icon id specified: " + iconId);
+ return KeyboardIconsSet.ICON_UNDEFINED;
+ }
}
- return null;
+ return KeyboardIconsSet.ICON_UNDEFINED;
}
private static int getResourceId(Resources res, String name) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/Row.java b/java/src/com/android/inputmethod/keyboard/internal/Row.java
index 99d69ea76..06aadcc05 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/Row.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/Row.java
@@ -16,14 +16,14 @@
package com.android.inputmethod.keyboard.internal;
-import com.android.inputmethod.keyboard.Keyboard;
-import com.android.inputmethod.latin.R;
-
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.Xml;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.latin.R;
+
/**
* Container for keys in the keyboard. All keys in a row are at the same Y-coordinate.
* Some of the key size defaults can be overridden per row from what the {@link Keyboard}
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/PopupCharactersParserTests.java b/tests/src/com/android/inputmethod/keyboard/internal/PopupCharactersParserTests.java
index be64f89d2..e4a1c68d8 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/PopupCharactersParserTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/PopupCharactersParserTests.java
@@ -16,23 +16,24 @@
package com.android.inputmethod.keyboard.internal;
-import com.android.inputmethod.keyboard.Keyboard;
-import com.android.inputmethod.keyboard.internal.PopupCharactersParser.PopupCharactersParserError;
-import com.android.inputmethod.latin.R;
import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
import android.test.AndroidTestCase;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.latin.R;
+
public class PopupCharactersParserTests extends AndroidTestCase {
private Resources mRes;
+ private static final int ICON_SETTINGS_KEY = 5;
+ private static final int ICON_UNDEFINED = KeyboardIconsSet.ICON_UNDEFINED;
+
private static final String CODE_SETTINGS = "@integer/key_settings";
- private static final String ICON_SETTINGS = "@drawable/sym_keyboard_settings";
+ private static final String ICON_SETTINGS = "@icon/" + ICON_SETTINGS_KEY;
private static final String CODE_NON_EXISTING = "@integer/non_existing";
- private static final String ICON_NON_EXISTING = "@drawable/non_existing";
+ private static final String ICON_NON_EXISTING = "@icon/non_existing";
private int mCodeSettings;
- private Drawable mIconSettings;
@Override
protected void setUp() {
@@ -41,33 +42,26 @@ public class PopupCharactersParserTests extends AndroidTestCase {
final String packageName = res.getResourcePackageName(R.string.english_ime_name);
final int codeId = res.getIdentifier(CODE_SETTINGS.substring(1), null, packageName);
- final int iconId = res.getIdentifier(ICON_SETTINGS.substring(1), null, packageName);
mCodeSettings = res.getInteger(codeId);
- mIconSettings = res.getDrawable(iconId);
}
private void assertParser(String message, String popupSpec, String expectedLabel,
- String expectedOutputText, Drawable expectedIcon, int expectedCode) {
+ String expectedOutputText, int expectedIcon, int expectedCode) {
String actualLabel = PopupCharactersParser.getLabel(popupSpec);
assertEquals(message + ": label:", expectedLabel, actualLabel);
String actualOutputText = PopupCharactersParser.getOutputText(popupSpec);
assertEquals(message + ": ouptputText:", expectedOutputText, actualOutputText);
- Drawable actualIcon = PopupCharactersParser.getIcon(mRes, popupSpec);
- // We can not compare drawables, checking null or non-null instead.
- if (expectedIcon == null) {
- assertNull(message + ": icon null:", actualIcon);
- } else {
- assertNotNull(message + ": icon non-null:", actualIcon);
- }
+ int actualIcon = PopupCharactersParser.getIconId(popupSpec);
+ assertEquals(message + ": icon:", expectedIcon, actualIcon);
int actualCode = PopupCharactersParser.getCode(mRes, popupSpec);
assertEquals(message + ": codes value:", expectedCode, actualCode);
}
private void assertParserError(String message, String popupSpec, String expectedLabel,
- String expectedOutputText, Drawable expectedIcon, int expectedCode) {
+ String expectedOutputText, int expectedIcon, int expectedCode) {
try {
assertParser(message, popupSpec, expectedLabel, expectedOutputText, expectedIcon,
expectedCode);
@@ -78,132 +72,149 @@ public class PopupCharactersParserTests extends AndroidTestCase {
}
public void testSingleLetter() {
- assertParser("Single letter", "a", "a", null, null, 'a');
- assertParser("Single escaped bar", "\\|", "|", null, null, '|');
- assertParser("Single escaped escape", "\\\\", "\\", null, null, '\\');
- assertParser("Single comma", ",", ",", null, null, ',');
- assertParser("Single escaped comma", "\\,", ",", null, null, ',');
- assertParser("Single escaped letter", "\\a", "a", null, null, 'a');
- assertParser("Single at", "@", "@", null, null, '@');
- assertParser("Single escaped at", "\\@", "@", null, null, '@');
- assertParser("Single letter with outputText", "a|abc", "a", "abc", null,
- Keyboard.CODE_DUMMY);
- assertParser("Single letter with escaped outputText", "a|a\\|c", "a", "a|c", null,
- Keyboard.CODE_DUMMY);
- assertParser("Single letter with comma outputText", "a|a,b", "a", "a,b", null,
- Keyboard.CODE_DUMMY);
- assertParser("Single letter with escaped comma outputText", "a|a\\,b", "a", "a,b", null,
- Keyboard.CODE_DUMMY);
- assertParser("Single letter with outputText starts with at", "a|@bc", "a", "@bc", null,
- Keyboard.CODE_DUMMY);
- assertParser("Single letter with outputText contains at", "a|a@c", "a", "a@c", null,
- Keyboard.CODE_DUMMY);
- assertParser("Single letter with escaped at outputText", "a|\\@bc", "a", "@bc", null,
- Keyboard.CODE_DUMMY);
- assertParser("Single escaped escape with outputText", "\\\\|\\\\", "\\", "\\", null,
- Keyboard.CODE_DUMMY);
- assertParser("Single escaped bar with outputText", "\\||\\|", "|", "|", null,
- Keyboard.CODE_DUMMY);
- assertParser("Single letter with code", "a|" + CODE_SETTINGS, "a", null, null,
- mCodeSettings);
+ assertParser("Single letter", "a",
+ "a", null, ICON_UNDEFINED, 'a');
+ assertParser("Single escaped bar", "\\|",
+ "|", null, ICON_UNDEFINED, '|');
+ assertParser("Single escaped escape", "\\\\",
+ "\\", null, ICON_UNDEFINED, '\\');
+ assertParser("Single comma", ",",
+ ",", null, ICON_UNDEFINED, ',');
+ assertParser("Single escaped comma", "\\,",
+ ",", null, ICON_UNDEFINED, ',');
+ assertParser("Single escaped letter", "\\a",
+ "a", null, ICON_UNDEFINED, 'a');
+ assertParser("Single at", "@",
+ "@", null, ICON_UNDEFINED, '@');
+ assertParser("Single escaped at", "\\@",
+ "@", null, ICON_UNDEFINED, '@');
+ assertParser("Single letter with outputText", "a|abc",
+ "a", "abc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Single letter with escaped outputText", "a|a\\|c",
+ "a", "a|c", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Single letter with comma outputText", "a|a,b",
+ "a", "a,b", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Single letter with escaped comma outputText", "a|a\\,b",
+ "a", "a,b", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Single letter with outputText starts with at", "a|@bc",
+ "a", "@bc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Single letter with outputText contains at", "a|a@c",
+ "a", "a@c", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Single letter with escaped at outputText", "a|\\@bc",
+ "a", "@bc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Single escaped escape with outputText", "\\\\|\\\\",
+ "\\", "\\", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Single escaped bar with outputText", "\\||\\|",
+ "|", "|", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Single letter with code", "a|" + CODE_SETTINGS,
+ "a", null, ICON_UNDEFINED, mCodeSettings);
}
public void testLabel() {
- assertParser("Simple label", "abc", "abc", "abc", null, Keyboard.CODE_DUMMY);
- assertParser("Label with escaped bar", "a\\|c", "a|c", "a|c", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with escaped escape", "a\\\\c", "a\\c", "a\\c", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with comma", "a,c", "a,c", "a,c", null, Keyboard.CODE_DUMMY);
- assertParser("Label with escaped comma", "a\\,c", "a,c", "a,c", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label starts with at", "@bc", "@bc", "@bc", null, Keyboard.CODE_DUMMY);
- assertParser("Label contains at", "a@c", "a@c", "a@c", null, Keyboard.CODE_DUMMY);
- assertParser("Label with escaped at", "\\@bc", "@bc", "@bc", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with escaped letter", "\\abc", "abc", "abc", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with outputText", "abc|def", "abc", "def", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with comma and outputText", "a,c|def", "a,c", "def", null,
- Keyboard.CODE_DUMMY);
- assertParser("Escaped comma label with outputText", "a\\,c|def", "a,c", "def", null,
- Keyboard.CODE_DUMMY);
- assertParser("Escaped label with outputText", "a\\|c|def", "a|c", "def", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with escaped bar outputText", "abc|d\\|f", "abc", "d|f", null,
- Keyboard.CODE_DUMMY);
- assertParser("Escaped escape label with outputText", "a\\\\|def", "a\\", "def", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label starts with at and outputText", "@bc|def", "@bc", "def", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label contains at label and outputText", "a@c|def", "a@c", "def", null,
- Keyboard.CODE_DUMMY);
- assertParser("Escaped at label with outputText", "\\@bc|def", "@bc", "def", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with comma outputText", "abc|a,b", "abc", "a,b", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with escaped comma outputText", "abc|a\\,b", "abc", "a,b", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with outputText starts with at", "abc|@bc", "abc", "@bc", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with outputText contains at", "abc|a@c", "abc", "a@c", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with escaped at outputText", "abc|\\@bc", "abc", "@bc", null,
- Keyboard.CODE_DUMMY);
- assertParser("Label with escaped bar outputText", "abc|d\\|f", "abc", "d|f",
- null, Keyboard.CODE_DUMMY);
- assertParser("Escaped bar label with escaped bar outputText", "a\\|c|d\\|f", "a|c", "d|f",
- null, Keyboard.CODE_DUMMY);
- assertParser("Label with code", "abc|" + CODE_SETTINGS, "abc", null, null, mCodeSettings);
- assertParser("Escaped label with code", "a\\|c|" + CODE_SETTINGS, "a|c", null, null,
- mCodeSettings);
+ assertParser("Simple label", "abc",
+ "abc", "abc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with escaped bar", "a\\|c",
+ "a|c", "a|c", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with escaped escape", "a\\\\c",
+ "a\\c", "a\\c", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with comma", "a,c",
+ "a,c", "a,c", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with escaped comma", "a\\,c",
+ "a,c", "a,c", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label starts with at", "@bc",
+ "@bc", "@bc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label contains at", "a@c",
+ "a@c", "a@c", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with escaped at", "\\@bc",
+ "@bc", "@bc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with escaped letter", "\\abc",
+ "abc", "abc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with outputText", "abc|def",
+ "abc", "def", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with comma and outputText", "a,c|def",
+ "a,c", "def", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Escaped comma label with outputText", "a\\,c|def",
+ "a,c", "def", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Escaped label with outputText", "a\\|c|def",
+ "a|c", "def", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with escaped bar outputText", "abc|d\\|f",
+ "abc", "d|f", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Escaped escape label with outputText", "a\\\\|def",
+ "a\\", "def", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label starts with at and outputText", "@bc|def",
+ "@bc", "def", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label contains at label and outputText", "a@c|def",
+ "a@c", "def", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Escaped at label with outputText", "\\@bc|def",
+ "@bc", "def", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with comma outputText", "abc|a,b",
+ "abc", "a,b", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with escaped comma outputText", "abc|a\\,b",
+ "abc", "a,b", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with outputText starts with at", "abc|@bc",
+ "abc", "@bc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with outputText contains at", "abc|a@c",
+ "abc", "a@c", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with escaped at outputText", "abc|\\@bc",
+ "abc", "@bc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with escaped bar outputText", "abc|d\\|f",
+ "abc", "d|f", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Escaped bar label with escaped bar outputText", "a\\|c|d\\|f",
+ "a|c", "d|f", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParser("Label with code", "abc|" + CODE_SETTINGS,
+ "abc", null, ICON_UNDEFINED, mCodeSettings);
+ assertParser("Escaped label with code", "a\\|c|" + CODE_SETTINGS,
+ "a|c", null, ICON_UNDEFINED, mCodeSettings);
}
public void testIconAndCode() {
- assertParser("Icon with outputText", ICON_SETTINGS + "|abc", null, "abc", mIconSettings,
- Keyboard.CODE_DUMMY);
- assertParser("Icon with outputText starts with at", ICON_SETTINGS + "|@bc", null, "@bc",
- mIconSettings, Keyboard.CODE_DUMMY);
- assertParser("Icon with outputText contains at", ICON_SETTINGS + "|a@c", null, "a@c",
- mIconSettings, Keyboard.CODE_DUMMY);
- assertParser("Icon with escaped at outputText", ICON_SETTINGS + "|\\@bc", null, "@bc",
- mIconSettings, Keyboard.CODE_DUMMY);
- assertParser("Label starts with at and code", "@bc|" + CODE_SETTINGS, "@bc", null, null,
- mCodeSettings);
- assertParser("Label contains at and code", "a@c|" + CODE_SETTINGS, "a@c", null, null,
- mCodeSettings);
- assertParser("Escaped at label with code", "\\@bc|" + CODE_SETTINGS, "@bc", null, null,
- mCodeSettings);
- assertParser("Icon with code", ICON_SETTINGS + "|" + CODE_SETTINGS, null, null,
- mIconSettings, mCodeSettings);
+ assertParser("Icon with outputText", ICON_SETTINGS + "|abc",
+ null, "abc", ICON_SETTINGS_KEY, Keyboard.CODE_DUMMY);
+ assertParser("Icon with outputText starts with at", ICON_SETTINGS + "|@bc",
+ null, "@bc", ICON_SETTINGS_KEY, Keyboard.CODE_DUMMY);
+ assertParser("Icon with outputText contains at", ICON_SETTINGS + "|a@c",
+ null, "a@c", ICON_SETTINGS_KEY, Keyboard.CODE_DUMMY);
+ assertParser("Icon with escaped at outputText", ICON_SETTINGS + "|\\@bc",
+ null, "@bc", ICON_SETTINGS_KEY, Keyboard.CODE_DUMMY);
+ assertParser("Label starts with at and code", "@bc|" + CODE_SETTINGS,
+ "@bc", null, ICON_UNDEFINED, mCodeSettings);
+ assertParser("Label contains at and code", "a@c|" + CODE_SETTINGS,
+ "a@c", null, ICON_UNDEFINED, mCodeSettings);
+ assertParser("Escaped at label with code", "\\@bc|" + CODE_SETTINGS,
+ "@bc", null, ICON_UNDEFINED, mCodeSettings);
+ assertParser("Icon with code", ICON_SETTINGS + "|" + CODE_SETTINGS,
+ null, null, ICON_SETTINGS_KEY, mCodeSettings);
}
public void testFormatError() {
- assertParserError("Empty spec", "", null, null, null, Keyboard.CODE_UNSPECIFIED);
- assertParserError("Empty label with outputText", "|a", null, "a", null,
- Keyboard.CODE_DUMMY);
- assertParserError("Empty label with code", "|" + CODE_SETTINGS, null, null, null,
- mCodeSettings);
- assertParserError("Empty outputText with label", "a|", "a", null, null,
- Keyboard.CODE_UNSPECIFIED);
- assertParserError("Empty outputText with icon", ICON_SETTINGS + "|", null, null,
- mIconSettings, Keyboard.CODE_UNSPECIFIED);
- assertParserError("Empty icon and code", "|", null, null, null, Keyboard.CODE_UNSPECIFIED);
- assertParserError("Icon without code", ICON_SETTINGS, null, null, mIconSettings,
- Keyboard.CODE_DUMMY);
- assertParserError("Non existing icon", ICON_NON_EXISTING + "|abc", null, "abc", null,
- Keyboard.CODE_DUMMY);
- assertParserError("Non existing code", "abc|" + CODE_NON_EXISTING, "abc", null, null,
- Keyboard.CODE_UNSPECIFIED);
- assertParserError("Third bar at end", "a|b|", "a", null, null, Keyboard.CODE_UNSPECIFIED);
- assertParserError("Multiple bar", "a|b|c", "a", null, null, Keyboard.CODE_UNSPECIFIED);
- assertParserError("Multiple bar with label and code", "a|" + CODE_SETTINGS + "|c", "a",
- null, null, mCodeSettings);
- assertParserError("Multiple bar with icon and outputText", ICON_SETTINGS + "|b|c", null,
- null, mIconSettings, Keyboard.CODE_UNSPECIFIED);
+ assertParserError("Empty spec", "", null,
+ null, ICON_UNDEFINED, Keyboard.CODE_UNSPECIFIED);
+ assertParserError("Empty label with outputText", "|a",
+ null, "a", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParserError("Empty label with code", "|" + CODE_SETTINGS,
+ null, null, ICON_UNDEFINED, mCodeSettings);
+ assertParserError("Empty outputText with label", "a|",
+ "a", null, ICON_UNDEFINED, Keyboard.CODE_UNSPECIFIED);
+ assertParserError("Empty outputText with icon", ICON_SETTINGS + "|",
+ null, null, ICON_SETTINGS_KEY, Keyboard.CODE_UNSPECIFIED);
+ assertParserError("Empty icon and code", "|",
+ null, null, ICON_UNDEFINED, Keyboard.CODE_UNSPECIFIED);
+ assertParserError("Icon without code", ICON_SETTINGS,
+ null, null, ICON_SETTINGS_KEY, Keyboard.CODE_DUMMY);
+ assertParser("Non existing icon", ICON_NON_EXISTING + "|abc",
+ null, "abc", ICON_UNDEFINED, Keyboard.CODE_DUMMY);
+ assertParserError("Non existing code", "abc|" + CODE_NON_EXISTING,
+ "abc", null, ICON_UNDEFINED, Keyboard.CODE_UNSPECIFIED);
+ assertParserError("Third bar at end", "a|b|",
+ "a", null, ICON_UNDEFINED, Keyboard.CODE_UNSPECIFIED);
+ assertParserError("Multiple bar", "a|b|c",
+ "a", null, ICON_UNDEFINED, Keyboard.CODE_UNSPECIFIED);
+ assertParserError("Multiple bar with label and code", "a|" + CODE_SETTINGS + "|c",
+ "a", null, ICON_UNDEFINED, mCodeSettings);
+ assertParserError("Multiple bar with icon and outputText", ICON_SETTINGS + "|b|c",
+ null, null, ICON_SETTINGS_KEY, Keyboard.CODE_UNSPECIFIED);
assertParserError("Multiple bar with icon and code",
- ICON_SETTINGS + "|" + CODE_SETTINGS + "|c", null, null, mIconSettings,
- mCodeSettings);
+ ICON_SETTINGS + "|" + CODE_SETTINGS + "|c",
+ null, null, ICON_SETTINGS_KEY, mCodeSettings);
}
}