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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java

Issue 2149433002: [Payments] Add ability to bold parts of addresses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
index 4c506bac1d64759d2c38d305739674e543d43411..2fb37b4f29a2c69ab37aa502ca19966fb8a159fc 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
@@ -81,6 +81,9 @@ 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();
@@ -646,7 +649,8 @@ public abstract class PaymentRequestSection extends LinearLayout {
ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
? R.style.PaymentsUiSectionDefaultText
: R.style.PaymentsUiSectionDisabledText);
- labelView.setText(convertOptionToString(mOption));
+ labelView.setText(convertOptionToString(
+ mOption, mDelegate.isBoldLabelNeeded(OptionSection.this)));
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.
@@ -857,7 +861,7 @@ public abstract class PaymentRequestSection extends LinearLayout {
}
} else {
setLogoResource(selectedItem.getDrawableIconId());
- setSummaryText(convertOptionToString(selectedItem), null);
+ setSummaryText(convertOptionToString(selectedItem, false), null);
}
}
@@ -903,9 +907,24 @@ public abstract class PaymentRequestSection extends LinearLayout {
}
}
- private CharSequence convertOptionToString(PaymentOption item) {
- if (TextUtils.isEmpty(item.getSublabel())) return item.getLabel();
- return new StringBuilder(item.getLabel()).append("\n").append(item.getSublabel());
+ 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;
}
}

Powered by Google App Engine
This is Rietveld 408576698