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 package com.android.settings.accessibility 17 18 import android.content.Context 19 import androidx.fragment.app.Fragment 20 import com.android.settings.R 21 import com.android.settings.flags.Flags 22 import com.android.settingslib.metadata.PreferenceAvailabilityProvider 23 import com.android.settingslib.metadata.ProvidePreferenceScreen 24 import com.android.settingslib.metadata.preferenceHierarchy 25 import com.android.settingslib.preference.PreferenceScreenCreator 26 27 /** 28 * Accessibility settings for vibration intensities. 29 */ 30 // TODO(b/368360218): investigate if we still need this screen once we finish the migration. 31 // We might be able to consolidate this into VibrationScreen with PreferenceHierarchy choosing 32 // between toggle or slider preferences based on device config, depending on how overlays are done. 33 // LINT.IfChange 34 @ProvidePreferenceScreen 35 class VibrationIntensityScreen : PreferenceScreenCreator, PreferenceAvailabilityProvider { 36 override val key: String 37 get() = KEY 38 39 override val title: Int 40 get() = R.string.accessibility_vibration_settings_title 41 42 override val keywords: Int 43 get() = R.string.keywords_vibration 44 isAvailablenull45 override fun isAvailable(context: Context) = 46 context.isVibratorAvailable() && context.getSupportedVibrationIntensityLevels() > 1 47 48 override fun isFlagEnabled(context: Context): Boolean = Flags.catalystVibrationIntensityScreen() 49 50 override fun hasCompleteHierarchy() = false 51 52 override fun fragmentClass(): Class<out Fragment>? = 53 VibrationIntensitySettingsFragment::class.java 54 55 override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(this) { 56 +VibrationMainSwitchPreference() 57 } 58 59 companion object { 60 const val KEY = "vibration_intensity_screen" 61 } 62 } 63 // LINT.ThenChange(VibrationPreferenceController.java) 64