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

Commit 00fb36fd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove old recyclerview layout logic" into ub-launcher3-master

parents 71025d43 cacf7df2
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ 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.TASKS_START_POSITION;
import static com.android.quickstep.views.TaskLayoutUtils.getTaskListHeight;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -33,7 +32,6 @@ import android.util.AttributeSet;
import android.util.FloatProperty;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;

@@ -47,7 +45,6 @@ import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import androidx.recyclerview.widget.RecyclerView.OnChildAttachStateChangeListener;

import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.quickstep.ContentFillItemAnimator;
import com.android.quickstep.RecentsModel;
@@ -106,7 +103,6 @@ public final class IconRecentsView extends FrameLayout {
    private final DefaultItemAnimator mDefaultItemAnimator = new DefaultItemAnimator();
    private final ContentFillItemAnimator mLoadingContentItemAnimator =
            new ContentFillItemAnimator();
    private final DeviceProfile mDeviceProfile;

    private RecentsToActivityHelper mActivityHelper;
    private RecyclerView mTaskRecyclerView;
@@ -137,7 +133,6 @@ public final class IconRecentsView extends FrameLayout {
        super(context, attrs);
        BaseActivity activity = BaseActivity.fromContext(context);
        mContext = context;
        mDeviceProfile = activity.getDeviceProfile();
        mTaskLoader = new TaskListLoader(mContext);
        mTaskAdapter = new TaskAdapter(mTaskLoader);
        mTaskAdapter.setOnClearAllClickListener(view -> animateClearAllTasks());
@@ -151,8 +146,6 @@ public final class IconRecentsView extends FrameLayout {
        super.onFinishInflate();
        if (mTaskRecyclerView == null) {
            mTaskRecyclerView = findViewById(R.id.recent_task_recycler_view);
            ViewGroup.LayoutParams recyclerViewParams = mTaskRecyclerView.getLayoutParams();
            recyclerViewParams.height = getTaskListHeight(mDeviceProfile);
            mTaskRecyclerView.setAdapter(mTaskAdapter);
            mTaskRecyclerView.setLayoutManager(
                    new LinearLayoutManager(mContext, VERTICAL, true /* reverseLayout */));
+3 −25
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ import static com.android.quickstep.TaskAdapter.MAX_TASKS_TO_DISPLAY;

import android.content.Context;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;

/**
@@ -27,18 +26,8 @@ import com.android.launcher3.InvariantDeviceProfile;
 */
public final class TaskLayoutUtils {

    private static final float BUTTON_TO_DEVICE_HEIGHT_RATIO = 36.0f/569;
    private static final float BUTTON_WIDTH_TO_HEIGHT_RATIO = 53.0f/18;
    private static final float BUTTON_MARGIN_TO_BUTTON_HEIGHT_RATIO = 5.0f/9;

    private TaskLayoutUtils() {}

    public static int getTaskListHeight(DeviceProfile dp) {
        // TODO: Remove this as task height is determined directly from device height.
        int clearAllSpace = getClearAllButtonHeight(dp) + 2 * getClearAllButtonTopBottomMargin(dp);
        return getDeviceLongWidth(dp) - clearAllSpace;
    }

    /**
     * Calculate task height based off the available height in portrait mode such that when the
     * recents list is full, the total height fills in the available device height perfectly. In
@@ -54,19 +43,8 @@ public final class TaskLayoutUtils {
        return (int) (availableHeight * 1.0f / MAX_TASKS_TO_DISPLAY);
    }

    public static int getClearAllButtonHeight(DeviceProfile dp) {
        return (int) (BUTTON_TO_DEVICE_HEIGHT_RATIO * getDeviceLongWidth(dp));
    }

    public static int getClearAllButtonWidth(DeviceProfile dp) {
        return (int) (BUTTON_WIDTH_TO_HEIGHT_RATIO * getClearAllButtonHeight(dp));
    }

    public static int getClearAllButtonTopBottomMargin(DeviceProfile dp) {
        return (int) (BUTTON_MARGIN_TO_BUTTON_HEIGHT_RATIO * getClearAllButtonHeight(dp));
    }

    private static int getDeviceLongWidth(DeviceProfile dp) {
        return Math.max(dp.availableHeightPx, dp.availableWidthPx);
    public static int getClearAllButtonHeight(Context context) {
        // TODO: Implement this
        return 0;
    }
}