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

Commit 400e3816 authored by Shuming Hao's avatar Shuming Hao
Browse files

Add config for auto expanding first notification

Add config_autoExpandFirstNotification to control whether the first
notification should be automatically expanded by system. This config
will be set to false when required.

Bug: 291113536
Test: manual test with Notify1.apk
Change-Id: Ifa873cff0b9455500b8603ffcd26f38071276345
parent 29aeb06c
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -366,10 +366,16 @@

    <!-- 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
         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. -->
         applications. If this value is false, then only the first notification will be expanded
         when config_autoExpandFirstNotification is true; the other notifications need to be
         manually expanded by the user. -->
    <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
         user. Grouped notifications are still expandable even if this value is false. -->
    <bool name="config_enableNonGroupedNotificationExpand">true</bool>
+12 −2
Original line number Diff line number Diff line
@@ -48,6 +48,14 @@ class RowAppearanceCoordinator @Inject internal constructor(
    private val mAlwaysExpandNonGroupedNotification =
        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) {
        pipeline.addOnBeforeRenderListListener(::onBeforeRenderList)
        pipeline.addOnAfterRenderEntryListener(::onAfterRenderEntry)
@@ -61,8 +69,10 @@ class RowAppearanceCoordinator @Inject internal constructor(

    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)
        // very first notification if it's not a child of grouped notifications and when
        // mAutoExpandFirstNotification is true.
        controller.setSystemExpanded(mAlwaysExpandNonGroupedNotification ||
                (mAutoExpandFirstNotification && entry == entryToExpand))
        // Show/hide the feedback icon
        controller.setFeedbackIcon(mAssistantFeedbackController.getFeedbackIcon(entry))
        // Show the "alerted" bell icon