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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java

Issue 1540423004: Add card details and legal message to Android save credit card infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial draft Created 5 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/infobar/InfoBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java
index 907c6eab678b135a4d3d8ad1ef58b22bfebbd316..bcdf24a3c965628231db080f414f3e28ab304fb1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java
@@ -6,6 +6,9 @@ package org.chromium.chrome.browser.infobar;
import android.content.Context;
import android.graphics.Bitmap;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;
@@ -13,6 +16,9 @@ import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R;
+import java.util.LinkedList;
+import java.util.List;
+
/**
* The base class for all InfoBar classes.
* Note that infobars expire by default when a new navigation occurs.
@@ -24,6 +30,8 @@ public abstract class InfoBar implements InfoBarView {
private final int mIconDrawableId;
private final Bitmap mIconBitmap;
private final CharSequence mMessage;
+ private List<Detail> mDetails;
+ private List<Description> mDescriptions;
private InfoBarListeners.Dismiss mListener;
private InfoBarContainer mContainer;
@@ -46,6 +54,61 @@ public abstract class InfoBar implements InfoBarView {
}
/**
+ * Detailed information to show in the infobar.
+ */
+ public static class Detail {
+ /**
+ * The identifier of the drawable for the detail section of the infobar.
+ */
+ public int iconDrawableId;
+
+ /**
+ * The label for the detail section of the infobar.
+ */
+ public String label;
+
+ /**
+ * The sub-label for the detail section of the infobar.
+ */
+ public String subLabel;
+ };
+
+ /**
+ * Description text with links to show in the infobar.
+ */
+ public static class Description {
+ /**
+ * A link in the description text.
+ */
+ public static class Link {
+ /**
+ * The starting inclusive index of the link position in the text.
+ */
+ public int start;
+
+ /**
+ * The ending exclusive index of the link position in the text.
+ */
+ public int end;
+
+ /**
+ * The URL of the link.
+ */
+ public String url;
+ }
+
+ /**
+ * The plain text description for the infobar.
+ */
+ public String text;
+
+ /**
+ * A collection of links in the description text.
+ */
+ public LinkedList<Link> links;
+ };
+
+ /**
* @param listener Listens to when buttons have been clicked on the InfoBar.
* @param iconDrawableId ID of the resource to use for the Icon. If 0, no icon will be shown.
* @param message The message to show in the infobar.
@@ -218,6 +281,27 @@ public abstract class InfoBar implements InfoBarView {
@Override
public void createContent(InfoBarLayout layout) {
+ if (mDetails != null) {
gone 2015/12/29 23:46:13 You should probably use only one InfoBarControlLay
please use gerrit instead 2016/01/07 01:39:25 Done.
+ for (Detail detail : mDetails) {
+ layout.addControlLayout().addIcon(detail.iconDrawableId, detail.label,
+ detail.subLabel);
+ }
+ }
+
+ if (mDescriptions != null) {
+ for (Description description : mDescriptions) {
+ SpannableString text = new SpannableString(description.text);
+ for (Description.Link link : description.links) {
+ text.setSpan(new ClickableSpan() {
+ @Override
+ public void onClick(View view) {
+ // Go to link.url.
+ }
+ }, link.start, link.end, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ }
+ layout.addControlLayout().addDescription(text);
+ }
+ }
}
@VisibleForTesting
@@ -230,6 +314,14 @@ public abstract class InfoBar implements InfoBarView {
mListener = listener;
}
+ public void setDetails(List<Detail> details) {
+ mDetails = details;
+ }
+
+ public void setDescriptions(List<Description> descriptions) {
+ mDescriptions = descriptions;
+ }
+
private native void nativeOnLinkClicked(long nativeInfoBarAndroid);
private native void nativeOnButtonClicked(long nativeInfoBarAndroid, int action);
private native void nativeOnCloseButtonClicked(long nativeInfoBarAndroid);

Powered by Google App Engine
This is Rietveld 408576698