From 7f0befe1f0e346ec6468f229f337eda32e19f6d8 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 23 Nov 2010 23:59:56 -0800 Subject: Update tablet keyboard layout to the latest design This change introduces shiftedIcon attribute for Key which specifies icon to draw the shift key while the key is in shifted state. This change also intriduces new configurable dimension value key_label_horizontal_alignment_padding which represents horizontal padding for left or right alignment of key label. Bug: 3216592 Bug: 3201839 Change-Id: I3aa7392227ce573c404517678e6340a8d1fcb328 --- java/src/com/android/inputmethod/latin/BaseKeyboard.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'java/src/com/android/inputmethod/latin/BaseKeyboard.java') diff --git a/java/src/com/android/inputmethod/latin/BaseKeyboard.java b/java/src/com/android/inputmethod/latin/BaseKeyboard.java index 485cc3153..00ed453c4 100644 --- a/java/src/com/android/inputmethod/latin/BaseKeyboard.java +++ b/java/src/com/android/inputmethod/latin/BaseKeyboard.java @@ -28,11 +28,14 @@ import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; import android.text.TextUtils; +import android.util.Log; import android.util.Xml; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard @@ -86,6 +89,9 @@ public class BaseKeyboard { /** List of shift keys in this keyboard */ private final List mShiftKeys = new ArrayList(); + /** List of shift keys and its shifted state icon */ + private final HashMap mShiftedIcons = new HashMap(); + /** Total height of the keyboard, including the padding and keys */ private int mTotalHeight; @@ -340,6 +346,10 @@ public class BaseKeyboard { manualTemporaryUpperCaseCode = style.getInt(a, R.styleable.BaseKeyboard_Key_manualTemporaryUpperCaseCode, 0); text = style.getText(a, R.styleable.BaseKeyboard_Key_keyOutputText); + final Drawable shiftedIcon = style.getDrawable(a, + R.styleable.BaseKeyboard_Key_shiftedIcon); + if (shiftedIcon != null) + keyboard.getShiftedIcons().put(this, shiftedIcon); if (codes == null && !TextUtils.isEmpty(label)) { codes = new int[] { label.charAt(0) }; @@ -622,6 +632,10 @@ public class BaseKeyboard { return mShiftKeys; } + public Map getShiftedIcons() { + return mShiftedIcons; + } + private void computeNearestNeighbors() { // Round-up so we don't have any pixels outside the grid mCellWidth = (getMinWidth() + GRID_WIDTH - 1) / GRID_WIDTH; @@ -686,8 +700,10 @@ public class BaseKeyboard { mTotalWidth = parser.getMaxRowWidth(); mTotalHeight = parser.getTotalHeight(); } catch (XmlPullParserException e) { + Log.w(TAG, "keyboard XML parse error: " + e); throw new IllegalArgumentException(e); } catch (IOException e) { + Log.w(TAG, "keyboard XML parse error: " + e); throw new RuntimeException(e); } } -- cgit v1.2.3-83-g751a