Rabbit-R1/android (non root)/java/sources/androidx/slidingpanelayout/widget/SlidingPaneLayout.java
2024-05-21 17:28:28 -04:00

1284 lines
51 KiB
Java

package androidx.slidingpanelayout.widget;
import android.R;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.FrameLayout;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.animation.PathInterpolatorCompat;
import androidx.customview.view.AbsSavedState;
import androidx.customview.widget.Openable;
import androidx.customview.widget.ViewDragHelper;
import androidx.slidingpanelayout.widget.FoldingFeatureObserver;
import androidx.transition.ChangeBounds;
import androidx.transition.TransitionManager;
import androidx.window.layout.FoldingFeature;
import androidx.window.layout.WindowInfoTracker;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/* loaded from: classes2.dex */
public class SlidingPaneLayout extends ViewGroup implements Openable {
private static final String ACCESSIBILITY_CLASS_NAME = "androidx.slidingpanelayout.widget.SlidingPaneLayout";
public static final int LOCK_MODE_LOCKED = 3;
public static final int LOCK_MODE_LOCKED_CLOSED = 2;
public static final int LOCK_MODE_LOCKED_OPEN = 1;
public static final int LOCK_MODE_UNLOCKED = 0;
private static final int MIN_FLING_VELOCITY = 400;
private static final String TAG = "SlidingPaneLayout";
private static boolean sEdgeSizeUsingSystemGestureInsets = true;
private boolean mCanSlide;
private int mCoveredFadeColor;
private boolean mDisplayListReflectionLoaded;
final ViewDragHelper mDragHelper;
private boolean mFirstLayout;
FoldingFeature mFoldingFeature;
private FoldingFeatureObserver mFoldingFeatureObserver;
private Method mGetDisplayList;
private float mInitialMotionX;
private float mInitialMotionY;
boolean mIsUnableToDrag;
private int mLockMode;
private FoldingFeatureObserver.OnFoldingFeatureChangeListener mOnFoldingFeatureChangeListener;
private PanelSlideListener mPanelSlideListener;
private final List<PanelSlideListener> mPanelSlideListeners;
private int mParallaxBy;
private float mParallaxOffset;
final ArrayList<DisableLayerRunnable> mPostedRunnables;
boolean mPreservedOpenState;
private Field mRecreateDisplayList;
private Drawable mShadowDrawableLeft;
private Drawable mShadowDrawableRight;
float mSlideOffset;
int mSlideRange;
View mSlideableView;
private int mSliderFadeColor;
private final Rect mTmpRect;
/* loaded from: classes2.dex */
public interface PanelSlideListener {
void onPanelClosed(View view);
void onPanelOpened(View view);
void onPanelSlide(View view, float f);
}
/* loaded from: classes2.dex */
public static class SimplePanelSlideListener implements PanelSlideListener {
@Override // androidx.slidingpanelayout.widget.SlidingPaneLayout.PanelSlideListener
public void onPanelClosed(View view) {
}
@Override // androidx.slidingpanelayout.widget.SlidingPaneLayout.PanelSlideListener
public void onPanelOpened(View view) {
}
@Override // androidx.slidingpanelayout.widget.SlidingPaneLayout.PanelSlideListener
public void onPanelSlide(View view, float f) {
}
}
@Deprecated
public boolean canSlide() {
return this.mCanSlide;
}
@Deprecated
public int getCoveredFadeColor() {
return this.mCoveredFadeColor;
}
public final int getLockMode() {
return this.mLockMode;
}
public int getParallaxDistance() {
return this.mParallaxBy;
}
@Deprecated
public int getSliderFadeColor() {
return this.mSliderFadeColor;
}
@Override // androidx.customview.widget.Openable
public boolean isOpen() {
return !this.mCanSlide || this.mSlideOffset == 0.0f;
}
public boolean isSlideable() {
return this.mCanSlide;
}
@Deprecated
public void setCoveredFadeColor(int i) {
this.mCoveredFadeColor = i;
}
public final void setLockMode(int i) {
this.mLockMode = i;
}
public void setShadowDrawableLeft(Drawable drawable) {
this.mShadowDrawableLeft = drawable;
}
public void setShadowDrawableRight(Drawable drawable) {
this.mShadowDrawableRight = drawable;
}
@Deprecated
public void setSliderFadeColor(int i) {
this.mSliderFadeColor = i;
}
public SlidingPaneLayout(Context context) {
this(context, null);
}
public SlidingPaneLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public SlidingPaneLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.mSliderFadeColor = 0;
this.mSlideOffset = 1.0f;
this.mPanelSlideListeners = new CopyOnWriteArrayList();
this.mFirstLayout = true;
this.mTmpRect = new Rect();
this.mPostedRunnables = new ArrayList<>();
this.mOnFoldingFeatureChangeListener = new FoldingFeatureObserver.OnFoldingFeatureChangeListener() { // from class: androidx.slidingpanelayout.widget.SlidingPaneLayout.1
@Override // androidx.slidingpanelayout.widget.FoldingFeatureObserver.OnFoldingFeatureChangeListener
public void onFoldingFeatureChange(FoldingFeature foldingFeature) {
SlidingPaneLayout.this.mFoldingFeature = foldingFeature;
ChangeBounds changeBounds = new ChangeBounds();
changeBounds.setDuration(300L);
changeBounds.setInterpolator(PathInterpolatorCompat.create(0.2f, 0.0f, 0.0f, 1.0f));
TransitionManager.beginDelayedTransition(SlidingPaneLayout.this, changeBounds);
SlidingPaneLayout.this.requestLayout();
}
};
float f = context.getResources().getDisplayMetrics().density;
setWillNotDraw(false);
ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
ViewCompat.setImportantForAccessibility(this, 1);
ViewDragHelper create = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
this.mDragHelper = create;
create.setMinVelocity(f * 400.0f);
setFoldingFeatureObserver(new FoldingFeatureObserver(WindowInfoTracker.getOrCreate(context), ContextCompat.getMainExecutor(context)));
}
private void setFoldingFeatureObserver(FoldingFeatureObserver foldingFeatureObserver) {
this.mFoldingFeatureObserver = foldingFeatureObserver;
foldingFeatureObserver.setOnFoldingFeatureChangeListener(this.mOnFoldingFeatureChangeListener);
}
public void setParallaxDistance(int i) {
this.mParallaxBy = i;
requestLayout();
}
@Deprecated
public void setPanelSlideListener(PanelSlideListener panelSlideListener) {
PanelSlideListener panelSlideListener2 = this.mPanelSlideListener;
if (panelSlideListener2 != null) {
removePanelSlideListener(panelSlideListener2);
}
if (panelSlideListener != null) {
addPanelSlideListener(panelSlideListener);
}
this.mPanelSlideListener = panelSlideListener;
}
public void addPanelSlideListener(PanelSlideListener panelSlideListener) {
this.mPanelSlideListeners.add(panelSlideListener);
}
public void removePanelSlideListener(PanelSlideListener panelSlideListener) {
this.mPanelSlideListeners.remove(panelSlideListener);
}
void dispatchOnPanelSlide(View view) {
Iterator<PanelSlideListener> it = this.mPanelSlideListeners.iterator();
while (it.hasNext()) {
it.next().onPanelSlide(view, this.mSlideOffset);
}
}
void dispatchOnPanelOpened(View view) {
Iterator<PanelSlideListener> it = this.mPanelSlideListeners.iterator();
while (it.hasNext()) {
it.next().onPanelOpened(view);
}
sendAccessibilityEvent(32);
}
void dispatchOnPanelClosed(View view) {
Iterator<PanelSlideListener> it = this.mPanelSlideListeners.iterator();
while (it.hasNext()) {
it.next().onPanelClosed(view);
}
sendAccessibilityEvent(32);
}
void updateObscuredViewsVisibility(View view) {
int i;
int i2;
int i3;
int i4;
boolean z;
View view2 = view;
boolean isLayoutRtlSupport = isLayoutRtlSupport();
int width = isLayoutRtlSupport ? getWidth() - getPaddingRight() : getPaddingLeft();
int paddingLeft = isLayoutRtlSupport ? getPaddingLeft() : getWidth() - getPaddingRight();
int paddingTop = getPaddingTop();
int height = getHeight() - getPaddingBottom();
if (view2 == null || !viewIsOpaque(view)) {
i = 0;
i2 = 0;
i3 = 0;
i4 = 0;
} else {
i = view.getLeft();
i2 = view.getRight();
i3 = view.getTop();
i4 = view.getBottom();
}
int childCount = getChildCount();
int i5 = 0;
while (i5 < childCount) {
View childAt = getChildAt(i5);
if (childAt == view2) {
return;
}
if (childAt.getVisibility() == 8) {
z = isLayoutRtlSupport;
} else {
z = isLayoutRtlSupport;
childAt.setVisibility((Math.max(isLayoutRtlSupport ? paddingLeft : width, childAt.getLeft()) < i || Math.max(paddingTop, childAt.getTop()) < i3 || Math.min(isLayoutRtlSupport ? width : paddingLeft, childAt.getRight()) > i2 || Math.min(height, childAt.getBottom()) > i4) ? 0 : 4);
}
i5++;
view2 = view;
isLayoutRtlSupport = z;
}
}
void setAllChildrenVisible() {
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = getChildAt(i);
if (childAt.getVisibility() == 4) {
childAt.setVisibility(0);
}
}
}
private static boolean viewIsOpaque(View view) {
return view.isOpaque();
}
@Override // android.view.ViewGroup
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
if (getChildCount() == 1) {
super.addView(new TouchBlocker(view), i, layoutParams);
} else {
super.addView(view, i, layoutParams);
}
}
@Override // android.view.ViewGroup, android.view.ViewManager
public void removeView(View view) {
if (view.getParent() instanceof TouchBlocker) {
super.removeView((View) view.getParent());
} else {
super.removeView(view);
}
}
@Override // android.view.ViewGroup, android.view.View
protected void onAttachedToWindow() {
Activity activityOrNull;
super.onAttachedToWindow();
this.mFirstLayout = true;
if (this.mFoldingFeatureObserver == null || (activityOrNull = getActivityOrNull(getContext())) == null) {
return;
}
this.mFoldingFeatureObserver.registerLayoutStateChangeCallback(activityOrNull);
}
@Override // android.view.ViewGroup, android.view.View
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
this.mFirstLayout = true;
FoldingFeatureObserver foldingFeatureObserver = this.mFoldingFeatureObserver;
if (foldingFeatureObserver != null) {
foldingFeatureObserver.unregisterLayoutStateChangeCallback();
}
int size = this.mPostedRunnables.size();
for (int i = 0; i < size; i++) {
this.mPostedRunnables.get(i).run();
}
this.mPostedRunnables.clear();
}
/* JADX WARN: Type inference failed for: r8v0 */
/* JADX WARN: Type inference failed for: r8v1, types: [boolean, int] */
/* JADX WARN: Type inference failed for: r8v12 */
@Override // android.view.View
protected void onMeasure(int i, int i2) {
int paddingTop;
int i3;
int i4;
int i5;
int i6;
int makeMeasureSpec;
int mode = View.MeasureSpec.getMode(i);
int size = View.MeasureSpec.getSize(i);
int mode2 = View.MeasureSpec.getMode(i2);
int size2 = View.MeasureSpec.getSize(i2);
?? r8 = 0;
if (mode2 != Integer.MIN_VALUE) {
i3 = mode2 != 1073741824 ? 0 : (size2 - getPaddingTop()) - getPaddingBottom();
paddingTop = i3;
} else {
paddingTop = (size2 - getPaddingTop()) - getPaddingBottom();
i3 = 0;
}
int max = Math.max((size - getPaddingLeft()) - getPaddingRight(), 0);
int childCount = getChildCount();
if (childCount > 2) {
Log.e(TAG, "onMeasure: More than two child views are not supported.");
}
this.mSlideableView = null;
int i7 = 0;
boolean z = false;
int i8 = max;
float f = 0.0f;
while (true) {
i4 = 8;
if (i7 >= childCount) {
break;
}
View childAt = getChildAt(i7);
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
int i9 = size;
if (childAt.getVisibility() == 8) {
layoutParams.dimWhenOffset = r8;
} else {
if (layoutParams.weight > 0.0f) {
f += layoutParams.weight;
if (layoutParams.width == 0) {
}
}
int max2 = Math.max(max - (layoutParams.leftMargin + layoutParams.rightMargin), (int) r8);
if (layoutParams.width == -2) {
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(max2, mode == 0 ? mode : Integer.MIN_VALUE);
} else if (layoutParams.width == -1) {
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(max2, mode);
} else {
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(layoutParams.width, 1073741824);
}
childAt.measure(makeMeasureSpec, getChildMeasureSpec(i2, getPaddingTop() + getPaddingBottom(), layoutParams.height));
int measuredWidth = childAt.getMeasuredWidth();
int measuredHeight = childAt.getMeasuredHeight();
if (measuredHeight > i3) {
if (mode2 == Integer.MIN_VALUE) {
i3 = Math.min(measuredHeight, paddingTop);
} else if (mode2 == 0) {
i3 = measuredHeight;
}
}
i8 -= measuredWidth;
if (i7 != 0) {
boolean z2 = i8 < 0;
layoutParams.slideable = z2;
z |= z2;
if (layoutParams.slideable) {
this.mSlideableView = childAt;
}
}
}
i7++;
size = i9;
r8 = 0;
}
int i10 = size;
int i11 = i8;
if (z || f > 0.0f) {
int i12 = 0;
while (i12 < childCount) {
View childAt2 = getChildAt(i12);
if (childAt2.getVisibility() != i4) {
LayoutParams layoutParams2 = (LayoutParams) childAt2.getLayoutParams();
int measuredWidth2 = (layoutParams2.width != 0 || layoutParams2.weight <= 0.0f) ? childAt2.getMeasuredWidth() : 0;
if (z) {
i5 = max - (layoutParams2.leftMargin + layoutParams2.rightMargin);
i6 = View.MeasureSpec.makeMeasureSpec(i5, 1073741824);
} else if (layoutParams2.weight > 0.0f) {
i5 = measuredWidth2 + ((int) ((layoutParams2.weight * Math.max(0, i11)) / f));
i6 = View.MeasureSpec.makeMeasureSpec(i5, 1073741824);
} else {
i5 = measuredWidth2;
i6 = 0;
}
int measureChildHeight = measureChildHeight(childAt2, i2, getPaddingTop() + getPaddingBottom());
if (measuredWidth2 != i5) {
childAt2.measure(i6, measureChildHeight);
int measuredHeight2 = childAt2.getMeasuredHeight();
if (measuredHeight2 > i3) {
if (mode2 == Integer.MIN_VALUE) {
measuredHeight2 = Math.min(measuredHeight2, paddingTop);
} else if (mode2 != 0) {
}
i3 = measuredHeight2;
}
}
}
i12++;
i4 = 8;
}
}
ArrayList<Rect> splitViewPositions = splitViewPositions();
if (splitViewPositions != null && !z) {
for (int i13 = 0; i13 < childCount; i13++) {
View childAt3 = getChildAt(i13);
if (childAt3.getVisibility() != 8) {
Rect rect = splitViewPositions.get(i13);
LayoutParams layoutParams3 = (LayoutParams) childAt3.getLayoutParams();
int i14 = layoutParams3.leftMargin + layoutParams3.rightMargin;
int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(childAt3.getMeasuredHeight(), 1073741824);
childAt3.measure(View.MeasureSpec.makeMeasureSpec(rect.width(), Integer.MIN_VALUE), makeMeasureSpec2);
if ((childAt3.getMeasuredWidthAndState() & 16777216) == 1 || (getMinimumWidth(childAt3) != 0 && rect.width() < getMinimumWidth(childAt3))) {
childAt3.measure(View.MeasureSpec.makeMeasureSpec(max - i14, 1073741824), makeMeasureSpec2);
if (i13 != 0) {
layoutParams3.slideable = true;
this.mSlideableView = childAt3;
z = true;
}
} else {
childAt3.measure(View.MeasureSpec.makeMeasureSpec(rect.width(), 1073741824), makeMeasureSpec2);
}
}
}
}
setMeasuredDimension(i10, i3 + getPaddingTop() + getPaddingBottom());
this.mCanSlide = z;
if (this.mDragHelper.getViewDragState() == 0 || z) {
return;
}
this.mDragHelper.abort();
}
private static int getMinimumWidth(View view) {
if (view instanceof TouchBlocker) {
return ViewCompat.getMinimumWidth(((TouchBlocker) view).getChildAt(0));
}
return ViewCompat.getMinimumWidth(view);
}
private static int measureChildHeight(View view, int i, int i2) {
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
if (layoutParams.width == 0 && layoutParams.weight > 0.0f) {
return getChildMeasureSpec(i, i2, layoutParams.height);
}
return View.MeasureSpec.makeMeasureSpec(view.getMeasuredHeight(), 1073741824);
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int i5;
int i6;
int i7;
int i8;
int i9;
boolean isLayoutRtlSupport = isLayoutRtlSupport();
int i10 = i3 - i;
int paddingRight = isLayoutRtlSupport ? getPaddingRight() : getPaddingLeft();
int paddingLeft = isLayoutRtlSupport ? getPaddingLeft() : getPaddingRight();
int paddingTop = getPaddingTop();
int childCount = getChildCount();
if (this.mFirstLayout) {
this.mSlideOffset = (this.mCanSlide && this.mPreservedOpenState) ? 0.0f : 1.0f;
}
int i11 = paddingRight;
int i12 = 0;
while (i12 < childCount) {
View childAt = getChildAt(i12);
if (childAt.getVisibility() == 8) {
i5 = i11;
} else {
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
int measuredWidth = childAt.getMeasuredWidth();
if (layoutParams.slideable) {
int i13 = i10 - paddingLeft;
int min = (Math.min(paddingRight, i13) - i11) - (layoutParams.leftMargin + layoutParams.rightMargin);
this.mSlideRange = min;
int i14 = isLayoutRtlSupport ? layoutParams.rightMargin : layoutParams.leftMargin;
layoutParams.dimWhenOffset = ((i11 + i14) + min) + (measuredWidth / 2) > i13;
int i15 = (int) (min * this.mSlideOffset);
this.mSlideOffset = i15 / this.mSlideRange;
i5 = i11 + i14 + i15;
i6 = 0;
} else if (!this.mCanSlide || (i7 = this.mParallaxBy) == 0) {
i5 = paddingRight;
i6 = 0;
} else {
i6 = (int) ((1.0f - this.mSlideOffset) * i7);
i5 = paddingRight;
}
if (isLayoutRtlSupport) {
i9 = (i10 - i5) + i6;
i8 = i9 - measuredWidth;
} else {
i8 = i5 - i6;
i9 = i8 + measuredWidth;
}
childAt.layout(i8, paddingTop, i9, childAt.getMeasuredHeight() + paddingTop);
FoldingFeature foldingFeature = this.mFoldingFeature;
paddingRight += childAt.getWidth() + Math.abs((foldingFeature != null && foldingFeature.getOrientation() == FoldingFeature.Orientation.VERTICAL && this.mFoldingFeature.isSeparating()) ? this.mFoldingFeature.getBounds().width() : 0);
}
i12++;
i11 = i5;
}
if (this.mFirstLayout) {
if (this.mCanSlide && this.mParallaxBy != 0) {
parallaxOtherViews(this.mSlideOffset);
}
updateObscuredViewsVisibility(this.mSlideableView);
}
this.mFirstLayout = false;
}
@Override // android.view.View
protected void onSizeChanged(int i, int i2, int i3, int i4) {
super.onSizeChanged(i, i2, i3, i4);
if (i != i3) {
this.mFirstLayout = true;
}
}
@Override // android.view.ViewGroup, android.view.ViewParent
public void requestChildFocus(View view, View view2) {
super.requestChildFocus(view, view2);
if (isInTouchMode() || this.mCanSlide) {
return;
}
this.mPreservedOpenState = view == this.mSlideableView;
}
@Override // android.view.ViewGroup
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
boolean z;
View childAt;
int actionMasked = motionEvent.getActionMasked();
if (!this.mCanSlide && actionMasked == 0 && getChildCount() > 1 && (childAt = getChildAt(1)) != null) {
this.mPreservedOpenState = this.mDragHelper.isViewUnder(childAt, (int) motionEvent.getX(), (int) motionEvent.getY());
}
if (!this.mCanSlide || (this.mIsUnableToDrag && actionMasked != 0)) {
this.mDragHelper.cancel();
return super.onInterceptTouchEvent(motionEvent);
}
if (actionMasked == 3 || actionMasked == 1) {
this.mDragHelper.cancel();
return false;
}
if (actionMasked == 0) {
this.mIsUnableToDrag = false;
float x = motionEvent.getX();
float y = motionEvent.getY();
this.mInitialMotionX = x;
this.mInitialMotionY = y;
if (this.mDragHelper.isViewUnder(this.mSlideableView, (int) x, (int) y) && isDimmed(this.mSlideableView)) {
z = true;
return this.mDragHelper.shouldInterceptTouchEvent(motionEvent) || z;
}
} else if (actionMasked == 2) {
float x2 = motionEvent.getX();
float y2 = motionEvent.getY();
float abs = Math.abs(x2 - this.mInitialMotionX);
float abs2 = Math.abs(y2 - this.mInitialMotionY);
if (abs > this.mDragHelper.getTouchSlop() && abs2 > abs) {
this.mDragHelper.cancel();
this.mIsUnableToDrag = true;
return false;
}
}
z = false;
if (this.mDragHelper.shouldInterceptTouchEvent(motionEvent)) {
return true;
}
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
if (!this.mCanSlide) {
return super.onTouchEvent(motionEvent);
}
this.mDragHelper.processTouchEvent(motionEvent);
int actionMasked = motionEvent.getActionMasked();
if (actionMasked == 0) {
float x = motionEvent.getX();
float y = motionEvent.getY();
this.mInitialMotionX = x;
this.mInitialMotionY = y;
} else if (actionMasked == 1 && isDimmed(this.mSlideableView)) {
float x2 = motionEvent.getX();
float y2 = motionEvent.getY();
float f = x2 - this.mInitialMotionX;
float f2 = y2 - this.mInitialMotionY;
int touchSlop = this.mDragHelper.getTouchSlop();
if ((f * f) + (f2 * f2) < touchSlop * touchSlop && this.mDragHelper.isViewUnder(this.mSlideableView, (int) x2, (int) y2)) {
closePane(0);
}
}
return true;
}
private boolean closePane(int i) {
if (!this.mCanSlide) {
this.mPreservedOpenState = false;
}
if (!this.mFirstLayout && !smoothSlideTo(1.0f, i)) {
return false;
}
this.mPreservedOpenState = false;
return true;
}
private boolean openPane(int i) {
if (!this.mCanSlide) {
this.mPreservedOpenState = true;
}
if (!this.mFirstLayout && !smoothSlideTo(0.0f, i)) {
return false;
}
this.mPreservedOpenState = true;
return true;
}
@Deprecated
public void smoothSlideOpen() {
openPane();
}
@Override // androidx.customview.widget.Openable
public void open() {
openPane();
}
public boolean openPane() {
return openPane(0);
}
@Deprecated
public void smoothSlideClosed() {
closePane();
}
@Override // androidx.customview.widget.Openable
public void close() {
closePane();
}
public boolean closePane() {
return closePane(0);
}
void onPanelDragged(int i) {
if (this.mSlideableView == null) {
this.mSlideOffset = 0.0f;
return;
}
boolean isLayoutRtlSupport = isLayoutRtlSupport();
LayoutParams layoutParams = (LayoutParams) this.mSlideableView.getLayoutParams();
int width = this.mSlideableView.getWidth();
if (isLayoutRtlSupport) {
i = (getWidth() - i) - width;
}
float paddingRight = (i - ((isLayoutRtlSupport ? getPaddingRight() : getPaddingLeft()) + (isLayoutRtlSupport ? layoutParams.rightMargin : layoutParams.leftMargin))) / this.mSlideRange;
this.mSlideOffset = paddingRight;
if (this.mParallaxBy != 0) {
parallaxOtherViews(paddingRight);
}
dispatchOnPanelSlide(this.mSlideableView);
}
@Override // android.view.ViewGroup
protected boolean drawChild(Canvas canvas, View view, long j) {
if (isLayoutRtlSupport() ^ isOpen()) {
this.mDragHelper.setEdgeTrackingEnabled(1);
Insets systemGestureInsets = getSystemGestureInsets();
if (systemGestureInsets != null) {
ViewDragHelper viewDragHelper = this.mDragHelper;
viewDragHelper.setEdgeSize(Math.max(viewDragHelper.getDefaultEdgeSize(), systemGestureInsets.left));
}
} else {
this.mDragHelper.setEdgeTrackingEnabled(2);
Insets systemGestureInsets2 = getSystemGestureInsets();
if (systemGestureInsets2 != null) {
ViewDragHelper viewDragHelper2 = this.mDragHelper;
viewDragHelper2.setEdgeSize(Math.max(viewDragHelper2.getDefaultEdgeSize(), systemGestureInsets2.right));
}
}
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
int save = canvas.save();
if (this.mCanSlide && !layoutParams.slideable && this.mSlideableView != null) {
canvas.getClipBounds(this.mTmpRect);
if (isLayoutRtlSupport()) {
Rect rect = this.mTmpRect;
rect.left = Math.max(rect.left, this.mSlideableView.getRight());
} else {
Rect rect2 = this.mTmpRect;
rect2.right = Math.min(rect2.right, this.mSlideableView.getLeft());
}
canvas.clipRect(this.mTmpRect);
}
boolean drawChild = super.drawChild(canvas, view, j);
canvas.restoreToCount(save);
return drawChild;
}
private Insets getSystemGestureInsets() {
WindowInsetsCompat rootWindowInsets;
if (!sEdgeSizeUsingSystemGestureInsets || (rootWindowInsets = ViewCompat.getRootWindowInsets(this)) == null) {
return null;
}
return rootWindowInsets.getSystemGestureInsets();
}
void invalidateChildRegion(View view) {
ViewCompat.setLayerPaint(view, ((LayoutParams) view.getLayoutParams()).dimPaint);
}
boolean smoothSlideTo(float f, int i) {
int paddingLeft;
if (!this.mCanSlide) {
return false;
}
boolean isLayoutRtlSupport = isLayoutRtlSupport();
LayoutParams layoutParams = (LayoutParams) this.mSlideableView.getLayoutParams();
if (isLayoutRtlSupport) {
paddingLeft = (int) (getWidth() - (((getPaddingRight() + layoutParams.rightMargin) + (f * this.mSlideRange)) + this.mSlideableView.getWidth()));
} else {
paddingLeft = (int) (getPaddingLeft() + layoutParams.leftMargin + (f * this.mSlideRange));
}
ViewDragHelper viewDragHelper = this.mDragHelper;
View view = this.mSlideableView;
if (!viewDragHelper.smoothSlideViewTo(view, paddingLeft, view.getTop())) {
return false;
}
setAllChildrenVisible();
ViewCompat.postInvalidateOnAnimation(this);
return true;
}
@Override // android.view.View
public void computeScroll() {
if (this.mDragHelper.continueSettling(true)) {
if (!this.mCanSlide) {
this.mDragHelper.abort();
} else {
ViewCompat.postInvalidateOnAnimation(this);
}
}
}
@Deprecated
public void setShadowDrawable(Drawable drawable) {
setShadowDrawableLeft(drawable);
}
@Deprecated
public void setShadowResource(int i) {
setShadowDrawableLeft(getResources().getDrawable(i));
}
public void setShadowResourceLeft(int i) {
setShadowDrawableLeft(ContextCompat.getDrawable(getContext(), i));
}
public void setShadowResourceRight(int i) {
setShadowDrawableRight(ContextCompat.getDrawable(getContext(), i));
}
@Override // android.view.View
public void draw(Canvas canvas) {
int i;
int i2;
super.draw(canvas);
Drawable drawable = isLayoutRtlSupport() ? this.mShadowDrawableRight : this.mShadowDrawableLeft;
View childAt = getChildCount() > 1 ? getChildAt(1) : null;
if (childAt == null || drawable == null) {
return;
}
int top = childAt.getTop();
int bottom = childAt.getBottom();
int intrinsicWidth = drawable.getIntrinsicWidth();
if (isLayoutRtlSupport()) {
i2 = childAt.getRight();
i = intrinsicWidth + i2;
} else {
int left = childAt.getLeft();
int i3 = left - intrinsicWidth;
i = left;
i2 = i3;
}
drawable.setBounds(i2, top, i, bottom);
drawable.draw(canvas);
}
private void parallaxOtherViews(float f) {
boolean isLayoutRtlSupport = isLayoutRtlSupport();
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = getChildAt(i);
if (childAt != this.mSlideableView) {
float f2 = 1.0f - this.mParallaxOffset;
int i2 = this.mParallaxBy;
this.mParallaxOffset = f;
int i3 = ((int) (f2 * i2)) - ((int) ((1.0f - f) * i2));
if (isLayoutRtlSupport) {
i3 = -i3;
}
childAt.offsetLeftAndRight(i3);
}
}
}
protected boolean canScroll(View view, boolean z, int i, int i2, int i3) {
int i4;
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
int scrollX = view.getScrollX();
int scrollY = view.getScrollY();
for (int childCount = viewGroup.getChildCount() - 1; childCount >= 0; childCount--) {
View childAt = viewGroup.getChildAt(childCount);
int i5 = i2 + scrollX;
if (i5 >= childAt.getLeft() && i5 < childAt.getRight() && (i4 = i3 + scrollY) >= childAt.getTop() && i4 < childAt.getBottom() && canScroll(childAt, true, i, i5 - childAt.getLeft(), i4 - childAt.getTop())) {
return true;
}
}
}
if (z) {
if (view.canScrollHorizontally(isLayoutRtlSupport() ? i : -i)) {
return true;
}
}
return false;
}
boolean isDimmed(View view) {
if (view == null) {
return false;
}
return this.mCanSlide && ((LayoutParams) view.getLayoutParams()).dimWhenOffset && this.mSlideOffset > 0.0f;
}
@Override // android.view.ViewGroup
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
return new LayoutParams();
}
@Override // android.view.ViewGroup
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.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.View
protected Parcelable onSaveInstanceState() {
SavedState savedState = new SavedState(super.onSaveInstanceState());
savedState.isOpen = isSlideable() ? isOpen() : this.mPreservedOpenState;
savedState.mLockMode = this.mLockMode;
return savedState;
}
@Override // android.view.View
protected void onRestoreInstanceState(Parcelable parcelable) {
if (!(parcelable instanceof SavedState)) {
super.onRestoreInstanceState(parcelable);
return;
}
SavedState savedState = (SavedState) parcelable;
super.onRestoreInstanceState(savedState.getSuperState());
if (savedState.isOpen) {
openPane();
} else {
closePane();
}
this.mPreservedOpenState = savedState.isOpen;
setLockMode(savedState.mLockMode);
}
/* loaded from: classes2.dex */
private class DragHelperCallback extends ViewDragHelper.Callback {
DragHelperCallback() {
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public boolean tryCaptureView(View view, int i) {
if (isDraggable()) {
return ((LayoutParams) view.getLayoutParams()).slideable;
}
return false;
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onViewDragStateChanged(int i) {
if (SlidingPaneLayout.this.mDragHelper.getViewDragState() == 0) {
if (SlidingPaneLayout.this.mSlideOffset == 1.0f) {
SlidingPaneLayout slidingPaneLayout = SlidingPaneLayout.this;
slidingPaneLayout.updateObscuredViewsVisibility(slidingPaneLayout.mSlideableView);
SlidingPaneLayout slidingPaneLayout2 = SlidingPaneLayout.this;
slidingPaneLayout2.dispatchOnPanelClosed(slidingPaneLayout2.mSlideableView);
SlidingPaneLayout.this.mPreservedOpenState = false;
return;
}
SlidingPaneLayout slidingPaneLayout3 = SlidingPaneLayout.this;
slidingPaneLayout3.dispatchOnPanelOpened(slidingPaneLayout3.mSlideableView);
SlidingPaneLayout.this.mPreservedOpenState = true;
}
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onViewCaptured(View view, int i) {
SlidingPaneLayout.this.setAllChildrenVisible();
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onViewPositionChanged(View view, int i, int i2, int i3, int i4) {
SlidingPaneLayout.this.onPanelDragged(i);
SlidingPaneLayout.this.invalidate();
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onViewReleased(View view, float f, float f2) {
int paddingLeft;
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
if (SlidingPaneLayout.this.isLayoutRtlSupport()) {
int paddingRight = SlidingPaneLayout.this.getPaddingRight() + layoutParams.rightMargin;
if (f < 0.0f || (f == 0.0f && SlidingPaneLayout.this.mSlideOffset > 0.5f)) {
paddingRight += SlidingPaneLayout.this.mSlideRange;
}
paddingLeft = (SlidingPaneLayout.this.getWidth() - paddingRight) - SlidingPaneLayout.this.mSlideableView.getWidth();
} else {
paddingLeft = layoutParams.leftMargin + SlidingPaneLayout.this.getPaddingLeft();
if (f > 0.0f || (f == 0.0f && SlidingPaneLayout.this.mSlideOffset > 0.5f)) {
paddingLeft += SlidingPaneLayout.this.mSlideRange;
}
}
SlidingPaneLayout.this.mDragHelper.settleCapturedViewAt(paddingLeft, view.getTop());
SlidingPaneLayout.this.invalidate();
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public int getViewHorizontalDragRange(View view) {
return SlidingPaneLayout.this.mSlideRange;
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public int clampViewPositionHorizontal(View view, int i, int i2) {
LayoutParams layoutParams = (LayoutParams) SlidingPaneLayout.this.mSlideableView.getLayoutParams();
if (SlidingPaneLayout.this.isLayoutRtlSupport()) {
int width = SlidingPaneLayout.this.getWidth() - ((SlidingPaneLayout.this.getPaddingRight() + layoutParams.rightMargin) + SlidingPaneLayout.this.mSlideableView.getWidth());
return Math.max(Math.min(i, width), width - SlidingPaneLayout.this.mSlideRange);
}
int paddingLeft = SlidingPaneLayout.this.getPaddingLeft() + layoutParams.leftMargin;
return Math.min(Math.max(i, paddingLeft), SlidingPaneLayout.this.mSlideRange + paddingLeft);
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public int clampViewPositionVertical(View view, int i, int i2) {
return view.getTop();
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onEdgeTouched(int i, int i2) {
if (isDraggable()) {
SlidingPaneLayout.this.mDragHelper.captureChildView(SlidingPaneLayout.this.mSlideableView, i2);
}
}
@Override // androidx.customview.widget.ViewDragHelper.Callback
public void onEdgeDragStarted(int i, int i2) {
if (isDraggable()) {
SlidingPaneLayout.this.mDragHelper.captureChildView(SlidingPaneLayout.this.mSlideableView, i2);
}
}
private boolean isDraggable() {
if (SlidingPaneLayout.this.mIsUnableToDrag || SlidingPaneLayout.this.getLockMode() == 3) {
return false;
}
if (SlidingPaneLayout.this.isOpen() && SlidingPaneLayout.this.getLockMode() == 1) {
return false;
}
return SlidingPaneLayout.this.isOpen() || SlidingPaneLayout.this.getLockMode() != 2;
}
}
/* loaded from: classes2.dex */
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
private static final int[] ATTRS = {R.attr.layout_weight};
Paint dimPaint;
boolean dimWhenOffset;
boolean slideable;
public float weight;
public LayoutParams() {
super(-1, -1);
this.weight = 0.0f;
}
public LayoutParams(int i, int i2) {
super(i, i2);
this.weight = 0.0f;
}
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
super(layoutParams);
this.weight = 0.0f;
}
public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) {
super(marginLayoutParams);
this.weight = 0.0f;
}
public LayoutParams(LayoutParams layoutParams) {
super((ViewGroup.MarginLayoutParams) layoutParams);
this.weight = 0.0f;
this.weight = layoutParams.weight;
}
public LayoutParams(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.weight = 0.0f;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ATTRS);
this.weight = obtainStyledAttributes.getFloat(0, 0.0f);
obtainStyledAttributes.recycle();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class SavedState extends AbsSavedState {
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: androidx.slidingpanelayout.widget.SlidingPaneLayout.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, null);
}
@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];
}
};
boolean isOpen;
int mLockMode;
SavedState(Parcelable parcelable) {
super(parcelable);
}
SavedState(Parcel parcel, ClassLoader classLoader) {
super(parcel, classLoader);
this.isOpen = parcel.readInt() != 0;
this.mLockMode = parcel.readInt();
}
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(this.isOpen ? 1 : 0);
parcel.writeInt(this.mLockMode);
}
}
/* loaded from: classes2.dex */
class AccessibilityDelegate extends AccessibilityDelegateCompat {
private final Rect mTmpRect = new Rect();
AccessibilityDelegate() {
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
AccessibilityNodeInfoCompat obtain = AccessibilityNodeInfoCompat.obtain(accessibilityNodeInfoCompat);
super.onInitializeAccessibilityNodeInfo(view, obtain);
copyNodeInfoNoChildren(accessibilityNodeInfoCompat, obtain);
obtain.recycle();
accessibilityNodeInfoCompat.setClassName(SlidingPaneLayout.ACCESSIBILITY_CLASS_NAME);
accessibilityNodeInfoCompat.setSource(view);
Object parentForAccessibility = ViewCompat.getParentForAccessibility(view);
if (parentForAccessibility instanceof View) {
accessibilityNodeInfoCompat.setParent((View) parentForAccessibility);
}
int childCount = SlidingPaneLayout.this.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = SlidingPaneLayout.this.getChildAt(i);
if (!filter(childAt) && childAt.getVisibility() == 0) {
ViewCompat.setImportantForAccessibility(childAt, 1);
accessibilityNodeInfoCompat.addChild(childAt);
}
}
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
super.onInitializeAccessibilityEvent(view, accessibilityEvent);
accessibilityEvent.setClassName(SlidingPaneLayout.ACCESSIBILITY_CLASS_NAME);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public boolean onRequestSendAccessibilityEvent(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
if (filter(view)) {
return false;
}
return super.onRequestSendAccessibilityEvent(viewGroup, view, accessibilityEvent);
}
public boolean filter(View view) {
return SlidingPaneLayout.this.isDimmed(view);
}
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.setClickable(accessibilityNodeInfoCompat2.isClickable());
accessibilityNodeInfoCompat.setFocusable(accessibilityNodeInfoCompat2.isFocusable());
accessibilityNodeInfoCompat.setFocused(accessibilityNodeInfoCompat2.isFocused());
accessibilityNodeInfoCompat.setAccessibilityFocused(accessibilityNodeInfoCompat2.isAccessibilityFocused());
accessibilityNodeInfoCompat.setSelected(accessibilityNodeInfoCompat2.isSelected());
accessibilityNodeInfoCompat.setLongClickable(accessibilityNodeInfoCompat2.isLongClickable());
accessibilityNodeInfoCompat.addAction(accessibilityNodeInfoCompat2.getActions());
accessibilityNodeInfoCompat.setMovementGranularities(accessibilityNodeInfoCompat2.getMovementGranularities());
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class TouchBlocker extends FrameLayout {
@Override // android.view.View
public boolean onGenericMotionEvent(MotionEvent motionEvent) {
return true;
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
return true;
}
TouchBlocker(View view) {
super(view.getContext());
addView(view);
}
}
/* loaded from: classes2.dex */
private class DisableLayerRunnable implements Runnable {
final View mChildView;
DisableLayerRunnable(View view) {
this.mChildView = view;
}
@Override // java.lang.Runnable
public void run() {
if (this.mChildView.getParent() == SlidingPaneLayout.this) {
this.mChildView.setLayerType(0, null);
SlidingPaneLayout.this.invalidateChildRegion(this.mChildView);
}
SlidingPaneLayout.this.mPostedRunnables.remove(this);
}
}
boolean isLayoutRtlSupport() {
return ViewCompat.getLayoutDirection(this) == 1;
}
private ArrayList<Rect> splitViewPositions() {
Rect foldBoundsInView;
FoldingFeature foldingFeature = this.mFoldingFeature;
if (foldingFeature == null || !foldingFeature.isSeparating() || this.mFoldingFeature.getBounds().left == 0 || this.mFoldingFeature.getBounds().top != 0 || (foldBoundsInView = getFoldBoundsInView(this.mFoldingFeature, this)) == null) {
return null;
}
Rect rect = new Rect(getPaddingLeft(), getPaddingTop(), Math.max(getPaddingLeft(), foldBoundsInView.left), getHeight() - getPaddingBottom());
int width = getWidth() - getPaddingRight();
return new ArrayList<>(Arrays.asList(rect, new Rect(Math.min(width, foldBoundsInView.right), getPaddingTop(), width, getHeight() - getPaddingBottom())));
}
private static Rect getFoldBoundsInView(FoldingFeature foldingFeature, View view) {
int[] iArr = new int[2];
view.getLocationInWindow(iArr);
int i = iArr[0];
Rect rect = new Rect(i, iArr[1], view.getWidth() + i, iArr[1] + view.getWidth());
Rect rect2 = new Rect(foldingFeature.getBounds());
boolean intersect = rect2.intersect(rect);
if ((rect2.width() == 0 && rect2.height() == 0) || !intersect) {
return null;
}
rect2.offset(-iArr[0], -iArr[1]);
return rect2;
}
private static Activity getActivityOrNull(Context context) {
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
return (Activity) context;
}
context = ((ContextWrapper) context).getBaseContext();
}
return null;
}
}