Add TaskInputController for Recents Go
Add TaskInputController, a class handling input logic for the Recents Go
view. This CL hooks up the tap to launch logic with swiping + clear all
to be added in a later CL.
Bug: 114136250
Test: Build Launcher3IconRecentsGo and tap apps; see that they launch
task
Change-Id: I03e14a6f66307b9c6239cdeaec95d09f160fa3e0
diff --git a/go/quickstep/src/com/android/quickstep/TaskAdapter.java b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
index d3fd240..99446d0 100644
--- a/go/quickstep/src/com/android/quickstep/TaskAdapter.java
+++ b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
@@ -35,17 +35,23 @@
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
diff --git a/go/quickstep/src/com/android/quickstep/TaskHolder.java b/go/quickstep/src/com/android/quickstep/TaskHolder.java
index 47398c8..67e8ece 100644
--- a/go/quickstep/src/com/android/quickstep/TaskHolder.java
+++ b/go/quickstep/src/com/android/quickstep/TaskHolder.java
@@ -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 @@
final class TaskHolder extends ViewHolder {
private final TaskItemView mTaskItemView;
+ private Task mTask;
public TaskHolder(TaskItemView itemView) {
super(itemView);
@@ -40,7 +42,17 @@
* @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;
+ }
}
diff --git a/go/quickstep/src/com/android/quickstep/TaskInputController.java b/go/quickstep/src/com/android/quickstep/TaskInputController.java
new file mode 100644
index 0000000..66c4496
--- /dev/null
+++ b/go/quickstep/src/com/android/quickstep/TaskInputController.java
@@ -0,0 +1,45 @@
+/*
+ * 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
+}
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index afb0540..e8a915f 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -28,6 +28,7 @@
import com.android.launcher3.R;
import com.android.quickstep.TaskAdapter;
+import com.android.quickstep.TaskInputController;
import com.android.quickstep.TaskListLoader;
/**
@@ -79,6 +80,7 @@
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 @@
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(