Loading api/current.txt +2 −2 Original line number Diff line number Diff line Loading @@ -54575,7 +54575,7 @@ package android.view { method public float getInterpolatedFraction(); method @Nullable public android.view.animation.Interpolator getInterpolator(); method public int getTypeMask(); method public void setDuration(long); method public void setAlpha(@FloatRange(from=0.0f, to=1.0f) float); method public void setFraction(@FloatRange(from=0.0f, to=1.0f) float); } Loading @@ -54596,7 +54596,7 @@ package android.view { } public interface WindowInsetsController { method public default void controlInputMethodAnimation(long, @NonNull android.view.WindowInsetsAnimationControlListener); method public default void controlInputMethodAnimation(long, @Nullable android.view.animation.Interpolator, @NonNull android.view.WindowInsetsAnimationControlListener); method public int getSystemBarsAppearance(); method public int getSystemBarsBehavior(); method public default void hideInputMethod(); core/java/android/view/InsetsAnimationControlImpl.java +6 −5 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.view.WindowInsets.Type.InsetsType; import android.view.WindowInsetsAnimationCallback.AnimationBounds; import android.view.WindowInsetsAnimationCallback.InsetsAnimation; import android.view.WindowManager.LayoutParams; import android.view.animation.Interpolator; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -84,8 +85,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls, Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener, @InsetsType int types, InsetsAnimationControlCallbacks controller, long durationMs, boolean fade, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation) { InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator, boolean fade, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation) { mControls = controls; mListener = listener; mTypes = types; Loading @@ -101,8 +102,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll mFrame = new Rect(frame); buildTypeSourcesMap(mTypeSideMap, mSideSourceMap, mControls); mAnimation = new WindowInsetsAnimationCallback.InsetsAnimation(mTypes, InsetsController.INTERPOLATOR, durationMs); mAnimation = new WindowInsetsAnimationCallback.InsetsAnimation(mTypes, interpolator, durationMs); mAnimation.setAlpha(getCurrentAlpha()); mController.startAnimation(this, listener, types, mAnimation, new AnimationBounds(mHiddenInsets, mShownInsets), layoutInsetsDuringAnimation); Loading Loading @@ -196,7 +197,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll state.getSource(control.getType()).setVisible(shown); } Insets insets = getInsetsFromState(state, mFrame, null /* typeSideMap */); setInsetsAndAlpha(insets, 1f /* alpha */, shown ? 1f : 0f /* fraction */); setInsetsAndAlpha(insets, 1f /* alpha */, 1f /* fraction */); mFinished = true; mShownOnFinish = shown; } Loading core/java/android/view/InsetsController.java +14 −12 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.animation.ObjectAnimator; import android.animation.TypeEvaluator; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.graphics.Insets; import android.graphics.Rect; import android.os.RemoteException; Loading Loading @@ -145,7 +146,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation controller.setInsetsAndAlpha( value, 1f /* alpha */, (((DefaultAnimationControlListener) ((InsetsAnimationControlImpl) controller).getListener()) .getRawProgress())); .getRawFraction())); } } Loading Loading @@ -204,9 +205,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation mController.finish(mShow); } protected float getRawProgress() { float fraction = (float) mAnimator.getCurrentPlayTime() / mAnimator.getDuration(); return mShow ? fraction : 1 - fraction; protected float getRawFraction() { return (float) mAnimator.getCurrentPlayTime() / mAnimator.getDuration(); } protected long getDurationMs() { Loading Loading @@ -437,27 +437,29 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @Override public void controlWindowInsetsAnimation(@InsetsType int types, long durationMs, WindowInsetsAnimationControlListener listener) { controlWindowInsetsAnimation(types, listener, false /* fromIme */, durationMs, @Nullable Interpolator interpolator, @NonNull WindowInsetsAnimationControlListener listener) { controlWindowInsetsAnimation(types, listener, false /* fromIme */, durationMs, interpolator, ANIMATION_TYPE_USER); } private void controlWindowInsetsAnimation(@InsetsType int types, WindowInsetsAnimationControlListener listener, boolean fromIme, long durationMs, @AnimationType int animationType) { @Nullable Interpolator interpolator, @AnimationType int animationType) { // If the frame of our window doesn't span the entire display, the control API makes very // little sense, as we don't deal with negative insets. So just cancel immediately. if (!mState.getDisplayFrame().equals(mFrame)) { listener.onCancelled(); return; } controlAnimationUnchecked(types, listener, mFrame, fromIme, durationMs, false /* fade */, animationType, getLayoutInsetsDuringAnimationMode(types)); controlAnimationUnchecked(types, listener, mFrame, fromIme, durationMs, interpolator, false /* fade */, animationType, getLayoutInsetsDuringAnimationMode(types)); } private void controlAnimationUnchecked(@InsetsType int types, WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme, long durationMs, boolean fade, @AnimationType int animationType, long durationMs, Interpolator interpolator, boolean fade, @AnimationType int animationType, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation) { if (types == 0) { // nothing to animate. Loading Loading @@ -488,7 +490,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } final InsetsAnimationControlImpl controller = new InsetsAnimationControlImpl(controls, frame, mState, listener, typesReady, this, durationMs, fade, frame, mState, listener, typesReady, this, durationMs, interpolator, fade, layoutInsetsDuringAnimation); mRunningAnimations.add(new RunningAnimation(controller, animationType)); } Loading Loading @@ -733,7 +735,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation // and hidden state insets are correct. controlAnimationUnchecked( types, listener, mState.getDisplayFrame(), fromIme, listener.getDurationMs(), true /* fade */, show ? ANIMATION_TYPE_SHOW : ANIMATION_TYPE_HIDE, INTERPOLATOR, true /* fade */, show ? ANIMATION_TYPE_SHOW : ANIMATION_TYPE_HIDE, show ? LAYOUT_INSETS_DURING_ANIMATION_SHOWN : LAYOUT_INSETS_DURING_ANIMATION_HIDDEN); } Loading core/java/android/view/WindowInsetsAnimationCallback.java +68 −27 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public interface WindowInsetsAnimationCallback { * <ul> * <li>Application calls {@link WindowInsetsController#hideInputMethod()}, * {@link WindowInsetsController#showInputMethod()}, * {@link WindowInsetsController#controlInputMethodAnimation(long, WindowInsetsAnimationControlListener)}</li> * {@link WindowInsetsController#controlInputMethodAnimation}</li> * <li>onPrepare is called on the view hierarchy listeners</li> * <li>{@link View#onApplyWindowInsets} will be called with the end state of the * animation</li> Loading Loading @@ -182,14 +182,26 @@ public interface WindowInsetsAnimationCallback { private final @InsetsType int mTypeMask; private float mFraction; @Nullable private final Interpolator mInterpolator; private long mDurationMs; private final long mDurationMillis; private float mAlpha; /** * Creates a new {@link InsetsAnimation} object. * <p> * This should only be used for testing, as usually the system creates this object for the * application to listen to with {@link WindowInsetsAnimationCallback}. * </p> * @param typeMask The bitmask of {@link WindowInsets.Type}s that are animating. * @param interpolator The interpolator of the animation. * @param durationMillis The duration of the animation in * {@link java.util.concurrent.TimeUnit#MILLISECONDS}. */ public InsetsAnimation( @InsetsType int typeMask, @Nullable Interpolator interpolator, long durationMs) { @InsetsType int typeMask, @Nullable Interpolator interpolator, long durationMillis) { mTypeMask = typeMask; mInterpolator = interpolator; mDurationMs = durationMs; mDurationMillis = durationMillis; } /** Loading @@ -201,14 +213,18 @@ public interface WindowInsetsAnimationCallback { /** * Returns the raw fractional progress of this animation between * {@link AnimationBounds#getLowerBound()} and {@link AnimationBounds#getUpperBound()}. Note * start state of the animation and the end state of the animation. Note * that this progress is the global progress of the animation, whereas * {@link WindowInsetsAnimationCallback#onProgress} will only dispatch the insets that may * be inset with {@link WindowInsets#inset} by parents of views in the hierarchy. * Progress per insets animation is global for the entire animation. One animation animates * all things together (in, out, ...). If they don't animate together, we'd have * multiple animations. * * <p> * Note: In case the application is controlling the animation, the valued returned here will * be the same as the application passed into * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)}. * </p> * @return The current progress of this animation. */ @FloatRange(from = 0f, to = 1f) Loading @@ -218,13 +234,24 @@ public interface WindowInsetsAnimationCallback { /** * Returns the interpolated fractional progress of this animation between * {@link AnimationBounds#getLowerBound()} and {@link AnimationBounds#getUpperBound()}. Note * start state of the animation and the end state of the animation. Note * that this progress is the global progress of the animation, whereas * {@link WindowInsetsAnimationCallback#onProgress} will only dispatch the insets that may * be inset with {@link WindowInsets#inset} by parents of views in the hierarchy. * Progress per insets animation is global for the entire animation. One animation animates * all things together (in, out, ...). If they don't animate together, we'd have * multiple animations. * <p> * Note: In case the application is controlling the animation, the valued returned here will * be the same as the application passed into * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)}, * interpolated with the interpolator passed into * {@link WindowInsetsController#controlInputMethodAnimation}. * </p> * <p> * Note: For system-initiated animations, this will always return a valid value between 0 * and 1. * </p> * @see #getFraction() for raw fraction. * @return The current interpolated progress of this animation. -1 if interpolator isn't * specified. Loading @@ -236,52 +263,66 @@ public interface WindowInsetsAnimationCallback { return -1; } /** * Retrieves the interpolator used for this animation, or {@code null} if this animation * doesn't follow an interpolation curved. For system-initiated animations, this will never * return {@code null}. * * @return The interpolator used for this animation. */ @Nullable public Interpolator getInterpolator() { return mInterpolator; } /** * @return duration of animation in {@link java.util.concurrent.TimeUnit#MILLISECONDS}. * @return duration of animation in {@link java.util.concurrent.TimeUnit#MILLISECONDS}, or * -1 if the animation doesn't have a fixed duration. */ public long getDurationMillis() { return mDurationMs; return mDurationMillis; } /** * Set fraction of the progress if {@link WindowInsets.Type.InsetsType} animation is * controlled by the app {@see #getCurrentFraction}. * <p>Note: If app didn't create {@link InsetsAnimation}, it shouldn't set progress either. * Progress would be set by system with the system-default animation. * controlled by the app. * <p> * Note: This should only be used for testing, as the system fills in the fraction for the * application or the fraction that was passed into * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)} is being * used. * </p> * @param fraction fractional progress between 0 and 1 where 0 represents hidden and * zero progress and 1 represent fully shown final state. * @see #getFraction() */ public void setFraction(@FloatRange(from = 0f, to = 1f) float fraction) { mFraction = fraction; } /** * Set duration of the animation if {@link WindowInsets.Type.InsetsType} animation is * controlled by the app. * <p>Note: If app didn't create {@link InsetsAnimation}, it shouldn't set duration either. * Duration would be set by system with the system-default animation. * </p> * @param durationMs in {@link java.util.concurrent.TimeUnit#MILLISECONDS} */ public void setDuration(long durationMs) { mDurationMs = durationMs; } /** * @return alpha of {@link WindowInsets.Type.InsetsType}. * Retrieves the translucency of the windows that are animating. * * @return Alpha of windows that cause insets of type {@link WindowInsets.Type.InsetsType}. */ @FloatRange(from = 0f, to = 1f) public float getAlpha() { return mAlpha; } void setAlpha(@FloatRange(from = 0f, to = 1f) float alpha) { /** * Sets the translucency of the windows that are animating. * <p> * Note: This should only be used for testing, as the system fills in the alpha for the * application or the alpha that was passed into * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)} is being * used. * </p> * @param alpha Alpha of windows that cause insets of type * {@link WindowInsets.Type.InsetsType}. * @see #getAlpha() */ public void setAlpha(@FloatRange(from = 0f, to = 1f) float alpha) { mAlpha = alpha; } } Loading core/java/android/view/WindowInsetsController.java +32 −7 Original line number Diff line number Diff line Loading @@ -20,8 +20,11 @@ import static android.view.WindowInsets.Type.ime; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.graphics.Insets; import android.view.WindowInsets.Type.InsetsType; import android.view.WindowInsetsAnimationCallback.InsetsAnimation; import android.view.animation.Interpolator; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading Loading @@ -148,29 +151,51 @@ public interface WindowInsetsController { * the position of the windows in the system causing insets directly. * * @param types The {@link InsetsType}s the application has requested to control. * @param durationMillis duration of animation in * @param durationMillis Duration of animation in * {@link java.util.concurrent.TimeUnit#MILLISECONDS}, or -1 if the * animation doesn't have a predetermined duration. * animation doesn't have a predetermined duration.T his value will be * passed to {@link InsetsAnimation#getDurationMillis()} * @param interpolator The interpolator used for this animation, or {@code null} if this * animation doesn't follow an interpolation curve. This value will be * passed to {@link InsetsAnimation#getInterpolator()} and used to calculate * {@link InsetsAnimation#getInterpolatedFraction()}. * @param listener The {@link WindowInsetsAnimationControlListener} that gets called when the * windows are ready to be controlled, among other callbacks. * * @see InsetsAnimation#getFraction() * @see InsetsAnimation#getInterpolatedFraction() * @see InsetsAnimation#getInterpolator() * @see InsetsAnimation#getDurationMillis() * @hide */ void controlWindowInsetsAnimation(@InsetsType int types, long durationMillis, @Nullable Interpolator interpolator, @NonNull WindowInsetsAnimationControlListener listener); /** * Lets the application control the animation for showing the IME in a frame-by-frame manner by * modifying the position of the IME when it's causing insets. * * @param durationMillis duration of the animation in * @param durationMillis Duration of the animation in * {@link java.util.concurrent.TimeUnit#MILLISECONDS}, or -1 if the * animation doesn't have a predetermined duration. * animation doesn't have a predetermined duration. This value will be * passed to {@link InsetsAnimation#getDurationMillis()} * @param interpolator The interpolator used for this animation, or {@code null} if this * animation doesn't follow an interpolation curve. This value will be * passed to {@link InsetsAnimation#getInterpolator()} and used to calculate * {@link InsetsAnimation#getInterpolatedFraction()}. * @param listener The {@link WindowInsetsAnimationControlListener} that gets called when the * IME are ready to be controlled, among other callbacks. * * @see InsetsAnimation#getFraction() * @see InsetsAnimation#getInterpolatedFraction() * @see InsetsAnimation#getInterpolator() * @see InsetsAnimation#getDurationMillis() */ default void controlInputMethodAnimation(long durationMillis, @Nullable Interpolator interpolator, @NonNull WindowInsetsAnimationControlListener listener) { controlWindowInsetsAnimation(ime(), durationMillis, listener); controlWindowInsetsAnimation(ime(), durationMillis, interpolator, listener); } /** Loading @@ -181,7 +206,7 @@ public interface WindowInsetsController { * the event by observing {@link View#onApplyWindowInsets} and checking visibility with * {@link WindowInsets#isVisible}. * * @see #controlInputMethodAnimation(long, WindowInsetsAnimationControlListener) * @see #controlInputMethodAnimation * @see #hideInputMethod() */ default void showInputMethod() { Loading @@ -196,7 +221,7 @@ public interface WindowInsetsController { * the event by observing {@link View#onApplyWindowInsets} and checking visibility with * {@link WindowInsets#isVisible}. * * @see #controlInputMethodAnimation(long, WindowInsetsAnimationControlListener) * @see #controlInputMethodAnimation * @see #showInputMethod() */ default void hideInputMethod() { Loading Loading
api/current.txt +2 −2 Original line number Diff line number Diff line Loading @@ -54575,7 +54575,7 @@ package android.view { method public float getInterpolatedFraction(); method @Nullable public android.view.animation.Interpolator getInterpolator(); method public int getTypeMask(); method public void setDuration(long); method public void setAlpha(@FloatRange(from=0.0f, to=1.0f) float); method public void setFraction(@FloatRange(from=0.0f, to=1.0f) float); } Loading @@ -54596,7 +54596,7 @@ package android.view { } public interface WindowInsetsController { method public default void controlInputMethodAnimation(long, @NonNull android.view.WindowInsetsAnimationControlListener); method public default void controlInputMethodAnimation(long, @Nullable android.view.animation.Interpolator, @NonNull android.view.WindowInsetsAnimationControlListener); method public int getSystemBarsAppearance(); method public int getSystemBarsBehavior(); method public default void hideInputMethod();
core/java/android/view/InsetsAnimationControlImpl.java +6 −5 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.view.WindowInsets.Type.InsetsType; import android.view.WindowInsetsAnimationCallback.AnimationBounds; import android.view.WindowInsetsAnimationCallback.InsetsAnimation; import android.view.WindowManager.LayoutParams; import android.view.animation.Interpolator; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -84,8 +85,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls, Rect frame, InsetsState state, WindowInsetsAnimationControlListener listener, @InsetsType int types, InsetsAnimationControlCallbacks controller, long durationMs, boolean fade, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation) { InsetsAnimationControlCallbacks controller, long durationMs, Interpolator interpolator, boolean fade, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation) { mControls = controls; mListener = listener; mTypes = types; Loading @@ -101,8 +102,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll mFrame = new Rect(frame); buildTypeSourcesMap(mTypeSideMap, mSideSourceMap, mControls); mAnimation = new WindowInsetsAnimationCallback.InsetsAnimation(mTypes, InsetsController.INTERPOLATOR, durationMs); mAnimation = new WindowInsetsAnimationCallback.InsetsAnimation(mTypes, interpolator, durationMs); mAnimation.setAlpha(getCurrentAlpha()); mController.startAnimation(this, listener, types, mAnimation, new AnimationBounds(mHiddenInsets, mShownInsets), layoutInsetsDuringAnimation); Loading Loading @@ -196,7 +197,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll state.getSource(control.getType()).setVisible(shown); } Insets insets = getInsetsFromState(state, mFrame, null /* typeSideMap */); setInsetsAndAlpha(insets, 1f /* alpha */, shown ? 1f : 0f /* fraction */); setInsetsAndAlpha(insets, 1f /* alpha */, 1f /* fraction */); mFinished = true; mShownOnFinish = shown; } Loading
core/java/android/view/InsetsController.java +14 −12 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.animation.ObjectAnimator; import android.animation.TypeEvaluator; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.graphics.Insets; import android.graphics.Rect; import android.os.RemoteException; Loading Loading @@ -145,7 +146,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation controller.setInsetsAndAlpha( value, 1f /* alpha */, (((DefaultAnimationControlListener) ((InsetsAnimationControlImpl) controller).getListener()) .getRawProgress())); .getRawFraction())); } } Loading Loading @@ -204,9 +205,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation mController.finish(mShow); } protected float getRawProgress() { float fraction = (float) mAnimator.getCurrentPlayTime() / mAnimator.getDuration(); return mShow ? fraction : 1 - fraction; protected float getRawFraction() { return (float) mAnimator.getCurrentPlayTime() / mAnimator.getDuration(); } protected long getDurationMs() { Loading Loading @@ -437,27 +437,29 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @Override public void controlWindowInsetsAnimation(@InsetsType int types, long durationMs, WindowInsetsAnimationControlListener listener) { controlWindowInsetsAnimation(types, listener, false /* fromIme */, durationMs, @Nullable Interpolator interpolator, @NonNull WindowInsetsAnimationControlListener listener) { controlWindowInsetsAnimation(types, listener, false /* fromIme */, durationMs, interpolator, ANIMATION_TYPE_USER); } private void controlWindowInsetsAnimation(@InsetsType int types, WindowInsetsAnimationControlListener listener, boolean fromIme, long durationMs, @AnimationType int animationType) { @Nullable Interpolator interpolator, @AnimationType int animationType) { // If the frame of our window doesn't span the entire display, the control API makes very // little sense, as we don't deal with negative insets. So just cancel immediately. if (!mState.getDisplayFrame().equals(mFrame)) { listener.onCancelled(); return; } controlAnimationUnchecked(types, listener, mFrame, fromIme, durationMs, false /* fade */, animationType, getLayoutInsetsDuringAnimationMode(types)); controlAnimationUnchecked(types, listener, mFrame, fromIme, durationMs, interpolator, false /* fade */, animationType, getLayoutInsetsDuringAnimationMode(types)); } private void controlAnimationUnchecked(@InsetsType int types, WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme, long durationMs, boolean fade, @AnimationType int animationType, long durationMs, Interpolator interpolator, boolean fade, @AnimationType int animationType, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation) { if (types == 0) { // nothing to animate. Loading Loading @@ -488,7 +490,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } final InsetsAnimationControlImpl controller = new InsetsAnimationControlImpl(controls, frame, mState, listener, typesReady, this, durationMs, fade, frame, mState, listener, typesReady, this, durationMs, interpolator, fade, layoutInsetsDuringAnimation); mRunningAnimations.add(new RunningAnimation(controller, animationType)); } Loading Loading @@ -733,7 +735,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation // and hidden state insets are correct. controlAnimationUnchecked( types, listener, mState.getDisplayFrame(), fromIme, listener.getDurationMs(), true /* fade */, show ? ANIMATION_TYPE_SHOW : ANIMATION_TYPE_HIDE, INTERPOLATOR, true /* fade */, show ? ANIMATION_TYPE_SHOW : ANIMATION_TYPE_HIDE, show ? LAYOUT_INSETS_DURING_ANIMATION_SHOWN : LAYOUT_INSETS_DURING_ANIMATION_HIDDEN); } Loading
core/java/android/view/WindowInsetsAnimationCallback.java +68 −27 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public interface WindowInsetsAnimationCallback { * <ul> * <li>Application calls {@link WindowInsetsController#hideInputMethod()}, * {@link WindowInsetsController#showInputMethod()}, * {@link WindowInsetsController#controlInputMethodAnimation(long, WindowInsetsAnimationControlListener)}</li> * {@link WindowInsetsController#controlInputMethodAnimation}</li> * <li>onPrepare is called on the view hierarchy listeners</li> * <li>{@link View#onApplyWindowInsets} will be called with the end state of the * animation</li> Loading Loading @@ -182,14 +182,26 @@ public interface WindowInsetsAnimationCallback { private final @InsetsType int mTypeMask; private float mFraction; @Nullable private final Interpolator mInterpolator; private long mDurationMs; private final long mDurationMillis; private float mAlpha; /** * Creates a new {@link InsetsAnimation} object. * <p> * This should only be used for testing, as usually the system creates this object for the * application to listen to with {@link WindowInsetsAnimationCallback}. * </p> * @param typeMask The bitmask of {@link WindowInsets.Type}s that are animating. * @param interpolator The interpolator of the animation. * @param durationMillis The duration of the animation in * {@link java.util.concurrent.TimeUnit#MILLISECONDS}. */ public InsetsAnimation( @InsetsType int typeMask, @Nullable Interpolator interpolator, long durationMs) { @InsetsType int typeMask, @Nullable Interpolator interpolator, long durationMillis) { mTypeMask = typeMask; mInterpolator = interpolator; mDurationMs = durationMs; mDurationMillis = durationMillis; } /** Loading @@ -201,14 +213,18 @@ public interface WindowInsetsAnimationCallback { /** * Returns the raw fractional progress of this animation between * {@link AnimationBounds#getLowerBound()} and {@link AnimationBounds#getUpperBound()}. Note * start state of the animation and the end state of the animation. Note * that this progress is the global progress of the animation, whereas * {@link WindowInsetsAnimationCallback#onProgress} will only dispatch the insets that may * be inset with {@link WindowInsets#inset} by parents of views in the hierarchy. * Progress per insets animation is global for the entire animation. One animation animates * all things together (in, out, ...). If they don't animate together, we'd have * multiple animations. * * <p> * Note: In case the application is controlling the animation, the valued returned here will * be the same as the application passed into * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)}. * </p> * @return The current progress of this animation. */ @FloatRange(from = 0f, to = 1f) Loading @@ -218,13 +234,24 @@ public interface WindowInsetsAnimationCallback { /** * Returns the interpolated fractional progress of this animation between * {@link AnimationBounds#getLowerBound()} and {@link AnimationBounds#getUpperBound()}. Note * start state of the animation and the end state of the animation. Note * that this progress is the global progress of the animation, whereas * {@link WindowInsetsAnimationCallback#onProgress} will only dispatch the insets that may * be inset with {@link WindowInsets#inset} by parents of views in the hierarchy. * Progress per insets animation is global for the entire animation. One animation animates * all things together (in, out, ...). If they don't animate together, we'd have * multiple animations. * <p> * Note: In case the application is controlling the animation, the valued returned here will * be the same as the application passed into * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)}, * interpolated with the interpolator passed into * {@link WindowInsetsController#controlInputMethodAnimation}. * </p> * <p> * Note: For system-initiated animations, this will always return a valid value between 0 * and 1. * </p> * @see #getFraction() for raw fraction. * @return The current interpolated progress of this animation. -1 if interpolator isn't * specified. Loading @@ -236,52 +263,66 @@ public interface WindowInsetsAnimationCallback { return -1; } /** * Retrieves the interpolator used for this animation, or {@code null} if this animation * doesn't follow an interpolation curved. For system-initiated animations, this will never * return {@code null}. * * @return The interpolator used for this animation. */ @Nullable public Interpolator getInterpolator() { return mInterpolator; } /** * @return duration of animation in {@link java.util.concurrent.TimeUnit#MILLISECONDS}. * @return duration of animation in {@link java.util.concurrent.TimeUnit#MILLISECONDS}, or * -1 if the animation doesn't have a fixed duration. */ public long getDurationMillis() { return mDurationMs; return mDurationMillis; } /** * Set fraction of the progress if {@link WindowInsets.Type.InsetsType} animation is * controlled by the app {@see #getCurrentFraction}. * <p>Note: If app didn't create {@link InsetsAnimation}, it shouldn't set progress either. * Progress would be set by system with the system-default animation. * controlled by the app. * <p> * Note: This should only be used for testing, as the system fills in the fraction for the * application or the fraction that was passed into * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)} is being * used. * </p> * @param fraction fractional progress between 0 and 1 where 0 represents hidden and * zero progress and 1 represent fully shown final state. * @see #getFraction() */ public void setFraction(@FloatRange(from = 0f, to = 1f) float fraction) { mFraction = fraction; } /** * Set duration of the animation if {@link WindowInsets.Type.InsetsType} animation is * controlled by the app. * <p>Note: If app didn't create {@link InsetsAnimation}, it shouldn't set duration either. * Duration would be set by system with the system-default animation. * </p> * @param durationMs in {@link java.util.concurrent.TimeUnit#MILLISECONDS} */ public void setDuration(long durationMs) { mDurationMs = durationMs; } /** * @return alpha of {@link WindowInsets.Type.InsetsType}. * Retrieves the translucency of the windows that are animating. * * @return Alpha of windows that cause insets of type {@link WindowInsets.Type.InsetsType}. */ @FloatRange(from = 0f, to = 1f) public float getAlpha() { return mAlpha; } void setAlpha(@FloatRange(from = 0f, to = 1f) float alpha) { /** * Sets the translucency of the windows that are animating. * <p> * Note: This should only be used for testing, as the system fills in the alpha for the * application or the alpha that was passed into * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)} is being * used. * </p> * @param alpha Alpha of windows that cause insets of type * {@link WindowInsets.Type.InsetsType}. * @see #getAlpha() */ public void setAlpha(@FloatRange(from = 0f, to = 1f) float alpha) { mAlpha = alpha; } } Loading
core/java/android/view/WindowInsetsController.java +32 −7 Original line number Diff line number Diff line Loading @@ -20,8 +20,11 @@ import static android.view.WindowInsets.Type.ime; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.graphics.Insets; import android.view.WindowInsets.Type.InsetsType; import android.view.WindowInsetsAnimationCallback.InsetsAnimation; import android.view.animation.Interpolator; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading Loading @@ -148,29 +151,51 @@ public interface WindowInsetsController { * the position of the windows in the system causing insets directly. * * @param types The {@link InsetsType}s the application has requested to control. * @param durationMillis duration of animation in * @param durationMillis Duration of animation in * {@link java.util.concurrent.TimeUnit#MILLISECONDS}, or -1 if the * animation doesn't have a predetermined duration. * animation doesn't have a predetermined duration.T his value will be * passed to {@link InsetsAnimation#getDurationMillis()} * @param interpolator The interpolator used for this animation, or {@code null} if this * animation doesn't follow an interpolation curve. This value will be * passed to {@link InsetsAnimation#getInterpolator()} and used to calculate * {@link InsetsAnimation#getInterpolatedFraction()}. * @param listener The {@link WindowInsetsAnimationControlListener} that gets called when the * windows are ready to be controlled, among other callbacks. * * @see InsetsAnimation#getFraction() * @see InsetsAnimation#getInterpolatedFraction() * @see InsetsAnimation#getInterpolator() * @see InsetsAnimation#getDurationMillis() * @hide */ void controlWindowInsetsAnimation(@InsetsType int types, long durationMillis, @Nullable Interpolator interpolator, @NonNull WindowInsetsAnimationControlListener listener); /** * Lets the application control the animation for showing the IME in a frame-by-frame manner by * modifying the position of the IME when it's causing insets. * * @param durationMillis duration of the animation in * @param durationMillis Duration of the animation in * {@link java.util.concurrent.TimeUnit#MILLISECONDS}, or -1 if the * animation doesn't have a predetermined duration. * animation doesn't have a predetermined duration. This value will be * passed to {@link InsetsAnimation#getDurationMillis()} * @param interpolator The interpolator used for this animation, or {@code null} if this * animation doesn't follow an interpolation curve. This value will be * passed to {@link InsetsAnimation#getInterpolator()} and used to calculate * {@link InsetsAnimation#getInterpolatedFraction()}. * @param listener The {@link WindowInsetsAnimationControlListener} that gets called when the * IME are ready to be controlled, among other callbacks. * * @see InsetsAnimation#getFraction() * @see InsetsAnimation#getInterpolatedFraction() * @see InsetsAnimation#getInterpolator() * @see InsetsAnimation#getDurationMillis() */ default void controlInputMethodAnimation(long durationMillis, @Nullable Interpolator interpolator, @NonNull WindowInsetsAnimationControlListener listener) { controlWindowInsetsAnimation(ime(), durationMillis, listener); controlWindowInsetsAnimation(ime(), durationMillis, interpolator, listener); } /** Loading @@ -181,7 +206,7 @@ public interface WindowInsetsController { * the event by observing {@link View#onApplyWindowInsets} and checking visibility with * {@link WindowInsets#isVisible}. * * @see #controlInputMethodAnimation(long, WindowInsetsAnimationControlListener) * @see #controlInputMethodAnimation * @see #hideInputMethod() */ default void showInputMethod() { Loading @@ -196,7 +221,7 @@ public interface WindowInsetsController { * the event by observing {@link View#onApplyWindowInsets} and checking visibility with * {@link WindowInsets#isVisible}. * * @see #controlInputMethodAnimation(long, WindowInsetsAnimationControlListener) * @see #controlInputMethodAnimation * @see #showInputMethod() */ default void hideInputMethod() { Loading