diff --git a/go/quickstep/res/layout/clear_all_button.xml b/go/quickstep/res/layout/clear_all_button.xml
index eceffec42f..003ee860e5 100644
--- a/go/quickstep/res/layout/clear_all_button.xml
+++ b/go/quickstep/res/layout/clear_all_button.xml
@@ -14,15 +14,20 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
+
+
+
diff --git a/go/quickstep/src/com/android/quickstep/TaskAdapter.java b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
index be6faca888..8651698f63 100644
--- a/go/quickstep/src/com/android/quickstep/TaskAdapter.java
+++ b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
@@ -16,6 +16,7 @@
package com.android.quickstep;
import android.view.LayoutInflater;
+import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
@@ -84,10 +85,11 @@ public final class TaskAdapter extends Adapter {
itemView.setOnClickListener(view -> mTaskActionController.launchTask(taskHolder));
return taskHolder;
case ITEM_TYPE_CLEAR_ALL:
- Button clearView = (Button) LayoutInflater.from(parent.getContext())
+ View clearView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.clear_all_button, parent, false);
ClearAllHolder clearAllHolder = new ClearAllHolder(clearView);
- clearView.setOnClickListener(mClearAllListener);
+ Button clearViewButton = clearView.findViewById(R.id.clear_all_button);
+ clearViewButton.setOnClickListener(mClearAllListener);
return clearAllHolder;
default:
throw new IllegalArgumentException("No known holder for item type: " + viewType);
diff --git a/go/quickstep/src/com/android/quickstep/views/ClearAllItemView.java b/go/quickstep/src/com/android/quickstep/views/ClearAllItemView.java
new file mode 100644
index 0000000000..378dbf4e4a
--- /dev/null
+++ b/go/quickstep/src/com/android/quickstep/views/ClearAllItemView.java
@@ -0,0 +1,41 @@
+/*
+ * 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.views;
+
+import static com.android.quickstep.views.TaskLayoutUtils.getClearAllItemHeight;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+/**
+ * Recycler view item that lays out the clear all button and measures the space it takes based on
+ * the device height.
+ */
+public final class ClearAllItemView extends FrameLayout {
+
+ public ClearAllItemView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int buttonHeight = getClearAllItemHeight(getContext());
+ int newHeightSpec = MeasureSpec.makeMeasureSpec(buttonHeight, MeasureSpec.EXACTLY);
+ super.onMeasure(widthMeasureSpec, newHeightSpec);
+ }
+}
diff --git a/go/quickstep/src/com/android/quickstep/views/TaskLayoutUtils.java b/go/quickstep/src/com/android/quickstep/views/TaskLayoutUtils.java
index f7d6495d28..e28a9e04f0 100644
--- a/go/quickstep/src/com/android/quickstep/views/TaskLayoutUtils.java
+++ b/go/quickstep/src/com/android/quickstep/views/TaskLayoutUtils.java
@@ -26,6 +26,8 @@ import com.android.launcher3.InvariantDeviceProfile;
*/
public final class TaskLayoutUtils {
+ private static final float CLEAR_ALL_ITEM_TO_HEIGHT_RATIO = 7.0f / 64;
+
private TaskLayoutUtils() {}
/**
@@ -39,12 +41,19 @@ public final class TaskLayoutUtils {
public static int getTaskHeight(Context context) {
final int availableHeight =
InvariantDeviceProfile.INSTANCE.get(context).portraitProfile.availableHeightPx;
- // TODO: Take into account clear all button height for task height
- return (int) (availableHeight * 1.0f / MAX_TASKS_TO_DISPLAY);
+ final int availableTaskSpace = availableHeight - getClearAllItemHeight(context);
+ return (int) (availableTaskSpace * 1.0f / MAX_TASKS_TO_DISPLAY);
}
- public static int getClearAllButtonHeight(Context context) {
- // TODO: Implement this
- return 0;
+ /**
+ * Calculate clear all item height scaled to available height in portrait mode.
+ *
+ * @param context current context
+ * @return clear all item height
+ */
+ public static int getClearAllItemHeight(Context context) {
+ final int availableHeight =
+ InvariantDeviceProfile.INSTANCE.get(context).portraitProfile.availableHeightPx;
+ return (int) (CLEAR_ALL_ITEM_TO_HEIGHT_RATIO * availableHeight);
}
}