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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillCreditCardEditor.java

Issue 897953002: Underlines for preference spinners and other autofill tweaks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pref_field_underline_color -> input_underline_color, fix wrapping Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/res/values/dimens.xml ('k') | chrome/android/java/strings/android_chrome_strings.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillCreditCardEditor.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillCreditCardEditor.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillCreditCardEditor.java
index a015cfd3e322573dbb6ecf7fa0458294d9879f36..9c212d8a98e9babab2958e615e5769abac90875e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillCreditCardEditor.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillCreditCardEditor.java
@@ -20,6 +20,7 @@ import android.widget.Spinner;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
+import org.chromium.chrome.browser.widget.FloatLabelLayout;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -33,7 +34,9 @@ public class AutofillCreditCardEditor extends Fragment implements TextWatcher {
// May be the empty string if creating a new profile.
private String mGUID;
+ private FloatLabelLayout mNameLabel;
private EditText mNameText;
+ private FloatLabelLayout mNumberLabel;
private EditText mNumberText;
private Spinner mExpirationMonth;
private Spinner mExpirationYear;
@@ -52,10 +55,10 @@ public class AutofillCreditCardEditor extends Fragment implements TextWatcher {
super.onCreate(savedInstanceState);
View v = inflater.inflate(R.layout.autofill_credit_card_editor, container, false);
- mNameText = (EditText) v.findViewById(
- R.id.autofill_credit_card_editor_name_edit);
- mNumberText = (EditText) v.findViewById(
- R.id.autofill_credit_card_editor_number_edit);
+ mNameLabel = (FloatLabelLayout) v.findViewById(R.id.credit_card_name_label);
+ mNameText = (EditText) v.findViewById(R.id.credit_card_name_edit);
+ mNumberLabel = (FloatLabelLayout) v.findViewById(R.id.credit_card_number_label);
+ mNumberText = (EditText) v.findViewById(R.id.credit_card_number_edit);
// Set text watcher to format credit card number
mNumberText.addTextChangedListener(new CreditCardNumberFormattingTextWatcher());
@@ -122,12 +125,24 @@ public class AutofillCreditCardEditor extends Fragment implements TextWatcher {
private void addCardDataToEditFields() {
CreditCard card = PersonalDataManager.getInstance().getCreditCard(mGUID);
if (card == null) {
+ // FloatLabelLayout animates showing the field label when its EditText is focused;
+ // to avoid this animation, manually set the name label to be visible, its EditText
+ // hint to null and request focus on its EditText field.
+ mNameLabel.getLabel().setVisibility(View.VISIBLE);
+ mNameText.setHint(null);
mNameText.requestFocus();
return;
}
- mNameText.setText(card.getName());
- mNumberText.setText(card.getNumber());
+ if (!TextUtils.isEmpty(card.getName())) {
+ mNameLabel.setText(card.getName());
+ }
+ if (!TextUtils.isEmpty(card.getNumber())) {
+ mNumberLabel.setText(card.getNumber());
+ }
+
+ // Make the name label focusable in touch mode so that mNameText doesn't get focused.
+ mNameLabel.getLabel().setFocusableInTouchMode(true);
int monthAsInt = 1;
if (!card.getMonth().isEmpty()) {
« no previous file with comments | « chrome/android/java/res/values/dimens.xml ('k') | chrome/android/java/strings/android_chrome_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698