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

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

Issue 2281913002: Currency code exceeding 6 chars will be ellipsized. (Closed)
Patch Set: Rebased Created 4 years, 3 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/CurrencyStringFormatter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
index 0bb0e59edf274bc3539621b135702dbf9c8090a1..50a5ce8c318d78e4ef0b45a1a14f90036507b1af 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
@@ -24,12 +24,23 @@ public class CurrencyStringFormatter {
// Max currency code length. Maximum length of currency code can be at most 2048.
private static final int MAX_CURRENCY_CODE_LEN = 2048;
+ // Currency code exceeding 6 chars will be ellipsized during formatting for display.
+ private static final int MAX_CURRENCY_CHARS = 6;
+
+ // Unicode character for ellipsis.
+ private static final String ELLIPSIS = "\u2026";
+
// Formatting constants.
private static final int DIGIT_GROUPING_SIZE = 3;
private final Pattern mAmountValuePattern;
/**
+ * The currency specified in the payment request.
+ */
+ private final String mCurrencyCode;
+
+ /**
* The symbol for the currency specified on the bill. For example, the symbol for "USD" is "$".
*/
private final String mCurrencySymbol;
@@ -65,6 +76,7 @@ public class CurrencyStringFormatter {
assert userLocale != null : "userLocale should not be null";
mAmountValuePattern = Pattern.compile(AMOUNT_VALUE_PATTERN);
+ mCurrencyCode = currencyCode;
String currencySymbol;
int defaultFractionDigits;
@@ -161,6 +173,16 @@ public class CurrencyStringFormatter {
}
}
please use gerrit instead 2016/09/01 14:55:55 /** @return The currency code formatted for displa
pals 2016/09/02 11:51:15 Done.
+ String currency = mCurrencyCode;
+ if (mCurrencyCode.length() > MAX_CURRENCY_CHARS) {
+ currency = mCurrencyCode.substring(0, MAX_CURRENCY_CHARS - 1) + ELLIPSIS;
+ }
+
+ if (currency.length() > 0) {
+ result.insert(0, " ");
+ result.insert(0, currency);
+ }
+
return result.toString();
}
}

Powered by Google App Engine
This is Rietveld 408576698