Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt +30 −4 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 ) { Loading @@ -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) { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +5 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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(); Loading Loading @@ -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() { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/ConversationNotifications.kt +30 −4 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 ) { Loading @@ -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) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +5 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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(); Loading Loading @@ -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() { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading