ADD week 5

This commit is contained in:
2025-03-31 16:33:42 +02:00
parent 86f265f22d
commit bf645048e6
4927 changed files with 544053 additions and 0 deletions

View File

@ -0,0 +1,420 @@
package com.google.android.material.bottomsheet;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.MotionEvent;
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.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import com.google.android.material.R;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.color.MaterialColors;
import com.google.android.material.internal.EdgeToEdgeUtils;
import com.google.android.material.internal.ViewUtils;
import com.google.android.material.motion.MaterialBackOrchestrator;
import com.google.android.material.shape.MaterialShapeDrawable;
/* loaded from: classes.dex */
public class BottomSheetDialog extends AppCompatDialog {
private MaterialBackOrchestrator backOrchestrator;
private BottomSheetBehavior<FrameLayout> behavior;
private FrameLayout bottomSheet;
private BottomSheetBehavior.BottomSheetCallback bottomSheetCallback;
boolean cancelable;
private boolean canceledOnTouchOutside;
private boolean canceledOnTouchOutsideSet;
private FrameLayout container;
private CoordinatorLayout coordinator;
boolean dismissWithAnimation;
private EdgeToEdgeCallback edgeToEdgeCallback;
private boolean edgeToEdgeEnabled;
public boolean getDismissWithAnimation() {
return this.dismissWithAnimation;
}
public boolean getEdgeToEdgeEnabled() {
return this.edgeToEdgeEnabled;
}
public void setDismissWithAnimation(boolean z) {
this.dismissWithAnimation = z;
}
public BottomSheetDialog(Context context) {
this(context, 0);
this.edgeToEdgeEnabled = getContext().getTheme().obtainStyledAttributes(new int[]{R.attr.enableEdgeToEdge}).getBoolean(0, false);
}
public BottomSheetDialog(Context context, int i) {
super(context, getThemeResId(context, i));
this.cancelable = true;
this.canceledOnTouchOutside = true;
this.bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.5
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onSlide(View view, float f) {
}
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onStateChanged(View view, int i2) {
if (i2 == 5) {
BottomSheetDialog.this.cancel();
}
}
};
supportRequestWindowFeature(1);
this.edgeToEdgeEnabled = getContext().getTheme().obtainStyledAttributes(new int[]{R.attr.enableEdgeToEdge}).getBoolean(0, false);
}
protected BottomSheetDialog(Context context, boolean z, DialogInterface.OnCancelListener onCancelListener) {
super(context, z, onCancelListener);
this.cancelable = true;
this.canceledOnTouchOutside = true;
this.bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.5
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onSlide(View view, float f) {
}
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onStateChanged(View view, int i2) {
if (i2 == 5) {
BottomSheetDialog.this.cancel();
}
}
};
supportRequestWindowFeature(1);
this.cancelable = z;
this.edgeToEdgeEnabled = getContext().getTheme().obtainStyledAttributes(new int[]{R.attr.enableEdgeToEdge}).getBoolean(0, false);
}
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
public void setContentView(int i) {
super.setContentView(wrapInBottomSheet(i, null, null));
}
@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 // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
public void setContentView(View view) {
super.setContentView(wrapInBottomSheet(0, view, null));
}
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
super.setContentView(wrapInBottomSheet(0, view, layoutParams));
}
@Override // android.app.Dialog
public void setCancelable(boolean z) {
super.setCancelable(z);
if (this.cancelable != z) {
this.cancelable = z;
BottomSheetBehavior<FrameLayout> bottomSheetBehavior = this.behavior;
if (bottomSheetBehavior != null) {
bottomSheetBehavior.setHideable(z);
}
if (getWindow() != null) {
updateListeningForBackCallbacks();
}
}
}
@Override // androidx.activity.ComponentDialog, android.app.Dialog
protected void onStart() {
super.onStart();
BottomSheetBehavior<FrameLayout> bottomSheetBehavior = this.behavior;
if (bottomSheetBehavior == null || bottomSheetBehavior.getState() != 5) {
return;
}
this.behavior.setState(4);
}
@Override // android.app.Dialog, android.view.Window.Callback
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
if (window != null) {
boolean z = this.edgeToEdgeEnabled && Color.alpha(window.getNavigationBarColor()) < 255;
FrameLayout frameLayout = this.container;
if (frameLayout != null) {
frameLayout.setFitsSystemWindows(!z);
}
CoordinatorLayout coordinatorLayout = this.coordinator;
if (coordinatorLayout != null) {
coordinatorLayout.setFitsSystemWindows(!z);
}
WindowCompat.setDecorFitsSystemWindows(window, !z);
EdgeToEdgeCallback edgeToEdgeCallback = this.edgeToEdgeCallback;
if (edgeToEdgeCallback != null) {
edgeToEdgeCallback.setWindow(window);
}
}
updateListeningForBackCallbacks();
}
@Override // android.app.Dialog, android.view.Window.Callback
public void onDetachedFromWindow() {
EdgeToEdgeCallback edgeToEdgeCallback = this.edgeToEdgeCallback;
if (edgeToEdgeCallback != null) {
edgeToEdgeCallback.setWindow(null);
}
MaterialBackOrchestrator materialBackOrchestrator = this.backOrchestrator;
if (materialBackOrchestrator != null) {
materialBackOrchestrator.stopListeningForBackCallbacks();
}
}
@Override // android.app.Dialog, android.content.DialogInterface
public void cancel() {
BottomSheetBehavior<FrameLayout> 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;
}
public BottomSheetBehavior<FrameLayout> getBehavior() {
if (this.behavior == null) {
ensureContainerAndBehavior();
}
return this.behavior;
}
private FrameLayout ensureContainerAndBehavior() {
if (this.container == null) {
FrameLayout frameLayout = (FrameLayout) View.inflate(getContext(), R.layout.design_bottom_sheet_dialog, null);
this.container = frameLayout;
this.coordinator = (CoordinatorLayout) frameLayout.findViewById(R.id.coordinator);
FrameLayout frameLayout2 = (FrameLayout) this.container.findViewById(R.id.design_bottom_sheet);
this.bottomSheet = frameLayout2;
BottomSheetBehavior<FrameLayout> from = BottomSheetBehavior.from(frameLayout2);
this.behavior = from;
from.addBottomSheetCallback(this.bottomSheetCallback);
this.behavior.setHideable(this.cancelable);
this.backOrchestrator = new MaterialBackOrchestrator(this.behavior, this.bottomSheet);
}
return this.container;
}
private View wrapInBottomSheet(int i, View view, ViewGroup.LayoutParams layoutParams) {
ensureContainerAndBehavior();
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) this.container.findViewById(R.id.coordinator);
if (i != 0 && view == null) {
view = getLayoutInflater().inflate(i, (ViewGroup) coordinatorLayout, false);
}
if (this.edgeToEdgeEnabled) {
ViewCompat.setOnApplyWindowInsetsListener(this.bottomSheet, new OnApplyWindowInsetsListener() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.1
@Override // androidx.core.view.OnApplyWindowInsetsListener
public WindowInsetsCompat onApplyWindowInsets(View view2, WindowInsetsCompat windowInsetsCompat) {
if (BottomSheetDialog.this.edgeToEdgeCallback != null) {
BottomSheetDialog.this.behavior.removeBottomSheetCallback(BottomSheetDialog.this.edgeToEdgeCallback);
}
if (windowInsetsCompat != null) {
BottomSheetDialog bottomSheetDialog = BottomSheetDialog.this;
bottomSheetDialog.edgeToEdgeCallback = new EdgeToEdgeCallback(bottomSheetDialog.bottomSheet, windowInsetsCompat);
BottomSheetDialog.this.edgeToEdgeCallback.setWindow(BottomSheetDialog.this.getWindow());
BottomSheetDialog.this.behavior.addBottomSheetCallback(BottomSheetDialog.this.edgeToEdgeCallback);
}
return windowInsetsCompat;
}
});
}
this.bottomSheet.removeAllViews();
if (layoutParams == null) {
this.bottomSheet.addView(view);
} else {
this.bottomSheet.addView(view, layoutParams);
}
coordinatorLayout.findViewById(R.id.touch_outside).setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.2
@Override // android.view.View.OnClickListener
public void onClick(View view2) {
if (BottomSheetDialog.this.cancelable && BottomSheetDialog.this.isShowing() && BottomSheetDialog.this.shouldWindowCloseOnTouchOutside()) {
BottomSheetDialog.this.cancel();
}
}
});
ViewCompat.setAccessibilityDelegate(this.bottomSheet, new AccessibilityDelegateCompat() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.3
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat);
if (BottomSheetDialog.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 && BottomSheetDialog.this.cancelable) {
BottomSheetDialog.this.cancel();
return true;
}
return super.performAccessibilityAction(view2, i2, bundle);
}
});
this.bottomSheet.setOnTouchListener(new View.OnTouchListener() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.4
@Override // android.view.View.OnTouchListener
public boolean onTouch(View view2, MotionEvent motionEvent) {
return true;
}
});
return this.container;
}
private void updateListeningForBackCallbacks() {
MaterialBackOrchestrator materialBackOrchestrator = this.backOrchestrator;
if (materialBackOrchestrator == null) {
return;
}
if (this.cancelable) {
materialBackOrchestrator.startListeningForBackCallbacks();
} else {
materialBackOrchestrator.stopListeningForBackCallbacks();
}
}
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) {
if (i != 0) {
return i;
}
TypedValue typedValue = new TypedValue();
if (context.getTheme().resolveAttribute(R.attr.bottomSheetDialogTheme, typedValue, true)) {
return typedValue.resourceId;
}
return R.style.Theme_Design_Light_BottomSheetDialog;
}
void removeDefaultCallback() {
this.behavior.removeBottomSheetCallback(this.bottomSheetCallback);
}
private static class EdgeToEdgeCallback extends BottomSheetBehavior.BottomSheetCallback {
private final WindowInsetsCompat insetsCompat;
private final Boolean lightBottomSheet;
private boolean lightStatusBar;
private Window window;
private EdgeToEdgeCallback(View view, WindowInsetsCompat windowInsetsCompat) {
ColorStateList backgroundTintList;
this.insetsCompat = windowInsetsCompat;
MaterialShapeDrawable materialShapeDrawable = BottomSheetBehavior.from(view).getMaterialShapeDrawable();
if (materialShapeDrawable != null) {
backgroundTintList = materialShapeDrawable.getFillColor();
} else {
backgroundTintList = ViewCompat.getBackgroundTintList(view);
}
if (backgroundTintList != null) {
this.lightBottomSheet = Boolean.valueOf(MaterialColors.isColorLight(backgroundTintList.getDefaultColor()));
return;
}
Integer backgroundColor = ViewUtils.getBackgroundColor(view);
if (backgroundColor != null) {
this.lightBottomSheet = Boolean.valueOf(MaterialColors.isColorLight(backgroundColor.intValue()));
} else {
this.lightBottomSheet = null;
}
}
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onStateChanged(View view, int i) {
setPaddingForPosition(view);
}
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onSlide(View view, float f) {
setPaddingForPosition(view);
}
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
void onLayout(View view) {
setPaddingForPosition(view);
}
void setWindow(Window window) {
if (this.window == window) {
return;
}
this.window = window;
if (window != null) {
this.lightStatusBar = WindowCompat.getInsetsController(window, window.getDecorView()).isAppearanceLightStatusBars();
}
}
private void setPaddingForPosition(View view) {
if (view.getTop() < this.insetsCompat.getSystemWindowInsetTop()) {
Window window = this.window;
if (window != null) {
Boolean bool = this.lightBottomSheet;
EdgeToEdgeUtils.setLightStatusBar(window, bool == null ? this.lightStatusBar : bool.booleanValue());
}
view.setPadding(view.getPaddingLeft(), this.insetsCompat.getSystemWindowInsetTop() - view.getTop(), view.getPaddingRight(), view.getPaddingBottom());
return;
}
if (view.getTop() != 0) {
Window window2 = this.window;
if (window2 != null) {
EdgeToEdgeUtils.setLightStatusBar(window2, this.lightStatusBar);
}
view.setPadding(view.getPaddingLeft(), 0, view.getPaddingRight(), view.getPaddingBottom());
}
}
}
@Deprecated
public static void setLightStatusBar(View view, boolean z) {
if (Build.VERSION.SDK_INT >= 23) {
int systemUiVisibility = view.getSystemUiVisibility();
view.setSystemUiVisibility(z ? systemUiVisibility | 8192 : systemUiVisibility & (-8193));
}
}
}

