Fix bug where floating icon and workspace icon visible at the same time.
- Add a signal for the animation to be "cancelled" - Allow the workspace view to be attached to a spring during the animatoin (but kept hidden) to prevent any jumpy movement Bug: 137215697 Change-Id: Ie6868a7f45fefaee5366c8d30bb323fe042e9156
This commit is contained in:
+59
-23
@@ -871,7 +871,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
||||
|
||||
@UiThread
|
||||
private InputConsumer createNewInputProxyHandler() {
|
||||
endRunningWindowAnim();
|
||||
endRunningWindowAnim(true /* cancel */);
|
||||
endLauncherTransitionController();
|
||||
if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) {
|
||||
// Hide the task view, if not already hidden
|
||||
@@ -883,9 +883,13 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
||||
? InputConsumer.NO_OP : new OverviewInputConsumer(activity, null, true);
|
||||
}
|
||||
|
||||
private void endRunningWindowAnim() {
|
||||
private void endRunningWindowAnim(boolean cancel) {
|
||||
if (mRunningWindowAnim != null) {
|
||||
mRunningWindowAnim.end();
|
||||
if (cancel) {
|
||||
mRunningWindowAnim.cancel();
|
||||
} else {
|
||||
mRunningWindowAnim.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1177,27 +1181,37 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
||||
// We want the window alpha to be 0 once this threshold is met, so that the
|
||||
// FolderIconView can be seen morphing into the icon shape.
|
||||
final float windowAlphaThreshold = isFloatingIconView ? 1f - SHAPE_PROGRESS_DURATION : 1f;
|
||||
anim.addOnUpdateListener((currentRect, progress) -> {
|
||||
homeAnim.setPlayFraction(progress);
|
||||
anim.addOnUpdateListener(new RectFSpringAnim.OnUpdateListener() {
|
||||
@Override
|
||||
public void onUpdate(RectF currentRect, float progress) {
|
||||
homeAnim.setPlayFraction(progress);
|
||||
|
||||
float alphaProgress = ACCEL_1_5.getInterpolation(progress);
|
||||
float windowAlpha = Utilities.boundToRange(Utilities.mapToRange(alphaProgress, 0,
|
||||
windowAlphaThreshold, 1.5f, 0f, Interpolators.LINEAR), 0, 1);
|
||||
mTransformParams.setProgress(progress)
|
||||
.setCurrentRectAndTargetAlpha(currentRect, windowAlpha);
|
||||
if (isFloatingIconView) {
|
||||
mTransformParams.setCornerRadius(endRadius * progress + startRadius
|
||||
* (1f - progress));
|
||||
}
|
||||
mClipAnimationHelper.applyTransform(targetSet, mTransformParams,
|
||||
false /* launcherOnTop */);
|
||||
float alphaProgress = ACCEL_1_5.getInterpolation(progress);
|
||||
float windowAlpha = Utilities.boundToRange(Utilities.mapToRange(alphaProgress, 0,
|
||||
windowAlphaThreshold, 1.5f, 0f, Interpolators.LINEAR), 0, 1);
|
||||
mTransformParams.setProgress(progress)
|
||||
.setCurrentRectAndTargetAlpha(currentRect, windowAlpha);
|
||||
if (isFloatingIconView) {
|
||||
mTransformParams.setCornerRadius(endRadius * progress + startRadius
|
||||
* (1f - progress));
|
||||
}
|
||||
mClipAnimationHelper.applyTransform(targetSet, mTransformParams,
|
||||
false /* launcherOnTop */);
|
||||
|
||||
if (isFloatingIconView) {
|
||||
((FloatingIconView) floatingView).update(currentRect, 1f, progress,
|
||||
windowAlphaThreshold, mClipAnimationHelper.getCurrentCornerRadius(), false);
|
||||
if (isFloatingIconView) {
|
||||
((FloatingIconView) floatingView).update(currentRect, 1f, progress,
|
||||
windowAlphaThreshold, mClipAnimationHelper.getCurrentCornerRadius(), false);
|
||||
}
|
||||
|
||||
updateSysUiFlags(Math.max(progress, mCurrentShift.value));
|
||||
}
|
||||
|
||||
updateSysUiFlags(Math.max(progress, mCurrentShift.value));
|
||||
@Override
|
||||
public void onCancel() {
|
||||
if (isFloatingIconView) {
|
||||
((FloatingIconView) floatingView).fastFinish();
|
||||
}
|
||||
}
|
||||
});
|
||||
anim.addAnimatorListener(new AnimationSuccessListener() {
|
||||
@Override
|
||||
@@ -1306,7 +1320,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
||||
}
|
||||
|
||||
private void invalidateHandler() {
|
||||
endRunningWindowAnim();
|
||||
endRunningWindowAnim(false /* cancel */);
|
||||
|
||||
if (mGestureEndCallback != null) {
|
||||
mGestureEndCallback.run();
|
||||
@@ -1471,12 +1485,34 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
||||
private interface RunningWindowAnim {
|
||||
void end();
|
||||
|
||||
void cancel();
|
||||
|
||||
static RunningWindowAnim wrap(Animator animator) {
|
||||
return animator::end;
|
||||
return new RunningWindowAnim() {
|
||||
@Override
|
||||
public void end() {
|
||||
animator.end();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
animator.cancel();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static RunningWindowAnim wrap(RectFSpringAnim rectFSpringAnim) {
|
||||
return rectFSpringAnim::end;
|
||||
return new RunningWindowAnim() {
|
||||
@Override
|
||||
public void end() {
|
||||
rectFSpringAnim.end();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
rectFSpringAnim.cancel();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,18 @@ public class RectFSpringAnim {
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
if (mAnimsStarted) {
|
||||
for (OnUpdateListener onUpdateListener : mOnUpdateListeners) {
|
||||
onUpdateListener.onCancel();
|
||||
}
|
||||
}
|
||||
end();
|
||||
}
|
||||
|
||||
public interface OnUpdateListener {
|
||||
void onUpdate(RectF currentRect, float progress);
|
||||
|
||||
void onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -134,10 +134,6 @@ public class StaggeredWorkspaceAnim {
|
||||
* @param totalRows Total number of rows.
|
||||
*/
|
||||
private void addStaggeredAnimationForView(View v, int row, int totalRows) {
|
||||
if (v == mViewToIgnore) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Invert the rows, because we stagger starting from the bottom of the screen.
|
||||
int invertedRow = totalRows - row;
|
||||
// Add 1 to the inverted row so that the bottom most row has a start delay.
|
||||
@@ -149,6 +145,10 @@ public class StaggeredWorkspaceAnim {
|
||||
springTransY.setStartDelay(startDelay);
|
||||
mAnimators.add(springTransY);
|
||||
|
||||
if (v == mViewToIgnore) {
|
||||
return;
|
||||
}
|
||||
|
||||
v.setAlpha(0);
|
||||
ObjectAnimator alpha = ObjectAnimator.ofFloat(v, View.ALPHA, 0f, 1f);
|
||||
alpha.setInterpolator(LINEAR);
|
||||
|
||||
@@ -656,8 +656,7 @@ public class FloatingIconView extends View implements
|
||||
canvas.restoreToCount(count);
|
||||
}
|
||||
|
||||
public void onListenerViewClosed() {
|
||||
// Fast finish here.
|
||||
public void fastFinish() {
|
||||
if (mEndRunnable != null) {
|
||||
mEndRunnable.run();
|
||||
mEndRunnable = null;
|
||||
@@ -757,7 +756,7 @@ public class FloatingIconView extends View implements
|
||||
view.setVisibility(INVISIBLE);
|
||||
parent.addView(view);
|
||||
dragLayer.addView(view.mListenerView);
|
||||
view.mListenerView.setListener(view::onListenerViewClosed);
|
||||
view.mListenerView.setListener(view::fastFinish);
|
||||
|
||||
view.mEndRunnable = () -> {
|
||||
view.mEndRunnable = null;
|
||||
|
||||
Reference in New Issue
Block a user