Close ZenModeScheduleRuleSettingsActivity when rule is deleted

This fixes an issue where the ZenRuleButtonsPreferenceController was redirecting to the rule list, but the container fragment was still trying to refresh the rule, leading to a "rule not found" toast. This also makes the transition look nicer, as it's a "back" instead of a "forward" animation now.

Fixes: 244103559
Test: Manually on phone & tablet
Change-Id: Ie26511dcaec4c7976f488936cdc6d417110ca1b1
This commit is contained in:
Matías Hernández
2023-03-13 11:01:13 +01:00
parent 850993d166
commit 89f93a9bb1
2 changed files with 12 additions and 8 deletions

View File

@@ -39,11 +39,11 @@ public class ZenRuleButtonsPreferenceController extends AbstractZenModePreferenc
implements PreferenceControllerMixin {
public static final String KEY = "zen_action_buttons";
private final PreferenceFragmentCompat mFragment;
private final ZenModeRuleSettingsBase mFragment;
private String mId;
private AutomaticZenRule mRule;
public ZenRuleButtonsPreferenceController(Context context, PreferenceFragmentCompat fragment,
public ZenRuleButtonsPreferenceController(Context context, ZenModeRuleSettingsBase fragment,
Lifecycle lc) {
super(context, KEY, lc);
mFragment = fragment;
@@ -106,12 +106,7 @@ public class ZenRuleButtonsPreferenceController extends AbstractZenModePreferenc
mBackend.removeZenRule(id);
mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_ZEN_DELETE_RULE_OK);
new SubSettingLauncher(mContext)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
.setDestination(ZenModeAutomationSettings.class.getName())
.setSourceMetricsCategory(MetricsProto.MetricsEvent
.NOTIFICATION_ZEN_MODE_AUTOMATION)
.launch();
mFragment.onRuleRemoved();
}
});
}