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

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: formatting 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..4e327ab907a3fa38bdc47f1ddb40e9518e0022a8 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, /* mainLabelOnly */
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 main label and the sub-label of summary should be separated
+ * in DISPLAY_MODE_NORMAL. */
+ private boolean mSeparateMainAndSubLabelInNormalMode = false;
gogerald1 2017/05/31 20:34:47 To make this feature more general instead of putti
gogerald1 2017/05/31 20:34:47 "=false" is not needed here,
wuandy1 2017/06/01 17:17:56 Done.
wuandy1 2017/06/01 17:17:57 Done.
+
/** Indicates whether the summary is set to R.style.PaymentsUiSectionDescriptiveText. */
private boolean mSummaryInDescriptiveText;
@@ -1173,6 +1177,17 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
mSetDisplaySummaryInSingleLineInNormalMode = singleLine;
}
+ /**
+ * @param separateMainAndSubLabelInNormalMode set to true if the main label and the
gogerald1 2017/05/31 20:34:47 splitSummary?
wuandy1 2017/06/01 17:17:56 Done.
+ * sub-label(eg, shipping option name and cost)
+ * should be displayed seprately when in
gogerald1 2017/05/31 20:34:47 "If true, sets to split and display the summary in
wuandy1 2017/06/01 17:17:56 Done.
+ * DISPLAY_MODE_NORMAL.
+ */
+ public void setSeparateMainAndSubLabelInNormalMode(
gogerald1 2017/05/31 20:34:47 setSplitSummaryInNormalMode()?
wuandy1 2017/06/01 17:17:56 Done.
+ boolean separateMainAndSubLabelInNormalMode) {
+ mSeparateMainAndSubLabelInNormalMode = separateMainAndSubLabelInNormalMode;
+ }
+
/** Updates the View to account for the new {@link SectionInformation} being passed in. */
public void update(SectionInformation information) {
mSectionInformation = information;
@@ -1290,9 +1305,17 @@ 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
gogerald1 2017/05/31 20:34:47 no need to comment on alignment, the left summary
wuandy1 2017/06/01 17:17:56 Done.
+ // section is in DISPLAY_MODE_NORMAL
+ boolean separateMainAndSubLabel = mSeparateMainAndSubLabelInNormalMode
+ && (mDisplayMode == DISPLAY_MODE_NORMAL);
+ setSummaryText(
+ convertOptionToString(selectedItem,
gogerald1 2017/05/31 20:34:47 "setSummaryText(selectedItem.getLabel(), convertOp
wuandy1 2017/06/01 17:17:57 changed to excludeMainLabel.
+ /* convert only main label if it is displayed separately from sub
+ label*/
+ separateMainAndSubLabel, false /* useBoldLabel */,
+ mSummaryInSingleLine),
+ separateMainAndSubLabel ? selectedItem.getSublabel() : null);
}
updateControlLayout();
@@ -1347,25 +1370,28 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
}
}
- private CharSequence convertOptionToString(
- PaymentOption item, boolean useBoldLabel, boolean singleLine) {
+ private CharSequence convertOptionToString(PaymentOption item, boolean mainLabelOnly,
gogerald1 2017/05/31 20:34:47 excludeMainLabel?
wuandy1 2017/06/01 17:17:57 Done.
+ 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(labelSeparator);
- builder.append(item.getSublabel());
- }
+ String labelSeparator = singleLine
+ ? getContext().getString(R.string.autofill_address_summary_separator)
+ : "\n";
+ if (!mainLabelOnly) { // build for sublabel and tertiary label
+ if (!TextUtils.isEmpty(item.getSublabel())) {
+ if (builder.length() > 0) builder.append(labelSeparator);
+ builder.append(item.getSublabel());
+ }
- if (!TextUtils.isEmpty(item.getTertiaryLabel())) {
- if (builder.length() > 0) builder.append(labelSeparator);
- builder.append(item.getTertiaryLabel());
+ if (!TextUtils.isEmpty(item.getTertiaryLabel())) {
+ if (builder.length() > 0) builder.append(labelSeparator);
+ builder.append(item.getTertiaryLabel());
+ }
}
if (!item.isComplete() && !TextUtils.isEmpty(item.getEditMessage())) {
@@ -1400,6 +1426,14 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
return getSummaryLeftTextView();
}
+ /**
+ * Returns the label of the summary for the OptionSection.
+ */
+ @VisibleForTesting
+ public TextView getSummarySubLabelForTest() {
gogerald1 2017/05/31 20:34:47 rename it to getRightSummaryLabelForTest
wuandy1 2017/06/01 17:17:57 Done.
+ return getSummaryRightTextView();
+ }
+
/** Returns the number of option labels. */
@VisibleForTesting
public int getNumberOfOptionLabelsForTest() {

Powered by Google App Engine
This is Rietveld 408576698