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