blob: 1427d5a4412a144dea94e9e8fc183483a99f46c9 [file] [log] [blame]
Doris Ling1b3ec042016-11-30 17:33:50 -08001/*
2 * Copyright (C) 2016 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
Doris Ling4d8a9bd2017-02-15 12:04:57 -080019import android.app.NotificationManager;
Doris Ling1b3ec042016-11-30 17:33:50 -080020import android.content.Context;
Doris Ling4d8a9bd2017-02-15 12:04:57 -080021import android.support.v7.preference.Preference;
22import com.android.settings.R;
Doris Ling1b3ec042016-11-30 17:33:50 -080023
24public class ZenModePreferenceController extends AdjustVolumeRestrictedPreferenceController {
25
26 private static final String KEY_ZEN_MODE = "zen_mode";
Doris Ling4d8a9bd2017-02-15 12:04:57 -080027 private String mSummaryPrefix;
28
29 private ZenModeSettings.SummaryBuilder mSummaryBuilder;
Doris Ling1b3ec042016-11-30 17:33:50 -080030
31 public ZenModePreferenceController(Context context) {
32 super(context);
Doris Ling4d8a9bd2017-02-15 12:04:57 -080033 mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
34 mSummaryPrefix = context.getString(R.string.zen_mode_priority_settings_title) + " ";
Doris Ling1b3ec042016-11-30 17:33:50 -080035 }
36
37 @Override
Doris Ling1b3ec042016-11-30 17:33:50 -080038 public String getPreferenceKey() {
39 return KEY_ZEN_MODE;
40 }
41
42 @Override
43 public boolean isAvailable() {
44 return true;
45 }
46
Doris Ling4d8a9bd2017-02-15 12:04:57 -080047 @Override
48 public void updateState(Preference preference) {
49 super.updateState(preference);
50 if (preference.isEnabled()) {
51 preference.setSummary(mSummaryPrefix + mSummaryBuilder.getPrioritySettingSummary(
52 NotificationManager.from(mContext).getNotificationPolicy()));
53 }
54 }
Doris Ling1b3ec042016-11-30 17:33:50 -080055}