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

Commit 3b212f6f authored by Yining Liu's avatar Yining Liu Committed by Android (Google) Code Review
Browse files

Merge changes from topic "NOTIFICATION_SHOW_ONLY_UNSEEN_NOTIFICATIONS" into main

* changes:
  Format kotlin code
  Add documentation for NOTIFICATION_SHOW_ONLY_UNSEEN_NOTIFICATIONS
parents 7d1c6e21 c6671a8f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -10981,7 +10981,10 @@ public final class Settings {
        /**
         * Indicates whether "seen" notifications should be suppressed from the lockscreen.
         * <p>
         * Type: int (0 for unset, 1 for true, 2 for false)
         * Type: int (0 for unset_off, 1 for true, 2 for false)
         * 0 is the default value for phones, which is equivalent to off in effect, before
         * the notification minimalism feature, this setting is default hidden to phones, we use
         * 0 instead of 2 to mark that we need to hide this setting toggle in the Settings app.
         *
         * @hide
         */
+14 −8
Original line number Diff line number Diff line
@@ -83,19 +83,28 @@ constructor(
            printSection("SeenNotificationsInteractor") {
                print(
                    "hasFilteredOutSeenNotifications",
                    notificationListRepository.hasFilteredOutSeenNotifications.value
                    notificationListRepository.hasFilteredOutSeenNotifications.value,
                )
                print(
                    "topOngoingNotificationKey",
                    notificationListRepository.topOngoingNotificationKey.value
                    notificationListRepository.topOngoingNotificationKey.value,
                )
                print(
                    "topUnseenNotificationKey",
                    notificationListRepository.topUnseenNotificationKey.value
                    notificationListRepository.topUnseenNotificationKey.value,
                )
            }
        }

    /**
     * There are three states for LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS.
     *
     * 0: unset_off, default value for phones.
     *
     * 1: on, default value for tablets.
     *
     * 2: off.
     */
    fun isLockScreenShowOnlyUnseenNotificationsEnabled(): Flow<Boolean> =
        secureSettings
            // emit whenever the setting has changed
@@ -109,7 +118,7 @@ constructor(
            .map {
                secureSettings.getIntForUser(
                    name = Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS,
                    default = 0,
                    default = 0, // 0 is unset_off, which should be treated as off
                    userHandle = UserHandle.USER_CURRENT,
                ) == 1
            }
@@ -124,10 +133,7 @@ constructor(
    fun isLockScreenNotificationMinimalismEnabled(): Flow<Boolean> =
        secureSettings
            // emit whenever the setting has changed
            .observerFlow(
                UserHandle.USER_ALL,
                Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM,
            )
            .observerFlow(UserHandle.USER_ALL, Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM)
            // perform a query immediately
            .onStart { emit(Unit) }
            // for each change, lookup the new value