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

Commit bc5711b0 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Move brightness icon to end side of track" into main

parents 6cd33417 291e6b3f
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -173,11 +173,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(),
@@ -289,25 +290,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 {