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

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

Issue 2529443002: Show custom error message in payments UI. (Closed)
Patch Set: Created 4 years, 1 month 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/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 5556cd458070f2f982c2d6b22b7c0e750a292f11..3bb443801a24a002d58edf05ab6124c503ea2974 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
@@ -23,6 +23,7 @@ import android.os.Handler;
import android.support.annotation.IntDef;
import android.support.v4.view.animation.FastOutLinearInInterpolator;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
+import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -1089,17 +1090,23 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
@Override
public String getAdditionalText(PaymentRequestSection section) {
- if (section == mShippingAddressSection) {
- int selectedItemIndex = mShippingAddressSectionInformation.getSelectedItemIndex();
- boolean isNecessary = selectedItemIndex == SectionInformation.NO_SELECTION
- || selectedItemIndex == SectionInformation.INVALID_SELECTION;
- return isNecessary
- ? mContext.getString(selectedItemIndex == SectionInformation.NO_SELECTION
- ? mShippingStrings.getSelectPrompt()
- : mShippingStrings.getUnsupported())
- : null;
+ if (section != mShippingAddressSection) return null;
+
+ int selectedItemIndex = mShippingAddressSectionInformation.getSelectedItemIndex();
+ if (selectedItemIndex != SectionInformation.NO_SELECTION
+ && selectedItemIndex != SectionInformation.INVALID_SELECTION) {
+ return null;
}
- return null;
+
+ String customErrorMessage = mShippingAddressSectionInformation.getErrorMessage();
+ if (selectedItemIndex == SectionInformation.INVALID_SELECTION
+ && !TextUtils.isEmpty(customErrorMessage)) {
+ return customErrorMessage;
+ }
+
+ return mContext.getString(selectedItemIndex == SectionInformation.NO_SELECTION
+ ? mShippingStrings.getSelectPrompt()
+ : mShippingStrings.getUnsupported());
}
@Override

Powered by Google App Engine
This is Rietveld 408576698