| 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 128dd59c415dc9290f13ae57872c3435b927e9cd..5aba0a406fbcc339957644ab69d5423e7601734e 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
|
| @@ -935,7 +935,7 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
|
| ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
|
| ? R.style.PaymentsUiSectionDefaultText
|
| : R.style.PaymentsUiSectionDisabledText);
|
| - labelView.setText(convertOptionToString(mOption,
|
| + labelView.setText(convertOptionToString(mOption, false, /* excludeMainLabel */
|
| mDelegate.isBoldLabelNeeded(OptionSection.this),
|
| false /* singleLine */));
|
| labelView.setEnabled(isEnabled);
|
| @@ -1061,6 +1061,10 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
|
| */
|
| boolean mSetDisplaySummaryInSingleLineInNormalMode = true;
|
|
|
| + /** Indicates whether the summary should be split to display in left and right summary
|
| + * text views in {@link PaymentRequestSection.DISPLAY_MODE_NORMAL}. */
|
| + private boolean mSplitSummaryInNormalMode;
|
| +
|
| /** Indicates whether the summary is set to R.style.PaymentsUiSectionDescriptiveText. */
|
| private boolean mSummaryInDescriptiveText;
|
|
|
| @@ -1173,6 +1177,16 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
|
| mSetDisplaySummaryInSingleLineInNormalMode = singleLine;
|
| }
|
|
|
| + /**
|
| + * @param splitSummary set to true to split the display of summary in left and right
|
| + * text views in {@link DISPLAY_MODE_NORMAL}. Otherwise the entire
|
| + * summary is displayed in left text view. Note that summary is
|
| + * split into 'label' and the rest('sublabel', 'Tertiary label').
|
| + */
|
| + public void setSplitSummaryInNormalMode(boolean splitSummary) {
|
| + mSplitSummaryInNormalMode = splitSummary;
|
| + }
|
| +
|
| /** Updates the View to account for the new {@link SectionInformation} being passed in. */
|
| public void update(SectionInformation information) {
|
| mSectionInformation = information;
|
| @@ -1253,9 +1267,9 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
|
|
|
| private void updateSelectedItem(PaymentOption selectedItem) {
|
| // Only left TextView in the summary section is used in this section.
|
| - // Summary is displayed in multiple lines by default unless:
|
| + // Summary is displayed in multiple line by default unless:
|
| // 1. nothing is selected or
|
| - // 2. the display mode is DISPLAY_MODE_NORMAL without caller explicitly set to display
|
| + // 2. display mode is DISPLAY_MODE_NORMAL without caller explicitly set to display
|
| // summary in multiple lines.
|
| if (selectedItem == null
|
| || (mDisplayMode == DISPLAY_MODE_NORMAL
|
| @@ -1290,9 +1304,19 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
|
| getSummaryLeftTextView(), R.style.PaymentsUiSectionDefaultText);
|
| mSummaryInDescriptiveText = false;
|
| }
|
| - setSummaryText(convertOptionToString(selectedItem, false /* useBoldLabel */,
|
| - mSummaryInSingleLine),
|
| - null);
|
| + // Align main label to the left and sub label to the right if caller specified and
|
| + // section is in DISPLAY_MODE_NORMAL
|
| + boolean splitSummary =
|
| + mSplitSummaryInNormalMode && (mDisplayMode == DISPLAY_MODE_NORMAL);
|
| + if (splitSummary) {
|
| + setSummaryText(selectedItem.getLabel(),
|
| + convertOptionToString(selectedItem, true /* excludeMainLabel */,
|
| + false /* useBoldLabel */, mSummaryInSingleLine));
|
| + } else {
|
| + setSummaryText(convertOptionToString(selectedItem, false /* excludeMainLabel */,
|
| + false /* useBoldLabel */, mSummaryInSingleLine),
|
| + null);
|
| + }
|
| }
|
|
|
| updateControlLayout();
|
| @@ -1347,17 +1371,19 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
|
| }
|
| }
|
|
|
| - 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";
|
| + private CharSequence convertOptionToString(PaymentOption item, boolean excludeMainLabel,
|
| + boolean useBoldLabel, boolean singleLine) {
|
| + SpannableStringBuilder builder = new SpannableStringBuilder();
|
| + if (!excludeMainLabel) builder.append(item.getLabel());
|
| +
|
| if (useBoldLabel) {
|
| builder.setSpan(
|
| new StyleSpan(android.graphics.Typeface.BOLD), 0, builder.length(), 0);
|
| }
|
|
|
| + String labelSeparator = singleLine
|
| + ? getContext().getString(R.string.autofill_address_summary_separator)
|
| + : "\n";
|
| if (!TextUtils.isEmpty(item.getSublabel())) {
|
| if (builder.length() > 0) builder.append(labelSeparator);
|
| builder.append(item.getSublabel());
|
| @@ -1396,10 +1422,18 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
|
| * Returns the label of the section summary.
|
| */
|
| @VisibleForTesting
|
| - public TextView getSummaryLabelForTest() {
|
| + public TextView getLeftSummaryLabelForTest() {
|
| return getSummaryLeftTextView();
|
| }
|
|
|
| + /**
|
| + * Returns the label of the summary right text view for the OptionSection.
|
| + */
|
| + @VisibleForTesting
|
| + public TextView getRightSummaryLabelForTest() {
|
| + return getSummaryRightTextView();
|
| + }
|
| +
|
| /** Returns the number of option labels. */
|
| @VisibleForTesting
|
| public int getNumberOfOptionLabelsForTest() {
|
|
|