Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 583b3dfc authored by Yuri Lin's avatar Yuri Lin
Browse files

Settings changes for changing default for zen policy.

This change sets a rule's ZenPolicy to the device default right before entering the customization screen, rather than setting it to a copy of the global DND policy. Further, because all policies are now fully specified, when the MODES_API flag is on, skip the radio button screen for selecting between a default and a custom setting and jump straight to the page for setting custom settings.

Bug: 312739308
Test: manual -- entered settings for rules created before and after V, modified settings, verified they took

Change-Id: I1e3a777b60a8fcf06732879f823b033826a52a43
parent 6384d974
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@ package com.android.settings.notification.zen;
import static android.app.NotificationManager.EXTRA_AUTOMATIC_RULE_ID;

import android.app.AutomaticZenRule;
import android.app.Flags;
import android.app.NotificationManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -100,10 +102,21 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
                    public boolean onPreferenceClick(Preference preference) {
                        Bundle bundle = new Bundle();
                        bundle.putString(ZenCustomRuleSettings.RULE_ID, mId);

                        // When modes_api flag is on, we skip the radio button screen distinguishing
                        // between "default" and "custom" and take users directly to the custom
                        // settings screen.
                        String destination = ZenCustomRuleSettings.class.getName();
                        int sourceMetricsCategory = 0;
                        if (Flags.modesApi()) {
                            // From ZenRuleCustomPolicyPreferenceController#launchCustomSettings
                            destination = ZenCustomRuleConfigSettings.class.getName();
                            sourceMetricsCategory = SettingsEnums.ZEN_CUSTOM_RULE_SOUND_SETTINGS;
                        }
                        new SubSettingLauncher(mContext)
                                .setDestination(ZenCustomRuleSettings.class.getName())
                                .setDestination(destination)
                                .setArguments(bundle)
                                .setSourceMetricsCategory(0) // TODO
                                .setSourceMetricsCategory(sourceMetricsCategory)
                                .launch();
                        return true;
                    }