OLD | NEW |
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.preferences.autofill; | 5 package org.chromium.chrome.browser.preferences.autofill; |
6 | 6 |
7 import android.os.Bundle; | 7 import android.os.Bundle; |
8 import android.text.Editable; | 8 import android.text.Editable; |
9 import android.text.TextUtils; | 9 import android.text.TextUtils; |
10 import android.view.LayoutInflater; | 10 import android.view.LayoutInflater; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 mInitialExpirationYearPos = 0; | 156 mInitialExpirationYearPos = 0; |
157 } | 157 } |
158 mExpirationYear.setSelection(mInitialExpirationYearPos); | 158 mExpirationYear.setSelection(mInitialExpirationYearPos); |
159 } | 159 } |
160 | 160 |
161 @Override | 161 @Override |
162 protected boolean saveEntry() { | 162 protected boolean saveEntry() { |
163 // Remove all spaces in editText. | 163 // Remove all spaces in editText. |
164 String cardNumber = mNumberText.getText().toString().replaceAll("\\s+",
""); | 164 String cardNumber = mNumberText.getText().toString().replaceAll("\\s+",
""); |
165 PersonalDataManager personalDataManager = PersonalDataManager.getInstanc
e(); | 165 PersonalDataManager personalDataManager = PersonalDataManager.getInstanc
e(); |
166 // Card Payment Type will be empty if credit card number is not valid. | 166 // Issuer network will be empty if credit card number is not valid. |
167 if (TextUtils.isEmpty(personalDataManager.getBasicCardPaymentType(cardNu
mber, | 167 if (TextUtils.isEmpty(personalDataManager.getBasicCardIssuerNetwork( |
168 true /* emptyIfInvalid */))) { | 168 cardNumber, true /* emptyIfInvalid */))) { |
169 mNumberLabel.setError(mContext.getString( | 169 mNumberLabel.setError(mContext.getString( |
170 R.string.payments_card_number_invalid_validation_message)); | 170 R.string.payments_card_number_invalid_validation_message)); |
171 return false; | 171 return false; |
172 } | 172 } |
173 CreditCard card = new CreditCard(mGUID, AutofillAndPaymentsPreferences.S
ETTINGS_ORIGIN, | 173 CreditCard card = new CreditCard(mGUID, AutofillAndPaymentsPreferences.S
ETTINGS_ORIGIN, |
174 true /* isLocal */, false /* isCached */, mNameText.getText().to
String().trim(), | 174 true /* isLocal */, false /* isCached */, mNameText.getText().to
String().trim(), |
175 cardNumber, "" /* obfuscatedNumber */, | 175 cardNumber, "" /* obfuscatedNumber */, |
176 String.valueOf(mExpirationMonth.getSelectedItemPosition() + 1), | 176 String.valueOf(mExpirationMonth.getSelectedItemPosition() + 1), |
177 (String) mExpirationYear.getSelectedItem(), "" /* basicCardPayme
ntType */, | 177 (String) mExpirationYear.getSelectedItem(), "" /* basicCardPayme
ntType */, |
178 0 /* issuerIconDrawableId */, | 178 0 /* issuerIconDrawableId */, |
(...skipping 26 matching lines...) Expand all Loading... |
205 mExpirationYear.setOnTouchListener(this); | 205 mExpirationYear.setOnTouchListener(this); |
206 } | 206 } |
207 | 207 |
208 private void updateSaveButtonEnabled() { | 208 private void updateSaveButtonEnabled() { |
209 // Enable save button if credit card number is not empty. We validate th
e credit card number | 209 // Enable save button if credit card number is not empty. We validate th
e credit card number |
210 // when user presses the save button. | 210 // when user presses the save button. |
211 boolean enabled = !TextUtils.isEmpty(mNumberText.getText()); | 211 boolean enabled = !TextUtils.isEmpty(mNumberText.getText()); |
212 ((Button) getView().findViewById(R.id.button_primary)).setEnabled(enable
d); | 212 ((Button) getView().findViewById(R.id.button_primary)).setEnabled(enable
d); |
213 } | 213 } |
214 } | 214 } |
OLD | NEW |