Add schedule setting page for time-based modes.

Creates new layout for setting the start & end time, and days of the week, for a schedule-based mode.

This is close to the mocks specified in https://screenshot.googleplex.com/8zmb7PAjjt73VkN, but with the following differences:
- the end time is left-aligned with the center rather than on the right side of the screen. This is a side effect of using LinearLayout to evenly space start & end times, and could in theory be fixed by using a ConstraintLayout, but that option seems to cause times to overlap instead of wrap when display size is cranked up. Could be fixed later.
- no icons yet on either side of the time display
- no Done button. Instead, has the "exit at alarm" switch that exists today.

Have not yet checked how this interacts with TalkBack, etc.

Flag: android.app.modes_ui
Bug: 332730302
Test: ZenModeSetSchedulePreferenceControllerTest, ZenModeExitAtAlarmPreferenceControllerTest, ZenModeSetTriggerLinkPreferenceControllerTest
Test: manual: interacting with UI in normal size, with font & display at minimum and maximum, and in locales (fr) where the first day of the week is a different day
Change-Id: I0b76f55891d6c12fc27720657c9eea6fe42fbafe
This commit is contained in:
Yuri Lin
2024-05-28 17:28:13 -04:00
parent cfaedb0199
commit 4203f311dd
13 changed files with 1129 additions and 3 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.notification.modes;
import static android.app.AutomaticZenRule.TYPE_SCHEDULE_CALENDAR;
import static android.app.AutomaticZenRule.TYPE_SCHEDULE_TIME;
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
@@ -32,13 +33,13 @@ import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.PrimarySwitchPreference;
/**
* Preference controller for the link
* Preference controller for the link to an individual mode's configuration page.
*/
public class ZenModeSetTriggerLinkPreferenceController extends AbstractZenModePreferenceController {
class ZenModeSetTriggerLinkPreferenceController extends AbstractZenModePreferenceController {
@VisibleForTesting
protected static final String AUTOMATIC_TRIGGER_PREF_KEY = "zen_automatic_trigger_settings";
public ZenModeSetTriggerLinkPreferenceController(Context context, String key,
ZenModeSetTriggerLinkPreferenceController(Context context, String key,
ZenModesBackend backend) {
super(context, key, backend);
}
@@ -66,6 +67,16 @@ public class ZenModeSetTriggerLinkPreferenceController extends AbstractZenModePr
// TODO: b/341961712 - direct preference to app-owned intent if available
switch (zenMode.getRule().getType()) {
case TYPE_SCHEDULE_TIME:
switchPref.setTitle(R.string.zen_mode_set_schedule_link);
switchPref.setSummary(zenMode.getRule().getTriggerDescription());
switchPref.setIntent(new SubSettingLauncher(mContext)
.setDestination(ZenModeSetScheduleFragment.class.getName())
// TODO: b/332937635 - set correct metrics category
.setSourceMetricsCategory(0)
.setArguments(bundle)
.toIntent());
break;
case TYPE_SCHEDULE_CALENDAR:
switchPref.setTitle(R.string.zen_mode_set_calendar_link);
switchPref.setSummary(zenMode.getRule().getTriggerDescription());