Fade task items when swiping out

As we have a fixed width for the task list now, we have to ensure that
we do not clip the task items when we swipe them out. In addition, we
should fade them out by the end of the swipe as the swipe end location
may still be on a visible part of the screen.

Bug: 131686863
Test: Go to landscape mode, swipe out tasks
Change-Id: If86136a9f9d47098a6dd5d355d3a99d540165c77
diff --git a/go/quickstep/res/layout/icon_recents_root_view.xml b/go/quickstep/res/layout/icon_recents_root_view.xml
index b64b7fd..595a380 100644
--- a/go/quickstep/res/layout/icon_recents_root_view.xml
+++ b/go/quickstep/res/layout/icon_recents_root_view.xml
@@ -18,14 +18,16 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="vertical">
+    android:orientation="vertical"
+    android:clipChildren="false">
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/recent_task_recycler_view"
         android:layout_width="@dimen/recents_list_width"
         android:layout_height="match_parent"
         android:layout_gravity="center_horizontal"
         android:scrollbars="none"
-        android:clipToPadding="false"/>
+        android:clipToPadding="false"
+        android:clipChildren="false"/>
     <TextView
         android:id="@+id/recent_task_empty_view"
         android:layout_width="match_parent"
diff --git a/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java b/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java
index 19951bb..7686543 100644
--- a/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java
+++ b/go/quickstep/src/com/android/quickstep/TaskSwipeCallback.java
@@ -19,6 +19,8 @@
 
 import static com.android.quickstep.TaskAdapter.ITEM_TYPE_CLEAR_ALL;
 
+import android.graphics.Canvas;
+
 import androidx.annotation.NonNull;
 import androidx.recyclerview.widget.ItemTouchHelper;
 import androidx.recyclerview.widget.RecyclerView;
@@ -50,6 +52,18 @@
     }
 
     @Override
+    public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView,
+            @NonNull ViewHolder viewHolder, float dX, float dY, int actionState,
+            boolean isCurrentlyActive) {
+        if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
+            float alpha = 1.0f - dX / (float) viewHolder.itemView.getWidth();
+            viewHolder.itemView.setAlpha(alpha);
+        }
+        super.onChildDraw(c, recyclerView, viewHolder, dX, dY,
+                    actionState, isCurrentlyActive);
+    }
+
+    @Override
     public int getSwipeDirs(@NonNull RecyclerView recyclerView,
             @NonNull ViewHolder viewHolder) {
         if (viewHolder.getItemViewType() == ITEM_TYPE_CLEAR_ALL) {