Loading packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/preference/TwoTargetSwitchPreference.kt +1 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import com.android.settingslib.spa.widget.ui.SettingsSwitch @Composable fun TwoTargetSwitchPreference( model: SwitchPreferenceModel, icon: @Composable (() -> Unit)? = null, primaryEnabled: () -> Boolean = { true }, primaryOnClick: (() -> Unit)?, ) { Loading @@ -33,7 +32,7 @@ fun TwoTargetSwitchPreference( summary = model.summary, primaryEnabled = primaryEnabled, primaryOnClick = primaryOnClick, icon = icon, icon = model.icon, ) { SettingsSwitch( checked = model.checked(), Loading packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListTwoTargetSwitchItem.kt +3 −1 Original line number Diff line number Diff line Loading @@ -33,11 +33,13 @@ fun <T : AppRecord> AppListItemModel<T>.AppListTwoTargetSwitchItem( model = object : SwitchPreferenceModel { override val title = label override val summary = this@AppListTwoTargetSwitchItem.summary override val icon = @Composable { AppIcon(record.app, SettingsDimension.appIconItemSize) } override val checked = checked override val changeable = changeable override val onCheckedChange = onCheckedChange }, icon = { AppIcon(record.app, SettingsDimension.appIconItemSize) }, primaryOnClick = onClick, ) } packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/preference/RestrictedSwitchPreferenceModel.kt +2 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ internal class RestrictedSwitchPreferenceModel( checked = model.checked, ) override val icon = model.icon override val checked = when (restrictedMode) { null -> ({ null }) is NoRestricted -> model.checked Loading packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/preference/RestrictedTwoTargetSwitchPreference.kt +1 −5 Original line number Diff line number Diff line Loading @@ -29,14 +29,12 @@ import com.android.settingslib.spaprivileged.template.preference.RestrictedSwitc @Composable fun RestrictedTwoTargetSwitchPreference( model: SwitchPreferenceModel, icon: @Composable (() -> Unit)? = null, restrictions: Restrictions, primaryEnabled: () -> Boolean = { true }, primaryOnClick: (() -> Unit)?, ) { RestrictedTwoTargetSwitchPreference( model = model, icon = icon, primaryEnabled = primaryEnabled, primaryOnClick = primaryOnClick, restrictions = restrictions, Loading @@ -48,21 +46,19 @@ fun RestrictedTwoTargetSwitchPreference( @Composable internal fun RestrictedTwoTargetSwitchPreference( model: SwitchPreferenceModel, icon: @Composable (() -> Unit)? = null, primaryEnabled: () -> Boolean = { true }, primaryOnClick: (() -> Unit)?, restrictions: Restrictions, restrictionsProviderFactory: RestrictionsProviderFactory, ) { if (restrictions.isEmpty()) { TwoTargetSwitchPreference(model, icon, primaryEnabled, primaryOnClick) TwoTargetSwitchPreference(model, primaryEnabled, primaryOnClick) return } val restrictedMode = restrictionsProviderFactory.rememberRestrictedMode(restrictions).value RestrictedSwitchWrapper(model, restrictedMode) { restrictedModel -> TwoTargetSwitchPreference( model = restrictedModel, icon = icon, primaryEnabled = restrictedMode.restrictEnabled(primaryEnabled), primaryOnClick = restrictedMode.restrictOnClick(primaryOnClick), ) Loading Loading
packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/preference/TwoTargetSwitchPreference.kt +1 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import com.android.settingslib.spa.widget.ui.SettingsSwitch @Composable fun TwoTargetSwitchPreference( model: SwitchPreferenceModel, icon: @Composable (() -> Unit)? = null, primaryEnabled: () -> Boolean = { true }, primaryOnClick: (() -> Unit)?, ) { Loading @@ -33,7 +32,7 @@ fun TwoTargetSwitchPreference( summary = model.summary, primaryEnabled = primaryEnabled, primaryOnClick = primaryOnClick, icon = icon, icon = model.icon, ) { SettingsSwitch( checked = model.checked(), Loading
packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListTwoTargetSwitchItem.kt +3 −1 Original line number Diff line number Diff line Loading @@ -33,11 +33,13 @@ fun <T : AppRecord> AppListItemModel<T>.AppListTwoTargetSwitchItem( model = object : SwitchPreferenceModel { override val title = label override val summary = this@AppListTwoTargetSwitchItem.summary override val icon = @Composable { AppIcon(record.app, SettingsDimension.appIconItemSize) } override val checked = checked override val changeable = changeable override val onCheckedChange = onCheckedChange }, icon = { AppIcon(record.app, SettingsDimension.appIconItemSize) }, primaryOnClick = onClick, ) }
packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/preference/RestrictedSwitchPreferenceModel.kt +2 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ internal class RestrictedSwitchPreferenceModel( checked = model.checked, ) override val icon = model.icon override val checked = when (restrictedMode) { null -> ({ null }) is NoRestricted -> model.checked Loading
packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/preference/RestrictedTwoTargetSwitchPreference.kt +1 −5 Original line number Diff line number Diff line Loading @@ -29,14 +29,12 @@ import com.android.settingslib.spaprivileged.template.preference.RestrictedSwitc @Composable fun RestrictedTwoTargetSwitchPreference( model: SwitchPreferenceModel, icon: @Composable (() -> Unit)? = null, restrictions: Restrictions, primaryEnabled: () -> Boolean = { true }, primaryOnClick: (() -> Unit)?, ) { RestrictedTwoTargetSwitchPreference( model = model, icon = icon, primaryEnabled = primaryEnabled, primaryOnClick = primaryOnClick, restrictions = restrictions, Loading @@ -48,21 +46,19 @@ fun RestrictedTwoTargetSwitchPreference( @Composable internal fun RestrictedTwoTargetSwitchPreference( model: SwitchPreferenceModel, icon: @Composable (() -> Unit)? = null, primaryEnabled: () -> Boolean = { true }, primaryOnClick: (() -> Unit)?, restrictions: Restrictions, restrictionsProviderFactory: RestrictionsProviderFactory, ) { if (restrictions.isEmpty()) { TwoTargetSwitchPreference(model, icon, primaryEnabled, primaryOnClick) TwoTargetSwitchPreference(model, primaryEnabled, primaryOnClick) return } val restrictedMode = restrictionsProviderFactory.rememberRestrictedMode(restrictions).value RestrictedSwitchWrapper(model, restrictedMode) { restrictedModel -> TwoTargetSwitchPreference( model = restrictedModel, icon = icon, primaryEnabled = restrictedMode.restrictEnabled(primaryEnabled), primaryOnClick = restrictedMode.restrictOnClick(primaryOnClick), ) Loading