diff options
author | 2012-03-07 15:30:16 +0900 | |
---|---|---|
committer | 2012-03-07 20:33:17 +0900 | |
commit | c8b0e5797e20d3fa25d319a9709aabc9149f8ff9 (patch) | |
tree | 9f0beb5472241cec7df7bd8e9aeb71709127af18 /java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java | |
parent | 65fe7f7994af97233f0b8b53f63bc89825d4c058 (diff) | |
download | latinime-c8b0e5797e20d3fa25d319a9709aabc9149f8ff9.tar.gz latinime-c8b0e5797e20d3fa25d319a9709aabc9149f8ff9.tar.xz latinime-c8b0e5797e20d3fa25d319a9709aabc9149f8ff9.zip |
Dynamically determine key preview backing view height
Bug: 6023947
Change-Id: I53a5c0eb99100a0dfe3e025808f5dc55747d1287
Diffstat (limited to 'java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java index d3362940f..075fb68ee 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java @@ -137,7 +137,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; @@ -225,12 +226,34 @@ 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); mHintToSaveView = (TextView)inflater.inflate(R.layout.suggestion_word, null); } + 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); @@ -645,6 +668,9 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, mParams.layout(mSuggestedWords, mSuggestionsStrip, this, getWidth()); } + public int setMoreSuggestionsHeight(int remainingHeight) { + return mParams.setMoreSuggestionsHeight(remainingHeight); + } public boolean isShowingAddToDictionaryHint() { return mSuggestionsStrip.getChildCount() > 0 @@ -735,7 +761,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder; builder.layout(mSuggestedWords, 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); |