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/MiniKeyboard.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/MiniKeyboard.java')
| -rw-r--r-- | java/src/com/android/inputmethod/keyboard/MiniKeyboard.java | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java index 2d6766f2d..44f9f195c 100644 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java @@ -18,13 +18,22 @@ package com.android.inputmethod.keyboard; import android.content.Context; -import java.util.List; - public class MiniKeyboard extends Keyboard { private int mDefaultKeyCoordX; public MiniKeyboard(Context context, int xmlLayoutResId, Keyboard parentKeyboard) { - super(context, xmlLayoutResId, null, parentKeyboard.getMinWidth()); + super(context, xmlLayoutResId, parentKeyboard.mId.cloneAsMiniKeyboard(), + parentKeyboard.getMinWidth()); + // HACK: Current mini keyboard design totally relies on the 9-patch padding about horizontal + // and vertical key spacing. To keep the visual of mini keyboard as is, these hacks are + // needed to keep having the same horizontal and vertical key spacing. + setHorizontalGap(0); + setVerticalGap(parentKeyboard.getVerticalGap() / 2); + + // TODO: When we have correctly padded key background 9-patch drawables for mini keyboard, + // revert the above hacks and uncomment the following lines. + //setHorizontalGap(parentKeyboard.getHorizontalGap()); + //setVerticalGap(parentKeyboard.getVerticalGap()); } public void setDefaultCoordX(int pos) { @@ -34,19 +43,4 @@ public class MiniKeyboard extends Keyboard { public int getDefaultCoordX() { return mDefaultKeyCoordX; } - - public boolean isOneRowKeyboard() { - final List<Key> keys = getKeys(); - if (keys.size() == 0) return false; - final int edgeFlags = keys.get(0).mEdgeFlags; - // HACK: The first key of mini keyboard which was inflated from xml and has multiple rows, - // does not have both top and bottom edge flags on at the same time. On the other hand, - // the first key of mini keyboard that was created with popupCharacters must have both top - // and bottom edge flags on. - // When you want to use one row mini-keyboard from xml file, make sure that the row has - // both top and bottom edge flags set. - return (edgeFlags & Keyboard.EDGE_TOP) != 0 - && (edgeFlags & Keyboard.EDGE_BOTTOM) != 0; - - } } |
