From bdc8b9e42b90e1fdf8e15d7ee5c0d319934fec0a Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 16 Oct 2012 13:26:45 -0700 Subject: [PATCH] Fix more suggestions text width calculation Bug: 7345983 Change-Id: Ic1554db98e7aaf032eb90a98c0c37c7c789461b5 --- java/src/com/android/inputmethod/keyboard/KeyboardView.java | 3 ++- .../inputmethod/latin/suggestions/MoreSuggestions.java | 4 +++- .../inputmethod/latin/suggestions/MoreSuggestionsView.java | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index b39f2bad3..472f74b12 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -105,7 +105,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { private static final String TAG = KeyboardView.class.getSimpleName(); // XML attributes - private final KeyVisualAttributes mKeyVisualAttributes; + protected final KeyVisualAttributes mKeyVisualAttributes; private final int mKeyLabelHorizontalPadding; private final float mKeyHintLetterPadding; private final float mKeyPopupHintLetterPadding; @@ -733,6 +733,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { return width; } + // TODO: Remove this method. public float getLabelWidth(final String label, final Paint paint) { paint.getTextBounds(label, 0, label.length(), mTextBounds); return mTextBounds.width(); diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java index e9bf0fac4..4e9fd1968 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java @@ -51,10 +51,11 @@ public final class MoreSuggestions extends Keyboard { super(); } + // TODO: Remove {@link MoreSuggestionsView} argument. public int layout(final SuggestedWords suggestions, final int fromPos, final int maxWidth, final int minWidth, final int maxRow, final MoreSuggestionsView view) { clearKeys(); - final Resources res = view.getContext().getResources(); + final Resources res = view.getResources(); mDivider = res.getDrawable(R.drawable.more_suggestions_divider); mDividerWidth = mDivider.getIntrinsicWidth(); final int padding = (int) res.getDimension( @@ -181,6 +182,7 @@ public final class MoreSuggestions extends Keyboard { load(xmlId, keyboard.mId); mParams.mVerticalGap = mParams.mTopPadding = keyboard.mVerticalGap / 2; + mPaneView.updateKeyboardGeometry(mParams.mDefaultRowHeight); final int count = mParams.layout(suggestions, fromPos, maxWidth, minWidth, maxRow, mPaneView); mFromPos = fromPos; diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java index 9b9a35478..03a2e73d1 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java @@ -105,6 +105,10 @@ public final class MoreSuggestionsView extends KeyboardView implements MoreKeysP } } + public void updateKeyboardGeometry(final int keyHeight) { + mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes); + } + @Override public void setKeyboard(Keyboard keyboard) { super.setKeyboard(keyboard);