diff options
7 files changed, 39 insertions, 17 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 4f070d65c2dc..f70f38ba3f6a 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -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> diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 0678aae2de8f..8a0a043ef4ff 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -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) { diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java index 0884695dea51..1d180870bb6b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java @@ -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); diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java index c4a71b3aac41..3484c389ff7a 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java @@ -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; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java index 2351aa3fe049..7f907ef86a2a 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java @@ -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); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java index 96b1a414bed6..135f0f92023b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java @@ -311,7 +311,7 @@ public class RecentsTransitionHelper { Bitmap b = null; if (addHeaderBitmap) { float scale = transform.scale; - int fromHeaderWidth = (int) (taskView.mHeaderView.getMeasuredWidth() * scale); + int fromHeaderWidth = (int) (transform.rect.width()); int fromHeaderHeight = (int) (taskView.mHeaderView.getMeasuredHeight() * scale); b = Bitmap.createBitmap(fromHeaderWidth, fromHeaderHeight, Bitmap.Config.ARGB_8888); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java index de944fc7b3c0..9625e5da2d39 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -294,7 +294,7 @@ public class TaskStackLayoutAlgorithm { mMinTranslationZ = res.getDimensionPixelSize(R.dimen.recents_task_view_z_min); mMaxTranslationZ = res.getDimensionPixelSize(R.dimen.recents_task_view_z_max); mContext = context; - mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm(); + mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm(context); mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, com.android.internal.R.interpolator.linear_out_slow_in); } |