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

Commit a015d7ee authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge changes from topics "caitlinshk-chips-color", "caitlinshk-text-truncation" into main

* changes:
  [SB][Notif] Hide text in chips if not *all* of the text fits.
  [SB][Notif] Add a subtle outline to notification chips.
  [SB][Notif] Update notif chips to use system theme colors.
parents 289ca076 31f9b781
Loading
Loading
Loading
Loading
+4 −71
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.activityStarter
import com.android.systemui.res.R
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.chips.ui.model.ColorsModel
import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
@@ -265,91 +264,25 @@ class CallChipViewModelTest : SysuiTestCase() {
        }

    @Test
    fun chip_positiveStartTime_notPromoted_colorsAreThemed() =
    fun chip_positiveStartTime_colorsAreAccentThemed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(inCallModel(startTimeMs = 1000, promotedContent = null))

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(ColorsModel.Themed)
                .isEqualTo(ColorsModel.AccentThemed)
        }

    @Test
    fun chip_zeroStartTime_notPromoted_colorsAreThemed() =
    fun chip_zeroStartTime_colorsAreAccentThemed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(inCallModel(startTimeMs = 0, promotedContent = null))

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(ColorsModel.Themed)
        }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME)
    fun chip_positiveStartTime_promoted_notifChipsFlagOff_colorsAreThemed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 1000, promotedContent = PROMOTED_CONTENT_WITH_COLOR)
            )

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(ColorsModel.Themed)
        }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME)
    fun chip_zeroStartTime_promoted_notifChipsFlagOff_colorsAreThemed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 0, promotedContent = PROMOTED_CONTENT_WITH_COLOR)
            )

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(ColorsModel.Themed)
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun chip_positiveStartTime_promoted_notifChipsFlagOn_colorsAreCustom() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 1000, promotedContent = PROMOTED_CONTENT_WITH_COLOR)
            )

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(
                    ColorsModel.Custom(
                        backgroundColorInt = PROMOTED_BACKGROUND_COLOR,
                        primaryTextColorInt = PROMOTED_PRIMARY_TEXT_COLOR,
                    )
                )
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun chip_zeroStartTime_promoted_notifChipsFlagOff_colorsAreCustom() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 0, promotedContent = PROMOTED_CONTENT_WITH_COLOR)
            )

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(
                    ColorsModel.Custom(
                        backgroundColorInt = PROMOTED_BACKGROUND_COLOR,
                        primaryTextColorInt = PROMOTED_PRIMARY_TEXT_COLOR,
                    )
                )
                .isEqualTo(ColorsModel.AccentThemed)
        }

    @Test
+2 −5
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ class NotifChipsViewModelTest : SysuiTestCase() {

    @Test
    @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY)
    fun chips_onePromotedNotif_colorMatches() =
    fun chips_onePromotedNotif_colorIsSystemThemed() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chips)

@@ -209,10 +209,7 @@ class NotifChipsViewModelTest : SysuiTestCase() {
            )

            assertThat(latest).hasSize(1)
            val colors = latest!![0].colors
            assertThat(colors).isInstanceOf(ColorsModel.Custom::class.java)
            assertThat((colors as ColorsModel.Custom).backgroundColorInt).isEqualTo(56)
            assertThat((colors as ColorsModel.Custom).primaryTextColorInt).isEqualTo(89)
            assertThat(latest!![0].colors).isEqualTo(ColorsModel.SystemThemed)
        }

    @Test
