summaryrefslogtreecommitdiffstats
path: root/go
diff options
context:
space:
mode:
authorKevin <kevhan@google.com>2019-02-25 12:04:02 -0800
committerKevin <kevhan@google.com>2019-02-26 13:30:14 -0800
commit0fcd22fc66ef544c2e082b7a5aa406edc78e22a9 (patch)
treef6acd7e93bfceff533fe62b35bed620d5f4bc3e3 /go
parentb04dabf7efe49a69b3663734840cf772fd106804 (diff)
downloadpackages_apps_Trebuchet-0fcd22fc66ef544c2e082b7a5aa406edc78e22a9.tar.gz
packages_apps_Trebuchet-0fcd22fc66ef544c2e082b7a5aa406edc78e22a9.tar.bz2
packages_apps_Trebuchet-0fcd22fc66ef544c2e082b7a5aa406edc78e22a9.zip
Add TaskAdapter to recents Go.
This CL adds a recycler view adapter for tasks to manage the item control logic. The data source itself and view hierarchy is planned to be added in future CLs. Bug: 114136250 Test: Build l3GoIconRecents Change-Id: I72d4f9df68d17fd745947d36522cde342ea58317
Diffstat (limited to 'go')
-rw-r--r--go/quickstep/src/com/android/quickstep/TaskAdapter.java58
-rw-r--r--go/quickstep/src/com/android/quickstep/TaskHolder.java48
-rw-r--r--go/quickstep/src/com/android/quickstep/views/IconRecentsView.java20
3 files changed, 125 insertions, 1 deletions
diff --git a/go/quickstep/src/com/android/quickstep/TaskAdapter.java b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
new file mode 100644
index 000000000..77c3f33b0
--- /dev/null
+++ b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
@@ -0,0 +1,58 @@
+/*
+ * 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 android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView.Adapter;
+
+import com.android.systemui.shared.recents.model.Task;
+
+import java.util.ArrayList;
+
+/**
+ * Recycler view adapter that dynamically inflates and binds {@link TaskHolder} instances with the
+ * appropriate {@link Task} from the recents task list.
+ */
+public final class TaskAdapter extends Adapter<TaskHolder> {
+
+ private static final int MAX_TASKS_TO_DISPLAY = 6;
+ private static final String TAG = "TaskAdapter";
+ private final ArrayList<Task> mTaskList;
+
+ public TaskAdapter(@NonNull ArrayList<Task> taskList) {
+ mTaskList = taskList;
+ }
+
+ @Override
+ public TaskHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ // TODO: Swap in an actual task view here (view w/ icon, label, etc.)
+ TextView stubView = new TextView(parent.getContext());
+ return new TaskHolder(stubView);
+ }
+
+ @Override
+ public void onBindViewHolder(TaskHolder holder, int position) {
+ holder.bindTask(mTaskList.get(position));
+ }
+
+ @Override
+ public int getItemCount() {
+ return Math.min(mTaskList.size(), MAX_TASKS_TO_DISPLAY);
+ }
+}
diff --git a/go/quickstep/src/com/android/quickstep/TaskHolder.java b/go/quickstep/src/com/android/quickstep/TaskHolder.java
new file mode 100644
index 000000000..1ea6d7610
--- /dev/null
+++ b/go/quickstep/src/com/android/quickstep/TaskHolder.java
@@ -0,0 +1,48 @@
+/*
+ * 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 android.widget.TextView;
+
+import androidx.recyclerview.widget.RecyclerView.ViewHolder;
+
+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 {
+
+ // TODO: Implement the actual task view to be held.
+ // For now, we just use a simple text view.
+ private final TextView mStubView;
+
+ public TaskHolder(TextView stubView) {
+ super(stubView);
+ mStubView = stubView;
+ }
+
+ /**
+ * Bind task content to the view. This includes the task icon and title as well as binding
+ * input handlers such as which task to launch/remove.
+ *
+ * @param task the task to bind to the view this
+ */
+ public void bindTask(Task task) {
+ mStubView.setText("Stub task view: " + task.titleDescription);
+ }
+}
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index e4741e9d5..ae8166c23 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -21,8 +21,14 @@ import android.util.FloatProperty;
import android.view.ViewDebug;
import android.widget.FrameLayout;
+import com.android.quickstep.TaskAdapter;
+import com.android.systemui.shared.recents.model.Task;
+
+import java.util.ArrayList;
+
/**
- * Root view for the icon recents view.
+ * Root view for the icon recents view. Acts as the main interface to the rest of the Launcher code
+ * base.
*/
public final class IconRecentsView extends FrameLayout {
@@ -58,12 +64,24 @@ public final class IconRecentsView extends FrameLayout {
* is top aligned and 0.5 is centered vertically.
*/
@ViewDebug.ExportedProperty(category = "launcher")
+
+ // TODO: Write a recents task list observer that creates/updates tasks and signals task adapter.
+ private static final ArrayList<Task> DUMMY_TASK_LIST = new ArrayList<>();
+
private float mTranslationYFactor;
+ private TaskAdapter mTaskAdapter;
public IconRecentsView(Context context, AttributeSet attrs) {
super(context, attrs);
}
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mTaskAdapter = new TaskAdapter(DUMMY_TASK_LIST);
+ // TODO: Hook task adapter up to recycler view.
+ }
+
public void setTranslationYFactor(float translationFactor) {
mTranslationYFactor = translationFactor;
setTranslationY(computeTranslationYForFactor(mTranslationYFactor));