Loading core/java/android/service/notification/SystemZenRules.java +10 −5 Original line number Diff line number Diff line Loading @@ -129,10 +129,7 @@ public final class SystemZenRules { } sb.append(daysSummary); sb.append(context.getString(R.string.zen_mode_trigger_summary_divider_text)); sb.append(context.getString( R.string.zen_mode_trigger_summary_range_symbol_combination, timeString(context, schedule.startHour, schedule.startMinute), timeString(context, schedule.endHour, schedule.endMinute))); sb.append(getTimeSummary(context, schedule)); return sb.toString(); } Loading @@ -142,7 +139,7 @@ public final class SystemZenRules { * adjacent days grouped together ("Sun-Wed" instead of "Sun,Mon,Tue,Wed"). */ @Nullable private static String getShortDaysSummary(Context context, @NonNull ScheduleInfo schedule) { public static String getShortDaysSummary(Context context, @NonNull ScheduleInfo schedule) { // Compute a list of days with contiguous days grouped together, for example: "Sun-Thu" or // "Sun-Mon,Wed,Fri" final int[] days = schedule.days; Loading Loading @@ -224,6 +221,14 @@ public final class SystemZenRules { return null; } /** Returns the time part of a {@link ScheduleInfo}, e.g. {@code 9:00-17:00}. */ public static String getTimeSummary(Context context, @NonNull ScheduleInfo schedule) { return context.getString( R.string.zen_mode_trigger_summary_range_symbol_combination, timeString(context, schedule.startHour, schedule.startMinute), timeString(context, schedule.endHour, schedule.endMinute)); } /** * Convenience method for representing the specified time in string format. */ Loading services/tests/uiservicestests/src/com/android/server/notification/SystemZenRulesTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -207,4 +207,28 @@ public class SystemZenRulesTest extends UiServiceTestCase { assertThat(getTriggerDescriptionForScheduleTime(mContext, scheduleInfo)) .isEqualTo("Mon,Wed,Fri-Sat,10:00 AM-4:00 PM"); } @Test public void getShortDaysSummary_onlyDays() { ScheduleInfo scheduleInfo = new ScheduleInfo(); scheduleInfo.startHour = 10; scheduleInfo.endHour = 16; scheduleInfo.days = new int[] {Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY}; assertThat(SystemZenRules.getShortDaysSummary(mContext, scheduleInfo)) .isEqualTo("Mon-Fri"); } @Test public void getTimeSummary_onlyTime() { ScheduleInfo scheduleInfo = new ScheduleInfo(); scheduleInfo.startHour = 11; scheduleInfo.endHour = 15; scheduleInfo.days = new int[] {Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY}; assertThat(SystemZenRules.getTimeSummary(mContext, scheduleInfo)) .isEqualTo("11:00 AM-3:00 PM"); } } Loading
core/java/android/service/notification/SystemZenRules.java +10 −5 Original line number Diff line number Diff line Loading @@ -129,10 +129,7 @@ public final class SystemZenRules { } sb.append(daysSummary); sb.append(context.getString(R.string.zen_mode_trigger_summary_divider_text)); sb.append(context.getString( R.string.zen_mode_trigger_summary_range_symbol_combination, timeString(context, schedule.startHour, schedule.startMinute), timeString(context, schedule.endHour, schedule.endMinute))); sb.append(getTimeSummary(context, schedule)); return sb.toString(); } Loading @@ -142,7 +139,7 @@ public final class SystemZenRules { * adjacent days grouped together ("Sun-Wed" instead of "Sun,Mon,Tue,Wed"). */ @Nullable private static String getShortDaysSummary(Context context, @NonNull ScheduleInfo schedule) { public static String getShortDaysSummary(Context context, @NonNull ScheduleInfo schedule) { // Compute a list of days with contiguous days grouped together, for example: "Sun-Thu" or // "Sun-Mon,Wed,Fri" final int[] days = schedule.days; Loading Loading @@ -224,6 +221,14 @@ public final class SystemZenRules { return null; } /** Returns the time part of a {@link ScheduleInfo}, e.g. {@code 9:00-17:00}. */ public static String getTimeSummary(Context context, @NonNull ScheduleInfo schedule) { return context.getString( R.string.zen_mode_trigger_summary_range_symbol_combination, timeString(context, schedule.startHour, schedule.startMinute), timeString(context, schedule.endHour, schedule.endMinute)); } /** * Convenience method for representing the specified time in string format. */ Loading
services/tests/uiservicestests/src/com/android/server/notification/SystemZenRulesTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -207,4 +207,28 @@ public class SystemZenRulesTest extends UiServiceTestCase { assertThat(getTriggerDescriptionForScheduleTime(mContext, scheduleInfo)) .isEqualTo("Mon,Wed,Fri-Sat,10:00 AM-4:00 PM"); } @Test public void getShortDaysSummary_onlyDays() { ScheduleInfo scheduleInfo = new ScheduleInfo(); scheduleInfo.startHour = 10; scheduleInfo.endHour = 16; scheduleInfo.days = new int[] {Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY}; assertThat(SystemZenRules.getShortDaysSummary(mContext, scheduleInfo)) .isEqualTo("Mon-Fri"); } @Test public void getTimeSummary_onlyTime() { ScheduleInfo scheduleInfo = new ScheduleInfo(); scheduleInfo.startHour = 11; scheduleInfo.endHour = 15; scheduleInfo.days = new int[] {Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY}; assertThat(SystemZenRules.getTimeSummary(mContext, scheduleInfo)) .isEqualTo("11:00 AM-3:00 PM"); } }