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

Commit ba4cd51a authored by Heemin Seog's avatar Heemin Seog
Browse files

Rearrange listener logic so it can be overriden

Bug: 144567659
Test: build, manual
Change-Id: I9f081fa8e0da1470fe15f5952a7d63448e43562f
parent 2b204642
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -562,15 +562,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        mCarUxRestrictionManagerWrapper = new CarUxRestrictionManagerWrapper();

        mNotificationDataManager = new NotificationDataManager();
        mNotificationDataManager.setOnUnseenCountUpdateListener(
                () -> {
                    if (mNotificationDataManager != null) {
                        boolean hasUnseen =
                                mNotificationDataManager.getUnseenNotificationCount() > 0;
                        mCarNavigationBarController.toggleAllNotificationsUnseenIndicator(
                                mDeviceProvisionedController.isCurrentUserSetup(), hasUnseen);
                    }
                });
        mNotificationDataManager.setOnUnseenCountUpdateListener(this::onUnseenCountUpdate);

        mEnableHeadsUpNotificationWhenNotificationShadeOpen = mContext.getResources().getBoolean(
                R.bool.config_enableHeadsUpNotificationWhenNotificationShadeOpen);
@@ -691,6 +683,18 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        });
    }

    /**
     * This method is called whenever there is an update to the number of unseen notifications.
     * This method can be extended by OEMs to customize the desired logic.
     */
    protected void onUnseenCountUpdate() {
        if (mNotificationDataManager != null) {
            boolean hasUnseen = mNotificationDataManager.getUnseenNotificationCount() > 0;
            mCarNavigationBarController.toggleAllNotificationsUnseenIndicator(
                    mDeviceProvisionedController.isCurrentUserSetup(), hasUnseen);
        }
    }

    /**
     * @return true if the notification panel is currently visible
     */