Gray out toggle if isAllowChangingState is false
BUG: 343317785 Test: local tested Flag: com.android.settings.flags.enable_bluetooth_device_details_polish Change-Id: I428b5093477ec9d1ba61cbbdb8430b9e28577d99
This commit is contained in:
@@ -44,6 +44,7 @@ sealed interface DeviceSettingPreferenceModel {
|
|||||||
val icon: DeviceSettingIcon? = null,
|
val icon: DeviceSettingIcon? = null,
|
||||||
val checked: Boolean,
|
val checked: Boolean,
|
||||||
val onCheckedChange: ((Boolean) -> Unit),
|
val onCheckedChange: ((Boolean) -> Unit),
|
||||||
|
val disabled: Boolean = false,
|
||||||
val action: DeviceSettingActionModel? = null,
|
val action: DeviceSettingActionModel? = null,
|
||||||
) : DeviceSettingPreferenceModel
|
) : DeviceSettingPreferenceModel
|
||||||
|
|
||||||
|
@@ -306,6 +306,7 @@ class DeviceDetailsFragmentFormatterImpl(
|
|||||||
override val onCheckedChange = { newChecked: Boolean ->
|
override val onCheckedChange = { newChecked: Boolean ->
|
||||||
model.onCheckedChange(newChecked)
|
model.onCheckedChange(newChecked)
|
||||||
}
|
}
|
||||||
|
override val changeable = { !model.disabled }
|
||||||
override val icon: (@Composable () -> Unit)?
|
override val icon: (@Composable () -> Unit)?
|
||||||
get() {
|
get() {
|
||||||
if (model.icon == null) {
|
if (model.icon == null) {
|
||||||
|
@@ -101,6 +101,7 @@ class BluetoothDeviceDetailsViewModel(
|
|||||||
DeviceSettingStateModel.ActionSwitchPreferenceState(newState)
|
DeviceSettingStateModel.ActionSwitchPreferenceState(newState)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
disabled = !isAllowedChangingState,
|
||||||
action = action,
|
action = action,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user