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.connecteddevice 17 18 import android.content.Context 19 import com.android.settings.R 20 import com.android.settings.Settings.BluetoothDashboardActivity 21 import com.android.settings.flags.Flags 22 import com.android.settings.utils.makeLaunchIntent 23 import com.android.settingslib.metadata.PreferenceMetadata 24 import com.android.settingslib.metadata.ProvidePreferenceScreen 25 import com.android.settingslib.metadata.preferenceHierarchy 26 import com.android.settingslib.preference.PreferenceScreenCreator 27 28 @ProvidePreferenceScreen(BluetoothDashboardScreen.KEY) 29 class BluetoothDashboardScreen : PreferenceScreenCreator { 30 override val key: String 31 get() = KEY 32 33 override val title: Int 34 get() = R.string.bluetooth_settings_title 35 36 override val icon: Int 37 get() = R.drawable.ic_settings_bluetooth 38 isFlagEnablednull39 override fun isFlagEnabled(context: Context) = Flags.catalystBluetoothSwitchbarScreen() 40 41 override fun hasCompleteHierarchy() = false 42 43 override fun fragmentClass() = BluetoothDashboardFragment::class.java 44 45 override fun getLaunchIntent(context: Context, metadata: PreferenceMetadata?) = 46 makeLaunchIntent(context, BluetoothDashboardActivity::class.java, metadata?.key) 47 48 override fun getPreferenceHierarchy(context: Context) = 49 preferenceHierarchy(context, this) { 50 val bluetoothDataStore = BluetoothPreference.createDataStore(context) 51 +BluetoothPreference(bluetoothDataStore) 52 +BluetoothFooterPreference(bluetoothDataStore) 53 } 54 55 companion object { 56 const val KEY = "bluetooth_switchbar_screen" 57 } 58 } 59