blob: cd1a08a1ab19f8d3c556f70d718a1b28cceb97b3 [file] [log] [blame]
Julia Reynolds4cf8bfd2018-04-23 12:24:21 -04001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings.notification;
18
19import android.app.NotificationManager.Policy;
20import android.content.Context;
Fan Zhangde117042018-09-04 13:52:15 -070021
Aurimas Liutikas03fcde32018-04-17 11:22:43 -070022import androidx.preference.Preference;
23import androidx.preference.PreferenceScreen;
Julia Reynolds4cf8bfd2018-04-23 12:24:21 -040024
25import com.android.internal.logging.nano.MetricsProto;
26import com.android.settingslib.core.lifecycle.Lifecycle;
27
28public class ZenModeVisEffectsAllPreferenceController
29 extends AbstractZenModePreferenceController
30 implements ZenCustomRadioButtonPreference.OnRadioButtonClickListener {
31
Beverly2f2a4d92018-05-18 14:33:36 -040032 private final String KEY;
33 private ZenCustomRadioButtonPreference mPreference;
34
Julia Reynolds4cf8bfd2018-04-23 12:24:21 -040035 protected static final int EFFECTS = Policy.SUPPRESSED_EFFECT_SCREEN_OFF
36 | Policy.SUPPRESSED_EFFECT_SCREEN_ON
37 | Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
38 | Policy.SUPPRESSED_EFFECT_LIGHTS
39 | Policy.SUPPRESSED_EFFECT_PEEK
40 | Policy.SUPPRESSED_EFFECT_STATUS_BAR
41 | Policy.SUPPRESSED_EFFECT_BADGE
42 | Policy.SUPPRESSED_EFFECT_AMBIENT
43 | Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
44
45 public ZenModeVisEffectsAllPreferenceController(Context context, Lifecycle lifecycle,
46 String key) {
47 super(context, key, lifecycle);
Beverly2f2a4d92018-05-18 14:33:36 -040048 KEY = key;
49 }
50
51 @Override
52 public void displayPreference(PreferenceScreen screen) {
53 super.displayPreference(screen);
54 mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(KEY);
55 mPreference.setOnRadioButtonClickListener(this);
Julia Reynolds4cf8bfd2018-04-23 12:24:21 -040056 }
57
58 @Override
59 public boolean isAvailable() {
60 return true;
61 }
62
63 @Override
64 public void updateState(Preference preference) {
65 super.updateState(preference);
66
67 boolean everythingBlocked = Policy.areAllVisualEffectsSuppressed(
68 mBackend.mPolicy.suppressedVisualEffects);
Beverly2f2a4d92018-05-18 14:33:36 -040069 mPreference.setChecked(everythingBlocked);
Julia Reynolds4cf8bfd2018-04-23 12:24:21 -040070 }
71
72 @Override
73 public void onRadioButtonClick(ZenCustomRadioButtonPreference p) {
74 mMetricsFeatureProvider.action(mContext,
75 MetricsProto.MetricsEvent.ACTION_ZEN_SOUND_AND_VIS_EFFECTS, true);
76 mBackend.saveVisualEffectsPolicy(EFFECTS, true);
77 }
78}