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

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 fixing Created 3 years, 6 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
« 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 128dd59c415dc9290f13ae57872c3435b927e9cd..f02418b8d2f02fc39db804c13f2b0d29e41cf09d 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,18 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
mSetDisplaySummaryInSingleLineInNormalMode = singleLine;
}
+ /**
+ * Specify whether the summary should be split to display under DISPLAY_MODE_NORMAL.
+ *
+ * @param splitSummary If true split the display of summary in the left and right
+ * text views in {@link DISPLAY_MODE_NORMAL}, the summary is
+ * split into 'label' and the rest('sublabel', 'Tertiary label').
+ * Otherwise the entire summary is displayed in the left text view.
+ */
+ 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 +1308,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 +1376,20 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
}
}
- private CharSequence convertOptionToString(
- PaymentOption item, boolean useBoldLabel, boolean singleLine) {
- SpannableStringBuilder builder = new SpannableStringBuilder(item.getLabel());
+ 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 (useBoldLabel) {
- builder.setSpan(
- new StyleSpan(android.graphics.Typeface.BOLD), 0, builder.length(), 0);
- }
-
if (!TextUtils.isEmpty(item.getSublabel())) {
if (builder.length() > 0) builder.append(labelSeparator);
builder.append(item.getSublabel());
@@ -1396,10 +1428,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() {
« 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