OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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.ui.autofill; |
| 6 |
| 7 import android.app.AlertDialog; |
| 8 import android.content.Context; |
| 9 import android.content.DialogInterface; |
| 10 import android.view.LayoutInflater; |
| 11 import android.view.View; |
| 12 import android.widget.EditText; |
| 13 |
| 14 import org.chromium.ui.R; |
| 15 |
| 16 /** |
| 17 * A prompt that bugs users to enter their CVC when unmasking a Wallet instrumen
t (credit card). |
| 18 */ |
| 19 public class CardUnmaskPrompt implements DialogInterface.OnClickListener, |
| 20 DialogInterface.OnDismissListener { |
| 21 private CardUnmaskPromptDelegate mDelegate; |
| 22 private int mClickedButton; |
| 23 private AlertDialog mDialog; |
| 24 |
| 25 /** |
| 26 * An interface to handle the interaction with an CardUnmaskPrompt object. |
| 27 */ |
| 28 public interface CardUnmaskPromptDelegate { |
| 29 /** |
| 30 * Called when the dialog has been dismissed. |
| 31 * @param userResponse The value the user entered (a CVC), or an empty s
tring if the |
| 32 * user canceled. |
| 33 */ |
| 34 void dismissed(String userResponse); |
| 35 } |
| 36 |
| 37 public CardUnmaskPrompt(Context context, CardUnmaskPromptDelegate delegate)
{ |
| 38 mDelegate = delegate; |
| 39 mClickedButton = DialogInterface.BUTTON_NEGATIVE; |
| 40 |
| 41 LayoutInflater inflater = LayoutInflater.from(context); |
| 42 View v = inflater.inflate(R.layout.autofill_card_unmask_prompt, null); |
| 43 |
| 44 mDialog = new AlertDialog.Builder(context) |
| 45 .setTitle("Unlocking Visa - 1111") |
| 46 .setView(v) |
| 47 .setNegativeButton("Back", this) |
| 48 .setPositiveButton("Rock on", this) |
| 49 .setOnDismissListener(this).create(); |
| 50 } |
| 51 |
| 52 public void show() { |
| 53 mDialog.show(); |
| 54 } |
| 55 |
| 56 @Override |
| 57 public void onClick(DialogInterface dialog, int which) { |
| 58 mClickedButton = which; |
| 59 } |
| 60 |
| 61 @Override |
| 62 public void onDismiss(DialogInterface dialog) { |
| 63 if (mClickedButton == DialogInterface.BUTTON_POSITIVE) { |
| 64 String response = ((EditText) mDialog.findViewById(R.id.card_unmask_
input)) |
| 65 .getText().toString(); |
| 66 mDelegate.dismissed(response); |
| 67 } else { |
| 68 mDelegate.dismissed(""); |
| 69 } |
| 70 } |
| 71 } |
OLD | NEW |