diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml
index 0f9bde882..4a5c5a44c 100644
--- a/java/res/values-land/dimens.xml
+++ b/java/res/values-land/dimens.xml
@@ -25,7 +25,6 @@
0.280in
- 0.0in
1.818%p
0.0%p
diff --git a/java/res/values-sw600dp-land/dimens.xml b/java/res/values-sw600dp-land/dimens.xml
index c1cef1d24..1b8c8a64a 100644
--- a/java/res/values-sw600dp-land/dimens.xml
+++ b/java/res/values-sw600dp-land/dimens.xml
@@ -23,7 +23,6 @@
45.0mm
45%p
- 0dp
2.444%p
0.0%p
4.911%p
diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml
index e1bdecfd9..31830239d 100644
--- a/java/res/values-sw600dp/dimens.xml
+++ b/java/res/values-sw600dp/dimens.xml
@@ -26,7 +26,6 @@
10.0mm
- 0.0mm
2.291%p
0.0%p
3.750%p
diff --git a/java/res/values-sw768dp-land/dimens.xml b/java/res/values-sw768dp-land/dimens.xml
index 8f9b00672..664e8c159 100644
--- a/java/res/values-sw768dp-land/dimens.xml
+++ b/java/res/values-sw768dp-land/dimens.xml
@@ -23,7 +23,6 @@
58.0mm
45%p
- 0.0mm
1.896%p
0.0%p
diff --git a/java/res/values-sw768dp/dimens.xml b/java/res/values-sw768dp/dimens.xml
index b825b1457..bb4937dd5 100644
--- a/java/res/values-sw768dp/dimens.xml
+++ b/java/res/values-sw768dp/dimens.xml
@@ -24,7 +24,6 @@
50%p
-35.0%p
- 0.0mm
2.291%p
0.0%p
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index cd1b46073..1776630d9 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -144,19 +144,10 @@
-
+
-
-
-
-
-
+
@@ -258,6 +249,17 @@
+
+
+
+
+
+
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index cbd557e52..8b4cd6d1b 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -29,9 +29,9 @@
16dip
8dip
- 0dp
1.556%p
4.669%p
+ 0%p
6.250%p
1.352%p
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index 7b8bfa841..c6ea2a5f8 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -24,6 +24,7 @@
- @xml/kbd_mini_keyboard_template
- @fraction/keyboard_top_padding
- @fraction/keyboard_bottom_padding
+ - @fraction/keyboard_horizontal_edges_padding
- @fraction/key_horizontal_gap
- @fraction/key_bottom_gap
- @integer/config_max_more_keys_column
diff --git a/java/res/xml-land/kbd_number.xml b/java/res/xml-land/kbd_number.xml
new file mode 100644
index 000000000..f5930ef41
--- /dev/null
+++ b/java/res/xml-land/kbd_number.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
diff --git a/java/res/xml-land/kbd_phone.xml b/java/res/xml-land/kbd_phone.xml
new file mode 100644
index 000000000..3b1fb36ff
--- /dev/null
+++ b/java/res/xml-land/kbd_phone.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
diff --git a/java/res/xml-land/kbd_phone_shift.xml b/java/res/xml-land/kbd_phone_shift.xml
new file mode 100644
index 000000000..e59664776
--- /dev/null
+++ b/java/res/xml-land/kbd_phone_shift.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
diff --git a/java/res/xml/kbd_number.xml b/java/res/xml/kbd_number.xml
index aabf0eb7a..38dd6bf62 100644
--- a/java/res/xml/kbd_number.xml
+++ b/java/res/xml/kbd_number.xml
@@ -23,109 +23,5 @@
latin:keyWidth="26.67%p"
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ latin:keyboardLayout="@xml/kbd_rows_number" />
diff --git a/java/res/xml/kbd_phone.xml b/java/res/xml/kbd_phone.xml
index 4588ab2c9..b550f17c5 100644
--- a/java/res/xml/kbd_phone.xml
+++ b/java/res/xml/kbd_phone.xml
@@ -1,19 +1,19 @@
@@ -23,53 +23,5 @@
latin:keyWidth="26.67%p"
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ latin:keyboardLayout="@xml/kbd_rows_phone" />
diff --git a/java/res/xml/kbd_phone_shift.xml b/java/res/xml/kbd_phone_shift.xml
index 5be9bf9a9..eea823fc0 100644
--- a/java/res/xml/kbd_phone_shift.xml
+++ b/java/res/xml/kbd_phone_shift.xml
@@ -1,19 +1,19 @@
@@ -23,66 +23,5 @@
latin:keyWidth="26.67%p"
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ latin:keyboardLayout="@xml/kbd_rows_phone_shift" />
diff --git a/java/res/xml/kbd_rows_number.xml b/java/res/xml/kbd_rows_number.xml
new file mode 100644
index 000000000..21d0656d1
--- /dev/null
+++ b/java/res/xml/kbd_rows_number.xml
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/res/xml/kbd_rows_phone.xml b/java/res/xml/kbd_rows_phone.xml
new file mode 100644
index 000000000..5500a6078
--- /dev/null
+++ b/java/res/xml/kbd_rows_phone.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/res/xml/kbd_rows_phone_shift.xml b/java/res/xml/kbd_rows_phone_shift.xml
new file mode 100644
index 000000000..3c283d3e6
--- /dev/null
+++ b/java/res/xml/kbd_rows_phone_shift.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 997c4c9ad..b1cc7cafb 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -120,11 +120,6 @@ public class Key {
/** Whether this key needs to show the "..." popup hint for special purposes */
private boolean mNeedsSpecialPopupHint;
- // keyWidth enum constants
- private static final int KEYWIDTH_NOT_ENUM = 0;
- private static final int KEYWIDTH_FILL_RIGHT = -1;
- private static final int KEYWIDTH_FILL_BOTH = -2;
-
// RTL parenthesis character swapping map.
private static final Map sRtlParenthesisMap = new HashMap();
@@ -216,21 +211,9 @@ public class Key {
*/
public Key(Resources res, KeyboardParams params, KeyboardBuilder.Row row,
XmlResourceParser parser, KeyStyles keyStyles) {
- final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
- R.styleable.Keyboard);
- mHeight = (int)KeyboardBuilder.getDimensionOrFraction(keyboardAttr,
- R.styleable.Keyboard_rowHeight, params.mBaseHeight, row.mRowHeight)
- - params.mVerticalGap;
- final float horizontalGap = isSpacer() ? 0
- : KeyboardBuilder.getDimensionOrFraction(keyboardAttr,
- R.styleable.Keyboard_horizontalGap, params.mBaseWidth,
- params.mHorizontalGap);
+ final float horizontalGap = isSpacer() ? 0 : params.mHorizontalGap;
mVerticalGap = params.mVerticalGap;
- final int widthType = KeyboardBuilder.getEnumValue(keyboardAttr,
- R.styleable.Keyboard_keyWidth, KEYWIDTH_NOT_ENUM);
- float keyWidth = KeyboardBuilder.getDimensionOrFraction(keyboardAttr,
- R.styleable.Keyboard_keyWidth, params.mBaseWidth, row.mDefaultKeyWidth);
- keyboardAttr.recycle();
+ mHeight = row.mRowHeight - mVerticalGap;
final TypedArray keyAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard_Key);
@@ -245,38 +228,16 @@ public class Key {
style = keyStyles.getEmptyKeyStyle();
}
- final int keyboardWidth = params.mOccupiedWidth;
- final float x = row.mCurrentX;
- float keyXPos = KeyboardBuilder.getDimensionOrFraction(keyAttr,
- R.styleable.Keyboard_Key_keyXPos, keyboardWidth, x);
- if (keyXPos < 0) {
- // If keyXPos is negative, the actual x-coordinate will be keyboardWidth + keyXPos.
- keyXPos += keyboardWidth;
- if (keyXPos < x) {
- // keyXPos shouldn't be less than x because drawable area for this key starts
- // at x. Or, this key will overlaps the adjacent key on its left hand side.
- keyXPos = x;
- }
- }
- if (widthType == KEYWIDTH_FILL_RIGHT) {
- // If keyWidth is zero, the actual key width will be determined to fill out the
- // area up to the right edge of the keyboard.
- keyWidth = keyboardWidth - keyXPos;
- } else if (widthType == KEYWIDTH_FILL_BOTH) {
- // If keyWidth is negative, the actual key width will be determined to fill out the
- // area between the nearest key on the left hand side and the right edge of the
- // keyboard.
- keyXPos = x;
- keyWidth = keyboardWidth - keyXPos;
- }
+ final float keyXPos = row.getKeyX(keyAttr);
+ final float keyWidth = row.getKeyWidth(keyAttr, keyXPos);
// Horizontal gap is divided equally to both sides of the key.
mX = (int) (keyXPos + horizontalGap / 2);
- mY = row.mCurrentY;
+ mY = row.getKeyY();
mWidth = (int) (keyWidth - horizontalGap);
mHorizontalGap = (int) horizontalGap;
// Update row to have current x coordinate.
- row.mCurrentX = keyXPos + keyWidth;
+ row.setXPos(keyXPos + keyWidth);
final CharSequence[] moreKeys = style.getTextArray(keyAttr,
R.styleable.Keyboard_Key_moreKeys);
@@ -288,20 +249,20 @@ public class Key {
} else {
mMoreKeys = moreKeys;
}
- mMaxMoreKeysColumn = style.getInt(keyboardAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn,
- params.mMaxMiniKeyboardColumn);
+ mMaxMoreKeysColumn = style.getInt(keyAttr,
+ R.styleable.Keyboard_Key_maxMoreKeysColumn, params.mMaxMiniKeyboardColumn);
- mBackgroundType = style.getInt(
- keyAttr, R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL);
+ mBackgroundType = style.getInt(keyAttr,
+ R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL);
mRepeatable = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable, false);
mEnabled = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_enabled, true);
mEdgeFlags = 0;
final KeyboardIconsSet iconsSet = params.mIconsSet;
mVisualInsetsLeft = (int) KeyboardBuilder.getDimensionOrFraction(keyAttr,
- R.styleable.Keyboard_Key_visualInsetsLeft, keyboardWidth, 0);
+ R.styleable.Keyboard_Key_visualInsetsLeft, params.mBaseWidth, 0);
mVisualInsetsRight = (int) KeyboardBuilder.getDimensionOrFraction(keyAttr,
- R.styleable.Keyboard_Key_visualInsetsRight, keyboardWidth, 0);
+ R.styleable.Keyboard_Key_visualInsetsRight, params.mBaseWidth, 0);
mPreviewIcon = iconsSet.getIcon(style.getInt(keyAttr,
R.styleable.Keyboard_Key_keyIconPreview, KeyboardIconsSet.ICON_UNDEFINED));
mIcon = iconsSet.getIcon(style.getInt(keyAttr, R.styleable.Keyboard_Key_keyIcon,
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
index 8d246c490..99b917c86 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
@@ -144,27 +144,96 @@ public class KeyboardBuilder {
* defines.
*/
public static class Row {
+ // keyWidth enum constants
+ private static final int KEYWIDTH_NOT_ENUM = 0;
+ private static final int KEYWIDTH_FILL_RIGHT = -1;
+ private static final int KEYWIDTH_FILL_BOTH = -2;
+
+ private final KeyboardParams mParams;
/** Default width of a key in this row. */
public final float mDefaultKeyWidth;
/** Default height of a key in this row. */
public final int mRowHeight;
- public final int mCurrentY;
+ private final int mCurrentY;
// Will be updated by {@link Key}'s constructor.
- public float mCurrentX;
+ private float mCurrentX;
public Row(Resources res, KeyboardParams params, XmlResourceParser parser, int y) {
- TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser),
+ mParams = params;
+ TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard);
- mDefaultKeyWidth = KeyboardBuilder.getDimensionOrFraction(a,
- R.styleable.Keyboard_keyWidth, params.mBaseWidth, params.mDefaultKeyWidth);
- mRowHeight = (int)KeyboardBuilder.getDimensionOrFraction(a,
+ mRowHeight = (int)KeyboardBuilder.getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_rowHeight, params.mBaseHeight, params.mDefaultRowHeight);
- a.recycle();
+ keyboardAttr.recycle();
+ TypedArray keyAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
+ R.styleable.Keyboard_Key);
+ mDefaultKeyWidth = KeyboardBuilder.getDimensionOrFraction(keyboardAttr,
+ R.styleable.Keyboard_Key_keyWidth, params.mBaseWidth, params.mDefaultKeyWidth);
+ keyAttr.recycle();
mCurrentY = y;
mCurrentX = 0.0f;
}
+
+ public void setXPos(float keyXPos) {
+ mCurrentX = keyXPos;
+ }
+
+ public void advanceXPos(float width) {
+ mCurrentX += width;
+ }
+
+ public int getKeyY() {
+ return mCurrentY;
+ }
+
+ public float getKeyX(TypedArray keyAttr) {
+ final int widthType = KeyboardBuilder.getEnumValue(keyAttr,
+ R.styleable.Keyboard_Key_keyWidth, KEYWIDTH_NOT_ENUM);
+ if (widthType == KEYWIDTH_FILL_BOTH) {
+ // If keyWidth is fillBoth, the key width should start right after the nearest key
+ // on the left hand side.
+ return mCurrentX;
+ }
+
+ final int keyboardRightEdge = mParams.mOccupiedWidth - mParams.mHorizontalEdgesPadding;
+ if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyXPos)) {
+ final float keyXPos = KeyboardBuilder.getDimensionOrFraction(keyAttr,
+ R.styleable.Keyboard_Key_keyXPos, mParams.mBaseWidth, 0);
+ if (keyXPos < 0) {
+ // If keyXPos is negative, the actual x-coordinate will be
+ // keyboardWidth + keyXPos.
+ // keyXPos shouldn't be less than mCurrentX because drawable area for this key
+ // starts at mCurrentX. Or, this key will overlaps the adjacent key on its left
+ // hand side.
+ return Math.max(keyXPos + keyboardRightEdge, mCurrentX);
+ } else {
+ return keyXPos + mParams.mHorizontalEdgesPadding;
+ }
+ }
+ return mCurrentX;
+ }
+
+ public float getKeyWidth(TypedArray keyAttr, float keyXPos) {
+ final int widthType = KeyboardBuilder.getEnumValue(keyAttr,
+ R.styleable.Keyboard_Key_keyWidth, KEYWIDTH_NOT_ENUM);
+ switch (widthType) {
+ case KEYWIDTH_FILL_RIGHT:
+ case KEYWIDTH_FILL_BOTH:
+ final int keyboardRightEdge =
+ mParams.mOccupiedWidth - mParams.mHorizontalEdgesPadding;
+ // If keyWidth is fillRight, the actual key width will be determined to fill out the
+ // area up to the right edge of the keyboard.
+ // If keyWidth is fillBoth, the actual key width will be determined to fill out the
+ // area between the nearest key on the left hand side and the right edge of the
+ // keyboard.
+ return keyboardRightEdge - keyXPos;
+ default: // KEYWIDTH_NOT_ENUM
+ return KeyboardBuilder.getDimensionOrFraction(keyAttr,
+ R.styleable.Keyboard_Key_keyWidth, mParams.mBaseWidth, mDefaultKeyWidth);
+ }
+ }
}
public KeyboardBuilder(Context context, KP params) {
@@ -174,8 +243,6 @@ public class KeyboardBuilder {
mDisplayMetrics = res.getDisplayMetrics();
mParams = params;
- mParams.mHorizontalEdgesPadding = (int)res.getDimension(
- R.dimen.keyboard_horizontal_edges_padding);
mParams.GRID_WIDTH = res.getInteger(R.integer.config_keyboard_grid_width);
mParams.GRID_HEIGHT = res.getInteger(R.integer.config_keyboard_grid_height);
@@ -270,11 +337,13 @@ public class KeyboardBuilder {
R.styleable.Keyboard_keyboardTopPadding, params.mOccupiedHeight, 0);
params.mBottomPadding = (int)getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_keyboardBottomPadding, params.mOccupiedHeight, 0);
+ params.mHorizontalEdgesPadding = (int)getDimensionOrFraction(keyboardAttr,
+ R.styleable.Keyboard_keyboardHorizontalEdgesPadding, mParams.mOccupiedWidth, 0);
params.mBaseWidth = params.mOccupiedWidth - params.mHorizontalEdgesPadding * 2
- params.mHorizontalCenterPadding;
- params.mDefaultKeyWidth = (int)getDimensionOrFraction(keyboardAttr,
- R.styleable.Keyboard_keyWidth, params.mBaseWidth,
+ params.mDefaultKeyWidth = (int)getDimensionOrFraction(keyAttr,
+ R.styleable.Keyboard_Key_keyWidth, params.mBaseWidth,
params.mBaseWidth / DEFAULT_KEYBOARD_COLUMNS);
params.mHorizontalGap = (int)getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_horizontalGap, params.mBaseWidth, 0);
@@ -670,7 +739,6 @@ public class KeyboardBuilder {
}
private void startRow(Row row) {
- row.mCurrentX = 0;
addEdgeSpace(mParams.mHorizontalEdgesPadding, row);
mCurrentRow = row;
mLeftEdge = true;
@@ -685,7 +753,7 @@ public class KeyboardBuilder {
mRightEdgeKey = null;
}
addEdgeSpace(mParams.mHorizontalEdgesPadding, row);
- mCurrentY += mCurrentRow.mRowHeight;
+ mCurrentY += row.mRowHeight;
mCurrentRow = null;
mTopEdge = false;
}
@@ -706,7 +774,7 @@ public class KeyboardBuilder {
}
private void addEdgeSpace(float width, Row row) {
- row.mCurrentX += width;
+ row.advanceXPos(width);
mLeftEdge = false;
mRightEdgeKey = null;
}