Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45e228ee authored by Santiago Etchebehere's avatar Santiago Etchebehere
Browse files

Properly bind color of updated switches

Bug: 390233022
Test: visually verified
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: Iee31bb82e422f8554a1cf41863b1b65788a35226
parent a04e94dc
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ object ColorsFloatingSheetBinder {
        ColorUpdateBinder.bind(
            setColor = { color ->
                view.requireViewById<TextView>(R.id.color_type_tab_subhead).setTextColor(color)
                view.requireViewById<TextView>(R.id.dark_mode_toggle).setTextColor(color)
            },
            color = colorUpdateViewModel.colorOnSurface,
            shouldAnimate = isFloatingSheetActive,
+28 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ object SwitchColorBinder {
    ): Binding {
        val bindingThumb: ColorUpdateBinder.Binding
        val bindingTrack: ColorUpdateBinder.Binding
        val bindingThumbIcon: ColorUpdateBinder.Binding
        if (isChecked) {
            switch.trackDecorationTintList = ColorStateList.valueOf(COLOR_TRANSPARENT)
            bindingThumb =
@@ -60,6 +61,15 @@ object SwitchColorBinder {
                    shouldAnimate = shouldAnimateColor,
                    lifecycleOwner = lifecycleOwner,
                )
            bindingThumbIcon =
                ColorUpdateBinder.bind(
                    setColor = { color ->
                        switch.thumbIconTintList = ColorStateList.valueOf(color)
                    },
                    color = colorUpdateViewModel.colorOnPrimaryContainer,
                    shouldAnimate = shouldAnimateColor,
                    lifecycleOwner = lifecycleOwner,
                )
        } else {
            bindingThumb =
                ColorUpdateBinder.bind(
@@ -78,11 +88,29 @@ object SwitchColorBinder {
                    shouldAnimate = shouldAnimateColor,
                    lifecycleOwner = lifecycleOwner,
                )
            bindingThumbIcon =
                ColorUpdateBinder.bind(
                    setColor = { color ->
                        switch.thumbIconTintList = ColorStateList.valueOf(color)
                    },
                    color = colorUpdateViewModel.colorSurfaceContainerHighest,
                    shouldAnimate = shouldAnimateColor,
                    lifecycleOwner = lifecycleOwner,
                )
        }
        val bindingText: ColorUpdateBinder.Binding =
            ColorUpdateBinder.bind(
                setColor = { color -> switch.setTextColor(color) },
                color = colorUpdateViewModel.colorOnSurface,
                shouldAnimate = shouldAnimateColor,
                lifecycleOwner = lifecycleOwner,
            )
        return object : Binding {
            override fun destroy() {
                bindingThumb.destroy()
                bindingTrack.destroy()
                bindingThumbIcon.destroy()
                bindingText.destroy()
            }
        }
    }