Commit 09435b7f authored by rouslan's avatar rouslan Committed by Commit bot
Browse files

Enable [Save] button after changing billing address.

After the user changes the billing address in Autofill settings for a
credit card, the [Save] button should become enabled.

BUG=623551

Review-Url: https://codereview.chromium.org/2101813002
Cr-Commit-Position: refs/heads/master@{#402362}
parent 3636550e
...@@ -42,6 +42,7 @@ public class AutofillCreditCardEditor extends AutofillEditorBase { ...@@ -42,6 +42,7 @@ public class AutofillCreditCardEditor extends AutofillEditorBase {
private int mInitialExpirationMonthPos; private int mInitialExpirationMonthPos;
private int mInitialExpirationYearPos; private int mInitialExpirationYearPos;
private int mInitialBillingAddressPos;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
...@@ -81,7 +82,8 @@ public class AutofillCreditCardEditor extends AutofillEditorBase { ...@@ -81,7 +82,8 @@ public class AutofillCreditCardEditor extends AutofillEditorBase {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if ((parent == mExpirationYear && position != mInitialExpirationYearPos) if ((parent == mExpirationYear && position != mInitialExpirationYearPos)
|| (parent == mExpirationMonth && position != mInitialExpirationMonthPos)) { || (parent == mExpirationMonth && position != mInitialExpirationMonthPos)
|| (parent == mBillingAddress && position != mInitialBillingAddressPos)) {
updateSaveButtonEnabled(); updateSaveButtonEnabled();
} }
} }
...@@ -134,6 +136,7 @@ public class AutofillCreditCardEditor extends AutofillEditorBase { ...@@ -134,6 +136,7 @@ public class AutofillCreditCardEditor extends AutofillEditorBase {
} }
mBillingAddress.setAdapter(profilesAdapter); mBillingAddress.setAdapter(profilesAdapter);
mInitialBillingAddressPos = 0;
mBillingAddress.setSelection(0); mBillingAddress.setSelection(0);
// TODO(rouslan): Use an [+ ADD ADDRESS] button instead of disabling the dropdown. // TODO(rouslan): Use an [+ ADD ADDRESS] button instead of disabling the dropdown.
...@@ -188,6 +191,7 @@ public class AutofillCreditCardEditor extends AutofillEditorBase { ...@@ -188,6 +191,7 @@ public class AutofillCreditCardEditor extends AutofillEditorBase {
for (int i = 0; i < mBillingAddress.getAdapter().getCount(); i++) { for (int i = 0; i < mBillingAddress.getAdapter().getCount(); i++) {
AutofillProfile profile = (AutofillProfile) mBillingAddress.getAdapter().getItem(i); AutofillProfile profile = (AutofillProfile) mBillingAddress.getAdapter().getItem(i);
if (TextUtils.equals(profile.getGUID(), card.getBillingAddressId())) { if (TextUtils.equals(profile.getGUID(), card.getBillingAddressId())) {
mInitialBillingAddressPos = i;
mBillingAddress.setSelection(i); mBillingAddress.setSelection(i);
break; break;
} }
...@@ -228,6 +232,7 @@ public class AutofillCreditCardEditor extends AutofillEditorBase { ...@@ -228,6 +232,7 @@ public class AutofillCreditCardEditor extends AutofillEditorBase {
mNumberText.addTextChangedListener(this); mNumberText.addTextChangedListener(this);
mExpirationMonth.setOnItemSelectedListener(this); mExpirationMonth.setOnItemSelectedListener(this);
mExpirationYear.setOnItemSelectedListener(this); mExpirationYear.setOnItemSelectedListener(this);
mBillingAddress.setOnItemSelectedListener(this);
} }
private void updateSaveButtonEnabled() { private void updateSaveButtonEnabled() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment