Rabbit-R1/android (non root)/java/sources/androidx/drawerlayout/widget/DrawerLayout.java

1806 lines
72 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package androidx.drawerlayout.widget;
import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.GravityCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.accessibility.AccessibilityViewCommand;
import androidx.customview.view.AbsSavedState;
import androidx.customview.widget.Openable;
import androidx.customview.widget.ViewDragHelper;
import io.flutter.plugin.platform.PlatformPlugin;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
public class DrawerLayout extends ViewGroup implements Openable {
private static final String ACCESSIBILITY_CLASS_NAME = "androidx.drawerlayout.widget.DrawerLayout";
private static final boolean ALLOW_EDGE_LOCK = false;
private static final boolean CHILDREN_DISALLOW_INTERCEPT = true;
private static final int DEFAULT_SCRIM_COLOR = -1728053248;
public static final int LOCK_MODE_LOCKED_CLOSED = 1;
public static final int LOCK_MODE_LOCKED_OPEN = 2;
public static final int LOCK_MODE_UNDEFINED = 3;
public static final int LOCK_MODE_UNLOCKED = 0;
private static final int MIN_DRAWER_MARGIN = 64;
private static final int MIN_FLING_VELOCITY = 400;
private static final int PEEK_DELAY = 160;
public static final int STATE_DRAGGING = 1;
public static final int STATE_IDLE = 0;
public static final int STATE_SETTLING = 2;
private static final String TAG = "DrawerLayout";
private static final float TOUCH_SLOP_SENSITIVITY = 1.0f;
private final AccessibilityViewCommand mActionDismiss;
private final ChildAccessibilityDelegate mChildAccessibilityDelegate;
private Rect mChildHitRect;
private Matrix mChildInvertedMatrix;
private boolean mChildrenCanceledTouch;
private boolean mDrawStatusBarBackground;
private float mDrawerElevation;
private int mDrawerState;
private boolean mFirstLayout;
private boolean mInLayout;
private float mInitialMotionX;
private float mInitialMotionY;
private Object mLastInsets;
private final ViewDragCallback mLeftCallback;
private final ViewDragHelper mLeftDragger;
private DrawerListener mListener;
private List<DrawerListener> mListeners;
private int mLockModeEnd;
private int mLockModeLeft;
private int mLockModeRight;
private int mLockModeStart;
private int mMinDrawerMargin;
private final ArrayList<View> mNonDrawerViews;
private final ViewDragCallback mRightCallback;
private final ViewDragHelper mRightDragger;
private int mScrimColor;
private float mScrimOpacity;
private Paint mScrimPaint;
private Drawable mShadowEnd;
private Drawable mShadowLeft;
private Drawable mShadowLeftResolved;
private Drawable mShadowRight;
private Drawable mShadowRightResolved;
private Drawable mShadowStart;
private Drawable mStatusBarBackground;
private CharSequence mTitleLeft;
private CharSequence mTitleRight;
private static final int[] THEME_ATTRS = {R.attr.colorPrimaryDark};
static final int[] LAYOUT_ATTRS = {R.attr.layout_gravity};
static final boolean CAN_HIDE_DESCENDANTS = true;
private static final boolean SET_DRAWER_SHADOW_FROM_ELEVATION = true;
private static boolean sEdgeSizeUsingSystemGestureInsets = true;
/* loaded from: classes.dex */
public interface DrawerListener {
void onDrawerClosed(View view);
void onDrawerOpened(View view);
void onDrawerSlide(View view, float f);
void onDrawerStateChanged(int i);
}
/* loaded from: classes.dex */
public static abstract class SimpleDrawerListener implements DrawerListener {
@Override // androidx.drawerlayout.widget.DrawerLayout.DrawerListener
public void onDrawerClosed(View view) {
}
@Override // androidx.drawerlayout.widget.DrawerLayout.DrawerListener
public void onDrawerOpened(View view) {
}
@Override // androidx.drawerlayout.widget.DrawerLayout.DrawerListener
public void onDrawerSlide(View view, float f) {
}
@Override // androidx.drawerlayout.widget.DrawerLayout.DrawerListener
public void onDrawerStateChanged(int i) {
}
}
public float getDrawerElevation() {
if (SET_DRAWER_SHADOW_FROM_ELEVATION) {
return this.mDrawerElevation;
}
return 0.0f;
}
public Drawable getStatusBarBackgroundDrawable() {
return this.mStatusBarBackground;
}
public DrawerLayout(Context context) {
this(context, null);
}
public DrawerLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, androidx.drawerlayout.R.attr.drawerLayoutStyle);
}
public DrawerLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.mChildAccessibilityDelegate = new ChildAccessibilityDelegate();
this.mScrimColor = DEFAULT_SCRIM_COLOR;
this.mScrimPaint = new Paint();
this.mFirstLayout = true;
this.mLockModeLeft = 3;
this.mLockModeRight = 3;
this.mLockModeStart = 3;
this.mLockModeEnd = 3;
this.mShadowStart = null;
this.mShadowEnd = null;
this.mShadowLeft = null;
this.mShadowRight = null;
this.mActionDismiss = new AccessibilityViewCommand() { // from class: androidx.drawerlayout.widget.DrawerLayout.1
@Override // androidx.core.view.accessibility.AccessibilityViewCommand
public boolean perform(View view, AccessibilityViewCommand.CommandArguments commandArguments) {
if (!DrawerLayout.this.isDrawerOpen(view) || DrawerLayout.this.getDrawerLockMode(view) == 2) {
return false;
}
DrawerLayout.this.closeDrawer(view);
return true;
}
};
setDescendantFocusability(262144);
float f = getResources().getDisplayMetrics().density;
this.mMinDrawerMargin = (int) ((64.0f * f) + 0.5f);
float f2 = f * 400.0f;
ViewDragCallback viewDragCallback = new ViewDragCallback(3);
this.mLeftCallback = viewDragCallback;
ViewDragCallback viewDragCallback2 = new ViewDragCallback(5);
this.mRightCallback = viewDragCallback2;
ViewDragHelper create = ViewDragHelper.create(this, 1.0f, viewDragCallback);
this.mLeftDragger = create;
create.setEdgeTrackingEnabled(1);
create.setMinVelocity(f2);
viewDragCallback.setDragger(create);
ViewDragHelper create2 = ViewDragHelper.create(this, 1.0f, viewDragCallback2);
this.mRightDragger = create2;
create2.setEdgeTrackingEnabled(2);
create2.setMinVelocity(f2);
viewDragCallback2.setDragger(create2);
setFocusableInTouchMode(true);
ViewCompat.setImportantForAccessibility(this, 1);
ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
setMotionEventSplittingEnabled(false);
if (ViewCompat.getFitsSystemWindows(this)) {
setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { // from class: androidx.drawerlayout.widget.DrawerLayout.2
@Override // android.view.View.OnApplyWindowInsetsListener
public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
((DrawerLayout) view).setChildInsets(windowInsets, windowInsets.getSystemWindowInsetTop() > 0);
return windowInsets.consumeSystemWindowInsets();
}
});
setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(THEME_ATTRS);
try {
this.mStatusBarBackground = obtainStyledAttributes.getDrawable(0);
} finally {
obtainStyledAttributes.recycle();
}
}
TypedArray obtainStyledAttributes2 = context.obtainStyledAttributes(attributeSet, androidx.drawerlayout.R.styleable.DrawerLayout, i, 0);
try {
if (obtainStyledAttributes2.hasValue(androidx.drawerlayout.R.styleable.DrawerLayout_elevation)) {
this.mDrawerElevation = obtainStyledAttributes2.getDimension(androidx.drawerlayout.R.styleable.DrawerLayout_elevation, 0.0f);
} else {
this.mDrawerElevation = getResources().getDimension(androidx.drawerlayout.R.dimen.def_drawer_elevation);
}
obtainStyledAttributes2.recycle();
this.mNonDrawerViews = new ArrayList<>();
} catch (Throwable th) {
obtainStyledAttributes2.recycle();
throw th;
}
}
public void setDrawerElevation(float f) {
this.mDrawerElevation = f;
for (int i = 0; i < getChildCount(); i++) {
View childAt = getChildAt(i);
if (isDrawerView(childAt)) {
ViewCompat.setElevation(childAt, this.mDrawerElevation);
}
}
}
public void setChildInsets(Object obj, boolean z) {
this.mLastInsets = obj;
this.mDrawStatusBarBackground = z;
setWillNotDraw(!z && getBackground() == null);
requestLayout();
}
public void setDrawerShadow(Drawable drawable, int i) {
if (SET_DRAWER_SHADOW_FROM_ELEVATION) {
return;
}
if ((i & GravityCompat.START) == 8388611) {
this.mShadowStart = drawable;
} else if ((i & GravityCompat.END) == 8388613) {
this.mShadowEnd = drawable;
} else if ((i & 3) == 3) {
this.mShadowLeft = drawable;
} else if ((i & 5) != 5) {
return;
} else {
this.mShadowRight = drawable;
}
resolveShadowDrawables();
invalidate();
}
public void setDrawerShadow(int i, int i2) {
setDrawerShadow(ContextCompat.getDrawable(getContext(), i), i2);
}
public void setScrimColor(int i) {
this.mScrimColor = i;
invalidate();
}
@Deprecated
public void setDrawerListener(DrawerListener drawerListener) {
DrawerListener drawerListener2 = this.mListener;
if (drawerListener2 != null) {
removeDrawerListener(drawerListener2);
}
if (drawerListener != null) {
addDrawerListener(drawerListener);
}
this.mListener = drawerListener;
}
public void addDrawerListener(DrawerListener drawerListener) {
if (drawerListener == null) {
return;
}
if (this.mListeners == null) {
this.mListeners = new ArrayList();
}
this.mListeners.add(drawerListener);
}
public void removeDrawerListener(DrawerListener drawerListener) {
List<DrawerListener> list;
if (drawerListener == null || (list = this.mListeners) == null) {
return;
}
list.remove(drawerListener);
}
public void setDrawerLockMode(int i) {
setDrawerLockMode(i, 3);
setDrawerLockMode(i, 5);
}
public void setDrawerLockMode(int i, int i2) {
View findDrawerWithGravity;
int absoluteGravity = GravityCompat.getAbsoluteGravity(i2, ViewCompat.getLayoutDirection(this));
if (i2 == 3) {
this.mLockModeLeft = i;
} else if (i2 == 5) {
this.mLockModeRight = i;
} else if (i2 == 8388611) {
this.mLockModeStart = i;
} else if (i2 == 8388613) {
this.mLockModeEnd = i;
}
if (i != 0) {
(absoluteGravity == 3 ? this.mLeftDragger : this.mRightDragger).cancel();
}
if (i != 1) {
if (i == 2 && (findDrawerWithGravity = findDrawerWithGravity(absoluteGravity)) != null) {
openDrawer(findDrawerWithGravity);
return;
}
return;
}
View findDrawerWithGravity2 = findDrawerWithGravity(absoluteGravity);
if (findDrawerWithGravity2 != null) {
closeDrawer(findDrawerWithGravity2);
}
}
public void setDrawerLockMode(int i, View view) {
if (!isDrawerView(view)) {
throw new IllegalArgumentException("View " + view + " is not a drawer with appropriate layout_gravity");
}
setDrawerLockMode(i, ((LayoutParams) view.getLayoutParams()).gravity);
}
public int getDrawerLockMode(int i) {
int layoutDirection = ViewCompat.getLayoutDirection(this);
if (i == 3) {
int i2 = this.mLockModeLeft;
if (i2 != 3) {
return i2;
}
int i3 = layoutDirection == 0 ? this.mLockModeStart : this.mLockModeEnd;
if (i3 != 3) {
return i3;
}
return 0;
}
if (i == 5) {
int i4 = this.mLockModeRight;
if (i4 != 3) {
return i4;
}
int i5 = layoutDirection == 0 ? this.mLockModeEnd : this.mLockModeStart;
if (i5 != 3) {
return i5;
}
return 0;
}
if (i == 8388611) {
int i6 = this.mLockModeStart;
if (i6 != 3) {
return i6;
}
int i7 = layoutDirection == 0 ? this.mLockModeLeft : this.mLockModeRight;
if (i7 != 3) {
return i7;
}
return 0;
}
if (i != 8388613) {
return 0;
}
int i8 = this.mLockModeEnd;
if (i8 != 3) {
return i8;
}
int i9 = layoutDirection == 0 ? this.mLockModeRight : this.mLockModeLeft;
if (i9 != 3) {
return i9;
}
return 0;
}
public int getDrawerLockMode(View view) {
if (!isDrawerView(view)) {
throw new IllegalArgumentException("View " + view + " is not a drawer");
}
return getDrawerLockMode(((LayoutParams) view.getLayoutParams()).gravity);
}
public void setDrawerTitle(int i, CharSequence charSequence) {
int absoluteGravity = GravityCompat.getAbsoluteGravity(i, ViewCompat.getLayoutDirection(this));
if (absoluteGravity == 3) {
this.mTitleLeft = charSequence;
} else if (absoluteGravity == 5) {
this.mTitleRight = charSequence;
}
}
public CharSequence getDrawerTitle(int i) {
int absoluteGravity = GravityCompat.getAbsoluteGravity(i, ViewCompat.getLayoutDirection(this));
if (absoluteGravity == 3) {
return this.mTitleLeft;
}
if (absoluteGravity == 5) {
return this.mTitleRight;
}
return null;
}
private boolean isInBoundsOfChild(float f, float f2, View view) {
if (this.mChildHitRect == null) {
this.mChildHitRect = new Rect();
}
view.getHitRect(this.mChildHitRect);
return this.mChildHitRect.contains((int) f, (int) f2);
}
private boolean dispatchTransformedGenericPointerEvent(MotionEvent motionEvent, View view) {
if (!view.getMatrix().isIdentity()) {
MotionEvent transformedMotionEvent = getTransformedMotionEvent(motionEvent, view);
boolean dispatchGenericMotionEvent = view.dispatchGenericMotionEvent(transformedMotionEvent);
transformedMotionEvent.recycle();
return dispatchGenericMotionEvent;
}
float scrollX = getScrollX() - view.getLeft();
float scrollY = getScrollY() - view.getTop();
motionEvent.offsetLocation(scrollX, scrollY);
boolean dispatchGenericMotionEvent2 = view.dispatchGenericMotionEvent(motionEvent);
motionEvent.offsetLocation(-scrollX, -scrollY);
return dispatchGenericMotionEvent2;
}
private MotionEvent getTransformedMotionEvent(MotionEvent motionEvent, View view) {
float scrollX = getScrollX() - view.getLeft();
float scrollY = getScrollY() - view.getTop();
MotionEvent obtain = MotionEvent.obtain(motionEvent);
obtain.offsetLocation(scrollX, scrollY);
Matrix matrix = view.getMatrix();
if (!matrix.isIdentity()) {
if (this.mChildInvertedMatrix == null) {
this.mChildInvertedMatrix = new Matrix();
}
matrix.invert(this.mChildInvertedMatrix);
obtain.transform(this.mChildInvertedMatrix);
}
return obtain;
}
void updateDrawerState(int i, View view) {
int i2;
int viewDragState = this.mLeftDragger.getViewDragState();
int viewDragState2 = this.mRightDragger.getViewDragState();
if (viewDragState == 1 || viewDragState2 == 1) {
i2 = 1;
} else {
i2 = 2;
if (viewDragState != 2 && viewDragState2 != 2) {
i2 = 0;
}
}
if (view != null && i == 0) {
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
if (layoutParams.onScreen == 0.0f) {
dispatchOnDrawerClosed(view);
} else if (layoutParams.onScreen == 1.0f) {
dispatchOnDrawerOpened(view);
}
}
if (i2 != this.mDrawerState) {
this.mDrawerState = i2;
List<DrawerListener> list = this.mListeners;
if (list != null) {
for (int size = list.size() - 1; size >= 0; size--) {
this.mListeners.get(size).onDrawerStateChanged(i2);
}
}
}
}
void dispatchOnDrawerClosed(View view) {
View rootView;
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
if ((layoutParams.openState & 1) == 1) {
layoutParams.openState = 0;
List<DrawerListener> list = this.mListeners;
if (list != null) {
for (int size = list.size() - 1; size >= 0; size--) {
this.mListeners.get(size).onDrawerClosed(view);
}
}
updateChildrenImportantForAccessibility(view, false);
updateChildAccessibilityAction(view);
if (!hasWindowFocus() || (rootView = getRootView()) == null) {
return;
}
rootView.sendAccessibilityEvent(32);
}
}
void dispatchOnDrawerOpened(View view) {
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
if ((layoutParams.openState & 1) == 0) {
layoutParams.openState = 1;
List<DrawerListener> list = this.mListeners;
if (list != null) {
for (int size = list.size() - 1; size >= 0; size--) {
this.mListeners.get(size).onDrawerOpened(view);
}
}
updateChildrenImportantForAccessibility(view, true);
updateChildAccessibilityAction(view);
if (hasWindowFocus()) {
sendAccessibilityEvent(32);
}
}
}
private void updateChildrenImportantForAccessibility(View view, boolean z) {
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = getChildAt(i);
if ((!z && !isDrawerView(childAt)) || (z && childAt == view)) {
ViewCompat.setImportantForAccessibility(childAt, 1);
} else {
ViewCompat.setImportantForAccessibility(childAt, 4);
}
}
}
private void updateChildAccessibilityAction(View view) {
ViewCompat.removeAccessibilityAction(view, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_DISMISS.getId());
if (!isDrawerOpen(view) || getDrawerLockMode(view) == 2) {
return;
}
ViewCompat.replaceAccessibilityAction(view, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_DISMISS, null, this.mActionDismiss);
}
void dispatchOnDrawerSlide(View view, float f) {
List<DrawerListener> list = this.mListeners;
if (list != null) {
for (int size = list.size() - 1; size >= 0; size--) {
this.mListeners.get(size).onDrawerSlide(view, f);
}
}
}
void setDrawerViewOffset(View view, float f) {
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
if (f == layoutParams.onScreen) {
return;
}
layoutParams.onScreen = f;
dispatchOnDrawerSlide(view, f);
}
float getDrawerViewOffset(View view) {
return ((LayoutParams) view.getLayoutParams()).onScreen;
}
int getDrawerViewAbsoluteGravity(View view) {
return GravityCompat.getAbsoluteGravity(((LayoutParams) view.getLayoutParams()).gravity, ViewCompat.getLayoutDirection(this));
}
boolean checkDrawerViewAbsoluteGravity(View view, int i) {
return (getDrawerViewAbsoluteGravity(view) & i) == i;
}
View findOpenDrawer() {
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = getChildAt(i);
if ((((LayoutParams) childAt.getLayoutParams()).openState & 1) == 1) {
return childAt;
}
}
return null;
}
void moveDrawerToOffset(View view, float f) {
float drawerViewOffset = getDrawerViewOffset(view);
float width = view.getWidth();
int i = ((int) (width * f)) - ((int) (drawerViewOffset * width));
if (!checkDrawerViewAbsoluteGravity(view, 3)) {
i = -i;
}
view.offsetLeftAndRight(i);
setDrawerViewOffset(view, f);
}
View findDrawerWithGravity(int i) {
int absoluteGravity = GravityCompat.getAbsoluteGravity(i, ViewCompat.getLayoutDirection(this)) & 7;
int childCount = getChildCount();
for (int i2 = 0; i2 < childCount; i2++) {
View childAt = getChildAt(i2);
if ((getDrawerViewAbsoluteGravity(childAt) & 7) == absoluteGravity) {
return childAt;
}
}
return null;
}
static String gravityToString(int i) {
return (i & 3) == 3 ? "LEFT" : (i & 5) == 5 ? "RIGHT" : Integer.toHexString(i);
}
@Override // android.view.ViewGroup, android.view.View
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
this.mFirstLayout = true;
}
@Override // android.view.ViewGroup, android.view.View
protected void onAttachedToWindow() {
super.onAttachedToWindow();
this.mFirstLayout = true;
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
int mode = View.MeasureSpec.getMode(i);
int mode2 = View.MeasureSpec.getMode(i2);
int size = View.MeasureSpec.getSize(i);
int size2 = View.MeasureSpec.getSize(i2);
if (mode != 1073741824 || mode2 != 1073741824) {
if (!isInEditMode()) {
throw new IllegalArgumentException("DrawerLayout must be measured with MeasureSpec.EXACTLY.");
}
if (mode == 0) {
size = 300;
}
if (mode2 == 0) {
size2 = 300;
}
}
setMeasuredDimension(size, size2);
boolean z = this.mLastInsets != null && ViewCompat.getFitsSystemWindows(this);
int layoutDirection = ViewCompat.getLayoutDirection(this);
int childCount = getChildCount();
boolean z2 = false;
boolean z3 = false;
for (int i3 = 0; i3 < childCount; i3++) {
View childAt = getChildAt(i3);
if (childAt.getVisibility() != 8) {
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
if (z) {
int absoluteGravity = GravityCompat.getAbsoluteGravity(layoutParams.gravity, layoutDirection);
if (ViewCompat.getFitsSystemWindows(childAt)) {
WindowInsets windowInsets = (WindowInsets) this.mLastInsets;
if (absoluteGravity == 3) {
windowInsets = windowInsets.replaceSystemWindowInsets(windowInsets.getSystemWindowInsetLeft(), windowInsets.getSystemWindowInsetTop(), 0, windowInsets.getSystemWindowInsetBottom());
} else if (absoluteGravity == 5) {
windowInsets = windowInsets.replaceSystemWindowInsets(0, windowInsets.getSystemWindowInsetTop(), windowInsets.getSystemWindowInsetRight(), windowInsets.getSystemWindowInsetBottom());
}
childAt.dispatchApplyWindowInsets(windowInsets);
} else {
WindowInsets windowInsets2 = (WindowInsets) this.mLastInsets;
if (absoluteGravity == 3) {
windowInsets2 = windowInsets2.replaceSystemWindowInsets(windowInsets2.getSystemWindowInsetLeft(), windowInsets2.getSystemWindowInsetTop(), 0, windowInsets2.getSystemWindowInsetBottom());
} else if (absoluteGravity == 5) {
windowInsets2 = windowInsets2.replaceSystemWindowInsets(0, windowInsets2.getSystemWindowInsetTop(), windowInsets2.getSystemWindowInsetRight(), windowInsets2.getSystemWindowInsetBottom());
}
layoutParams.leftMargin = windowInsets2.getSystemWindowInsetLeft();
layoutParams.topMargin = windowInsets2.getSystemWindowInsetTop();
layoutParams.rightMargin = windowInsets2.getSystemWindowInsetRight();
layoutParams.bottomMargin = windowInsets2.getSystemWindowInsetBottom();
}
}
if (isContentView(childAt)) {
childAt.measure(View.MeasureSpec.makeMeasureSpec((size - layoutParams.leftMargin) - layoutParams.rightMargin, 1073741824), View.MeasureSpec.makeMeasureSpec((size2 - layoutParams.topMargin) - layoutParams.bottomMargin, 1073741824));
} else if (isDrawerView(childAt)) {
if (SET_DRAWER_SHADOW_FROM_ELEVATION) {
float elevation = ViewCompat.getElevation(childAt);
float f = this.mDrawerElevation;
if (elevation != f) {
ViewCompat.setElevation(childAt, f);
}
}
int drawerViewAbsoluteGravity = getDrawerViewAbsoluteGravity(childAt) & 7;
boolean z4 = drawerViewAbsoluteGravity == 3;
if ((z4 && z2) || (!z4 && z3)) {
throw new IllegalStateException("Child drawer has absolute gravity " + gravityToString(drawerViewAbsoluteGravity) + " but this DrawerLayout already has a drawer view along that edge");
}
if (z4) {
z2 = true;
} else {
z3 = true;
}
childAt.measure(getChildMeasureSpec(i, this.mMinDrawerMargin + layoutParams.leftMargin + layoutParams.rightMargin, layoutParams.width), getChildMeasureSpec(i2, layoutParams.topMargin + layoutParams.bottomMargin, layoutParams.height));
} else {
throw new IllegalStateException("Child " + childAt + " at index " + i3 + " does not have a valid layout_gravity - must be Gravity.LEFT, Gravity.RIGHT or Gravity.NO_GRAVITY");
}
}
}
}
private void resolveShadowDrawables() {
if (SET_DRAWER_SHADOW_FROM_ELEVATION) {
return;
}
this.mShadowLeftResolved = resolveLeftShadow();
this.mShadowRightResolved = resolveRightShadow();
}
private Drawable resolveLeftShadow() {
int layoutDirection = ViewCompat.getLayoutDirection(this);
if (layoutDirection == 0) {
Drawable drawable = this.mShadowStart;
if (drawable != null) {
mirror(drawable, layoutDirection);
return this.mShadowStart;
}
} else {
Drawable drawable2 = this.mShadowEnd;
if (drawable2 != null) {
mirror(drawable2, layoutDirection);
return this.mShadowEnd;
}
}
return this.mShadowLeft;
}
private Drawable resolveRightShadow() {
int layoutDirection = ViewCompat.getLayoutDirection(this);
if (layoutDirection == 0) {
Drawable drawable = this.mShadowEnd;
if (drawable != null) {
mirror(drawable, layoutDirection);
return this.mShadowEnd;
}
} else {
Drawable drawable2 = this.mShadowStart;
if (drawable2 != null) {
mirror(drawable2, layoutDirection);
return this.mShadowStart;
}
}
return this.mShadowRight;
}
private void mirror(Drawable drawable, int i) {
if (drawable == null || !DrawableCompat.isAutoMirrored(drawable)) {
return;
}
DrawableCompat.setLayoutDirection(drawable, i);
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
WindowInsets rootWindowInsets;
float f;
int i5;
boolean z2 = true;
this.mInLayout = true;
int i6 = i3 - i;
int childCount = getChildCount();
int i7 = 0;
while (i7 < childCount) {
View childAt = getChildAt(i7);
if (childAt.getVisibility() != 8) {
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
if (isContentView(childAt)) {
childAt.layout(layoutParams.leftMargin, layoutParams.topMargin, layoutParams.leftMargin + childAt.getMeasuredWidth(), layoutParams.topMargin + childAt.getMeasuredHeight());
} else {
int measuredWidth = childAt.getMeasuredWidth();
int measuredHeight = childAt.getMeasuredHeight();
if (checkDrawerViewAbsoluteGravity(childAt, 3)) {
float f2 = measuredWidth;
i5 = (-measuredWidth) + ((int) (layoutParams.onScreen * f2));
f = (measuredWidth + i5) / f2;
} else {
float f3 = measuredWidth;
f = (i6 - r11) / f3;
i5 = i6 - ((int) (layoutParams.onScreen * f3));
}
boolean z3 = f != layoutParams.onScreen ? z2 : false;
int i8 = layoutParams.gravity & 112;
if (i8 == 16) {
int i9 = i4 - i2;
int i10 = (i9 - measuredHeight) / 2;
if (i10 < layoutParams.topMargin) {
i10 = layoutParams.topMargin;
} else if (i10 + measuredHeight > i9 - layoutParams.bottomMargin) {
i10 = (i9 - layoutParams.bottomMargin) - measuredHeight;
}
childAt.layout(i5, i10, measuredWidth + i5, measuredHeight + i10);
} else if (i8 != 80) {
childAt.layout(i5, layoutParams.topMargin, measuredWidth + i5, layoutParams.topMargin + measuredHeight);
} else {
int i11 = i4 - i2;
childAt.layout(i5, (i11 - layoutParams.bottomMargin) - childAt.getMeasuredHeight(), measuredWidth + i5, i11 - layoutParams.bottomMargin);
}
if (z3) {
setDrawerViewOffset(childAt, f);
}
int i12 = layoutParams.onScreen > 0.0f ? 0 : 4;
if (childAt.getVisibility() != i12) {
childAt.setVisibility(i12);
}
}
}
i7++;
z2 = true;
}
if (sEdgeSizeUsingSystemGestureInsets && (rootWindowInsets = getRootWindowInsets()) != null) {
Insets systemGestureInsets = WindowInsetsCompat.toWindowInsetsCompat(rootWindowInsets).getSystemGestureInsets();
ViewDragHelper viewDragHelper = this.mLeftDragger;
viewDragHelper.setEdgeSize(Math.max(viewDragHelper.getDefaultEdgeSize(), systemGestureInsets.left));
ViewDragHelper viewDragHelper2 = this.mRightDragger;
viewDragHelper2.setEdgeSize(Math.max(viewDragHelper2.getDefaultEdgeSize(), systemGestureInsets.right));
}
this.mInLayout = false;
this.mFirstLayout = false;
}
@Override // android.view.View, android.view.ViewParent
public void requestLayout() {
if (this.mInLayout) {
return;
}
super.requestLayout();
}
@Override // android.view.View
public void computeScroll() {
int childCount = getChildCount();
float f = 0.0f;
for (int i = 0; i < childCount; i++) {
f = Math.max(f, ((LayoutParams) getChildAt(i).getLayoutParams()).onScreen);
}
this.mScrimOpacity = f;
boolean continueSettling = this.mLeftDragger.continueSettling(true);
boolean continueSettling2 = this.mRightDragger.continueSettling(true);
if (continueSettling || continueSettling2) {
ViewCompat.postInvalidateOnAnimation(this);
}
}
private static boolean hasOpaqueBackground(View view) {
Drawable background = view.getBackground();
return background != null && background.getOpacity() == -1;
}
public void setStatusBarBackground(Drawable drawable) {
this.mStatusBarBackground = drawable;
invalidate();
}
public void setStatusBarBackground(int i) {
this.mStatusBarBackground = i != 0 ? ContextCompat.getDrawable(getContext(), i) : null;
invalidate();
}
public void setStatusBarBackgroundColor(int i) {
this.mStatusBarBackground = new ColorDrawable(i);
invalidate();
}
@Override // android.view.View
public void onRtlPropertiesChanged(int i) {
resolveShadowDrawables();
}
@Override // android.view.View
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (!this.mDrawStatusBarBackground || this.mStatusBarBackground == null) {
return;
}
Object obj = this.mLastInsets;
int systemWindowInsetTop = obj != null ? ((WindowInsets) obj).getSystemWindowInsetTop() : 0;
if (systemWindowInsetTop > 0) {
this.mStatusBarBackground.setBounds(0, 0, getWidth(), systemWindowInsetTop);
this.mStatusBarBackground.draw(canvas);
}
}
@Override // android.view.ViewGroup
protected boolean drawChild(Canvas canvas, View view, long j) {
int height = getHeight();
boolean isContentView = isContentView(view);
int width = getWidth();
int save = canvas.save();
int i = 0;
if (isContentView) {
int childCount = getChildCount();
int i2 = 0;
for (int i3 = 0; i3 < childCount; i3++) {
View childAt = getChildAt(i3);
if (childAt != view && childAt.getVisibility() == 0 && hasOpaqueBackground(childAt) && isDrawerView(childAt) && childAt.getHeight() >= height) {
if (checkDrawerViewAbsoluteGravity(childAt, 3)) {
int right = childAt.getRight();
if (right > i2) {
i2 = right;
}
} else {
int left = childAt.getLeft();
if (left < width) {
width = left;
}
}
}
}
canvas.clipRect(i2, 0, width, getHeight());
i = i2;
}
boolean drawChild = super.drawChild(canvas, view, j);
canvas.restoreToCount(save);
float f = this.mScrimOpacity;
if (f > 0.0f && isContentView) {
this.mScrimPaint.setColor((this.mScrimColor & ViewCompat.MEASURED_SIZE_MASK) | (((int) ((((-16777216) & r2) >>> 24) * f)) << 24));
canvas.drawRect(i, 0.0f, width, getHeight(), this.mScrimPaint);
} else if (this.mShadowLeftResolved != null && checkDrawerViewAbsoluteGravity(view, 3)) {
int intrinsicWidth = this.mShadowLeftResolved.getIntrinsicWidth();
int right2 = view.getRight();
float max = Math.max(0.0f, Math.min(right2 / this.mLeftDragger.getEdgeSize(), 1.0f));
this.mShadowLeftResolved.setBounds(right2, view.getTop(), intrinsicWidth + right2, view.getBottom());
this.mShadowLeftResolved.setAlpha((int) (max * 255.0f));
this.mShadowLeftResolved.draw(canvas);
} else if (this.mShadowRightResolved != null && checkDrawerViewAbsoluteGravity(view, 5)) {
int intrinsicWidth2 = this.mShadowRightResolved.getIntrinsicWidth();
int left2 = view.getLeft();
float max2 = Math.max(0.0f, Math.min((getWidth() - left2) / this.mRightDragger.getEdgeSize(), 1.0f));
this.mShadowRightResolved.setBounds(left2 - intrinsicWidth2, view.getTop(), left2, view.getBottom());
this.mShadowRightResolved.setAlpha((int) (max2 * 255.0f));
this.mShadowRightResolved.draw(canvas);
}
return drawChild;
}
boolean isContentView(View view) {
return ((LayoutParams) view.getLayoutParams()).gravity == 0;
}
boolean isDrawerView(View view) {
int absoluteGravity = GravityCompat.getAbsoluteGravity(((LayoutParams) view.getLayoutParams()).gravity, ViewCompat.getLayoutDirection(view));
return ((absoluteGravity & 3) == 0 && (absoluteGravity & 5) == 0) ? false : true;
}
/* JADX WARN: Code restructure failed: missing block: B:6:0x001b, code lost:
if (r0 != 3) goto L13;
*/
@Override // android.view.ViewGroup
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public boolean onInterceptTouchEvent(android.view.MotionEvent r7) {
/*
r6 = this;
int r0 = r7.getActionMasked()
androidx.customview.widget.ViewDragHelper r1 = r6.mLeftDragger
boolean r1 = r1.shouldInterceptTouchEvent(r7)
androidx.customview.widget.ViewDragHelper r2 = r6.mRightDragger
boolean r2 = r2.shouldInterceptTouchEvent(r7)
r1 = r1 | r2
r2 = 1
r3 = 0
if (r0 == 0) goto L38
if (r0 == r2) goto L31
r7 = 2
r4 = 3
if (r0 == r7) goto L1e
if (r0 == r4) goto L31
goto L36
L1e:
androidx.customview.widget.ViewDragHelper r7 = r6.mLeftDragger
boolean r7 = r7.checkTouchSlop(r4)
if (r7 == 0) goto L36
androidx.drawerlayout.widget.DrawerLayout$ViewDragCallback r7 = r6.mLeftCallback
r7.removeCallbacks()
androidx.drawerlayout.widget.DrawerLayout$ViewDragCallback r7 = r6.mRightCallback
r7.removeCallbacks()
goto L36
L31:
r6.closeDrawers(r2)
r6.mChildrenCanceledTouch = r3
L36:
r7 = r3
goto L60
L38:
float r0 = r7.getX()
float r7 = r7.getY()
r6.mInitialMotionX = r0
r6.mInitialMotionY = r7
float r4 = r6.mScrimOpacity
r5 = 0
int r4 = (r4 > r5 ? 1 : (r4 == r5 ? 0 : -1))
if (r4 <= 0) goto L5d
androidx.customview.widget.ViewDragHelper r4 = r6.mLeftDragger
int r0 = (int) r0
int r7 = (int) r7
android.view.View r7 = r4.findTopChildUnder(r0, r7)
if (r7 == 0) goto L5d
boolean r7 = r6.isContentView(r7)
if (r7 == 0) goto L5d
r7 = r2
goto L5e
L5d:
r7 = r3
L5e:
r6.mChildrenCanceledTouch = r3
L60:
if (r1 != 0) goto L70
if (r7 != 0) goto L70
boolean r7 = r6.hasPeekingDrawer()
if (r7 != 0) goto L70
boolean r6 = r6.mChildrenCanceledTouch
if (r6 == 0) goto L6f
goto L70
L6f:
r2 = r3
L70:
return r2
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.drawerlayout.widget.DrawerLayout.onInterceptTouchEvent(android.view.MotionEvent):boolean");
}
@Override // android.view.View
public boolean dispatchGenericMotionEvent(MotionEvent motionEvent) {
if ((motionEvent.getSource() & 2) == 0 || motionEvent.getAction() == 10 || this.mScrimOpacity <= 0.0f) {
return super.dispatchGenericMotionEvent(motionEvent);
}
int childCount = getChildCount();
if (childCount == 0) {
return false;
}
float x = motionEvent.getX();
float y = motionEvent.getY();
for (int i = childCount - 1; i >= 0; i--) {
View childAt = getChildAt(i);
if (isInBoundsOfChild(x, y, childAt) && !isContentView(childAt) && dispatchTransformedGenericPointerEvent(motionEvent, childAt)) {
return true;
}
}
return false;
}
/* JADX WARN: Code restructure failed: missing block: B:18:0x0058, code lost:
if (getDrawerLockMode(r7) != 2) goto L20;
*/
@Override // android.view.View
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public boolean onTouchEvent(android.view.MotionEvent r7) {
/*
r6 = this;
androidx.customview.widget.ViewDragHelper r0 = r6.mLeftDragger
r0.processTouchEvent(r7)
androidx.customview.widget.ViewDragHelper r0 = r6.mRightDragger
r0.processTouchEvent(r7)
int r0 = r7.getAction()
r0 = r0 & 255(0xff, float:3.57E-43)
r1 = 0
r2 = 1
if (r0 == 0) goto L5f
if (r0 == r2) goto L20
r7 = 3
if (r0 == r7) goto L1a
goto L6d
L1a:
r6.closeDrawers(r2)
r6.mChildrenCanceledTouch = r1
goto L6d
L20:
float r0 = r7.getX()
float r7 = r7.getY()
androidx.customview.widget.ViewDragHelper r3 = r6.mLeftDragger
int r4 = (int) r0
int r5 = (int) r7
android.view.View r3 = r3.findTopChildUnder(r4, r5)
if (r3 == 0) goto L5a
boolean r3 = r6.isContentView(r3)
if (r3 == 0) goto L5a
float r3 = r6.mInitialMotionX
float r0 = r0 - r3
float r3 = r6.mInitialMotionY
float r7 = r7 - r3
androidx.customview.widget.ViewDragHelper r3 = r6.mLeftDragger
int r3 = r3.getTouchSlop()
float r0 = r0 * r0
float r7 = r7 * r7
float r0 = r0 + r7
int r3 = r3 * r3
float r7 = (float) r3
int r7 = (r0 > r7 ? 1 : (r0 == r7 ? 0 : -1))
if (r7 >= 0) goto L5a
android.view.View r7 = r6.findOpenDrawer()
if (r7 == 0) goto L5a
int r7 = r6.getDrawerLockMode(r7)
r0 = 2
if (r7 != r0) goto L5b
L5a:
r1 = r2
L5b:
r6.closeDrawers(r1)
goto L6d
L5f:
float r0 = r7.getX()
float r7 = r7.getY()
r6.mInitialMotionX = r0
r6.mInitialMotionY = r7
r6.mChildrenCanceledTouch = r1
L6d:
return r2
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.drawerlayout.widget.DrawerLayout.onTouchEvent(android.view.MotionEvent):boolean");
}
@Override // android.view.ViewGroup, android.view.ViewParent
public void requestDisallowInterceptTouchEvent(boolean z) {
super.requestDisallowInterceptTouchEvent(z);
if (z) {
closeDrawers(true);
}
}
public void closeDrawers() {
closeDrawers(false);
}
void closeDrawers(boolean z) {
boolean smoothSlideViewTo;
int childCount = getChildCount();
boolean z2 = false;
for (int i = 0; i < childCount; i++) {
View childAt = getChildAt(i);
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
if (isDrawerView(childAt) && (!z || layoutParams.isPeeking)) {
int width = childAt.getWidth();
if (checkDrawerViewAbsoluteGravity(childAt, 3)) {
smoothSlideViewTo = this.mLeftDragger.smoothSlideViewTo(childAt, -width, childAt.getTop());
} else {
smoothSlideViewTo = this.mRightDragger.smoothSlideViewTo(childAt, getWidth(), childAt.getTop());
}
z2 |= smoothSlideViewTo;
layoutParams.isPeeking = false;
}
}
this.mLeftCallback.removeCallbacks();
this.mRightCallback.removeCallbacks();
if (z2) {
invalidate();
}
}
@Override // androidx.customview.widget.Openable
public void open() {
openDrawer(GravityCompat.START);
}
public void openDrawer(View view) {
openDrawer(view, true);
}
public void openDrawer(View view, boolean z) {
if (!isDrawerView(view)) {
throw new IllegalArgumentException("View " + view + " is not a sliding drawer");
}
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
if (this.mFirstLayout) {
layoutParams.onScreen = 1.0f;
layoutParams.openState = 1;
updateChildrenImportantForAccessibility(view, true);
updateChildAccessibilityAction(view);
} else if (z) {
layoutParams.openState |= 2;
if (checkDrawerViewAbsoluteGravity(view, 3)) {
this.mLeftDragger.smoothSlideViewTo(view, 0, view.getTop());
} else {
this.mRightDragger.smoothSlideViewTo(view, getWidth() - view.getWidth(), view.getTop());
}
} else {
moveDrawerToOffset(view, 1.0f);
updateDrawerState(0, view);
view.setVisibility(0);
}
invalidate();
}
public void openDrawer(int i) {
openDrawer(i, true);
}
public void openDrawer(int i, boolean z) {
View findDrawerWithGravity = findDrawerWithGravity(i);
if (findDrawerWithGravity == null) {
throw new IllegalArgumentException("No drawer view found with gravity " + gravityToString(i));
}
openDrawer(findDrawerWithGravity, z);
}
@Override // androidx.customview.widget.Openable
public void close() {
closeDrawer(GravityCompat.START);
}
public void closeDrawer(View view) {
closeDrawer(view, true);
}
public void closeDrawer(View view, boolean z) {
if (!isDrawerView(view)) {
throw new IllegalArgumentException("View " + view + " is not a sliding drawer");
}
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
if (this.mFirstLayout) {
layoutParams.onScreen = 0.0f;
layoutParams.openState = 0;
} else if (z) {
layoutParams.openState |= 4;
if (checkDrawerViewAbsoluteGravity(view, 3)) {
this.mLeftDragger.smoothSlideViewTo(view, -view.getWidth(), view.getTop());
} else {
this.mRightDragger.smoothSlideViewTo(view, getWidth(), view.getTop());
}
} else {
moveDrawerToOffset(view, 0.0f);
updateDrawerState(0, view);
view.setVisibility(4);
}
invalidate();
}
public void closeDrawer(int i) {
closeDrawer(i, true);
}
public void closeDrawer(int i, boolean z) {
View findDrawerWithGravity = findDrawerWithGravity(i);
if (findDrawerWithGravity == null) {
throw new IllegalArgumentException("No drawer view found with gravity " + gravityToString(i));
}
closeDrawer(findDrawerWithGravity, z);
}
public boolean isDrawerOpen(View view) {
if (isDrawerView(view)) {
return (((LayoutParams) view.getLayoutParams()).openState & 1) == 1;
}
throw new IllegalArgumentException("View " + view + " is not a drawer");
}
@Override // androidx.customview.widget.Openable
public boolean isOpen() {
return isDrawerOpen(GravityCompat.START);
}
public boolean isDrawerOpen(int i) {
View findDrawerWithGravity = findDrawerWithGravity(i);
if (findDrawerWithGravity != null) {
return isDrawerOpen(findDrawerWithGravity);
}
return false;
}
public boolean isDrawerVisible(View view) {
if (isDrawerView(view)) {
return ((LayoutParams) view.getLayoutParams()).onScreen > 0.0f;
}
throw new IllegalArgumentException("View " + view + " is not a drawer");
}
public boolean isDrawerVisible(int i) {
View findDrawerWithGravity = findDrawerWithGravity(i);
if (findDrawerWithGravity != null) {
return isDrawerVisible(findDrawerWithGravity);
}
return false;
}
private boolean hasPeekingDrawer() {
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
if (((LayoutParams) getChildAt(i).getLayoutParams()).isPeeking) {
return true;
}
}
return false;
}
@Override // android.view.ViewGroup
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
return new LayoutParams(-1, -1);
}
@Override // android.view.ViewGroup
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
if (layoutParams instanceof LayoutParams) {
return new LayoutParams((LayoutParams) layoutParams);
}
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
return new LayoutParams((ViewGroup.MarginLayoutParams) layoutParams);
}
return new LayoutParams(layoutParams);
}
@Override // android.view.ViewGroup
protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
return (layoutParams instanceof LayoutParams) && super.checkLayoutParams(layoutParams);
}
@Override // android.view.ViewGroup
public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
return new LayoutParams(getContext(), attributeSet);
}
@Override // android.view.ViewGroup, android.view.View
public void addFocusables(ArrayList<View> arrayList, int i, int i2) {
if (getDescendantFocusability() == 393216) {
return;
}
int childCount = getChildCount();
boolean z = false;
for (int i3 = 0; i3 < childCount; i3++) {
View childAt = getChildAt(i3);
if (isDrawerView(childAt)) {
if (isDrawerOpen(childAt)) {
childAt.addFocusables(arrayList, i, i2);
z = true;
}
} else {
this.mNonDrawerViews.add(childAt);
}
}
if (!z) {
int size = this.mNonDrawerViews.size();
for (int i4 = 0; i4 < size; i4++) {
View view = this.mNonDrawerViews.get(i4);
if (view.getVisibility() == 0) {
view.addFocusables(arrayList, i, i2);
}
}
}
this.mNonDrawerViews.clear();
}
private boolean hasVisibleDrawer() {
return findVisibleDrawer() != null;
}
View findVisibleDrawer() {
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = getChildAt(i);
if (isDrawerView(childAt) && isDrawerVisible(childAt)) {
return childAt;
}
}
return null;
}
void cancelChildViewTouch() {
if (this.mChildrenCanceledTouch) {
return;
}
long uptimeMillis = SystemClock.uptimeMillis();
MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0);
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
getChildAt(i).dispatchTouchEvent(obtain);
}
obtain.recycle();
this.mChildrenCanceledTouch = true;
}
@Override // android.view.View, android.view.KeyEvent.Callback
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (i == 4 && hasVisibleDrawer()) {
keyEvent.startTracking();
return true;
}
return super.onKeyDown(i, keyEvent);
}
@Override // android.view.View, android.view.KeyEvent.Callback
public boolean onKeyUp(int i, KeyEvent keyEvent) {
if (i == 4) {
View findVisibleDrawer = findVisibleDrawer();
if (findVisibleDrawer != null && getDrawerLockMode(findVisibleDrawer) == 0) {
closeDrawers();
}
return findVisibleDrawer != null;
}
return super.onKeyUp(i, keyEvent);
}
@Override // android.view.View
protected void onRestoreInstanceState(Parcelable parcelable) {
View findDrawerWithGravity;
if (!(parcelable instanceof SavedState)) {
super.onRestoreInstanceState(parcelable);
return;
}
SavedState savedState = (SavedState) parcelable;
super.onRestoreInstanceState(savedState.getSuperState());
if (savedState.openDrawerGravity != 0 && (findDrawerWithGravity = findDrawerWithGravity(savedState.openDrawerGravity)) != null) {
openDrawer(findDrawerWithGravity);
}
if (savedState.lockModeLeft != 3) {
setDrawerLockMode(savedState.lockModeLeft, 3);
}
if (savedState.lockModeRight != 3) {
setDrawerLockMode(savedState.lockModeRight, 5);
}
if (savedState.lockModeStart != 3) {
setDrawerLockMode(savedState.lockModeStart, GravityCompat.START);
}
if (savedState.lockModeEnd != 3) {
setDrawerLockMode(savedState.lockModeEnd, GravityCompat.END);
}
}
@Override // android.view.View
protected Parcelable onSaveInstanceState() {
SavedState savedState = new SavedState(super.onSaveInstanceState());
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
LayoutParams layoutParams = (LayoutParams) getChildAt(i).getLayoutParams();
boolean z = layoutParams.openState == 1;
boolean z2 = layoutParams.openState == 2;
if (z || z2) {
savedState.openDrawerGravity = layoutParams.gravity;
break;
}
}
savedState.lockModeLeft = this.mLockModeLeft;
savedState.lockModeRight = this.mLockModeRight;
savedState.lockModeStart = this.mLockModeStart;
savedState.lockModeEnd = this.mLockModeEnd;
return savedState;
}
@Override // android.view.ViewGroup
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
super.addView(view, i, layoutParams);
if (findOpenDrawer() != null || isDrawerView(view)) {
ViewCompat.setImportantForAccessibility(view, 4);
} else {
ViewCompat.setImportantForAccessibility(view, 1);
}
if (CAN_HIDE_DESCENDANTS) {
return;
}
ViewCompat.setAccessibilityDelegate(view, this.mChildAccessibilityDelegate);
}
static boolean includeChildForAccessibility(View view) {
return (ViewCompat.getImportantForAccessibility(view) == 4 || ViewCompat.getImportantForAccessibility(view) == 2) ? false : true;
}
/* JADX INFO: Access modifiers changed from: protected */
/* loaded from: classes.dex */
public static class SavedState extends AbsSavedState {
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: androidx.drawerlayout.widget.DrawerLayout.SavedState.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.ClassLoaderCreator
public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
return new SavedState(parcel, classLoader);
}
@Override // android.os.Parcelable.Creator
public SavedState createFromParcel(Parcel parcel) {
return new SavedState(parcel, null);
}
@Override // android.os.Parcelable.Creator
public SavedState[] newArray(int i) {
return new SavedState[i];
}
};
int lockModeEnd;
int lockModeLeft;
int lockModeRight;
int lockModeStart;
int openDrawerGravity;
public SavedState(Parcel parcel, ClassLoader classLoader) {
super(parcel, classLoader);
this.openDrawerGravity = 0;
this.openDrawerGravity = parcel.readInt();
this.lockModeLeft = parcel.readInt();
this.lockModeRight = parcel.readInt();
this.lockModeStart = parcel.readInt();
this.lockModeEnd = parcel.readInt();
}
public SavedState(Parcelable parcelable) {
super(parcelable);
this.openDrawerGravity = 0;
}
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(this.openDrawerGravity);
parcel.writeInt(this.lockModeLeft);
parcel.writeInt(this.lockModeRight);
parcel.writeInt(this.lockModeStart);
parcel.writeInt(this.lockModeEnd);
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes.dex */
public class ViewDragCallback extends ViewDragHelper.Callback {
private final int mAbsGravity;
private ViewDragHelper mDragger;
private final Runnable mPeekRunnable = new Runnable() { // from class: androidx.drawerlayout.widget.DrawerLayout.ViewDragCallback.1
@Override // java.lang.Runnable
public void run() {
ViewDragCallback.this.peekDrawer();
}
};
@Override // androidx.customview.widget.ViewDragHelper.Callback
public boolean onEdgeLock(int i) {
return false;
}
public void setDragger(ViewDragHelper viewDragHelper) {
this.mDragger = viewDragHelper;
}
ViewDragCallback(int i) {
this.mAbsGravity = i;
}
public void removeCallbacks() {
DrawerLayout.this.removeCallbacks(this.mPeekRunnable);
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public boolean tryCaptureView(View view, int i) {
return DrawerLayout.this.isDrawerView(view) && DrawerLayout.this.checkDrawerViewAbsoluteGravity(view, this.mAbsGravity) && DrawerLayout.this.getDrawerLockMode(view) == 0;
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onViewDragStateChanged(int i) {
DrawerLayout.this.updateDrawerState(i, this.mDragger.getCapturedView());
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onViewPositionChanged(View view, int i, int i2, int i3, int i4) {
float width = (DrawerLayout.this.checkDrawerViewAbsoluteGravity(view, 3) ? i + r3 : DrawerLayout.this.getWidth() - i) / view.getWidth();
DrawerLayout.this.setDrawerViewOffset(view, width);
view.setVisibility(width == 0.0f ? 4 : 0);
DrawerLayout.this.invalidate();
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onViewCaptured(View view, int i) {
((LayoutParams) view.getLayoutParams()).isPeeking = false;
closeOtherDrawer();
}
private void closeOtherDrawer() {
View findDrawerWithGravity = DrawerLayout.this.findDrawerWithGravity(this.mAbsGravity == 3 ? 5 : 3);
if (findDrawerWithGravity != null) {
DrawerLayout.this.closeDrawer(findDrawerWithGravity);
}
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onViewReleased(View view, float f, float f2) {
int i;
float drawerViewOffset = DrawerLayout.this.getDrawerViewOffset(view);
int width = view.getWidth();
if (DrawerLayout.this.checkDrawerViewAbsoluteGravity(view, 3)) {
i = (f > 0.0f || (f == 0.0f && drawerViewOffset > 0.5f)) ? 0 : -width;
} else {
int width2 = DrawerLayout.this.getWidth();
if (f < 0.0f || (f == 0.0f && drawerViewOffset > 0.5f)) {
width2 -= width;
}
i = width2;
}
this.mDragger.settleCapturedViewAt(i, view.getTop());
DrawerLayout.this.invalidate();
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onEdgeTouched(int i, int i2) {
DrawerLayout.this.postDelayed(this.mPeekRunnable, 160L);
}
void peekDrawer() {
View findDrawerWithGravity;
int width;
int edgeSize = this.mDragger.getEdgeSize();
boolean z = this.mAbsGravity == 3;
if (z) {
findDrawerWithGravity = DrawerLayout.this.findDrawerWithGravity(3);
width = (findDrawerWithGravity != null ? -findDrawerWithGravity.getWidth() : 0) + edgeSize;
} else {
findDrawerWithGravity = DrawerLayout.this.findDrawerWithGravity(5);
width = DrawerLayout.this.getWidth() - edgeSize;
}
if (findDrawerWithGravity != null) {
if (((!z || findDrawerWithGravity.getLeft() >= width) && (z || findDrawerWithGravity.getLeft() <= width)) || DrawerLayout.this.getDrawerLockMode(findDrawerWithGravity) != 0) {
return;
}
LayoutParams layoutParams = (LayoutParams) findDrawerWithGravity.getLayoutParams();
this.mDragger.smoothSlideViewTo(findDrawerWithGravity, width, findDrawerWithGravity.getTop());
layoutParams.isPeeking = true;
DrawerLayout.this.invalidate();
closeOtherDrawer();
DrawerLayout.this.cancelChildViewTouch();
}
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onEdgeDragStarted(int i, int i2) {
View findDrawerWithGravity;
if ((i & 1) == 1) {
findDrawerWithGravity = DrawerLayout.this.findDrawerWithGravity(3);
} else {
findDrawerWithGravity = DrawerLayout.this.findDrawerWithGravity(5);
}
if (findDrawerWithGravity == null || DrawerLayout.this.getDrawerLockMode(findDrawerWithGravity) != 0) {
return;
}
this.mDragger.captureChildView(findDrawerWithGravity, i2);
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public int getViewHorizontalDragRange(View view) {
if (DrawerLayout.this.isDrawerView(view)) {
return view.getWidth();
}
return 0;
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public int clampViewPositionHorizontal(View view, int i, int i2) {
if (DrawerLayout.this.checkDrawerViewAbsoluteGravity(view, 3)) {
return Math.max(-view.getWidth(), Math.min(i, 0));
}
int width = DrawerLayout.this.getWidth();
return Math.max(width - view.getWidth(), Math.min(i, width));
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public int clampViewPositionVertical(View view, int i, int i2) {
return view.getTop();
}
}
/* loaded from: classes.dex */
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
private static final int FLAG_IS_CLOSING = 4;
private static final int FLAG_IS_OPENED = 1;
private static final int FLAG_IS_OPENING = 2;
public int gravity;
boolean isPeeking;
float onScreen;
int openState;
public LayoutParams(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.gravity = 0;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, DrawerLayout.LAYOUT_ATTRS);
this.gravity = obtainStyledAttributes.getInt(0, 0);
obtainStyledAttributes.recycle();
}
public LayoutParams(int i, int i2) {
super(i, i2);
this.gravity = 0;
}
public LayoutParams(int i, int i2, int i3) {
this(i, i2);
this.gravity = i3;
}
public LayoutParams(LayoutParams layoutParams) {
super((ViewGroup.MarginLayoutParams) layoutParams);
this.gravity = 0;
this.gravity = layoutParams.gravity;
}
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
super(layoutParams);
this.gravity = 0;
}
public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) {
super(marginLayoutParams);
this.gravity = 0;
}
}
/* loaded from: classes.dex */
class AccessibilityDelegate extends AccessibilityDelegateCompat {
private final Rect mTmpRect = new Rect();
AccessibilityDelegate() {
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
if (DrawerLayout.CAN_HIDE_DESCENDANTS) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
} else {
AccessibilityNodeInfoCompat obtain = AccessibilityNodeInfoCompat.obtain(accessibilityNodeInfoCompat);
super.onInitializeAccessibilityNodeInfo(view, obtain);
accessibilityNodeInfoCompat.setSource(view);
Object parentForAccessibility = ViewCompat.getParentForAccessibility(view);
if (parentForAccessibility instanceof View) {
accessibilityNodeInfoCompat.setParent((View) parentForAccessibility);
}
copyNodeInfoNoChildren(accessibilityNodeInfoCompat, obtain);
obtain.recycle();
addChildrenForAccessibility(accessibilityNodeInfoCompat, (ViewGroup) view);
}
accessibilityNodeInfoCompat.setClassName(DrawerLayout.ACCESSIBILITY_CLASS_NAME);
accessibilityNodeInfoCompat.setFocusable(false);
accessibilityNodeInfoCompat.setFocused(false);
accessibilityNodeInfoCompat.removeAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_FOCUS);
accessibilityNodeInfoCompat.removeAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CLEAR_FOCUS);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
super.onInitializeAccessibilityEvent(view, accessibilityEvent);
accessibilityEvent.setClassName(DrawerLayout.ACCESSIBILITY_CLASS_NAME);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public boolean dispatchPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
if (accessibilityEvent.getEventType() == 32) {
List<CharSequence> text = accessibilityEvent.getText();
View findVisibleDrawer = DrawerLayout.this.findVisibleDrawer();
if (findVisibleDrawer == null) {
return true;
}
CharSequence drawerTitle = DrawerLayout.this.getDrawerTitle(DrawerLayout.this.getDrawerViewAbsoluteGravity(findVisibleDrawer));
if (drawerTitle == null) {
return true;
}
text.add(drawerTitle);
return true;
}
return super.dispatchPopulateAccessibilityEvent(view, accessibilityEvent);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public boolean onRequestSendAccessibilityEvent(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
if (DrawerLayout.CAN_HIDE_DESCENDANTS || DrawerLayout.includeChildForAccessibility(view)) {
return super.onRequestSendAccessibilityEvent(viewGroup, view, accessibilityEvent);
}
return false;
}
private void addChildrenForAccessibility(AccessibilityNodeInfoCompat accessibilityNodeInfoCompat, ViewGroup viewGroup) {
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = viewGroup.getChildAt(i);
if (DrawerLayout.includeChildForAccessibility(childAt)) {
accessibilityNodeInfoCompat.addChild(childAt);
}
}
}
private void copyNodeInfoNoChildren(AccessibilityNodeInfoCompat accessibilityNodeInfoCompat, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat2) {
Rect rect = this.mTmpRect;
accessibilityNodeInfoCompat2.getBoundsInScreen(rect);
accessibilityNodeInfoCompat.setBoundsInScreen(rect);
accessibilityNodeInfoCompat.setVisibleToUser(accessibilityNodeInfoCompat2.isVisibleToUser());
accessibilityNodeInfoCompat.setPackageName(accessibilityNodeInfoCompat2.getPackageName());
accessibilityNodeInfoCompat.setClassName(accessibilityNodeInfoCompat2.getClassName());
accessibilityNodeInfoCompat.setContentDescription(accessibilityNodeInfoCompat2.getContentDescription());
accessibilityNodeInfoCompat.setEnabled(accessibilityNodeInfoCompat2.isEnabled());
accessibilityNodeInfoCompat.setFocused(accessibilityNodeInfoCompat2.isFocused());
accessibilityNodeInfoCompat.setAccessibilityFocused(accessibilityNodeInfoCompat2.isAccessibilityFocused());
accessibilityNodeInfoCompat.setSelected(accessibilityNodeInfoCompat2.isSelected());
accessibilityNodeInfoCompat.addAction(accessibilityNodeInfoCompat2.getActions());
}
}
/* loaded from: classes.dex */
static final class ChildAccessibilityDelegate extends AccessibilityDelegateCompat {
ChildAccessibilityDelegate() {
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
if (DrawerLayout.includeChildForAccessibility(view)) {
return;
}
accessibilityNodeInfoCompat.setParent(null);
}
}
}