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

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

Issue 2514693002: [Payments] Display payment method and contact summary in a single line in bottom sheet (Closed)
Patch Set: address comments Created 4 years, 1 month 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 | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java » ('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/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 45def34f5a3dce3d714587a5296df997ae04e1e3..d4c61db098ed64161ff861c895b2b22eb858bf60 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
@@ -248,8 +248,10 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
/**
* Sets how the summary text should be displayed.
*
- * @param leftTruncate How to truncate the left summary text. Set to null to clear.
- * @param rightTruncate How to truncate the right summary text. Set to null to clear.
+ * @param leftTruncate How to truncate the left summary text. Set to null to clear.
+ * @param leftIsSingleLine Whether the left summary text should be a single line.
+ * @param rightTruncate How to truncate the right summary text. Set to null to clear.
+ * @param rightIsSingleLine Whether the right summary text should be a single line.
*/
public void setSummaryProperties(@Nullable TruncateAt leftTruncate, boolean leftIsSingleLine,
@Nullable TruncateAt rightTruncate, boolean rightIsSingleLine) {
@@ -841,8 +843,9 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
? R.style.PaymentsUiSectionDefaultText
: R.style.PaymentsUiSectionDisabledText);
- labelView.setText(convertOptionToString(
- mOption, mDelegate.isBoldLabelNeeded(OptionSection.this)));
+ labelView.setText(convertOptionToString(mOption,
+ mDelegate.isBoldLabelNeeded(OptionSection.this),
+ false /* singleLine */));
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.
@@ -944,6 +947,9 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
/** SectionInformation that is used to populate the views in this section. */
private SectionInformation mSectionInformation;
+ /** Indicates whether the summary should be a single line. */
+ private boolean mSummaryInSingleLine = false;
+
/**
* Constructs an OptionSection.
*
@@ -1004,6 +1010,20 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
}
@Override
+ public void setSummaryProperties(@Nullable TruncateAt leftTruncate,
+ boolean leftIsSingleLine, @Nullable TruncateAt rightTruncate,
+ boolean rightIsSingleLine) {
+ super.setSummaryProperties(
+ leftTruncate, leftIsSingleLine, rightTruncate, rightIsSingleLine);
+
+ // Updates the summary if necessary after properties are changed.
+ mSummaryInSingleLine = leftIsSingleLine;
+ if (mSectionInformation != null) {
+ updateSelectedItem(mSectionInformation.getSelectedItem());
+ }
+ }
+
+ @Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
Context context = mainSectionLayout.getContext();
mCheckingProgress = createLoadingSpinner();
@@ -1104,7 +1124,10 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
setSummaryText(null, null);
} else {
setLogoDrawable(selectedItem.getDrawableIcon());
- setSummaryText(convertOptionToString(selectedItem, false), null);
+ setSummaryText(
+ convertOptionToString(selectedItem, false /* useBoldLabel */,
+ mSummaryInSingleLine),
+ null);
}
updateControlLayout();
@@ -1159,25 +1182,29 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
}
}
- private CharSequence convertOptionToString(PaymentOption item, boolean useBoldLabel) {
+ private CharSequence convertOptionToString(
+ PaymentOption item, boolean useBoldLabel, boolean singleLine) {
SpannableStringBuilder builder = new SpannableStringBuilder(item.getLabel());
+ String labelSeparator = singleLine
+ ? getContext().getString(R.string.autofill_address_summary_separator)
+ : "\n";
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");
+ if (builder.length() > 0) builder.append(labelSeparator);
builder.append(item.getSublabel());
}
if (!TextUtils.isEmpty(item.getTertiaryLabel())) {
- if (builder.length() > 0) builder.append("\n");
+ if (builder.length() > 0) builder.append(labelSeparator);
builder.append(item.getTertiaryLabel());
}
if (!item.isComplete() && !TextUtils.isEmpty(item.getEditMessage())) {
- if (builder.length() > 0) builder.append("\n");
+ if (builder.length() > 0) builder.append(labelSeparator);
String editMessage = item.getEditMessage();
builder.append(editMessage);
Object foregroundSpanner = new ForegroundColorSpan(ApiCompatibilityUtils.getColor(
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698