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

Commit e69c29fb authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Fix body text color in mono theme

Because it's either white or black let's use color that contrasts better with the background.

Bug: 369985720
Test: manual, turn on mono theme and see text is visible when switching between dark and light theme
Flag: com.android.systemui.shared.new_touchpad_gestures_tutorial
Change-Id: I04cc67ae631d1937e6715bc323f47daba5a79154
parent 7ac15605
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import androidx.compose.runtime.saveable.mapSaver
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.stringResource
@@ -194,7 +193,7 @@ fun TutorialDescription(
        Text(
            text = stringResource(id = bodyTextId),
            style = MaterialTheme.typography.bodyLarge,
            color = Color.White,
            color = config.colors.bodyText,
        )
    }
}
+19 −1
Original line number Diff line number Diff line
@@ -16,9 +16,12 @@

package com.android.systemui.inputdevice.tutorial.ui.composable

import androidx.annotation.ColorInt
import androidx.annotation.RawRes
import androidx.annotation.StringRes
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.core.graphics.ColorUtils
import com.airbnb.lottie.compose.LottieDynamicProperties

data class TutorialScreenConfig(
@@ -30,8 +33,23 @@ data class TutorialScreenConfig(
    data class Colors(
        val background: Color,
        val title: Color,
        val bodyText: Color,
        val animationColors: LottieDynamicProperties,
    )
    ) {
        constructor(
            background: Color,
            title: Color,
            animationColors: LottieDynamicProperties,
        ) : this(background, title, textColorOnBackground(background.toArgb()), animationColors)

        companion object {
            private fun textColorOnBackground(@ColorInt background: Int): Color {
                val whiteContrast = ColorUtils.calculateContrast(Color.White.toArgb(), background)
                val blackContrast = ColorUtils.calculateContrast(Color.Black.toArgb(), background)
                return if (whiteContrast >= blackContrast) Color.White else Color.Black
            }
        }
    }

    data class Strings(
        @StringRes val titleResId: Int,