diff options
| author | Tadashi G. Takaoka <takaoka@google.com> | 2011-06-28 16:32:39 +0900 |
|---|---|---|
| committer | Tadashi G. Takaoka <takaoka@google.com> | 2011-06-29 18:34:57 +0900 |
| commit | d773bf38a3c8f49ea56de67d3b828f8126f46ed2 (patch) | |
| tree | b402a558ecf37cc1ff6f2bc584abf9a537fee5b6 /java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java | |
| parent | 98d2e4c840e7adf9d5fbb008fb3312914b1ed36b (diff) | |
Cleanup key drawing code
This change also modifies 9-patch drawables to fix the following
issues. In order to draw key background drawable just on the
coordinates we want, we have to know where an actual "visible" part is
in the drawable. The only clue we can use is "padding" of the
drawable. To achieve this, the 9-patch drawable must have its
"visible" part marked as "content". Please refer the Bug: 4948171 for
more detailed explanation.
This change also reverts the following "black" drawables back from
Gingerbread because recent change broke these (I70019a91).
* drawable-hdpi/sym_bkeyboard_*.png
* drawable-hdpi/btn_keyboard_key_*_stone.9.png
Bug: 4948171
Change-Id: I6e4d03b3144caa95c793aac97af22df34c5f454f
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java')
| -rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java index a6708171f..3e433361a 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java @@ -195,6 +195,7 @@ public class KeyboardParser { private void parseKeyboardAttributes(XmlResourceParser parser) { final Keyboard keyboard = mKeyboard; + final int displayWidth = keyboard.getDisplayWidth(); final TypedArray keyboardAttr = mContext.obtainStyledAttributes( Xml.asAttributeSet(parser), R.styleable.Keyboard, R.attr.keyboardStyle, R.style.Keyboard); @@ -211,7 +212,6 @@ public class KeyboardParser { if (minKeyboardHeight < 0) { // Specified fraction was negative, so it should be calculated against display // width. - final int displayWidth = keyboard.getDisplayWidth(); minKeyboardHeight = -getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_minKeyboardHeight, displayWidth, displayWidth / 2); } @@ -219,20 +219,19 @@ public class KeyboardParser { // minKeyboardHeight. final int height = Math.max( Math.min(keyboardHeight, maxKeyboardHeight), minKeyboardHeight); - final int width = keyboard.getDisplayWidth(); + keyboard.setKeyboardHeight(height); keyboard.setKeyWidth(getDimensionOrFraction(keyboardAttr, - R.styleable.Keyboard_keyWidth, width, width / 10)); + R.styleable.Keyboard_keyWidth, displayWidth, displayWidth / 10)); keyboard.setRowHeight(getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_rowHeight, height, 50)); keyboard.setHorizontalGap(getDimensionOrFraction(keyboardAttr, - R.styleable.Keyboard_horizontalGap, width, 0)); + R.styleable.Keyboard_horizontalGap, displayWidth, 0)); keyboard.setVerticalGap(getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_verticalGap, height, 0)); keyboard.setPopupKeyboardResId(keyboardAttr.getResourceId( R.styleable.Keyboard_popupKeyboardTemplate, 0)); - keyboard.setMaxPopupKeyboardColumn(keyAttr.getInt( R.styleable.Keyboard_Key_maxPopupKeyboardColumn, 5)); @@ -352,18 +351,18 @@ public class KeyboardParser { R.styleable.Keyboard); if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap)) throw new IllegalAttribute(parser, "horizontalGap"); - final int defaultWidth = (row != null) ? row.mDefaultWidth : 0; + final int keyboardWidth = mKeyboard.getDisplayWidth(); final int keyWidth = getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_keyWidth, - mKeyboard.getDisplayWidth(), defaultWidth); + keyboardWidth, row.mDefaultWidth); keyboardAttr.recycle(); final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.Keyboard_Key); int keyXPos = KeyboardParser.getDimensionOrFraction(keyAttr, - R.styleable.Keyboard_Key_keyXPos, mKeyboard.getDisplayWidth(), mCurrentX); + R.styleable.Keyboard_Key_keyXPos, keyboardWidth, mCurrentX); if (keyXPos < 0) { // If keyXPos is negative, the actual x-coordinate will be display_width + keyXPos. - keyXPos += mKeyboard.getDisplayWidth(); + keyXPos += keyboardWidth; } checkEndTag(TAG_SPACER, parser); |
