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

Commit 468f2d3e authored by Ondrej Novak's avatar Ondrej Novak
Browse files

Animate activity when launching over keyguard

When launching new activity over keyguard, slide in the new activity from
bottom and collapse the notification panels

Test: manual
Change-Id: I26169755bbeacd1f907448ed542059ce8464af97
Bug: 35754927
parent 96fb339b
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2018 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromYDelta="90%"
        android:toYDelta="0%"
        android:interpolator="@interpolator/fast_out_slow_in"
        android:duration="400"/>
    <alpha
        android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:interpolator="@interpolator/fast_out_slow_in"
        android:duration="300"/>
</set>
+1 −0
Original line number Diff line number Diff line
@@ -2161,6 +2161,7 @@
  <java-symbol type="anim" name="push_down_out" />
  <java-symbol type="anim" name="push_up_in" />
  <java-symbol type="anim" name="push_up_out" />
  <java-symbol type="anim" name="keyguard_occlude_open_enter" />
  <java-symbol type="anim" name="lock_screen_behind_enter" />
  <java-symbol type="anim" name="lock_screen_behind_enter_wallpaper" />
  <java-symbol type="anim" name="lock_screen_behind_enter_fade_in" />
+8 −8
Original line number Diff line number Diff line
@@ -103,9 +103,9 @@ public class KeyguardClockPositionAlgorithm {
    private float mDarkAmount;

    /**
     * If keyguard will require a password or just fade away.
     * If keyguard will just fade away or will require a password.
     */
    private boolean mCurrentlySecure;
    private boolean mFadeAway;

    /**
     * Dozing and receiving a notification (AOD notification.)
@@ -135,7 +135,7 @@ public class KeyguardClockPositionAlgorithm {

    public void setup(int minTopMargin, int maxShadeBottom, int notificationStackHeight,
            float panelExpansion, int parentHeight,
            int keyguardStatusHeight, float dark, boolean secure, boolean pulsing,
            int keyguardStatusHeight, float dark, boolean fadeAway, boolean pulsing,
            int bouncerTop) {
        mMinTopMargin = minTopMargin + mContainerTopPadding;
        mMaxShadeBottom = maxShadeBottom;
@@ -144,7 +144,7 @@ public class KeyguardClockPositionAlgorithm {
        mHeight = parentHeight;
        mKeyguardStatusHeight = keyguardStatusHeight;
        mDarkAmount = dark;
        mCurrentlySecure = secure;
        mFadeAway = fadeAway;
        mPulsing = pulsing;
        mBouncerTop = bouncerTop;
    }
@@ -198,7 +198,7 @@ public class KeyguardClockPositionAlgorithm {

        float clockYRegular = getExpandedClockPosition();
        boolean hasEnoughSpace = mMinTopMargin + mKeyguardStatusHeight < mBouncerTop;
        float clockYTarget = mCurrentlySecure && hasEnoughSpace ?
        float clockYTarget = !mFadeAway && hasEnoughSpace ?
                mMinTopMargin : -mKeyguardStatusHeight;

        // Move clock up while collapsing the shade
@@ -218,11 +218,11 @@ public class KeyguardClockPositionAlgorithm {
     */
    private float getClockAlpha(int y) {
        float alphaKeyguard;
        if (mCurrentlySecure) {
            alphaKeyguard = 1;
        } else {
        if (mFadeAway) {
            alphaKeyguard = Math.max(0, y / Math.max(1f, getExpandedClockPosition()));
            alphaKeyguard = Interpolators.ACCELERATE.getInterpolation(alphaKeyguard);
        } else {
            alphaKeyguard = 1;
        }
        return MathUtils.lerp(alphaKeyguard, 1f, mDarkAmount);
    }
+2 −1
Original line number Diff line number Diff line
@@ -524,7 +524,8 @@ public class NotificationPanelView extends PanelView implements
                    totalHeight,
                    mKeyguardStatusView.getHeight(),
                    mInterpolatedDarkAmount,
                    mStatusBar.isKeyguardCurrentlySecure(),
                    !mStatusBar.isKeyguardCurrentlySecure()
                            || mStatusBar.isKeyguardOccludeAnimationRunning(),
                    mPulsing,
                    mBouncerTop);
            mClockPositionAlgorithm.run(mClockPositionResult);
+37 −5
Original line number Diff line number Diff line
@@ -322,6 +322,8 @@ public class StatusBar extends SystemUI implements DemoMode,
    public static final int FADE_KEYGUARD_START_DELAY = 100;
    public static final int FADE_KEYGUARD_DURATION = 300;
    public static final int FADE_KEYGUARD_DURATION_PULSING = 96;
    public static final int FADE_BACKDROP_DURATION = 300;
    public static final int FADE_BACKDROP_DURATION_FAST = 240;

    /** If true, the system is in the half-boot-to-decryption-screen state.
     * Prudently disable QS and notifications.  */
@@ -543,6 +545,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    private boolean mIsOccluded;
    private boolean mWereIconsJustHidden;
    private boolean mBouncerWasShowingWhenHidden;
    private boolean mKeyguardOccludeAnimationRunning;

    // Notifies StatusBarKeyguardViewManager every time the keyguard transition is over,
    // this animation is tied to the scrim for historic reasons.
@@ -1641,7 +1644,7 @@ public class StatusBar extends SystemUI implements DemoMode,

        boolean wakeAndUnlock = mBiometricUnlockController != null
            && mBiometricUnlockController.isWakeAndUnlock();
        if (mLaunchTransitionFadingAway || wakeAndUnlock) {
        if (mLaunchTransitionFadingAway && !mIsOccluded || wakeAndUnlock) {
            mBackdrop.setVisibility(View.INVISIBLE);
            Trace.endSection();
            return;
@@ -1760,7 +1763,8 @@ public class StatusBar extends SystemUI implements DemoMode,
                boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange();
                if (mBiometricUnlockController.getMode()
                        == BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
                        || hideBecauseOccluded || cannotAnimateDoze) {
                        || hideBecauseOccluded  && !mKeyguardOccludeAnimationRunning
                        || cannotAnimateDoze) {

                    // We are unlocking directly - no animation!
                    mBackdrop.setVisibility(View.GONE);
@@ -1771,7 +1775,9 @@ public class StatusBar extends SystemUI implements DemoMode,
                    mBackdrop.animate()
                            .alpha(SRC_MIN_ALPHA)
                            .setInterpolator(Interpolators.ACCELERATE_DECELERATE)
                            .setDuration(300)
                            .setDuration(
                                    mKeyguardOccludeAnimationRunning
                                            ? FADE_BACKDROP_DURATION_FAST : FADE_BACKDROP_DURATION)
                            .setStartDelay(0)
                            .withEndAction(() -> {
                                mBackdrop.setVisibility(View.GONE);
@@ -3667,6 +3673,27 @@ public class StatusBar extends SystemUI implements DemoMode,
                }).start();
    }

    /**
    * Is keyguard being occluded by a newly launched activity.
    */
    public boolean isKeyguardOccludeAnimationRunning() {
        return mKeyguardOccludeAnimationRunning;
    }

    /**
     * Plays the animation when new activity is launched over keyguard.
     */
    public void animateKeyguardOccluding() {
        mKeyguardOccludeAnimationRunning = true;
        addPostCollapseAction(() -> {
            mStatusBarKeyguardViewManager.reset(true /* hideBouncerWhenShowing */);
            mKeyguardOccludeAnimationRunning = false;
        });
        mStatusBarKeyguardViewManager.animateCollapsePanels(1.0f /* speedfactor */);
        updateScrimController();
        updateMediaMetaData(false /* metaDataChanged */, true /* allowEnterAnimation */);
    }

    /**
     * Plays the animation when an activity that was occluding Keyguard goes away.
     */
@@ -4012,7 +4039,7 @@ public class StatusBar extends SystemUI implements DemoMode,

    private void showBouncerIfKeyguard() {
        if ((mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)
                && !mKeyguardViewMediator.isHiding()) {
                && !mKeyguardViewMediator.isHiding() && !mKeyguardOccludeAnimationRunning) {
            showBouncer(true /* scrimmed */);
        }
    }
@@ -4512,6 +4539,11 @@ public class StatusBar extends SystemUI implements DemoMode,

        @Override
        public void onStartedGoingToSleep() {
            // in case we start going to sleep while new animation is launching over keyguard, make
            // sure to finish it
            if (mKeyguardOccludeAnimationRunning) {
                runPostCollapseRunnables();
            }
            notifyHeadsUpGoingToSleep();
            dismissVolumeDialog();
        }
@@ -4753,7 +4785,7 @@ public class StatusBar extends SystemUI implements DemoMode,
                    ? ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER;
            mScrimController.transitionTo(state);
        } else if (isInLaunchTransition() || mLaunchCameraOnScreenTurningOn
                || launchingAffordanceWithPreview) {
                || launchingAffordanceWithPreview || mKeyguardOccludeAnimationRunning) {
            mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
        } else if (mBrightnessMirrorVisible) {
            mScrimController.transitionTo(ScrimState.BRIGHTNESS_MIRROR);
Loading