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

Commit d27dae20 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Minor fixes to freeform workspace"

parents 09d7a93b 509d0d0c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -245,6 +245,9 @@
    <!-- The height of the history button. -->
    <dimen name="recents_history_button_height">48dp</dimen>

    <!-- The padding between freeform workspace tasks -->
    <dimen name="recents_freeform_workspace_task_padding">8dp</dimen>

    <!-- Space reserved for the cards behind the top card in the top stack -->
    <dimen name="top_stack_peek_amount">12dp</dimen>

+3 −1
Original line number Diff line number Diff line
@@ -776,8 +776,10 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        if (toTransform != null && toTask.key != null) {
            Bitmap thumbnail;
            synchronized (mHeaderBarLock) {
                int toHeaderWidth = (int) (mHeaderBar.getMeasuredWidth() * toTransform.scale);
                int toHeaderWidth = (int) toTransform.rect.width();
                int toHeaderHeight = (int) (mHeaderBar.getMeasuredHeight() * toTransform.scale);
                mHeaderBar.onTaskViewSizeChanged((int) toTransform.rect.width(),
                        (int) toTransform.rect.height());
                thumbnail = Bitmap.createBitmap(toHeaderWidth, toHeaderHeight,
                        Bitmap.Config.ARGB_8888);
                if (RecentsDebugFlags.Static.EnableTransitionThumbnailDebugMode) {
+2 −11
Original line number Diff line number Diff line
@@ -128,12 +128,10 @@ public class RecentsTaskLoadPlan {
    public synchronized void preloadPlan(RecentsTaskLoader loader, boolean isTopTaskHome) {
        if (DEBUG) Log.d(TAG, "preloadPlan");

        RecentsDebugFlags debugFlags = Recents.getDebugFlags();
        RecentsConfiguration config = Recents.getConfiguration();
        SystemServicesProxy ssp = Recents.getSystemServices();
        Resources res = mContext.getResources();
        ArrayList<Task> freeformTasks = new ArrayList<>();
        ArrayList<Task> stackTasks = new ArrayList<>();
        ArrayList<Task> allTasks = new ArrayList<>();
        if (mRawTasks == null) {
            preloadRawTasks(isTopTaskHome);
        }
@@ -184,11 +182,7 @@ public class RecentsTaskLoadPlan {
                Log.d(TAG, activityLabel + " bounds: " + t.bounds);
            }

            if (task.isFreeformTask()) {
                freeformTasks.add(task);
            } else {
                stackTasks.add(task);
            }
            allTasks.add(task);
        }
        if (newLastStackActiveTime != -1) {
            Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
@@ -196,9 +190,6 @@ public class RecentsTaskLoadPlan {
        }

        // Initialize the stacks
        ArrayList<Task> allTasks = new ArrayList<>();
        allTasks.addAll(stackTasks);
        allTasks.addAll(freeformTasks);
        mStack = new TaskStack();
        mStack.setTasks(allTasks, false /* notifyStackChanges */);
        mStack.createAffiliatedGroupings(mContext);
+17 −3
Original line number Diff line number Diff line
@@ -321,6 +321,20 @@ public class TaskStack {
        }
    };

    // A comparator that sorts tasks by their last active time and freeform state
    private Comparator<Task> FREEFORM_LAST_ACTIVE_TIME_COMPARATOR = new Comparator<Task>() {
        @Override
        public int compare(Task o1, Task o2) {
            if (o1.isFreeformTask() && !o2.isFreeformTask()) {
                return 1;
            } else if (o2.isFreeformTask() && !o1.isFreeformTask()) {
                return -1;
            }
            return Long.compare(o1.key.lastActiveTime, o2.key.lastActiveTime);
        }
    };


    // The task offset to apply to a task id as a group affiliation
    static final int IndividualTaskIdOffset = 1 << 16;

@@ -484,7 +498,7 @@ public class TaskStack {
        }

        // Sort all the tasks to ensure they are ordered correctly
        Collections.sort(newTasks, LAST_ACTIVE_TIME_COMPARATOR);
        Collections.sort(newTasks, FREEFORM_LAST_ACTIVE_TIME_COMPARATOR);

        // TODO: Update screen pinning for the new front-most task post refactoring lockToTask out
        // of the Task
@@ -670,7 +684,7 @@ public class TaskStack {
            Collections.sort(mGroups, new Comparator<TaskGrouping>() {
                @Override
                public int compare(TaskGrouping taskGrouping, TaskGrouping taskGrouping2) {
                    return (int) (taskGrouping.latestActiveTimeInGroup -
                    return Long.compare(taskGrouping.latestActiveTimeInGroup,
                            taskGrouping2.latestActiveTimeInGroup);
                }
            });
@@ -683,7 +697,7 @@ public class TaskStack {
                Collections.sort(group.mTaskKeys, new Comparator<Task.TaskKey>() {
                    @Override
                    public int compare(Task.TaskKey taskKey, Task.TaskKey taskKey2) {
                        return (int) (taskKey.firstActiveTime - taskKey2.firstActiveTime);
                        return Long.compare(taskKey.firstActiveTime, taskKey2.firstActiveTime);
                    }
                });
                ArrayList<Task.TaskKey> groupTasks = group.mTaskKeys;
+12 −0
Original line number Diff line number Diff line
@@ -16,9 +16,12 @@

package com.android.systemui.recents.views;

import android.content.Context;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.Log;

import com.android.systemui.R;
import com.android.systemui.recents.model.Task;

import java.util.Collections;
@@ -36,6 +39,14 @@ public class FreeformWorkspaceLayoutAlgorithm {
    // Optimization, allows for quick lookup of task -> rect
    private HashMap<Task.TaskKey, RectF> mTaskRectMap = new HashMap<>();

    private int mTaskPadding;

    public FreeformWorkspaceLayoutAlgorithm(Context context) {
        // This is applied to the edges of each task
        mTaskPadding = context.getResources().getDimensionPixelSize(
                R.dimen.recents_freeform_workspace_task_padding) / 2;
    }

    /**
     * Updates the layout for each of the freeform workspace tasks.  This is called after the stack
     * layout is updated.
@@ -117,6 +128,7 @@ public class FreeformWorkspaceLayoutAlgorithm {
                    rowLeft = defaultRowLeft;
                }
                RectF rect = new RectF(rowLeft, rowTop, rowLeft + width, rowTop + rowHeight);
                rect.inset(mTaskPadding, mTaskPadding);
                rowLeft += width;
                mTaskRectMap.put(task.key, rect);
            }
Loading