Merge "Apply visibility at the beginning of the animation"
This commit is contained in:
@@ -127,16 +127,18 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
||||
final Insets offset = Insets.subtract(mShownInsets, mPendingInsets);
|
||||
ArrayList<SurfaceParams> params = new ArrayList<>();
|
||||
if (offset.left != 0) {
|
||||
updateLeashesForSide(INSET_SIDE_LEFT, offset.left, params, state);
|
||||
updateLeashesForSide(INSET_SIDE_LEFT, offset.left, mPendingInsets.left, params, state);
|
||||
}
|
||||
if (offset.top != 0) {
|
||||
updateLeashesForSide(INSET_SIDE_TOP, offset.top, params, state);
|
||||
updateLeashesForSide(INSET_SIDE_TOP, offset.top, mPendingInsets.top, params, state);
|
||||
}
|
||||
if (offset.right != 0) {
|
||||
updateLeashesForSide(INSET_SIDE_RIGHT, offset.right, params, state);
|
||||
updateLeashesForSide(INSET_SIDE_RIGHT, offset.right, mPendingInsets.right, params,
|
||||
state);
|
||||
}
|
||||
if (offset.bottom != 0) {
|
||||
updateLeashesForSide(INSET_SIDE_BOTTOM, offset.bottom, params, state);
|
||||
updateLeashesForSide(INSET_SIDE_BOTTOM, offset.bottom, mPendingInsets.bottom, params,
|
||||
state);
|
||||
}
|
||||
SyncRtSurfaceTransactionApplier applier = mTransactionApplierSupplier.get();
|
||||
applier.scheduleApply(params.toArray(new SurfaceParams[params.size()]));
|
||||
@@ -171,7 +173,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
||||
return Insets.max(Insets.min(insets, mShownInsets), mHiddenInsets);
|
||||
}
|
||||
|
||||
private void updateLeashesForSide(@InsetSide int side, int inset,
|
||||
private void updateLeashesForSide(@InsetSide int side, int offset, int inset,
|
||||
ArrayList<SurfaceParams> surfaceParams, InsetsState state) {
|
||||
ArraySet<InsetsSourceConsumer> items = mSideSourceMap.get(side);
|
||||
// TODO: Implement behavior when inset spans over multiple types
|
||||
@@ -182,10 +184,10 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
|
||||
mTmpMatrix.setTranslate(source.getFrame().left, source.getFrame().top);
|
||||
|
||||
mTmpFrame.set(source.getFrame());
|
||||
addTranslationToMatrix(side, inset, mTmpMatrix, mTmpFrame);
|
||||
addTranslationToMatrix(side, offset, mTmpMatrix, mTmpFrame);
|
||||
|
||||
state.getSource(source.getType()).setFrame(mTmpFrame);
|
||||
surfaceParams.add(new SurfaceParams(leash, 1f, mTmpMatrix, null, 0, 0f));
|
||||
surfaceParams.add(new SurfaceParams(leash, 1f, mTmpMatrix, null, 0, 0f, inset != 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -329,6 +329,11 @@ public class InsetsController implements WindowInsetsController {
|
||||
WindowInsetsAnimationControlListener listener = new WindowInsetsAnimationControlListener() {
|
||||
@Override
|
||||
public void onReady(WindowInsetsAnimationController controller, int types) {
|
||||
if (show) {
|
||||
showDirectly(types);
|
||||
} else {
|
||||
hideDirectly(types);
|
||||
}
|
||||
mAnimator = ObjectAnimator.ofObject(
|
||||
controller,
|
||||
new InsetsProperty(),
|
||||
@@ -356,11 +361,6 @@ public class InsetsController implements WindowInsetsController {
|
||||
|
||||
private void onAnimationFinish() {
|
||||
mAnimationDirection = DIRECTION_NONE;
|
||||
if (show) {
|
||||
showOnAnimationEnd(types);
|
||||
} else {
|
||||
hideOnAnimationEnd(types);
|
||||
}
|
||||
}
|
||||
};
|
||||
// TODO: Instead of clearing this here, properly wire up
|
||||
@@ -369,14 +369,14 @@ public class InsetsController implements WindowInsetsController {
|
||||
controlWindowInsetsAnimation(types, listener);
|
||||
}
|
||||
|
||||
private void hideOnAnimationEnd(@InsetType int types) {
|
||||
private void hideDirectly(@InsetType int types) {
|
||||
final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
|
||||
for (int i = internalTypes.size() - 1; i >= 0; i--) {
|
||||
getSourceConsumer(internalTypes.valueAt(i)).hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void showOnAnimationEnd(@InsetType int types) {
|
||||
private void showDirectly(@InsetType int types) {
|
||||
final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
|
||||
for (int i = internalTypes.size() - 1; i >= 0; i--) {
|
||||
getSourceConsumer(internalTypes.valueAt(i)).show();
|
||||
|
||||
@@ -109,7 +109,6 @@ public class InsetsSourceConsumer {
|
||||
return;
|
||||
}
|
||||
mVisible = visible;
|
||||
applyHiddenToControl();
|
||||
applyLocalVisibilityOverride();
|
||||
mController.notifyVisibilityChanged();
|
||||
}
|
||||
@@ -119,7 +118,6 @@ public class InsetsSourceConsumer {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Animation
|
||||
final Transaction t = mTransactionSupplier.get();
|
||||
if (mVisible) {
|
||||
t.show(mSourceControl.getLeash());
|
||||
|
||||
@@ -77,7 +77,11 @@ public class SyncRtSurfaceTransactionApplier {
|
||||
t.setAlpha(params.surface, params.alpha);
|
||||
t.setLayer(params.surface, params.layer);
|
||||
t.setCornerRadius(params.surface, params.cornerRadius);
|
||||
t.show(params.surface);
|
||||
if (params.visible) {
|
||||
t.show(params.surface);
|
||||
} else {
|
||||
t.hide(params.surface);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,13 +125,14 @@ public class SyncRtSurfaceTransactionApplier {
|
||||
* @param windowCrop Crop to apply.
|
||||
*/
|
||||
public SurfaceParams(SurfaceControl surface, float alpha, Matrix matrix,
|
||||
Rect windowCrop, int layer, float cornerRadius) {
|
||||
Rect windowCrop, int layer, float cornerRadius, boolean visible) {
|
||||
this.surface = surface;
|
||||
this.alpha = alpha;
|
||||
this.matrix = new Matrix(matrix);
|
||||
this.windowCrop = new Rect(windowCrop);
|
||||
this.layer = layer;
|
||||
this.cornerRadius = cornerRadius;
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -147,5 +152,7 @@ public class SyncRtSurfaceTransactionApplier {
|
||||
|
||||
@VisibleForTesting
|
||||
public final int layer;
|
||||
|
||||
public final boolean visible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ public class ActivityLaunchAnimator {
|
||||
m.postTranslate(0, (float) (mParams.top - app.position.y));
|
||||
mWindowCrop.set(mParams.left, 0, mParams.right, mParams.getHeight());
|
||||
SurfaceParams params = new SurfaceParams(app.leash, 1f /* alpha */, m, mWindowCrop,
|
||||
app.prefixOrderIndex, mCornerRadius);
|
||||
app.prefixOrderIndex, mCornerRadius, true /* visible */);
|
||||
mSyncRtTransactionApplier.scheduleApply(params);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user