OLD | NEW |
(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 |
| 9 import org.chromium.base.annotations.CalledByNative; |
| 10 import org.chromium.chrome.browser.ResourceId; |
| 11 |
| 12 import java.util.ArrayList; |
| 13 import java.util.List; |
| 14 |
| 15 /** |
| 16 * An infobar for assisted credit card filling. |
| 17 */ |
| 18 public class AutofillCreditCardFillingInfoBar extends ConfirmInfoBar { |
| 19 private final List<CardDetail> mCardDetails = new ArrayList<>(); |
| 20 |
| 21 /** |
| 22 * Creates a new instance of the infobar. |
| 23 * |
| 24 * @param nativeAutofillCreditCardFillingInfoBar The pointer to the native o
bject for callbacks. |
| 25 * @param enumeratedIconId ID corresponding to the icon that will be shown f
or the InfoBar. |
| 26 * The ID must have been mapped using the ResourceMa
pper class before |
| 27 * passing it to this function. |
| 28 * @param iconBitmap Bitmap to use if there is no equivalent Java resource f
or enumeratedIconId. |
| 29 * @param message Message to display to the user indicating what the InfoBar
is for. |
| 30 * @param buttonOk String to display on the OK button. |
| 31 * @param buttonCancel String to display on the Cancel button. |
| 32 */ |
| 33 private AutofillCreditCardFillingInfoBar(long nativeAutofillCreditCardFillin
gInfoBar, |
| 34 int enumeratedIconId, Bitmap iconBitmap, String message, String butt
onOk, |
| 35 String buttonCancel) { |
| 36 super(ResourceId.mapToDrawableId(enumeratedIconId), iconBitmap, message,
null, buttonOk, |
| 37 buttonCancel); |
| 38 } |
| 39 |
| 40 /** |
| 41 * Creates an infobar for assisted credit card filling. |
| 42 * |
| 43 * @param nativeAutofillCreditCardFillingInfoBar The pointer to the native o
bject for callbacks. |
| 44 * @param enumeratedIconId ID corresponding to the icon that will be shown f
or the InfoBar. |
| 45 * The ID must have been mapped using the ResourceMa
pper class before |
| 46 * passing it to this function. |
| 47 * @param iconBitmap Bitmap to use if there is no equivalent Java resource f
or enumeratedIconId. |
| 48 * @param message Message to display to the user indicating what the InfoBar
is for. |
| 49 * @param buttonOk String to display on the OK button. |
| 50 * @param buttonCancel String to display on the Cancel button. |
| 51 * @return A new instance of the infobar. |
| 52 */ |
| 53 @CalledByNative |
| 54 private static AutofillCreditCardFillingInfoBar create( |
| 55 long nativeAutofillCreditCardFillingInfoBar, int enumeratedIconId, B
itmap iconBitmap, |
| 56 String message, String buttonOk, String buttonCancel) { |
| 57 return new AutofillCreditCardFillingInfoBar(nativeAutofillCreditCardFill
ingInfoBar, |
| 58 enumeratedIconId, iconBitmap, message, buttonOk, buttonCancel); |
| 59 } |
| 60 |
| 61 /** |
| 62 * Adds information to the infobar about the credit card that will be propos
ed for the assist. |
| 63 * |
| 64 * @param enumeratedIconId ID corresponding to the icon that will be shown f
or this credit card. |
| 65 * The ID must have been mapped using the ResourceMa
pper class before |
| 66 * passing it to this function. |
| 67 * @param label The credit card label, for example "***1234". |
| 68 * @param subLabel The credit card sub-label, for example "Exp: 06/17". |
| 69 */ |
| 70 @CalledByNative |
| 71 private void addDetail(int enumeratedIconId, String label, String subLabel)
{ |
| 72 mCardDetails.add(new CardDetail(enumeratedIconId, label, subLabel)); |
| 73 } |
| 74 |
| 75 @Override |
| 76 public void createContent(InfoBarLayout layout) { |
| 77 super.createContent(layout); |
| 78 InfoBarControlLayout control = layout.addControlLayout(); |
| 79 for (int i = 0; i < mCardDetails.size(); i++) { |
| 80 CardDetail detail = mCardDetails.get(i); |
| 81 control.addIcon(detail.issuerIconDrawableId, 0, detail.label, detail
.subLabel); |
| 82 } |
| 83 } |
| 84 } |
OLD | NEW |