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

Commit 63e6a4a1 authored by Lyn Han's avatar Lyn Han
Browse files

Allow overlap between notifications and lock icon

Fixes: 213934746
Test: NotificationPanelViewControllerTest
Test: visually inspect mKeyguardBottomPadding debug line

Change-Id: I21d630edf2b0b6690301da8d0c16527c6354643f
parent 3ce32193
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -388,6 +388,8 @@

    <dimen name="split_shade_notifications_scrim_margin_bottom">0dp</dimen>

    <dimen name="shelf_and_lock_icon_overlap">5dp</dimen>

    <dimen name="notification_panel_margin_horizontal">0dp</dimen>

    <dimen name="brightness_mirror_height">48dp</dimen>
+33 −16
Original line number Diff line number Diff line
@@ -389,6 +389,12 @@ public class NotificationPanelViewController extends PanelViewController {
    private int mLargeScreenShadeHeaderHeight;
    private int mSplitShadeNotificationsScrimMarginBottom;

    /**
     * Vertical overlap allowed between the bottom of the notification shelf and
     * the top of the lock icon or the under-display fingerprint sensor background.
     */
    private int mShelfAndLockIconOverlap;

    private final KeyguardClockPositionAlgorithm
            mClockPositionAlgorithm =
            new KeyguardClockPositionAlgorithm();
@@ -1081,6 +1087,9 @@ public class NotificationPanelViewController extends PanelViewController {
                mResources.getDimensionPixelSize(
                        R.dimen.split_shade_notifications_scrim_margin_bottom);

        mShelfAndLockIconOverlap =
                mResources.getDimensionPixelSize(R.dimen.shelf_and_lock_icon_overlap);

        final boolean newShouldUseSplitNotificationShade =
                LargeScreenUtils.shouldUseSplitNotificationShade(mResources);
        final boolean splitNotificationShadeChanged =
@@ -1466,27 +1475,18 @@ public class NotificationPanelViewController extends PanelViewController {
    }

    /**
     * @return the maximum keyguard notifications that can fit on the screen
     * @return Space available to show notifications on lockscreen.
     */
    @VisibleForTesting
    int computeMaxKeyguardNotifications() {
        if (mAmbientState.getFractionToShade() > 0 || mAmbientState.getDozeAmount() > 0) {
            return mMaxAllowedKeyguardNotifications;
        }
    float getSpaceForLockscreenNotifications() {
        float topPadding = mNotificationStackScrollLayoutController.getTopPadding();
        float shelfIntrinsicHeight =
                mNotificationShelfController.getVisibility() == View.GONE
                        ? 0
                        : mNotificationShelfController.getIntrinsicHeight();

        // Padding to add to the bottom of the stack to keep a minimum distance from the top of
        // the lock icon.
        float lockIconPadding = 0;
        // Space between bottom of notifications and top of lock icon or udfps background.
        float lockIconPadding = mLockIconViewController.getTop();
        if (mLockIconViewController.getTop() != 0) {
            final float lockIconTopWithPadding = mLockIconViewController.getTop()
                    - mResources.getDimensionPixelSize(R.dimen.min_lock_icon_padding);
            lockIconPadding = mNotificationStackScrollLayoutController.getBottom()
                    - lockIconTopWithPadding;
                    - mLockIconViewController.getTop()
                    - mShelfAndLockIconOverlap;
        }

        float bottomPadding = Math.max(lockIconPadding,
@@ -1497,9 +1497,26 @@ public class NotificationPanelViewController extends PanelViewController {
                mNotificationStackScrollLayoutController.getHeight()
                        - topPadding
                        - bottomPadding;
        return availableSpace;
    }

    /**
     * @return Maximum number of notifications that can fit on keyguard.
     */
    @VisibleForTesting
    int computeMaxKeyguardNotifications() {
        if (mAmbientState.getFractionToShade() > 0 || mAmbientState.getDozeAmount() > 0) {
            return mMaxAllowedKeyguardNotifications;
        }

        final float shelfIntrinsicHeight =
                mNotificationShelfController.getVisibility() == View.GONE
                        ? 0
                        : mNotificationShelfController.getIntrinsicHeight();

        return mNotificationStackSizeCalculator.computeMaxKeyguardNotifications(
                mNotificationStackScrollLayoutController.getView(), availableSpace,
                mNotificationStackScrollLayoutController.getView(),
                getSpaceForLockscreenNotifications(),
                shelfIntrinsicHeight);
    }

+21 −0
Original line number Diff line number Diff line
@@ -588,6 +588,27 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
                .isNotEqualTo(-1);
    }

    @Test
    public void getLockscreenSpaceForNotifications_includesOverlapWithLockIcon() {
        when(mResources.getDimensionPixelSize(R.dimen.keyguard_indication_bottom_padding))
                .thenReturn(0);
        mNotificationPanelViewController.setAmbientIndicationTop(
                /* ambientIndicationTop= */ 0, /* ambientTextVisible */ false);

        // Use lock icon padding (100 - 80 - 5 = 15) as bottom padding
        when(mNotificationStackScrollLayoutController.getBottom()).thenReturn(100);
        when(mLockIconViewController.getTop()).thenReturn(80f);
        when(mResources.getDimensionPixelSize(R.dimen.shelf_and_lock_icon_overlap)).thenReturn(5);

        // Available space (100 - 10 - 15 = 75)
        when(mNotificationStackScrollLayoutController.getHeight()).thenReturn(100);
        when(mNotificationStackScrollLayoutController.getTopPadding()).thenReturn(10);
        mNotificationPanelViewController.updateResources();

        assertThat(mNotificationPanelViewController.getSpaceForLockscreenNotifications())
                .isEqualTo(75);
    }

    @Test
    public void testSetPanelScrimMinFraction() {
        mNotificationPanelViewController.setPanelScrimMinFraction(0.5f);