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

Commit b0058e12 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add overview button handling to Go recents." into ub-launcher3-master

parents c8d33f8b c977ea9a
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.OverviewInteractionState;
import com.android.quickstep.views.IconRecentsView;

import java.util.ArrayList;

@@ -87,7 +88,10 @@ public abstract class RecentsUiFactory {
     *
     * @param launcher the launcher activity
     */
    public static void resetOverview(Launcher launcher) {}
    public static void resetOverview(Launcher launcher) {
        IconRecentsView recentsView = launcher.getOverviewPanel();
        recentsView.setTransitionedFromApp(false);
    }

    /**
     * Recents logic that triggers when launcher state changes or launcher activity stops/resumes.
+5 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import androidx.annotation.NonNull;
import com.android.launcher3.BaseDraggingActivity;
import com.android.quickstep.util.MultiValueUpdateListener;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.views.IconRecentsView;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat;
@@ -100,6 +101,10 @@ final class AppToOverviewAnimationProvider<T extends BaseDraggingActivity> imple
            return anim;
        }

        RemoteAnimationTargetSet targetSet =
                new RemoteAnimationTargetSet(targetCompats, MODE_CLOSING);
        mRecentsView.setTransitionedFromApp(!targetSet.isAnimatingHome());

        RemoteAnimationTargetCompat recentsTarget = null;
        RemoteAnimationTargetCompat closingAppTarget = null;

+2 −2
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ public class OverviewCommandHelper {
            if (recents == null) {
                return false;
            }
            //TODO: Launch last running task or go to home.
            recents.handleOverviewCommand();
            return true;
        }
    }
@@ -146,7 +146,7 @@ public class OverviewCommandHelper {
        protected boolean handleCommand(long elapsedTime) {
            IconRecentsView recents = mHelper.getVisibleRecentsView();
            if (recents != null) {
                //TODO: Launch next task in icon recents.
                recents.handleOverviewCommand();
                return true;
            } else if (elapsedTime < ViewConfiguration.getDoubleTapTimeout()) {
                // The user tried to launch back into overview too quickly, either after
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import com.android.systemui.shared.recents.model.Task;
 * A recycler view holder that holds the task view and binds {@link Task} content (app title, icon,
 * etc.) to the view.
 */
final class TaskHolder extends ViewHolder {
public final class TaskHolder extends ViewHolder {

    private final TaskItemView mTaskItemView;
    private Task mTask;
+35 −1
Original line number Diff line number Diff line
@@ -35,8 +35,9 @@ import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;

import com.android.launcher3.R;
import com.android.quickstep.RecentsToActivityHelper;
import com.android.quickstep.TaskAdapter;
import com.android.quickstep.TaskActionController;
import com.android.quickstep.TaskAdapter;
import com.android.quickstep.TaskHolder;
import com.android.quickstep.TaskListLoader;
import com.android.quickstep.TaskSwipeCallback;

@@ -80,6 +81,7 @@ public final class IconRecentsView extends FrameLayout {
    private RecyclerView mTaskRecyclerView;
    private View mEmptyView;
    private View mContentView;
    private boolean mTransitionedFromApp;

    public IconRecentsView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -146,6 +148,38 @@ public final class IconRecentsView extends FrameLayout {
        });
    }

    /**
     * Set whether we transitioned to recents from the most recent app.
     *
     * @param transitionedFromApp true if transitioned from the most recent app, false otherwise
     */
    public void setTransitionedFromApp(boolean transitionedFromApp) {
        mTransitionedFromApp = transitionedFromApp;
    }

    /**
     * Handles input from the overview button. Launch the most recent task unless we just came from
     * the app. In that case, we launch the next most recent.
     */
    public void handleOverviewCommand() {
        int childCount = mTaskRecyclerView.getChildCount();
        if (childCount == 0) {
            // Do nothing
            return;
        }
        TaskHolder taskToLaunch;
        if (mTransitionedFromApp && childCount > 1) {
            // Launch the next most recent app
            TaskItemView itemView = (TaskItemView) mTaskRecyclerView.getChildAt(1);
            taskToLaunch = (TaskHolder) mTaskRecyclerView.getChildViewHolder(itemView);
        } else {
            // Launch the most recent app
            TaskItemView itemView = (TaskItemView) mTaskRecyclerView.getChildAt(0);
            taskToLaunch = (TaskHolder) mTaskRecyclerView.getChildViewHolder(itemView);
        }
        mTaskActionController.launchTask(taskToLaunch);
    }

    /**
     * Get the thumbnail view associated with a task for the purposes of animation.
     *