Commit 46a39fbe authored by estade's avatar estade Committed by Commit bot

revert a057427e

    Added code to disable save button if no text is present in name or number field

    Currently if some text is first typed in any of the fields then save button
    gets enabled. But when all text is deleted from field, save button is not
    disabled.
    Added code to enable/disable properly.

    BUG=446760

    Review URL: https://codereview.chromium.org/837613003

It created a new bug, http://crbug.com/453568, and the original issue it solved is not worth fixing.

BUG=453568,446760

Review URL: https://codereview.chromium.org/895433005

Cr-Commit-Position: refs/heads/master@{#314935}
parent 8fc7b4dd
...@@ -12,6 +12,8 @@ import android.text.TextWatcher; ...@@ -12,6 +12,8 @@ import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
...@@ -29,7 +31,8 @@ import java.util.Locale; ...@@ -29,7 +31,8 @@ import java.util.Locale;
/** /**
* Provides the Java-ui for editing a Credit Card autofill entry. * Provides the Java-ui for editing a Credit Card autofill entry.
*/ */
public class AutofillCreditCardEditor extends Fragment implements TextWatcher { public class AutofillCreditCardEditor extends Fragment implements OnItemSelectedListener,
TextWatcher {
// GUID of the profile we are editing. // GUID of the profile we are editing.
// May be the empty string if creating a new profile. // May be the empty string if creating a new profile.
private String mGUID; private String mGUID;
...@@ -87,6 +90,17 @@ public class AutofillCreditCardEditor extends Fragment implements TextWatcher { ...@@ -87,6 +90,17 @@ public class AutofillCreditCardEditor extends Fragment implements TextWatcher {
return v; return v;
} }
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if ((parent == mExpirationYear && position != mInitialExpirationYearPos)
|| (parent == mExpirationMonth && position != mInitialExpirationMonthPos)) {
enableSaveButton();
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
@Override @Override
public void afterTextChanged(Editable s) {} public void afterTextChanged(Editable s) {}
...@@ -95,7 +109,7 @@ public class AutofillCreditCardEditor extends Fragment implements TextWatcher { ...@@ -95,7 +109,7 @@ public class AutofillCreditCardEditor extends Fragment implements TextWatcher {
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
updateSaveButtonState(); enableSaveButton();
} }
void addSpinnerAdapters() { void addSpinnerAdapters() {
...@@ -229,13 +243,13 @@ public class AutofillCreditCardEditor extends Fragment implements TextWatcher { ...@@ -229,13 +243,13 @@ public class AutofillCreditCardEditor extends Fragment implements TextWatcher {
// Listen for changes to inputs. Enable the save button after something has changed. // Listen for changes to inputs. Enable the save button after something has changed.
mNameText.addTextChangedListener(this); mNameText.addTextChangedListener(this);
mNumberText.addTextChangedListener(this); mNumberText.addTextChangedListener(this);
mExpirationMonth.setOnItemSelectedListener(this);
mExpirationYear.setOnItemSelectedListener(this);
} }
private void updateSaveButtonState() { private void enableSaveButton() {
Button button = (Button) getView().findViewById(R.id.autofill_credit_card_save); Button button = (Button) getView().findViewById(R.id.autofill_credit_card_save);
boolean enabled = mNameText.getEditableText().toString().trim().length() > 0 button.setEnabled(true);
|| mNumberText.getEditableText().toString().trim().length() > 0;
button.setEnabled(enabled);
} }
/** /**
......
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