View File

@ -0,0 +1,93 @@
package com.google.android.material.bottomsheet;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import androidx.appcompat.app.AppCompatDialogFragment;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
/* loaded from: classes.dex */
public class BottomSheetDialogFragment extends AppCompatDialogFragment {
private boolean waitingForDismissAllowingStateLoss;
public BottomSheetDialogFragment() {
}
public BottomSheetDialogFragment(int i) {
super(i);
}
@Override // androidx.appcompat.app.AppCompatDialogFragment, androidx.fragment.app.DialogFragment
public Dialog onCreateDialog(Bundle bundle) {
return new BottomSheetDialog(getContext(), getTheme());
}
@Override // androidx.fragment.app.DialogFragment
public void dismiss() {
if (tryDismissWithAnimation(false)) {
return;
}
super.dismiss();
}
@Override // androidx.fragment.app.DialogFragment
public void dismissAllowingStateLoss() {
if (tryDismissWithAnimation(true)) {
return;
}
super.dismissAllowingStateLoss();
}
private boolean tryDismissWithAnimation(boolean z) {
Dialog dialog = getDialog();
if (!(dialog instanceof BottomSheetDialog)) {
return false;
}
BottomSheetDialog bottomSheetDialog = (BottomSheetDialog) dialog;
BottomSheetBehavior<FrameLayout> behavior = bottomSheetDialog.getBehavior();
if (!behavior.isHideable() || !bottomSheetDialog.getDismissWithAnimation()) {
return false;
}
dismissWithAnimation(behavior, z);
return true;
}
private void dismissWithAnimation(BottomSheetBehavior<?> bottomSheetBehavior, boolean z) {
this.waitingForDismissAllowingStateLoss = z;
if (bottomSheetBehavior.getState() == 5) {
dismissAfterAnimation();
return;
}
if (getDialog() instanceof BottomSheetDialog) {
((BottomSheetDialog) getDialog()).removeDefaultCallback();
}
bottomSheetBehavior.addBottomSheetCallback(new BottomSheetDismissCallback());
bottomSheetBehavior.setState(5);
}
/* JADX INFO: Access modifiers changed from: private */
public void dismissAfterAnimation() {
if (this.waitingForDismissAllowingStateLoss) {
super.dismissAllowingStateLoss();
} else {
super.dismiss();
}
}
private class BottomSheetDismissCallback extends BottomSheetBehavior.BottomSheetCallback {
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onSlide(View view, float f) {
}
private BottomSheetDismissCallback() {
}
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onStateChanged(View view, int i) {
if (i == 5) {
BottomSheetDialogFragment.this.dismissAfterAnimation();
}
}
}
}

