1 /* 2 * Copyright (C) 2024 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.modes; 18 19 import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID; 20 21 import android.content.Context; 22 import android.os.Bundle; 23 24 import androidx.annotation.NonNull; 25 import androidx.annotation.Nullable; 26 import androidx.preference.Preference; 27 28 import com.android.settings.R; 29 import com.android.settings.core.SubSettingLauncher; 30 import com.android.settingslib.widget.ActionButtonsPreference; 31 32 class ZenModeActionsPreferenceController extends AbstractZenModePreferenceController { 33 ZenModeActionsPreferenceController(@onNull Context context, @NonNull String key, @Nullable ZenModesBackend backend)34 ZenModeActionsPreferenceController(@NonNull Context context, @NonNull String key, 35 @Nullable ZenModesBackend backend) { 36 super(context, key, backend); 37 } 38 39 @Override updateState(Preference preference, @NonNull ZenMode zenMode)40 void updateState(Preference preference, @NonNull ZenMode zenMode) { 41 ActionButtonsPreference buttonsPreference = (ActionButtonsPreference) preference; 42 43 // TODO: b/346278854 - Add rename action (with setButton1Enabled(zenMode.canEditName()) 44 buttonsPreference.setButton1Text(R.string.zen_mode_action_change_name); 45 buttonsPreference.setButton1Icon(R.drawable.ic_mode_edit); 46 buttonsPreference.setButton1Enabled(false); 47 48 buttonsPreference.setButton2Text(R.string.zen_mode_action_change_icon); 49 buttonsPreference.setButton2Icon(R.drawable.ic_zen_mode_action_change_icon); 50 buttonsPreference.setButton2Enabled(zenMode.canEditIcon()); 51 buttonsPreference.setButton2OnClickListener(v -> { 52 Bundle bundle = new Bundle(); 53 bundle.putString(MODE_ID, zenMode.getId()); 54 new SubSettingLauncher(mContext) 55 .setDestination(ZenModeIconPickerFragment.class.getName()) 56 // TODO: b/332937635 - Update metrics category 57 .setSourceMetricsCategory(0) 58 .setArguments(bundle) 59 .launch(); 60 }); 61 } 62 } 63