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

Commit 291e6b3f authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Move brightness icon to end side of track

Test: manual
Test: atest BrightnessSliderMotionTest
Fixes: 416536760
Flag: EXEMPT bugfix
Change-Id: Ic1ec6e432756e69220d4e98c7f243edc7cbf15f8
parent 894af0f1
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -177,11 +177,12 @@ fun BrightnessSlider(

    val activeIconColor = colors.activeTickColor
    val inactiveIconColor = colors.inactiveTickColor
    // Offset from the right
    val trackIcon: DrawScope.(Offset, Color, Float) -> Unit = remember {
        { offset, color, alpha ->
            val rtl = layoutDirection == LayoutDirection.Rtl
            scale(if (rtl) -1f else 1f, 1f) {
                translate(offset.x + IconPadding.toPx(), offset.y) {
                translate(offset.x - IconPadding.toPx() - IconSize.toSize().width, offset.y) {
                    with(painter) {
                        draw(
                            IconSize.toSize(),
@@ -293,25 +294,26 @@ fun BrightnessSlider(

                            val activeTrackWidth = activeTrackEnd - activeTrackStart
                            val inactiveTrackWidth = inactiveTrackEnd - inactiveTrackStart

                            if (
                                IconSize.toSize().width < activeTrackWidth - IconPadding.toPx() * 2
                            ) {
                                showIconActive = true
                                trackIcon(
                                    Offset(activeTrackStart, yOffset),
                                    activeIconColor,
                                    iconActiveAlphaAnimatable.value,
                                )
                            } else if (
                                IconSize.toSize().width <
                                    inactiveTrackWidth - IconPadding.toPx() * 2
                            ) {
                                showIconActive = false
                                trackIcon(
                                    Offset(inactiveTrackStart, yOffset),
                                    Offset(inactiveTrackEnd, yOffset),
                                    inactiveIconColor,
                                    iconInactiveAlphaAnimatable.value,
                                )
                            } else if (
                                IconSize.toSize().width < activeTrackWidth - IconPadding.toPx() * 2
                            ) {
                                showIconActive = true
                                trackIcon(
                                    Offset(activeTrackEnd, yOffset),
                                    activeIconColor,
                                    iconActiveAlphaAnimatable.value,
                                )
                            }
                        },
                trackCornerSize = SliderTrackRoundedCorner,
+59 −56
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
    720,
    736,
    752,
    768,
    "after"
  ],
  "features": [
@@ -56,62 +57,7 @@
      "name": "activeIconAlpha_activeIconAlpha",
      "type": "float",
      "data_points": [
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        0.5782508,
        0.09543866,
        8.595586E-4,
        0,
        0,
        0,
        0,
        0,
        0
      ]
    },
    {
      "name": "inactiveIconAlpha_inactiveIconAlpha",
      "type": "float",
      "data_points": [
        0,
        0,
        0,
@@ -163,6 +109,63 @@
        0.9986459,
        1
      ]
    },
    {
      "name": "inactiveIconAlpha_inactiveIconAlpha",
      "type": "float",
      "data_points": [
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        0.5782508,
        0.09543866,
        0.0008595586,
        0,
        0,
        0,
        0,
        0,
        0
      ]
    }
  ]
}
 No newline at end of file
+7 −3
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.swipeLeft
import androidx.compose.ui.test.swipeRight
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import com.android.compose.theme.PlatformTheme
@@ -89,7 +89,7 @@ class BrightnessSliderMotionTest : SysuiTestCase() {
        motionTestRule.runTest(timeout = 30.seconds) {
            val motion =
                recordMotion(
                    content = { BrightnessSliderUnderTest(100) },
                    content = { BrightnessSliderUnderTest(0) },
                    ComposeRecordingSpec(
                        MotionControl(delayReadyToPlay = { awaitCondition { !isAnimating } }) {
                            coroutineScope {
@@ -97,7 +97,11 @@ class BrightnessSliderMotionTest : SysuiTestCase() {
                                    performTouchInputAsync(
                                        onNode(hasTestTag("com.android.systemui:id/slider"))
                                    ) {
                                        swipeLeft(startX = right, endX = left, durationMillis = 500)
                                        swipeRight(
                                            startX = left,
                                            endX = right,
                                            durationMillis = 500,
                                        )
                                    }
                                }
                                val animationEnd = async {