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

Commit 3aaf3967 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Remove sensor manager from RecentsView

This disables the rotation animation in
overview, but should hopefully fix tests.

fixes: 150260456
Change-Id: I121cad155672c2e325cc0f83ce209be0d3806b1c
parent 9caed38e
Loading
Loading
Loading
Loading
+0 −53
Original line number Diff line number Diff line
@@ -169,7 +169,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
                }
            };

    private final OrientationEventListener mOrientationListener;
    private int mPreviousRotation;
    protected RecentsAnimationController mRecentsAnimationController;
    protected RecentsAnimationTargets mRecentsAnimationTargets;
@@ -377,22 +376,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl

        // Initialize quickstep specific cache params here, as this is constructed only once
        mActivity.getViewCache().setCacheSize(R.layout.digital_wellbeing_toast, 5);
        mOrientationListener = new OrientationEventListener(getContext()) {
            @Override
            public void onOrientationChanged(int i) {
                int rotation = RotationHelper.getRotationFromDegrees(i);
                if (mPreviousRotation != rotation) {
                    animateRecentsRotationInPlace(rotation);
                    if (rotation == 0) {
                        showActionsView();
                    } else {
                        hideActionsView();
                    }
                    mPreviousRotation = rotation;
                }
            }
        };

    }

    public OverScroller getScroller() {
@@ -521,13 +504,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
    }

    public void setOverviewStateEnabled(boolean enabled) {
        if (supportsVerticalLandscape() && mOrientationListener.canDetectOrientation()) {
            if (enabled) {
                mOrientationListener.enable();
            } else {
                mOrientationListener.disable();
            }
        }
        mOverviewStateEnabled = enabled;
        updateTaskStackListenerState();
        if (!enabled) {
@@ -968,35 +944,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        setSwipeDownShouldLaunchApp(true);
    }

    private void animateRecentsRotationInPlace(int newRotation) {
        if (!supportsVerticalLandscape()) {
            return;
        }

        AnimatorSet pa = setRecentsChangedOrientation(true);
        pa.addListener(AnimationSuccessListener.forRunnable(() -> {
            updateLayoutRotation(newRotation);
            ((DragLayer) mActivity.getDragLayer()).recreateControllers();
            rotateAllChildTasks();
            setRecentsChangedOrientation(false).start();
        }));
        pa.start();
    }

    public AnimatorSet setRecentsChangedOrientation(boolean fadeInChildren) {
        getRunningTaskIndex();
        int runningIndex = getCurrentPage();
        AnimatorSet as = new AnimatorSet();
        for (int i = 0; i < getTaskViewCount(); i++) {
            if (runningIndex == i) {
                continue;
            }
            View taskView = getTaskViewAt(i);
            as.play(ObjectAnimator.ofFloat(taskView, View.ALPHA, fadeInChildren ? 0 : 1));
        }
        return as;
    }

    abstract protected boolean supportsVerticalLandscape();

    private void rotateAllChildTasks() {