Clean <plurals> in DateTimeView
Bug: 199230228 Test: make Change-Id: Ib484fc0c59f7900b751f4e782dd67c000cc855bb
This commit is contained in:
@@ -18,11 +18,14 @@ package android.webkit;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.PluralsMessageFormatter;
|
||||
|
||||
import com.android.icu.text.DateSorterBridge;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Sorts dates into the following groups:
|
||||
@@ -73,9 +76,12 @@ public class DateSorter {
|
||||
mLabels[0] = dateSorterBridge.getToday();
|
||||
mLabels[1] = dateSorterBridge.getYesterday();
|
||||
|
||||
int resId = com.android.internal.R.plurals.last_num_days;
|
||||
String format = resources.getQuantityString(resId, NUM_DAYS_AGO);
|
||||
mLabels[2] = String.format(format, NUM_DAYS_AGO);
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
arguments.put("count", NUM_DAYS_AGO);
|
||||
mLabels[2] = PluralsMessageFormatter.format(
|
||||
resources,
|
||||
arguments,
|
||||
com.android.internal.R.string.last_num_days);
|
||||
|
||||
mLabels[3] = context.getString(com.android.internal.R.string.last_month);
|
||||
mLabels[4] = context.getString(com.android.internal.R.string.older);
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.database.ContentObserver;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.PluralsMessageFormatter;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.inspector.InspectableProperty;
|
||||
import android.widget.RemoteViews.RemoteView;
|
||||
@@ -48,6 +49,8 @@ import java.time.ZoneId;
|
||||
import java.time.temporal.JulianFields;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
//
|
||||
// TODO
|
||||
@@ -260,19 +263,17 @@ public class DateTimeView extends TextView {
|
||||
return;
|
||||
} else if (duration < HOUR_IN_MILLIS) {
|
||||
count = (int)(duration / MINUTE_IN_MILLIS);
|
||||
result = String.format(getContext().getResources().getQuantityString(past
|
||||
? com.android.internal.R.plurals.duration_minutes_shortest
|
||||
: com.android.internal.R.plurals.duration_minutes_shortest_future,
|
||||
count),
|
||||
result = getContext().getResources().getString(past
|
||||
? com.android.internal.R.string.duration_minutes_shortest
|
||||
: com.android.internal.R.string.duration_minutes_shortest_future,
|
||||
count);
|
||||
millisIncrease = MINUTE_IN_MILLIS;
|
||||
} else if (duration < DAY_IN_MILLIS) {
|
||||
count = (int)(duration / HOUR_IN_MILLIS);
|
||||
result = String.format(getContext().getResources().getQuantityString(past
|
||||
? com.android.internal.R.plurals.duration_hours_shortest
|
||||
: com.android.internal.R.plurals.duration_hours_shortest_future,
|
||||
count),
|
||||
count);
|
||||
result = getContext().getResources().getString(past
|
||||
? com.android.internal.R.string.duration_hours_shortest
|
||||
: com.android.internal.R.string.duration_hours_shortest_future,
|
||||
count);
|
||||
millisIncrease = HOUR_IN_MILLIS;
|
||||
} else if (duration < YEAR_IN_MILLIS) {
|
||||
// In weird cases it can become 0 because of daylight savings
|
||||
@@ -281,10 +282,9 @@ public class DateTimeView extends TextView {
|
||||
LocalDateTime localNow = toLocalDateTime(now, zoneId);
|
||||
|
||||
count = Math.max(Math.abs(dayDistance(localDateTime, localNow)), 1);
|
||||
result = String.format(getContext().getResources().getQuantityString(past
|
||||
? com.android.internal.R.plurals.duration_days_shortest
|
||||
: com.android.internal.R.plurals.duration_days_shortest_future,
|
||||
count),
|
||||
result = getContext().getResources().getString(past
|
||||
? com.android.internal.R.string.duration_days_shortest
|
||||
: com.android.internal.R.string.duration_days_shortest_future,
|
||||
count);
|
||||
if (past || count != 1) {
|
||||
mUpdateTimeMillis = computeNextMidnight(localNow, zoneId);
|
||||
@@ -295,10 +295,9 @@ public class DateTimeView extends TextView {
|
||||
|
||||
} else {
|
||||
count = (int)(duration / YEAR_IN_MILLIS);
|
||||
result = String.format(getContext().getResources().getQuantityString(past
|
||||
? com.android.internal.R.plurals.duration_years_shortest
|
||||
: com.android.internal.R.plurals.duration_years_shortest_future,
|
||||
count),
|
||||
result = getContext().getResources().getString(past
|
||||
? com.android.internal.R.string.duration_years_shortest
|
||||
: com.android.internal.R.string.duration_years_shortest_future,
|
||||
count);
|
||||
millisIncrease = YEAR_IN_MILLIS;
|
||||
}
|
||||
@@ -363,26 +362,25 @@ public class DateTimeView extends TextView {
|
||||
int count;
|
||||
boolean past = (now >= mTimeMillis);
|
||||
String result;
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
if (duration < MINUTE_IN_MILLIS) {
|
||||
result = mNowText;
|
||||
} else if (duration < HOUR_IN_MILLIS) {
|
||||
count = (int)(duration / MINUTE_IN_MILLIS);
|
||||
result = String.format(getContext().getResources().getQuantityString(past
|
||||
? com.android.internal.
|
||||
R.plurals.duration_minutes_relative
|
||||
: com.android.internal.
|
||||
R.plurals.duration_minutes_relative_future,
|
||||
count),
|
||||
count);
|
||||
arguments.put("count", count);
|
||||
result = PluralsMessageFormatter.format(
|
||||
getContext().getResources(),
|
||||
arguments,
|
||||
past ? R.string.duration_minutes_relative
|
||||
: R.string.duration_minutes_relative_future);
|
||||
} else if (duration < DAY_IN_MILLIS) {
|
||||
count = (int)(duration / HOUR_IN_MILLIS);
|
||||
result = String.format(getContext().getResources().getQuantityString(past
|
||||
? com.android.internal.
|
||||
R.plurals.duration_hours_relative
|
||||
: com.android.internal.
|
||||
R.plurals.duration_hours_relative_future,
|
||||
count),
|
||||
count);
|
||||
arguments.put("count", count);
|
||||
result = PluralsMessageFormatter.format(
|
||||
getContext().getResources(),
|
||||
arguments,
|
||||
past ? R.string.duration_hours_relative
|
||||
: R.string.duration_hours_relative_future);
|
||||
} else if (duration < YEAR_IN_MILLIS) {
|
||||
// In weird cases it can become 0 because of daylight savings
|
||||
LocalDateTime localDateTime = mLocalTime;
|
||||
@@ -390,23 +388,20 @@ public class DateTimeView extends TextView {
|
||||
LocalDateTime localNow = toLocalDateTime(now, zoneId);
|
||||
|
||||
count = Math.max(Math.abs(dayDistance(localDateTime, localNow)), 1);
|
||||
result = String.format(getContext().getResources().getQuantityString(past
|
||||
? com.android.internal.
|
||||
R.plurals.duration_days_relative
|
||||
: com.android.internal.
|
||||
R.plurals.duration_days_relative_future,
|
||||
count),
|
||||
count);
|
||||
|
||||
arguments.put("count", count);
|
||||
result = PluralsMessageFormatter.format(
|
||||
getContext().getResources(),
|
||||
arguments,
|
||||
past ? R.string.duration_days_relative
|
||||
: R.string.duration_days_relative_future);
|
||||
} else {
|
||||
count = (int)(duration / YEAR_IN_MILLIS);
|
||||
result = String.format(getContext().getResources().getQuantityString(past
|
||||
? com.android.internal.
|
||||
R.plurals.duration_years_relative
|
||||
: com.android.internal.
|
||||
R.plurals.duration_years_relative_future,
|
||||
count),
|
||||
count);
|
||||
arguments.put("count", count);
|
||||
result = PluralsMessageFormatter.format(
|
||||
getContext().getResources(),
|
||||
arguments,
|
||||
past ? R.string.duration_years_relative
|
||||
: R.string.duration_years_relative_future);
|
||||
}
|
||||
info.setText(result);
|
||||
}
|
||||
|
||||
@@ -3041,10 +3041,10 @@
|
||||
<string name="beforeOneMonthDurationPast">Before 1 month ago</string>
|
||||
|
||||
<!-- This is used to express that something occurred within the last X days (e.g., Last 7 days). -->
|
||||
<plurals name="last_num_days">
|
||||
<item quantity="one">Last <xliff:g id="count">%d</xliff:g> day</item>
|
||||
<item quantity="other">Last <xliff:g id="count">%d</xliff:g> days</item>
|
||||
</plurals>
|
||||
<string name="last_num_days">{ count, plural,
|
||||
=1 {Last # day}
|
||||
other {Last # days}
|
||||
}</string>
|
||||
|
||||
<!-- This is used to express that something has occurred within the last month -->
|
||||
<string name="last_month">Last month</string>
|
||||
@@ -3088,100 +3088,100 @@
|
||||
<string name="now_string_shortest">now</string>
|
||||
|
||||
<!-- Phrase describing a time duration using minutes that is as short as possible, preferrably one character. If the language needs a space in between the integer and the unit, please also integrate it in the string, but preferably it should not have a space in between.[CHAR LIMIT=6] -->
|
||||
<plurals name="duration_minutes_shortest">
|
||||
<item quantity="one"><xliff:g example="1" id="count">%d</xliff:g>m</item>
|
||||
<item quantity="other"><xliff:g example="2" id="count">%d</xliff:g>m</item>
|
||||
</plurals>
|
||||
<string name="duration_minutes_shortest">
|
||||
<xliff:g id="count">%d</xliff:g>m
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a time duration using hours that is as short as possible, preferrably one character. If the language needs a space in between the integer and the unit, please also integrate it in the string, but preferably it should not have a space in between.[CHAR LIMIT=6] -->
|
||||
<plurals name="duration_hours_shortest">
|
||||
<item quantity="one"><xliff:g example="1" id="count">%d</xliff:g>h</item>
|
||||
<item quantity="other"><xliff:g example="2" id="count">%d</xliff:g>h</item>
|
||||
</plurals>
|
||||
<string name="duration_hours_shortest">
|
||||
<xliff:g id="count">%d</xliff:g>h
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a time duration using days that is as short as possible, preferrably one character. If the language needs a space in between the integer and the unit, please also integrate it in the string, but preferably it should not have a space in between.[CHAR LIMIT=6] -->
|
||||
<plurals name="duration_days_shortest">
|
||||
<item quantity="one"><xliff:g example="1" id="count">%d</xliff:g>d</item>
|
||||
<item quantity="other"><xliff:g example="2" id="count">%d</xliff:g>d</item>
|
||||
</plurals>
|
||||
<string name="duration_days_shortest">
|
||||
<xliff:g id="count">%d</xliff:g>d
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a time duration using years that is as short as possible, preferrably one character. If the language needs a space in between the integer and the unit, please also integrate it in the string, but preferably it should not have a space in between.[CHAR LIMIT=6] -->
|
||||
<plurals name="duration_years_shortest">
|
||||
<item quantity="one"><xliff:g example="1" id="count">%d</xliff:g>y</item>
|
||||
<item quantity="other"><xliff:g example="2" id="count">%d</xliff:g>y</item>
|
||||
</plurals>
|
||||
<string name="duration_years_shortest">
|
||||
<xliff:g id="count">%d</xliff:g>y
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a time duration using minutes that is as short as possible, preferrably one character. This version should be a future point in time. If the language needs a space in between the integer and the unit, please also integrate it in the string, but preferably it should not have a space in between.[CHAR LIMIT=14] -->
|
||||
<plurals name="duration_minutes_shortest_future">
|
||||
<item quantity="one">in <xliff:g example="1" id="count">%d</xliff:g>m</item>
|
||||
<item quantity="other">in <xliff:g example="2" id="count">%d</xliff:g>m</item>
|
||||
</plurals>
|
||||
<string name="duration_minutes_shortest_future">
|
||||
in <xliff:g id="count">%d</xliff:g>m
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a time duration using hours that is as short as possible, preferrably one character. This version should be a future point in time. If the language needs a space in between the integer and the unit, please also integrate it in the string, but preferably it should not have a space in between.[CHAR LIMIT=14] -->
|
||||
<plurals name="duration_hours_shortest_future">
|
||||
<item quantity="one">in <xliff:g example="1" id="count">%d</xliff:g>h</item>
|
||||
<item quantity="other">in <xliff:g example="2" id="count">%d</xliff:g>h</item>
|
||||
</plurals>
|
||||
<string name="duration_hours_shortest_future">
|
||||
in <xliff:g id="count">%d</xliff:g>h
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a time duration using days that is as short as possible, preferrably one character. This version should be a future point in time. If the language needs a space in between the integer and the unit, please also integrate it in the string, but preferably it should not have a space in between.[CHAR LIMIT=14] -->
|
||||
<plurals name="duration_days_shortest_future">
|
||||
<item quantity="one">in <xliff:g example="1" id="count">%d</xliff:g>d</item>
|
||||
<item quantity="other">in <xliff:g example="2" id="count">%d</xliff:g>d</item>
|
||||
</plurals>
|
||||
<string name="duration_days_shortest_future">
|
||||
in <xliff:g example="1" id="count">%d</xliff:g>d
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a time duration using years that is as short as possible, preferrably one character. This version should be a future point in time. If the language needs a space in between the integer and the unit, please also integrate it in the string, but preferably it should not have a space in between.[CHAR LIMIT=14] -->
|
||||
<plurals name="duration_years_shortest_future">
|
||||
<item quantity="one">in <xliff:g example="1" id="count">%d</xliff:g>y</item>
|
||||
<item quantity="other">in <xliff:g example="2" id="count">%d</xliff:g>y</item>
|
||||
</plurals>
|
||||
<string name="duration_years_shortest_future">
|
||||
in <xliff:g id="count">%d</xliff:g>y
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a relative time using minutes in the past that is not shown on the screen but used for accessibility. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="duration_minutes_relative">
|
||||
<item quantity="one"><xliff:g example="1" id="count">%d</xliff:g> minute ago</item>
|
||||
<item quantity="other"><xliff:g example="2" id="count">%d</xliff:g> minutes ago</item>
|
||||
</plurals>
|
||||
<string name="duration_minutes_relative">{count, plural,
|
||||
=1 {# minute ago}
|
||||
other {# minutes ago}
|
||||
}
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a relative time using hours in the past that is not shown on the screen but used for accessibility. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="duration_hours_relative">
|
||||
<item quantity="one"><xliff:g example="1" id="count">%d</xliff:g> hour ago</item>
|
||||
<item quantity="other"><xliff:g example="2" id="count">%d</xliff:g> hours ago</item>
|
||||
</plurals>
|
||||
<string name="duration_hours_relative">{count, plural,
|
||||
=1 {# hour ago}
|
||||
other {# hours ago}
|
||||
}
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a relative time using days in the past that is not shown on the screen but used for accessibility. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="duration_days_relative">
|
||||
<item quantity="one"><xliff:g example="1" id="count">%d</xliff:g> day ago</item>
|
||||
<item quantity="other"><xliff:g example="2" id="count">%d</xliff:g> days ago</item>
|
||||
</plurals>
|
||||
<string name="duration_days_relative">{count, plural,
|
||||
=1 {# day ago}
|
||||
other {# days ago}
|
||||
}
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a relative time using years in the past that is not shown on the screen but used for accessibility. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="duration_years_relative">
|
||||
<item quantity="one"><xliff:g example="1" id="count">%d</xliff:g> year ago</item>
|
||||
<item quantity="other"><xliff:g example="2" id="count">%d</xliff:g> years ago</item>
|
||||
</plurals>
|
||||
<string name="duration_years_relative">{count, plural,
|
||||
=1 {# year ago}
|
||||
other {# years ago}
|
||||
}
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a relative time using minutes that is not shown on the screen but used for accessibility. This version should be a future point in time. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="duration_minutes_relative_future">
|
||||
<item quantity="one">in <xliff:g example="1" id="count">%d</xliff:g> minute</item>
|
||||
<item quantity="other">in <xliff:g example="2" id="count">%d</xliff:g> minutes</item>
|
||||
</plurals>
|
||||
<string name="duration_minutes_relative_future">{count, plural,
|
||||
=1 {# minute}
|
||||
other {# minutes}
|
||||
}
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a relative time using hours that is not shown on the screen but used for accessibility. This version should be a future point in time. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="duration_hours_relative_future">
|
||||
<item quantity="one">in <xliff:g example="1" id="count">%d</xliff:g> hour</item>
|
||||
<item quantity="other">in <xliff:g example="2" id="count">%d</xliff:g> hours</item>
|
||||
</plurals>
|
||||
<string name="duration_hours_relative_future">{count, plural,
|
||||
=1 {# hour}
|
||||
other {# hours}
|
||||
}
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a relative time using days that is not shown on the screen but used for accessibility. This version should be a future point in time. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="duration_days_relative_future">
|
||||
<item quantity="one">in <xliff:g example="1" id="count">%d</xliff:g> day</item>
|
||||
<item quantity="other">in <xliff:g example="2" id="count">%d</xliff:g> days</item>
|
||||
</plurals>
|
||||
<string name="duration_days_relative_future">{count, plural,
|
||||
=1 {# day}
|
||||
other {# days}
|
||||
}
|
||||
</string>
|
||||
|
||||
<!-- Phrase describing a relative time using years that is not shown on the screen but used for accessibility. This version should be a future point in time. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="duration_years_relative_future">
|
||||
<item quantity="one">in <xliff:g example="1" id="count">%d</xliff:g> year</item>
|
||||
<item quantity="other">in <xliff:g example="2" id="count">%d</xliff:g> years</item>
|
||||
</plurals>
|
||||
<string name="duration_years_relative_future">{count, plural,
|
||||
=1 {# year}
|
||||
other {# years}
|
||||
}
|
||||
</string>
|
||||
|
||||
<!-- Title for error alert when a video cannot be played. it can be used by any app. -->
|
||||
<string name="VideoView_error_title">Video problem</string>
|
||||
@@ -5094,12 +5094,6 @@
|
||||
<string name="restr_pin_error_doesnt_match">PINs don\'t match. Try again.</string>
|
||||
<!-- PIN entry dialog error when PIN is too short [CHAR LIMIT=none] -->
|
||||
<string name="restr_pin_error_too_short">PIN is too short. Must be at least 4 digits.</string>
|
||||
<!-- PIN entry dialog countdown message for next chance to enter the PIN [CHAR LIMIT=none] -->
|
||||
<!-- Phrase describing a time duration using seconds [CHAR LIMIT=none] -->
|
||||
<plurals name="restr_pin_countdown">
|
||||
<item quantity="one">Try again in 1 second</item>
|
||||
<item quantity="other">Try again in <xliff:g id="count">%d</xliff:g> seconds</item>
|
||||
</plurals>
|
||||
<!-- PIN entry dialog tells the user to not enter a PIN for a while. [CHAR LIMIT=none] -->
|
||||
<string name="restr_pin_try_later">Try again later</string>
|
||||
|
||||
|
||||
@@ -1260,10 +1260,9 @@
|
||||
<java-symbol type="string" name="conference_call" />
|
||||
<java-symbol type="string" name="tooltip_popup_title" />
|
||||
|
||||
<java-symbol type="plurals" name="last_num_days" />
|
||||
<java-symbol type="plurals" name="restr_pin_countdown" />
|
||||
<java-symbol type="string" name="bugreport_countdown" />
|
||||
<java-symbol type="string" name="file_count" />
|
||||
<java-symbol type="string" name="last_num_days" />
|
||||
<java-symbol type="string" name="matches_found" />
|
||||
<java-symbol type="plurals" name="pinpuk_attempts" />
|
||||
<java-symbol type="string" name="ssl_ca_cert_warning" />
|
||||
@@ -3098,23 +3097,23 @@
|
||||
|
||||
<java-symbol type="id" name="aerr_wait" />
|
||||
|
||||
<java-symbol type="plurals" name="duration_minutes_shortest" />
|
||||
<java-symbol type="plurals" name="duration_hours_shortest" />
|
||||
<java-symbol type="plurals" name="duration_days_shortest" />
|
||||
<java-symbol type="plurals" name="duration_years_shortest" />
|
||||
<java-symbol type="plurals" name="duration_minutes_shortest_future" />
|
||||
<java-symbol type="plurals" name="duration_hours_shortest_future" />
|
||||
<java-symbol type="plurals" name="duration_days_shortest_future" />
|
||||
<java-symbol type="plurals" name="duration_years_shortest_future" />
|
||||
<java-symbol type="string" name="duration_minutes_shortest" />
|
||||
<java-symbol type="string" name="duration_hours_shortest" />
|
||||
<java-symbol type="string" name="duration_days_shortest" />
|
||||
<java-symbol type="string" name="duration_years_shortest" />
|
||||
<java-symbol type="string" name="duration_minutes_shortest_future" />
|
||||
<java-symbol type="string" name="duration_hours_shortest_future" />
|
||||
<java-symbol type="string" name="duration_days_shortest_future" />
|
||||
<java-symbol type="string" name="duration_years_shortest_future" />
|
||||
|
||||
<java-symbol type="plurals" name="duration_minutes_relative" />
|
||||
<java-symbol type="plurals" name="duration_hours_relative" />
|
||||
<java-symbol type="plurals" name="duration_days_relative" />
|
||||
<java-symbol type="plurals" name="duration_years_relative" />
|
||||
<java-symbol type="plurals" name="duration_minutes_relative_future" />
|
||||
<java-symbol type="plurals" name="duration_hours_relative_future" />
|
||||
<java-symbol type="plurals" name="duration_days_relative_future" />
|
||||
<java-symbol type="plurals" name="duration_years_relative_future" />
|
||||
<java-symbol type="string" name="duration_minutes_relative" />
|
||||
<java-symbol type="string" name="duration_hours_relative" />
|
||||
<java-symbol type="string" name="duration_days_relative" />
|
||||
<java-symbol type="string" name="duration_years_relative" />
|
||||
<java-symbol type="string" name="duration_minutes_relative_future" />
|
||||
<java-symbol type="string" name="duration_hours_relative_future" />
|
||||
<java-symbol type="string" name="duration_days_relative_future" />
|
||||
<java-symbol type="string" name="duration_years_relative_future" />
|
||||
|
||||
<java-symbol type="string" name="now_string_shortest" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user