Commit b060edf6 authored by dfalcantara's avatar dfalcantara Committed by Commit bot

[Payments] Add ability to show additional text for OptionSections

* Add ability to display additional text above the PaymentOption
  lists.

* Shipping address section now has the option to display text
  saying that the user needs to select a shipping address to
  update the shipping options.

* Optional shipping address section text disappears once the
  user selects an option.

BUG=603635

Review-Url: https://codereview.chromium.org/2040623002
Cr-Commit-Position: refs/heads/master@{#397900}
parent 137c967a
...@@ -458,6 +458,8 @@ ...@@ -458,6 +458,8 @@
<style name="PaymentsUiSectionDescriptiveText"> <style name="PaymentsUiSectionDescriptiveText">
<item name="android:textColor">@color/descriptive_text_color</item> <item name="android:textColor">@color/descriptive_text_color</item>
<item name="android:textSize">14sp</item> <item name="android:textSize">14sp</item>
</style>
<style name="PaymentsUiSectionDescriptiveTextEndAligned" parent="PaymentsUiSectionDescriptiveText">
<item name="android:textAlignment">viewEnd</item> <item name="android:textAlignment">viewEnd</item>
</style> </style>
<style name="PaymentsUiSectionAddButtonLabel"> <style name="PaymentsUiSectionAddButtonLabel">
......
...@@ -583,6 +583,11 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie ...@@ -583,6 +583,11 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
closeUI(false); closeUI(false);
} }
@Override
public boolean merchantNeedsShippingAddress() {
return mMerchantNeedsShippingAddress;
}
/** /**
* Called by the merchant website to abort the payment. * Called by the merchant website to abort the payment.
*/ */
......
...@@ -57,7 +57,7 @@ import java.util.List; ...@@ -57,7 +57,7 @@ import java.util.List;
* The PaymentRequest UI. * The PaymentRequest UI.
*/ */
public class PaymentRequestUI implements DialogInterface.OnDismissListener, View.OnClickListener, public class PaymentRequestUI implements DialogInterface.OnDismissListener, View.OnClickListener,
PaymentRequestSection.PaymentsSectionDelegate { PaymentRequestSection.SectionDelegate {
public static final int TYPE_SHIPPING_ADDRESSES = 1; public static final int TYPE_SHIPPING_ADDRESSES = 1;
public static final int TYPE_SHIPPING_OPTIONS = 2; public static final int TYPE_SHIPPING_OPTIONS = 2;
public static final int TYPE_PAYMENT_METHODS = 3; public static final int TYPE_PAYMENT_METHODS = 3;
...@@ -119,6 +119,12 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View ...@@ -119,6 +119,12 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
* or the “X” button in UI. * or the “X” button in UI.
*/ */
void onDismiss(); void onDismiss();
/**
* Checks if the merchant needs a shipping address to provide the shipping options.
* @return Whether or not the merchant needs a shipping address.
*/
boolean merchantNeedsShippingAddress();
} }
/** /**
...@@ -697,6 +703,18 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View ...@@ -697,6 +703,18 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
if (!mIsClientClosing) mClient.onDismiss(); if (!mIsClientClosing) mClient.onDismiss();
} }
@Override
public String getAdditionalText(OptionSection section) {
if (section == mShippingAddressSection) {
int selectedItemIndex = mShippingAddressSectionInformation.getSelectedItemIndex();
boolean isNecessary = mClient.merchantNeedsShippingAddress()
&& selectedItemIndex == SectionInformation.NO_SELECTION;
return isNecessary ? mContext.getString(
R.string.payments_select_shipping_address_for_shipping_methods) : null;
}
return null;
}
/** /**
* Animates the whole dialog fading in and darkening everything else on screen. * Animates the whole dialog fading in and darkening everything else on screen.
* This particular animation is not tracked because it is not meant to be cancelable. * This particular animation is not tracked because it is not meant to be cancelable.
......
...@@ -2432,6 +2432,9 @@ You can control the Physical Web in Chrome Settings. ...@@ -2432,6 +2432,9 @@ You can control the Physical Web in Chrome Settings.
<message name="IDS_PAYMENTS_ADD_PAYMENT_INSTRUMENT" desc="Text on a button that lets a user add a new payment method, like a credit card."> <message name="IDS_PAYMENTS_ADD_PAYMENT_INSTRUMENT" desc="Text on a button that lets a user add a new payment method, like a credit card.">
Add card Add card
</message> </message>
<message name="IDS_PAYMENTS_SELECT_SHIPPING_ADDRESS_FOR_SHIPPING_METHODS" desc="Text implying that a user needs to pick a shipping address to see the shipping methods.">
Select a shipping address to check shipping methods.
</message>
<!-- Migration strings --> <!-- Migration strings -->
<message name="IDS_TAB_SWITCHER_CALLOUT_HEADER" desc="Header for the Tab Switcher callout."> <message name="IDS_TAB_SWITCHER_CALLOUT_HEADER" desc="Header for the Tab Switcher callout.">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment