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

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

Merge "Add TaskInputController for Recents Go" into ub-launcher3-master

parents 0bef2bf8 1ae97d81
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -35,17 +35,23 @@ public final class TaskAdapter extends Adapter<TaskHolder> {
    private static final int MAX_TASKS_TO_DISPLAY = 6;
    private static final String TAG = "TaskAdapter";
    private final TaskListLoader mLoader;
    private TaskInputController mInputController;

    public TaskAdapter(@NonNull TaskListLoader loader) {
        mLoader = loader;
    }

    public void setInputController(TaskInputController inputController) {
        mInputController = inputController;
    }

    @Override
    public TaskHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        // TODO: Swap in an actual task view here (view w/ icon, label, etc.)
        TaskItemView itemView = (TaskItemView) LayoutInflater.from(parent.getContext())
                .inflate(R.layout.task_item_view, parent, false);
        return new TaskHolder(itemView);
        TaskHolder holder = new TaskHolder(itemView);
        itemView.setOnClickListener(view -> mInputController.onTaskClicked(holder));
        return holder;
    }

    @Override
+12 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.quickstep;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;

import com.android.quickstep.views.TaskItemView;
@@ -27,6 +28,7 @@ import com.android.systemui.shared.recents.model.Task;
final class TaskHolder extends ViewHolder {

    private final TaskItemView mTaskItemView;
    private Task mTask;

    public TaskHolder(TaskItemView itemView) {
        super(itemView);
@@ -40,7 +42,17 @@ final class TaskHolder extends ViewHolder {
     * @param task the task to bind to the view
     */
    public void bindTask(Task task) {
        mTask = task;
        mTaskItemView.setLabel(task.titleDescription);
        mTaskItemView.setIcon(task.icon);
    }

    /**
     * Gets the task currently bound to this view
     *
     * @return the current task
     */
    public @NonNull Task getTask() {
        return mTask;
    }
}
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.systemui.shared.system.ActivityManagerWrapper;

/**
 * Controller responsible for task logic that occurs on various input to the recents view.
 */
public final class TaskInputController {

    TaskAdapter mAdapter;

    public TaskInputController(TaskAdapter adapter) {
        mAdapter = adapter;
    }

    /**
     * Logic that occurs when a task view is tapped. Launches the respective task.
     *
     * @param viewHolder the task view holder that has been tapped
     */
    public void onTaskClicked(TaskHolder viewHolder) {
        // TODO: Add app launch animation as part of the launch options here.
        ActivityManagerWrapper.getInstance().startActivityFromRecentsAsync(viewHolder.getTask().key,
                null /* options */, null /* resultCallback */, null /* resultCallbackHandler */);
    }

    // TODO: Implement swipe to delete and notify adapter that data has updated

    // TODO: Implement "Clear all" and notify adapter that data has updated
}
+4 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import androidx.recyclerview.widget.RecyclerView;

import com.android.launcher3.R;
import com.android.quickstep.TaskAdapter;
import com.android.quickstep.TaskInputController;
import com.android.quickstep.TaskListLoader;

/**
@@ -79,6 +80,7 @@ public final class IconRecentsView extends FrameLayout {
    private float mTranslationYFactor;
    private TaskAdapter mTaskAdapter;
    private RecyclerView mTaskRecyclerView;
    private TaskInputController mTaskInputController;
    private TaskListLoader mTaskLoader;

    public IconRecentsView(Context context, AttributeSet attrs) {
@@ -91,6 +93,8 @@ public final class IconRecentsView extends FrameLayout {
        super.onFinishInflate();
        mTaskLoader = new TaskListLoader(mContext);
        mTaskAdapter = new TaskAdapter(mTaskLoader);
        mTaskInputController = new TaskInputController(mTaskAdapter);
        mTaskAdapter.setInputController(mTaskInputController);
        mTaskRecyclerView = findViewById(R.id.recent_task_recycler_view);
        mTaskRecyclerView.setAdapter(mTaskAdapter);
        mTaskRecyclerView.setLayoutManager(