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

Commit cc03fe48 authored by Lyn Han's avatar Lyn Han Committed by Automerger Merge Worker
Browse files

Merge "Allow overlap between notifications and lock icon" into tm-dev am: 44286954 am: 49e1be67

parents 5e776643 49e1be67
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -388,6 +388,8 @@


    <dimen name="split_shade_notifications_scrim_margin_bottom">0dp</dimen>
    <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="notification_panel_margin_horizontal">0dp</dimen>


    <dimen name="brightness_mirror_height">48dp</dimen>
    <dimen name="brightness_mirror_height">48dp</dimen>
+33 −16
Original line number Original line Diff line number Diff line
@@ -391,6 +391,12 @@ public class NotificationPanelViewController extends PanelViewController {
    private int mLargeScreenShadeHeaderHeight;
    private int mLargeScreenShadeHeaderHeight;
    private int mSplitShadeNotificationsScrimMarginBottom;
    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
    private final KeyguardClockPositionAlgorithm
            mClockPositionAlgorithm =
            mClockPositionAlgorithm =
            new KeyguardClockPositionAlgorithm();
            new KeyguardClockPositionAlgorithm();
@@ -1104,6 +1110,9 @@ public class NotificationPanelViewController extends PanelViewController {
                mResources.getDimensionPixelSize(
                mResources.getDimensionPixelSize(
                        R.dimen.split_shade_notifications_scrim_margin_bottom);
                        R.dimen.split_shade_notifications_scrim_margin_bottom);


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

        final boolean newShouldUseSplitNotificationShade =
        final boolean newShouldUseSplitNotificationShade =
                LargeScreenUtils.shouldUseSplitNotificationShade(mResources);
                LargeScreenUtils.shouldUseSplitNotificationShade(mResources);
        final boolean splitNotificationShadeChanged =
        final boolean splitNotificationShadeChanged =
@@ -1489,27 +1498,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
    @VisibleForTesting
    int computeMaxKeyguardNotifications() {
    float getSpaceForLockscreenNotifications() {
        if (mAmbientState.getFractionToShade() > 0 || mAmbientState.getDozeAmount() > 0) {
            return mMaxAllowedKeyguardNotifications;
        }
        float topPadding = mNotificationStackScrollLayoutController.getTopPadding();
        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
        // Space between bottom of notifications and top of lock icon or udfps background.
        // the lock icon.
        float lockIconPadding = mLockIconViewController.getTop();
        float lockIconPadding = 0;
        if (mLockIconViewController.getTop() != 0) {
        if (mLockIconViewController.getTop() != 0) {
            final float lockIconTopWithPadding = mLockIconViewController.getTop()
                    - mResources.getDimensionPixelSize(R.dimen.min_lock_icon_padding);
            lockIconPadding = mNotificationStackScrollLayoutController.getBottom()
            lockIconPadding = mNotificationStackScrollLayoutController.getBottom()
                    - lockIconTopWithPadding;
                    - mLockIconViewController.getTop()
                    - mShelfAndLockIconOverlap;
        }
        }


        float bottomPadding = Math.max(lockIconPadding,
        float bottomPadding = Math.max(lockIconPadding,
@@ -1520,9 +1520,26 @@ public class NotificationPanelViewController extends PanelViewController {
                mNotificationStackScrollLayoutController.getHeight()
                mNotificationStackScrollLayoutController.getHeight()
                        - topPadding
                        - topPadding
                        - bottomPadding;
                        - 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(
        return mNotificationStackSizeCalculator.computeMaxKeyguardNotifications(
                mNotificationStackScrollLayoutController.getView(), availableSpace,
                mNotificationStackScrollLayoutController.getView(),
                getSpaceForLockscreenNotifications(),
                shelfIntrinsicHeight);
                shelfIntrinsicHeight);
    }
    }


+21 −0
Original line number Original line Diff line number Diff line
@@ -594,6 +594,27 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
                .isNotEqualTo(-1);
                .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
    @Test
    public void testSetPanelScrimMinFraction() {
    public void testSetPanelScrimMinFraction() {
        mNotificationPanelViewController.setPanelScrimMinFraction(0.5f);
        mNotificationPanelViewController.setPanelScrimMinFraction(0.5f);