1 /*
2  * Copyright (C) 2020 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.content.Context;
20 import android.text.TextUtils;
21 import android.widget.Toast;
22 
23 import androidx.preference.Preference;
24 
25 import com.android.settings.R;
26 import com.android.settings.core.BasePreferenceController;
27 
28 public class ImportanceResetPreferenceController extends BasePreferenceController {
29 
30     public static final String KEY = "asst_importance_reset";
31     private static final String TAG = "ResetImportanceButton";
32 
33     private NotificationBackend mBackend;
34 
ImportanceResetPreferenceController(Context context, String key)35     public ImportanceResetPreferenceController(Context context, String key) {
36         super(context, key);
37         mBackend = new NotificationBackend();
38     }
39 
40     @Override
getPreferenceKey()41     public String getPreferenceKey() {
42         return KEY;
43     }
44 
45     @Override
handlePreferenceTreeClick(Preference preference)46     public boolean handlePreferenceTreeClick(Preference preference) {
47         if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
48             return false;
49         }
50         mBackend.resetNotificationImportance();
51         Toast.makeText(mContext, R.string.reset_importance_completed, Toast.LENGTH_SHORT)
52                 .show();
53         return true;
54     }
55 
56     @Override
getAvailabilityStatus()57     public int getAvailabilityStatus() {
58         return AVAILABLE;
59     }
60 
61 }
62 
63