summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt34
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java10
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java6
3 files changed, 38 insertions, 12 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt
index 600eb1a9b7eb..7ef1d0eba3f1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt
@@ -19,17 +19,21 @@ package com.android.systemui.statusbar.notification
import android.app.Notification
import android.content.Context
import android.content.pm.LauncherApps
+import android.service.notification.NotificationListenerService.Ranking
+import android.service.notification.NotificationListenerService.RankingMap
import com.android.internal.statusbar.NotificationVisibility
import com.android.internal.widget.ConversationLayout
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
+import com.android.systemui.statusbar.notification.row.NotificationContentView
import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject
import javax.inject.Singleton
+/** Populates additional information in conversation notifications */
class ConversationNotificationProcessor @Inject constructor(
private val launcherApps: LauncherApps,
- private val unreadConversationBadgeManager: UnreadConversationBadgeManager
+ private val conversationNotificationManager: ConversationNotificationManager
) {
fun processNotification(entry: NotificationEntry, recoveredBuilder: Notification.Builder) {
val messagingStyle = recoveredBuilder.style as? Notification.MessagingStyle ?: return
@@ -45,12 +49,16 @@ class ConversationNotificationProcessor @Inject constructor(
}
}
messagingStyle.unreadMessageCount =
- unreadConversationBadgeManager.getUnreadCount(entry, recoveredBuilder)
+ conversationNotificationManager.getUnreadCount(entry, recoveredBuilder)
}
}
+/**
+ * Tracks state related to conversation notifications, and updates the UI of existing notifications
+ * when necessary.
+ */
@Singleton
-class UnreadConversationBadgeManager @Inject constructor(
+class ConversationNotificationManager @Inject constructor(
private val notificationEntryManager: NotificationEntryManager,
private val context: Context
) {
@@ -63,6 +71,24 @@ class UnreadConversationBadgeManager @Inject constructor(
init {
notificationEntryManager.addNotificationEntryListener(object : NotificationEntryListener {
+ override fun onNotificationRankingUpdated(rankingMap: RankingMap) {
+ fun getLayouts(view: NotificationContentView) =
+ sequenceOf(view.contractedChild, view.expandedChild, view.headsUpChild)
+ val ranking = Ranking()
+ states.keys.asSequence()
+ .mapNotNull { notificationEntryManager.getActiveNotificationUnfiltered(it) }
+ .forEach { entry ->
+ if (rankingMap.getRanking(entry.sbn.key, ranking) &&
+ ranking.isConversation) {
+ val important = ranking.channel.isImportantConversation
+ entry.row?.layouts?.asSequence()
+ ?.flatMap(::getLayouts)
+ ?.mapNotNull { it as? ConversationLayout }
+ ?.forEach { it.setIsImportantConversation(important) }
+ }
+ }
+ }
+
override fun onEntryInflated(entry: NotificationEntry) {
if (!entry.ranking.isConversation) return
fun updateCount(isExpanded: Boolean) {
@@ -136,4 +162,4 @@ class UnreadConversationBadgeManager @Inject constructor(
.forEach { convoLayout -> convoLayout.setUnreadCount(0) }
private data class ConversationState(val unreadCount: Int, val notification: Notification)
-} \ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index 7d09dcacfb46..be8cd6a6481c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -86,11 +86,11 @@ import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
import com.android.systemui.statusbar.notification.AnimatableProperty;
+import com.android.systemui.statusbar.notification.ConversationNotificationManager;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.PropertyAnimator;
-import com.android.systemui.statusbar.notification.UnreadConversationBadgeManager;
import com.android.systemui.statusbar.notification.ViewGroupFadeHelper;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
@@ -239,7 +239,7 @@ public class NotificationPanelViewController extends PanelViewController {
private final PulseExpansionHandler mPulseExpansionHandler;
private final KeyguardBypassController mKeyguardBypassController;
private final KeyguardUpdateMonitor mUpdateMonitor;
- private final UnreadConversationBadgeManager mUnreadConversationBadgeManager;
+ private final ConversationNotificationManager mConversationNotificationManager;
private KeyguardAffordanceHelper mAffordanceHelper;
private KeyguardUserSwitcher mKeyguardUserSwitcher;
@@ -454,7 +454,7 @@ public class NotificationPanelViewController extends PanelViewController {
ConfigurationController configurationController,
FlingAnimationUtils.Builder flingAnimationUtilsBuilder,
StatusBarTouchableRegionManager statusBarTouchableRegionManager,
- UnreadConversationBadgeManager unreadConversationBadgeManager) {
+ ConversationNotificationManager conversationNotificationManager) {
super(view, falsingManager, dozeLog, keyguardStateController,
(SysuiStatusBarStateController) statusBarStateController, vibratorHelper,
latencyTracker, flingAnimationUtilsBuilder, statusBarTouchableRegionManager);
@@ -512,7 +512,7 @@ public class NotificationPanelViewController extends PanelViewController {
mShadeController = shadeController;
mLockscreenUserManager = notificationLockscreenUserManager;
mEntryManager = notificationEntryManager;
- mUnreadConversationBadgeManager = unreadConversationBadgeManager;
+ mConversationNotificationManager = conversationNotificationManager;
mView.setBackgroundColor(Color.TRANSPARENT);
OnAttachStateChangeListener onAttachStateChangeListener = new OnAttachStateChangeListener();
@@ -2147,7 +2147,7 @@ public class NotificationPanelViewController extends PanelViewController {
super.onExpandingFinished();
mNotificationStackScroller.onExpansionStopped();
mHeadsUpManager.onExpandingFinished();
- mUnreadConversationBadgeManager.onNotificationPanelExpandStateChanged(isFullyCollapsed());
+ mConversationNotificationManager.onNotificationPanelExpandStateChanged(isFullyCollapsed());
mIsExpanding = false;
if (isFullyCollapsed()) {
DejankUtils.postAfterTraversal(new Runnable() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
index 5bca946ec1ee..4b09aa687073 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
@@ -64,10 +64,10 @@ import com.android.systemui.statusbar.PulseExpansionHandler;
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
+import com.android.systemui.statusbar.notification.ConversationNotificationManager;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
-import com.android.systemui.statusbar.notification.UnreadConversationBadgeManager;
import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -171,7 +171,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
@Mock
private ConfigurationController mConfigurationController;
@Mock
- private UnreadConversationBadgeManager mUnreadConversationBadgeManager;
+ private ConversationNotificationManager mConversationNotificationManager;
private FlingAnimationUtils.Builder mFlingAnimationUtilsBuilder;
private NotificationPanelViewController mNotificationPanelViewController;
@@ -227,7 +227,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
mLatencyTracker, mPowerManager, mAccessibilityManager, 0, mUpdateMonitor,
mMetricsLogger, mActivityManager, mZenModeController, mConfigurationController,
mFlingAnimationUtilsBuilder, mStatusBarTouchableRegionManager,
- mUnreadConversationBadgeManager);
+ mConversationNotificationManager);
mNotificationPanelViewController.initDependencies(mStatusBar, mGroupManager,
mNotificationShelf, mNotificationAreaController, mScrimController);
mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager);