aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestionsView.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-03-07 15:30:16 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-03-21 11:21:34 +0900
commit710c69fc82c172f802d2e06276b61e7e077ae094 (patch)
tree2b59010b194162fea31efd335082ea46003fb635 /java/src/com/android/inputmethod/latin/SuggestionsView.java
parentc85dde47e89f19aad3a29de08c11ae97f79be618 (diff)
downloadlatinime-710c69fc82c172f802d2e06276b61e7e077ae094.tar.gz
latinime-710c69fc82c172f802d2e06276b61e7e077ae094.tar.xz
latinime-710c69fc82c172f802d2e06276b61e7e077ae094.zip
Dynamically determine key preview backing view height
Bug: 6023947 Change-Id: I53a5c0eb99100a0dfe3e025808f5dc55747d1287
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestionsView.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestionsView.java31
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);