mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-26 17:12:31 -06:00
308 lines
12 KiB
Java
308 lines
12 KiB
Java
package com.google.android.material.snackbar;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.ColorStateList;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.text.TextUtils;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.accessibility.AccessibilityManager;
|
|
import android.widget.Button;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.TextView;
|
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
import com.google.android.material.R;
|
|
import com.google.android.material.snackbar.BaseTransientBottomBar;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class Snackbar extends BaseTransientBottomBar<Snackbar> {
|
|
private static final int[] SNACKBAR_BUTTON_STYLE_ATTR = {R.attr.snackbarButtonStyle};
|
|
private static final int[] SNACKBAR_CONTENT_STYLE_ATTRS = {R.attr.snackbarButtonStyle, R.attr.snackbarTextViewStyle};
|
|
private final AccessibilityManager accessibilityManager;
|
|
private BaseTransientBottomBar.BaseCallback<Snackbar> callback;
|
|
private boolean hasAction;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class Callback extends BaseTransientBottomBar.BaseCallback<Snackbar> {
|
|
public static final int DISMISS_EVENT_ACTION = 1;
|
|
public static final int DISMISS_EVENT_CONSECUTIVE = 4;
|
|
public static final int DISMISS_EVENT_MANUAL = 3;
|
|
public static final int DISMISS_EVENT_SWIPE = 0;
|
|
public static final int DISMISS_EVENT_TIMEOUT = 2;
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback
|
|
public void onDismissed(Snackbar snackbar, int i) {
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback
|
|
public void onShown(Snackbar snackbar) {
|
|
}
|
|
}
|
|
|
|
private Snackbar(Context context, ViewGroup viewGroup, View view, ContentViewCallback contentViewCallback) {
|
|
super(context, viewGroup, view, contentViewCallback);
|
|
this.accessibilityManager = (AccessibilityManager) viewGroup.getContext().getSystemService("accessibility");
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar
|
|
public void show() {
|
|
super.show();
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar
|
|
public void dismiss() {
|
|
super.dismiss();
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar
|
|
public boolean isShown() {
|
|
return super.isShown();
|
|
}
|
|
|
|
public static Snackbar make(View view, CharSequence charSequence, int i) {
|
|
return makeInternal(null, view, charSequence, i);
|
|
}
|
|
|
|
public static Snackbar make(Context context, View view, CharSequence charSequence, int i) {
|
|
return makeInternal(context, view, charSequence, i);
|
|
}
|
|
|
|
private static Snackbar makeInternal(Context context, View view, CharSequence charSequence, int i) {
|
|
int i2;
|
|
ViewGroup findSuitableParent = findSuitableParent(view);
|
|
if (findSuitableParent == null) {
|
|
throw new IllegalArgumentException("No suitable parent found from the given view. Please provide a valid view.");
|
|
}
|
|
if (context == null) {
|
|
context = findSuitableParent.getContext();
|
|
}
|
|
LayoutInflater from = LayoutInflater.from(context);
|
|
if (hasSnackbarContentStyleAttrs(context)) {
|
|
i2 = R.layout.mtrl_layout_snackbar_include;
|
|
} else {
|
|
i2 = R.layout.design_layout_snackbar_include;
|
|
}
|
|
SnackbarContentLayout snackbarContentLayout = (SnackbarContentLayout) from.inflate(i2, findSuitableParent, false);
|
|
Snackbar snackbar = new Snackbar(context, findSuitableParent, snackbarContentLayout, snackbarContentLayout);
|
|
snackbar.setText(charSequence);
|
|
snackbar.setDuration(i);
|
|
return snackbar;
|
|
}
|
|
|
|
@Deprecated
|
|
protected static boolean hasSnackbarButtonStyleAttr(Context context) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(SNACKBAR_BUTTON_STYLE_ATTR);
|
|
int resourceId = obtainStyledAttributes.getResourceId(0, -1);
|
|
obtainStyledAttributes.recycle();
|
|
return resourceId != -1;
|
|
}
|
|
|
|
private static boolean hasSnackbarContentStyleAttrs(Context context) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(SNACKBAR_CONTENT_STYLE_ATTRS);
|
|
int resourceId = obtainStyledAttributes.getResourceId(0, -1);
|
|
int resourceId2 = obtainStyledAttributes.getResourceId(1, -1);
|
|
obtainStyledAttributes.recycle();
|
|
return (resourceId == -1 || resourceId2 == -1) ? false : true;
|
|
}
|
|
|
|
public static Snackbar make(View view, int i, int i2) {
|
|
return make(view, view.getResources().getText(i), i2);
|
|
}
|
|
|
|
private static ViewGroup findSuitableParent(View view) {
|
|
ViewGroup viewGroup = null;
|
|
while (!(view instanceof CoordinatorLayout)) {
|
|
if (view instanceof FrameLayout) {
|
|
if (view.getId() == 16908290) {
|
|
return (ViewGroup) view;
|
|
}
|
|
viewGroup = (ViewGroup) view;
|
|
}
|
|
if (view != null) {
|
|
Object parent = view.getParent();
|
|
view = parent instanceof View ? (View) parent : null;
|
|
}
|
|
if (view == null) {
|
|
return viewGroup;
|
|
}
|
|
}
|
|
return (ViewGroup) view;
|
|
}
|
|
|
|
public Snackbar setText(CharSequence charSequence) {
|
|
getMessageView().setText(charSequence);
|
|
return this;
|
|
}
|
|
|
|
public Snackbar setText(int i) {
|
|
return setText(getContext().getText(i));
|
|
}
|
|
|
|
public Snackbar setAction(int i, View.OnClickListener onClickListener) {
|
|
return setAction(getContext().getText(i), onClickListener);
|
|
}
|
|
|
|
public Snackbar setAction(CharSequence charSequence, final View.OnClickListener onClickListener) {
|
|
Button actionView = getActionView();
|
|
if (TextUtils.isEmpty(charSequence) || onClickListener == null) {
|
|
actionView.setVisibility(8);
|
|
actionView.setOnClickListener(null);
|
|
this.hasAction = false;
|
|
} else {
|
|
this.hasAction = true;
|
|
actionView.setVisibility(0);
|
|
actionView.setText(charSequence);
|
|
actionView.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.snackbar.Snackbar$$ExternalSyntheticLambda0
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
Snackbar.this.m5555lambda$setAction$0$comgoogleandroidmaterialsnackbarSnackbar(onClickListener, view);
|
|
}
|
|
});
|
|
}
|
|
return this;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: lambda$setAction$0$com-google-android-material-snackbar-Snackbar, reason: not valid java name */
|
|
public /* synthetic */ void m5555lambda$setAction$0$comgoogleandroidmaterialsnackbarSnackbar(View.OnClickListener onClickListener, View view) {
|
|
onClickListener.onClick(view);
|
|
dispatchDismiss(1);
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar
|
|
public int getDuration() {
|
|
int duration = super.getDuration();
|
|
if (duration == -2) {
|
|
return -2;
|
|
}
|
|
return this.accessibilityManager.getRecommendedTimeoutMillis(duration, (this.hasAction ? 4 : 0) | 3);
|
|
}
|
|
|
|
public Snackbar setTextColor(ColorStateList colorStateList) {
|
|
getMessageView().setTextColor(colorStateList);
|
|
return this;
|
|
}
|
|
|
|
public Snackbar setTextColor(int i) {
|
|
getMessageView().setTextColor(i);
|
|
return this;
|
|
}
|
|
|
|
public Snackbar setTextMaxLines(int i) {
|
|
getMessageView().setMaxLines(i);
|
|
return this;
|
|
}
|
|
|
|
public Snackbar setActionTextColor(ColorStateList colorStateList) {
|
|
getActionView().setTextColor(colorStateList);
|
|
return this;
|
|
}
|
|
|
|
public Snackbar setMaxInlineActionWidth(int i) {
|
|
getContentLayout().setMaxInlineActionWidth(i);
|
|
return this;
|
|
}
|
|
|
|
public Snackbar setActionTextColor(int i) {
|
|
getActionView().setTextColor(i);
|
|
return this;
|
|
}
|
|
|
|
public Snackbar setBackgroundTint(int i) {
|
|
return setBackgroundTintList(ColorStateList.valueOf(i));
|
|
}
|
|
|
|
public Snackbar setBackgroundTintList(ColorStateList colorStateList) {
|
|
this.view.setBackgroundTintList(colorStateList);
|
|
return this;
|
|
}
|
|
|
|
public Snackbar setBackgroundTintMode(PorterDuff.Mode mode) {
|
|
this.view.setBackgroundTintMode(mode);
|
|
return this;
|
|
}
|
|
|
|
@Deprecated
|
|
public Snackbar setCallback(Callback callback) {
|
|
BaseTransientBottomBar.BaseCallback<Snackbar> baseCallback = this.callback;
|
|
if (baseCallback != null) {
|
|
removeCallback(baseCallback);
|
|
}
|
|
if (callback != null) {
|
|
addCallback(callback);
|
|
}
|
|
this.callback = callback;
|
|
return this;
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static final class SnackbarLayout extends BaseTransientBottomBar.SnackbarBaseLayout {
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar.SnackbarBaseLayout, android.view.View
|
|
public /* bridge */ /* synthetic */ void setBackground(Drawable drawable) {
|
|
super.setBackground(drawable);
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar.SnackbarBaseLayout, android.view.View
|
|
public /* bridge */ /* synthetic */ void setBackgroundDrawable(Drawable drawable) {
|
|
super.setBackgroundDrawable(drawable);
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar.SnackbarBaseLayout, android.view.View
|
|
public /* bridge */ /* synthetic */ void setBackgroundTintList(ColorStateList colorStateList) {
|
|
super.setBackgroundTintList(colorStateList);
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar.SnackbarBaseLayout, android.view.View
|
|
public /* bridge */ /* synthetic */ void setBackgroundTintMode(PorterDuff.Mode mode) {
|
|
super.setBackgroundTintMode(mode);
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar.SnackbarBaseLayout, android.view.View
|
|
public /* bridge */ /* synthetic */ void setLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
super.setLayoutParams(layoutParams);
|
|
}
|
|
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar.SnackbarBaseLayout, android.view.View
|
|
public /* bridge */ /* synthetic */ void setOnClickListener(View.OnClickListener onClickListener) {
|
|
super.setOnClickListener(onClickListener);
|
|
}
|
|
|
|
public SnackbarLayout(Context context) {
|
|
super(context);
|
|
}
|
|
|
|
public SnackbarLayout(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.android.material.snackbar.BaseTransientBottomBar.SnackbarBaseLayout, android.widget.FrameLayout, android.view.View
|
|
public void onMeasure(int i, int i2) {
|
|
super.onMeasure(i, i2);
|
|
int childCount = getChildCount();
|
|
int measuredWidth = (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight();
|
|
for (int i3 = 0; i3 < childCount; i3++) {
|
|
View childAt = getChildAt(i3);
|
|
if (childAt.getLayoutParams().width == -1) {
|
|
childAt.measure(View.MeasureSpec.makeMeasureSpec(measuredWidth, 1073741824), View.MeasureSpec.makeMeasureSpec(childAt.getMeasuredHeight(), 1073741824));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private TextView getMessageView() {
|
|
return getContentLayout().getMessageView();
|
|
}
|
|
|
|
private Button getActionView() {
|
|
return getContentLayout().getActionView();
|
|
}
|
|
|
|
private SnackbarContentLayout getContentLayout() {
|
|
return (SnackbarContentLayout) this.view.getChildAt(0);
|
|
}
|
|
}
|