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

Commit 2239fa79 authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Scale battery text size in shade in low display sizes."

This reverts commit 13a8bae4.

Reason for revert: Droidmonitor created revert due to b/440090913. Will be verifying through ABTD before submission.

Fix: 440090913
Bug: 438705602
Bug: 413620149
Change-Id: I10a424085d846ed0ba534617ce4168be6547cf8b
parent 13a8bae4
Loading
Loading
Loading
Loading
+0 −38
Original line number Diff line number Diff line
@@ -18,12 +18,8 @@ package com.android.systemui.statusbar.pipeline.battery.ui.viewmodel

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.res.R
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
@@ -33,7 +29,6 @@ import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
@OptIn(ExperimentalMaterial3ExpressiveApi::class) // Required for bodyMediumEmphasized style
class BatteryViewModelTest : SysuiTestCase() {

    @Test
@@ -75,37 +70,4 @@ class BatteryViewModelTest : SysuiTestCase() {

        assertThat(height.value).isEqualTo(26f)
    }

    @Test
    @Composable
    @DisableFlags(Flags.FLAG_FIX_SHADE_HEADER_WRONG_ICON_SIZE)
    fun getStatusBarBatteryTextStyle_flagOff_scaleIsTwo_returnsDefautFontSize() {
        overrideResource(R.dimen.status_bar_icon_scale_factor, 2.0f)

        val baseFontSize = MaterialTheme.typography.bodyMediumEmphasized.fontSize
        val actualTextStyle = BatteryViewModel.getStatusBarBatteryTextStyle(context)
        assertThat(actualTextStyle.fontSize).isEqualTo(baseFontSize)
    }

    @Test
    @Composable
    @EnableFlags(Flags.FLAG_FIX_SHADE_HEADER_WRONG_ICON_SIZE)
    fun getStatusBarBatteryTextStyle_scaleIsOne_returnsDefaultFontSize() {
        overrideResource(R.dimen.status_bar_icon_scale_factor, 1.0f)

        val baseFontSize = MaterialTheme.typography.bodyMediumEmphasized.fontSize
        val actualTextStyle = BatteryViewModel.getStatusBarBatteryTextStyle(context)
        assertThat(actualTextStyle.fontSize).isEqualTo(baseFontSize)
    }

    @Test
    @Composable
    @EnableFlags(Flags.FLAG_FIX_SHADE_HEADER_WRONG_ICON_SIZE)
    fun getStatusBarBatteryTextStyle_scaleIsTwo_returnsScaledFontSize() {
        overrideResource(R.dimen.status_bar_icon_scale_factor, 2.0f)

        val baseFontSize = MaterialTheme.typography.bodyMediumEmphasized.fontSize
        val actualTextStyle = BatteryViewModel.getStatusBarBatteryTextStyle(context)
        assertThat(actualTextStyle.fontSize).isEqualTo(baseFontSize * 2)
    }
}
+6 −6
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.text.BasicText
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -69,11 +70,6 @@ fun BatteryWithChargeStatus(
            BatteryViewModel.getStatusBarBatteryHeight(LocalContext.current).toDp()
        }

    val textStyle =
        with(LocalDensity.current) {
            BatteryViewModel.getStatusBarBatteryTextStyle(LocalContext.current)
        }

    var bounds by remember { mutableStateOf(Rect()) }

    Row(
@@ -124,7 +120,11 @@ fun BatteryWithChargeStatus(

            textToShow?.let {
                Spacer(modifier.width(4.dp))
                BasicText(text = it, color = colorProducer, style = textStyle)
                BasicText(
                    text = it,
                    color = colorProducer,
                    style = MaterialTheme.typography.bodyMediumEmphasized,
                )
            }
        }
    }
+2 −6
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.height
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -51,11 +52,6 @@ fun BatteryWithEstimate(
            BatteryViewModel.getStatusBarBatteryHeight(LocalContext.current).toDp()
        }

    val textStyle =
        with(LocalDensity.current) {
            BatteryViewModel.getStatusBarBatteryTextStyle(LocalContext.current)
        }

    Row(
        modifier = modifier,
        horizontalArrangement = Arrangement.spacedBy(4.dp),
@@ -73,7 +69,7 @@ fun BatteryWithEstimate(
                Text(
                    text = it,
                    color = textColor,
                    style = textStyle,
                    style = MaterialTheme.typography.bodyMediumEmphasized,
                    maxLines = 1,
                    modifier = Modifier.basicMarquee(iterations = 1),
                )
+0 −22
Original line number Diff line number Diff line
@@ -17,14 +17,9 @@
package com.android.systemui.statusbar.pipeline.battery.ui.viewmodel

import android.content.Context
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.sp
import com.android.systemui.Flags
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.lifecycle.ExclusiveActivatable
@@ -313,23 +308,6 @@ sealed class BatteryViewModel(
            }
        }

        /**
         * [TextStyle] for status bar battery text [Composable]s. The size of this text will scale
         * consistent with display size changes
         */
        @OptIn(ExperimentalMaterial3ExpressiveApi::class) // Required for bodyMediumEmphasized style
        @Composable
        fun getStatusBarBatteryTextStyle(context: Context): TextStyle {
            val baseStyle = MaterialTheme.typography.bodyMediumEmphasized
            if (!Flags.fixShadeHeaderWrongIconSize()) {
                return baseStyle
            }

            val customStyle =
                baseStyle.copy(fontSize = baseStyle.fontSize * getScaleFactor(context))
            return customStyle
        }

        private fun getScaleFactor(context: Context): Float {
            return context.resources.getFloat(R.dimen.status_bar_icon_scale_factor)
        }