From f01ead4eb15d220ec96e89b855432e03e050910a Mon Sep 17 00:00:00 2001 From: vinayjoglekar Date: Wed, 13 Nov 2024 16:46:53 +0000 Subject: [PATCH] Fix Blank task thumbnails during animation in following scenarios 1. During split 2. During dismiss We need to expand window of visible task data, we use dismissTranslation property to increase window. Fix: 376409147 Flag: EXEMPT bugfix Test: Manual: Dismiss desktop when have focus task as well as small tiles, split from far away with multiple desktops Change-Id: I0102f8927e70a37ffe4db18adefd33eb7a823981 --- .../android/quickstep/views/RecentsView.java | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 8982850532..b27cbc0b92 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -610,6 +610,8 @@ public abstract class RecentsView< private int mKeyboardTaskFocusSnapAnimationDuration; private int mKeyboardTaskFocusIndex = INVALID_PAGE; + private int[] mDismissPrimaryTranslations; + /** * TODO: Call reloadIdNeeded in onTaskStackChanged. */ @@ -1418,7 +1420,7 @@ public abstract class RecentsView< if (showAsGrid()) { int screenStart = getPagedOrientationHandler().getPrimaryScroll(this); int screenEnd = screenStart + getPagedOrientationHandler().getMeasuredSize(this); - return isTaskViewWithinBounds(tv, screenStart, screenEnd); + return isTaskViewWithinBounds(tv, screenStart, screenEnd, /*taskViewTranslation=*/ 0); } else { // For now, just check if it's the active task or an adjacent task return Math.abs(indexOfChild(tv) - getNextPage()) <= 1; @@ -1465,14 +1467,28 @@ public abstract class RecentsView< return clearAllScroll + (mIsRtl ? distance : -distance); } - private boolean isTaskViewWithinBounds(TaskView tv, int start, int end) { - int taskStart = getPagedOrientationHandler().getChildStart(tv) - + (int) tv.getOffsetAdjustment(showAsGrid()); - int taskSize = (int) (getPagedOrientationHandler().getMeasuredSize(tv) - * tv.getSizeAdjustment(showAsFullscreen())); + /* + * Returns if TaskView is within screen bounds defined in [screenStart, screenEnd]. + * + * @param taskViewTranslation taskView is considered within bounds if either translated or + * original position of taskView is within screen bounds. + */ + private boolean isTaskViewWithinBounds(TaskView taskView, int screenStart, int screenEnd, + int taskViewTranslation) { + int taskStart = getPagedOrientationHandler().getChildStart(taskView) + + (int) taskView.getOffsetAdjustment(showAsGrid()); + int taskSize = (int) (getPagedOrientationHandler().getMeasuredSize(taskView) + * taskView.getSizeAdjustment(showAsFullscreen())); int taskEnd = taskStart + taskSize; - return (taskStart >= start && taskStart <= end) || (taskEnd >= start - && taskEnd <= end); + + int translatedTaskStart = taskStart + taskViewTranslation; + int translatedTaskEnd = taskEnd + taskViewTranslation; + + taskStart = Math.min(taskStart, translatedTaskStart); + taskEnd = Math.max(taskEnd, translatedTaskEnd); + + return (taskStart >= screenStart && taskStart <= screenEnd) || (taskEnd >= screenStart + && taskEnd <= screenEnd); } private boolean isTaskViewFullyWithinBounds(TaskView tv, int start, int end) { @@ -2470,7 +2486,8 @@ public abstract class RecentsView< } boolean visible; if (showAsGrid()) { - visible = isTaskViewWithinBounds(taskView, visibleStart, visibleEnd); + visible = isTaskViewWithinBounds(taskView, visibleStart, visibleEnd, + mDismissPrimaryTranslations != null ? mDismissPrimaryTranslations[i] : 0); } else { visible = lower <= i && i <= upper; } @@ -3837,6 +3854,7 @@ public abstract class RecentsView< stagingTranslation += mIsRtl ? newClearAllShortTotalWidthTranslation : -newClearAllShortTotalWidthTranslation; } + mDismissPrimaryTranslations = new int[taskCount]; for (int i = 0; i < count; i++) { View child = getChildAt(i); if (child == dismissedTaskView) { @@ -3854,7 +3872,7 @@ public abstract class RecentsView< Math.abs(i - dismissedIndex), scrollDiff, anim, - splitTimings); + splitTimings, i); needsCurveUpdates = true; } } else if (child instanceof TaskView taskView) { @@ -3915,10 +3933,12 @@ public abstract class RecentsView< primaryTranslation += mIsRtl ? stagingTranslation : -stagingTranslation; if (primaryTranslation != 0) { + float finalTranslation = mIsRtl ? primaryTranslation : -primaryTranslation; anim.setFloat(taskView, taskView.getPrimaryDismissTranslationProperty(), - mIsRtl ? primaryTranslation : -primaryTranslation, + finalTranslation, clampToProgress(dismissInterpolator, animationStartProgress, animationEndProgress)); + mDismissPrimaryTranslations[i] = (int) finalTranslation; distanceFromDismissedTask++; } } @@ -3937,7 +3957,7 @@ public abstract class RecentsView< if (animateTaskView && dismissedTaskView != null) { dismissedTaskView.setTranslationZ(0.1f); } - + loadVisibleTaskData(TaskView.FLAG_UPDATE_ALL); mPendingAnimation = anim; final TaskView finalNextFocusedTaskView = nextFocusedTaskView; final boolean finalCloseGapBetweenClearAll = closeGapBetweenClearAll; @@ -4155,6 +4175,7 @@ public abstract class RecentsView< updateCurrentTaskActionsVisibility(); onDismissAnimationEnds(); mPendingAnimation = null; + mDismissPrimaryTranslations = null; } }); } @@ -4193,7 +4214,8 @@ public abstract class RecentsView< int indexDiff, int scrollDiffPerPage, PendingAnimation pendingAnimation, - SplitAnimationTimings splitTimings) { + SplitAnimationTimings splitTimings, + int index) { FloatProperty translationProperty = view instanceof TaskView ? ((TaskView) view).getPrimaryDismissTranslationProperty() : getPagedOrientationHandler().getPrimaryViewTranslate(); @@ -4227,6 +4249,9 @@ public abstract class RecentsView< ) ); + if (view instanceof TaskView) { + mDismissPrimaryTranslations[index] = scrollDiffPerPage; + } if (mEnableDrawingLiveTile && view instanceof TaskView && ((TaskView) view).isRunningTask()) { pendingAnimation.addOnFrameCallback(() -> {