Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5164)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java

Issue 16994006: [Android] Change the AutofillPopup UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding a hack to prevent the popup from expanding on top of the keyboard Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java
index c1b5d9a965a75ac31c72084c30c9ec12cdb556e9..35caf5bcc31358ed65ad159ae6d4020d55eef939 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java
@@ -35,7 +35,7 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem
private static final int ITEM_ID_PASSWORD_ENTRY = -2;
private static final int ITEM_ID_DATA_LIST_ENTRY = -6;
- private static final int TEXT_PADDING_DP = 40;
+ private static final int TEXT_PADDING_DP = 25;
private final AutofillPopupDelegate mAutofillCallback;
private final Context mContext;
@@ -45,8 +45,8 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem
private float mAnchorHeight;
private float mAnchorX;
private float mAnchorY;
- private Paint mNameViewPaint;
private Paint mLabelViewPaint;
+ private Paint mSublabelViewPaint;
private OnLayoutChangeListener mLayoutChangeListener;
/**
@@ -73,7 +73,7 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem
*/
public AutofillPopup(Context context, ViewAndroidDelegate viewAndroidDelegate,
AutofillPopupDelegate autofillCallback) {
- super(context);
+ super(context, null, 0, R.style.AutofillPopupWindow);
mContext = context;
mViewAndroidDelegate = viewAndroidDelegate ;
mAutofillCallback = autofillCallback;
@@ -96,6 +96,13 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem
setAnchorView(mAnchorView);
}
+ @Override
+ public void show() {
+ // An ugly hack to keep the popup from expanding on top of the keyboard.
+ setInputMethodMode(INPUT_METHOD_NEEDED);
+ super.show();
+ }
+
/**
* Sets the location and the size of the anchor view that the AutofillPopup will use to attach
* itself.
@@ -159,34 +166,36 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem
* @return The popup window width in DIP.
*/
private float getDesiredWidth(AutofillSuggestion[] data) {
- if (mNameViewPaint == null || mLabelViewPaint == null) {
+ if (mLabelViewPaint == null || mSublabelViewPaint == null) {
LayoutInflater inflater =
(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.autofill_text, null);
- TextView nameView = (TextView) layout.findViewById(R.id.autofill_name);
- mNameViewPaint = nameView.getPaint();
TextView labelView = (TextView) layout.findViewById(R.id.autofill_label);
mLabelViewPaint = labelView.getPaint();
+ TextView sublabelView = (TextView) layout.findViewById(R.id.autofill_sublabel);
+ mSublabelViewPaint = sublabelView.getPaint();
}
float maxTextWidth = 0;
Rect bounds = new Rect();
for (int i = 0; i < data.length; ++i) {
bounds.setEmpty();
- String name = data[i].mName;
- float width = 0;
- if (name.length() > 0) {
- mNameViewPaint.getTextBounds(name, 0, name.length(), bounds);
- }
- width += bounds.width();
-
- bounds.setEmpty();
String label = data[i].mLabel;
+ float labelWidth = 0;
Ted C 2013/06/14 20:57:53 this isn't used until after the conditional
aurimas (slooooooooow) 2013/06/14 21:09:09 Done.
if (label.length() > 0) {
mLabelViewPaint.getTextBounds(label, 0, label.length(), bounds);
}
- width += bounds.width();
- maxTextWidth = Math.max(width, maxTextWidth);
+ labelWidth = bounds.width();
+
+ bounds.setEmpty();
+ String sublabel = data[i].mSublabel;
+ float sublabelWidth = 0;
Ted C 2013/06/14 20:57:53 same here
aurimas (slooooooooow) 2013/06/14 21:09:09 Done.
+ if (sublabel.length() > 0) {
Ted C 2013/06/14 20:57:53 TextUtils isEmpty?
aurimas (slooooooooow) 2013/06/14 21:09:09 Done.
+ mSublabelViewPaint.getTextBounds(sublabel, 0, sublabel.length(), bounds);
+ }
+ sublabelWidth = bounds.width();
+ float localMax = Math.max(labelWidth, sublabelWidth);
+ maxTextWidth = Math.max(maxTextWidth, localMax);
}
// Scale it down to make it unscaled by screen density.
maxTextWidth = maxTextWidth / mContext.getResources().getDisplayMetrics().density;

Powered by Google App Engine
This is Rietveld 408576698