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

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

Issue 2914503002: align shipping option name to left and shipping cost to right on bottom sheet (Closed)
Patch Set: more comments addressing Created 3 years, 7 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 128dd59c415dc9290f13ae57872c3435b927e9cd..827ad4fe61fbc9c93696a595a105781df6ea9b8d 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,12 @@ 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 DISPLAY_MODE_NORMAL}.
+ */
+ private boolean mSplitSummaryInDisplayModeNormal;
+
/** Indicates whether the summary is set to R.style.PaymentsUiSectionDescriptiveText. */
private boolean mSummaryInDescriptiveText;
@@ -1173,6 +1179,17 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
mSetDisplaySummaryInSingleLineInNormalMode = singleLine;
}
+ /**
+ * Specify if the summary should be displayed split under DISPLAY_MODE_NORMAL.
gogerald1 2017/06/06 16:55:19 Specify whether.........should be split to display
gogerald1 2017/06/06 16:55:20 one space line below
wuandy1 2017/06/07 01:58:04 Done.
wuandy1 2017/06/07 01:58:04 Done.
+ * @param splitSummary set to true to split the display of summary in left and right
gogerald1 2017/06/06 16:55:19 If true, split the display..... or at least upperc
wuandy1 2017/06/07 01:58:04 Done.
+ * text views in {@link DISPLAY_MODE_NORMAL}. Otherwise the entire
+ * summary is displayed in left text view. Note that summary is
gogerald1 2017/06/06 16:55:20 Move this sentence before 'Otherwise' and replace
wuandy1 2017/06/07 01:58:04 Done.
+ * split into 'label' and the rest('sublabel', 'Tertiary label').
+ */
+ public void setSplitSummaryInDisplayModeNormal(boolean splitSummary) {
+ mSplitSummaryInDisplayModeNormal = splitSummary;
+ }
+
/** Updates the View to account for the new {@link SectionInformation} being passed in. */
public void update(SectionInformation information) {
mSectionInformation = information;
@@ -1290,9 +1307,20 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
getSummaryLeftTextView(), R.style.PaymentsUiSectionDefaultText);
mSummaryInDescriptiveText = false;
}
- setSummaryText(convertOptionToString(selectedItem, false /* useBoldLabel */,
- mSummaryInSingleLine),
- null);
+ // Split summary in DISPLAY_MODE_NORMAL if caller specified. The first part is
+ // displayed on the left summary text view aligned to the left. The second part is
+ // displayed on the right summary text view aligned to the right.
+ boolean splitSummary =
+ mSplitSummaryInDisplayModeNormal && (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 +1375,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 +1426,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 right summary text view.
+ */
+ @VisibleForTesting
+ public TextView getRightSummaryLabelForTest() {
+ return getSummaryRightTextView();
+ }
+
/** Returns the number of option labels. */
@VisibleForTesting
public int getNumberOfOptionLabelsForTest() {

Powered by Google App Engine
This is Rietveld 408576698