Search in sources :

Example 61 with MessageFormat

use of android.icu.text.MessageFormat in project android_packages_apps_Settings by omnirom.

the class ZenModeBackend method getStarredContactsSummary.

String getStarredContactsSummary(Context context) {
    List<String> starredContacts = getStarredContacts();
    int numStarredContacts = starredContacts.size();
    MessageFormat msgFormat = new MessageFormat(mContext.getString(R.string.zen_mode_starred_contacts_summary_contacts), Locale.getDefault());
    Map<String, Object> args = new HashMap<>();
    args.put("count", numStarredContacts);
    if (numStarredContacts >= 1) {
        args.put("contact_1", starredContacts.get(0));
        if (numStarredContacts >= 2) {
            args.put("contact_2", starredContacts.get(1));
            if (numStarredContacts == 3) {
                args.put("contact_3", starredContacts.get(2));
            }
        }
    }
    return msgFormat.format(args);
}
Also used : MessageFormat(android.icu.text.MessageFormat) HashMap(java.util.HashMap)

Aggregations

MessageFormat (android.icu.text.MessageFormat)61 Test (org.junit.Test)53 AttributedString (java.text.AttributedString)24 HashMap (java.util.HashMap)15 FieldPosition (java.text.FieldPosition)12 ParsePosition (java.text.ParsePosition)10 Date (java.util.Date)10 ChoiceFormat (java.text.ChoiceFormat)9 ParseException (java.text.ParseException)9 IOException (java.io.IOException)7 Map (java.util.Map)7 TreeMap (java.util.TreeMap)6 SimpleDateFormat (android.icu.text.SimpleDateFormat)5 DateFormat (android.icu.text.DateFormat)4 DecimalFormat (android.icu.text.DecimalFormat)4 NumberFormat (android.icu.text.NumberFormat)4 UFormat (android.icu.text.UFormat)3 ULocale (android.icu.util.ULocale)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3