Add keyboardLetfPadding and keyboardRightPadding attributes

This change splits keyboardHorizontalEdgesPadding attributes of
Keyboard into two attributes.

Change-Id: Iefdb358783b81af4027e8d9e991db36a6c429cf1
This commit is contained in:
Tadashi G. Takaoka 2013-01-30 13:08:44 +09:00
parent 48409b9ac6
commit e1f091c5d4
16 changed files with 40 additions and 31 deletions

View file

@ -173,11 +173,11 @@
<attr name="themeId" format="integer" />
<!-- Touch position correction -->
<attr name="touchPositionCorrectionData" format="reference" />
<!-- Keyboard top, bottom edges paddings, in propotion of keyboard height. -->
<!-- Keyboard top, bottom, left, right edges paddings, in propotion of keyboard height. -->
<attr name="keyboardTopPadding" format="fraction" />
<attr name="keyboardBottomPadding" format="fraction" />
<!-- Keyboard both horizontal edges paddings, in propotion of keyboard width. -->
<attr name="keyboardHorizontalEdgesPadding" format="fraction" />
<attr name="keyboardLeftPadding" format="fraction" />
<attr name="keyboardRightPadding" format="fraction" />
<!-- Default height of a row (key height + vertical gap), in pixels or in the proportion of
keyboard height. -->
<attr name="rowHeight" format="dimension|fraction" />

View file

@ -31,7 +31,8 @@
<fraction name="keyboard_top_padding">1.556%p</fraction>
<fraction name="keyboard_bottom_padding">4.669%p</fraction>
<fraction name="keyboard_horizontal_edges_padding">0%p</fraction>
<fraction name="keyboard_left_padding">0%p</fraction>
<fraction name="keyboard_right_padding">0%p</fraction>
<fraction name="key_bottom_gap">6.250%p</fraction>
<fraction name="key_horizontal_gap">1.352%p</fraction>

View file

@ -24,7 +24,8 @@
<item name="moreKeysTemplate">@xml/kbd_more_keys_keyboard_template</item>
<item name="keyboardTopPadding">@fraction/keyboard_top_padding</item>
<item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding</item>
<item name="keyboardHorizontalEdgesPadding">@fraction/keyboard_horizontal_edges_padding</item>
<item name="keyboardLeftPadding">@fraction/keyboard_left_padding</item>
<item name="keyboardRightPadding">@fraction/keyboard_right_padding</item>
<item name="horizontalGap">@fraction/key_horizontal_gap</item>
<item name="verticalGap">@fraction/key_bottom_gap</item>
<item name="maxMoreKeysColumn">@integer/config_max_more_keys_column</item>

View file

@ -20,7 +20,8 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyboardLeftPadding="10%p"
latin:keyboardRightPadding="10%p"
latin:keyWidth="26.67%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>

View file

@ -20,7 +20,8 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyboardLeftPadding="10%p"
latin:keyboardRightPadding="10%p"
latin:keyWidth="26.67%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>

View file

@ -20,7 +20,8 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyboardLeftPadding="10%p"
latin:keyboardRightPadding="10%p"
latin:keyWidth="26.67%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>

View file

@ -20,7 +20,8 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyboardLeftPadding="10%p"
latin:keyboardRightPadding="10%p"
latin:keyWidth="18%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>

View file

@ -20,7 +20,8 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyboardLeftPadding="10%p"
latin:keyboardRightPadding="10%p"
latin:keyWidth="18%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>

View file

@ -20,7 +20,8 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyboardLeftPadding="10%p"
latin:keyboardRightPadding="10%p"
latin:keyWidth="18%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>

View file

@ -20,7 +20,8 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyboardLeftPadding="10%p"
latin:keyboardRightPadding="10%p"
latin:keyWidth="13.250%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>

View file

@ -20,7 +20,8 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyboardLeftPadding="10%p"
latin:keyboardRightPadding="10%p"
latin:keyWidth="13.250%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>

View file

@ -20,7 +20,8 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyboardLeftPadding="10%p"
latin:keyboardRightPadding="10%p"
latin:keyWidth="13.250%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>

