diff options
-rw-r--r-- | res/values/strings.xml | 9 | ||||
-rw-r--r-- | src/com/android/car/calendar/AllDayEventsItem.java | 12 |
2 files changed, 15 insertions, 6 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index a78bc08..493f549 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -42,8 +42,9 @@ </string> <!-- The title for the all-day events section. Only shown for more than one item. [CHAR LIMIT=120] --> - <plurals name="all_day_title"> - <item quantity="one">%d all day event</item> - <item quantity="other">%d all day events</item> - </plurals> + <string name="all_day_title"> {count, plural, + =1 {# all day event} + other {# all day events} + } + </string> </resources>
\ No newline at end of file diff --git a/src/com/android/car/calendar/AllDayEventsItem.java b/src/com/android/car/calendar/AllDayEventsItem.java index 92c00ca..d42d78c 100644 --- a/src/com/android/car/calendar/AllDayEventsItem.java +++ b/src/com/android/car/calendar/AllDayEventsItem.java @@ -19,6 +19,7 @@ package com.android.car.calendar; import static com.google.common.base.Preconditions.checkNotNull; import android.content.res.Resources; +import android.icu.text.MessageFormat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -28,7 +29,10 @@ import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; +import java.util.HashMap; import java.util.List; +import java.util.Locale; +import java.util.Map; class AllDayEventsItem implements CalendarItem { @@ -78,8 +82,12 @@ class AllDayEventsItem implements CalendarItem { hideEventSection(); int size = eventCalendarItems.size(); - mTitleTextView.setText( - mResources.getQuantityString(R.plurals.all_day_title, size, size)); + MessageFormat msgFmt = new MessageFormat(mResources.getString( + R.string.all_day_title), Locale.getDefault()); + Map<String, Object> strArgs = new HashMap<>(); + strArgs.put("count", size); + String title = msgFmt.format(strArgs); + mTitleTextView.setText(title); for (EventCalendarItem eventCalendarItem : eventCalendarItems) { EventCalendarItem.EventViewHolder holder = |