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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java

Issue 2541693004: Add Information Tooltip for Public Suffix List Matches (Closed)
Patch Set: Addressed comments. Created 4 years 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/password_manager/AccountChooserDialog.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java
index 4c41262fb1945784f7eb33a5ab13b333c6e4846c..d1b02c941625a04b55b6f6117f185f25c4817311 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java
@@ -7,21 +7,27 @@ package org.chromium.chrome.browser.password_manager;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.support.v7.app.AlertDialog;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
+import android.util.TypedValue;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
+import android.widget.PopupWindow;
import android.widget.TextView;
+import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.signin.AccountManagementFragment;
@@ -138,6 +144,65 @@ public class AccountChooserDialog
secondaryNameView.setVisibility(View.VISIBLE);
}
+ final String originUrl = credential.getOriginUrl();
+ if (!originUrl.isEmpty()) {
+ ImageView pslInfoIconView =
+ (ImageView) convertView.findViewById(R.id.psl_info_icon);
+ pslInfoIconView.setImageResource(R.drawable.btn_info);
gone 2016/12/08 01:32:44 Set the ImageResource in the XML file directly.
jdoerrie 2016/12/13 17:24:48 Done.
+ pslInfoIconView.setClickable(true);
gone 2016/12/08 01:32:44 If you use the ImageButton, this should be automat
jdoerrie 2016/12/13 17:24:48 Acknowledged.
+ pslInfoIconView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ final ImageView iconView = (ImageView) view;
gone 2016/12/08 01:32:44 Pull this all out into another function called pre
jdoerrie 2016/12/13 17:24:48 Done.
+ Context context = iconView.getContext();
+ Resources resources = context.getResources();
+ iconView.setBackground(ApiCompatibilityUtils.getDrawable(
+ resources, R.drawable.psl_info_icon_background));
+
+ TextView textView = new TextView(context);
gone 2016/12/08 01:32:44 1) Can you apply the background for the tooltip to
jdoerrie 2016/12/13 17:24:48 Done.
+ textView.setText(originUrl);
+ textView.setTextColor(Color.WHITE);
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(
+ R.dimen.psl_info_tooltip_text_size));
+ int horizontalPadding = resources.getDimensionPixelSize(
+ R.dimen.psl_info_tooltip_horizontal_padding);
+ textView.setPadding(horizontalPadding, 0, horizontalPadding, 0);
+ textView.setHeight(resources.getDimensionPixelSize(
+ R.dimen.psl_info_tooltip_height));
gone 2016/12/08 01:32:44 Don't set the height of the TextView directly. Pe
jdoerrie 2016/12/13 17:24:48 I would like to avoid this, however the official M
gone 2016/12/13 23:14:29 A fixed-height on text is generally unenforceable;
jdoerrie 2016/12/14 16:04:01 We could specify padding in the tooltip background
gone 2016/12/14 18:20:42 Setting padding like that is totally arbitrary and
jdoerrie 2016/12/15 13:27:18 Done.
+ textView.setGravity(Gravity.CENTER);
+
+ PopupWindow tooltip = new PopupWindow(context);
+ tooltip.setContentView(textView);
+ tooltip.setOutsideTouchable(true);
+ tooltip.setBackgroundDrawable(ApiCompatibilityUtils.getDrawable(
+ resources, R.drawable.psl_info_tooltip_background));
+ tooltip.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ @Override
+ public void onDismiss() {
+ iconView.setBackgroundResource(0);
+ }
+ });
+
+ // Measure size of textView for correct offsets.
+ textView.measure(0, 0);
gone 2016/12/08 01:32:44 These should be MeasureSpecs instead of straight i
jdoerrie 2016/12/15 13:27:18 Acknowledged.
+
+ // Shift tooltip to the left by required amount, handle RTL correctly.
+ int xOffset = ApiCompatibilityUtils.isLayoutRtl(iconView)
+ ? -iconView.getWidth()
+ : -(textView.getMeasuredWidth() - iconView.getWidth());
+
+ // Shift tooltip up by required amount.
gone 2016/12/08 01:32:44 What happens on small phones and long addresses?
jdoerrie 2016/12/13 17:24:48 Done.
+ int tooltip_margin = resources.getDimensionPixelSize(
+ R.dimen.psl_info_tooltip_margin);
+ int yOffset = -(textView.getMeasuredHeight() + iconView.getHeight()
+ + tooltip_margin);
+
+ tooltip.showAsDropDown(iconView, xOffset, yOffset);
+ textView.announceForAccessibility(textView.getText());
+ }
+ });
+ }
+
return convertView;
}
};

Powered by Google App Engine
This is Rietveld 408576698