2 * Copyright (C) 2018 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings.notification;
19 import android.app.NotificationManager.Policy;
20 import android.content.Context;
21 import androidx.preference.Preference;
22 import androidx.preference.PreferenceScreen;
24 import com.android.internal.logging.nano.MetricsProto;
25 import com.android.settingslib.core.lifecycle.Lifecycle;
27 public class ZenModeVisEffectsNonePreferenceController
28 extends AbstractZenModePreferenceController
29 implements ZenCustomRadioButtonPreference.OnRadioButtonClickListener {
31 private ZenCustomRadioButtonPreference mPreference;
33 protected static final int EFFECTS = Policy.SUPPRESSED_EFFECT_SCREEN_OFF
34 | Policy.SUPPRESSED_EFFECT_SCREEN_ON
35 | Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
36 | Policy.SUPPRESSED_EFFECT_LIGHTS
37 | Policy.SUPPRESSED_EFFECT_PEEK
38 | Policy.SUPPRESSED_EFFECT_STATUS_BAR
39 | Policy.SUPPRESSED_EFFECT_BADGE
40 | Policy.SUPPRESSED_EFFECT_AMBIENT
41 | Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
43 public ZenModeVisEffectsNonePreferenceController(Context context, Lifecycle lifecycle,
45 super(context, key, lifecycle);
49 public void displayPreference(PreferenceScreen screen) {
50 super.displayPreference(screen);
51 mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
52 mPreference.setOnRadioButtonClickListener(this);
56 public boolean isAvailable() {
61 public void updateState(Preference preference) {
62 super.updateState(preference);
64 boolean nothingBlocked = mBackend.mPolicy.suppressedVisualEffects == 0;
65 mPreference.setChecked(nothingBlocked);
69 public void onRadioButtonClick(ZenCustomRadioButtonPreference preference) {
70 mMetricsFeatureProvider.action(mContext,
71 MetricsProto.MetricsEvent.ACTION_ZEN_SOUND_ONLY, true);
72 mBackend.saveVisualEffectsPolicy(EFFECTS, false);