438 lines
18 KiB
Java
438 lines
18 KiB
Java
package androidx.core.view;
|
|
|
|
import android.os.Build;
|
|
import android.os.CancellationSignal;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.view.WindowInsetsAnimationControlListener;
|
|
import android.view.WindowInsetsAnimationController;
|
|
import android.view.WindowInsetsController;
|
|
import android.view.animation.Interpolator;
|
|
import android.view.inputmethod.InputMethodManager;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.collection.SimpleArrayMap;
|
|
public final class WindowInsetsControllerCompat {
|
|
public static final int BEHAVIOR_SHOW_BARS_BY_SWIPE = 1;
|
|
public static final int BEHAVIOR_SHOW_BARS_BY_TOUCH = 0;
|
|
public static final int BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE = 2;
|
|
private final Impl mImpl;
|
|
|
|
public static class Impl {
|
|
public void addOnControllableInsetsChangedListener(OnControllableInsetsChangedListener onControllableInsetsChangedListener) {
|
|
}
|
|
|
|
public void controlWindowInsetsAnimation(int i, long j, Interpolator interpolator, CancellationSignal cancellationSignal, WindowInsetsAnimationControlListenerCompat windowInsetsAnimationControlListenerCompat) {
|
|
}
|
|
|
|
public int getSystemBarsBehavior() {
|
|
return 0;
|
|
}
|
|
|
|
public void hide(int i) {
|
|
}
|
|
|
|
public boolean isAppearanceLightNavigationBars() {
|
|
return false;
|
|
}
|
|
|
|
public boolean isAppearanceLightStatusBars() {
|
|
return false;
|
|
}
|
|
|
|
public void removeOnControllableInsetsChangedListener(@NonNull OnControllableInsetsChangedListener onControllableInsetsChangedListener) {
|
|
}
|
|
|
|
public void setAppearanceLightNavigationBars(boolean z2) {
|
|
}
|
|
|
|
public void setAppearanceLightStatusBars(boolean z2) {
|
|
}
|
|
|
|
public void setSystemBarsBehavior(int i) {
|
|
}
|
|
|
|
public void show(int i) {
|
|
}
|
|
}
|
|
|
|
@RequiresApi(20)
|
|
public static class Impl20 extends Impl {
|
|
@Nullable
|
|
private final View mView;
|
|
@NonNull
|
|
public final Window mWindow;
|
|
|
|
/* renamed from: androidx.core.view.WindowInsetsControllerCompat$Impl20$1 reason: invalid class name */
|
|
public class AnonymousClass1 implements Runnable {
|
|
public final /* synthetic */ View val$finalView;
|
|
|
|
public AnonymousClass1(View view) {
|
|
this.val$finalView = view;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
((InputMethodManager) this.val$finalView.getContext().getSystemService("input_method")).showSoftInput(this.val$finalView, 0);
|
|
}
|
|
}
|
|
|
|
public Impl20(@NonNull Window window, @Nullable View view) {
|
|
this.mWindow = window;
|
|
this.mView = view;
|
|
}
|
|
|
|
private void hideForType(int i) {
|
|
if (i == 1) {
|
|
setSystemUiFlag(4);
|
|
} else if (i == 2) {
|
|
setSystemUiFlag(2);
|
|
} else if (i == 8) {
|
|
((InputMethodManager) this.mWindow.getContext().getSystemService("input_method")).hideSoftInputFromWindow(this.mWindow.getDecorView().getWindowToken(), 0);
|
|
}
|
|
}
|
|
|
|
private void showForType(int i) {
|
|
if (i == 1) {
|
|
unsetSystemUiFlag(4);
|
|
unsetWindowFlag(1024);
|
|
} else if (i == 2) {
|
|
unsetSystemUiFlag(2);
|
|
} else if (i == 8) {
|
|
View view = this.mView;
|
|
if (view == null || (!view.isInEditMode() && !view.onCheckIsTextEditor())) {
|
|
view = this.mWindow.getCurrentFocus();
|
|
} else {
|
|
view.requestFocus();
|
|
}
|
|
if (view == null) {
|
|
view = this.mWindow.findViewById(16908290);
|
|
}
|
|
if (view != null && view.hasWindowFocus()) {
|
|
view.post(new AnonymousClass1(view));
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void addOnControllableInsetsChangedListener(OnControllableInsetsChangedListener onControllableInsetsChangedListener) {
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void controlWindowInsetsAnimation(int i, long j, Interpolator interpolator, CancellationSignal cancellationSignal, WindowInsetsAnimationControlListenerCompat windowInsetsAnimationControlListenerCompat) {
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public int getSystemBarsBehavior() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void hide(int i) {
|
|
for (int i2 = 1; i2 <= 256; i2 <<= 1) {
|
|
if ((i & i2) != 0) {
|
|
hideForType(i2);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void removeOnControllableInsetsChangedListener(@NonNull OnControllableInsetsChangedListener onControllableInsetsChangedListener) {
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void setSystemBarsBehavior(int i) {
|
|
if (i == 0) {
|
|
unsetSystemUiFlag(6144);
|
|
} else if (i == 1) {
|
|
unsetSystemUiFlag(4096);
|
|
setSystemUiFlag(2048);
|
|
} else if (i == 2) {
|
|
unsetSystemUiFlag(2048);
|
|
setSystemUiFlag(4096);
|
|
}
|
|
}
|
|
|
|
public void setSystemUiFlag(int i) {
|
|
View decorView = this.mWindow.getDecorView();
|
|
decorView.setSystemUiVisibility(i | decorView.getSystemUiVisibility());
|
|
}
|
|
|
|
public void setWindowFlag(int i) {
|
|
this.mWindow.addFlags(i);
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void show(int i) {
|
|
for (int i2 = 1; i2 <= 256; i2 <<= 1) {
|
|
if ((i & i2) != 0) {
|
|
showForType(i2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void unsetSystemUiFlag(int i) {
|
|
View decorView = this.mWindow.getDecorView();
|
|
decorView.setSystemUiVisibility((~i) & decorView.getSystemUiVisibility());
|
|
}
|
|
|
|
public void unsetWindowFlag(int i) {
|
|
this.mWindow.clearFlags(i);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(23)
|
|
public static class Impl23 extends Impl20 {
|
|
public Impl23(@NonNull Window window, @Nullable View view) {
|
|
super(window, view);
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public boolean isAppearanceLightStatusBars() {
|
|
return (this.mWindow.getDecorView().getSystemUiVisibility() & 8192) != 0;
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void setAppearanceLightStatusBars(boolean z2) {
|
|
if (z2) {
|
|
unsetWindowFlag(67108864);
|
|
setWindowFlag(Integer.MIN_VALUE);
|
|
setSystemUiFlag(8192);
|
|
return;
|
|
}
|
|
unsetSystemUiFlag(8192);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(26)
|
|
public static class Impl26 extends Impl23 {
|
|
public Impl26(@NonNull Window window, @Nullable View view) {
|
|
super(window, view);
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public boolean isAppearanceLightNavigationBars() {
|
|
return (this.mWindow.getDecorView().getSystemUiVisibility() & 16) != 0;
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void setAppearanceLightNavigationBars(boolean z2) {
|
|
if (z2) {
|
|
unsetWindowFlag(134217728);
|
|
setWindowFlag(Integer.MIN_VALUE);
|
|
setSystemUiFlag(16);
|
|
return;
|
|
}
|
|
unsetSystemUiFlag(16);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(30)
|
|
public static class Impl30 extends Impl {
|
|
public final WindowInsetsControllerCompat mCompatController;
|
|
public final WindowInsetsController mInsetsController;
|
|
private final SimpleArrayMap<OnControllableInsetsChangedListener, WindowInsetsController.OnControllableInsetsChangedListener> mListeners;
|
|
|
|
/* renamed from: androidx.core.view.WindowInsetsControllerCompat$Impl30$1 reason: invalid class name */
|
|
public class AnonymousClass1 implements WindowInsetsAnimationControlListener {
|
|
private WindowInsetsAnimationControllerCompat mCompatAnimController = null;
|
|
public final /* synthetic */ WindowInsetsAnimationControlListenerCompat val$listener;
|
|
|
|
public AnonymousClass1(WindowInsetsAnimationControlListenerCompat windowInsetsAnimationControlListenerCompat) {
|
|
this.val$listener = windowInsetsAnimationControlListenerCompat;
|
|
}
|
|
|
|
@Override // android.view.WindowInsetsAnimationControlListener
|
|
public void onCancelled(@Nullable WindowInsetsAnimationController windowInsetsAnimationController) {
|
|
this.val$listener.onCancelled(windowInsetsAnimationController == null ? null : this.mCompatAnimController);
|
|
}
|
|
|
|
@Override // android.view.WindowInsetsAnimationControlListener
|
|
public void onFinished(@NonNull WindowInsetsAnimationController windowInsetsAnimationController) {
|
|
this.val$listener.onFinished(this.mCompatAnimController);
|
|
}
|
|
|
|
@Override // android.view.WindowInsetsAnimationControlListener
|
|
public void onReady(@NonNull WindowInsetsAnimationController windowInsetsAnimationController, int i) {
|
|
WindowInsetsAnimationControllerCompat windowInsetsAnimationControllerCompat = new WindowInsetsAnimationControllerCompat(windowInsetsAnimationController);
|
|
this.mCompatAnimController = windowInsetsAnimationControllerCompat;
|
|
this.val$listener.onReady(windowInsetsAnimationControllerCompat, i);
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.core.view.WindowInsetsControllerCompat$Impl30$2 reason: invalid class name */
|
|
public class AnonymousClass2 implements WindowInsetsController.OnControllableInsetsChangedListener {
|
|
public final /* synthetic */ OnControllableInsetsChangedListener val$listener;
|
|
|
|
public AnonymousClass2(OnControllableInsetsChangedListener onControllableInsetsChangedListener) {
|
|
this.val$listener = onControllableInsetsChangedListener;
|
|
}
|
|
|
|
@Override // android.view.WindowInsetsController.OnControllableInsetsChangedListener
|
|
public void onControllableInsetsChanged(@NonNull WindowInsetsController windowInsetsController, int i) {
|
|
Impl30 impl30 = Impl30.this;
|
|
if (impl30.mInsetsController == windowInsetsController) {
|
|
this.val$listener.onControllableInsetsChanged(impl30.mCompatController, i);
|
|
}
|
|
}
|
|
}
|
|
|
|
public Impl30(@NonNull Window window, @NonNull WindowInsetsControllerCompat windowInsetsControllerCompat) {
|
|
this(window.getInsetsController(), windowInsetsControllerCompat);
|
|
}
|
|
|
|
public Impl30(@NonNull WindowInsetsController windowInsetsController, @NonNull WindowInsetsControllerCompat windowInsetsControllerCompat) {
|
|
this.mListeners = new SimpleArrayMap<>();
|
|
this.mInsetsController = windowInsetsController;
|
|
this.mCompatController = windowInsetsControllerCompat;
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void addOnControllableInsetsChangedListener(@NonNull OnControllableInsetsChangedListener onControllableInsetsChangedListener) {
|
|
if (!this.mListeners.containsKey(onControllableInsetsChangedListener)) {
|
|
AnonymousClass2 r0 = new AnonymousClass2(onControllableInsetsChangedListener);
|
|
this.mListeners.put(onControllableInsetsChangedListener, r0);
|
|
this.mInsetsController.addOnControllableInsetsChangedListener(r0);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void controlWindowInsetsAnimation(int i, long j, @Nullable Interpolator interpolator, @Nullable CancellationSignal cancellationSignal, @NonNull WindowInsetsAnimationControlListenerCompat windowInsetsAnimationControlListenerCompat) {
|
|
this.mInsetsController.controlWindowInsetsAnimation(i, j, interpolator, cancellationSignal, new AnonymousClass1(windowInsetsAnimationControlListenerCompat));
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public int getSystemBarsBehavior() {
|
|
return this.mInsetsController.getSystemBarsBehavior();
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void hide(int i) {
|
|
this.mInsetsController.hide(i);
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public boolean isAppearanceLightNavigationBars() {
|
|
return (this.mInsetsController.getSystemBarsAppearance() & 16) != 0;
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public boolean isAppearanceLightStatusBars() {
|
|
return (this.mInsetsController.getSystemBarsAppearance() & 8) != 0;
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void removeOnControllableInsetsChangedListener(@NonNull OnControllableInsetsChangedListener onControllableInsetsChangedListener) {
|
|
WindowInsetsController.OnControllableInsetsChangedListener remove = this.mListeners.remove(onControllableInsetsChangedListener);
|
|
if (remove != null) {
|
|
this.mInsetsController.removeOnControllableInsetsChangedListener(remove);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void setAppearanceLightNavigationBars(boolean z2) {
|
|
if (z2) {
|
|
this.mInsetsController.setSystemBarsAppearance(16, 16);
|
|
} else {
|
|
this.mInsetsController.setSystemBarsAppearance(0, 16);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void setAppearanceLightStatusBars(boolean z2) {
|
|
if (z2) {
|
|
this.mInsetsController.setSystemBarsAppearance(8, 8);
|
|
} else {
|
|
this.mInsetsController.setSystemBarsAppearance(0, 8);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void setSystemBarsBehavior(int i) {
|
|
this.mInsetsController.setSystemBarsBehavior(i);
|
|
}
|
|
|
|
@Override // androidx.core.view.WindowInsetsControllerCompat.Impl
|
|
public void show(int i) {
|
|
this.mInsetsController.show(i);
|
|
}
|
|
}
|
|
|
|
public interface OnControllableInsetsChangedListener {
|
|
void onControllableInsetsChanged(@NonNull WindowInsetsControllerCompat windowInsetsControllerCompat, int i);
|
|
}
|
|
|
|
public WindowInsetsControllerCompat(@NonNull Window window, @NonNull View view) {
|
|
int i = Build.VERSION.SDK_INT;
|
|
if (i >= 30) {
|
|
this.mImpl = new Impl30(window, this);
|
|
} else if (i >= 26) {
|
|
this.mImpl = new Impl26(window, view);
|
|
} else if (i >= 23) {
|
|
this.mImpl = new Impl23(window, view);
|
|
} else {
|
|
this.mImpl = new Impl20(window, view);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(30)
|
|
private WindowInsetsControllerCompat(@NonNull WindowInsetsController windowInsetsController) {
|
|
if (Build.VERSION.SDK_INT >= 30) {
|
|
this.mImpl = new Impl30(windowInsetsController, this);
|
|
} else {
|
|
this.mImpl = new Impl();
|
|
}
|
|
}
|
|
|
|
@NonNull
|
|
@RequiresApi(30)
|
|
public static WindowInsetsControllerCompat toWindowInsetsControllerCompat(@NonNull WindowInsetsController windowInsetsController) {
|
|
return new WindowInsetsControllerCompat(windowInsetsController);
|
|
}
|
|
|
|
public void addOnControllableInsetsChangedListener(@NonNull OnControllableInsetsChangedListener onControllableInsetsChangedListener) {
|
|
this.mImpl.addOnControllableInsetsChangedListener(onControllableInsetsChangedListener);
|
|
}
|
|
|
|
public void controlWindowInsetsAnimation(int i, long j, @Nullable Interpolator interpolator, @Nullable CancellationSignal cancellationSignal, @NonNull WindowInsetsAnimationControlListenerCompat windowInsetsAnimationControlListenerCompat) {
|
|
this.mImpl.controlWindowInsetsAnimation(i, j, interpolator, cancellationSignal, windowInsetsAnimationControlListenerCompat);
|
|
}
|
|
|
|
public int getSystemBarsBehavior() {
|
|
return this.mImpl.getSystemBarsBehavior();
|
|
}
|
|
|
|
public void hide(int i) {
|
|
this.mImpl.hide(i);
|
|
}
|
|
|
|
public boolean isAppearanceLightNavigationBars() {
|
|
return this.mImpl.isAppearanceLightNavigationBars();
|
|
}
|
|
|
|
public boolean isAppearanceLightStatusBars() {
|
|
return this.mImpl.isAppearanceLightStatusBars();
|
|
}
|
|
|
|
public void removeOnControllableInsetsChangedListener(@NonNull OnControllableInsetsChangedListener onControllableInsetsChangedListener) {
|
|
this.mImpl.removeOnControllableInsetsChangedListener(onControllableInsetsChangedListener);
|
|
}
|
|
|
|
public void setAppearanceLightNavigationBars(boolean z2) {
|
|
this.mImpl.setAppearanceLightNavigationBars(z2);
|
|
}
|
|
|
|
public void setAppearanceLightStatusBars(boolean z2) {
|
|
this.mImpl.setAppearanceLightStatusBars(z2);
|
|
}
|
|
|
|
public void setSystemBarsBehavior(int i) {
|
|
this.mImpl.setSystemBarsBehavior(i);
|
|
}
|
|
|
|
public void show(int i) {
|
|
this.mImpl.show(i);
|
|
}
|
|
}
|