OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.autofill; | 5 package org.chromium.chrome.browser.autofill; |
6 | 6 |
7 import android.app.AlertDialog; | 7 import android.app.AlertDialog; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
10 import android.graphics.ColorFilter; | 10 import android.graphics.ColorFilter; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 mMainContents = (ViewGroup) v.findViewById(R.id.main_contents); | 96 mMainContents = (ViewGroup) v.findViewById(R.id.main_contents); |
97 mVerificationOverlay = v.findViewById(R.id.verification_overlay); | 97 mVerificationOverlay = v.findViewById(R.id.verification_overlay); |
98 mVerificationProgressBar = (ProgressBar) v.findViewById(R.id.verificatio
n_progress_bar); | 98 mVerificationProgressBar = (ProgressBar) v.findViewById(R.id.verificatio
n_progress_bar); |
99 mVerificationView = (TextView) v.findViewById(R.id.verification_message)
; | 99 mVerificationView = (TextView) v.findViewById(R.id.verification_message)
; |
100 ((ImageView) v.findViewById(R.id.cvc_hint_image)).setImageResource(drawa
bleId); | 100 ((ImageView) v.findViewById(R.id.cvc_hint_image)).setImageResource(drawa
bleId); |
101 | 101 |
102 mDialog = new AlertDialog.Builder(context) | 102 mDialog = new AlertDialog.Builder(context) |
103 .setTitle(title) | 103 .setTitle(title) |
104 .setView(v) | 104 .setView(v) |
105 .setNegativeButton(R.string.cancel, null) | 105 .setNegativeButton(R.string.cancel, null) |
106 .setPositiveButton(R.string.card_unmask_confirm_button
, null) | 106 .setPositiveButton(R.string.autofill_card_unmask_confi
rm_button, null) |
107 .create(); | 107 .create(); |
108 mDialog.setOnDismissListener(this); | 108 mDialog.setOnDismissListener(this); |
109 | 109 |
110 mShouldRequestExpirationDate = shouldRequestExpirationDate; | 110 mShouldRequestExpirationDate = shouldRequestExpirationDate; |
111 mThisYear = Calendar.getInstance().get(Calendar.YEAR); | 111 mThisYear = Calendar.getInstance().get(Calendar.YEAR); |
112 } | 112 } |
113 | 113 |
114 public void show() { | 114 public void show() { |
115 mDialog.show(); | 115 mDialog.show(); |
116 | 116 |
(...skipping 30 matching lines...) Expand all Loading... |
147 } | 147 } |
148 | 148 |
149 public void dismiss() { | 149 public void dismiss() { |
150 mDialog.dismiss(); | 150 mDialog.dismiss(); |
151 } | 151 } |
152 | 152 |
153 public void disableAndWaitForVerification() { | 153 public void disableAndWaitForVerification() { |
154 setInputsEnabled(false); | 154 setInputsEnabled(false); |
155 setOverlayVisibility(View.VISIBLE); | 155 setOverlayVisibility(View.VISIBLE); |
156 mVerificationProgressBar.setVisibility(View.VISIBLE); | 156 mVerificationProgressBar.setVisibility(View.VISIBLE); |
157 // TODO(estade): l10n | 157 mVerificationView.setText(mDialog.getContext().getResources().getString( |
158 mVerificationView.setText("Verifying card"); | 158 R.string.autofill_card_unmask_verification_in_progress)); |
159 setInputError(null); | 159 setInputError(null); |
160 } | 160 } |
161 | 161 |
162 public void verificationFinished(String errorMessage, boolean allowRetry) { | 162 public void verificationFinished(String errorMessage, boolean allowRetry) { |
163 if (errorMessage != null) { | 163 if (errorMessage != null) { |
164 setOverlayVisibility(View.GONE); | 164 setOverlayVisibility(View.GONE); |
165 if (allowRetry) { | 165 if (allowRetry) { |
166 setInputError(errorMessage); | 166 setInputError(errorMessage); |
167 setInputsEnabled(true); | 167 setInputsEnabled(true); |
168 setInitialFocus(); | 168 setInitialFocus(); |
169 } else { | 169 } else { |
170 setInputError(null); | 170 setInputError(null); |
171 setNoRetryError(errorMessage); | 171 setNoRetryError(errorMessage); |
172 } | 172 } |
173 } else { | 173 } else { |
174 mVerificationProgressBar.setVisibility(View.GONE); | 174 mVerificationProgressBar.setVisibility(View.GONE); |
175 mDialog.findViewById(R.id.verification_success).setVisibility(View.V
ISIBLE); | 175 mDialog.findViewById(R.id.verification_success).setVisibility(View.V
ISIBLE); |
176 mVerificationView.setText("Your card is verified"); | 176 mVerificationView.setText(mDialog.getContext().getResources().getStr
ing( |
| 177 R.string.autofill_card_unmask_verification_success)); |
177 Handler h = new Handler(); | 178 Handler h = new Handler(); |
178 h.postDelayed(new Runnable() { | 179 h.postDelayed(new Runnable() { |
179 @Override | 180 @Override |
180 public void run() { | 181 public void run() { |
181 dismiss(); | 182 dismiss(); |
182 } | 183 } |
183 }, 1000); | 184 }, 1000); |
184 } | 185 } |
185 } | 186 } |
186 | 187 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 try { | 303 try { |
303 int year = Integer.parseInt(mYearInput.getText().toString()); | 304 int year = Integer.parseInt(mYearInput.getText().toString()); |
304 if (year < 0) return -1; | 305 if (year < 0) return -1; |
305 if (year < 100) year += mThisYear - mThisYear % 100; | 306 if (year < 100) year += mThisYear - mThisYear % 100; |
306 return year; | 307 return year; |
307 } catch (NumberFormatException e) { | 308 } catch (NumberFormatException e) { |
308 return -1; | 309 return -1; |
309 } | 310 } |
310 } | 311 } |
311 } | 312 } |
OLD | NEW |