• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.bluetooth.ui.model
18 
19 import android.content.Intent
20 import com.android.settingslib.bluetooth.devicesettings.DeviceSettingId
21 import com.android.settingslib.bluetooth.devicesettings.shared.model.DeviceSettingActionModel
22 import com.android.settingslib.bluetooth.devicesettings.shared.model.DeviceSettingIcon
23 import com.android.settingslib.bluetooth.devicesettings.shared.model.ToggleModel
24 
25 /** Models a device setting preference. */
26 sealed interface DeviceSettingPreferenceModel {
27     @DeviceSettingId
28     val id: Int
29 
30     /** Models a plain preference. */
31     data class PlainPreference(
32         @DeviceSettingId override val id: Int,
33         val title: String,
34         val summary: String? = null,
35         val icon: DeviceSettingIcon? = null,
36         val action: DeviceSettingActionModel? = null,
37     ) : DeviceSettingPreferenceModel
38 
39     /** Models a switch preference. */
40     data class SwitchPreference(
41         @DeviceSettingId override val id: Int,
42         val title: String,
43         val summary: String? = null,
44         val icon: DeviceSettingIcon? = null,
45         val checked: Boolean,
46         val onCheckedChange: ((Boolean) -> Unit),
47         val disabled: Boolean = false,
48         val action: DeviceSettingActionModel? = null,
49     ) : DeviceSettingPreferenceModel
50 
51     /** Models a multi-toggle preference. */
52     data class MultiTogglePreference(
53         @DeviceSettingId override val id: Int,
54         val title: String,
55         val toggles: List<ToggleModel>,
56         val isActive: Boolean,
57         val selectedIndex: Int,
58         val isAllowedChangingState: Boolean,
59         val onSelectedChange: (Int) -> Unit,
60     ) : DeviceSettingPreferenceModel
61 
62     /** Models a footer preference. */
63     data class FooterPreference(
64         @DeviceSettingId override val id: Int,
65         val footerText: String,
66     ) : DeviceSettingPreferenceModel
67 
68     /** Models a preference which could navigate to more settings fragment. */
69     data class MoreSettingsPreference(
70         @DeviceSettingId override val id: Int,
71     ) : DeviceSettingPreferenceModel
72 
73     /** Models a help button on the top right corner of the fragment. */
74     data class HelpPreference(
75         @DeviceSettingId override val id: Int,
76         val icon: DeviceSettingIcon,
77         val intent: Intent,
78     ) : DeviceSettingPreferenceModel
79 }
80