ADD week 5
This commit is contained in:
@ -0,0 +1,97 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class LeftSheetDelegate extends SheetDelegate {
|
||||
final SideSheetBehavior<? extends View> sheetBehavior;
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getSheetEdge() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
boolean isExpandingOutwards(float f) {
|
||||
return f > 0.0f;
|
||||
}
|
||||
|
||||
LeftSheetDelegate(SideSheetBehavior<? extends View> sideSheetBehavior) {
|
||||
this.sheetBehavior = sideSheetBehavior;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getHiddenOffset() {
|
||||
return (-this.sheetBehavior.getChildWidth()) - this.sheetBehavior.getInnerMargin();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getExpandedOffset() {
|
||||
return Math.max(0, this.sheetBehavior.getParentInnerEdge() + this.sheetBehavior.getInnerMargin());
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
boolean isReleasedCloseToInnerEdge(View view) {
|
||||
return view.getRight() < (getExpandedOffset() - getHiddenOffset()) / 2;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
boolean isSwipeSignificant(float f, float f2) {
|
||||
return SheetUtils.isSwipeMostlyHorizontal(f, f2) && Math.abs(f) > ((float) this.sheetBehavior.getSignificantVelocityThreshold());
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
boolean shouldHide(View view, float f) {
|
||||
return Math.abs(((float) view.getLeft()) + (f * this.sheetBehavior.getHideFriction())) > this.sheetBehavior.getHideThreshold();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
<V extends View> int getOuterEdge(V v) {
|
||||
return v.getRight() + this.sheetBehavior.getInnerMargin();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
float calculateSlideOffset(int i) {
|
||||
float hiddenOffset = getHiddenOffset();
|
||||
return (i - hiddenOffset) / (getExpandedOffset() - hiddenOffset);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
void updateCoplanarSiblingLayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams, int i, int i2) {
|
||||
if (i <= this.sheetBehavior.getParentWidth()) {
|
||||
marginLayoutParams.leftMargin = i2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
void updateCoplanarSiblingAdjacentMargin(ViewGroup.MarginLayoutParams marginLayoutParams, int i) {
|
||||
marginLayoutParams.leftMargin = i;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getCoplanarSiblingAdjacentMargin(ViewGroup.MarginLayoutParams marginLayoutParams) {
|
||||
return marginLayoutParams.leftMargin;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
public int getParentInnerEdge(CoordinatorLayout coordinatorLayout) {
|
||||
return coordinatorLayout.getLeft();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int calculateInnerMargin(ViewGroup.MarginLayoutParams marginLayoutParams) {
|
||||
return marginLayoutParams.leftMargin;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getMinViewPositionHorizontal() {
|
||||
return -this.sheetBehavior.getChildWidth();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getMaxViewPositionHorizontal() {
|
||||
return this.sheetBehavior.getInnerMargin();
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class RightSheetDelegate extends SheetDelegate {
|
||||
final SideSheetBehavior<? extends View> sheetBehavior;
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getSheetEdge() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
boolean isExpandingOutwards(float f) {
|
||||
return f < 0.0f;
|
||||
}
|
||||
|
||||
RightSheetDelegate(SideSheetBehavior<? extends View> sideSheetBehavior) {
|
||||
this.sheetBehavior = sideSheetBehavior;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getHiddenOffset() {
|
||||
return this.sheetBehavior.getParentWidth();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getExpandedOffset() {
|
||||
return Math.max(0, (getHiddenOffset() - this.sheetBehavior.getChildWidth()) - this.sheetBehavior.getInnerMargin());
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
boolean isReleasedCloseToInnerEdge(View view) {
|
||||
return view.getLeft() > (getHiddenOffset() + getExpandedOffset()) / 2;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
boolean isSwipeSignificant(float f, float f2) {
|
||||
return SheetUtils.isSwipeMostlyHorizontal(f, f2) && Math.abs(f) > ((float) this.sheetBehavior.getSignificantVelocityThreshold());
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
boolean shouldHide(View view, float f) {
|
||||
return Math.abs(((float) view.getRight()) + (f * this.sheetBehavior.getHideFriction())) > this.sheetBehavior.getHideThreshold();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
<V extends View> int getOuterEdge(V v) {
|
||||
return v.getLeft() - this.sheetBehavior.getInnerMargin();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
float calculateSlideOffset(int i) {
|
||||
float hiddenOffset = getHiddenOffset();
|
||||
return (hiddenOffset - i) / (hiddenOffset - getExpandedOffset());
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
void updateCoplanarSiblingLayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams, int i, int i2) {
|
||||
int parentWidth = this.sheetBehavior.getParentWidth();
|
||||
if (i <= parentWidth) {
|
||||
marginLayoutParams.rightMargin = parentWidth - i;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
void updateCoplanarSiblingAdjacentMargin(ViewGroup.MarginLayoutParams marginLayoutParams, int i) {
|
||||
marginLayoutParams.rightMargin = i;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getCoplanarSiblingAdjacentMargin(ViewGroup.MarginLayoutParams marginLayoutParams) {
|
||||
return marginLayoutParams.rightMargin;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
public int getParentInnerEdge(CoordinatorLayout coordinatorLayout) {
|
||||
return coordinatorLayout.getRight();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int calculateInnerMargin(ViewGroup.MarginLayoutParams marginLayoutParams) {
|
||||
return marginLayoutParams.rightMargin;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getMinViewPositionHorizontal() {
|
||||
return getExpandedOffset();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDelegate
|
||||
int getMaxViewPositionHorizontal() {
|
||||
return this.sheetBehavior.getParentWidth();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
import com.google.android.material.motion.MaterialBackHandler;
|
||||
import com.google.android.material.sidesheet.SheetCallback;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface Sheet<C extends SheetCallback> extends MaterialBackHandler {
|
||||
public static final int EDGE_LEFT = 1;
|
||||
public static final int EDGE_RIGHT = 0;
|
||||
public static final int STATE_DRAGGING = 1;
|
||||
public static final int STATE_EXPANDED = 3;
|
||||
public static final int STATE_HIDDEN = 5;
|
||||
public static final int STATE_SETTLING = 2;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SheetEdge {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SheetState {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface StableSheetState {
|
||||
}
|
||||
|
||||
void addCallback(C c);
|
||||
|
||||
int getState();
|
||||
|
||||
void removeCallback(C c);
|
||||
|
||||
void setState(int i);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface SheetCallback {
|
||||
void onSlide(View view, float f);
|
||||
|
||||
void onStateChanged(View view, int i);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class SheetDelegate {
|
||||
abstract int calculateInnerMargin(ViewGroup.MarginLayoutParams marginLayoutParams);
|
||||
|
||||
abstract float calculateSlideOffset(int i);
|
||||
|
||||
abstract int getCoplanarSiblingAdjacentMargin(ViewGroup.MarginLayoutParams marginLayoutParams);
|
||||
|
||||
abstract int getExpandedOffset();
|
||||
|
||||
abstract int getHiddenOffset();
|
||||
|
||||
abstract int getMaxViewPositionHorizontal();
|
||||
|
||||
abstract int getMinViewPositionHorizontal();
|
||||
|
||||
abstract <V extends View> int getOuterEdge(V v);
|
||||
|
||||
abstract int getParentInnerEdge(CoordinatorLayout coordinatorLayout);
|
||||
|
||||
abstract int getSheetEdge();
|
||||
|
||||
abstract boolean isExpandingOutwards(float f);
|
||||
|
||||
abstract boolean isReleasedCloseToInnerEdge(View view);
|
||||
|
||||
abstract boolean isSwipeSignificant(float f, float f2);
|
||||
|
||||
abstract boolean shouldHide(View view, float f);
|
||||
|
||||
abstract void updateCoplanarSiblingAdjacentMargin(ViewGroup.MarginLayoutParams marginLayoutParams, int i);
|
||||
|
||||
abstract void updateCoplanarSiblingLayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams, int i, int i2);
|
||||
|
||||
SheetDelegate() {
|
||||
}
|
||||
}
|
@ -0,0 +1,289 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.appcompat.app.AppCompatDialog;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.AccessibilityDelegateCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.motion.MaterialBackOrchestrator;
|
||||
import com.google.android.material.sidesheet.SheetCallback;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class SheetDialog<C extends SheetCallback> extends AppCompatDialog {
|
||||
private static final int COORDINATOR_LAYOUT_ID = R.id.coordinator;
|
||||
private static final int TOUCH_OUTSIDE_ID = R.id.touch_outside;
|
||||
private MaterialBackOrchestrator backOrchestrator;
|
||||
private Sheet<C> behavior;
|
||||
boolean cancelable;
|
||||
private boolean canceledOnTouchOutside;
|
||||
private boolean canceledOnTouchOutsideSet;
|
||||
private FrameLayout container;
|
||||
boolean dismissWithAnimation;
|
||||
private FrameLayout sheet;
|
||||
|
||||
abstract void addSheetCancelOnHideCallback(Sheet<C> sheet);
|
||||
|
||||
abstract Sheet<C> getBehaviorFromSheet(FrameLayout frameLayout);
|
||||
|
||||
abstract int getDialogId();
|
||||
|
||||
abstract int getLayoutResId();
|
||||
|
||||
abstract int getStateOnStart();
|
||||
|
||||
public boolean isDismissWithSheetAnimationEnabled() {
|
||||
return this.dismissWithAnimation;
|
||||
}
|
||||
|
||||
public void setDismissWithSheetAnimationEnabled(boolean z) {
|
||||
this.dismissWithAnimation = z;
|
||||
}
|
||||
|
||||
SheetDialog(Context context, int i, int i2, int i3) {
|
||||
super(context, getThemeResId(context, i, i2, i3));
|
||||
this.cancelable = true;
|
||||
this.canceledOnTouchOutside = true;
|
||||
supportRequestWindowFeature(1);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
public void setContentView(int i) {
|
||||
super.setContentView(wrapInSheet(i, null, null));
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
public void setContentView(View view) {
|
||||
super.setContentView(wrapInSheet(0, view, null));
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
|
||||
super.setContentView(wrapInSheet(0, view, layoutParams));
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.setStatusBarColor(0);
|
||||
window.addFlags(Integer.MIN_VALUE);
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
window.addFlags(67108864);
|
||||
}
|
||||
window.setLayout(-1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog
|
||||
public void setCancelable(boolean z) {
|
||||
super.setCancelable(z);
|
||||
if (this.cancelable != z) {
|
||||
this.cancelable = z;
|
||||
}
|
||||
if (getWindow() != null) {
|
||||
updateListeningForBackCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateListeningForBackCallbacks() {
|
||||
MaterialBackOrchestrator materialBackOrchestrator = this.backOrchestrator;
|
||||
if (materialBackOrchestrator == null) {
|
||||
return;
|
||||
}
|
||||
if (this.cancelable) {
|
||||
materialBackOrchestrator.startListeningForBackCallbacks();
|
||||
} else {
|
||||
materialBackOrchestrator.stopListeningForBackCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.activity.ComponentDialog, android.app.Dialog
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
Sheet<C> sheet = this.behavior;
|
||||
if (sheet == null || sheet.getState() != 5) {
|
||||
return;
|
||||
}
|
||||
this.behavior.setState(getStateOnStart());
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog, android.view.Window.Callback
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
maybeUpdateWindowAnimationsBasedOnLayoutDirection();
|
||||
updateListeningForBackCallbacks();
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog, android.view.Window.Callback
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
MaterialBackOrchestrator materialBackOrchestrator = this.backOrchestrator;
|
||||
if (materialBackOrchestrator != null) {
|
||||
materialBackOrchestrator.stopListeningForBackCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog, android.content.DialogInterface
|
||||
public void cancel() {
|
||||
Sheet<C> behavior = getBehavior();
|
||||
if (!this.dismissWithAnimation || behavior.getState() == 5) {
|
||||
super.cancel();
|
||||
} else {
|
||||
behavior.setState(5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog
|
||||
public void setCanceledOnTouchOutside(boolean z) {
|
||||
super.setCanceledOnTouchOutside(z);
|
||||
if (z && !this.cancelable) {
|
||||
this.cancelable = true;
|
||||
}
|
||||
this.canceledOnTouchOutside = z;
|
||||
this.canceledOnTouchOutsideSet = true;
|
||||
}
|
||||
|
||||
private void ensureContainerAndBehavior() {
|
||||
if (this.container == null) {
|
||||
FrameLayout frameLayout = (FrameLayout) View.inflate(getContext(), getLayoutResId(), null);
|
||||
this.container = frameLayout;
|
||||
FrameLayout frameLayout2 = (FrameLayout) frameLayout.findViewById(getDialogId());
|
||||
this.sheet = frameLayout2;
|
||||
Sheet<C> behaviorFromSheet = getBehaviorFromSheet(frameLayout2);
|
||||
this.behavior = behaviorFromSheet;
|
||||
addSheetCancelOnHideCallback(behaviorFromSheet);
|
||||
this.backOrchestrator = new MaterialBackOrchestrator(this.behavior, this.sheet);
|
||||
}
|
||||
}
|
||||
|
||||
private FrameLayout getContainer() {
|
||||
if (this.container == null) {
|
||||
ensureContainerAndBehavior();
|
||||
}
|
||||
return this.container;
|
||||
}
|
||||
|
||||
private FrameLayout getSheet() {
|
||||
if (this.sheet == null) {
|
||||
ensureContainerAndBehavior();
|
||||
}
|
||||
return this.sheet;
|
||||
}
|
||||
|
||||
Sheet<C> getBehavior() {
|
||||
if (this.behavior == null) {
|
||||
ensureContainerAndBehavior();
|
||||
}
|
||||
return this.behavior;
|
||||
}
|
||||
|
||||
private View wrapInSheet(int i, View view, ViewGroup.LayoutParams layoutParams) {
|
||||
ensureContainerAndBehavior();
|
||||
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) getContainer().findViewById(COORDINATOR_LAYOUT_ID);
|
||||
if (i != 0 && view == null) {
|
||||
view = getLayoutInflater().inflate(i, (ViewGroup) coordinatorLayout, false);
|
||||
}
|
||||
FrameLayout sheet = getSheet();
|
||||
sheet.removeAllViews();
|
||||
if (layoutParams == null) {
|
||||
sheet.addView(view);
|
||||
} else {
|
||||
sheet.addView(view, layoutParams);
|
||||
}
|
||||
coordinatorLayout.findViewById(TOUCH_OUTSIDE_ID).setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.sidesheet.SheetDialog$$ExternalSyntheticLambda0
|
||||
@Override // android.view.View.OnClickListener
|
||||
public final void onClick(View view2) {
|
||||
SheetDialog.this.m260x401f75dd(view2);
|
||||
}
|
||||
});
|
||||
ViewCompat.setAccessibilityDelegate(getSheet(), new AccessibilityDelegateCompat() { // from class: com.google.android.material.sidesheet.SheetDialog.1
|
||||
@Override // androidx.core.view.AccessibilityDelegateCompat
|
||||
public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||||
super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat);
|
||||
if (SheetDialog.this.cancelable) {
|
||||
accessibilityNodeInfoCompat.addAction(1048576);
|
||||
accessibilityNodeInfoCompat.setDismissable(true);
|
||||
} else {
|
||||
accessibilityNodeInfoCompat.setDismissable(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.AccessibilityDelegateCompat
|
||||
public boolean performAccessibilityAction(View view2, int i2, Bundle bundle) {
|
||||
if (i2 == 1048576 && SheetDialog.this.cancelable) {
|
||||
SheetDialog.this.cancel();
|
||||
return true;
|
||||
}
|
||||
return super.performAccessibilityAction(view2, i2, bundle);
|
||||
}
|
||||
});
|
||||
return this.container;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$wrapInSheet$0$com-google-android-material-sidesheet-SheetDialog, reason: not valid java name */
|
||||
/* synthetic */ void m260x401f75dd(View view) {
|
||||
if (this.cancelable && isShowing() && shouldWindowCloseOnTouchOutside()) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSheetEdge(int i) {
|
||||
FrameLayout frameLayout = this.sheet;
|
||||
if (frameLayout == null) {
|
||||
throw new IllegalStateException("Sheet view reference is null; sheet edge cannot be changed if the sheet view is null.");
|
||||
}
|
||||
if (ViewCompat.isLaidOut(frameLayout)) {
|
||||
throw new IllegalStateException("Sheet view has been laid out; sheet edge cannot be changed once the sheet has been laid out.");
|
||||
}
|
||||
ViewGroup.LayoutParams layoutParams = this.sheet.getLayoutParams();
|
||||
if (layoutParams instanceof CoordinatorLayout.LayoutParams) {
|
||||
((CoordinatorLayout.LayoutParams) layoutParams).gravity = i;
|
||||
maybeUpdateWindowAnimationsBasedOnLayoutDirection();
|
||||
}
|
||||
}
|
||||
|
||||
private void maybeUpdateWindowAnimationsBasedOnLayoutDirection() {
|
||||
FrameLayout frameLayout;
|
||||
int i;
|
||||
Window window = getWindow();
|
||||
if (window == null || (frameLayout = this.sheet) == null || !(frameLayout.getLayoutParams() instanceof CoordinatorLayout.LayoutParams)) {
|
||||
return;
|
||||
}
|
||||
if (GravityCompat.getAbsoluteGravity(((CoordinatorLayout.LayoutParams) this.sheet.getLayoutParams()).gravity, ViewCompat.getLayoutDirection(this.sheet)) == 3) {
|
||||
i = R.style.Animation_Material3_SideSheetDialog_Left;
|
||||
} else {
|
||||
i = R.style.Animation_Material3_SideSheetDialog_Right;
|
||||
}
|
||||
window.setWindowAnimations(i);
|
||||
}
|
||||
|
||||
private boolean shouldWindowCloseOnTouchOutside() {
|
||||
if (!this.canceledOnTouchOutsideSet) {
|
||||
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(new int[]{android.R.attr.windowCloseOnTouchOutside});
|
||||
this.canceledOnTouchOutside = obtainStyledAttributes.getBoolean(0, true);
|
||||
obtainStyledAttributes.recycle();
|
||||
this.canceledOnTouchOutsideSet = true;
|
||||
}
|
||||
return this.canceledOnTouchOutside;
|
||||
}
|
||||
|
||||
private static int getThemeResId(Context context, int i, int i2, int i3) {
|
||||
if (i != 0) {
|
||||
return i;
|
||||
}
|
||||
TypedValue typedValue = new TypedValue();
|
||||
return context.getTheme().resolveAttribute(i2, typedValue, true) ? typedValue.resourceId : i3;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class SheetUtils {
|
||||
private SheetUtils() {
|
||||
}
|
||||
|
||||
static boolean isSwipeMostlyHorizontal(float f, float f2) {
|
||||
return Math.abs(f) > Math.abs(f2);
|
||||
}
|
||||
}
|
@ -0,0 +1,972 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import androidx.activity.BackEventCompat;
|
||||
import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.math.MathUtils;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityViewCommand;
|
||||
import androidx.customview.view.AbsSavedState;
|
||||
import androidx.customview.widget.ViewDragHelper;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.motion.MaterialSideContainerBackHelper;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.google.android.material.sidesheet.SideSheetBehavior;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SideSheetBehavior<V extends View> extends CoordinatorLayout.Behavior<V> implements Sheet<SideSheetCallback> {
|
||||
private static final int DEFAULT_ACCESSIBILITY_PANE_TITLE = R.string.side_sheet_accessibility_pane_title;
|
||||
private static final int DEF_STYLE_RES = R.style.Widget_Material3_SideSheet;
|
||||
private static final float HIDE_FRICTION = 0.1f;
|
||||
private static final float HIDE_THRESHOLD = 0.5f;
|
||||
private static final int NO_MAX_SIZE = -1;
|
||||
static final int SIGNIFICANT_VEL_THRESHOLD = 500;
|
||||
private ColorStateList backgroundTint;
|
||||
private final Set<SideSheetCallback> callbacks;
|
||||
private int childWidth;
|
||||
private int coplanarSiblingViewId;
|
||||
private WeakReference<View> coplanarSiblingViewRef;
|
||||
private final ViewDragHelper.Callback dragCallback;
|
||||
private boolean draggable;
|
||||
private float elevation;
|
||||
private float hideFriction;
|
||||
private boolean ignoreEvents;
|
||||
private int initialX;
|
||||
private int innerMargin;
|
||||
private int lastStableState;
|
||||
private MaterialShapeDrawable materialShapeDrawable;
|
||||
private float maximumVelocity;
|
||||
private int parentInnerEdge;
|
||||
private int parentWidth;
|
||||
private ShapeAppearanceModel shapeAppearanceModel;
|
||||
private SheetDelegate sheetDelegate;
|
||||
private MaterialSideContainerBackHelper sideContainerBackHelper;
|
||||
private int state;
|
||||
private final SideSheetBehavior<V>.StateSettlingTracker stateSettlingTracker;
|
||||
private VelocityTracker velocityTracker;
|
||||
private ViewDragHelper viewDragHelper;
|
||||
private WeakReference<V> viewRef;
|
||||
|
||||
private boolean shouldHandleDraggingWithHelper() {
|
||||
return this.viewDragHelper != null && (this.draggable || this.state == 1);
|
||||
}
|
||||
|
||||
MaterialSideContainerBackHelper getBackHelper() {
|
||||
return this.sideContainerBackHelper;
|
||||
}
|
||||
|
||||
int getChildWidth() {
|
||||
return this.childWidth;
|
||||
}
|
||||
|
||||
public float getHideFriction() {
|
||||
return this.hideFriction;
|
||||
}
|
||||
|
||||
float getHideThreshold() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
int getInnerMargin() {
|
||||
return this.innerMargin;
|
||||
}
|
||||
|
||||
public int getLastStableState() {
|
||||
return this.lastStableState;
|
||||
}
|
||||
|
||||
int getParentInnerEdge() {
|
||||
return this.parentInnerEdge;
|
||||
}
|
||||
|
||||
int getParentWidth() {
|
||||
return this.parentWidth;
|
||||
}
|
||||
|
||||
int getSignificantVelocityThreshold() {
|
||||
return SIGNIFICANT_VEL_THRESHOLD;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.Sheet
|
||||
public int getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
ViewDragHelper getViewDragHelper() {
|
||||
return this.viewDragHelper;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return this.draggable;
|
||||
}
|
||||
|
||||
public void setDraggable(boolean z) {
|
||||
this.draggable = z;
|
||||
}
|
||||
|
||||
public void setHideFriction(float f) {
|
||||
this.hideFriction = f;
|
||||
}
|
||||
|
||||
public boolean shouldSkipSmoothAnimation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public SideSheetBehavior() {
|
||||
this.stateSettlingTracker = new StateSettlingTracker();
|
||||
this.draggable = true;
|
||||
this.state = 5;
|
||||
this.lastStableState = 5;
|
||||
this.hideFriction = 0.1f;
|
||||
this.coplanarSiblingViewId = -1;
|
||||
this.callbacks = new LinkedHashSet();
|
||||
this.dragCallback = new ViewDragHelper.Callback() { // from class: com.google.android.material.sidesheet.SideSheetBehavior.1
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public boolean tryCaptureView(View view, int i) {
|
||||
return (SideSheetBehavior.this.state == 1 || SideSheetBehavior.this.viewRef == null || SideSheetBehavior.this.viewRef.get() != view) ? false : true;
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewPositionChanged(View view, int i, int i2, int i3, int i4) {
|
||||
ViewGroup.MarginLayoutParams marginLayoutParams;
|
||||
View coplanarSiblingView = SideSheetBehavior.this.getCoplanarSiblingView();
|
||||
if (coplanarSiblingView != null && (marginLayoutParams = (ViewGroup.MarginLayoutParams) coplanarSiblingView.getLayoutParams()) != null) {
|
||||
SideSheetBehavior.this.sheetDelegate.updateCoplanarSiblingLayoutParams(marginLayoutParams, view.getLeft(), view.getRight());
|
||||
coplanarSiblingView.setLayoutParams(marginLayoutParams);
|
||||
}
|
||||
SideSheetBehavior.this.dispatchOnSlide(view, i);
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewDragStateChanged(int i) {
|
||||
if (i == 1 && SideSheetBehavior.this.draggable) {
|
||||
SideSheetBehavior.this.setStateInternal(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewReleased(View view, float f, float f2) {
|
||||
int calculateTargetStateOnViewReleased = SideSheetBehavior.this.calculateTargetStateOnViewReleased(view, f, f2);
|
||||
SideSheetBehavior sideSheetBehavior = SideSheetBehavior.this;
|
||||
sideSheetBehavior.startSettling(view, calculateTargetStateOnViewReleased, sideSheetBehavior.shouldSkipSmoothAnimation());
|
||||
}
|
||||
|
||||
@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 int clampViewPositionHorizontal(View view, int i, int i2) {
|
||||
return MathUtils.clamp(i, SideSheetBehavior.this.sheetDelegate.getMinViewPositionHorizontal(), SideSheetBehavior.this.sheetDelegate.getMaxViewPositionHorizontal());
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public int getViewHorizontalDragRange(View view) {
|
||||
return SideSheetBehavior.this.childWidth + SideSheetBehavior.this.getInnerMargin();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public SideSheetBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.stateSettlingTracker = new StateSettlingTracker();
|
||||
this.draggable = true;
|
||||
this.state = 5;
|
||||
this.lastStableState = 5;
|
||||
this.hideFriction = 0.1f;
|
||||
this.coplanarSiblingViewId = -1;
|
||||
this.callbacks = new LinkedHashSet();
|
||||
this.dragCallback = new ViewDragHelper.Callback() { // from class: com.google.android.material.sidesheet.SideSheetBehavior.1
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public boolean tryCaptureView(View view, int i) {
|
||||
return (SideSheetBehavior.this.state == 1 || SideSheetBehavior.this.viewRef == null || SideSheetBehavior.this.viewRef.get() != view) ? false : true;
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewPositionChanged(View view, int i, int i2, int i3, int i4) {
|
||||
ViewGroup.MarginLayoutParams marginLayoutParams;
|
||||
View coplanarSiblingView = SideSheetBehavior.this.getCoplanarSiblingView();
|
||||
if (coplanarSiblingView != null && (marginLayoutParams = (ViewGroup.MarginLayoutParams) coplanarSiblingView.getLayoutParams()) != null) {
|
||||
SideSheetBehavior.this.sheetDelegate.updateCoplanarSiblingLayoutParams(marginLayoutParams, view.getLeft(), view.getRight());
|
||||
coplanarSiblingView.setLayoutParams(marginLayoutParams);
|
||||
}
|
||||
SideSheetBehavior.this.dispatchOnSlide(view, i);
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewDragStateChanged(int i) {
|
||||
if (i == 1 && SideSheetBehavior.this.draggable) {
|
||||
SideSheetBehavior.this.setStateInternal(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewReleased(View view, float f, float f2) {
|
||||
int calculateTargetStateOnViewReleased = SideSheetBehavior.this.calculateTargetStateOnViewReleased(view, f, f2);
|
||||
SideSheetBehavior sideSheetBehavior = SideSheetBehavior.this;
|
||||
sideSheetBehavior.startSettling(view, calculateTargetStateOnViewReleased, sideSheetBehavior.shouldSkipSmoothAnimation());
|
||||
}
|
||||
|
||||
@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 int clampViewPositionHorizontal(View view, int i, int i2) {
|
||||
return MathUtils.clamp(i, SideSheetBehavior.this.sheetDelegate.getMinViewPositionHorizontal(), SideSheetBehavior.this.sheetDelegate.getMaxViewPositionHorizontal());
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public int getViewHorizontalDragRange(View view) {
|
||||
return SideSheetBehavior.this.childWidth + SideSheetBehavior.this.getInnerMargin();
|
||||
}
|
||||
};
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.SideSheetBehavior_Layout);
|
||||
if (obtainStyledAttributes.hasValue(R.styleable.SideSheetBehavior_Layout_backgroundTint)) {
|
||||
this.backgroundTint = MaterialResources.getColorStateList(context, obtainStyledAttributes, R.styleable.SideSheetBehavior_Layout_backgroundTint);
|
||||
}
|
||||
if (obtainStyledAttributes.hasValue(R.styleable.SideSheetBehavior_Layout_shapeAppearance)) {
|
||||
this.shapeAppearanceModel = ShapeAppearanceModel.builder(context, attributeSet, 0, DEF_STYLE_RES).build();
|
||||
}
|
||||
if (obtainStyledAttributes.hasValue(R.styleable.SideSheetBehavior_Layout_coplanarSiblingViewId)) {
|
||||
setCoplanarSiblingViewId(obtainStyledAttributes.getResourceId(R.styleable.SideSheetBehavior_Layout_coplanarSiblingViewId, -1));
|
||||
}
|
||||
createMaterialShapeDrawableIfNeeded(context);
|
||||
this.elevation = obtainStyledAttributes.getDimension(R.styleable.SideSheetBehavior_Layout_android_elevation, -1.0f);
|
||||
setDraggable(obtainStyledAttributes.getBoolean(R.styleable.SideSheetBehavior_Layout_behavior_draggable, true));
|
||||
obtainStyledAttributes.recycle();
|
||||
this.maximumVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
|
||||
}
|
||||
|
||||
private void setSheetEdge(V v, int i) {
|
||||
setSheetEdge(GravityCompat.getAbsoluteGravity(((CoordinatorLayout.LayoutParams) v.getLayoutParams()).gravity, i) == 3 ? 1 : 0);
|
||||
}
|
||||
|
||||
private void setSheetEdge(int i) {
|
||||
SheetDelegate sheetDelegate = this.sheetDelegate;
|
||||
if (sheetDelegate == null || sheetDelegate.getSheetEdge() != i) {
|
||||
if (i == 0) {
|
||||
this.sheetDelegate = new RightSheetDelegate(this);
|
||||
if (this.shapeAppearanceModel == null || hasRightMargin()) {
|
||||
return;
|
||||
}
|
||||
ShapeAppearanceModel.Builder builder = this.shapeAppearanceModel.toBuilder();
|
||||
builder.setTopRightCornerSize(0.0f).setBottomRightCornerSize(0.0f);
|
||||
updateMaterialShapeDrawable(builder.build());
|
||||
return;
|
||||
}
|
||||
if (i == 1) {
|
||||
this.sheetDelegate = new LeftSheetDelegate(this);
|
||||
if (this.shapeAppearanceModel == null || hasLeftMargin()) {
|
||||
return;
|
||||
}
|
||||
ShapeAppearanceModel.Builder builder2 = this.shapeAppearanceModel.toBuilder();
|
||||
builder2.setTopLeftCornerSize(0.0f).setBottomLeftCornerSize(0.0f);
|
||||
updateMaterialShapeDrawable(builder2.build());
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid sheet edge position value: " + i + ". Must be 0 or 1.");
|
||||
}
|
||||
}
|
||||
|
||||
private int getGravityFromSheetEdge() {
|
||||
SheetDelegate sheetDelegate = this.sheetDelegate;
|
||||
return (sheetDelegate == null || sheetDelegate.getSheetEdge() == 0) ? 5 : 3;
|
||||
}
|
||||
|
||||
private boolean hasRightMargin() {
|
||||
CoordinatorLayout.LayoutParams viewLayoutParams = getViewLayoutParams();
|
||||
return viewLayoutParams != null && viewLayoutParams.rightMargin > 0;
|
||||
}
|
||||
|
||||
private boolean hasLeftMargin() {
|
||||
CoordinatorLayout.LayoutParams viewLayoutParams = getViewLayoutParams();
|
||||
return viewLayoutParams != null && viewLayoutParams.leftMargin > 0;
|
||||
}
|
||||
|
||||
private CoordinatorLayout.LayoutParams getViewLayoutParams() {
|
||||
V v;
|
||||
WeakReference<V> weakReference = this.viewRef;
|
||||
if (weakReference == null || (v = weakReference.get()) == null || !(v.getLayoutParams() instanceof CoordinatorLayout.LayoutParams)) {
|
||||
return null;
|
||||
}
|
||||
return (CoordinatorLayout.LayoutParams) v.getLayoutParams();
|
||||
}
|
||||
|
||||
private void updateMaterialShapeDrawable(ShapeAppearanceModel shapeAppearanceModel) {
|
||||
MaterialShapeDrawable materialShapeDrawable = this.materialShapeDrawable;
|
||||
if (materialShapeDrawable != null) {
|
||||
materialShapeDrawable.setShapeAppearanceModel(shapeAppearanceModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void expand() {
|
||||
setState(3);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
setState(5);
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public Parcelable onSaveInstanceState(CoordinatorLayout coordinatorLayout, V v) {
|
||||
return new SavedState(super.onSaveInstanceState(coordinatorLayout, v), (SideSheetBehavior<?>) this);
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public void onRestoreInstanceState(CoordinatorLayout coordinatorLayout, V v, Parcelable parcelable) {
|
||||
SavedState savedState = (SavedState) parcelable;
|
||||
if (savedState.getSuperState() != null) {
|
||||
super.onRestoreInstanceState(coordinatorLayout, v, savedState.getSuperState());
|
||||
}
|
||||
int i = (savedState.state == 1 || savedState.state == 2) ? 5 : savedState.state;
|
||||
this.state = i;
|
||||
this.lastStableState = i;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public void onAttachedToLayoutParams(CoordinatorLayout.LayoutParams layoutParams) {
|
||||
super.onAttachedToLayoutParams(layoutParams);
|
||||
this.viewRef = null;
|
||||
this.viewDragHelper = null;
|
||||
this.sideContainerBackHelper = null;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public void onDetachedFromLayoutParams() {
|
||||
super.onDetachedFromLayoutParams();
|
||||
this.viewRef = null;
|
||||
this.viewDragHelper = null;
|
||||
this.sideContainerBackHelper = null;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onMeasureChild(CoordinatorLayout coordinatorLayout, V v, int i, int i2, int i3, int i4) {
|
||||
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
|
||||
v.measure(getChildMeasureSpec(i, coordinatorLayout.getPaddingLeft() + coordinatorLayout.getPaddingRight() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i2, -1, marginLayoutParams.width), getChildMeasureSpec(i3, coordinatorLayout.getPaddingTop() + coordinatorLayout.getPaddingBottom() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i4, -1, marginLayoutParams.height));
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getChildMeasureSpec(int i, int i2, int i3, int i4) {
|
||||
int childMeasureSpec = ViewGroup.getChildMeasureSpec(i, i2, i4);
|
||||
if (i3 == -1) {
|
||||
return childMeasureSpec;
|
||||
}
|
||||
int mode = View.MeasureSpec.getMode(childMeasureSpec);
|
||||
int size = View.MeasureSpec.getSize(childMeasureSpec);
|
||||
if (mode == 1073741824) {
|
||||
return View.MeasureSpec.makeMeasureSpec(Math.min(size, i3), BasicMeasure.EXACTLY);
|
||||
}
|
||||
if (size != 0) {
|
||||
i3 = Math.min(size, i3);
|
||||
}
|
||||
return View.MeasureSpec.makeMeasureSpec(i3, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onLayoutChild(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
if (ViewCompat.getFitsSystemWindows(coordinatorLayout) && !ViewCompat.getFitsSystemWindows(v)) {
|
||||
v.setFitsSystemWindows(true);
|
||||
}
|
||||
if (this.viewRef == null) {
|
||||
this.viewRef = new WeakReference<>(v);
|
||||
this.sideContainerBackHelper = new MaterialSideContainerBackHelper(v);
|
||||
MaterialShapeDrawable materialShapeDrawable = this.materialShapeDrawable;
|
||||
if (materialShapeDrawable != null) {
|
||||
ViewCompat.setBackground(v, materialShapeDrawable);
|
||||
MaterialShapeDrawable materialShapeDrawable2 = this.materialShapeDrawable;
|
||||
float f = this.elevation;
|
||||
if (f == -1.0f) {
|
||||
f = ViewCompat.getElevation(v);
|
||||
}
|
||||
materialShapeDrawable2.setElevation(f);
|
||||
} else {
|
||||
ColorStateList colorStateList = this.backgroundTint;
|
||||
if (colorStateList != null) {
|
||||
ViewCompat.setBackgroundTintList(v, colorStateList);
|
||||
}
|
||||
}
|
||||
updateSheetVisibility(v);
|
||||
updateAccessibilityActions();
|
||||
if (ViewCompat.getImportantForAccessibility(v) == 0) {
|
||||
ViewCompat.setImportantForAccessibility(v, 1);
|
||||
}
|
||||
ensureAccessibilityPaneTitleIsSet(v);
|
||||
}
|
||||
setSheetEdge(v, i);
|
||||
if (this.viewDragHelper == null) {
|
||||
this.viewDragHelper = ViewDragHelper.create(coordinatorLayout, this.dragCallback);
|
||||
}
|
||||
int outerEdge = this.sheetDelegate.getOuterEdge(v);
|
||||
coordinatorLayout.onLayoutChild(v, i);
|
||||
this.parentWidth = coordinatorLayout.getWidth();
|
||||
this.parentInnerEdge = this.sheetDelegate.getParentInnerEdge(coordinatorLayout);
|
||||
this.childWidth = v.getWidth();
|
||||
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
|
||||
this.innerMargin = marginLayoutParams != null ? this.sheetDelegate.calculateInnerMargin(marginLayoutParams) : 0;
|
||||
ViewCompat.offsetLeftAndRight(v, calculateCurrentOffset(outerEdge, v));
|
||||
maybeAssignCoplanarSiblingViewBasedId(coordinatorLayout);
|
||||
for (SideSheetCallback sideSheetCallback : this.callbacks) {
|
||||
if (sideSheetCallback instanceof SideSheetCallback) {
|
||||
sideSheetCallback.onLayout(v);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateSheetVisibility(View view) {
|
||||
int i = this.state == 5 ? 4 : 0;
|
||||
if (view.getVisibility() != i) {
|
||||
view.setVisibility(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureAccessibilityPaneTitleIsSet(View view) {
|
||||
if (ViewCompat.getAccessibilityPaneTitle(view) == null) {
|
||||
ViewCompat.setAccessibilityPaneTitle(view, view.getResources().getString(DEFAULT_ACCESSIBILITY_PANE_TITLE));
|
||||
}
|
||||
}
|
||||
|
||||
private void maybeAssignCoplanarSiblingViewBasedId(CoordinatorLayout coordinatorLayout) {
|
||||
int i;
|
||||
View findViewById;
|
||||
if (this.coplanarSiblingViewRef != null || (i = this.coplanarSiblingViewId) == -1 || (findViewById = coordinatorLayout.findViewById(i)) == null) {
|
||||
return;
|
||||
}
|
||||
this.coplanarSiblingViewRef = new WeakReference<>(findViewById);
|
||||
}
|
||||
|
||||
private int calculateCurrentOffset(int i, V v) {
|
||||
int i2 = this.state;
|
||||
if (i2 == 1 || i2 == 2) {
|
||||
return i - this.sheetDelegate.getOuterEdge(v);
|
||||
}
|
||||
if (i2 == 3) {
|
||||
return 0;
|
||||
}
|
||||
if (i2 == 5) {
|
||||
return this.sheetDelegate.getHiddenOffset();
|
||||
}
|
||||
throw new IllegalStateException("Unexpected value: " + this.state);
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onInterceptTouchEvent(CoordinatorLayout coordinatorLayout, V v, MotionEvent motionEvent) {
|
||||
ViewDragHelper viewDragHelper;
|
||||
if (!shouldInterceptTouchEvent(v)) {
|
||||
this.ignoreEvents = true;
|
||||
return false;
|
||||
}
|
||||
int actionMasked = motionEvent.getActionMasked();
|
||||
if (actionMasked == 0) {
|
||||
resetVelocity();
|
||||
}
|
||||
if (this.velocityTracker == null) {
|
||||
this.velocityTracker = VelocityTracker.obtain();
|
||||
}
|
||||
this.velocityTracker.addMovement(motionEvent);
|
||||
if (actionMasked == 0) {
|
||||
this.initialX = (int) motionEvent.getX();
|
||||
} else if ((actionMasked == 1 || actionMasked == 3) && this.ignoreEvents) {
|
||||
this.ignoreEvents = false;
|
||||
return false;
|
||||
}
|
||||
return (this.ignoreEvents || (viewDragHelper = this.viewDragHelper) == null || !viewDragHelper.shouldInterceptTouchEvent(motionEvent)) ? false : true;
|
||||
}
|
||||
|
||||
private boolean shouldInterceptTouchEvent(V v) {
|
||||
return (v.isShown() || ViewCompat.getAccessibilityPaneTitle(v) != null) && this.draggable;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onTouchEvent(CoordinatorLayout coordinatorLayout, V v, MotionEvent motionEvent) {
|
||||
if (!v.isShown()) {
|
||||
return false;
|
||||
}
|
||||
int actionMasked = motionEvent.getActionMasked();
|
||||
if (this.state == 1 && actionMasked == 0) {
|
||||
return true;
|
||||
}
|
||||
if (shouldHandleDraggingWithHelper()) {
|
||||
this.viewDragHelper.processTouchEvent(motionEvent);
|
||||
}
|
||||
if (actionMasked == 0) {
|
||||
resetVelocity();
|
||||
}
|
||||
if (this.velocityTracker == null) {
|
||||
this.velocityTracker = VelocityTracker.obtain();
|
||||
}
|
||||
this.velocityTracker.addMovement(motionEvent);
|
||||
if (shouldHandleDraggingWithHelper() && actionMasked == 2 && !this.ignoreEvents && isDraggedFarEnough(motionEvent)) {
|
||||
this.viewDragHelper.captureChildView(v, motionEvent.getPointerId(motionEvent.getActionIndex()));
|
||||
}
|
||||
return !this.ignoreEvents;
|
||||
}
|
||||
|
||||
private boolean isDraggedFarEnough(MotionEvent motionEvent) {
|
||||
return shouldHandleDraggingWithHelper() && calculateDragDistance((float) this.initialX, motionEvent.getX()) > ((float) this.viewDragHelper.getTouchSlop());
|
||||
}
|
||||
|
||||
private float calculateDragDistance(float f, float f2) {
|
||||
return Math.abs(f - f2);
|
||||
}
|
||||
|
||||
public int getExpandedOffset() {
|
||||
return this.sheetDelegate.getExpandedOffset();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.Sheet
|
||||
public void addCallback(SideSheetCallback sideSheetCallback) {
|
||||
this.callbacks.add(sideSheetCallback);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.Sheet
|
||||
public void removeCallback(SideSheetCallback sideSheetCallback) {
|
||||
this.callbacks.remove(sideSheetCallback);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.Sheet
|
||||
public void setState(final int i) {
|
||||
if (i == 1 || i == 2) {
|
||||
StringBuilder sb = new StringBuilder("STATE_");
|
||||
sb.append(i == 1 ? "DRAGGING" : "SETTLING");
|
||||
sb.append(" should not be set externally.");
|
||||
throw new IllegalArgumentException(sb.toString());
|
||||
}
|
||||
WeakReference<V> weakReference = this.viewRef;
|
||||
if (weakReference == null || weakReference.get() == null) {
|
||||
setStateInternal(i);
|
||||
} else {
|
||||
runAfterLayout(this.viewRef.get(), new Runnable() { // from class: com.google.android.material.sidesheet.SideSheetBehavior$$ExternalSyntheticLambda1
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
SideSheetBehavior.this.m263xc0f1d0a9(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* renamed from: lambda$setState$0$com-google-android-material-sidesheet-SideSheetBehavior, reason: not valid java name */
|
||||
/* synthetic */ void m263xc0f1d0a9(int i) {
|
||||
V v = this.viewRef.get();
|
||||
if (v != null) {
|
||||
startSettling(v, i, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void runAfterLayout(V v, Runnable runnable) {
|
||||
if (isLayingOut(v)) {
|
||||
v.post(runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLayingOut(V v) {
|
||||
ViewParent parent = v.getParent();
|
||||
return parent != null && parent.isLayoutRequested() && ViewCompat.isAttachedToWindow(v);
|
||||
}
|
||||
|
||||
void setStateInternal(int i) {
|
||||
V v;
|
||||
if (this.state == i) {
|
||||
return;
|
||||
}
|
||||
this.state = i;
|
||||
if (i == 3 || i == 5) {
|
||||
this.lastStableState = i;
|
||||
}
|
||||
WeakReference<V> weakReference = this.viewRef;
|
||||
if (weakReference == null || (v = weakReference.get()) == null) {
|
||||
return;
|
||||
}
|
||||
updateSheetVisibility(v);
|
||||
Iterator<SideSheetCallback> it = this.callbacks.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onStateChanged(v, i);
|
||||
}
|
||||
updateAccessibilityActions();
|
||||
}
|
||||
|
||||
private void resetVelocity() {
|
||||
VelocityTracker velocityTracker = this.velocityTracker;
|
||||
if (velocityTracker != null) {
|
||||
velocityTracker.recycle();
|
||||
this.velocityTracker = null;
|
||||
}
|
||||
}
|
||||
|
||||
boolean shouldHide(View view, float f) {
|
||||
return this.sheetDelegate.shouldHide(view, f);
|
||||
}
|
||||
|
||||
private void createMaterialShapeDrawableIfNeeded(Context context) {
|
||||
if (this.shapeAppearanceModel == null) {
|
||||
return;
|
||||
}
|
||||
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(this.shapeAppearanceModel);
|
||||
this.materialShapeDrawable = materialShapeDrawable;
|
||||
materialShapeDrawable.initializeElevationOverlay(context);
|
||||
ColorStateList colorStateList = this.backgroundTint;
|
||||
if (colorStateList != null) {
|
||||
this.materialShapeDrawable.setFillColor(colorStateList);
|
||||
return;
|
||||
}
|
||||
TypedValue typedValue = new TypedValue();
|
||||
context.getTheme().resolveAttribute(android.R.attr.colorBackground, typedValue, true);
|
||||
this.materialShapeDrawable.setTint(typedValue.data);
|
||||
}
|
||||
|
||||
float getXVelocity() {
|
||||
VelocityTracker velocityTracker = this.velocityTracker;
|
||||
if (velocityTracker == null) {
|
||||
return 0.0f;
|
||||
}
|
||||
velocityTracker.computeCurrentVelocity(1000, this.maximumVelocity);
|
||||
return this.velocityTracker.getXVelocity();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void startSettling(View view, int i, boolean z) {
|
||||
if (isSettling(view, i, z)) {
|
||||
setStateInternal(2);
|
||||
this.stateSettlingTracker.continueSettlingToState(i);
|
||||
} else {
|
||||
setStateInternal(i);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSettling(View view, int i, boolean z) {
|
||||
int outerEdgeOffsetForState = getOuterEdgeOffsetForState(i);
|
||||
ViewDragHelper viewDragHelper = getViewDragHelper();
|
||||
return viewDragHelper != null && (!z ? !viewDragHelper.smoothSlideViewTo(view, outerEdgeOffsetForState, view.getTop()) : !viewDragHelper.settleCapturedViewAt(outerEdgeOffsetForState, view.getTop()));
|
||||
}
|
||||
|
||||
int getOuterEdgeOffsetForState(int i) {
|
||||
if (i == 3) {
|
||||
return getExpandedOffset();
|
||||
}
|
||||
if (i == 5) {
|
||||
return this.sheetDelegate.getHiddenOffset();
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid state to get outer edge offset: " + i);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int calculateTargetStateOnViewReleased(View view, float f, float f2) {
|
||||
if (isExpandingOutwards(f)) {
|
||||
return 3;
|
||||
}
|
||||
if (shouldHide(view, f)) {
|
||||
if (!this.sheetDelegate.isSwipeSignificant(f, f2) && !this.sheetDelegate.isReleasedCloseToInnerEdge(view)) {
|
||||
return 3;
|
||||
}
|
||||
} else if (f == 0.0f || !SheetUtils.isSwipeMostlyHorizontal(f, f2)) {
|
||||
int left = view.getLeft();
|
||||
if (Math.abs(left - getExpandedOffset()) < Math.abs(left - this.sheetDelegate.getHiddenOffset())) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
private boolean isExpandingOutwards(float f) {
|
||||
return this.sheetDelegate.isExpandingOutwards(f);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void dispatchOnSlide(View view, int i) {
|
||||
if (this.callbacks.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
float calculateSlideOffset = this.sheetDelegate.calculateSlideOffset(i);
|
||||
Iterator<SideSheetCallback> it = this.callbacks.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onSlide(view, calculateSlideOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCoplanarSiblingViewId(int i) {
|
||||
this.coplanarSiblingViewId = i;
|
||||
clearCoplanarSiblingView();
|
||||
WeakReference<V> weakReference = this.viewRef;
|
||||
if (weakReference != null) {
|
||||
V v = weakReference.get();
|
||||
if (i == -1 || !ViewCompat.isLaidOut(v)) {
|
||||
return;
|
||||
}
|
||||
v.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCoplanarSiblingView(View view) {
|
||||
this.coplanarSiblingViewId = -1;
|
||||
if (view == null) {
|
||||
clearCoplanarSiblingView();
|
||||
return;
|
||||
}
|
||||
this.coplanarSiblingViewRef = new WeakReference<>(view);
|
||||
WeakReference<V> weakReference = this.viewRef;
|
||||
if (weakReference != null) {
|
||||
V v = weakReference.get();
|
||||
if (ViewCompat.isLaidOut(v)) {
|
||||
v.requestLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public View getCoplanarSiblingView() {
|
||||
WeakReference<View> weakReference = this.coplanarSiblingViewRef;
|
||||
if (weakReference != null) {
|
||||
return weakReference.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void clearCoplanarSiblingView() {
|
||||
WeakReference<View> weakReference = this.coplanarSiblingViewRef;
|
||||
if (weakReference != null) {
|
||||
weakReference.clear();
|
||||
}
|
||||
this.coplanarSiblingViewRef = null;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.motion.MaterialBackHandler
|
||||
public void startBackProgress(BackEventCompat backEventCompat) {
|
||||
MaterialSideContainerBackHelper materialSideContainerBackHelper = this.sideContainerBackHelper;
|
||||
if (materialSideContainerBackHelper == null) {
|
||||
return;
|
||||
}
|
||||
materialSideContainerBackHelper.startBackProgress(backEventCompat);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.motion.MaterialBackHandler
|
||||
public void updateBackProgress(BackEventCompat backEventCompat) {
|
||||
MaterialSideContainerBackHelper materialSideContainerBackHelper = this.sideContainerBackHelper;
|
||||
if (materialSideContainerBackHelper == null) {
|
||||
return;
|
||||
}
|
||||
materialSideContainerBackHelper.updateBackProgress(backEventCompat, getGravityFromSheetEdge());
|
||||
updateCoplanarSiblingBackProgress();
|
||||
}
|
||||
|
||||
private void updateCoplanarSiblingBackProgress() {
|
||||
ViewGroup.MarginLayoutParams marginLayoutParams;
|
||||
WeakReference<V> weakReference = this.viewRef;
|
||||
if (weakReference == null || weakReference.get() == null) {
|
||||
return;
|
||||
}
|
||||
V v = this.viewRef.get();
|
||||
View coplanarSiblingView = getCoplanarSiblingView();
|
||||
if (coplanarSiblingView == null || (marginLayoutParams = (ViewGroup.MarginLayoutParams) coplanarSiblingView.getLayoutParams()) == null) {
|
||||
return;
|
||||
}
|
||||
this.sheetDelegate.updateCoplanarSiblingAdjacentMargin(marginLayoutParams, (int) ((this.childWidth * v.getScaleX()) + this.innerMargin));
|
||||
coplanarSiblingView.requestLayout();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.motion.MaterialBackHandler
|
||||
public void handleBackInvoked() {
|
||||
MaterialSideContainerBackHelper materialSideContainerBackHelper = this.sideContainerBackHelper;
|
||||
if (materialSideContainerBackHelper == null) {
|
||||
return;
|
||||
}
|
||||
BackEventCompat onHandleBackInvoked = materialSideContainerBackHelper.onHandleBackInvoked();
|
||||
if (onHandleBackInvoked == null || Build.VERSION.SDK_INT < 34) {
|
||||
setState(5);
|
||||
} else {
|
||||
this.sideContainerBackHelper.finishBackProgress(onHandleBackInvoked, getGravityFromSheetEdge(), new AnimatorListenerAdapter() { // from class: com.google.android.material.sidesheet.SideSheetBehavior.2
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
SideSheetBehavior.this.setStateInternal(5);
|
||||
if (SideSheetBehavior.this.viewRef == null || SideSheetBehavior.this.viewRef.get() == null) {
|
||||
return;
|
||||
}
|
||||
((View) SideSheetBehavior.this.viewRef.get()).requestLayout();
|
||||
}
|
||||
}, getCoplanarFinishAnimatorUpdateListener());
|
||||
}
|
||||
}
|
||||
|
||||
private ValueAnimator.AnimatorUpdateListener getCoplanarFinishAnimatorUpdateListener() {
|
||||
final ViewGroup.MarginLayoutParams marginLayoutParams;
|
||||
final View coplanarSiblingView = getCoplanarSiblingView();
|
||||
if (coplanarSiblingView == null || (marginLayoutParams = (ViewGroup.MarginLayoutParams) coplanarSiblingView.getLayoutParams()) == null) {
|
||||
return null;
|
||||
}
|
||||
final int coplanarSiblingAdjacentMargin = this.sheetDelegate.getCoplanarSiblingAdjacentMargin(marginLayoutParams);
|
||||
return new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.sidesheet.SideSheetBehavior$$ExternalSyntheticLambda0
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
SideSheetBehavior.this.m262xc3af8fb4(marginLayoutParams, coplanarSiblingAdjacentMargin, coplanarSiblingView, valueAnimator);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* renamed from: lambda$getCoplanarFinishAnimatorUpdateListener$1$com-google-android-material-sidesheet-SideSheetBehavior, reason: not valid java name */
|
||||
/* synthetic */ void m262xc3af8fb4(ViewGroup.MarginLayoutParams marginLayoutParams, int i, View view, ValueAnimator valueAnimator) {
|
||||
this.sheetDelegate.updateCoplanarSiblingAdjacentMargin(marginLayoutParams, AnimationUtils.lerp(i, 0, valueAnimator.getAnimatedFraction()));
|
||||
view.requestLayout();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.motion.MaterialBackHandler
|
||||
public void cancelBackProgress() {
|
||||
MaterialSideContainerBackHelper materialSideContainerBackHelper = this.sideContainerBackHelper;
|
||||
if (materialSideContainerBackHelper == null) {
|
||||
return;
|
||||
}
|
||||
materialSideContainerBackHelper.cancelBackProgress();
|
||||
}
|
||||
|
||||
class StateSettlingTracker {
|
||||
private final Runnable continueSettlingRunnable = new Runnable() { // from class: com.google.android.material.sidesheet.SideSheetBehavior$StateSettlingTracker$$ExternalSyntheticLambda0
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
SideSheetBehavior.StateSettlingTracker.this.m264xe5f914a3();
|
||||
}
|
||||
};
|
||||
private boolean isContinueSettlingRunnablePosted;
|
||||
private int targetState;
|
||||
|
||||
StateSettlingTracker() {
|
||||
}
|
||||
|
||||
/* renamed from: lambda$new$0$com-google-android-material-sidesheet-SideSheetBehavior$StateSettlingTracker, reason: not valid java name */
|
||||
/* synthetic */ void m264xe5f914a3() {
|
||||
this.isContinueSettlingRunnablePosted = false;
|
||||
if (SideSheetBehavior.this.viewDragHelper != null && SideSheetBehavior.this.viewDragHelper.continueSettling(true)) {
|
||||
continueSettlingToState(this.targetState);
|
||||
} else if (SideSheetBehavior.this.state == 2) {
|
||||
SideSheetBehavior.this.setStateInternal(this.targetState);
|
||||
}
|
||||
}
|
||||
|
||||
void continueSettlingToState(int i) {
|
||||
if (SideSheetBehavior.this.viewRef == null || SideSheetBehavior.this.viewRef.get() == null) {
|
||||
return;
|
||||
}
|
||||
this.targetState = i;
|
||||
if (this.isContinueSettlingRunnablePosted) {
|
||||
return;
|
||||
}
|
||||
ViewCompat.postOnAnimation((View) SideSheetBehavior.this.viewRef.get(), this.continueSettlingRunnable);
|
||||
this.isContinueSettlingRunnablePosted = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected static class SavedState extends AbsSavedState {
|
||||
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: com.google.android.material.sidesheet.SideSheetBehavior.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, (ClassLoader) null);
|
||||
}
|
||||
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public SavedState[] newArray(int i) {
|
||||
return new SavedState[i];
|
||||
}
|
||||
};
|
||||
final int state;
|
||||
|
||||
public SavedState(Parcel parcel) {
|
||||
this(parcel, (ClassLoader) null);
|
||||
}
|
||||
|
||||
public SavedState(Parcel parcel, ClassLoader classLoader) {
|
||||
super(parcel, classLoader);
|
||||
this.state = parcel.readInt();
|
||||
}
|
||||
|
||||
public SavedState(Parcelable parcelable, SideSheetBehavior<?> sideSheetBehavior) {
|
||||
super(parcelable);
|
||||
this.state = ((SideSheetBehavior) sideSheetBehavior).state;
|
||||
}
|
||||
|
||||
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
super.writeToParcel(parcel, i);
|
||||
parcel.writeInt(this.state);
|
||||
}
|
||||
}
|
||||
|
||||
public static <V extends View> SideSheetBehavior<V> from(V v) {
|
||||
ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
|
||||
if (!(layoutParams instanceof CoordinatorLayout.LayoutParams)) {
|
||||
throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
|
||||
}
|
||||
CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) layoutParams).getBehavior();
|
||||
if (!(behavior instanceof SideSheetBehavior)) {
|
||||
throw new IllegalArgumentException("The view is not associated with SideSheetBehavior");
|
||||
}
|
||||
return (SideSheetBehavior) behavior;
|
||||
}
|
||||
|
||||
private void updateAccessibilityActions() {
|
||||
V v;
|
||||
WeakReference<V> weakReference = this.viewRef;
|
||||
if (weakReference == null || (v = weakReference.get()) == null) {
|
||||
return;
|
||||
}
|
||||
ViewCompat.removeAccessibilityAction(v, 262144);
|
||||
ViewCompat.removeAccessibilityAction(v, 1048576);
|
||||
if (this.state != 5) {
|
||||
replaceAccessibilityActionForState(v, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_DISMISS, 5);
|
||||
}
|
||||
if (this.state != 3) {
|
||||
replaceAccessibilityActionForState(v, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_EXPAND, 3);
|
||||
}
|
||||
}
|
||||
|
||||
private void replaceAccessibilityActionForState(V v, AccessibilityNodeInfoCompat.AccessibilityActionCompat accessibilityActionCompat, int i) {
|
||||
ViewCompat.replaceAccessibilityAction(v, accessibilityActionCompat, null, createAccessibilityViewCommandForState(i));
|
||||
}
|
||||
|
||||
private AccessibilityViewCommand createAccessibilityViewCommandForState(final int i) {
|
||||
return new AccessibilityViewCommand() { // from class: com.google.android.material.sidesheet.SideSheetBehavior$$ExternalSyntheticLambda2
|
||||
@Override // androidx.core.view.accessibility.AccessibilityViewCommand
|
||||
public final boolean perform(View view, AccessibilityViewCommand.CommandArguments commandArguments) {
|
||||
return SideSheetBehavior.this.m261x564aa398(i, view, commandArguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* renamed from: lambda$createAccessibilityViewCommandForState$2$com-google-android-material-sidesheet-SideSheetBehavior, reason: not valid java name */
|
||||
/* synthetic */ boolean m261x564aa398(int i, View view, AccessibilityViewCommand.CommandArguments commandArguments) {
|
||||
setState(i);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class SideSheetCallback implements SheetCallback {
|
||||
void onLayout(View view) {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetCallback
|
||||
public abstract void onSlide(View view, float f);
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetCallback
|
||||
public abstract void onStateChanged(View view, int i);
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package com.google.android.material.sidesheet;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import com.google.android.material.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SideSheetDialog extends SheetDialog<SideSheetCallback> {
|
||||
private static final int SIDE_SHEET_DIALOG_THEME_ATTR = R.attr.sideSheetDialogTheme;
|
||||
private static final int SIDE_SHEET_DIALOG_DEFAULT_THEME_RES = R.style.Theme_Material3_Light_SideSheetDialog;
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog
|
||||
int getStateOnStart() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog, android.app.Dialog, android.content.DialogInterface
|
||||
public /* bridge */ /* synthetic */ void cancel() {
|
||||
super.cancel();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog
|
||||
public /* bridge */ /* synthetic */ boolean isDismissWithSheetAnimationEnabled() {
|
||||
return super.isDismissWithSheetAnimationEnabled();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog, android.app.Dialog, android.view.Window.Callback
|
||||
public /* bridge */ /* synthetic */ void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog, android.app.Dialog, android.view.Window.Callback
|
||||
public /* bridge */ /* synthetic */ void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog, android.app.Dialog
|
||||
public /* bridge */ /* synthetic */ void setCancelable(boolean z) {
|
||||
super.setCancelable(z);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog, android.app.Dialog
|
||||
public /* bridge */ /* synthetic */ void setCanceledOnTouchOutside(boolean z) {
|
||||
super.setCanceledOnTouchOutside(z);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog, androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
public /* bridge */ /* synthetic */ void setContentView(int i) {
|
||||
super.setContentView(i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog, androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
public /* bridge */ /* synthetic */ void setContentView(View view) {
|
||||
super.setContentView(view);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog, androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
public /* bridge */ /* synthetic */ void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
|
||||
super.setContentView(view, layoutParams);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog
|
||||
public /* bridge */ /* synthetic */ void setDismissWithSheetAnimationEnabled(boolean z) {
|
||||
super.setDismissWithSheetAnimationEnabled(z);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog
|
||||
public /* bridge */ /* synthetic */ void setSheetEdge(int i) {
|
||||
super.setSheetEdge(i);
|
||||
}
|
||||
|
||||
public SideSheetDialog(Context context) {
|
||||
this(context, 0);
|
||||
}
|
||||
|
||||
public SideSheetDialog(Context context, int i) {
|
||||
super(context, i, SIDE_SHEET_DIALOG_THEME_ATTR, SIDE_SHEET_DIALOG_DEFAULT_THEME_RES);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog
|
||||
void addSheetCancelOnHideCallback(Sheet<SideSheetCallback> sheet) {
|
||||
sheet.addCallback(new SideSheetCallback() { // from class: com.google.android.material.sidesheet.SideSheetDialog.1
|
||||
@Override // com.google.android.material.sidesheet.SideSheetCallback, com.google.android.material.sidesheet.SheetCallback
|
||||
public void onSlide(View view, float f) {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SideSheetCallback, com.google.android.material.sidesheet.SheetCallback
|
||||
public void onStateChanged(View view, int i) {
|
||||
if (i == 5) {
|
||||
SideSheetDialog.this.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog
|
||||
int getLayoutResId() {
|
||||
return R.layout.m3_side_sheet_dialog;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog
|
||||
int getDialogId() {
|
||||
return R.id.m3_side_sheet;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog
|
||||
Sheet<SideSheetCallback> getBehaviorFromSheet(FrameLayout frameLayout) {
|
||||
return SideSheetBehavior.from(frameLayout);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.sidesheet.SheetDialog
|
||||
public Sheet<SideSheetCallback> getBehavior() {
|
||||
Sheet behavior = super.getBehavior();
|
||||
if (!(behavior instanceof SideSheetBehavior)) {
|
||||
throw new IllegalStateException("The view is not associated with SideSheetBehavior");
|
||||
}
|
||||
return (SideSheetBehavior) behavior;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user