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

Commit 928c11a1 authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Centering clock in split shade when no visible notifications

Adjusting constraints of KeyguardStatusView so that big clock is centered when there are no notifications on the lockscreen

Fixes: 190701966
Test: atest NotificationPanelViewTest
Change-Id: I3dd6497644df112826d4bb63362636a0fe85766a
parent 32fd2556
Loading
Loading
Loading
Loading
+27 −2
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ import android.os.SystemClock;
import android.os.UserManager;
import android.os.VibrationEffect;
import android.provider.Settings;
import android.transition.ChangeBounds;
import android.transition.TransitionManager;
import android.util.Log;
import android.util.MathUtils;
import android.view.LayoutInflater;
@@ -615,6 +617,8 @@ public class NotificationPanelViewController extends PanelViewController {

    private KeyguardMediaController mKeyguardMediaController;

    private boolean mStatusViewCentered = false;

    private View.AccessibilityDelegate mAccessibilityDelegate = new View.AccessibilityDelegate() {
        @Override
        public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
@@ -1022,16 +1026,16 @@ public class NotificationPanelViewController extends PanelViewController {
            constraintSet.connect(
                    R.id.notification_stack_scroller, START,
                    R.id.qs_edge_guideline, START);
            constraintSet.connect(R.id.keyguard_status_view, END, R.id.qs_edge_guideline, END);
        } else {
            constraintSet.connect(R.id.qs_frame, END, PARENT_ID, END);
            constraintSet.connect(R.id.notification_stack_scroller, START, PARENT_ID, START);
            constraintSet.connect(R.id.keyguard_status_view, END, PARENT_ID, END);
        }
        constraintSet.getConstraint(R.id.notification_stack_scroller).layout.mWidth = panelWidth;
        constraintSet.getConstraint(R.id.qs_frame).layout.mWidth = qsWidth;
        constraintSet.applyTo(mNotificationContainerParent);

        updateKeyguardStatusViewAlignment(false /* animate */);

        mKeyguardMediaController.refreshMediaPosition();
    }

@@ -1282,6 +1286,7 @@ public class NotificationPanelViewController extends PanelViewController {
        } else {
            mKeyguardStatusViewController.displayClock(LARGE);
        }
        updateKeyguardStatusViewAlignment(true /* animate */);
        int userIconHeight = mKeyguardQsUserSwitchController != null
                ? mKeyguardQsUserSwitchController.getUserIconHeight() : 0;
        float expandedFraction =
@@ -1325,6 +1330,26 @@ public class NotificationPanelViewController extends PanelViewController {
        updateClock();
    }

    private void updateKeyguardStatusViewAlignment(boolean animate) {
        boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
                .getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMedia();
        boolean shouldBeCentered = !mShouldUseSplitNotificationShade || !hasVisibleNotifications;
        if (mStatusViewCentered != shouldBeCentered) {
            mStatusViewCentered = shouldBeCentered;
            ConstraintSet constraintSet = new ConstraintSet();
            constraintSet.clone(mNotificationContainerParent);
            int statusConstraint = shouldBeCentered ? PARENT_ID : R.id.qs_edge_guideline;
            constraintSet.connect(R.id.keyguard_status_view, END, statusConstraint, END);
            if (animate) {
                ChangeBounds transition = new ChangeBounds();
                transition.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
                transition.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
                TransitionManager.beginDelayedTransition(mNotificationContainerParent, transition);
            }
            constraintSet.applyTo(mNotificationContainerParent);
        }
    }

    /**
     * @return the padding of the stackscroller when unlocked
     */
+8 −6
Original line number Diff line number Diff line
@@ -576,17 +576,19 @@ public class NotificationPanelViewTest extends SysuiTestCase {
    }

    @Test
    public void testKeyguardStatusView_isAlignedToGuidelineInSplitShadeMode() {
        mNotificationPanelViewController.updateResources();
    public void testKeyguardStatusViewInSplitShade_changesConstraintsDependingOnNotifications() {
        mStatusBarStateController.setState(KEYGUARD);
        enableSplitShade();

        when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2);
        mNotificationPanelViewController.updateResources();
        assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd)
                .isEqualTo(ConstraintSet.PARENT_ID);
                .isEqualTo(R.id.qs_edge_guideline);

        enableSplitShade();
        when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(0);
        mNotificationPanelViewController.updateResources();

        assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd)
                .isEqualTo(R.id.qs_edge_guideline);
                .isEqualTo(ConstraintSet.PARENT_ID);
    }

    @Test