Use ICU to format plural strings
Test: manual
Fix: 199230208
Change-Id: I0b6fe9f8bb134a1479117c832575c63da2a07794
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 54920e1..f6c58c4 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -32,6 +32,7 @@
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.icu.text.MessageFormat;
import android.text.TextUtils.TruncateAt;
import android.util.AttributeSet;
import android.util.Property;
@@ -68,6 +69,8 @@
import com.android.launcher3.views.IconLabelDotView;
import java.text.NumberFormat;
+import java.util.HashMap;
+import java.util.Locale;
/**
* TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan
@@ -695,8 +698,8 @@
itemInfo.contentDescription));
} else if (hasDot()) {
int count = mDotInfo.getNotificationCount();
- setContentDescription(getContext().getResources().getQuantityString(
- R.plurals.dotted_app_label, count, itemInfo.contentDescription, count));
+ setContentDescription(
+ getAppLabelPluralString(itemInfo.contentDescription.toString(), count));
} else {
setContentDescription(itemInfo.contentDescription);
}
@@ -938,4 +941,14 @@
setCompoundDrawables(null, newIcon, null, null);
}
}
+
+ private String getAppLabelPluralString(String appName, int notificationCount) {
+ MessageFormat icuCountFormat = new MessageFormat(
+ getResources().getString(R.string.dotted_app_label),
+ Locale.getDefault());
+ HashMap<String, Object> args = new HashMap();
+ args.put("app_name", appName);
+ args.put("count", notificationCount);
+ return icuCountFormat.format(args);
+ }
}