View File

@ -0,0 +1,194 @@
package com.google.android.material.bottomsheet;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.accessibility.AccessibilityViewCommand;
import com.google.android.material.R;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.theme.overlay.MaterialThemeOverlay;
/* loaded from: classes.dex */
public class BottomSheetDragHandleView extends AppCompatImageView implements AccessibilityManager.AccessibilityStateChangeListener {
private static final int DEF_STYLE_RES = R.style.Widget_Material3_BottomSheet_DragHandle;
private final AccessibilityManager accessibilityManager;
private boolean accessibilityServiceEnabled;
private BottomSheetBehavior<?> bottomSheetBehavior;
private final BottomSheetBehavior.BottomSheetCallback bottomSheetCallback;
private final String clickFeedback;
private final String clickToCollapseActionLabel;
private boolean clickToExpand;
private final String clickToExpandActionLabel;
private boolean interactable;
public BottomSheetDragHandleView(Context context) {
this(context, null);
}
public BottomSheetDragHandleView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R.attr.bottomSheetDragHandleStyle);
}
public BottomSheetDragHandleView(Context context, AttributeSet attributeSet, int i) {
super(MaterialThemeOverlay.wrap(context, attributeSet, i, DEF_STYLE_RES), attributeSet, i);
this.clickToExpandActionLabel = getResources().getString(R.string.bottomsheet_action_expand);
this.clickToCollapseActionLabel = getResources().getString(R.string.bottomsheet_action_collapse);
this.clickFeedback = getResources().getString(R.string.bottomsheet_drag_handle_clicked);
this.bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() { // from class: com.google.android.material.bottomsheet.BottomSheetDragHandleView.1
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onSlide(View view, float f) {
}
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
public void onStateChanged(View view, int i2) {
BottomSheetDragHandleView.this.onBottomSheetStateChanged(i2);
}
};
this.accessibilityManager = (AccessibilityManager) getContext().getSystemService("accessibility");
updateInteractableState();
ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegateCompat() { // from class: com.google.android.material.bottomsheet.BottomSheetDragHandleView.2
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
super.onPopulateAccessibilityEvent(view, accessibilityEvent);
if (accessibilityEvent.getEventType() == 1) {
BottomSheetDragHandleView.this.expandOrCollapseBottomSheetIfPossible();
}
}
});
}
@Override // android.widget.ImageView, android.view.View
protected void onAttachedToWindow() {
super.onAttachedToWindow();
setBottomSheetBehavior(findParentBottomSheetBehavior());
AccessibilityManager accessibilityManager = this.accessibilityManager;
if (accessibilityManager != null) {
accessibilityManager.addAccessibilityStateChangeListener(this);
onAccessibilityStateChanged(this.accessibilityManager.isEnabled());
}
}
@Override // android.widget.ImageView, android.view.View
protected void onDetachedFromWindow() {
AccessibilityManager accessibilityManager = this.accessibilityManager;
if (accessibilityManager != null) {
accessibilityManager.removeAccessibilityStateChangeListener(this);
}
setBottomSheetBehavior(null);
super.onDetachedFromWindow();
}
@Override // android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener
public void onAccessibilityStateChanged(boolean z) {
this.accessibilityServiceEnabled = z;
updateInteractableState();
}
private void setBottomSheetBehavior(BottomSheetBehavior<?> bottomSheetBehavior) {
BottomSheetBehavior<?> bottomSheetBehavior2 = this.bottomSheetBehavior;
if (bottomSheetBehavior2 != null) {
bottomSheetBehavior2.removeBottomSheetCallback(this.bottomSheetCallback);
this.bottomSheetBehavior.setAccessibilityDelegateView(null);
}
this.bottomSheetBehavior = bottomSheetBehavior;
if (bottomSheetBehavior != null) {
bottomSheetBehavior.setAccessibilityDelegateView(this);
onBottomSheetStateChanged(this.bottomSheetBehavior.getState());
this.bottomSheetBehavior.addBottomSheetCallback(this.bottomSheetCallback);
}
updateInteractableState();
}
/* JADX INFO: Access modifiers changed from: private */
public void onBottomSheetStateChanged(int i) {
if (i == 4) {
this.clickToExpand = true;
} else if (i == 3) {
this.clickToExpand = false;
}
ViewCompat.replaceAccessibilityAction(this, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CLICK, this.clickToExpand ? this.clickToExpandActionLabel : this.clickToCollapseActionLabel, new AccessibilityViewCommand() { // from class: com.google.android.material.bottomsheet.BottomSheetDragHandleView$$ExternalSyntheticLambda0
@Override // androidx.core.view.accessibility.AccessibilityViewCommand
public final boolean perform(View view, AccessibilityViewCommand.CommandArguments commandArguments) {
return BottomSheetDragHandleView.this.m192xa7b4c95f(view, commandArguments);
}
});
}
/* renamed from: lambda$onBottomSheetStateChanged$0$com-google-android-material-bottomsheet-BottomSheetDragHandleView, reason: not valid java name */
/* synthetic */ boolean m192xa7b4c95f(View view, AccessibilityViewCommand.CommandArguments commandArguments) {
return expandOrCollapseBottomSheetIfPossible();
}
private void updateInteractableState() {
this.interactable = this.accessibilityServiceEnabled && this.bottomSheetBehavior != null;
ViewCompat.setImportantForAccessibility(this, this.bottomSheetBehavior == null ? 2 : 1);
setClickable(this.interactable);
}
/* JADX INFO: Access modifiers changed from: private */
public boolean expandOrCollapseBottomSheetIfPossible() {
boolean z = false;
if (!this.interactable) {
return false;
}
announceAccessibilityEvent(this.clickFeedback);
if (!this.bottomSheetBehavior.isFitToContents() && !this.bottomSheetBehavior.shouldSkipHalfExpandedStateWhenDragging()) {
z = true;
}
int state = this.bottomSheetBehavior.getState();
int i = 6;
if (state == 4) {
if (!z) {
i = 3;
}
} else if (state != 3) {
i = this.clickToExpand ? 3 : 4;
} else if (!z) {
i = 4;
}
this.bottomSheetBehavior.setState(i);
return true;
}
private void announceAccessibilityEvent(String str) {
if (this.accessibilityManager == null) {
return;
}
AccessibilityEvent obtain = AccessibilityEvent.obtain(16384);
obtain.getText().add(str);
this.accessibilityManager.sendAccessibilityEvent(obtain);
}
private BottomSheetBehavior<?> findParentBottomSheetBehavior() {
View view = this;
while (true) {
view = getParentView(view);
if (view == null) {
return null;
}
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
if (layoutParams instanceof CoordinatorLayout.LayoutParams) {
CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) layoutParams).getBehavior();
if (behavior instanceof BottomSheetBehavior) {
return (BottomSheetBehavior) behavior;
}
}
}
}
private static View getParentView(View view) {
Object parent = view.getParent();
if (parent instanceof View) {
return (View) parent;
}
return null;
}
}

