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

Commit 57dbe94c authored by Christian Göllner's avatar Christian Göllner
Browse files

[Motion] Split-shade transition on LS: cross-fade status bars

Before, both the keyguard status bar and the split shade header
were showing at the same time during the shade expansion.

With this change, we make sure the keyguard status bar is faded
out before the split shade header fades in.

Fixes: 226548318
Test: Unit tests + Manually
Change-Id: I5757e7d6c065ee156030e434c19a965f8e1ef2f3
parent 0f3393a4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -494,6 +494,9 @@ class LockscreenShadeTransitionController @Inject constructor(
        }
        notificationPanelController
            .setKeyguardTransitionProgress(keyguardAlpha, keyguardTranslationY)

        val statusBarAlpha = if (useSplitShade) keyguardAlpha else -1f
        notificationPanelController.setKeyguardStatusBarAlpha(statusBarAlpha)
    }

    private fun setDragDownAmountAnimated(
+24 −3
Original line number Diff line number Diff line
@@ -229,6 +229,11 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
    private boolean mShowingKeyguardHeadsUp;
    private StatusBarSystemEventAnimator mSystemEventAnimator;

    /**
     * The alpha value to be set on the View. If -1, this value is to be ignored.
     */
    private float mExplicitAlpha = -1f;

    @Inject
    public KeyguardStatusBarViewController(
            KeyguardStatusBarView view,
@@ -425,9 +430,15 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat

        float alphaQsExpansion = 1 - Math.min(
                1, mNotificationPanelViewStateProvider.getLockscreenShadeDragProgress() * 2);
        float newAlpha = Math.min(getKeyguardContentsAlpha(), alphaQsExpansion)

        float newAlpha;
        if (mExplicitAlpha != -1) {
            newAlpha = mExplicitAlpha;
        } else {
            newAlpha = Math.min(getKeyguardContentsAlpha(), alphaQsExpansion)
                    * mKeyguardStatusBarAnimateAlpha
                    * (1.0f - mKeyguardHeadsUpShowingAmount);
        }

        boolean hideForBypass =
                mFirstBypassAttempt && mKeyguardUpdateMonitor.shouldListenForFace()
@@ -510,7 +521,17 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("KeyguardStatusBarView:");
        pw.println("  mBatteryListening: " + mBatteryListening);
        pw.println("  mExplicitAlpha: " + mExplicitAlpha);
        mView.dump(fd, pw, args);
    }

    /**
     * Sets the alpha to be set on the view.
     *
     * @param alpha a value between 0 and 1. -1 if the value is to be reset/ignored.
     */
    public void setAlpha(float alpha) {
        mExplicitAlpha = alpha;
        updateViewState();
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -2682,6 +2682,15 @@ public class NotificationPanelViewController extends PanelViewController {
        updateClock();
    }

    /**
     * Sets the alpha value to be set on the keyguard status bar.
     *
     * @param alpha value between 0 and 1. -1 if the value is to be reset.
     */
    public void setKeyguardStatusBarAlpha(float alpha) {
        mKeyguardStatusBarViewController.setAlpha(alpha);
    }

    private void trackMovement(MotionEvent event) {
        if (mQsVelocityTracker != null) mQsVelocityTracker.addMovement(event);
    }
+22 −0
Original line number Diff line number Diff line
@@ -413,6 +413,28 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
        verifyZeroInteractions(singleShadeOverScroller)
    }

    @Test
    fun setDragDownAmount_inSplitShade_setsKeyguardStatusBarAlphaBasedOnDistance() {
        val alphaDistance = context.resources.getDimensionPixelSize(
            R.dimen.lockscreen_shade_npvc_keyguard_content_alpha_transition_distance)
        val dragDownAmount = 10f
        enableSplitShade()

        transitionController.dragDownAmount = dragDownAmount

        val expectedAlpha = 1 - dragDownAmount / alphaDistance
        verify(notificationPanelController).setKeyguardStatusBarAlpha(expectedAlpha)
    }

    @Test
    fun setDragDownAmount_notInSplitShade_setsKeyguardStatusBarAlphaToMinusOne() {
        disableSplitShade()

        transitionController.dragDownAmount = 10f

        verify(notificationPanelController).setKeyguardStatusBarAlpha(-1f)
    }

    private fun enableSplitShade() {
        setSplitShadeEnabled(true)
    }
+22 −0
Original line number Diff line number Diff line
@@ -343,6 +343,28 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
        assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE);
    }

    @Test
    public void setAlpha_explicitAlpha_setsExplicitAlpha() {
        mController.onViewAttached();
        updateStateToKeyguard();

        mController.setAlpha(0.5f);

        assertThat(mKeyguardStatusBarView.getAlpha()).isEqualTo(0.5f);
    }

    @Test
    public void setAlpha_explicitAlpha_thenMinusOneAlpha_setsAlphaBasedOnDefaultCriteria() {
        mController.onViewAttached();
        updateStateToKeyguard();

        mController.setAlpha(0.5f);
        mController.setAlpha(-1f);

        assertThat(mKeyguardStatusBarView.getAlpha()).isGreaterThan(0);
        assertThat(mKeyguardStatusBarView.getAlpha()).isNotEqualTo(0.5f);
    }

    // TODO(b/195442899): Add more tests for #updateViewState once CLs are finalized.

    @Test
Loading