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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillCCInfoBar.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: Addressed Justin's nits. Created 4 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.infobar;
6
7 import android.graphics.Bitmap;
8 import android.text.SpannableString;
9 import android.text.Spanned;
10 import android.text.style.ClickableSpan;
11 import android.view.View;
12
13 import java.util.LinkedList;
14 import java.util.List;
15
16 /**
17 * An infobar for saving credit card information.
18 */
19 public class AutofillCCInfoBar extends ConfirmInfoBar {
20 /**
21 * Detailed card information to show in the infobar.
22 */
23 public static class CardDetail {
24 /**
25 * The identifier of the drawable of the card issuer icon.
26 */
27 public int issuerIconDrawableId;
28
29 /**
30 * The label for the card.
31 */
32 public String label;
33
34 /**
35 * The sub-label for the card.
36 */
37 public String subLabel;
38 }
39
40 /**
41 * Legal message line with links to show in the infobar.
42 */
43 public static class LegalMessageLine {
44 /**
45 * A link in the legal message line.
46 */
47 public static class Link {
48 /**
49 * The starting inclusive index of the link position in the text.
50 */
51 public int start;
52
53 /**
54 * The ending inclusive index of the link position in the text.
55 */
56 public int end;
57
58 /**
59 * The URL of the link.
60 */
61 public String url;
62 }
63
64 /**
65 * The plain text legal message line.
66 */
67 public String text;
68
69 /**
70 * A collection of links in the legal message line.
71 */
72 public LinkedList<Link> links;
73 }
74
75 /**
76 * An interface to be implemented by objects that wish to be notified of cli cks on the links in
77 * the legal message text.
78 */
79 public interface LegalMessageLinkClickDelegate {
80 /**
81 * Called when a link in the legal message text was clicked.
82 * @param url The URL of the clicked link.
83 */
84 public void onLegalMessageLinkClicked(String url);
85 }
86
87 private final List<CardDetail> mCardDetails;
88 private final List<LegalMessageLine> mLegalMessageLines;
89 private final LegalMessageLinkClickDelegate mDelegate;
90
91 /**
92 * Creates an infobar for saving a credit card.
93 * @param iconDrawableId Resource ID for the icon that will be shown for the InfoBar.
94 * @param iconBitmap Bitmap to use if there is no equivalent Java resource f or enumeratedIconId.
95 * @param message Message to display to the user indicating what the InfoBar is for.
96 * @param linkText Link text to display in addition to the message.
97 * @param details Card details to show in the Infobar.
98 * @param legalMessageLines Legal message lines to show in the InfoBar.
99 * @param primaryButtonText String to display on the primary button.
100 * @param secondaryButtonText String to display on the secondary button.
101 * @param delegate The delegate to be notified of clicks on the links in the legal message text.
102 */
103 public AutofillCCInfoBar(int iconDrawableId, Bitmap iconBitmap, String messa ge, String linkText,
104 List<CardDetail> details, List<LegalMessageLine> legalMessageLines,
105 String primaryButtonText, String secondaryButtonText,
106 LegalMessageLinkClickDelegate delegate) {
107 super(null, iconDrawableId, iconBitmap, message, linkText, primaryButton Text,
108 secondaryButtonText);
109 mCardDetails = details;
110 mLegalMessageLines = legalMessageLines;
111 mDelegate = delegate;
112 }
113
114 /**
115 * @see org.chromium.chrome.browser.infobar.InfoBarView#intteContent(InfoBar Layout layout)
116 */
117 @Override
118 public void createContent(InfoBarLayout layout) {
119 super.createContent(layout);
120 InfoBarControlLayout control = layout.addControlLayout();
121 for (CardDetail detail : mCardDetails) {
122 control.addIcon(detail.issuerIconDrawableId, detail.label, detail.su bLabel);
123 }
124
125 for (LegalMessageLine line : mLegalMessageLines) {
126 SpannableString text = new SpannableString(line.text);
127 for (final LegalMessageLine.Link link : line.links) {
128 text.setSpan(new ClickableSpan() {
129 @Override
130 public void onClick(View view) {
131 mDelegate.onLegalMessageLinkClicked(link.url);
132 }
133 }, link.start, link.end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
134 }
135 control.addDescription(text);
136 }
137 }
138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698