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

Commit a05033b7 authored by Shuming Hao's avatar Shuming Hao Committed by Android (Google) Code Review
Browse files

Merge "Add config for auto expanding first notification" into main

parents 9c505541 400e3816
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -366,10 +366,16 @@


    <!-- Whether or not notifications that can be expanded will always be in their expanded state.
    <!-- Whether or not notifications that can be expanded will always be in their expanded state.
         This value only affects notifications that are not a group of notifications from the same
         This value only affects notifications that are not a group of notifications from the same
         applications. If this value is false, then only the first notification will be expanded;
         applications. If this value is false, then only the first notification will be expanded
         the other notifications need to be manually expanded by the user. -->
         when config_autoExpandFirstNotification is true; the other notifications need to be
         manually expanded by the user. -->
    <bool name="config_alwaysExpandNonGroupedNotifications">false</bool>
    <bool name="config_alwaysExpandNonGroupedNotifications">false</bool>


    <!-- Whether or not the first expandable notification will be expanded automatically by the
         system. This value only affects notifications that are not a group of notifications from
         the same applications and when config_alwaysExpandNonGroupedNotifications is false. -->
    <bool name="config_autoExpandFirstNotification">true</bool>

    <!-- Whether or not an expandable notification can be manually expanded or collapsed by the
    <!-- Whether or not an expandable notification can be manually expanded or collapsed by the
         user. Grouped notifications are still expandable even if this value is false. -->
         user. Grouped notifications are still expandable even if this value is false. -->
    <bool name="config_enableNonGroupedNotificationExpand">true</bool>
    <bool name="config_enableNonGroupedNotificationExpand">true</bool>
+12 −2
Original line number Original line Diff line number Diff line
@@ -48,6 +48,14 @@ class RowAppearanceCoordinator @Inject internal constructor(
    private val mAlwaysExpandNonGroupedNotification =
    private val mAlwaysExpandNonGroupedNotification =
        context.resources.getBoolean(R.bool.config_alwaysExpandNonGroupedNotifications)
        context.resources.getBoolean(R.bool.config_alwaysExpandNonGroupedNotifications)


    /**
     * `true` if the first non-group expandable notification should be expanded automatically
     * when possible. If `false`, then the first non-group expandable notification should not
     * be expanded.
     */
    private val mAutoExpandFirstNotification =
            context.resources.getBoolean(R.bool.config_autoExpandFirstNotification)

    override fun attach(pipeline: NotifPipeline) {
    override fun attach(pipeline: NotifPipeline) {
        pipeline.addOnBeforeRenderListListener(::onBeforeRenderList)
        pipeline.addOnBeforeRenderListListener(::onBeforeRenderList)
        pipeline.addOnAfterRenderEntryListener(::onAfterRenderEntry)
        pipeline.addOnAfterRenderEntryListener(::onAfterRenderEntry)
@@ -61,8 +69,10 @@ class RowAppearanceCoordinator @Inject internal constructor(


    private fun onAfterRenderEntry(entry: NotificationEntry, controller: NotifRowController) {
    private fun onAfterRenderEntry(entry: NotificationEntry, controller: NotifRowController) {
        // If mAlwaysExpandNonGroupedNotification is false, then only expand the
        // If mAlwaysExpandNonGroupedNotification is false, then only expand the
        // very first notification and if it's not a child of grouped notifications.
        // very first notification if it's not a child of grouped notifications and when
        controller.setSystemExpanded(mAlwaysExpandNonGroupedNotification || entry == entryToExpand)
        // mAutoExpandFirstNotification is true.
        controller.setSystemExpanded(mAlwaysExpandNonGroupedNotification ||
                (mAutoExpandFirstNotification && entry == entryToExpand))
        // Show/hide the feedback icon
        // Show/hide the feedback icon
        controller.setFeedbackIcon(mAssistantFeedbackController.getFeedbackIcon(entry))
        controller.setFeedbackIcon(mAssistantFeedbackController.getFeedbackIcon(entry))
        // Show the "alerted" bell icon
        // Show the "alerted" bell icon