View File

@ -0,0 +1,57 @@
package com.google.android.material.bottomsheet;
import android.view.View;
import androidx.core.view.WindowInsetsAnimationCompat;
import androidx.core.view.WindowInsetsCompat;
import com.google.android.material.animation.AnimationUtils;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
class InsetsAnimationCallback extends WindowInsetsAnimationCompat.Callback {
private int startTranslationY;
private int startY;
private final int[] tmpLocation;
private final View view;
public InsetsAnimationCallback(View view) {
super(0);
this.tmpLocation = new int[2];
this.view = view;
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Callback
public void onPrepare(WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
this.view.getLocationOnScreen(this.tmpLocation);
this.startY = this.tmpLocation[1];
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Callback
public WindowInsetsAnimationCompat.BoundsCompat onStart(WindowInsetsAnimationCompat windowInsetsAnimationCompat, WindowInsetsAnimationCompat.BoundsCompat boundsCompat) {
this.view.getLocationOnScreen(this.tmpLocation);
int i = this.startY - this.tmpLocation[1];
this.startTranslationY = i;
this.view.setTranslationY(i);
return boundsCompat;
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Callback
public WindowInsetsCompat onProgress(WindowInsetsCompat windowInsetsCompat, List<WindowInsetsAnimationCompat> list) {
Iterator<WindowInsetsAnimationCompat> it = list.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
if ((it.next().getTypeMask() & WindowInsetsCompat.Type.ime()) != 0) {
this.view.setTranslationY(AnimationUtils.lerp(this.startTranslationY, 0, r0.getInterpolatedFraction()));
break;
}
}
return windowInsetsCompat;
}
@Override // androidx.core.view.WindowInsetsAnimationCompat.Callback
public void onEnd(WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
this.view.setTranslationY(0.0f);
}
}