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

Commit 1a341002 authored by Winson Chung's avatar Winson Chung
Browse files

Add code path for the recents animation using window transitions.

Test: Enable in settings, swipe up

Change-Id: I1053f9e519c2f612bd3db0b66cd16ad9a30bfeb4
parent d30e74b5
Loading
Loading
Loading
Loading
+7.23 KiB (108 KiB)

File changed.

No diff preview for this file type.

+42 −0
Original line number Diff line number Diff line
/*
 * 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.
 */
package com.android.quickstep;

import com.android.launcher3.states.InternalStateHandler;
import com.android.quickstep.TouchInteractionService.InteractionType;

public abstract class BaseSwipeInteractionHandler extends InternalStateHandler {

    protected Runnable mGestureEndCallback;

    public void setGestureEndCallback(Runnable gestureEndCallback) {
        mGestureEndCallback = gestureEndCallback;
    }

    public void reset() {}

    public abstract void onGestureStarted();

    public abstract void onGestureEnded(float endVelocity);

    public abstract void updateInteractionType(@InteractionType int interactionType);

    public abstract void onQuickScrubEnd();

    public abstract void onQuickScrubProgress(float progress);

    public abstract void updateDisplacement(float displacement);
}
+77 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.
 */
package com.android.quickstep;

import android.graphics.Rect;
import android.view.MotionEvent;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;

/**
 * Floating view which shows the task snapshot allowing it to be dragged and placed.
 */
public class LauncherLayoutListener extends AbstractFloatingView implements Insettable {

    private final Launcher mLauncher;
    private final WindowTransformSwipeHandler mHandler;

    public LauncherLayoutListener(Launcher launcher, WindowTransformSwipeHandler handler) {
        super(launcher, null);
        mLauncher = launcher;
        mHandler = handler;
        setVisibility(INVISIBLE);
    }

    @Override
    public void setInsets(Rect insets) {
        requestLayout();
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
        mHandler.onLauncherLayoutChanged();
    }

    @Override
    public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
        return false;
    }

    @Override
    protected void handleClose(boolean animate) {
        // We dont suupport animate.
        mLauncher.getDragLayer().removeView(this);
        mHandler.layoutListenerClosed();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        setMeasuredDimension(1, 1);
    }

    @Override
    public void logActionCommand(int command) {
        // We should probably log the weather
    }

    @Override
    protected boolean isOfType(int type) {
        return (type & TYPE_QUICKSTEP_PREVIEW) != 0;
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -55,4 +55,8 @@ public class MultiStateCallback {
    public void addCallback(int stateMask, Runnable callback) {
        mCallbacks.put(stateMask, callback);
    }

    public int getState() {
        return mState;
    }
}
+21 −5
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.Launcher.OnResumeCallback;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
@@ -48,7 +49,6 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.states.InternalStateHandler;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.TouchInteractionService.InteractionType;
@@ -59,7 +59,8 @@ import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.WindowManagerWrapper;

@TargetApi(Build.VERSION_CODES.O)
public class NavBarSwipeInteractionHandler extends InternalStateHandler {
public class NavBarSwipeInteractionHandler extends BaseSwipeInteractionHandler implements
        OnResumeCallback {

    private static final int STATE_LAUNCHER_READY = 1 << 0;
    private static final int STATE_ACTIVITY_MULTIPLIER_COMPLETE = 1 << 4;
@@ -187,7 +188,8 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
    }

    @Override
    protected void init(Launcher launcher, boolean alreadyOnHome) {
    protected boolean init(Launcher launcher, boolean alreadyOnHome) {
        launcher.setOnResumeCallback(this);
        mLauncher = launcher;
        mRecentsView = launcher.getOverviewPanel();
        mRecentsView.showTask(mRunningTask);
@@ -212,9 +214,9 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
            mLauncher.getAppsView().setVisibility(View.GONE);
        }
        TraceHelper.partitionSection("TouchInt", "Launcher on new intent");
        return false;
    }


    public void updateInteractionType(@InteractionType int interactionType) {
        Preconditions.assertUIThread();
        if (mInteractionType != INTERACTION_NORMAL) {
@@ -288,8 +290,11 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
                ? mHotseat.getWidth() : mHotseat.getHeight();
    }

    @Override
    public void onGestureStarted() { }

    @UiThread
    public void endTouch(float endVelocity) {
    public void onGestureEnded(float endVelocity) {
        if (mTouchEndHandled) {
            return;
        }
@@ -349,13 +354,24 @@ public class NavBarSwipeInteractionHandler extends InternalStateHandler {
        ActivityManagerWrapper.getInstance().startActivityFromRecentsAsync(key, opts, null, null);
    }

    public void reset() {
        mCurrentShift.cancelAnimation();
        if (mGestureEndCallback != null) {
            mGestureEndCallback.run();
        }
    }

    private void cleanupLauncher() {
        reset();

        // TODO: These should be done as part of ActivityOptions#OnAnimationStarted
        mLauncher.getStateManager().reapplyState();
        mLauncher.setOnResumeCallback(() -> mDragView.close(false));
    }

    private void onAnimationToLauncherComplete() {
        reset();

        mDragView.close(false);
        View currentRecentsPage = mRecentsView.getPageAt(mRecentsView.getCurrentPage());
        if (currentRecentsPage instanceof TaskView) {
Loading