Commit bdf235c5 authored by markusheintz's avatar markusheintz Committed by Commit bot

Revert of [Payments] Add ability to bold parts of addresses (patchset #4...

Revert of [Payments] Add ability to bold parts of addresses (patchset #4 id:60001 of https://codereview.chromium.org/2135573004/ )

Reason for revert:
Android Test builder is failing since https://build.chromium.org/p/chromium.linux/builders/Android%20Tests%20%28dbg%29/builds/35304

see https://build.chromium.org/p/chromium.linux/builders/Android%20Tests%20%28dbg%29/builds/35304/steps/chrome_public_test_apk/logs/stdio

This may be one of two CLs that could have caused this (the other is https://codereview.chromium.org/2116583002). Since the two CLs have some files in common I'll start reverting this one first.

Original issue's description:
> [Payments] Add ability to bold parts of addresses
>
> * Add the ability to bold parts of a label.
>
> * Add the ability to show a tertiary label in the PaymentOption, which
>   will later be used for phone number display.
>
> * The phone number is passed in to the PaymentOption using the new constructor
>   via the AutofillAddress class.
>
> See crbug.com/626833 for screenshots.
>
> BUG=603635,626833
>
> Committed: https://crrev.com/92f4c6ac21b2578ab3938c5bd3eb0f793621164f
> Cr-Commit-Position: refs/heads/master@{#405900}

TBR=rouslan@chromium.org,mathp@chromium.org,dfalcantara@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=603635,626833

Review-Url: https://codereview.chromium.org/2158763002
Cr-Commit-Position: refs/heads/master@{#405968}
parent 894f497b
......@@ -40,8 +40,7 @@ public class AutofillAddress extends PaymentOption {
* @param profile The autofill profile containing the address information.
*/
public AutofillAddress(AutofillProfile profile, boolean isComplete) {
super(profile.getGUID(), profile.getFullName(), profile.getLabel(),
profile.getPhoneNumber(), PaymentOption.NO_ICON);
super(profile.getGUID(), profile.getFullName(), profile.getLabel(), PaymentOption.NO_ICON);
mProfile = profile;
mIsComplete = isComplete;
}
......@@ -53,15 +52,14 @@ public class AutofillAddress extends PaymentOption {
/**
* Updates the address and marks it "complete." Called after the user has edited this address.
* Updates the identifier and labels.
* Updates the identifier, label, and sublabel.
*
* @param profile The new profile to use.
*/
public void completeAddress(AutofillProfile profile) {
mProfile = profile;
mIsComplete = true;
updateIdentifierAndLabels(mProfile.getGUID(), mProfile.getFullName(), mProfile.getLabel(),
mProfile.getPhoneNumber());
updateIdentifierAndLabels(mProfile.getGUID(), mProfile.getFullName(), mProfile.getLabel());
}
/** @return The country code to use, e.g., when constructing an editor for this address. */
......
......@@ -160,7 +160,7 @@ public class AutofillPaymentInstrument
mBillingAddress = billingAddress;
mIsComplete = true;
updateIdentifierLabelsAndIcon(card.getGUID(), card.getObfuscatedNumber(), card.getName(),
null, card.getIssuerIconDrawableId());
card.getIssuerIconDrawableId());
}
/** @return The credit card represented by this payment instrument. */
......
......@@ -16,27 +16,24 @@ public class PaymentOption implements Completable {
protected boolean mIsComplete;
private String mId;
@Nullable private String mLabel;
@Nullable private String mSublabel;
private int mIcon;
private String[] mLabels = {null, null, null};
private boolean mIsValid = true;
/** See {@link #PaymentOption(String, String, String, String, int)}. */
public PaymentOption(String id, @Nullable String label, @Nullable String sublabel, int icon) {
this(id, label, sublabel, null, icon);
}
/**
* Constructs a payment option.
*
* @param id The identifier.
* @param label The label.
* @param sublabel The optional sublabel.
* @param tertiarylabel The optional tertiary label.
* @param icon The drawable icon identifier or NO_ICON.
* @param id The identifier.
* @param label The label.
* @param sublabel The optional sublabel.
* @param icon The drawable icon identifier or NO_ICON.
*/
public PaymentOption(String id, @Nullable String label, @Nullable String sublabel,
@Nullable String tertiarylabel, int icon) {
updateIdentifierLabelsAndIcon(id, label, sublabel, tertiarylabel, icon);
public PaymentOption(String id, @Nullable String label, @Nullable String sublabel, int icon) {
mId = id;
mLabel = label;
mSublabel = sublabel;
mIcon = icon;
}
@Override
......@@ -56,51 +53,42 @@ public class PaymentOption implements Completable {
* The primary label of this option. For example, “Visa***1234” or "2-day shipping".
*/
@Nullable public String getLabel() {
return mLabels[0];
return mLabel;
}
/**
* The optional sublabel of this option. For example, “Expiration date: 12/2025”.
*/
@Nullable public String getSublabel() {
return mLabels[1];
return mSublabel;
}
/**
* The optional tertiary label of this option. For example, "(555) 867-5309".
* Updates the identifier, label, and sublabel of this option. Called after the user has edited
* this option.
*
* @param id The new id to use. Should not be null.
* @param label The new label to use. Should not be null.
* @param sublabel The new sublabel to use. Can be null.
*/
@Nullable public String getTertiaryLabel() {
return mLabels[2];
}
/** See {@link #updateIdentifierAndLabels(String, String, String, String)}. */
protected void updateIdentifierAndLabels(String id, String label, @Nullable String sublabel) {
updateIdentifierAndLabels(id, label, sublabel, null);
}
/** See {@link #updateIdentifierLabelsAndIcon(String, String, String, String, int)}. */
protected void updateIdentifierAndLabels(
String id, String label, @Nullable String sublabel, @Nullable String tertiarylabel) {
mId = id;
mLabels[0] = label;
mLabels[1] = sublabel;
mLabels[2] = tertiarylabel;
updateIdentifierLabelsAndIcon(id, label, sublabel, mIcon);
}
/**
* Updates the identifier, labels, and icon of this option. Called after the user has
* Updates the identifier, label, sublabel, and icon of this option. Called after the user has
* edited this option.
*
* @param id The new id to use. Should not be null.
* @param label The new label to use. Should not be null.
* @param sublabel The new sublabel to use. Can be null.
* @param tertiarylabel The new tertiary label to use. Can be null.
* @param icon The drawable icon identifier or NO_ICON.
* @param id The new id to use. Should not be null.
* @param label The new label to use. Should not be null.
* @param sublabel The new sublabel to use. Can be null.
* @param icon The drawable icon identifier or NO_ICON.
*/
protected void updateIdentifierLabelsAndIcon(
String id, String label, @Nullable String sublabel, @Nullable String tertiarylabel,
int icon) {
updateIdentifierAndLabels(id, label, sublabel, tertiarylabel);
String id, String label, @Nullable String sublabel, int icon) {
mId = id;
mLabel = label;
mSublabel = sublabel;
mIcon = icon;
}
......
......@@ -83,9 +83,6 @@ public abstract class PaymentRequestSection extends LinearLayout {
/** Called when the user requests adding a new PaymentOption to a given section. */
void onAddPaymentOption(OptionSection section);
/** Checks whether or not the text should be formatted with a bold label. */
boolean isBoldLabelNeeded(OptionSection section);
/** Checks whether or not the user should be allowed to click on controls. */
boolean isAcceptingUserInput();
......@@ -653,8 +650,7 @@ public abstract class PaymentRequestSection extends LinearLayout {
ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
? R.style.PaymentsUiSectionDefaultText
: R.style.PaymentsUiSectionDisabledText);
labelView.setText(convertOptionToString(
mOption, mDelegate.isBoldLabelNeeded(OptionSection.this)));
labelView.setText(convertOptionToString(mOption));
labelView.setEnabled(isEnabled);
} else if (mRowType == OPTION_ROW_TYPE_ADD) {
// Shows string saying that the user can add a new option, e.g. credit card no.
......@@ -865,7 +861,7 @@ public abstract class PaymentRequestSection extends LinearLayout {
}
} else {
setLogoResource(selectedItem.getDrawableIconId());
setSummaryText(convertOptionToString(selectedItem, false), null);
setSummaryText(convertOptionToString(selectedItem), null);
}
}
......@@ -917,24 +913,9 @@ public abstract class PaymentRequestSection extends LinearLayout {
}
}
private CharSequence convertOptionToString(PaymentOption item, boolean useBoldLabel) {
SpannableStringBuilder builder = new SpannableStringBuilder(item.getLabel());
if (useBoldLabel) {
builder.setSpan(
new StyleSpan(android.graphics.Typeface.BOLD), 0, builder.length(), 0);
}
if (!TextUtils.isEmpty(item.getSublabel())) {
if (builder.length() > 0) builder.append("\n");
builder.append(item.getSublabel());
}
if (!TextUtils.isEmpty(item.getTertiaryLabel())) {
if (builder.length() > 0) builder.append("\n");
builder.append(item.getTertiaryLabel());
}
return builder;
private CharSequence convertOptionToString(PaymentOption item) {
if (TextUtils.isEmpty(item.getSublabel())) return item.getLabel();
return new StringBuilder(item.getLabel()).append("\n").append(item.getSublabel());
}
/**
......
......@@ -620,11 +620,6 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
updatePayButtonEnabled();
}
@Override
public boolean isBoldLabelNeeded(OptionSection section) {
return section == mShippingAddressSection;
}
/** @return The common editor user interface. */
public EditorView getEditorView() {
return mEditorView;
......
......@@ -383,6 +383,7 @@ PersonalDataManagerAndroid::GetAddressLabelForPaymentRequest(
label_fields.push_back(ADDRESS_HOME_ZIP);
label_fields.push_back(ADDRESS_HOME_SORTING_CODE);
label_fields.push_back(ADDRESS_HOME_COUNTRY);
label_fields.push_back(PHONE_HOME_WHOLE_NUMBER);
AutofillProfile profile;
PopulateNativeProfileFromJava(jprofile, env, &profile);
......@@ -628,6 +629,7 @@ ScopedJavaLocalRef<jobjectArray> PersonalDataManagerAndroid::GetProfileLabels(
suggested_fields->push_back(ADDRESS_HOME_ZIP);
suggested_fields->push_back(ADDRESS_HOME_SORTING_CODE);
suggested_fields->push_back(ADDRESS_HOME_COUNTRY);
suggested_fields->push_back(PHONE_HOME_WHOLE_NUMBER);
minimal_fields_shown = suggested_fields->size();
}
......
......@@ -61,8 +61,8 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver {
// Gets the labels for the profiles to suggest to the user. These labels are
// useful for distinguishing the profiles from one another.
//
// The labels never contain the full name, email address, or phone numbers.
// All other fields are included in the label.
// The labels never contain the full name or email address. All other fields
// are included in the label.
base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabelsToSuggest(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& unused_obj);
......@@ -221,8 +221,8 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver {
//
// The labels never contain the full name and include at least 2 fields.
//
// If |address_only| is true, then such fields as phone number, and email
// address are also omitted, but all other fields are included in the label.
// If |address_only| is true, then such fields as phone number and email
// address are also omitted, but all fields are included in the label.
base::android::ScopedJavaLocalRef<jobjectArray> GetProfileLabels(
JNIEnv* env,
bool address_only,
......
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