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

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

Merge "[SB][Chips] Fix Compose chips that use notification icons." into main

parents 976910dc 313f6455
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {

            val newChip =
                OngoingActivityChipModel.Shown.Timer(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_cake),
                    colors = ColorsModel.Themed,
                    startTimeMs = 100L,
@@ -65,6 +66,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {

            val newerChip =
                OngoingActivityChipModel.Shown.IconOnly(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_hotspot),
                    colors = ColorsModel.Themed,
                    onClickListenerLegacy = null,
@@ -86,6 +88,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {

            val shownChip =
                OngoingActivityChipModel.Shown.Timer(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_cake),
                    colors = ColorsModel.Themed,
                    startTimeMs = 100L,
@@ -127,6 +130,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {

            val shownChip =
                OngoingActivityChipModel.Shown.Timer(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_cake),
                    colors = ColorsModel.Themed,
                    startTimeMs = 100L,
@@ -162,4 +166,8 @@ class ChipTransitionHelperTest : SysuiTestCase() {
        OngoingActivityChipModel.ChipIcon.SingleColorIcon(
            Icon.Resource(drawable, contentDescription = null)
        )

    companion object {
        private const val KEY = "testKey"
    }
}
+14 −9
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ import com.android.systemui.screenrecord.data.repository.screenRecordRepository
import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.NORMAL_PACKAGE
import com.android.systemui.statusbar.chips.mediaprojection.domain.interactor.MediaProjectionChipInteractorTest.Companion.setUpPackageManagerForMediaProjection
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.chips.screenrecord.ui.viewmodel.ScreenRecordChipViewModel
import com.android.systemui.statusbar.chips.sharetoapp.ui.viewmodel.ShareToAppChipViewModel
import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
@@ -385,32 +387,35 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() {

        fun assertIsScreenRecordChip(latest: OngoingActivityChipModel?) {
            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java)
            assertThat((latest as OngoingActivityChipModel.Shown).key)
                .isEqualTo(ScreenRecordChipViewModel.KEY)
            val icon =
                (((latest as OngoingActivityChipModel.Shown).icon)
                        as OngoingActivityChipModel.ChipIcon.SingleColorIcon)
                    .impl as Icon.Resource
                ((latest.icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon).impl
                    as Icon.Resource
            assertThat(icon.res).isEqualTo(R.drawable.ic_screenrecord)
        }

        fun assertIsShareToAppChip(latest: OngoingActivityChipModel?) {
            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java)
            assertThat((latest as OngoingActivityChipModel.Shown).key)
                .isEqualTo(ShareToAppChipViewModel.KEY)
            val icon =
                (((latest as OngoingActivityChipModel.Shown).icon)
                        as OngoingActivityChipModel.ChipIcon.SingleColorIcon)
                    .impl as Icon.Resource
                ((latest.icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon).impl
                    as Icon.Resource
            assertThat(icon.res).isEqualTo(R.drawable.ic_present_to_all)
        }

        fun assertIsCallChip(latest: OngoingActivityChipModel?, notificationKey: String) {
            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java)
            assertThat((latest as OngoingActivityChipModel.Shown).key).isEqualTo(notificationKey)

            if (StatusBarConnectedDisplays.isEnabled) {
                assertNotificationIcon(latest, notificationKey)
                return
            }
            val icon =
                (((latest as OngoingActivityChipModel.Shown).icon)
                        as OngoingActivityChipModel.ChipIcon.SingleColorIcon)
                    .impl as Icon.Resource
                ((latest.icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon).impl
                    as Icon.Resource
            assertThat(icon.res).isEqualTo(com.android.internal.R.drawable.ic_phone)
        }

+3 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ constructor(
                    is OngoingCallModel.NoCall,
                    is OngoingCallModel.InCallWithVisibleApp -> OngoingActivityChipModel.Hidden()
                    is OngoingCallModel.InCall -> {
                        val key = state.notificationKey
                        val contentDescription = getContentDescription(state.appName)
                        val icon =
                            if (state.notificationIconView != null) {
@@ -97,6 +98,7 @@ constructor(
                            // If the start time is invalid, don't show a timer and show just an
                            // icon. See b/192379214.
                            OngoingActivityChipModel.Shown.IconOnly(
                                key = key,
                                icon = icon,
                                colors = colors,
                                onClickListenerLegacy = getOnClickListener(state),
@@ -107,6 +109,7 @@ constructor(
                                state.startTimeMs - systemClock.currentTimeMillis() +
                                    systemClock.elapsedRealtime()
                            OngoingActivityChipModel.Shown.Timer(
                                key = key,
                                icon = icon,
                                colors = colors,
                                startTimeMs = startTimeInElapsedRealtime,
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.chips.casttootherdevice.ui.viewmodel

import android.content.Context
import androidx.annotation.DrawableRes
import androidx.annotation.VisibleForTesting
import com.android.internal.jank.Cuj
import com.android.systemui.animation.DialogCuj
import com.android.systemui.animation.DialogTransitionAnimator
@@ -192,6 +193,7 @@ constructor(
        state: ProjectionChipModel.Projecting
    ): OngoingActivityChipModel.Shown {
        return OngoingActivityChipModel.Shown.Timer(
            key = KEY,
            icon =
                OngoingActivityChipModel.ChipIcon.SingleColorIcon(
                    Icon.Resource(
@@ -229,6 +231,7 @@ constructor(

    private fun createIconOnlyCastChip(deviceName: String?): OngoingActivityChipModel.Shown {
        return OngoingActivityChipModel.Shown.IconOnly(
            key = KEY,
            icon =
                OngoingActivityChipModel.ChipIcon.SingleColorIcon(
                    Icon.Resource(
@@ -276,6 +279,7 @@ constructor(
        )

    companion object {
        @VisibleForTesting const val KEY = "CastToOtherDevice"
        @DrawableRes val CAST_TO_OTHER_DEVICE_ICON = R.drawable.ic_cast_connected
        private val DIALOG_CUJ =
            DialogCuj(Cuj.CUJ_STATUS_BAR_LAUNCH_DIALOG_FROM_CHIP, tag = "Cast to other device")
+7 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ constructor(
            // If the user tapped this chip to show the HUN, we want to just show the icon because
            // the HUN will show the rest of the information.
            return OngoingActivityChipModel.Shown.IconOnly(
                this.key,
                icon,
                colors,
                onClickListenerLegacy,
@@ -123,6 +124,7 @@ constructor(

        if (this.promotedContent.shortCriticalText != null) {
            return OngoingActivityChipModel.Shown.Text(
                this.key,
                icon,
                colors,
                this.promotedContent.shortCriticalText,
@@ -140,6 +142,7 @@ constructor(
            // to always show "now". We don't want early testers to get that experience since it's
            // not what will happen at launch, so just don't show any time.
            return OngoingActivityChipModel.Shown.IconOnly(
                this.key,
                icon,
                colors,
                onClickListenerLegacy,
@@ -149,6 +152,7 @@ constructor(

        if (this.promotedContent.time == null) {
            return OngoingActivityChipModel.Shown.IconOnly(
                this.key,
                icon,
                colors,
                onClickListenerLegacy,
@@ -158,6 +162,7 @@ constructor(
        when (this.promotedContent.time.mode) {
            PromotedNotificationContentModel.When.Mode.BasicTime -> {
                return OngoingActivityChipModel.Shown.ShortTimeDelta(
                    this.key,
                    icon,
                    colors,
                    time = this.promotedContent.time.time,
@@ -167,6 +172,7 @@ constructor(
            }
            PromotedNotificationContentModel.When.Mode.CountUp -> {
                return OngoingActivityChipModel.Shown.Timer(
                    this.key,
                    icon,
                    colors,
                    startTimeMs = this.promotedContent.time.time,
@@ -177,6 +183,7 @@ constructor(
            PromotedNotificationContentModel.When.Mode.CountDown -> {
                // TODO(b/364653005): Support CountDown.
                return OngoingActivityChipModel.Shown.Timer(
                    this.key,
                    icon,
                    colors,
                    startTimeMs = this.promotedContent.time.time,
Loading