2021-06-27 20:44:35 +00:00
package androidx.core.view ;
2021-09-29 00:45:08 +00:00
import android.annotation.SuppressLint ;
2021-06-27 20:44:35 +00:00
import android.graphics.Rect ;
import android.os.Build ;
import android.util.Log ;
2021-09-29 00:45:08 +00:00
import android.view.View ;
2021-06-27 20:44:35 +00:00
import android.view.WindowInsets ;
import androidx.annotation.IntRange ;
import androidx.annotation.NonNull ;
import androidx.annotation.Nullable ;
import androidx.annotation.RequiresApi ;
import androidx.annotation.RestrictTo ;
import androidx.core.graphics.Insets ;
import androidx.core.util.ObjectsCompat ;
import androidx.core.util.Preconditions ;
2021-12-21 23:37:30 +00:00
import b.d.b.a.a ;
2021-09-29 00:45:08 +00:00
import java.lang.annotation.Retention ;
import java.lang.annotation.RetentionPolicy ;
2021-06-27 20:44:35 +00:00
import java.lang.reflect.Constructor ;
import java.lang.reflect.Field ;
2021-09-29 00:45:08 +00:00
import java.lang.reflect.Method ;
2021-06-27 20:44:35 +00:00
import java.util.Objects ;
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public class WindowInsetsCompat {
2021-09-29 00:45:08 +00:00
@NonNull
public static final WindowInsetsCompat CONSUMED ;
2021-06-27 20:44:35 +00:00
private static final String TAG = " WindowInsetsCompat " ;
private final Impl mImpl ;
2021-09-29 00:45:08 +00:00
@RequiresApi ( 21 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-09-29 00:45:08 +00:00
public static class Api21ReflectionHolder {
private static Field sContentInsets ;
2022-03-02 20:59:20 +00:00
private static boolean sReflectionSucceeded ;
2021-09-29 00:45:08 +00:00
private static Field sStableInsets ;
private static Field sViewAttachInfoField ;
static {
try {
Field declaredField = View . class . getDeclaredField ( " mAttachInfo " ) ;
sViewAttachInfoField = declaredField ;
declaredField . setAccessible ( true ) ;
Class < ? > cls = Class . forName ( " android.view.View$AttachInfo " ) ;
Field declaredField2 = cls . getDeclaredField ( " mStableInsets " ) ;
sStableInsets = declaredField2 ;
declaredField2 . setAccessible ( true ) ;
Field declaredField3 = cls . getDeclaredField ( " mContentInsets " ) ;
sContentInsets = declaredField3 ;
declaredField3 . setAccessible ( true ) ;
2022-03-02 20:59:20 +00:00
sReflectionSucceeded = true ;
2021-09-29 00:45:08 +00:00
} catch ( ReflectiveOperationException e ) {
2021-11-08 18:25:28 +00:00
StringBuilder R = a . R ( " Failed to get visible insets from AttachInfo " ) ;
R . append ( e . getMessage ( ) ) ;
Log . w ( WindowInsetsCompat . TAG , R . toString ( ) , e ) ;
2021-09-29 00:45:08 +00:00
}
}
private Api21ReflectionHolder ( ) {
}
@Nullable
public static WindowInsetsCompat getRootWindowInsets ( @NonNull View view ) {
if ( sReflectionSucceeded & & view . isAttachedToWindow ( ) ) {
try {
Object obj = sViewAttachInfoField . get ( view . getRootView ( ) ) ;
if ( obj ! = null ) {
Rect rect = ( Rect ) sStableInsets . get ( obj ) ;
Rect rect2 = ( Rect ) sContentInsets . get ( obj ) ;
if ( ! ( rect = = null | | rect2 = = null ) ) {
WindowInsetsCompat build = new Builder ( ) . setStableInsets ( Insets . of ( rect ) ) . setSystemWindowInsets ( Insets . of ( rect2 ) ) . build ( ) ;
build . setRootWindowInsets ( build ) ;
build . copyRootViewBounds ( view . getRootView ( ) ) ;
return build ;
}
}
} catch ( IllegalAccessException e ) {
2021-11-08 18:25:28 +00:00
StringBuilder R = a . R ( " Failed to get insets from AttachInfo. " ) ;
R . append ( e . getMessage ( ) ) ;
Log . w ( WindowInsetsCompat . TAG , R . toString ( ) , e ) ;
2021-09-29 00:45:08 +00:00
}
}
return null ;
}
}
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public static final class Builder {
private final BuilderImpl mImpl ;
public Builder ( ) {
2021-09-29 00:45:08 +00:00
int i = Build . VERSION . SDK_INT ;
if ( i > = 30 ) {
this . mImpl = new BuilderImpl30 ( ) ;
} else if ( i > = 29 ) {
2021-06-27 20:44:35 +00:00
this . mImpl = new BuilderImpl29 ( ) ;
} else {
this . mImpl = new BuilderImpl20 ( ) ;
}
}
public Builder ( @NonNull WindowInsetsCompat windowInsetsCompat ) {
2021-09-29 00:45:08 +00:00
int i = Build . VERSION . SDK_INT ;
if ( i > = 30 ) {
this . mImpl = new BuilderImpl30 ( windowInsetsCompat ) ;
} else if ( i > = 29 ) {
2021-06-27 20:44:35 +00:00
this . mImpl = new BuilderImpl29 ( windowInsetsCompat ) ;
} else {
this . mImpl = new BuilderImpl20 ( windowInsetsCompat ) ;
}
}
@NonNull
public WindowInsetsCompat build ( ) {
return this . mImpl . build ( ) ;
}
@NonNull
public Builder setDisplayCutout ( @Nullable DisplayCutoutCompat displayCutoutCompat ) {
this . mImpl . setDisplayCutout ( displayCutoutCompat ) ;
return this ;
}
@NonNull
2021-09-29 00:45:08 +00:00
public Builder setInsets ( int i , @NonNull Insets insets ) {
this . mImpl . setInsets ( i , insets ) ;
return this ;
}
@NonNull
public Builder setInsetsIgnoringVisibility ( int i , @NonNull Insets insets ) {
this . mImpl . setInsetsIgnoringVisibility ( i , insets ) ;
return this ;
}
@NonNull
@Deprecated
2021-06-27 20:44:35 +00:00
public Builder setMandatorySystemGestureInsets ( @NonNull Insets insets ) {
this . mImpl . setMandatorySystemGestureInsets ( insets ) ;
return this ;
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public Builder setStableInsets ( @NonNull Insets insets ) {
this . mImpl . setStableInsets ( insets ) ;
return this ;
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public Builder setSystemGestureInsets ( @NonNull Insets insets ) {
this . mImpl . setSystemGestureInsets ( insets ) ;
return this ;
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public Builder setSystemWindowInsets ( @NonNull Insets insets ) {
this . mImpl . setSystemWindowInsets ( insets ) ;
return this ;
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public Builder setTappableElementInsets ( @NonNull Insets insets ) {
this . mImpl . setTappableElementInsets ( insets ) ;
return this ;
}
2021-09-29 00:45:08 +00:00
@NonNull
public Builder setVisible ( int i , boolean z2 ) {
this . mImpl . setVisible ( i , z2 ) ;
return this ;
}
2021-06-27 20:44:35 +00:00
}
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public static class BuilderImpl {
private final WindowInsetsCompat mInsets ;
2021-09-29 00:45:08 +00:00
public Insets [ ] mInsetsTypeMask ;
2021-06-27 20:44:35 +00:00
public BuilderImpl ( ) {
this ( new WindowInsetsCompat ( ( WindowInsetsCompat ) null ) ) ;
}
public BuilderImpl ( @NonNull WindowInsetsCompat windowInsetsCompat ) {
this . mInsets = windowInsetsCompat ;
}
2021-09-29 00:45:08 +00:00
public final void applyInsetTypes ( ) {
Insets [ ] insetsArr = this . mInsetsTypeMask ;
if ( insetsArr ! = null ) {
Insets insets = insetsArr [ Type . indexOf ( 1 ) ] ;
Insets insets2 = this . mInsetsTypeMask [ Type . indexOf ( 2 ) ] ;
if ( insets2 = = null ) {
insets2 = this . mInsets . getInsets ( 2 ) ;
}
if ( insets = = null ) {
insets = this . mInsets . getInsets ( 1 ) ;
}
setSystemWindowInsets ( Insets . max ( insets , insets2 ) ) ;
Insets insets3 = this . mInsetsTypeMask [ Type . indexOf ( 16 ) ] ;
if ( insets3 ! = null ) {
setSystemGestureInsets ( insets3 ) ;
}
Insets insets4 = this . mInsetsTypeMask [ Type . indexOf ( 32 ) ] ;
if ( insets4 ! = null ) {
setMandatorySystemGestureInsets ( insets4 ) ;
}
Insets insets5 = this . mInsetsTypeMask [ Type . indexOf ( 64 ) ] ;
if ( insets5 ! = null ) {
setTappableElementInsets ( insets5 ) ;
}
}
}
2021-06-27 20:44:35 +00:00
@NonNull
public WindowInsetsCompat build ( ) {
2021-09-29 00:45:08 +00:00
applyInsetTypes ( ) ;
2021-06-27 20:44:35 +00:00
return this . mInsets ;
}
public void setDisplayCutout ( @Nullable DisplayCutoutCompat displayCutoutCompat ) {
}
2021-09-29 00:45:08 +00:00
public void setInsets ( int i , @NonNull Insets insets ) {
if ( this . mInsetsTypeMask = = null ) {
this . mInsetsTypeMask = new Insets [ 9 ] ;
}
for ( int i2 = 1 ; i2 < = 256 ; i2 < < = 1 ) {
if ( ( i & i2 ) ! = 0 ) {
this . mInsetsTypeMask [ Type . indexOf ( i2 ) ] = insets ;
}
}
}
public void setInsetsIgnoringVisibility ( int i , @NonNull Insets insets ) {
if ( i = = 8 ) {
throw new IllegalArgumentException ( " Ignoring visibility inset not available for IME " ) ;
}
}
2021-06-27 20:44:35 +00:00
public void setMandatorySystemGestureInsets ( @NonNull Insets insets ) {
}
public void setStableInsets ( @NonNull Insets insets ) {
}
public void setSystemGestureInsets ( @NonNull Insets insets ) {
}
public void setSystemWindowInsets ( @NonNull Insets insets ) {
}
public void setTappableElementInsets ( @NonNull Insets insets ) {
}
2021-09-29 00:45:08 +00:00
public void setVisible ( int i , boolean z2 ) {
}
2021-06-27 20:44:35 +00:00
}
@RequiresApi ( api = 20 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public static class BuilderImpl20 extends BuilderImpl {
private static Constructor < WindowInsets > sConstructor = null ;
private static boolean sConstructorFetched = false ;
private static Field sConsumedField = null ;
private static boolean sConsumedFieldFetched = false ;
2021-09-29 00:45:08 +00:00
private WindowInsets mPlatformInsets ;
private Insets mStableInsets ;
2021-06-27 20:44:35 +00:00
public BuilderImpl20 ( ) {
2021-09-29 00:45:08 +00:00
this . mPlatformInsets = createWindowInsetsInstance ( ) ;
2021-06-27 20:44:35 +00:00
}
public BuilderImpl20 ( @NonNull WindowInsetsCompat windowInsetsCompat ) {
2021-09-29 00:45:08 +00:00
super ( windowInsetsCompat ) ;
this . mPlatformInsets = windowInsetsCompat . toWindowInsets ( ) ;
2021-06-27 20:44:35 +00:00
}
@Nullable
private static WindowInsets createWindowInsetsInstance ( ) {
if ( ! sConsumedFieldFetched ) {
try {
sConsumedField = WindowInsets . class . getDeclaredField ( " CONSUMED " ) ;
} catch ( ReflectiveOperationException e ) {
2021-08-09 22:50:01 +00:00
Log . i ( WindowInsetsCompat . TAG , " Could not retrieve WindowInsets.CONSUMED field " , e ) ;
2021-06-27 20:44:35 +00:00
}
sConsumedFieldFetched = true ;
}
Field field = sConsumedField ;
if ( field ! = null ) {
try {
WindowInsets windowInsets = ( WindowInsets ) field . get ( null ) ;
if ( windowInsets ! = null ) {
return new WindowInsets ( windowInsets ) ;
}
} catch ( ReflectiveOperationException e2 ) {
2021-08-09 22:50:01 +00:00
Log . i ( WindowInsetsCompat . TAG , " Could not get value from WindowInsets.CONSUMED field " , e2 ) ;
2021-06-27 20:44:35 +00:00
}
}
if ( ! sConstructorFetched ) {
try {
sConstructor = WindowInsets . class . getConstructor ( Rect . class ) ;
} catch ( ReflectiveOperationException e3 ) {
2021-08-09 22:50:01 +00:00
Log . i ( WindowInsetsCompat . TAG , " Could not retrieve WindowInsets(Rect) constructor " , e3 ) ;
2021-06-27 20:44:35 +00:00
}
sConstructorFetched = true ;
}
Constructor < WindowInsets > constructor = sConstructor ;
if ( constructor ! = null ) {
try {
return constructor . newInstance ( new Rect ( ) ) ;
} catch ( ReflectiveOperationException e4 ) {
2021-08-09 22:50:01 +00:00
Log . i ( WindowInsetsCompat . TAG , " Could not invoke WindowInsets(Rect) constructor " , e4 ) ;
2021-06-27 20:44:35 +00:00
}
}
return null ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
@NonNull
public WindowInsetsCompat build ( ) {
2021-09-29 00:45:08 +00:00
applyInsetTypes ( ) ;
WindowInsetsCompat windowInsetsCompat = WindowInsetsCompat . toWindowInsetsCompat ( this . mPlatformInsets ) ;
windowInsetsCompat . setOverriddenInsets ( this . mInsetsTypeMask ) ;
windowInsetsCompat . setStableInsets ( this . mStableInsets ) ;
return windowInsetsCompat ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setStableInsets ( @Nullable Insets insets ) {
this . mStableInsets = insets ;
2021-06-27 20:44:35 +00:00
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setSystemWindowInsets ( @NonNull Insets insets ) {
2021-09-29 00:45:08 +00:00
WindowInsets windowInsets = this . mPlatformInsets ;
2021-06-27 20:44:35 +00:00
if ( windowInsets ! = null ) {
2021-09-29 00:45:08 +00:00
this . mPlatformInsets = windowInsets . replaceSystemWindowInsets ( insets . left , insets . top , insets . right , insets . bottom ) ;
2021-06-27 20:44:35 +00:00
}
}
}
@RequiresApi ( api = 29 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public static class BuilderImpl29 extends BuilderImpl {
public final WindowInsets . Builder mPlatBuilder ;
public BuilderImpl29 ( ) {
this . mPlatBuilder = new WindowInsets . Builder ( ) ;
}
public BuilderImpl29 ( @NonNull WindowInsetsCompat windowInsetsCompat ) {
2021-09-29 00:45:08 +00:00
super ( windowInsetsCompat ) ;
2021-06-27 20:44:35 +00:00
WindowInsets windowInsets = windowInsetsCompat . toWindowInsets ( ) ;
this . mPlatBuilder = windowInsets ! = null ? new WindowInsets . Builder ( windowInsets ) : new WindowInsets . Builder ( ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
@NonNull
public WindowInsetsCompat build ( ) {
2021-09-29 00:45:08 +00:00
applyInsetTypes ( ) ;
WindowInsetsCompat windowInsetsCompat = WindowInsetsCompat . toWindowInsetsCompat ( this . mPlatBuilder . build ( ) ) ;
windowInsetsCompat . setOverriddenInsets ( this . mInsetsTypeMask ) ;
return windowInsetsCompat ;
2021-06-27 20:44:35 +00:00
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setDisplayCutout ( @Nullable DisplayCutoutCompat displayCutoutCompat ) {
this . mPlatBuilder . setDisplayCutout ( displayCutoutCompat ! = null ? displayCutoutCompat . unwrap ( ) : null ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setMandatorySystemGestureInsets ( @NonNull Insets insets ) {
this . mPlatBuilder . setMandatorySystemGestureInsets ( insets . toPlatformInsets ( ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setStableInsets ( @NonNull Insets insets ) {
this . mPlatBuilder . setStableInsets ( insets . toPlatformInsets ( ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setSystemGestureInsets ( @NonNull Insets insets ) {
this . mPlatBuilder . setSystemGestureInsets ( insets . toPlatformInsets ( ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setSystemWindowInsets ( @NonNull Insets insets ) {
this . mPlatBuilder . setSystemWindowInsets ( insets . toPlatformInsets ( ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setTappableElementInsets ( @NonNull Insets insets ) {
this . mPlatBuilder . setTappableElementInsets ( insets . toPlatformInsets ( ) ) ;
}
}
2021-09-29 00:45:08 +00:00
@RequiresApi ( 30 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-09-29 00:45:08 +00:00
public static class BuilderImpl30 extends BuilderImpl29 {
public BuilderImpl30 ( ) {
}
public BuilderImpl30 ( @NonNull WindowInsetsCompat windowInsetsCompat ) {
super ( windowInsetsCompat ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setInsets ( int i , @NonNull Insets insets ) {
this . mPlatBuilder . setInsets ( TypeImpl30 . toPlatformType ( i ) , insets . toPlatformInsets ( ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setInsetsIgnoringVisibility ( int i , @NonNull Insets insets ) {
this . mPlatBuilder . setInsetsIgnoringVisibility ( TypeImpl30 . toPlatformType ( i ) , insets . toPlatformInsets ( ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.BuilderImpl
public void setVisible ( int i , boolean z2 ) {
this . mPlatBuilder . setVisible ( TypeImpl30 . toPlatformType ( i ) , z2 ) ;
}
}
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public static class Impl {
2021-09-29 00:45:08 +00:00
@NonNull
public static final WindowInsetsCompat CONSUMED = new Builder ( ) . build ( ) . consumeDisplayCutout ( ) . consumeStableInsets ( ) . consumeSystemWindowInsets ( ) ;
2021-06-27 20:44:35 +00:00
public final WindowInsetsCompat mHost ;
public Impl ( @NonNull WindowInsetsCompat windowInsetsCompat ) {
this . mHost = windowInsetsCompat ;
}
@NonNull
public WindowInsetsCompat consumeDisplayCutout ( ) {
return this . mHost ;
}
@NonNull
public WindowInsetsCompat consumeStableInsets ( ) {
return this . mHost ;
}
@NonNull
public WindowInsetsCompat consumeSystemWindowInsets ( ) {
return this . mHost ;
}
2021-09-29 00:45:08 +00:00
public void copyRootViewBounds ( @NonNull View view ) {
}
public void copyWindowDataInto ( @NonNull WindowInsetsCompat windowInsetsCompat ) {
}
2021-06-27 20:44:35 +00:00
public boolean equals ( Object obj ) {
if ( this = = obj ) {
return true ;
}
if ( ! ( obj instanceof Impl ) ) {
return false ;
}
Impl impl = ( Impl ) obj ;
return isRound ( ) = = impl . isRound ( ) & & isConsumed ( ) = = impl . isConsumed ( ) & & ObjectsCompat . equals ( getSystemWindowInsets ( ) , impl . getSystemWindowInsets ( ) ) & & ObjectsCompat . equals ( getStableInsets ( ) , impl . getStableInsets ( ) ) & & ObjectsCompat . equals ( getDisplayCutout ( ) , impl . getDisplayCutout ( ) ) ;
}
@Nullable
public DisplayCutoutCompat getDisplayCutout ( ) {
return null ;
}
2021-09-29 00:45:08 +00:00
@NonNull
public Insets getInsets ( int i ) {
return Insets . NONE ;
}
@NonNull
public Insets getInsetsIgnoringVisibility ( int i ) {
if ( ( i & 8 ) = = 0 ) {
return Insets . NONE ;
}
throw new IllegalArgumentException ( " Unable to query the maximum insets for IME " ) ;
}
2021-06-27 20:44:35 +00:00
@NonNull
public Insets getMandatorySystemGestureInsets ( ) {
return getSystemWindowInsets ( ) ;
}
@NonNull
public Insets getStableInsets ( ) {
return Insets . NONE ;
}
@NonNull
public Insets getSystemGestureInsets ( ) {
return getSystemWindowInsets ( ) ;
}
@NonNull
public Insets getSystemWindowInsets ( ) {
return Insets . NONE ;
}
@NonNull
public Insets getTappableElementInsets ( ) {
return getSystemWindowInsets ( ) ;
}
public int hashCode ( ) {
return ObjectsCompat . hash ( Boolean . valueOf ( isRound ( ) ) , Boolean . valueOf ( isConsumed ( ) ) , getSystemWindowInsets ( ) , getStableInsets ( ) , getDisplayCutout ( ) ) ;
}
@NonNull
public WindowInsetsCompat inset ( int i , int i2 , int i3 , int i4 ) {
2021-09-29 00:45:08 +00:00
return CONSUMED ;
2021-06-27 20:44:35 +00:00
}
public boolean isConsumed ( ) {
return false ;
}
public boolean isRound ( ) {
return false ;
}
2021-09-29 00:45:08 +00:00
public boolean isVisible ( int i ) {
return true ;
}
public void setOverriddenInsets ( Insets [ ] insetsArr ) {
}
public void setRootViewData ( @NonNull Insets insets ) {
}
public void setRootWindowInsets ( @Nullable WindowInsetsCompat windowInsetsCompat ) {
}
public void setStableInsets ( Insets insets ) {
}
2021-06-27 20:44:35 +00:00
}
@RequiresApi ( 20 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public static class Impl20 extends Impl {
2021-09-29 00:45:08 +00:00
private static Class < ? > sAttachInfoClass = null ;
private static Field sAttachInfoField = null ;
private static Method sGetViewRootImplMethod = null ;
private static Class < ? > sViewRootImplClass = null ;
private static Field sVisibleInsetsField = null ;
private static boolean sVisibleRectReflectionFetched = false ;
private Insets [ ] mOverriddenInsets ;
2021-06-27 20:44:35 +00:00
@NonNull
public final WindowInsets mPlatformInsets ;
2021-09-29 00:45:08 +00:00
public Insets mRootViewVisibleInsets ;
private WindowInsetsCompat mRootWindowInsets ;
2021-06-27 20:44:35 +00:00
private Insets mSystemWindowInsets ;
public Impl20 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull WindowInsets windowInsets ) {
super ( windowInsetsCompat ) ;
this . mSystemWindowInsets = null ;
this . mPlatformInsets = windowInsets ;
}
public Impl20 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull Impl20 impl20 ) {
this ( windowInsetsCompat , new WindowInsets ( impl20 . mPlatformInsets ) ) ;
}
2021-09-29 00:45:08 +00:00
@NonNull
@SuppressLint ( { " WrongConstant " } )
private Insets getInsets ( int i , boolean z2 ) {
Insets insets = Insets . NONE ;
for ( int i2 = 1 ; i2 < = 256 ; i2 < < = 1 ) {
if ( ( i & i2 ) ! = 0 ) {
insets = Insets . max ( insets , getInsetsForType ( i2 , z2 ) ) ;
}
}
return insets ;
}
private Insets getRootStableInsets ( ) {
WindowInsetsCompat windowInsetsCompat = this . mRootWindowInsets ;
return windowInsetsCompat ! = null ? windowInsetsCompat . getStableInsets ( ) : Insets . NONE ;
}
@Nullable
private Insets getVisibleInsets ( @NonNull View view ) {
if ( Build . VERSION . SDK_INT < 30 ) {
if ( ! sVisibleRectReflectionFetched ) {
loadReflectionField ( ) ;
}
Method method = sGetViewRootImplMethod ;
if ( ! ( method = = null | | sAttachInfoClass = = null | | sVisibleInsetsField = = null ) ) {
try {
Object invoke = method . invoke ( view , new Object [ 0 ] ) ;
if ( invoke = = null ) {
Log . w ( WindowInsetsCompat . TAG , " Failed to get visible insets. getViewRootImpl() returned null from the provided view. This means that the view is either not attached or the method has been overridden " , new NullPointerException ( ) ) ;
return null ;
}
Rect rect = ( Rect ) sVisibleInsetsField . get ( sAttachInfoField . get ( invoke ) ) ;
if ( rect ! = null ) {
return Insets . of ( rect ) ;
}
return null ;
} catch ( ReflectiveOperationException e ) {
2021-11-08 18:25:28 +00:00
StringBuilder R = a . R ( " Failed to get visible insets. (Reflection error). " ) ;
R . append ( e . getMessage ( ) ) ;
Log . e ( WindowInsetsCompat . TAG , R . toString ( ) , e ) ;
2021-09-29 00:45:08 +00:00
}
}
return null ;
}
throw new UnsupportedOperationException ( " getVisibleInsets() should not be called on API >= 30. Use WindowInsets.isVisible() instead. " ) ;
}
@SuppressLint ( { " PrivateApi " } )
private static void loadReflectionField ( ) {
try {
sGetViewRootImplMethod = View . class . getDeclaredMethod ( " getViewRootImpl " , new Class [ 0 ] ) ;
sViewRootImplClass = Class . forName ( " android.view.ViewRootImpl " ) ;
Class < ? > cls = Class . forName ( " android.view.View$AttachInfo " ) ;
sAttachInfoClass = cls ;
sVisibleInsetsField = cls . getDeclaredField ( " mVisibleInsets " ) ;
sAttachInfoField = sViewRootImplClass . getDeclaredField ( " mAttachInfo " ) ;
sVisibleInsetsField . setAccessible ( true ) ;
sAttachInfoField . setAccessible ( true ) ;
} catch ( ReflectiveOperationException e ) {
2021-11-08 18:25:28 +00:00
StringBuilder R = a . R ( " Failed to get visible insets. (Reflection error). " ) ;
R . append ( e . getMessage ( ) ) ;
Log . e ( WindowInsetsCompat . TAG , R . toString ( ) , e ) ;
2021-09-29 00:45:08 +00:00
}
sVisibleRectReflectionFetched = true ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
public void copyRootViewBounds ( @NonNull View view ) {
Insets visibleInsets = getVisibleInsets ( view ) ;
if ( visibleInsets = = null ) {
visibleInsets = Insets . NONE ;
}
setRootViewData ( visibleInsets ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
public void copyWindowDataInto ( @NonNull WindowInsetsCompat windowInsetsCompat ) {
windowInsetsCompat . setRootWindowInsets ( this . mRootWindowInsets ) ;
windowInsetsCompat . setRootViewData ( this . mRootViewVisibleInsets ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
public boolean equals ( Object obj ) {
if ( ! super . equals ( obj ) ) {
return false ;
}
return Objects . equals ( this . mRootViewVisibleInsets , ( ( Impl20 ) obj ) . mRootViewVisibleInsets ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public Insets getInsets ( int i ) {
return getInsets ( i , false ) ;
}
@NonNull
public Insets getInsetsForType ( int i , boolean z2 ) {
int i2 ;
if ( i = = 1 ) {
return z2 ? Insets . of ( 0 , Math . max ( getRootStableInsets ( ) . top , getSystemWindowInsets ( ) . top ) , 0 , 0 ) : Insets . of ( 0 , getSystemWindowInsets ( ) . top , 0 , 0 ) ;
}
Insets insets = null ;
if ( i ! = 2 ) {
if ( i = = 8 ) {
Insets [ ] insetsArr = this . mOverriddenInsets ;
if ( insetsArr ! = null ) {
insets = insetsArr [ Type . indexOf ( 8 ) ] ;
}
if ( insets ! = null ) {
return insets ;
}
Insets systemWindowInsets = getSystemWindowInsets ( ) ;
Insets rootStableInsets = getRootStableInsets ( ) ;
int i3 = systemWindowInsets . bottom ;
if ( i3 > rootStableInsets . bottom ) {
return Insets . of ( 0 , 0 , 0 , i3 ) ;
}
Insets insets2 = this . mRootViewVisibleInsets ;
return ( insets2 = = null | | insets2 . equals ( Insets . NONE ) | | ( i2 = this . mRootViewVisibleInsets . bottom ) < = rootStableInsets . bottom ) ? Insets . NONE : Insets . of ( 0 , 0 , 0 , i2 ) ;
} else if ( i = = 16 ) {
return getSystemGestureInsets ( ) ;
} else {
if ( i = = 32 ) {
return getMandatorySystemGestureInsets ( ) ;
}
if ( i = = 64 ) {
return getTappableElementInsets ( ) ;
}
if ( i ! = 128 ) {
return Insets . NONE ;
}
WindowInsetsCompat windowInsetsCompat = this . mRootWindowInsets ;
DisplayCutoutCompat displayCutout = windowInsetsCompat ! = null ? windowInsetsCompat . getDisplayCutout ( ) : getDisplayCutout ( ) ;
return displayCutout ! = null ? Insets . of ( displayCutout . getSafeInsetLeft ( ) , displayCutout . getSafeInsetTop ( ) , displayCutout . getSafeInsetRight ( ) , displayCutout . getSafeInsetBottom ( ) ) : Insets . NONE ;
}
} else if ( z2 ) {
Insets rootStableInsets2 = getRootStableInsets ( ) ;
Insets stableInsets = getStableInsets ( ) ;
return Insets . of ( Math . max ( rootStableInsets2 . left , stableInsets . left ) , 0 , Math . max ( rootStableInsets2 . right , stableInsets . right ) , Math . max ( rootStableInsets2 . bottom , stableInsets . bottom ) ) ;
} else {
Insets systemWindowInsets2 = getSystemWindowInsets ( ) ;
WindowInsetsCompat windowInsetsCompat2 = this . mRootWindowInsets ;
if ( windowInsetsCompat2 ! = null ) {
insets = windowInsetsCompat2 . getStableInsets ( ) ;
}
int i4 = systemWindowInsets2 . bottom ;
if ( insets ! = null ) {
i4 = Math . min ( i4 , insets . bottom ) ;
}
return Insets . of ( systemWindowInsets2 . left , 0 , systemWindowInsets2 . right , i4 ) ;
}
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public Insets getInsetsIgnoringVisibility ( int i ) {
return getInsets ( i , true ) ;
}
2021-06-27 20:44:35 +00:00
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public final Insets getSystemWindowInsets ( ) {
if ( this . mSystemWindowInsets = = null ) {
this . mSystemWindowInsets = Insets . of ( this . mPlatformInsets . getSystemWindowInsetLeft ( ) , this . mPlatformInsets . getSystemWindowInsetTop ( ) , this . mPlatformInsets . getSystemWindowInsetRight ( ) , this . mPlatformInsets . getSystemWindowInsetBottom ( ) ) ;
}
return this . mSystemWindowInsets ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public WindowInsetsCompat inset ( int i , int i2 , int i3 , int i4 ) {
Builder builder = new Builder ( WindowInsetsCompat . toWindowInsetsCompat ( this . mPlatformInsets ) ) ;
builder . setSystemWindowInsets ( WindowInsetsCompat . insetInsets ( getSystemWindowInsets ( ) , i , i2 , i3 , i4 ) ) ;
builder . setStableInsets ( WindowInsetsCompat . insetInsets ( getStableInsets ( ) , i , i2 , i3 , i4 ) ) ;
return builder . build ( ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
public boolean isRound ( ) {
return this . mPlatformInsets . isRound ( ) ;
}
2021-09-29 00:45:08 +00:00
public boolean isTypeVisible ( int i ) {
if ( ! ( i = = 1 | | i = = 2 ) ) {
if ( i = = 4 ) {
return false ;
}
if ( ! ( i = = 8 | | i = = 128 ) ) {
return true ;
}
}
return ! getInsetsForType ( i , false ) . equals ( Insets . NONE ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@SuppressLint ( { " WrongConstant " } )
public boolean isVisible ( int i ) {
for ( int i2 = 1 ; i2 < = 256 ; i2 < < = 1 ) {
if ( ( i & i2 ) ! = 0 & & ! isTypeVisible ( i2 ) ) {
return false ;
}
}
return true ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
public void setOverriddenInsets ( Insets [ ] insetsArr ) {
this . mOverriddenInsets = insetsArr ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
public void setRootViewData ( @NonNull Insets insets ) {
this . mRootViewVisibleInsets = insets ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
public void setRootWindowInsets ( @Nullable WindowInsetsCompat windowInsetsCompat ) {
this . mRootWindowInsets = windowInsetsCompat ;
}
2021-06-27 20:44:35 +00:00
}
@RequiresApi ( 21 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public static class Impl21 extends Impl20 {
2022-03-02 20:59:20 +00:00
private Insets mStableInsets ;
2021-06-27 20:44:35 +00:00
public Impl21 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull WindowInsets windowInsets ) {
super ( windowInsetsCompat , windowInsets ) ;
2022-03-02 20:59:20 +00:00
this . mStableInsets = null ;
2021-06-27 20:44:35 +00:00
}
public Impl21 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull Impl21 impl21 ) {
super ( windowInsetsCompat , impl21 ) ;
2022-03-02 20:59:20 +00:00
this . mStableInsets = null ;
2021-09-29 00:45:08 +00:00
this . mStableInsets = impl21 . mStableInsets ;
2021-06-27 20:44:35 +00:00
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public WindowInsetsCompat consumeStableInsets ( ) {
return WindowInsetsCompat . toWindowInsetsCompat ( this . mPlatformInsets . consumeStableInsets ( ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public WindowInsetsCompat consumeSystemWindowInsets ( ) {
return WindowInsetsCompat . toWindowInsetsCompat ( this . mPlatformInsets . consumeSystemWindowInsets ( ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public final Insets getStableInsets ( ) {
if ( this . mStableInsets = = null ) {
this . mStableInsets = Insets . of ( this . mPlatformInsets . getStableInsetLeft ( ) , this . mPlatformInsets . getStableInsetTop ( ) , this . mPlatformInsets . getStableInsetRight ( ) , this . mPlatformInsets . getStableInsetBottom ( ) ) ;
}
return this . mStableInsets ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
public boolean isConsumed ( ) {
return this . mPlatformInsets . isConsumed ( ) ;
}
2021-09-29 00:45:08 +00:00
@Override // androidx.core.view.WindowInsetsCompat.Impl
public void setStableInsets ( @Nullable Insets insets ) {
this . mStableInsets = insets ;
}
2021-06-27 20:44:35 +00:00
}
@RequiresApi ( 28 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public static class Impl28 extends Impl21 {
public Impl28 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull WindowInsets windowInsets ) {
super ( windowInsetsCompat , windowInsets ) ;
}
public Impl28 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull Impl28 impl28 ) {
super ( windowInsetsCompat , impl28 ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public WindowInsetsCompat consumeDisplayCutout ( ) {
return WindowInsetsCompat . toWindowInsetsCompat ( this . mPlatformInsets . consumeDisplayCutout ( ) ) ;
}
2021-09-29 00:45:08 +00:00
@Override // androidx.core.view.WindowInsetsCompat.Impl20, androidx.core.view.WindowInsetsCompat.Impl
2021-06-27 20:44:35 +00:00
public boolean equals ( Object obj ) {
if ( this = = obj ) {
return true ;
}
if ( ! ( obj instanceof Impl28 ) ) {
return false ;
}
2021-09-29 00:45:08 +00:00
Impl28 impl28 = ( Impl28 ) obj ;
return Objects . equals ( this . mPlatformInsets , impl28 . mPlatformInsets ) & & Objects . equals ( this . mRootViewVisibleInsets , impl28 . mRootViewVisibleInsets ) ;
2021-06-27 20:44:35 +00:00
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@Nullable
public DisplayCutoutCompat getDisplayCutout ( ) {
return DisplayCutoutCompat . wrap ( this . mPlatformInsets . getDisplayCutout ( ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
public int hashCode ( ) {
return this . mPlatformInsets . hashCode ( ) ;
}
}
@RequiresApi ( 29 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-06-27 20:44:35 +00:00
public static class Impl29 extends Impl28 {
private Insets mSystemGestureInsets = null ;
2022-03-02 20:59:20 +00:00
private Insets mMandatorySystemGestureInsets = null ;
2021-06-27 20:44:35 +00:00
private Insets mTappableElementInsets = null ;
public Impl29 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull WindowInsets windowInsets ) {
super ( windowInsetsCompat , windowInsets ) ;
}
public Impl29 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull Impl29 impl29 ) {
super ( windowInsetsCompat , impl29 ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public Insets getMandatorySystemGestureInsets ( ) {
if ( this . mMandatorySystemGestureInsets = = null ) {
this . mMandatorySystemGestureInsets = Insets . toCompatInsets ( this . mPlatformInsets . getMandatorySystemGestureInsets ( ) ) ;
}
return this . mMandatorySystemGestureInsets ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public Insets getSystemGestureInsets ( ) {
if ( this . mSystemGestureInsets = = null ) {
this . mSystemGestureInsets = Insets . toCompatInsets ( this . mPlatformInsets . getSystemGestureInsets ( ) ) ;
}
return this . mSystemGestureInsets ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public Insets getTappableElementInsets ( ) {
if ( this . mTappableElementInsets = = null ) {
this . mTappableElementInsets = Insets . toCompatInsets ( this . mPlatformInsets . getTappableElementInsets ( ) ) ;
}
return this . mTappableElementInsets ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl20, androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public WindowInsetsCompat inset ( int i , int i2 , int i3 , int i4 ) {
return WindowInsetsCompat . toWindowInsetsCompat ( this . mPlatformInsets . inset ( i , i2 , i3 , i4 ) ) ;
}
2021-09-29 00:45:08 +00:00
@Override // androidx.core.view.WindowInsetsCompat.Impl21, androidx.core.view.WindowInsetsCompat.Impl
public void setStableInsets ( @Nullable Insets insets ) {
}
}
@RequiresApi ( 30 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-09-29 00:45:08 +00:00
public static class Impl30 extends Impl29 {
@NonNull
public static final WindowInsetsCompat CONSUMED = WindowInsetsCompat . toWindowInsetsCompat ( WindowInsets . CONSUMED ) ;
public Impl30 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull WindowInsets windowInsets ) {
super ( windowInsetsCompat , windowInsets ) ;
}
public Impl30 ( @NonNull WindowInsetsCompat windowInsetsCompat , @NonNull Impl30 impl30 ) {
super ( windowInsetsCompat , impl30 ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl20, androidx.core.view.WindowInsetsCompat.Impl
public final void copyRootViewBounds ( @NonNull View view ) {
}
@Override // androidx.core.view.WindowInsetsCompat.Impl20, androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public Insets getInsets ( int i ) {
return Insets . toCompatInsets ( this . mPlatformInsets . getInsets ( TypeImpl30 . toPlatformType ( i ) ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl20, androidx.core.view.WindowInsetsCompat.Impl
@NonNull
public Insets getInsetsIgnoringVisibility ( int i ) {
return Insets . toCompatInsets ( this . mPlatformInsets . getInsetsIgnoringVisibility ( TypeImpl30 . toPlatformType ( i ) ) ) ;
}
@Override // androidx.core.view.WindowInsetsCompat.Impl20, androidx.core.view.WindowInsetsCompat.Impl
public boolean isVisible ( int i ) {
return this . mPlatformInsets . isVisible ( TypeImpl30 . toPlatformType ( i ) ) ;
}
}
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-09-29 00:45:08 +00:00
public static final class Type {
public static final int CAPTION_BAR = 4 ;
public static final int DISPLAY_CUTOUT = 128 ;
public static final int FIRST = 1 ;
public static final int IME = 8 ;
public static final int LAST = 256 ;
public static final int MANDATORY_SYSTEM_GESTURES = 32 ;
public static final int NAVIGATION_BARS = 2 ;
public static final int SIZE = 9 ;
public static final int STATUS_BARS = 1 ;
public static final int SYSTEM_GESTURES = 16 ;
public static final int TAPPABLE_ELEMENT = 64 ;
public static final int WINDOW_DECOR = 256 ;
@Retention ( RetentionPolicy . SOURCE )
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP } )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-09-29 00:45:08 +00:00
public @interface InsetsType {
}
private Type ( ) {
}
@SuppressLint ( { " WrongConstant " } )
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP } )
public static int all ( ) {
return - 1 ;
}
public static int captionBar ( ) {
return 4 ;
}
public static int displayCutout ( ) {
return 128 ;
}
public static int ime ( ) {
return 8 ;
}
public static int indexOf ( int i ) {
if ( i = = 1 ) {
return 0 ;
}
if ( i = = 2 ) {
return 1 ;
}
if ( i = = 4 ) {
return 2 ;
}
if ( i = = 8 ) {
return 3 ;
}
if ( i = = 16 ) {
return 4 ;
}
if ( i = = 32 ) {
return 5 ;
}
if ( i = = 64 ) {
return 6 ;
}
if ( i = = 128 ) {
return 7 ;
}
if ( i = = 256 ) {
return 8 ;
}
2021-11-08 18:25:28 +00:00
throw new IllegalArgumentException ( a . p ( " type needs to be >= FIRST and <= LAST, type= " , i ) ) ;
2021-09-29 00:45:08 +00:00
}
public static int mandatorySystemGestures ( ) {
return 32 ;
}
public static int navigationBars ( ) {
return 2 ;
}
public static int statusBars ( ) {
return 1 ;
}
public static int systemBars ( ) {
return 7 ;
}
public static int systemGestures ( ) {
return 16 ;
}
public static int tappableElement ( ) {
return 64 ;
}
}
@RequiresApi ( 30 )
2022-03-02 20:59:20 +00:00
/* loaded from: classes.dex */
2021-09-29 00:45:08 +00:00
public static final class TypeImpl30 {
private TypeImpl30 ( ) {
}
public static int toPlatformType ( int i ) {
int i2 ;
int i3 = 0 ;
for ( int i4 = 1 ; i4 < = 256 ; i4 < < = 1 ) {
if ( ( i & i4 ) ! = 0 ) {
if ( i4 = = 1 ) {
i2 = WindowInsets . Type . statusBars ( ) ;
} else if ( i4 = = 2 ) {
i2 = WindowInsets . Type . navigationBars ( ) ;
} else if ( i4 = = 4 ) {
i2 = WindowInsets . Type . captionBar ( ) ;
} else if ( i4 = = 8 ) {
i2 = WindowInsets . Type . ime ( ) ;
} else if ( i4 = = 16 ) {
i2 = WindowInsets . Type . systemGestures ( ) ;
} else if ( i4 = = 32 ) {
i2 = WindowInsets . Type . mandatorySystemGestures ( ) ;
} else if ( i4 = = 64 ) {
i2 = WindowInsets . Type . tappableElement ( ) ;
} else if ( i4 = = 128 ) {
i2 = WindowInsets . Type . displayCutout ( ) ;
}
i3 | = i2 ;
}
}
return i3 ;
}
}
static {
if ( Build . VERSION . SDK_INT > = 30 ) {
CONSUMED = Impl30 . CONSUMED ;
} else {
CONSUMED = Impl . CONSUMED ;
}
2021-06-27 20:44:35 +00:00
}
@RequiresApi ( 20 )
private WindowInsetsCompat ( @NonNull WindowInsets windowInsets ) {
int i = Build . VERSION . SDK_INT ;
2021-09-29 00:45:08 +00:00
if ( i > = 30 ) {
this . mImpl = new Impl30 ( this , windowInsets ) ;
} else if ( i > = 29 ) {
2021-06-27 20:44:35 +00:00
this . mImpl = new Impl29 ( this , windowInsets ) ;
} else if ( i > = 28 ) {
this . mImpl = new Impl28 ( this , windowInsets ) ;
} else {
this . mImpl = new Impl21 ( this , windowInsets ) ;
}
}
public WindowInsetsCompat ( @Nullable WindowInsetsCompat windowInsetsCompat ) {
if ( windowInsetsCompat ! = null ) {
Impl impl = windowInsetsCompat . mImpl ;
int i = Build . VERSION . SDK_INT ;
2021-09-29 00:45:08 +00:00
if ( i > = 30 & & ( impl instanceof Impl30 ) ) {
this . mImpl = new Impl30 ( this , ( Impl30 ) impl ) ;
} else if ( i > = 29 & & ( impl instanceof Impl29 ) ) {
2021-06-27 20:44:35 +00:00
this . mImpl = new Impl29 ( this , ( Impl29 ) impl ) ;
} else if ( i > = 28 & & ( impl instanceof Impl28 ) ) {
this . mImpl = new Impl28 ( this , ( Impl28 ) impl ) ;
} else if ( impl instanceof Impl21 ) {
this . mImpl = new Impl21 ( this , ( Impl21 ) impl ) ;
} else if ( impl instanceof Impl20 ) {
this . mImpl = new Impl20 ( this , ( Impl20 ) impl ) ;
} else {
this . mImpl = new Impl ( this ) ;
}
2021-09-29 00:45:08 +00:00
impl . copyWindowDataInto ( this ) ;
return ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
this . mImpl = new Impl ( this ) ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
public static Insets insetInsets ( @NonNull Insets insets , int i , int i2 , int i3 , int i4 ) {
2021-06-27 20:44:35 +00:00
int max = Math . max ( 0 , insets . left - i ) ;
int max2 = Math . max ( 0 , insets . top - i2 ) ;
int max3 = Math . max ( 0 , insets . right - i3 ) ;
int max4 = Math . max ( 0 , insets . bottom - i4 ) ;
return ( max = = i & & max2 = = i2 & & max3 = = i3 & & max4 = = i4 ) ? insets : Insets . of ( max , max2 , max3 , max4 ) ;
}
@NonNull
@RequiresApi ( 20 )
public static WindowInsetsCompat toWindowInsetsCompat ( @NonNull WindowInsets windowInsets ) {
2021-09-29 00:45:08 +00:00
return toWindowInsetsCompat ( windowInsets , null ) ;
}
@NonNull
@RequiresApi ( 20 )
public static WindowInsetsCompat toWindowInsetsCompat ( @NonNull WindowInsets windowInsets , @Nullable View view ) {
WindowInsetsCompat windowInsetsCompat = new WindowInsetsCompat ( ( WindowInsets ) Preconditions . checkNotNull ( windowInsets ) ) ;
if ( view ! = null & & view . isAttachedToWindow ( ) ) {
windowInsetsCompat . setRootWindowInsets ( ViewCompat . getRootWindowInsets ( view ) ) ;
windowInsetsCompat . copyRootViewBounds ( view . getRootView ( ) ) ;
}
return windowInsetsCompat ;
2021-06-27 20:44:35 +00:00
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public WindowInsetsCompat consumeDisplayCutout ( ) {
return this . mImpl . consumeDisplayCutout ( ) ;
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public WindowInsetsCompat consumeStableInsets ( ) {
return this . mImpl . consumeStableInsets ( ) ;
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public WindowInsetsCompat consumeSystemWindowInsets ( ) {
return this . mImpl . consumeSystemWindowInsets ( ) ;
}
2021-09-29 00:45:08 +00:00
public void copyRootViewBounds ( @NonNull View view ) {
this . mImpl . copyRootViewBounds ( view ) ;
}
2021-06-27 20:44:35 +00:00
public boolean equals ( Object obj ) {
if ( this = = obj ) {
return true ;
}
if ( ! ( obj instanceof WindowInsetsCompat ) ) {
return false ;
}
return ObjectsCompat . equals ( this . mImpl , ( ( WindowInsetsCompat ) obj ) . mImpl ) ;
}
@Nullable
public DisplayCutoutCompat getDisplayCutout ( ) {
return this . mImpl . getDisplayCutout ( ) ;
}
@NonNull
2021-09-29 00:45:08 +00:00
public Insets getInsets ( int i ) {
return this . mImpl . getInsets ( i ) ;
}
@NonNull
public Insets getInsetsIgnoringVisibility ( int i ) {
return this . mImpl . getInsetsIgnoringVisibility ( i ) ;
}
@NonNull
@Deprecated
2021-06-27 20:44:35 +00:00
public Insets getMandatorySystemGestureInsets ( ) {
return this . mImpl . getMandatorySystemGestureInsets ( ) ;
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public int getStableInsetBottom ( ) {
2021-09-29 00:45:08 +00:00
return this . mImpl . getStableInsets ( ) . bottom ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public int getStableInsetLeft ( ) {
2021-09-29 00:45:08 +00:00
return this . mImpl . getStableInsets ( ) . left ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public int getStableInsetRight ( ) {
2021-09-29 00:45:08 +00:00
return this . mImpl . getStableInsets ( ) . right ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public int getStableInsetTop ( ) {
2021-09-29 00:45:08 +00:00
return this . mImpl . getStableInsets ( ) . top ;
2021-06-27 20:44:35 +00:00
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public Insets getStableInsets ( ) {
return this . mImpl . getStableInsets ( ) ;
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public Insets getSystemGestureInsets ( ) {
return this . mImpl . getSystemGestureInsets ( ) ;
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public int getSystemWindowInsetBottom ( ) {
2021-09-29 00:45:08 +00:00
return this . mImpl . getSystemWindowInsets ( ) . bottom ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public int getSystemWindowInsetLeft ( ) {
2021-09-29 00:45:08 +00:00
return this . mImpl . getSystemWindowInsets ( ) . left ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public int getSystemWindowInsetRight ( ) {
2021-09-29 00:45:08 +00:00
return this . mImpl . getSystemWindowInsets ( ) . right ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public int getSystemWindowInsetTop ( ) {
2021-09-29 00:45:08 +00:00
return this . mImpl . getSystemWindowInsets ( ) . top ;
2021-06-27 20:44:35 +00:00
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public Insets getSystemWindowInsets ( ) {
return this . mImpl . getSystemWindowInsets ( ) ;
}
@NonNull
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public Insets getTappableElementInsets ( ) {
return this . mImpl . getTappableElementInsets ( ) ;
}
public boolean hasInsets ( ) {
2021-09-29 00:45:08 +00:00
Insets insets = getInsets ( Type . all ( ) ) ;
Insets insets2 = Insets . NONE ;
return ! insets . equals ( insets2 ) | | ! getInsetsIgnoringVisibility ( Type . all ( ) ^ Type . ime ( ) ) . equals ( insets2 ) | | getDisplayCutout ( ) ! = null ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public boolean hasStableInsets ( ) {
2021-09-29 00:45:08 +00:00
return ! this . mImpl . getStableInsets ( ) . equals ( Insets . NONE ) ;
2021-06-27 20:44:35 +00:00
}
2021-09-29 00:45:08 +00:00
@Deprecated
2021-06-27 20:44:35 +00:00
public boolean hasSystemWindowInsets ( ) {
2021-09-29 00:45:08 +00:00
return ! this . mImpl . getSystemWindowInsets ( ) . equals ( Insets . NONE ) ;
2021-06-27 20:44:35 +00:00
}
public int hashCode ( ) {
Impl impl = this . mImpl ;
if ( impl = = null ) {
return 0 ;
}
return impl . hashCode ( ) ;
}
@NonNull
public WindowInsetsCompat inset ( @IntRange ( from = 0 ) int i , @IntRange ( from = 0 ) int i2 , @IntRange ( from = 0 ) int i3 , @IntRange ( from = 0 ) int i4 ) {
return this . mImpl . inset ( i , i2 , i3 , i4 ) ;
}
@NonNull
public WindowInsetsCompat inset ( @NonNull Insets insets ) {
return inset ( insets . left , insets . top , insets . right , insets . bottom ) ;
}
public boolean isConsumed ( ) {
return this . mImpl . isConsumed ( ) ;
}
public boolean isRound ( ) {
return this . mImpl . isRound ( ) ;
}
2021-09-29 00:45:08 +00:00
public boolean isVisible ( int i ) {
return this . mImpl . isVisible ( i ) ;
}
2021-06-27 20:44:35 +00:00
@NonNull
@Deprecated
public WindowInsetsCompat replaceSystemWindowInsets ( int i , int i2 , int i3 , int i4 ) {
return new Builder ( this ) . setSystemWindowInsets ( Insets . of ( i , i2 , i3 , i4 ) ) . build ( ) ;
}
@NonNull
@Deprecated
public WindowInsetsCompat replaceSystemWindowInsets ( @NonNull Rect rect ) {
return new Builder ( this ) . setSystemWindowInsets ( Insets . of ( rect ) ) . build ( ) ;
}
2021-09-29 00:45:08 +00:00
public void setOverriddenInsets ( Insets [ ] insetsArr ) {
this . mImpl . setOverriddenInsets ( insetsArr ) ;
}
public void setRootViewData ( @NonNull Insets insets ) {
this . mImpl . setRootViewData ( insets ) ;
}
public void setRootWindowInsets ( @Nullable WindowInsetsCompat windowInsetsCompat ) {
this . mImpl . setRootWindowInsets ( windowInsetsCompat ) ;
}
public void setStableInsets ( @Nullable Insets insets ) {
this . mImpl . setStableInsets ( insets ) ;
}
2021-06-27 20:44:35 +00:00
@Nullable
@RequiresApi ( 20 )
public WindowInsets toWindowInsets ( ) {
Impl impl = this . mImpl ;
if ( impl instanceof Impl20 ) {
return ( ( Impl20 ) impl ) . mPlatformInsets ;
}
return null ;
}
}