Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -52801,6 +52801,7 @@ package android.view { public static final class WindowInsetsAnimationCallback.InsetsAnimation { ctor public WindowInsetsAnimationCallback.InsetsAnimation(int, @Nullable android.view.animation.Interpolator, long); method @FloatRange(from=0.0f, to=1.0f) public float getAlpha(); method public long getDurationMillis(); method @FloatRange(from=0.0f, to=1.0f) public float getFraction(); method public float getInterpolatedFraction(); Loading @@ -52817,6 +52818,7 @@ package android.view { public interface WindowInsetsAnimationController { method public void finish(boolean); method public float getCurrentAlpha(); method @FloatRange(from=0.0f, to=1.0f) public float getCurrentFraction(); method @NonNull public android.graphics.Insets getCurrentInsets(); method @NonNull public android.graphics.Insets getHiddenStateInsets(); core/java/android/view/InsetsAnimationControlImpl.java +28 −8 Original line number Diff line number Diff line Loading @@ -68,22 +68,26 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll private final InsetsController mController; private final WindowInsetsAnimationCallback.InsetsAnimation mAnimation; private final Rect mFrame; private final boolean mFade; private Insets mCurrentInsets; private Insets mPendingInsets; private float mPendingFraction; private boolean mFinished; private boolean mCancelled; private boolean mShownOnFinish; private float mCurrentAlpha; private float mPendingAlpha; @VisibleForTesting public InsetsAnimationControlImpl(SparseArray<InsetsSourceConsumer> consumers, Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener, @InsetsType int types, Supplier<SyncRtSurfaceTransactionApplier> transactionApplierSupplier, InsetsController controller, long durationMs) { InsetsController controller, long durationMs, boolean fade) { mConsumers = consumers; mListener = listener; mTypes = types; mFade = fade; mTransactionApplierSupplier = transactionApplierSupplier; mController = controller; mInitialInsetsState = new InsetsState(state, true /* copySources */); Loading @@ -100,6 +104,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll mAnimation = new WindowInsetsAnimationCallback.InsetsAnimation(mTypes, InsetsController.INTERPOLATOR, durationMs); mAnimation.setAlpha(getCurrentAlpha()); mController.dispatchAnimationStarted(mAnimation, new AnimationBounds(mHiddenInsets, mShownInsets)); } Loading @@ -119,6 +124,11 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll return mCurrentInsets; } @Override public float getCurrentAlpha() { return mCurrentAlpha; } @Override @InsetsType public int getTypes() { return mTypes; Loading @@ -136,6 +146,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll } mPendingFraction = sanitize(fraction); mPendingInsets = sanitize(insets); mPendingAlpha = 1 - sanitize(alpha); mController.scheduleApplyChangeInsets(); } Loading @@ -148,17 +159,24 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll return false; } final Insets offset = Insets.subtract(mShownInsets, mPendingInsets); final Float alphaOffset = 1 - mPendingAlpha; ArrayList<SurfaceParams> params = new ArrayList<>(); updateLeashesForSide(ISIDE_LEFT, offset.left, mPendingInsets.left, params, state); updateLeashesForSide(ISIDE_TOP, offset.top, mPendingInsets.top, params, state); updateLeashesForSide(ISIDE_RIGHT, offset.right, mPendingInsets.right, params, state); updateLeashesForSide(ISIDE_BOTTOM, offset.bottom, mPendingInsets.bottom, params, state); updateLeashesForSide(ISIDE_FLOATING, 0 /* offset */, 0 /* inset */, params, state); updateLeashesForSide(ISIDE_LEFT, offset.left, mShownInsets.left, mPendingInsets.left, params, state, alphaOffset); updateLeashesForSide(ISIDE_TOP, offset.top, mShownInsets.top, mPendingInsets.top, params, state, alphaOffset); updateLeashesForSide(ISIDE_RIGHT, offset.right, mShownInsets.right, mPendingInsets.right, params, state, alphaOffset); updateLeashesForSide(ISIDE_BOTTOM, offset.bottom, mShownInsets.bottom, mPendingInsets.bottom, params, state, alphaOffset); updateLeashesForSide(ISIDE_FLOATING, 0 /* offset */, 0 /* inset */, 0 /* maxInset */, params, state, alphaOffset); SyncRtSurfaceTransactionApplier applier = mTransactionApplierSupplier.get(); applier.scheduleApply(params.toArray(new SurfaceParams[params.size()])); mCurrentInsets = mPendingInsets; mAnimation.setFraction(mPendingFraction); mCurrentAlpha = 1 - alphaOffset; if (mFinished) { mController.notifyFinished(this, mShownOnFinish); } Loading Loading @@ -233,7 +251,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll } private void updateLeashesForSide(@InternalInsetsSide int side, int offset, int inset, ArrayList<SurfaceParams> surfaceParams, InsetsState state) { int maxInset, ArrayList<SurfaceParams> surfaceParams, InsetsState state, Float alpha) { ArraySet<InsetsSourceConsumer> items = mSideSourceMap.get(side); if (items == null) { return; Loading @@ -257,7 +275,9 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll // If the system is controlling the insets source, the leash can be null. if (leash != null) { surfaceParams.add(new SurfaceParams(leash, 1f /* alpha */, mTmpMatrix, // TODO: use a better interpolation for fade. alpha = mFade ? ((float) maxInset / inset * 0.3f + 0.7f) : alpha; surfaceParams.add(new SurfaceParams(leash, alpha, mTmpMatrix, null /* windowCrop */, 0 /* layer */, 0f /* cornerRadius*/, side == ISIDE_FLOATING ? consumer.isVisible() : inset != 0 /* visible */)); } Loading core/java/android/view/InsetsController.java +5 −4 Original line number Diff line number Diff line Loading @@ -361,12 +361,12 @@ public class InsetsController implements WindowInsetsController { listener.onCancelled(); return; } controlAnimationUnchecked(types, listener, mFrame, fromIme, durationMs); controlAnimationUnchecked(types, listener, mFrame, fromIme, durationMs, false /* fade */); } private void controlAnimationUnchecked(@InsetsType int types, WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme, long durationMs) { long durationMs, boolean fade) { if (types == 0) { // nothing to animate. return; Loading Loading @@ -397,7 +397,7 @@ public class InsetsController implements WindowInsetsController { final InsetsAnimationControlImpl controller = new InsetsAnimationControlImpl(consumers, frame, mState, listener, typesReady, () -> new SyncRtSurfaceTransactionApplier(mViewRoot.mView), this, durationMs); () -> new SyncRtSurfaceTransactionApplier(mViewRoot.mView), this, durationMs, fade); mAnimationControls.add(controller); } Loading Loading @@ -588,7 +588,8 @@ public class InsetsController implements WindowInsetsController { // Show/hide animations always need to be relative to the display frame, in order that shown // and hidden state insets are correct. controlAnimationUnchecked( types, listener, mState.getDisplayFrame(), fromIme, listener.getDurationMs()); types, listener, mState.getDisplayFrame(), fromIme, listener.getDurationMs(), true /* fade */); } private void hideDirectly(@InsetsType int types) { Loading core/java/android/view/WindowInsetsAnimationCallback.java +13 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ public interface WindowInsetsAnimationCallback { private float mFraction; @Nullable private final Interpolator mInterpolator; private long mDurationMs; private float mAlpha; public InsetsAnimation( @InsetsType int typeMask, @Nullable Interpolator interpolator, long durationMs) { Loading Loading @@ -177,6 +178,18 @@ public interface WindowInsetsAnimationCallback { public void setDuration(long durationMs) { mDurationMs = durationMs; } /** * @return alpha of {@link WindowInsets.Type.InsetsType}. */ @FloatRange(from = 0f, to = 1f) public float getAlpha() { return mAlpha; } void setAlpha(@FloatRange(from = 0f, to = 1f) float alpha) { mAlpha = alpha; } } /** Loading core/java/android/view/WindowInsetsAnimationController.java +6 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,12 @@ public interface WindowInsetsAnimationController { @FloatRange(from = 0f, to = 1f) float getCurrentFraction(); /** * Current alpha value of the window. * @return float value between 0 and 1. */ float getCurrentAlpha(); /** * @return The {@link InsetsType}s this object is currently controlling. */ Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -52801,6 +52801,7 @@ package android.view { public static final class WindowInsetsAnimationCallback.InsetsAnimation { ctor public WindowInsetsAnimationCallback.InsetsAnimation(int, @Nullable android.view.animation.Interpolator, long); method @FloatRange(from=0.0f, to=1.0f) public float getAlpha(); method public long getDurationMillis(); method @FloatRange(from=0.0f, to=1.0f) public float getFraction(); method public float getInterpolatedFraction(); Loading @@ -52817,6 +52818,7 @@ package android.view { public interface WindowInsetsAnimationController { method public void finish(boolean); method public float getCurrentAlpha(); method @FloatRange(from=0.0f, to=1.0f) public float getCurrentFraction(); method @NonNull public android.graphics.Insets getCurrentInsets(); method @NonNull public android.graphics.Insets getHiddenStateInsets();
core/java/android/view/InsetsAnimationControlImpl.java +28 −8 Original line number Diff line number Diff line Loading @@ -68,22 +68,26 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll private final InsetsController mController; private final WindowInsetsAnimationCallback.InsetsAnimation mAnimation; private final Rect mFrame; private final boolean mFade; private Insets mCurrentInsets; private Insets mPendingInsets; private float mPendingFraction; private boolean mFinished; private boolean mCancelled; private boolean mShownOnFinish; private float mCurrentAlpha; private float mPendingAlpha; @VisibleForTesting public InsetsAnimationControlImpl(SparseArray<InsetsSourceConsumer> consumers, Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener, @InsetsType int types, Supplier<SyncRtSurfaceTransactionApplier> transactionApplierSupplier, InsetsController controller, long durationMs) { InsetsController controller, long durationMs, boolean fade) { mConsumers = consumers; mListener = listener; mTypes = types; mFade = fade; mTransactionApplierSupplier = transactionApplierSupplier; mController = controller; mInitialInsetsState = new InsetsState(state, true /* copySources */); Loading @@ -100,6 +104,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll mAnimation = new WindowInsetsAnimationCallback.InsetsAnimation(mTypes, InsetsController.INTERPOLATOR, durationMs); mAnimation.setAlpha(getCurrentAlpha()); mController.dispatchAnimationStarted(mAnimation, new AnimationBounds(mHiddenInsets, mShownInsets)); } Loading @@ -119,6 +124,11 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll return mCurrentInsets; } @Override public float getCurrentAlpha() { return mCurrentAlpha; } @Override @InsetsType public int getTypes() { return mTypes; Loading @@ -136,6 +146,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll } mPendingFraction = sanitize(fraction); mPendingInsets = sanitize(insets); mPendingAlpha = 1 - sanitize(alpha); mController.scheduleApplyChangeInsets(); } Loading @@ -148,17 +159,24 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll return false; } final Insets offset = Insets.subtract(mShownInsets, mPendingInsets); final Float alphaOffset = 1 - mPendingAlpha; ArrayList<SurfaceParams> params = new ArrayList<>(); updateLeashesForSide(ISIDE_LEFT, offset.left, mPendingInsets.left, params, state); updateLeashesForSide(ISIDE_TOP, offset.top, mPendingInsets.top, params, state); updateLeashesForSide(ISIDE_RIGHT, offset.right, mPendingInsets.right, params, state); updateLeashesForSide(ISIDE_BOTTOM, offset.bottom, mPendingInsets.bottom, params, state); updateLeashesForSide(ISIDE_FLOATING, 0 /* offset */, 0 /* inset */, params, state); updateLeashesForSide(ISIDE_LEFT, offset.left, mShownInsets.left, mPendingInsets.left, params, state, alphaOffset); updateLeashesForSide(ISIDE_TOP, offset.top, mShownInsets.top, mPendingInsets.top, params, state, alphaOffset); updateLeashesForSide(ISIDE_RIGHT, offset.right, mShownInsets.right, mPendingInsets.right, params, state, alphaOffset); updateLeashesForSide(ISIDE_BOTTOM, offset.bottom, mShownInsets.bottom, mPendingInsets.bottom, params, state, alphaOffset); updateLeashesForSide(ISIDE_FLOATING, 0 /* offset */, 0 /* inset */, 0 /* maxInset */, params, state, alphaOffset); SyncRtSurfaceTransactionApplier applier = mTransactionApplierSupplier.get(); applier.scheduleApply(params.toArray(new SurfaceParams[params.size()])); mCurrentInsets = mPendingInsets; mAnimation.setFraction(mPendingFraction); mCurrentAlpha = 1 - alphaOffset; if (mFinished) { mController.notifyFinished(this, mShownOnFinish); } Loading Loading @@ -233,7 +251,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll } private void updateLeashesForSide(@InternalInsetsSide int side, int offset, int inset, ArrayList<SurfaceParams> surfaceParams, InsetsState state) { int maxInset, ArrayList<SurfaceParams> surfaceParams, InsetsState state, Float alpha) { ArraySet<InsetsSourceConsumer> items = mSideSourceMap.get(side); if (items == null) { return; Loading @@ -257,7 +275,9 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll // If the system is controlling the insets source, the leash can be null. if (leash != null) { surfaceParams.add(new SurfaceParams(leash, 1f /* alpha */, mTmpMatrix, // TODO: use a better interpolation for fade. alpha = mFade ? ((float) maxInset / inset * 0.3f + 0.7f) : alpha; surfaceParams.add(new SurfaceParams(leash, alpha, mTmpMatrix, null /* windowCrop */, 0 /* layer */, 0f /* cornerRadius*/, side == ISIDE_FLOATING ? consumer.isVisible() : inset != 0 /* visible */)); } Loading
core/java/android/view/InsetsController.java +5 −4 Original line number Diff line number Diff line Loading @@ -361,12 +361,12 @@ public class InsetsController implements WindowInsetsController { listener.onCancelled(); return; } controlAnimationUnchecked(types, listener, mFrame, fromIme, durationMs); controlAnimationUnchecked(types, listener, mFrame, fromIme, durationMs, false /* fade */); } private void controlAnimationUnchecked(@InsetsType int types, WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme, long durationMs) { long durationMs, boolean fade) { if (types == 0) { // nothing to animate. return; Loading Loading @@ -397,7 +397,7 @@ public class InsetsController implements WindowInsetsController { final InsetsAnimationControlImpl controller = new InsetsAnimationControlImpl(consumers, frame, mState, listener, typesReady, () -> new SyncRtSurfaceTransactionApplier(mViewRoot.mView), this, durationMs); () -> new SyncRtSurfaceTransactionApplier(mViewRoot.mView), this, durationMs, fade); mAnimationControls.add(controller); } Loading Loading @@ -588,7 +588,8 @@ public class InsetsController implements WindowInsetsController { // Show/hide animations always need to be relative to the display frame, in order that shown // and hidden state insets are correct. controlAnimationUnchecked( types, listener, mState.getDisplayFrame(), fromIme, listener.getDurationMs()); types, listener, mState.getDisplayFrame(), fromIme, listener.getDurationMs(), true /* fade */); } private void hideDirectly(@InsetsType int types) { Loading
core/java/android/view/WindowInsetsAnimationCallback.java +13 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ public interface WindowInsetsAnimationCallback { private float mFraction; @Nullable private final Interpolator mInterpolator; private long mDurationMs; private float mAlpha; public InsetsAnimation( @InsetsType int typeMask, @Nullable Interpolator interpolator, long durationMs) { Loading Loading @@ -177,6 +178,18 @@ public interface WindowInsetsAnimationCallback { public void setDuration(long durationMs) { mDurationMs = durationMs; } /** * @return alpha of {@link WindowInsets.Type.InsetsType}. */ @FloatRange(from = 0f, to = 1f) public float getAlpha() { return mAlpha; } void setAlpha(@FloatRange(from = 0f, to = 1f) float alpha) { mAlpha = alpha; } } /** Loading
core/java/android/view/WindowInsetsAnimationController.java +6 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,12 @@ public interface WindowInsetsAnimationController { @FloatRange(from = 0f, to = 1f) float getCurrentFraction(); /** * Current alpha value of the window. * @return float value between 0 and 1. */ float getCurrentAlpha(); /** * @return The {@link InsetsType}s this object is currently controlling. */ Loading