Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/SectionClassifier.kt 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner import javax.inject.Inject /** * A class which is used to classify the sections. * NOTE: This class exists to avoid putting metadata like "isMinimized" on the NotifSection */ @SysUISingleton class SectionClassifier @Inject constructor() { private lateinit var lowPrioritySections: Set<NotifSectioner> /** * Feed the provider the information it needs about which sections should have minimized top * level views, so that it can calculate the correct minimized state. */ fun setMinimizedSections(sections: Collection<NotifSectioner>) { lowPrioritySections = sections.toSet() } /** * Determine if the given section is minimized */ fun isMinimizedSection(section: NotifSection): Boolean { return lowPrioritySections.contains(section.sectioner) } } No newline at end of file packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/NotifCoordinators.kt +2 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ class NotifCoordinatorsImpl @Inject constructor( groupCountCoordinator: GroupCountCoordinator, mediaCoordinator: MediaCoordinator, remoteInputCoordinator: RemoteInputCoordinator, rowAppearanceCoordinator: RowAppearanceCoordinator, stackCoordinator: StackCoordinator, shadeEventCoordinator: ShadeEventCoordinator, smartspaceDedupingCoordinator: SmartspaceDedupingCoordinator, Loading Loading @@ -77,6 +78,7 @@ class NotifCoordinatorsImpl @Inject constructor( mCoordinators.add(groupCountCoordinator) mCoordinators.add(mediaCoordinator) mCoordinators.add(remoteInputCoordinator) mCoordinators.add(rowAppearanceCoordinator) mCoordinators.add(stackCoordinator) mCoordinators.add(shadeEventCoordinator) mCoordinators.add(viewConfigCoordinator) Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java +5 −5 Original line number Diff line number Diff line Loading @@ -20,11 +20,11 @@ import android.annotation.NonNull; import android.annotation.Nullable; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.notification.SectionClassifier; import com.android.systemui.statusbar.notification.collection.ListEntry; import com.android.systemui.statusbar.notification.collection.NotifPipeline; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope; import com.android.systemui.statusbar.notification.collection.inflation.NotifUiAdjustmentProvider; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner; import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider; Loading @@ -51,7 +51,7 @@ public class RankingCoordinator implements Coordinator { public static final boolean SHOW_ALL_SECTIONS = false; private final StatusBarStateController mStatusBarStateController; private final HighPriorityProvider mHighPriorityProvider; private final NotifUiAdjustmentProvider mAdjustmentProvider; private final SectionClassifier mSectionClassifier; private final NodeController mSilentNodeController; private final SectionHeaderController mSilentHeaderController; private final NodeController mAlertingHeaderController; Loading @@ -62,13 +62,13 @@ public class RankingCoordinator implements Coordinator { public RankingCoordinator( StatusBarStateController statusBarStateController, HighPriorityProvider highPriorityProvider, NotifUiAdjustmentProvider adjustmentProvider, SectionClassifier sectionClassifier, @AlertingHeader NodeController alertingHeaderController, @SilentHeader SectionHeaderController silentHeaderController, @SilentHeader NodeController silentNodeController) { mStatusBarStateController = statusBarStateController; mHighPriorityProvider = highPriorityProvider; mAdjustmentProvider = adjustmentProvider; mSectionClassifier = sectionClassifier; mAlertingHeaderController = alertingHeaderController; mSilentNodeController = silentNodeController; mSilentHeaderController = silentHeaderController; Loading @@ -77,7 +77,7 @@ public class RankingCoordinator implements Coordinator { @Override public void attach(NotifPipeline pipeline) { mStatusBarStateController.addCallback(mStatusBarStateCallback); mAdjustmentProvider.setLowPrioritySections(Collections.singleton(mMinimizedNotifSectioner)); mSectionClassifier.setMinimizedSections(Collections.singleton(mMinimizedNotifSectioner)); pipeline.addPreGroupFilter(mSuspendedFilter); pipeline.addPreGroupFilter(mDndVisualEffectsFilter); Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RowAppearanceCoordinator.kt 0 → 100644 +74 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.collection.coordinator import android.content.Context import com.android.systemui.R import com.android.systemui.statusbar.notification.AssistantFeedbackController import com.android.systemui.statusbar.notification.SectionClassifier import com.android.systemui.statusbar.notification.collection.ListEntry import com.android.systemui.statusbar.notification.collection.NotifPipeline import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope import com.android.systemui.statusbar.notification.collection.render.NotifRowController import javax.inject.Inject /** * A small coordinator which updates the notif rows with data related to the current shade after * they are fully attached. */ @CoordinatorScope class RowAppearanceCoordinator @Inject internal constructor( context: Context, private var mAssistantFeedbackController: AssistantFeedbackController, private var mSectionClassifier: SectionClassifier ) : Coordinator { private var entryToExpand: NotificationEntry? = null /** * `true` if notifications not part of a group should by default be rendered in their * expanded state. If `false`, then only the first notification will be expanded if * possible. */ private val mAlwaysExpandNonGroupedNotification = context.resources.getBoolean(R.bool.config_alwaysExpandNonGroupedNotifications) override fun attach(pipeline: NotifPipeline) { pipeline.addOnBeforeRenderListListener(::onBeforeRenderList) pipeline.addOnAfterRenderEntryListener(::onAfterRenderEntry) } private fun onBeforeRenderList(list: List<ListEntry>) { entryToExpand = list.firstOrNull()?.representativeEntry?.takeIf { entry -> !mSectionClassifier.isMinimizedSection(entry.section!!) } } private fun onAfterRenderEntry(entry: NotificationEntry, controller: NotifRowController) { // If mAlwaysExpandNonGroupedNotification is false, then only expand the // very first notification and if it's not a child of grouped notifications. controller.setSystemExpanded(mAlwaysExpandNonGroupedNotification || entry == entryToExpand) // Show/hide the feedback icon controller.showFeedbackIcon( mAssistantFeedbackController.showFeedbackIndicator(entry), mAssistantFeedbackController.getFeedbackResources(entry) ) // Show the "alerted" bell icon controller.setLastAudiblyAlertedMs(entry.lastAudiblyAlertedMs) } } No newline at end of file packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt +6 −14 Original line number Diff line number Diff line Loading @@ -17,9 +17,9 @@ package com.android.systemui.statusbar.notification.collection.inflation import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.notification.SectionClassifier import com.android.systemui.statusbar.notification.collection.GroupEntry import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner import javax.inject.Inject /** Loading @@ -27,25 +27,17 @@ import javax.inject.Inject * to ensure that notifications are reinflated when ranking-derived information changes. */ @SysUISingleton open class NotifUiAdjustmentProvider @Inject constructor() { private lateinit var lowPrioritySections: Set<NotifSectioner> /** * Feed the provider the information it needs about which sections should have minimized top * level views, so that it can calculate the correct minimized value in the adjustment. */ fun setLowPrioritySections(sections: Collection<NotifSectioner>) { lowPrioritySections = sections.toSet() } open class NotifUiAdjustmentProvider @Inject constructor( private val sectionClassifier: SectionClassifier ) { private fun isEntryMinimized(entry: NotificationEntry): Boolean { val section = entry.section ?: error("Entry must have a section to determine if minimized") val parent = entry.parent ?: error("Entry must have a parent to determine if minimized") val isLowPrioritySection = lowPrioritySections.contains(section.sectioner) val isMinimizedSection = sectionClassifier.isMinimizedSection(section) val isTopLevelEntry = parent == GroupEntry.ROOT_ENTRY val isGroupSummary = parent.summary == entry return isLowPrioritySection && (isTopLevelEntry || isGroupSummary) return isMinimizedSection && (isTopLevelEntry || isGroupSummary) } /** Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/SectionClassifier.kt 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner import javax.inject.Inject /** * A class which is used to classify the sections. * NOTE: This class exists to avoid putting metadata like "isMinimized" on the NotifSection */ @SysUISingleton class SectionClassifier @Inject constructor() { private lateinit var lowPrioritySections: Set<NotifSectioner> /** * Feed the provider the information it needs about which sections should have minimized top * level views, so that it can calculate the correct minimized state. */ fun setMinimizedSections(sections: Collection<NotifSectioner>) { lowPrioritySections = sections.toSet() } /** * Determine if the given section is minimized */ fun isMinimizedSection(section: NotifSection): Boolean { return lowPrioritySections.contains(section.sectioner) } } No newline at end of file
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/NotifCoordinators.kt +2 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ class NotifCoordinatorsImpl @Inject constructor( groupCountCoordinator: GroupCountCoordinator, mediaCoordinator: MediaCoordinator, remoteInputCoordinator: RemoteInputCoordinator, rowAppearanceCoordinator: RowAppearanceCoordinator, stackCoordinator: StackCoordinator, shadeEventCoordinator: ShadeEventCoordinator, smartspaceDedupingCoordinator: SmartspaceDedupingCoordinator, Loading Loading @@ -77,6 +78,7 @@ class NotifCoordinatorsImpl @Inject constructor( mCoordinators.add(groupCountCoordinator) mCoordinators.add(mediaCoordinator) mCoordinators.add(remoteInputCoordinator) mCoordinators.add(rowAppearanceCoordinator) mCoordinators.add(stackCoordinator) mCoordinators.add(shadeEventCoordinator) mCoordinators.add(viewConfigCoordinator) Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java +5 −5 Original line number Diff line number Diff line Loading @@ -20,11 +20,11 @@ import android.annotation.NonNull; import android.annotation.Nullable; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.notification.SectionClassifier; import com.android.systemui.statusbar.notification.collection.ListEntry; import com.android.systemui.statusbar.notification.collection.NotifPipeline; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope; import com.android.systemui.statusbar.notification.collection.inflation.NotifUiAdjustmentProvider; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner; import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider; Loading @@ -51,7 +51,7 @@ public class RankingCoordinator implements Coordinator { public static final boolean SHOW_ALL_SECTIONS = false; private final StatusBarStateController mStatusBarStateController; private final HighPriorityProvider mHighPriorityProvider; private final NotifUiAdjustmentProvider mAdjustmentProvider; private final SectionClassifier mSectionClassifier; private final NodeController mSilentNodeController; private final SectionHeaderController mSilentHeaderController; private final NodeController mAlertingHeaderController; Loading @@ -62,13 +62,13 @@ public class RankingCoordinator implements Coordinator { public RankingCoordinator( StatusBarStateController statusBarStateController, HighPriorityProvider highPriorityProvider, NotifUiAdjustmentProvider adjustmentProvider, SectionClassifier sectionClassifier, @AlertingHeader NodeController alertingHeaderController, @SilentHeader SectionHeaderController silentHeaderController, @SilentHeader NodeController silentNodeController) { mStatusBarStateController = statusBarStateController; mHighPriorityProvider = highPriorityProvider; mAdjustmentProvider = adjustmentProvider; mSectionClassifier = sectionClassifier; mAlertingHeaderController = alertingHeaderController; mSilentNodeController = silentNodeController; mSilentHeaderController = silentHeaderController; Loading @@ -77,7 +77,7 @@ public class RankingCoordinator implements Coordinator { @Override public void attach(NotifPipeline pipeline) { mStatusBarStateController.addCallback(mStatusBarStateCallback); mAdjustmentProvider.setLowPrioritySections(Collections.singleton(mMinimizedNotifSectioner)); mSectionClassifier.setMinimizedSections(Collections.singleton(mMinimizedNotifSectioner)); pipeline.addPreGroupFilter(mSuspendedFilter); pipeline.addPreGroupFilter(mDndVisualEffectsFilter); Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RowAppearanceCoordinator.kt 0 → 100644 +74 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.collection.coordinator import android.content.Context import com.android.systemui.R import com.android.systemui.statusbar.notification.AssistantFeedbackController import com.android.systemui.statusbar.notification.SectionClassifier import com.android.systemui.statusbar.notification.collection.ListEntry import com.android.systemui.statusbar.notification.collection.NotifPipeline import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope import com.android.systemui.statusbar.notification.collection.render.NotifRowController import javax.inject.Inject /** * A small coordinator which updates the notif rows with data related to the current shade after * they are fully attached. */ @CoordinatorScope class RowAppearanceCoordinator @Inject internal constructor( context: Context, private var mAssistantFeedbackController: AssistantFeedbackController, private var mSectionClassifier: SectionClassifier ) : Coordinator { private var entryToExpand: NotificationEntry? = null /** * `true` if notifications not part of a group should by default be rendered in their * expanded state. If `false`, then only the first notification will be expanded if * possible. */ private val mAlwaysExpandNonGroupedNotification = context.resources.getBoolean(R.bool.config_alwaysExpandNonGroupedNotifications) override fun attach(pipeline: NotifPipeline) { pipeline.addOnBeforeRenderListListener(::onBeforeRenderList) pipeline.addOnAfterRenderEntryListener(::onAfterRenderEntry) } private fun onBeforeRenderList(list: List<ListEntry>) { entryToExpand = list.firstOrNull()?.representativeEntry?.takeIf { entry -> !mSectionClassifier.isMinimizedSection(entry.section!!) } } private fun onAfterRenderEntry(entry: NotificationEntry, controller: NotifRowController) { // If mAlwaysExpandNonGroupedNotification is false, then only expand the // very first notification and if it's not a child of grouped notifications. controller.setSystemExpanded(mAlwaysExpandNonGroupedNotification || entry == entryToExpand) // Show/hide the feedback icon controller.showFeedbackIcon( mAssistantFeedbackController.showFeedbackIndicator(entry), mAssistantFeedbackController.getFeedbackResources(entry) ) // Show the "alerted" bell icon controller.setLastAudiblyAlertedMs(entry.lastAudiblyAlertedMs) } } No newline at end of file
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt +6 −14 Original line number Diff line number Diff line Loading @@ -17,9 +17,9 @@ package com.android.systemui.statusbar.notification.collection.inflation import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.notification.SectionClassifier import com.android.systemui.statusbar.notification.collection.GroupEntry import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner import javax.inject.Inject /** Loading @@ -27,25 +27,17 @@ import javax.inject.Inject * to ensure that notifications are reinflated when ranking-derived information changes. */ @SysUISingleton open class NotifUiAdjustmentProvider @Inject constructor() { private lateinit var lowPrioritySections: Set<NotifSectioner> /** * Feed the provider the information it needs about which sections should have minimized top * level views, so that it can calculate the correct minimized value in the adjustment. */ fun setLowPrioritySections(sections: Collection<NotifSectioner>) { lowPrioritySections = sections.toSet() } open class NotifUiAdjustmentProvider @Inject constructor( private val sectionClassifier: SectionClassifier ) { private fun isEntryMinimized(entry: NotificationEntry): Boolean { val section = entry.section ?: error("Entry must have a section to determine if minimized") val parent = entry.parent ?: error("Entry must have a parent to determine if minimized") val isLowPrioritySection = lowPrioritySections.contains(section.sectioner) val isMinimizedSection = sectionClassifier.isMinimizedSection(section) val isTopLevelEntry = parent == GroupEntry.ROOT_ENTRY val isGroupSummary = parent.summary == entry return isLowPrioritySection && (isTopLevelEntry || isGroupSummary) return isMinimizedSection && (isTopLevelEntry || isGroupSummary) } /** Loading