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

Commit e2ac5207 authored by John Spurlock's avatar John Spurlock
Browse files

Disable lockscreen window anim when launching camera.

Prevent the exit animation from running when exiting the lockscreen
due to launching the camera from the camera widget.

Bug:7429770
Change-Id: I2a0148d84158fca11dda4c4a563fe5ab3236be81
parent cf69c56b
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
@@ -47,6 +48,7 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
    private final Handler mHandler = new Handler();
    private final KeyguardActivityLauncher mActivityLauncher;
    private final Callbacks mCallbacks;
    private final WindowManager mWindowManager;

    private View mWidgetView;
    private long mLaunchCameraStart;
@@ -81,6 +83,7 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli

        mCallbacks = callbacks;
        mActivityLauncher = activityLauncher;
        mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    }

    public static CameraWidgetFrame create(Context context, Callbacks callbacks,
@@ -200,6 +203,7 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
                scaleX, scaleY,
                startCenter, finishCenter));

        enableWindowExitAnimation(false);
        animate()
            .scaleX(scale)
            .scaleY(scale)
@@ -305,6 +309,7 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
        setScaleX(1);
        setScaleY(1);
        setTranslationY(0);
        enableWindowExitAnimation(true);
    }

    @Override
@@ -312,4 +317,14 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
        super.onAttachedToWindow();
        mHandler.post(mRenderRunnable);
    }

    private void enableWindowExitAnimation(boolean isEnabled) {
        View root = getRootView();
        WindowManager.LayoutParams lp = (WindowManager.LayoutParams) root.getLayoutParams();
        int newWindowAnimations = isEnabled ? com.android.internal.R.style.Animation_LockScreen : 0;
        if (newWindowAnimations != lp.windowAnimations) {
            lp.windowAnimations = newWindowAnimations;
            mWindowManager.updateViewLayout(root, lp);
        }
    }
}