diff options
author | 2012-03-29 17:14:26 -0700 | |
---|---|---|
committer | 2012-03-29 17:14:26 -0700 | |
commit | 393345160c0d1bfe8bb64a3ad9e353589710ffc4 (patch) | |
tree | 2b59010b194162fea31efd335082ea46003fb635 /java/src/com/android/inputmethod/latin/SuggestionsView.java | |
parent | 2f2007d6b7d90258a9d099dfa0d93632ae236ead (diff) | |
parent | 710c69fc82c172f802d2e06276b61e7e077ae094 (diff) | |
download | latinime-393345160c0d1bfe8bb64a3ad9e353589710ffc4.tar.gz latinime-393345160c0d1bfe8bb64a3ad9e353589710ffc4.tar.xz latinime-393345160c0d1bfe8bb64a3ad9e353589710ffc4.zip |
am 710c69fc: Dynamically determine key preview backing view height
* commit '710c69fc82c172f802d2e06276b61e7e077ae094':
Dynamically determine key preview backing view height
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestionsView.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/SuggestionsView.java | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java index c25ecb382..0986a0b27 100644 --- a/java/src/com/android/inputmethod/latin/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java @@ -141,7 +141,8 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, public final int mDividerWidth; public final int mSuggestionsStripHeight; public final int mSuggestionsCountInStrip; - public final int mMaxMoreSuggestionsRow; + public final int mMoreSuggestionsRowHeight; + private int mMaxMoreSuggestionsRow; public final float mMinMoreSuggestionsWidth; public final int mMoreSuggestionsBottomGap; @@ -224,6 +225,8 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, mCenterSuggestionIndex = mSuggestionsCountInStrip / 2; mMoreSuggestionsBottomGap = res.getDimensionPixelOffset( R.dimen.more_suggestions_bottom_gap); + mMoreSuggestionsRowHeight = res.getDimensionPixelSize( + R.dimen.more_suggestions_row_height); final LayoutInflater inflater = LayoutInflater.from(context); mWordToSaveView = (TextView)inflater.inflate(R.layout.suggestion_word, null); @@ -231,6 +234,26 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, mHintToSaveText = context.getText(R.string.hint_add_to_dictionary); } + public int getMaxMoreSuggestionsRow() { + return mMaxMoreSuggestionsRow; + } + + private int getMoreSuggestionsHeight() { + return mMaxMoreSuggestionsRow * mMoreSuggestionsRowHeight + mMoreSuggestionsBottomGap; + } + + public int setMoreSuggestionsHeight(int remainingHeight) { + final int currentHeight = getMoreSuggestionsHeight(); + if (currentHeight <= remainingHeight) { + return currentHeight; + } + + mMaxMoreSuggestionsRow = (remainingHeight - mMoreSuggestionsBottomGap) + / mMoreSuggestionsRowHeight; + final int newHeight = getMoreSuggestionsHeight(); + return newHeight; + } + private static Drawable getMoreSuggestionsHint(Resources res, float textSize, int color) { final Paint paint = new Paint(); paint.setAntiAlias(true); @@ -642,6 +665,10 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, } } + public int setMoreSuggestionsHeight(int remainingHeight) { + return mParams.setMoreSuggestionsHeight(remainingHeight); + } + public boolean isShowingAddToDictionaryHint() { return mSuggestionsStrip.getChildCount() > 0 && mSuggestionsStrip.getChildAt(0) == mParams.mWordToSaveView; @@ -757,7 +784,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder; builder.layout(mSuggestions, params.mSuggestionsCountInStrip, maxWidth, (int)(maxWidth * params.mMinMoreSuggestionsWidth), - params.mMaxMoreSuggestionsRow); + params.getMaxMoreSuggestionsRow()); mMoreSuggestionsView.setKeyboard(builder.build()); container.measure( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); |