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.view.View; 21 import android.widget.Button; 22 import android.widget.Toast; 23 24 import androidx.preference.Preference; 25 26 import com.android.settings.R; 27 import com.android.settings.core.BasePreferenceController; 28 import com.android.settingslib.widget.LayoutPreference; 29 30 public class ImportanceResetPreferenceController extends BasePreferenceController implements 31 View.OnClickListener { 32 33 public static final String KEY = "asst_importance_reset"; 34 private static final String TAG = "ResetImportanceButton"; 35 36 private NotificationBackend mBackend; 37 private Button mButton; 38 ImportanceResetPreferenceController(Context context, String key)39 public ImportanceResetPreferenceController(Context context, String key) { 40 super(context, key); 41 mBackend = new NotificationBackend(); 42 } 43 44 @Override getPreferenceKey()45 public String getPreferenceKey() { 46 return KEY; 47 } 48 49 @Override updateState(Preference preference)50 public void updateState(Preference preference) { 51 super.updateState(preference); 52 53 mButton = ((LayoutPreference) preference) 54 .findViewById(R.id.reset_importance_button); 55 mButton.setOnClickListener(this); 56 } 57 58 @Override onClick(View v)59 public void onClick(View v) { 60 mBackend.resetNotificationImportance(); 61 Toast.makeText(mContext, R.string.reset_importance_completed, Toast.LENGTH_SHORT) 62 .show(); 63 } 64 65 @Override getAvailabilityStatus()66 public int getAvailabilityStatus() { 67 return AVAILABLE; 68 } 69 70 } 71 72