summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJin Cao <jinyan@google.com>2014-10-13 13:21:42 -0700
committerJin Cao <jinyan@google.com>2014-10-13 13:21:42 -0700
commitf6ddb7541feb5e415f9750fb403814dbbc9068be (patch)
tree4f4dd44f5a7d00eca2422eef3da4bd9d717f4118
parentfcaf9868ae2b549f1b95465e4e7877482403398d (diff)
downloadandroid_frameworks_opt_chips-f6ddb7541feb5e415f9750fb403814dbbc9068be.tar.gz
android_frameworks_opt_chips-f6ddb7541feb5e415f9750fb403814dbbc9068be.tar.bz2
android_frameworks_opt_chips-f6ddb7541feb5e415f9750fb403814dbbc9068be.zip
Don't rely on action bar height
When computing the scroll offset to scroll the edittext's bottom line into view (to maximize the space for the dropdown), don't rely on the statis status bar + action bar height calculation because action bar's height changes depending on platform version and orientation. Instead, use the scroll view's location in window as the "top" of the visible display frame. b/17824127 Change-Id: I35fd04201a11e5ba47de84eb4a1c5d309e08c203
-rw-r--r--src/com/android/ex/chips/RecipientEditTextView.java24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 400f049..cb0ef51 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -17,7 +17,6 @@
package com.android.ex.chips;
-import android.app.Activity;
import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipDescription;
@@ -63,7 +62,6 @@ import android.text.util.Rfc822Token;
import android.text.util.Rfc822Tokenizer;
import android.util.AttributeSet;
import android.util.Log;
-import android.util.TypedValue;
import android.view.ActionMode;
import android.view.ActionMode.Callback;
import android.view.DragEvent;
@@ -141,7 +139,6 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
private static final int MAX_CHIPS_PARSED = 50;
private static int sSelectedTextColor = -1;
- private static int sVisibleDisplayFrameTop = -1;
// Work variables to avoid re-allocation on every typed character.
private final Rect mRect = new Rect();
@@ -497,24 +494,6 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
}
}
- // sVisibleDisplayFrameTop is computed on a on-demand basis because the view needs to be fully
- // measured and created in order to calculate the visible display frame.
- private int getVisibleDisplayFrameTop() {
- if (sVisibleDisplayFrameTop == -1) {
- final TypedValue tv = new TypedValue();
- final Context context = getContext();
- // Visible top is our visible display (due to status bar) plus the height of action bar.
- if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
- sVisibleDisplayFrameTop = TypedValue.complexToDimensionPixelSize(tv.data,
- getResources().getDisplayMetrics());
- }
- // Compute the status bar height, or rather where our visible display starts
- getWindowVisibleDisplayFrame(mRect);
- sVisibleDisplayFrameTop += mRect.top;
- }
- return sVisibleDisplayFrameTop;
- }
-
@Override
public <T extends ListAdapter & Filterable> void setAdapter(T adapter) {
super.setAdapter(adapter);
@@ -568,7 +547,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
// content.
final int height = getHeight();
final int currentPos = mCoords[1] + height;
- final int desiredPos = getVisibleDisplayFrameTop() + height / getLineCount();
+ mScrollView.getLocationInWindow(mCoords);
+ final int desiredPos = mCoords[1] + height / getLineCount();
if (currentPos > desiredPos) {
mScrollView.scrollBy(0, currentPos - desiredPos);
}