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

Commit b8b86a57 authored by lyn's avatar lyn Committed by Lyn Han
Browse files

Remove unreadMessages from bundle repository

Fixes: 413814493
Test: manual
Flag: com.android.systemui.notification_bundle_ui
Change-Id: Ic6347caf2fd4a8d42bb09a25bd7519b9d25c3a57
parent 592ace54
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -170,7 +170,6 @@ private fun ContentScope.BundleHeaderContent(

        ExpansionControl(
            collapsed = collapsed,
            hasUnread = viewModel.hasUnreadMessages,
            numberToShow = viewModel.numberOfChildren,
            modifier = Modifier.padding(start = 8.dp, end = 16.dp),
        )
+13 −25
Original line number Diff line number Diff line
@@ -67,7 +67,6 @@ object NotificationRowPrimitives {

    object Values {
        val ChevronRotation = ValueKey("NotificationChevronRotation")
        val PillBackgroundColor = ValueKey("PillBackgroundColor")
    }
}

@@ -120,16 +119,14 @@ fun PreviewIcon(drawable: Drawable, modifier: Modifier = Modifier) {
@Composable
fun ContentScope.ExpansionControl(
    collapsed: Boolean,
    hasUnread: Boolean,
    numberToShow: Int?,
    modifier: Modifier = Modifier,
) {
    val textColor =
        if (hasUnread) MaterialTheme.colorScheme.onTertiary else MaterialTheme.colorScheme.onSurface
    val textColor = MaterialTheme.colorScheme.onSurface
    Box(modifier = modifier) {
        // The background is a shared Element and therefore can't be the parent of a different
        // shared Element (the chevron), otherwise the child can't be animated.
        PillBackground(hasUnread, modifier = Modifier.matchParentSize())
        PillBackground(modifier = Modifier.matchParentSize())
        Row(
            verticalAlignment = Alignment.CenterVertically,
            modifier = Modifier.padding(vertical = 2.dp, horizontal = 6.dp),
@@ -150,15 +147,8 @@ fun ContentScope.ExpansionControl(
}

@Composable
private fun ContentScope.PillBackground(hasUnread: Boolean, modifier: Modifier = Modifier) {
    ElementWithValues(NotificationRowPrimitives.Elements.PillBackground, modifier) {
        val bgColorNoUnread = notificationElementSurfaceColor()
        val surfaceColor by
            animateElementColorAsState(
                if (hasUnread) MaterialTheme.colorScheme.tertiary else bgColorNoUnread,
                NotificationRowPrimitives.Values.PillBackgroundColor,
            )
        content {
private fun ContentScope.PillBackground(modifier: Modifier = Modifier) {
    val surfaceColor = notificationElementSurfaceColor()
    Box(
        modifier =
            Modifier.drawBehind {
@@ -169,8 +159,6 @@ private fun ContentScope.PillBackground(hasUnread: Boolean, modifier: Modifier =
            }
    )
}
    }
}

@Composable
@ReadOnlyComposable
+0 −2
Original line number Diff line number Diff line
@@ -28,7 +28,5 @@ class BundleRepository(@StringRes val titleTextResId: Int, @DrawableRes val bund

    var numberOfChildren by mutableStateOf<Int?>(0)

    var hasUnreadMessages by mutableStateOf(false)

    var previewIcons by mutableStateOf(listOf<Drawable>())
}
+0 −7
Original line number Diff line number Diff line
@@ -27,16 +27,9 @@ class BundleInteractor(private val repository: BundleRepository) {
    val numberOfChildren
        get() = repository.numberOfChildren

    val hasUnreadMessages
        get() = repository.hasUnreadMessages

    val bundleIcon
        get() = repository.bundleIcon

    val previewIcons
        get() = repository.previewIcons

    fun rowExpanded() {
        repository.hasUnreadMessages = false
    }
}
+1 −7
Original line number Diff line number Diff line
@@ -38,9 +38,6 @@ class BundleHeaderViewModel(val interactor: BundleInteractor) {
    val numberOfChildren
        get() = interactor.numberOfChildren

    val hasUnreadMessages
        get() = interactor.hasUnreadMessages

    val bundleIcon
        get() = interactor.bundleIcon

@@ -71,10 +68,7 @@ class BundleHeaderViewModel(val interactor: BundleInteractor) {
    fun onHeaderClicked(scope: CoroutineScope) {
        val targetScene =
            when (state.currentScene) {
                BundleHeader.Scenes.Collapsed -> {
                    interactor.rowExpanded()
                    BundleHeader.Scenes.Expanded
                }
                BundleHeader.Scenes.Collapsed -> BundleHeader.Scenes.Expanded
                BundleHeader.Scenes.Expanded -> BundleHeader.Scenes.Collapsed
                else -> error("Unknown Scene")
            }