Files
rr3-apk/decompiled/sources/androidx/core/view/WindowInsetsAnimationCompat.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

591 lines
26 KiB
Java

package androidx.core.view;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowInsetsAnimation;
import android.view.WindowInsetsAnimation$Callback;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
import androidx.annotation.FloatRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.R;
import androidx.core.graphics.Insets;
import androidx.core.view.WindowInsetsCompat;
import androidx.interpolator.view.animation.FastOutLinearInInterpolator;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
/* loaded from: classes.dex */
public final class WindowInsetsAnimationCompat {
private static final boolean DEBUG = false;
private static final String TAG = "WindowInsetsAnimCompat";
private Impl mImpl;
public WindowInsetsAnimationCompat(int i, @Nullable Interpolator interpolator, long j) {
if (Build.VERSION.SDK_INT >= 30) {
this.mImpl = new Impl30(i, interpolator, j);
} else {
this.mImpl = new Impl21(i, interpolator, j);
}
}
@RequiresApi(30)
private WindowInsetsAnimationCompat(@NonNull WindowInsetsAnimation windowInsetsAnimation) {
this(0, null, 0L);
if (Build.VERSION.SDK_INT >= 30) {
this.mImpl = new Impl30(windowInsetsAnimation);
}
}
public int getTypeMask() {
return this.mImpl.getTypeMask();
}
@FloatRange(from = 0.0d, to = 1.0d)
public float getFraction() {
return this.mImpl.getFraction();
}
public float getInterpolatedFraction() {
return this.mImpl.getInterpolatedFraction();
}
@Nullable
public Interpolator getInterpolator() {
return this.mImpl.getInterpolator();
}
public long getDurationMillis() {
return this.mImpl.getDurationMillis();
}
public void setFraction(@FloatRange(from = 0.0d, to = 1.0d) float f) {
this.mImpl.setFraction(f);
}
@FloatRange(from = 0.0d, to = 1.0d)
public float getAlpha() {
return this.mImpl.getAlpha();
}
public void setAlpha(@FloatRange(from = 0.0d, to = 1.0d) float f) {
this.mImpl.setAlpha(f);
}
public static final class BoundsCompat {
private final Insets mLowerBound;
private final Insets mUpperBound;
@NonNull
public Insets getLowerBound() {
return this.mLowerBound;
}
@NonNull
public Insets getUpperBound() {
return this.mUpperBound;
}
public BoundsCompat(@NonNull Insets insets, @NonNull Insets insets2) {
this.mLowerBound = insets;
this.mUpperBound = insets2;
}
@RequiresApi(30)
private BoundsCompat(@NonNull WindowInsetsAnimation.Bounds bounds) {
this.mLowerBound = Impl30.getLowerBounds(bounds);
this.mUpperBound = Impl30.getHigherBounds(bounds);
}
@NonNull
public BoundsCompat inset(@NonNull Insets insets) {
return new BoundsCompat(WindowInsetsCompat.insetInsets(this.mLowerBound, insets.left, insets.top, insets.right, insets.bottom), WindowInsetsCompat.insetInsets(this.mUpperBound, insets.left, insets.top, insets.right, insets.bottom));
}
public String toString() {
return "Bounds{lower=" + this.mLowerBound + " upper=" + this.mUpperBound + "}";
}
@NonNull
@RequiresApi(30)
public WindowInsetsAnimation.Bounds toBounds() {
return Impl30.createPlatformBounds(this);
}
@NonNull
@RequiresApi(30)
public static BoundsCompat toBoundsCompat(@NonNull WindowInsetsAnimation.Bounds bounds) {
return new BoundsCompat(bounds);
}
}
@RequiresApi(30)
public static WindowInsetsAnimationCompat toWindowInsetsAnimationCompat(WindowInsetsAnimation windowInsetsAnimation) {
return new WindowInsetsAnimationCompat(windowInsetsAnimation);
}
public static abstract class Callback {
public static final int DISPATCH_MODE_CONTINUE_ON_SUBTREE = 1;
public static final int DISPATCH_MODE_STOP = 0;
WindowInsets mDispachedInsets;
private final int mDispatchMode;
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public @interface DispatchMode {
}
public final int getDispatchMode() {
return this.mDispatchMode;
}
public void onEnd(@NonNull WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
}
public void onPrepare(@NonNull WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
}
@NonNull
public abstract WindowInsetsCompat onProgress(@NonNull WindowInsetsCompat windowInsetsCompat, @NonNull List<WindowInsetsAnimationCompat> list);
@NonNull
public BoundsCompat onStart(@NonNull WindowInsetsAnimationCompat windowInsetsAnimationCompat, @NonNull BoundsCompat boundsCompat) {
return boundsCompat;
}
public Callback(int i) {
this.mDispatchMode = i;
}
}
public static void setCallback(@NonNull View view, @Nullable Callback callback) {
if (Build.VERSION.SDK_INT >= 30) {
Impl30.setCallback(view, callback);
} else {
Impl21.setCallback(view, callback);
}
}
public static class Impl {
private float mAlpha;
private final long mDurationMillis;
private float mFraction;
@Nullable
private final Interpolator mInterpolator;
private final int mTypeMask;
public float getAlpha() {
return this.mAlpha;
}
public long getDurationMillis() {
return this.mDurationMillis;
}
public float getFraction() {
return this.mFraction;
}
@Nullable
public Interpolator getInterpolator() {
return this.mInterpolator;
}
public int getTypeMask() {
return this.mTypeMask;
}
public void setAlpha(float f) {
this.mAlpha = f;
}
public void setFraction(float f) {
this.mFraction = f;
}
public Impl(int i, @Nullable Interpolator interpolator, long j) {
this.mTypeMask = i;
this.mInterpolator = interpolator;
this.mDurationMillis = j;
}
public float getInterpolatedFraction() {
Interpolator interpolator = this.mInterpolator;
return interpolator != null ? interpolator.getInterpolation(this.mFraction) : this.mFraction;
}
}
@RequiresApi(21)
public static class Impl21 extends Impl {
private static final Interpolator SHOW_IME_INTERPOLATOR = new PathInterpolator(0.0f, 1.1f, 0.0f, 1.0f);
private static final Interpolator HIDE_IME_INTERPOLATOR = new FastOutLinearInInterpolator();
private static final Interpolator DEFAULT_INSET_INTERPOLATOR = new DecelerateInterpolator();
public Impl21(int i, @Nullable Interpolator interpolator, long j) {
super(i, interpolator, j);
}
public static void setCallback(@NonNull View view, @Nullable Callback callback) {
Object tag = view.getTag(R.id.tag_on_apply_window_listener);
if (callback == null) {
view.setTag(R.id.tag_window_insets_animation_callback, null);
if (tag == null) {
view.setOnApplyWindowInsetsListener(null);
return;
}
return;
}
View.OnApplyWindowInsetsListener createProxyListener = createProxyListener(view, callback);
view.setTag(R.id.tag_window_insets_animation_callback, createProxyListener);
if (tag == null) {
view.setOnApplyWindowInsetsListener(createProxyListener);
}
}
@NonNull
private static View.OnApplyWindowInsetsListener createProxyListener(@NonNull View view, @NonNull Callback callback) {
return new Impl21OnApplyWindowInsetsListener(view, callback);
}
@NonNull
public static BoundsCompat computeAnimationBounds(@NonNull WindowInsetsCompat windowInsetsCompat, @NonNull WindowInsetsCompat windowInsetsCompat2, int i) {
Insets insets = windowInsetsCompat.getInsets(i);
Insets insets2 = windowInsetsCompat2.getInsets(i);
return new BoundsCompat(Insets.of(Math.min(insets.left, insets2.left), Math.min(insets.top, insets2.top), Math.min(insets.right, insets2.right), Math.min(insets.bottom, insets2.bottom)), Insets.of(Math.max(insets.left, insets2.left), Math.max(insets.top, insets2.top), Math.max(insets.right, insets2.right), Math.max(insets.bottom, insets2.bottom)));
}
@SuppressLint({"WrongConstant"})
public static int buildAnimationMask(@NonNull WindowInsetsCompat windowInsetsCompat, @NonNull WindowInsetsCompat windowInsetsCompat2) {
int i = 0;
for (int i2 = 1; i2 <= 256; i2 <<= 1) {
if (!windowInsetsCompat.getInsets(i2).equals(windowInsetsCompat2.getInsets(i2))) {
i |= i2;
}
}
return i;
}
public static Interpolator createInsetInterpolator(int i, WindowInsetsCompat windowInsetsCompat, WindowInsetsCompat windowInsetsCompat2) {
return (i & 8) != 0 ? windowInsetsCompat.getInsets(WindowInsetsCompat.Type.ime()).bottom > windowInsetsCompat2.getInsets(WindowInsetsCompat.Type.ime()).bottom ? SHOW_IME_INTERPOLATOR : HIDE_IME_INTERPOLATOR : DEFAULT_INSET_INTERPOLATOR;
}
@SuppressLint({"WrongConstant"})
public static WindowInsetsCompat interpolateInsets(WindowInsetsCompat windowInsetsCompat, WindowInsetsCompat windowInsetsCompat2, float f, int i) {
WindowInsetsCompat.Builder builder = new WindowInsetsCompat.Builder(windowInsetsCompat);
for (int i2 = 1; i2 <= 256; i2 <<= 1) {
if ((i & i2) == 0) {
builder.setInsets(i2, windowInsetsCompat.getInsets(i2));
} else {
Insets insets = windowInsetsCompat.getInsets(i2);
Insets insets2 = windowInsetsCompat2.getInsets(i2);
float f2 = 1.0f - f;
builder.setInsets(i2, WindowInsetsCompat.insetInsets(insets, (int) (((insets.left - insets2.left) * f2) + 0.5d), (int) (((insets.top - insets2.top) * f2) + 0.5d), (int) (((insets.right - insets2.right) * f2) + 0.5d), (int) (((insets.bottom - insets2.bottom) * f2) + 0.5d)));
}
}
return builder.build();
}
@RequiresApi(21)
public static class Impl21OnApplyWindowInsetsListener implements View.OnApplyWindowInsetsListener {
private static final int COMPAT_ANIMATION_DURATION = 160;
final Callback mCallback;
private WindowInsetsCompat mLastInsets;
public Impl21OnApplyWindowInsetsListener(@NonNull View view, @NonNull Callback callback) {
this.mCallback = callback;
WindowInsetsCompat rootWindowInsets = ViewCompat.getRootWindowInsets(view);
this.mLastInsets = rootWindowInsets != null ? new WindowInsetsCompat.Builder(rootWindowInsets).build() : null;
}
@Override // android.view.View.OnApplyWindowInsetsListener
public WindowInsets onApplyWindowInsets(final View view, WindowInsets windowInsets) {
if (!view.isLaidOut()) {
this.mLastInsets = WindowInsetsCompat.toWindowInsetsCompat(windowInsets, view);
return Impl21.forwardToViewIfNeeded(view, windowInsets);
}
final WindowInsetsCompat windowInsetsCompat = WindowInsetsCompat.toWindowInsetsCompat(windowInsets, view);
if (this.mLastInsets == null) {
this.mLastInsets = ViewCompat.getRootWindowInsets(view);
}
if (this.mLastInsets == null) {
this.mLastInsets = windowInsetsCompat;
return Impl21.forwardToViewIfNeeded(view, windowInsets);
}
Callback callback = Impl21.getCallback(view);
if (callback != null && Objects.equals(callback.mDispachedInsets, windowInsets)) {
return Impl21.forwardToViewIfNeeded(view, windowInsets);
}
final int buildAnimationMask = Impl21.buildAnimationMask(windowInsetsCompat, this.mLastInsets);
if (buildAnimationMask == 0) {
return Impl21.forwardToViewIfNeeded(view, windowInsets);
}
final WindowInsetsCompat windowInsetsCompat2 = this.mLastInsets;
final WindowInsetsAnimationCompat windowInsetsAnimationCompat = new WindowInsetsAnimationCompat(buildAnimationMask, Impl21.createInsetInterpolator(buildAnimationMask, windowInsetsCompat, windowInsetsCompat2), 160L);
windowInsetsAnimationCompat.setFraction(0.0f);
final ValueAnimator duration = ValueAnimator.ofFloat(0.0f, 1.0f).setDuration(windowInsetsAnimationCompat.getDurationMillis());
final BoundsCompat computeAnimationBounds = Impl21.computeAnimationBounds(windowInsetsCompat, windowInsetsCompat2, buildAnimationMask);
Impl21.dispatchOnPrepare(view, windowInsetsAnimationCompat, windowInsets, false);
duration.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: androidx.core.view.WindowInsetsAnimationCompat.Impl21.Impl21OnApplyWindowInsetsListener.1
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
windowInsetsAnimationCompat.setFraction(valueAnimator.getAnimatedFraction());
Impl21.dispatchOnProgress(view, Impl21.interpolateInsets(windowInsetsCompat, windowInsetsCompat2, windowInsetsAnimationCompat.getInterpolatedFraction(), buildAnimationMask), Collections.singletonList(windowInsetsAnimationCompat));
}
});
duration.addListener(new AnimatorListenerAdapter() { // from class: androidx.core.view.WindowInsetsAnimationCompat.Impl21.Impl21OnApplyWindowInsetsListener.2
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
windowInsetsAnimationCompat.setFraction(1.0f);
Impl21.dispatchOnEnd(view, windowInsetsAnimationCompat);
}
});
OneShotPreDrawListener.add(view, new Runnable() { // from class: androidx.core.view.WindowInsetsAnimationCompat.Impl21.Impl21OnApplyWindowInsetsListener.3
@Override // java.lang.Runnable
public void run() {
Impl21.dispatchOnStart(view, windowInsetsAnimationCompat, computeAnimationBounds);
duration.start();
}
});
this.mLastInsets = windowInsetsCompat;
return Impl21.forwardToViewIfNeeded(view, windowInsets);
}
}
@NonNull
public static WindowInsets forwardToViewIfNeeded(@NonNull View view, @NonNull WindowInsets windowInsets) {
return view.getTag(R.id.tag_on_apply_window_listener) != null ? windowInsets : view.onApplyWindowInsets(windowInsets);
}
public static void dispatchOnPrepare(View view, WindowInsetsAnimationCompat windowInsetsAnimationCompat, WindowInsets windowInsets, boolean z) {
Callback callback = getCallback(view);
if (callback != null) {
callback.mDispachedInsets = windowInsets;
if (!z) {
callback.onPrepare(windowInsetsAnimationCompat);
z = callback.getDispatchMode() == 0;
}
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
dispatchOnPrepare(viewGroup.getChildAt(i), windowInsetsAnimationCompat, windowInsets, z);
}
}
}
public static void dispatchOnStart(View view, WindowInsetsAnimationCompat windowInsetsAnimationCompat, BoundsCompat boundsCompat) {
Callback callback = getCallback(view);
if (callback != null) {
callback.onStart(windowInsetsAnimationCompat, boundsCompat);
if (callback.getDispatchMode() == 0) {
return;
}
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
dispatchOnStart(viewGroup.getChildAt(i), windowInsetsAnimationCompat, boundsCompat);
}
}
}
public static void dispatchOnProgress(@NonNull View view, @NonNull WindowInsetsCompat windowInsetsCompat, @NonNull List<WindowInsetsAnimationCompat> list) {
Callback callback = getCallback(view);
if (callback != null) {
windowInsetsCompat = callback.onProgress(windowInsetsCompat, list);
if (callback.getDispatchMode() == 0) {
return;
}
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
dispatchOnProgress(viewGroup.getChildAt(i), windowInsetsCompat, list);
}
}
}
public static void dispatchOnEnd(@NonNull View view, @NonNull WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
Callback callback = getCallback(view);
if (callback != null) {
callback.onEnd(windowInsetsAnimationCompat);
if (callback.getDispatchMode() == 0) {
return;
}
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
dispatchOnEnd(viewGroup.getChildAt(i), windowInsetsAnimationCompat);
}
}
}
@Nullable
public static Callback getCallback(View view) {
Object tag = view.getTag(R.id.tag_window_insets_animation_callback);
if (tag instanceof Impl21OnApplyWindowInsetsListener) {
return ((Impl21OnApplyWindowInsetsListener) tag).mCallback;
}
return null;
}
}
@RequiresApi(30)
public static class Impl30 extends Impl {
@NonNull
private final WindowInsetsAnimation mWrapped;
public Impl30(@NonNull WindowInsetsAnimation windowInsetsAnimation) {
super(0, null, 0L);
this.mWrapped = windowInsetsAnimation;
}
public Impl30(int i, Interpolator interpolator, long j) {
this(WindowInsetsAnimationCompat$Impl30$$ExternalSyntheticApiModelOutline9.m(i, interpolator, j));
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Impl
public int getTypeMask() {
int typeMask;
typeMask = this.mWrapped.getTypeMask();
return typeMask;
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Impl
@Nullable
public Interpolator getInterpolator() {
Interpolator interpolator;
interpolator = this.mWrapped.getInterpolator();
return interpolator;
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Impl
public long getDurationMillis() {
long durationMillis;
durationMillis = this.mWrapped.getDurationMillis();
return durationMillis;
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Impl
public float getFraction() {
float fraction;
fraction = this.mWrapped.getFraction();
return fraction;
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Impl
public void setFraction(float f) {
this.mWrapped.setFraction(f);
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Impl
public float getInterpolatedFraction() {
float interpolatedFraction;
interpolatedFraction = this.mWrapped.getInterpolatedFraction();
return interpolatedFraction;
}
@RequiresApi(30)
public static class ProxyCallback extends WindowInsetsAnimation$Callback {
private final HashMap<WindowInsetsAnimation, WindowInsetsAnimationCompat> mAnimations;
private final Callback mCompat;
private List<WindowInsetsAnimationCompat> mRORunningAnimations;
private ArrayList<WindowInsetsAnimationCompat> mTmpRunningAnimations;
public ProxyCallback(@NonNull Callback callback) {
super(callback.getDispatchMode());
this.mAnimations = new HashMap<>();
this.mCompat = callback;
}
@NonNull
private WindowInsetsAnimationCompat getWindowInsetsAnimationCompat(@NonNull WindowInsetsAnimation windowInsetsAnimation) {
WindowInsetsAnimationCompat windowInsetsAnimationCompat = this.mAnimations.get(windowInsetsAnimation);
if (windowInsetsAnimationCompat != null) {
return windowInsetsAnimationCompat;
}
WindowInsetsAnimationCompat windowInsetsAnimationCompat2 = WindowInsetsAnimationCompat.toWindowInsetsAnimationCompat(windowInsetsAnimation);
this.mAnimations.put(windowInsetsAnimation, windowInsetsAnimationCompat2);
return windowInsetsAnimationCompat2;
}
public void onPrepare(@NonNull WindowInsetsAnimation windowInsetsAnimation) {
this.mCompat.onPrepare(getWindowInsetsAnimationCompat(windowInsetsAnimation));
}
@NonNull
public WindowInsetsAnimation.Bounds onStart(@NonNull WindowInsetsAnimation windowInsetsAnimation, @NonNull WindowInsetsAnimation.Bounds bounds) {
return this.mCompat.onStart(getWindowInsetsAnimationCompat(windowInsetsAnimation), BoundsCompat.toBoundsCompat(bounds)).toBounds();
}
@NonNull
public WindowInsets onProgress(@NonNull WindowInsets windowInsets, @NonNull List<WindowInsetsAnimation> list) {
float fraction;
ArrayList<WindowInsetsAnimationCompat> arrayList = this.mTmpRunningAnimations;
if (arrayList == null) {
ArrayList<WindowInsetsAnimationCompat> arrayList2 = new ArrayList<>(list.size());
this.mTmpRunningAnimations = arrayList2;
this.mRORunningAnimations = Collections.unmodifiableList(arrayList2);
} else {
arrayList.clear();
}
for (int size = list.size() - 1; size >= 0; size--) {
WindowInsetsAnimation m = WindowInsetsAnimationCompat$Impl30$ProxyCallback$$ExternalSyntheticApiModelOutline0.m(list.get(size));
WindowInsetsAnimationCompat windowInsetsAnimationCompat = getWindowInsetsAnimationCompat(m);
fraction = m.getFraction();
windowInsetsAnimationCompat.setFraction(fraction);
this.mTmpRunningAnimations.add(windowInsetsAnimationCompat);
}
return this.mCompat.onProgress(WindowInsetsCompat.toWindowInsetsCompat(windowInsets), this.mRORunningAnimations).toWindowInsets();
}
public void onEnd(@NonNull WindowInsetsAnimation windowInsetsAnimation) {
this.mCompat.onEnd(getWindowInsetsAnimationCompat(windowInsetsAnimation));
this.mAnimations.remove(windowInsetsAnimation);
}
}
public static void setCallback(@NonNull View view, @Nullable Callback callback) {
view.setWindowInsetsAnimationCallback(callback != null ? new ProxyCallback(callback) : null);
}
@NonNull
public static WindowInsetsAnimation.Bounds createPlatformBounds(@NonNull BoundsCompat boundsCompat) {
WindowInsetsAnimationCompat$Impl30$$ExternalSyntheticApiModelOutline11.m();
return WindowInsetsAnimationCompat$Impl30$$ExternalSyntheticApiModelOutline10.m(boundsCompat.getLowerBound().toPlatformInsets(), boundsCompat.getUpperBound().toPlatformInsets());
}
@NonNull
public static Insets getLowerBounds(@NonNull WindowInsetsAnimation.Bounds bounds) {
android.graphics.Insets lowerBound;
lowerBound = bounds.getLowerBound();
return Insets.toCompatInsets(lowerBound);
}
@NonNull
public static Insets getHigherBounds(@NonNull WindowInsetsAnimation.Bounds bounds) {
android.graphics.Insets upperBound;
upperBound = bounds.getUpperBound();
return Insets.toCompatInsets(upperBound);
}
}
}