Layout aligned to dp grid for portrait (2/3)

Add vertical margins to all recycler items. In the future, we will
change these dynamically to ensure a task item is semi-visible on screen

Bug: 131610834
Test: Builds
Change-Id: I0b21c8ea7249e7fac640705e8128e309b954815b
diff --git a/go/quickstep/res/values/dimens.xml b/go/quickstep/res/values/dimens.xml
index db3cc21..0be5ee6 100644
--- a/go/quickstep/res/values/dimens.xml
+++ b/go/quickstep/res/values/dimens.xml
@@ -16,10 +16,12 @@
 -->
 <resources>
     <dimen name="task_item_height">60dp</dimen>
+    <dimen name="task_item_top_margin">16dp</dimen>
     <dimen name="task_thumbnail_icon_horiz_margin">16dp</dimen>
 
     <dimen name="task_thumbnail_corner_radius">3dp</dimen>
 
     <dimen name="clear_all_item_view_height">36dp</dimen>
+    <dimen name="clear_all_item_view_top_margin">20dp</dimen>
     <dimen name="clear_all_button_width">106dp</dimen>
 </resources>
\ No newline at end of file
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index e4795ce..f079515 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -20,6 +20,8 @@
 import static androidx.recyclerview.widget.LinearLayoutManager.VERTICAL;
 
 import static com.android.quickstep.TaskAdapter.CHANGE_EVENT_TYPE_EMPTY_TO_CONTENT;
+import static com.android.quickstep.TaskAdapter.ITEM_TYPE_CLEAR_ALL;
+import static com.android.quickstep.TaskAdapter.ITEM_TYPE_TASK;
 import static com.android.quickstep.TaskAdapter.TASKS_START_POSITION;
 
 import android.animation.Animator;
@@ -29,6 +31,7 @@
 import android.animation.PropertyValuesHolder;
 import android.animation.ValueAnimator;
 import android.content.Context;
+import android.graphics.Rect;
 import android.util.ArraySet;
 import android.util.AttributeSet;
 import android.util.FloatProperty;
@@ -44,6 +47,7 @@
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
+import androidx.recyclerview.widget.RecyclerView.ItemDecoration;
 import androidx.recyclerview.widget.RecyclerView.OnChildAttachStateChangeListener;
 
 import com.android.launcher3.BaseActivity;
@@ -174,7 +178,29 @@
             mTaskRecyclerView.setItemAnimator(mDefaultItemAnimator);
             mLoadingContentItemAnimator.setOnAnimationFinishedRunnable(
                     () -> mTaskRecyclerView.setItemAnimator(new DefaultItemAnimator()));
-            // TODO: Add item decorator for vertical item margins
+            ItemDecoration marginDecorator = new ItemDecoration() {
+                @Override
+                public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
+                        @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
+                    // TODO: Determine if current margins cause off screen item to be fully off
+                    // screen and if so, modify them so that it is partially off screen.
+                    int itemType = parent.getChildViewHolder(view).getItemViewType();
+                    switch (itemType) {
+                        case ITEM_TYPE_CLEAR_ALL:
+                            outRect.top = (int) getResources().getDimension(
+                                    R.dimen.clear_all_item_view_top_margin);
+                            // TODO: In landscape, add bottom margin as well since we won't have
+                            // nav bar to buffer things nicely.
+                            break;
+                        case ITEM_TYPE_TASK:
+                            outRect.top = (int) getResources().getDimension(
+                                    R.dimen.task_item_top_margin);
+                            break;
+                        default:
+                    }
+                }
+            };
+            mTaskRecyclerView.addItemDecoration(marginDecorator);
 
             mEmptyView = findViewById(R.id.recent_task_empty_view);
             mContentView = mTaskRecyclerView;