Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f6d41ee authored by Kevin's avatar Kevin
Browse files

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
parent ee8caf68
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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"
+14 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ import static androidx.recyclerview.widget.ItemTouchHelper.RIGHT;

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;
@@ -49,6 +51,18 @@ public final class TaskSwipeCallback extends ItemTouchHelper.SimpleCallback {
        }
    }

    @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) {