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

Commit 1562f4a8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "only show summary onboarding if messages present" into main

parents 18c2906a 75c6182d
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -15,12 +15,14 @@
 */
package com.android.systemui.statusbar.notification.domain.interactor

import android.app.Notification
import android.app.Notification.CallStyle.CALL_TYPE_INCOMING
import android.app.Notification.CallStyle.CALL_TYPE_ONGOING
import android.app.Notification.CallStyle.CALL_TYPE_SCREENING
import android.app.Notification.CallStyle.CALL_TYPE_UNKNOWN
import android.app.Notification.EXTRA_CALL_TYPE
import android.app.Notification.FLAG_ONGOING_EVENT
import android.app.Notification.MessagingStyle
import android.app.PendingIntent
import android.content.Context
import android.graphics.drawable.Icon
@@ -46,6 +48,7 @@ import com.android.systemui.statusbar.notification.shared.ActiveNotificationEntr
import com.android.systemui.statusbar.notification.shared.ActiveNotificationGroupModel
import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel
import com.android.systemui.statusbar.notification.shared.CallType
import com.android.systemui.statusbar.notification.shared.NotifStyle
import javax.inject.Inject
import kotlinx.coroutines.flow.update

@@ -220,7 +223,8 @@ private class ActiveNotificationsStoreBuilder(
            bucket = bucket,
            callType = sbn.toCallType(),
            promotedContent = promotedContent,
            requestedPromotion = sbn.notification.isRequestPromotedOngoing(),
            requestedPromotion = sbn.notification.isRequestPromotedOngoing,
            notifStyle = notifStyle(sbn.notification),
        )
    }
}
@@ -251,6 +255,7 @@ private fun ActiveNotificationsStore.createOrReuseNotif(
    callType: CallType,
    promotedContent: PromotedNotificationContentModels?,
    requestedPromotion: Boolean,
    notifStyle: NotifStyle?,
): ActiveNotificationModel {
    return individuals[key]?.takeIf {
        it.isCurrent(
@@ -279,6 +284,7 @@ private fun ActiveNotificationsStore.createOrReuseNotif(
            callType = callType,
            promotedContent = promotedContent,
            requestedPromotion = requestedPromotion,
            style = notifStyle,
        )
    }
        ?: ActiveNotificationModel(
@@ -307,6 +313,7 @@ private fun ActiveNotificationsStore.createOrReuseNotif(
            callType = callType,
            promotedContent = promotedContent,
            requestedPromotion = requestedPromotion,
            style = notifStyle,
        )
}

@@ -336,6 +343,7 @@ private fun ActiveNotificationModel.isCurrent(
    callType: CallType,
    promotedContent: PromotedNotificationContentModels?,
    requestedPromotion: Boolean,
    style: NotifStyle?,
): Boolean {
    return when {
        key != this.key -> false
@@ -365,6 +373,7 @@ private fun ActiveNotificationModel.isCurrent(
        // recreating the active notification model constantly?
        promotedContent != this.promotedContent -> false
        requestedPromotion != this.requestedPromotion -> false
        style != this.style -> false
        else -> true
    }
}
@@ -434,3 +443,9 @@ private fun hasSameInstances(list1: List<*>, list2: List<*>): Boolean {
    }
    return true
}

private fun notifStyle(notif: Notification): NotifStyle? =
    when {
        notif.isStyle(MessagingStyle::class.java) -> NotifStyle.Messaging()
        else -> null
    }
+10 −0
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ data class ActiveNotificationModel(
    val promotedContent: PromotedNotificationContentModels?,
    /** True if this notification set the "requested promotion?" extra and false otherwise. */
    val requestedPromotion: Boolean,
    /** The visual style of the notification, containing additional data relevant to that style. */
    val style: NotifStyle?,
) : ActiveNotificationEntryModel() {
    init {
        if (!PromotedNotificationContentModel.featureFlagEnabled()) {
@@ -143,3 +145,11 @@ enum class CallType {
    /** See [android.app.Notification.CallStyle.CALL_TYPE_UNKNOWN]. */
    Unknown,
}

/** Style-specific data for [ActiveNotificationModel] */
sealed class NotifStyle {
    /**
     * Data pertaining to [messaging style][android.app.Notification.MessagingStyle] notifications.
     */
    class Messaging : NotifStyle()
}
+5 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.util.Log
import androidx.core.content.edit
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository
import com.android.systemui.statusbar.notification.shared.NotifStyle
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.util.kotlin.BooleanFlowOperators.allOf
import com.android.systemui.util.kotlin.SharedPreferencesExt.observeBoolean
@@ -47,7 +48,10 @@ constructor(
) {
    private val notifsPresent: Flow<Boolean> =
        notifListRepo.activeNotifications
            .map { store -> store.renderList.isNotEmpty() }
            .map { store ->
                store.renderList.isNotEmpty() &&
                    store.individuals.any { (_, notif) -> notif.style is NotifStyle.Messaging }
            }
            .distinctUntilChanged()

    private val onboardingUnseen: Flow<Boolean> =
+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModels
import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel
import com.android.systemui.statusbar.notification.shared.CallType
import com.android.systemui.statusbar.notification.shared.NotifStyle
import com.android.systemui.statusbar.notification.stack.BUCKET_UNKNOWN

/** Simple ActiveNotificationModel builder for use in tests. */
@@ -52,6 +53,7 @@ fun activeNotificationModel(
    callType: CallType = CallType.None,
    requestedPromotion: Boolean = false,
    promotedContent: PromotedNotificationContentModels? = null,
    notifStyle: NotifStyle? = null,
) =
    ActiveNotificationModel(
        key = key,
@@ -79,4 +81,5 @@ fun activeNotificationModel(
        callType = callType,
        requestedPromotion = requestedPromotion,
        promotedContent = promotedContent,
        style = notifStyle,
    )