1 /* 2 * Copyright (C) 2023 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.accessibility; 18 19 import android.content.Context; 20 import android.util.FeatureFlagUtils; 21 22 import com.android.settings.R; 23 import com.android.settings.core.BasePreferenceController; 24 25 /** 26 * Controller for flash notifications. 27 */ 28 public class FlashNotificationsPreferenceController extends BasePreferenceController { 29 FlashNotificationsPreferenceController(Context context, String key)30 public FlashNotificationsPreferenceController(Context context, String key) { 31 super(context, key); 32 } 33 34 @Override getAvailabilityStatus()35 public int getAvailabilityStatus() { 36 boolean isFeatureOn = FeatureFlagUtils.isEnabled(mContext, 37 FeatureFlagUtils.SETTINGS_FLASH_NOTIFICATIONS); 38 return isFeatureOn ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; 39 } 40 41 @Override getSummary()42 public CharSequence getSummary() { 43 final int res; 44 45 switch (FlashNotificationsUtil.getFlashNotificationsState(mContext)) { 46 case FlashNotificationsUtil.State.CAMERA: 47 res = R.string.flash_notifications_summary_on_camera; 48 break; 49 case FlashNotificationsUtil.State.SCREEN: 50 res = R.string.flash_notifications_summary_on_screen; 51 break; 52 case FlashNotificationsUtil.State.CAMERA_SCREEN: 53 res = R.string.flash_notifications_summary_on_camera_and_screen; 54 break; 55 case FlashNotificationsUtil.State.OFF: 56 default: 57 res = R.string.flash_notifications_summary_off; 58 break; 59 } 60 61 return mContext.getString(res); 62 } 63 } 64