Support daily and hourly battery chartview.

https://drive.google.com/file/d/1vjt6FPFAiFakb158t1IBku1IQNzVPW46/view?usp=sharing&resourcekey=0-f5m2eUKWbth6gdEFh5lOIQ

Test: manual
Bug: 236101166
Change-Id: I47d899b936742514801cd4fa7a82ddaea5d21c31
This commit is contained in:
Zaiyue Xue
2022-07-22 15:24:09 +08:00
parent 03182b5781
commit eaf4d1bb50
4 changed files with 295 additions and 318 deletions

View File

@@ -140,7 +140,7 @@ public final class ConvertUtils {
/** Converts UTC timestamp to local time hour data. */
public static String utcToLocalTimeHour(
Context context, long timestamp, boolean is24HourFormat) {
final Context context, final long timestamp, final boolean is24HourFormat) {
final Locale locale = getLocale(context);
// e.g. for 12-hour format: 9 pm
// e.g. for 24-hour format: 09:00
@@ -149,6 +149,13 @@ public final class ConvertUtils {
return DateFormat.format(pattern, timestamp).toString().toLowerCase(locale);
}
/** Converts UTC timestamp to local time day of week data. */
public static String utcToLocalTimeDayOfWeek(final Context context, final long timestamp) {
final Locale locale = getLocale(context);
final String pattern = DateFormat.getBestDateTimePattern(locale, "E");
return DateFormat.format(pattern, timestamp).toString().toUpperCase(locale);
}
/** Gets indexed battery usage data for each corresponding time slot. */
public static Map<Integer, List<BatteryDiffEntry>> getIndexedUsageMap(
final Context context,