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

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

Issue 2940353002: [Payments] Only show shipping option section once there are shipping options (Closed)
Patch Set: 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 | no next file » | 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/PaymentRequestUI.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java
index 1848ed97892fc953913e0fb89510dac8e02ee5ab..8ff4cd7b8588154bbdcb97abce0cec77c28584d1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java
@@ -561,10 +561,6 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout));
- mPaymentContainerLayout.addView(mShippingOptionSection,
- new LinearLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
- mSectionSeparators.add(new SectionSeparator(mPaymentContainerLayout));
}
mPaymentContainerLayout.addView(mPaymentMethodSection, new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
@@ -663,6 +659,7 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
} else if (whichSection == TYPE_SHIPPING_OPTIONS) {
mShippingOptionsSectionInformation = section;
mShippingOptionSection.update(section);
+ showShippingOptionSectionIfNecessary();
} else if (whichSection == TYPE_CONTACT_DETAILS) {
mContactDetailsSectionInformation = section;
mContactDetailsSection.update(section);
@@ -680,6 +677,25 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
if (isFinishingEditItem) notifyReadyForInput();
}
+ // Only show shipping option section once there are shipping options.
+ private void showShippingOptionSectionIfNecessary() {
+ if (!mRequestShipping || mShippingOptionsSectionInformation.isEmpty()
+ || mPaymentContainerLayout.indexOfChild(mShippingOptionSection) != -1) {
+ return;
+ }
+
+ // Shipping option section is added below shipping address section.
+ int addressSectionIndex = mPaymentContainerLayout.indexOfChild(mShippingAddressSection);
+ SectionSeparator sectionSeparator =
+ new SectionSeparator(mPaymentContainerLayout, addressSectionIndex + 1);
+ mSectionSeparators.add(sectionSeparator);
+ if (mIsExpandedToFullHeight) sectionSeparator.expand();
+ mPaymentContainerLayout.addView(mShippingOptionSection, addressSectionIndex + 2,
+ new LinearLayout.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
+ mPaymentContainerLayout.requestLayout();
+ }
+
@Override
public void onPaymentOptionChanged(final PaymentRequestSection section, PaymentOption option) {
@SelectionResult int result = SELECTION_RESULT_NONE;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698