• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 static android.provider.Settings.Secure.SHOW_NOTIFICATION_SNOOZE;
20 
21 import android.content.Context;
22 import android.provider.Settings;
23 
24 import com.android.settings.core.TogglePreferenceController;
25 
26 import androidx.annotation.VisibleForTesting;
27 
28 public class SnoozeNotificationPreferenceController extends TogglePreferenceController {
29 
30     private static final String TAG = "SnoozeNotifPrefContr";
31     @VisibleForTesting
32     static final int ON = 1;
33     @VisibleForTesting
34     static final int OFF = 0;
35 
SnoozeNotificationPreferenceController(Context context, String preferenceKey)36     public SnoozeNotificationPreferenceController(Context context, String preferenceKey) {
37         super(context, preferenceKey);
38     }
39 
40     @Override
getAvailabilityStatus()41     public int getAvailabilityStatus() {
42         return AVAILABLE;
43     }
44 
45     @Override
isChecked()46     public boolean isChecked() {
47         return Settings.Secure.getInt(mContext.getContentResolver(),
48                 SHOW_NOTIFICATION_SNOOZE, OFF) == ON;
49     }
50 
51     @Override
setChecked(boolean isChecked)52     public boolean setChecked(boolean isChecked) {
53         return Settings.Secure.putInt(mContext.getContentResolver(),
54                 SHOW_NOTIFICATION_SNOOZE, isChecked ? ON : OFF);
55     }
56 }
57