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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/CardEditor.java

Issue 2952673002: [Payments] Format and validate phone number according to selected country in address editor (Closed)
Patch Set: Fix tests Created 3 years, 6 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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.payments; 5 package org.chromium.chrome.browser.payments;
6 6
7 import android.os.AsyncTask; 7 import android.os.AsyncTask;
8 import android.os.Handler; 8 import android.os.Handler;
9 import android.text.SpannableStringBuilder; 9 import android.text.SpannableStringBuilder;
10 import android.text.TextUtils; 10 import android.text.TextUtils;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // Card scanner is expensive to query. 478 // Card scanner is expensive to query.
479 if (mCardScanner == null) { 479 if (mCardScanner == null) {
480 mCardScanner = CreditCardScanner.create(mWebContents, this); 480 mCardScanner = CreditCardScanner.create(mWebContents, this);
481 mCanScan = mCardScanner.canScan(); 481 mCanScan = mCardScanner.canScan();
482 } 482 }
483 483
484 // Card number is validated. 484 // Card number is validated.
485 if (mNumberField == null) { 485 if (mNumberField == null) {
486 mNumberField = EditorFieldModel.createTextInput( 486 mNumberField = EditorFieldModel.createTextInput(
487 EditorFieldModel.INPUT_TYPE_HINT_CREDIT_CARD, 487 EditorFieldModel.INPUT_TYPE_HINT_CREDIT_CARD,
488 mContext.getString(R.string.autofill_credit_card_editor_numb er), null, 488 mContext.getString(R.string.autofill_credit_card_editor_numb er),
489 mCardNumberValidator, mCardIconGenerator, 489 null /* suggestions */, null /* formatter */, mCardNumberVal idator,
490 mCardIconGenerator,
490 mContext.getString(R.string.payments_field_required_validati on_message), 491 mContext.getString(R.string.payments_field_required_validati on_message),
491 mContext.getString(R.string.payments_card_number_invalid_val idation_message), 492 mContext.getString(R.string.payments_card_number_invalid_val idation_message),
492 null); 493 null /* value */);
493 if (mCanScan) { 494 if (mCanScan) {
494 mNumberField.addActionIcon(R.drawable.ic_photo_camera, 495 mNumberField.addActionIcon(R.drawable.ic_photo_camera,
495 R.string.autofill_scan_credit_card, new Runnable() { 496 R.string.autofill_scan_credit_card, new Runnable() {
496 @Override 497 @Override
497 public void run() { 498 public void run() {
498 if (mIsScanning) return; 499 if (mIsScanning) return;
499 mIsScanning = true; 500 mIsScanning = true;
500 mCardScanner.scan(); 501 mCardScanner.scan();
501 } 502 }
502 }); 503 });
503 } 504 }
504 } 505 }
505 mNumberField.setValue(card.getNumber()); 506 mNumberField.setValue(card.getNumber());
506 editor.addField(mNumberField); 507 editor.addField(mNumberField);
507 508
508 // Name on card is required. 509 // Name on card is required.
509 if (mNameField == null) { 510 if (mNameField == null) {
510 mNameField = EditorFieldModel.createTextInput( 511 mNameField =
511 EditorFieldModel.INPUT_TYPE_HINT_PERSON_NAME, 512 EditorFieldModel.createTextInput(EditorFieldModel.INPUT_TYPE _HINT_PERSON_NAME,
512 mContext.getString(R.string.autofill_credit_card_editor_name ), null, null, null, 513 mContext.getString(R.string.autofill_credit_card_edi tor_name),
513 mContext.getString(R.string.payments_field_required_validati on_message), null, 514 null /* suggestions */, null /* formatter */, null / * validator */,
514 null); 515 null /* valueIconGenerator */,
516 mContext.getString(R.string.payments_field_required_ validation_message),
517 null /* invalidErrorMessage */, null /* value */);
515 } 518 }
516 mNameField.setValue(card.getName()); 519 mNameField.setValue(card.getName());
517 editor.addField(mNameField); 520 editor.addField(mNameField);
518 521
519 // Expiration month dropdown. 522 // Expiration month dropdown.
520 if (mMonthField == null) { 523 if (mMonthField == null) {
521 mCurrentYear = calendar.get(Calendar.YEAR); 524 mCurrentYear = calendar.get(Calendar.YEAR);
522 // The month in calendar is 0 based but the month value is 1 based. 525 // The month in calendar is 0 based but the month value is 1 based.
523 mCurrentMonth = calendar.get(Calendar.MONTH) + 1; 526 mCurrentMonth = calendar.get(Calendar.MONTH) + 1;
524 527
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 830
828 mEditorDialog.update(); 831 mEditorDialog.update();
829 mIsScanning = false; 832 mIsScanning = false;
830 } 833 }
831 834
832 @Override 835 @Override
833 public void onScanCancelled() { 836 public void onScanCancelled() {
834 mIsScanning = false; 837 mIsScanning = false;
835 } 838 }
836 } 839 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698