+5 −16
Original line number Diff line number Diff line
@@ -52,24 +52,13 @@ class ChipTextTruncationHelperTest : SysuiTestCase() {
    }

    @Test
    fun shouldShowText_desiredSlightlyLargerThanMax_true() {
    fun shouldShowText_desiredMoreThanMax_false() {
        val result =
            underTest.shouldShowText(
                desiredTextWidthPx = (MAX_WIDTH * 1.1).toInt(),
                widthMeasureSpec = UNLIMITED_WIDTH_SPEC,
            )

        assertThat(result).isTrue()
    }

    @Test
    fun shouldShowText_desiredMoreThanTwiceMax_false() {
        val result =
            underTest.shouldShowText(
                desiredTextWidthPx = (MAX_WIDTH * 2.2).toInt(),
                widthMeasureSpec = UNLIMITED_WIDTH_SPEC,
            )

        assertThat(result).isFalse()
    }

@@ -80,8 +69,8 @@ class ChipTextTruncationHelperTest : SysuiTestCase() {
                View.MeasureSpec.makeMeasureSpec(MAX_WIDTH / 2, View.MeasureSpec.AT_MOST)
            )

        // WHEN desired is more than twice the smallerWidthSpec
        val desiredWidth = (MAX_WIDTH * 1.1).toInt()
        // WHEN desired is more than the smallerWidthSpec
        val desiredWidth = ((MAX_WIDTH / 2) * 1.1).toInt()

        val result =
            underTest.shouldShowText(
@@ -100,8 +89,8 @@ class ChipTextTruncationHelperTest : SysuiTestCase() {
                View.MeasureSpec.makeMeasureSpec(MAX_WIDTH * 3, View.MeasureSpec.AT_MOST)
            )

        // WHEN desired is more than twice the max
        val desiredWidth = (MAX_WIDTH * 2.2).toInt()
        // WHEN desired is more than the max
        val desiredWidth = (MAX_WIDTH * 1.1).toInt()

        val result =
            underTest.shouldShowText(
+4 −4
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {
                OngoingActivityChipModel.Active.Timer(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_cake),
                    colors = ColorsModel.Themed,
                    colors = ColorsModel.AccentThemed,
                    startTimeMs = 100L,
                    onClickListenerLegacy = null,
                    clickBehavior = OngoingActivityChipModel.ClickBehavior.None,
@@ -68,7 +68,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {
                OngoingActivityChipModel.Active.IconOnly(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_hotspot),
                    colors = ColorsModel.Themed,
                    colors = ColorsModel.AccentThemed,
                    onClickListenerLegacy = null,
                    clickBehavior = OngoingActivityChipModel.ClickBehavior.None,
                )
@@ -90,7 +90,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {
                OngoingActivityChipModel.Active.Timer(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_cake),
                    colors = ColorsModel.Themed,
                    colors = ColorsModel.AccentThemed,
                    startTimeMs = 100L,
                    onClickListenerLegacy = null,
                    clickBehavior = OngoingActivityChipModel.ClickBehavior.None,
@@ -132,7 +132,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {
                OngoingActivityChipModel.Active.Timer(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_cake),
                    colors = ColorsModel.Themed,
                    colors = ColorsModel.AccentThemed,
                    startTimeMs = 100L,
                    onClickListenerLegacy = null,
                    clickBehavior = OngoingActivityChipModel.ClickBehavior.None,
+2 −5
Original line number Diff line number Diff line
@@ -43,9 +43,6 @@
             ongoing_activity_chip_short_time_delta] will ever be shown at one time. -->

        <!-- Shows a timer, like 00:01. -->
        <!-- Don't use the LimitedWidth style for the timer because the end of the timer is often
             the most important value. ChipChronometer has the correct logic for when the timer is
             too large for the space allowed. -->
        <com.android.systemui.statusbar.chips.ui.view.ChipChronometer
            android:id="@+id/ongoing_activity_chip_time"
            style="@style/StatusBar.Chip.Text"
@@ -54,14 +51,14 @@
        <!-- Shows generic text. -->
        <com.android.systemui.statusbar.chips.ui.view.ChipTextView
            android:id="@+id/ongoing_activity_chip_text"
            style="@style/StatusBar.Chip.Text.LimitedWidth"
            style="@style/StatusBar.Chip.Text"
            android:visibility="gone"
            />

        <!-- Shows a time delta in short form, like "15min" or "1hr". -->
        <com.android.systemui.statusbar.chips.ui.view.ChipDateTimeView
            android:id="@+id/ongoing_activity_chip_short_time_delta"
            style="@style/StatusBar.Chip.Text.LimitedWidth"
            style="@style/StatusBar.Chip.Text"
            android:visibility="gone"
            />

Loading