View file

@ -470,11 +470,11 @@ public class Key implements Comparable<Key> {
}
public void markAsLeftEdge(final KeyboardParams params) {
mHitBox.left = params.mHorizontalEdgesPadding;
mHitBox.left = params.mLeftPadding;
}
public void markAsRightEdge(final KeyboardParams params) {
mHitBox.right = params.mOccupiedWidth - params.mHorizontalEdgesPadding;
mHitBox.right = params.mOccupiedWidth - params.mRightPadding;
}
public void markAsTopEdge(final KeyboardParams params) {

View file

@ -243,13 +243,13 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
R.styleable.Keyboard_keyboardTopPadding, height, height, 0);
params.mBottomPadding = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardBottomPadding, height, height, 0);
// TODO: Split keyboardHorizontalEdgesPadding into two, keyboardLeftPaddings and
// keyboardRightPaddings.
params.mHorizontalEdgesPadding = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardHorizontalEdgesPadding, width, width, 0);
params.mLeftPadding = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardLeftPadding, width, width, 0);
params.mRightPadding = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardRightPadding, width, width, 0);
final int baseWidth = params.mOccupiedWidth - params.mHorizontalEdgesPadding * 2
- params.mHorizontalCenterPadding;
final int baseWidth =
params.mOccupiedWidth - params.mLeftPadding - params.mRightPadding;
params.mBaseWidth = baseWidth;
params.mDefaultKeyWidth = (int)keyAttr.getFraction(R.styleable.Keyboard_Key_keyWidth,
baseWidth, baseWidth, baseWidth / DEFAULT_KEYBOARD_COLUMNS);
@ -742,7 +742,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
}
private void startRow(final KeyboardRow row) {
addEdgeSpace(mParams.mHorizontalEdgesPadding, row);
addEdgeSpace(mParams.mLeftPadding, row);
mCurrentRow = row;
mLeftEdge = true;
mRightEdgeKey = null;
@ -756,7 +756,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
mRightEdgeKey.markAsRightEdge(mParams);
mRightEdgeKey = null;
}
addEdgeSpace(mParams.mHorizontalEdgesPadding, row);
addEdgeSpace(mParams.mRightPadding, row);
mCurrentY += row.mRowHeight;
mCurrentRow = null;
mTopEdge = false;

View file

@ -42,8 +42,8 @@ public class KeyboardParams {
public int mTopPadding;
public int mBottomPadding;
public int mHorizontalEdgesPadding;
public int mHorizontalCenterPadding;
public int mLeftPadding;
public int mRightPadding;
public KeyVisualAttributes mKeyVisualAttributes;

View file

@ -111,8 +111,6 @@ public final class KeyboardRow {
}
public float getKeyX(final TypedArray keyAttr) {
final int keyboardRightEdge = mParams.mOccupiedWidth
- mParams.mHorizontalEdgesPadding;
if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyXPos)) {
final float keyXPos = keyAttr.getFraction(R.styleable.Keyboard_Key_keyXPos,
mParams.mBaseWidth, mParams.mBaseWidth, 0);
@ -122,9 +120,10 @@ public final class KeyboardRow {
// 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.
final int keyboardRightEdge = mParams.mOccupiedWidth - mParams.mRightPadding;
return Math.max(keyXPos + keyboardRightEdge, mCurrentX);
} else {
return keyXPos + mParams.mHorizontalEdgesPadding;
return keyXPos + mParams.mLeftPadding;
}
}
return mCurrentX;
@ -139,10 +138,9 @@ public final class KeyboardRow {
R.styleable.Keyboard_Key_keyWidth, KEYWIDTH_NOT_ENUM);
switch (widthType) {
case KEYWIDTH_FILL_RIGHT:
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.
final int keyboardRightEdge = mParams.mOccupiedWidth - mParams.mRightPadding;
return keyboardRightEdge - keyXPos;
default: // KEYWIDTH_NOT_ENUM
return keyAttr.getFraction(R.styleable.Keyboard_Key_keyWidth,