diff options
author | 2013-07-19 11:31:52 +0900 | |
---|---|---|
committer | 2013-07-19 11:43:50 +0900 | |
commit | b0e76724edcde33dbfa17b56c3f5858705cd06ee (patch) | |
tree | 34aa5ef1878d1013aade23d14d3fd3cfb98bc586 /java/src/com/android/inputmethod | |
parent | 03a76a07e2454271e67cfe1a6b563e7e32087a06 (diff) | |
download | latinime-b0e76724edcde33dbfa17b56c3f5858705cd06ee.tar.gz latinime-b0e76724edcde33dbfa17b56c3f5858705cd06ee.tar.xz latinime-b0e76724edcde33dbfa17b56c3f5858705cd06ee.zip |
Fix IllegalArgumentException in MoreKeysKeyboard
It seems that MainKeyboardView.getMeasuredWidth() returns weird
value. Using KeyboardId.mWidth as main keyboard width may resolve the
issue.
Bug: 9684622
Change-Id: I975bfb934b8d2448e72555a3ccae0123341186b9
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java index d29e6382c..3fd29dcfd 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java @@ -17,7 +17,6 @@ package com.android.inputmethod.keyboard; import android.content.Context; -import android.content.res.Resources; import android.graphics.Paint; import android.graphics.drawable.Drawable; @@ -76,10 +75,8 @@ public final class MoreKeysKeyboard extends Keyboard { final boolean isFixedColumnOrder, final int dividerWidth) { mIsFixedOrder = isFixedColumnOrder; if (parentKeyboardWidth / keyWidth < Math.min(numKeys, maxColumns)) { - throw new IllegalArgumentException( - "Keyboard is too small to hold more keys keyboard: " - + parentKeyboardWidth + " " + keyWidth + " " - + numKeys + " " + maxColumns); + throw new IllegalArgumentException("Keyboard is too small to hold more keys: " + + parentKeyboardWidth + " " + keyWidth + " " + numKeys + " " + maxColumns); } mDefaultKeyWidth = keyWidth; mDefaultRowHeight = rowHeight; @@ -299,8 +296,12 @@ public final class MoreKeysKeyboard extends Keyboard { width = keyPreviewDrawParams.mPreviewVisibleWidth; height = keyPreviewDrawParams.mPreviewVisibleHeight + mParams.mVerticalGap; } else { - width = getMaxKeyWidth(parentKeyboardView, parentKey, mParams.mDefaultKeyWidth, - context.getResources()); + final float padding = context.getResources().getDimension( + R.dimen.more_keys_keyboard_key_horizontal_padding) + + (parentKey.hasLabelsInMoreKeys() + ? mParams.mDefaultKeyWidth * LABEL_PADDING_RATIO : 0.0f); + width = getMaxKeyWidth(parentKey, mParams.mDefaultKeyWidth, padding, + parentKeyboardView.newLabelPaint(parentKey)); height = parentKeyboard.mMostCommonKeyHeight; } final int dividerWidth; @@ -313,16 +314,12 @@ public final class MoreKeysKeyboard extends Keyboard { } mParams.setParameters(parentKey.mMoreKeys.length, parentKey.getMoreKeysColumn(), width, height, parentKey.mX + parentKey.mWidth / 2, - parentKeyboardView.getMeasuredWidth(), parentKey.isFixedColumnOrderMoreKeys(), + parentKeyboard.mId.mWidth, parentKey.isFixedColumnOrderMoreKeys(), dividerWidth); } - private static int getMaxKeyWidth(final KeyboardView view, final Key parentKey, - final int minKeyWidth, final Resources res) { - final float padding = - res.getDimension(R.dimen.more_keys_keyboard_key_horizontal_padding) - + (parentKey.hasLabelsInMoreKeys() ? minKeyWidth * LABEL_PADDING_RATIO : 0.0f); - final Paint paint = view.newLabelPaint(parentKey); + private static int getMaxKeyWidth(final Key parentKey, final int minKeyWidth, + final float padding, final Paint paint) { int maxWidth = minKeyWidth; for (final MoreKeySpec spec : parentKey.mMoreKeys) { final String label = spec.mLabel; |