• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package com.android.settings.notification;
18 
19 import android.app.NotificationManager.Policy;
20 import android.app.settings.SettingsEnums;
21 import android.content.Context;
22 
23 import androidx.preference.Preference;
24 import androidx.preference.PreferenceScreen;
25 
26 import com.android.settingslib.core.lifecycle.Lifecycle;
27 
28 public class ZenModeVisEffectsAllPreferenceController
29         extends AbstractZenModePreferenceController
30         implements ZenCustomRadioButtonPreference.OnRadioButtonClickListener {
31 
32     private ZenCustomRadioButtonPreference mPreference;
33 
34     protected static final int EFFECTS = Policy.SUPPRESSED_EFFECT_SCREEN_OFF
35             | Policy.SUPPRESSED_EFFECT_SCREEN_ON
36             | Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
37             | Policy.SUPPRESSED_EFFECT_LIGHTS
38             | Policy.SUPPRESSED_EFFECT_PEEK
39             | Policy.SUPPRESSED_EFFECT_STATUS_BAR
40             | Policy.SUPPRESSED_EFFECT_BADGE
41             | Policy.SUPPRESSED_EFFECT_AMBIENT
42             | Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
43 
ZenModeVisEffectsAllPreferenceController(Context context, Lifecycle lifecycle, String key)44     public ZenModeVisEffectsAllPreferenceController(Context context, Lifecycle lifecycle,
45             String key) {
46         super(context, key, lifecycle);
47     }
48 
49     @Override
displayPreference(PreferenceScreen screen)50     public void displayPreference(PreferenceScreen screen) {
51         super.displayPreference(screen);
52         mPreference = screen.findPreference(getPreferenceKey());
53         mPreference.setOnRadioButtonClickListener(this);
54     }
55 
56     @Override
isAvailable()57     public boolean isAvailable() {
58         return true;
59     }
60 
61     @Override
updateState(Preference preference)62     public void updateState(Preference preference) {
63         super.updateState(preference);
64 
65         boolean everythingBlocked = Policy.areAllVisualEffectsSuppressed(
66                 mBackend.mPolicy.suppressedVisualEffects);
67         mPreference.setChecked(everythingBlocked);
68     }
69 
70     @Override
onRadioButtonClick(ZenCustomRadioButtonPreference p)71     public void onRadioButtonClick(ZenCustomRadioButtonPreference p) {
72         mMetricsFeatureProvider.action(mContext,
73                 SettingsEnums.ACTION_ZEN_SOUND_AND_VIS_EFFECTS, true);
74         mBackend.saveVisualEffectsPolicy(EFFECTS, true);
75     }
76 }
77