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,78 @@
package com.google.android.material.internal;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
/* loaded from: classes.dex */
public class BaselineLayout extends ViewGroup {
private int baseline;
@Override // android.view.View
public int getBaseline() {
return this.baseline;
}
public BaselineLayout(Context context) {
super(context, null, 0);
this.baseline = -1;
}
public BaselineLayout(Context context, AttributeSet attributeSet) {
super(context, attributeSet, 0);
this.baseline = -1;
}
public BaselineLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.baseline = -1;
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
int childCount = getChildCount();
int i3 = 0;
int i4 = 0;
int i5 = 0;
int i6 = -1;
int i7 = -1;
for (int i8 = 0; i8 < childCount; i8++) {
View childAt = getChildAt(i8);
if (childAt.getVisibility() != 8) {
measureChild(childAt, i, i2);
int baseline = childAt.getBaseline();
if (baseline != -1) {
i6 = Math.max(i6, baseline);
i7 = Math.max(i7, childAt.getMeasuredHeight() - baseline);
}
i4 = Math.max(i4, childAt.getMeasuredWidth());
i3 = Math.max(i3, childAt.getMeasuredHeight());
i5 = View.combineMeasuredStates(i5, childAt.getMeasuredState());
}
}
if (i6 != -1) {
i3 = Math.max(i3, Math.max(i7, getPaddingBottom()) + i6);
this.baseline = i6;
}
setMeasuredDimension(View.resolveSizeAndState(Math.max(i4, getSuggestedMinimumWidth()), i, i5), View.resolveSizeAndState(Math.max(i3, getSuggestedMinimumHeight()), i2, i5 << 16));
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int childCount = getChildCount();
int paddingLeft = getPaddingLeft();
int paddingRight = ((i3 - i) - getPaddingRight()) - paddingLeft;
int paddingTop = getPaddingTop();
for (int i5 = 0; i5 < childCount; i5++) {
View childAt = getChildAt(i5);
if (childAt.getVisibility() != 8) {
int measuredWidth = childAt.getMeasuredWidth();
int measuredHeight = childAt.getMeasuredHeight();
int i6 = ((paddingRight - measuredWidth) / 2) + paddingLeft;
int baseline = (this.baseline == -1 || childAt.getBaseline() == -1) ? paddingTop : (this.baseline + paddingTop) - childAt.getBaseline();
childAt.layout(i6, baseline, measuredWidth + i6, measuredHeight + baseline);
}
}
}
}

View File

@ -0,0 +1,168 @@
package com.google.android.material.internal;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.material.internal.MaterialCheckable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
public class CheckableGroup<T extends MaterialCheckable<T>> {
private final Map<Integer, T> checkables = new HashMap();
private final Set<Integer> checkedIds = new HashSet();
private OnCheckedStateChangeListener onCheckedStateChangeListener;
private boolean selectionRequired;
private boolean singleSelection;
public interface OnCheckedStateChangeListener {
void onCheckedStateChanged(Set<Integer> set);
}
public boolean isSelectionRequired() {
return this.selectionRequired;
}
public boolean isSingleSelection() {
return this.singleSelection;
}
public void setOnCheckedStateChangeListener(OnCheckedStateChangeListener onCheckedStateChangeListener) {
this.onCheckedStateChangeListener = onCheckedStateChangeListener;
}
public void setSelectionRequired(boolean z) {
this.selectionRequired = z;
}
public void setSingleSelection(boolean z) {
if (this.singleSelection != z) {
this.singleSelection = z;
clearCheck();
}
}
/* JADX WARN: Multi-variable type inference failed */
public void addCheckable(T t) {
this.checkables.put(Integer.valueOf(t.getId()), t);
if (t.isChecked()) {
checkInternal(t);
}
t.setInternalOnCheckedChangeListener(new MaterialCheckable.OnCheckedChangeListener<T>() { // from class: com.google.android.material.internal.CheckableGroup.1
@Override // com.google.android.material.internal.MaterialCheckable.OnCheckedChangeListener
public void onCheckedChanged(T t2, boolean z) {
if (z) {
if (!CheckableGroup.this.checkInternal(t2)) {
return;
}
} else {
CheckableGroup checkableGroup = CheckableGroup.this;
if (!checkableGroup.uncheckInternal(t2, checkableGroup.selectionRequired)) {
return;
}
}
CheckableGroup.this.onCheckedStateChanged();
}
});
}
public void removeCheckable(T t) {
t.setInternalOnCheckedChangeListener(null);
this.checkables.remove(Integer.valueOf(t.getId()));
this.checkedIds.remove(Integer.valueOf(t.getId()));
}
public void check(int i) {
T t = this.checkables.get(Integer.valueOf(i));
if (t != null && checkInternal(t)) {
onCheckedStateChanged();
}
}
public void uncheck(int i) {
T t = this.checkables.get(Integer.valueOf(i));
if (t != null && uncheckInternal(t, this.selectionRequired)) {
onCheckedStateChanged();
}
}
public void clearCheck() {
boolean z = !this.checkedIds.isEmpty();
Iterator<T> it = this.checkables.values().iterator();
while (it.hasNext()) {
uncheckInternal(it.next(), false);
}
if (z) {
onCheckedStateChanged();
}
}
public int getSingleCheckedId() {
if (!this.singleSelection || this.checkedIds.isEmpty()) {
return -1;
}
return this.checkedIds.iterator().next().intValue();
}
public Set<Integer> getCheckedIds() {
return new HashSet(this.checkedIds);
}
public List<Integer> getCheckedIdsSortedByChildOrder(ViewGroup viewGroup) {
Set<Integer> checkedIds = getCheckedIds();
ArrayList arrayList = new ArrayList();
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View childAt = viewGroup.getChildAt(i);
if ((childAt instanceof MaterialCheckable) && checkedIds.contains(Integer.valueOf(childAt.getId()))) {
arrayList.add(Integer.valueOf(childAt.getId()));
}
}
return arrayList;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean checkInternal(MaterialCheckable<T> materialCheckable) {
int id = materialCheckable.getId();
if (this.checkedIds.contains(Integer.valueOf(id))) {
return false;
}
T t = this.checkables.get(Integer.valueOf(getSingleCheckedId()));
if (t != null) {
uncheckInternal(t, false);
}
boolean add = this.checkedIds.add(Integer.valueOf(id));
if (!materialCheckable.isChecked()) {
materialCheckable.setChecked(true);
}
return add;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean uncheckInternal(MaterialCheckable<T> materialCheckable, boolean z) {
int id = materialCheckable.getId();
if (!this.checkedIds.contains(Integer.valueOf(id))) {
return false;
}
if (z && this.checkedIds.size() == 1 && this.checkedIds.contains(Integer.valueOf(id))) {
materialCheckable.setChecked(true);
return false;
}
boolean remove = this.checkedIds.remove(Integer.valueOf(id));
if (materialCheckable.isChecked()) {
materialCheckable.setChecked(false);
}
return remove;
}
/* JADX INFO: Access modifiers changed from: private */
public void onCheckedStateChanged() {
OnCheckedStateChangeListener onCheckedStateChangeListener = this.onCheckedStateChangeListener;
if (onCheckedStateChangeListener != null) {
onCheckedStateChangeListener.onCheckedStateChanged(getCheckedIds());
}
}
}

View File

@ -0,0 +1,164 @@
package com.google.android.material.internal;
import android.R;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.widget.Checkable;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.customview.view.AbsSavedState;
/* loaded from: classes.dex */
public class CheckableImageButton extends AppCompatImageButton implements Checkable {
private static final int[] DRAWABLE_STATE_CHECKED = {R.attr.state_checked};
private boolean checkable;
private boolean checked;
private boolean pressable;
public boolean isCheckable() {
return this.checkable;
}
@Override // android.widget.Checkable
public boolean isChecked() {
return this.checked;
}
public boolean isPressable() {
return this.pressable;
}
public void setPressable(boolean z) {
this.pressable = z;
}
public CheckableImageButton(Context context) {
this(context, null);
}
public CheckableImageButton(Context context, AttributeSet attributeSet) {
this(context, attributeSet, androidx.appcompat.R.attr.imageButtonStyle);
}
public CheckableImageButton(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.checkable = true;
this.pressable = true;
ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegateCompat() { // from class: com.google.android.material.internal.CheckableImageButton.1
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
super.onInitializeAccessibilityEvent(view, accessibilityEvent);
accessibilityEvent.setChecked(CheckableImageButton.this.isChecked());
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setCheckable(CheckableImageButton.this.isCheckable());
accessibilityNodeInfoCompat.setChecked(CheckableImageButton.this.isChecked());
}
});
}
@Override // android.widget.Checkable
public void setChecked(boolean z) {
if (!this.checkable || this.checked == z) {
return;
}
this.checked = z;
refreshDrawableState();
sendAccessibilityEvent(2048);
}
@Override // android.widget.Checkable
public void toggle() {
setChecked(!this.checked);
}
@Override // android.view.View
public void setPressed(boolean z) {
if (this.pressable) {
super.setPressed(z);
}
}
@Override // android.widget.ImageView, android.view.View
public int[] onCreateDrawableState(int i) {
if (this.checked) {
int[] iArr = DRAWABLE_STATE_CHECKED;
return mergeDrawableStates(super.onCreateDrawableState(i + iArr.length), iArr);
}
return super.onCreateDrawableState(i);
}
@Override // android.view.View
protected Parcelable onSaveInstanceState() {
SavedState savedState = new SavedState(super.onSaveInstanceState());
savedState.checked = this.checked;
return savedState;
}
@Override // android.view.View
protected void onRestoreInstanceState(Parcelable parcelable) {
if (!(parcelable instanceof SavedState)) {
super.onRestoreInstanceState(parcelable);
return;
}
SavedState savedState = (SavedState) parcelable;
super.onRestoreInstanceState(savedState.getSuperState());
setChecked(savedState.checked);
}
public void setCheckable(boolean z) {
if (this.checkable != z) {
this.checkable = z;
sendAccessibilityEvent(0);
}
}
static class SavedState extends AbsSavedState {
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: com.google.android.material.internal.CheckableImageButton.SavedState.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.ClassLoaderCreator
public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
return new SavedState(parcel, classLoader);
}
@Override // android.os.Parcelable.Creator
public SavedState createFromParcel(Parcel parcel) {
return new SavedState(parcel, null);
}
@Override // android.os.Parcelable.Creator
public SavedState[] newArray(int i) {
return new SavedState[i];
}
};
boolean checked;
public SavedState(Parcelable parcelable) {
super(parcelable);
}
public SavedState(Parcel parcel, ClassLoader classLoader) {
super(parcel, classLoader);
readFromParcel(parcel);
}
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(this.checked ? 1 : 0);
}
private void readFromParcel(Parcel parcel) {
this.checked = parcel.readInt() == 1;
}
}
}

View File

@ -0,0 +1,72 @@
package com.google.android.material.internal;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/* loaded from: classes.dex */
public class ClippableRoundedCornerLayout extends FrameLayout {
private float cornerRadius;
private Path path;
public float getCornerRadius() {
return this.cornerRadius;
}
public ClippableRoundedCornerLayout(Context context) {
super(context);
}
public ClippableRoundedCornerLayout(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
public ClippableRoundedCornerLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
}
@Override // android.view.ViewGroup, android.view.View
protected void dispatchDraw(Canvas canvas) {
if (this.path == null) {
super.dispatchDraw(canvas);
return;
}
int save = canvas.save();
canvas.clipPath(this.path);
super.dispatchDraw(canvas);
canvas.restoreToCount(save);
}
public void resetClipBoundsAndCornerRadius() {
this.path = null;
this.cornerRadius = 0.0f;
invalidate();
}
public void updateCornerRadius(float f) {
updateClipBoundsAndCornerRadius(getLeft(), getTop(), getRight(), getBottom(), f);
}
public void updateClipBoundsAndCornerRadius(Rect rect, float f) {
updateClipBoundsAndCornerRadius(rect.left, rect.top, rect.right, rect.bottom, f);
}
public void updateClipBoundsAndCornerRadius(float f, float f2, float f3, float f4, float f5) {
updateClipBoundsAndCornerRadius(new RectF(f, f2, f3, f4), f5);
}
public void updateClipBoundsAndCornerRadius(RectF rectF, float f) {
if (this.path == null) {
this.path = new Path();
}
this.cornerRadius = f;
this.path.reset();
this.path.addRoundRect(rectF, f, f, Path.Direction.CW);
this.path.close();
invalidate();
}
}

View File

@ -0,0 +1,966 @@
package com.google.android.material.internal;
import android.animation.TimeInterpolator;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.Build;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import androidx.core.math.MathUtils;
import androidx.core.text.TextDirectionHeuristicCompat;
import androidx.core.text.TextDirectionHeuristicsCompat;
import androidx.core.util.Preconditions;
import androidx.core.view.GravityCompat;
import androidx.core.view.ViewCompat;
import com.google.android.material.animation.AnimationUtils;
import com.google.android.material.color.MaterialColors;
import com.google.android.material.internal.StaticLayoutBuilderCompat;
import com.google.android.material.resources.CancelableFontCallback;
import com.google.android.material.resources.TextAppearance;
import com.google.android.material.resources.TypefaceUtils;
/* loaded from: classes.dex */
public final class CollapsingTextHelper {
private static final boolean DEBUG_DRAW = false;
private static final String ELLIPSIS_NORMAL = "";
private static final float FADE_MODE_THRESHOLD_FRACTION_RELATIVE = 0.5f;
private static final String TAG = "CollapsingTextHelper";
private boolean boundsChanged;
private final Rect collapsedBounds;
private float collapsedDrawX;
private float collapsedDrawY;
private CancelableFontCallback collapsedFontCallback;
private float collapsedLetterSpacing;
private ColorStateList collapsedShadowColor;
private float collapsedShadowDx;
private float collapsedShadowDy;
private float collapsedShadowRadius;
private float collapsedTextBlend;
private ColorStateList collapsedTextColor;
private float collapsedTextWidth;
private Typeface collapsedTypeface;
private Typeface collapsedTypefaceBold;
private Typeface collapsedTypefaceDefault;
private final RectF currentBounds;
private float currentDrawX;
private float currentDrawY;
private float currentLetterSpacing;
private int currentOffsetY;
private int currentShadowColor;
private float currentShadowDx;
private float currentShadowDy;
private float currentShadowRadius;
private float currentTextSize;
private Typeface currentTypeface;
private final Rect expandedBounds;
private float expandedDrawX;
private float expandedDrawY;
private CancelableFontCallback expandedFontCallback;
private float expandedFraction;
private float expandedLetterSpacing;
private int expandedLineCount;
private ColorStateList expandedShadowColor;
private float expandedShadowDx;
private float expandedShadowDy;
private float expandedShadowRadius;
private float expandedTextBlend;
private ColorStateList expandedTextColor;
private Bitmap expandedTitleTexture;
private Typeface expandedTypeface;
private Typeface expandedTypefaceBold;
private Typeface expandedTypefaceDefault;
private boolean fadeModeEnabled;
private float fadeModeStartFraction;
private float fadeModeThresholdFraction;
private boolean isRtl;
private TimeInterpolator positionInterpolator;
private float scale;
private int[] state;
private StaticLayoutBuilderConfigurer staticLayoutBuilderConfigurer;
private CharSequence text;
private StaticLayout textLayout;
private final TextPaint textPaint;
private TimeInterpolator textSizeInterpolator;
private CharSequence textToDraw;
private CharSequence textToDrawCollapsed;
private Paint texturePaint;
private final TextPaint tmpPaint;
private boolean useTexture;
private final View view;
private static final boolean USE_SCALING_TEXTURE = false;
private static final Paint DEBUG_DRAW_PAINT = null;
private int expandedTextGravity = 16;
private int collapsedTextGravity = 16;
private float expandedTextSize = 15.0f;
private float collapsedTextSize = 15.0f;
private TextUtils.TruncateAt titleTextEllipsize = TextUtils.TruncateAt.END;
private boolean isRtlTextDirectionHeuristicsEnabled = true;
private int maxLines = 1;
private float lineSpacingAdd = 0.0f;
private float lineSpacingMultiplier = 1.0f;
private int hyphenationFrequency = StaticLayoutBuilderCompat.DEFAULT_HYPHENATION_FREQUENCY;
private float calculateFadeModeThresholdFraction() {
float f = this.fadeModeStartFraction;
return f + ((1.0f - f) * 0.5f);
}
private boolean shouldDrawMultiline() {
return this.maxLines > 1 && (!this.isRtl || this.fadeModeEnabled) && !this.useTexture;
}
public ColorStateList getCollapsedTextColor() {
return this.collapsedTextColor;
}
public int getCollapsedTextGravity() {
return this.collapsedTextGravity;
}
public float getCollapsedTextSize() {
return this.collapsedTextSize;
}
public int getExpandedLineCount() {
return this.expandedLineCount;
}
public ColorStateList getExpandedTextColor() {
return this.expandedTextColor;
}
public int getExpandedTextGravity() {
return this.expandedTextGravity;
}
public float getExpandedTextSize() {
return this.expandedTextSize;
}
public float getExpansionFraction() {
return this.expandedFraction;
}
public float getFadeModeThresholdFraction() {
return this.fadeModeThresholdFraction;
}
public int getHyphenationFrequency() {
return this.hyphenationFrequency;
}
public int getMaxLines() {
return this.maxLines;
}
public TimeInterpolator getPositionInterpolator() {
return this.positionInterpolator;
}
public CharSequence getText() {
return this.text;
}
public TextUtils.TruncateAt getTitleTextEllipsize() {
return this.titleTextEllipsize;
}
public boolean isRtlTextDirectionHeuristicsEnabled() {
return this.isRtlTextDirectionHeuristicsEnabled;
}
public void setCurrentOffsetY(int i) {
this.currentOffsetY = i;
}
public void setFadeModeEnabled(boolean z) {
this.fadeModeEnabled = z;
}
public void setHyphenationFrequency(int i) {
this.hyphenationFrequency = i;
}
public void setLineSpacingAdd(float f) {
this.lineSpacingAdd = f;
}
public void setLineSpacingMultiplier(float f) {
this.lineSpacingMultiplier = f;
}
public void setRtlTextDirectionHeuristicsEnabled(boolean z) {
this.isRtlTextDirectionHeuristicsEnabled = z;
}
public CollapsingTextHelper(View view) {
this.view = view;
TextPaint textPaint = new TextPaint(129);
this.textPaint = textPaint;
this.tmpPaint = new TextPaint(textPaint);
this.collapsedBounds = new Rect();
this.expandedBounds = new Rect();
this.currentBounds = new RectF();
this.fadeModeThresholdFraction = calculateFadeModeThresholdFraction();
maybeUpdateFontWeightAdjustment(view.getContext().getResources().getConfiguration());
}
public void setTextSizeInterpolator(TimeInterpolator timeInterpolator) {
this.textSizeInterpolator = timeInterpolator;
recalculate();
}
public void setPositionInterpolator(TimeInterpolator timeInterpolator) {
this.positionInterpolator = timeInterpolator;
recalculate();
}
public void setExpandedTextSize(float f) {
if (this.expandedTextSize != f) {
this.expandedTextSize = f;
recalculate();
}
}
public void setCollapsedTextSize(float f) {
if (this.collapsedTextSize != f) {
this.collapsedTextSize = f;
recalculate();
}
}
public void setCollapsedTextColor(ColorStateList colorStateList) {
if (this.collapsedTextColor != colorStateList) {
this.collapsedTextColor = colorStateList;
recalculate();
}
}
public void setExpandedTextColor(ColorStateList colorStateList) {
if (this.expandedTextColor != colorStateList) {
this.expandedTextColor = colorStateList;
recalculate();
}
}
public void setCollapsedAndExpandedTextColor(ColorStateList colorStateList) {
if (this.collapsedTextColor == colorStateList && this.expandedTextColor == colorStateList) {
return;
}
this.collapsedTextColor = colorStateList;
this.expandedTextColor = colorStateList;
recalculate();
}
public void setExpandedLetterSpacing(float f) {
if (this.expandedLetterSpacing != f) {
this.expandedLetterSpacing = f;
recalculate();
}
}
public void setExpandedBounds(int i, int i2, int i3, int i4) {
if (rectEquals(this.expandedBounds, i, i2, i3, i4)) {
return;
}
this.expandedBounds.set(i, i2, i3, i4);
this.boundsChanged = true;
}
public void setExpandedBounds(Rect rect) {
setExpandedBounds(rect.left, rect.top, rect.right, rect.bottom);
}
public void setCollapsedBounds(int i, int i2, int i3, int i4) {
if (rectEquals(this.collapsedBounds, i, i2, i3, i4)) {
return;
}
this.collapsedBounds.set(i, i2, i3, i4);
this.boundsChanged = true;
}
public void setCollapsedBounds(Rect rect) {
setCollapsedBounds(rect.left, rect.top, rect.right, rect.bottom);
}
public void getCollapsedTextActualBounds(RectF rectF, int i, int i2) {
this.isRtl = calculateIsRtl(this.text);
rectF.left = Math.max(getCollapsedTextLeftBound(i, i2), this.collapsedBounds.left);
rectF.top = this.collapsedBounds.top;
rectF.right = Math.min(getCollapsedTextRightBound(rectF, i, i2), this.collapsedBounds.right);
rectF.bottom = this.collapsedBounds.top + getCollapsedTextHeight();
}
private float getCollapsedTextLeftBound(int i, int i2) {
return (i2 == 17 || (i2 & 7) == 1) ? (i / 2.0f) - (this.collapsedTextWidth / 2.0f) : ((i2 & GravityCompat.END) == 8388613 || (i2 & 5) == 5) ? this.isRtl ? this.collapsedBounds.left : this.collapsedBounds.right - this.collapsedTextWidth : this.isRtl ? this.collapsedBounds.right - this.collapsedTextWidth : this.collapsedBounds.left;
}
private float getCollapsedTextRightBound(RectF rectF, int i, int i2) {
return (i2 == 17 || (i2 & 7) == 1) ? (i / 2.0f) + (this.collapsedTextWidth / 2.0f) : ((i2 & GravityCompat.END) == 8388613 || (i2 & 5) == 5) ? this.isRtl ? rectF.left + this.collapsedTextWidth : this.collapsedBounds.right : this.isRtl ? this.collapsedBounds.right : rectF.left + this.collapsedTextWidth;
}
public float getExpandedTextHeight() {
getTextPaintExpanded(this.tmpPaint);
return -this.tmpPaint.ascent();
}
public float getExpandedTextFullHeight() {
getTextPaintExpanded(this.tmpPaint);
return (-this.tmpPaint.ascent()) + this.tmpPaint.descent();
}
public float getCollapsedTextHeight() {
getTextPaintCollapsed(this.tmpPaint);
return -this.tmpPaint.ascent();
}
public void setFadeModeStartFraction(float f) {
this.fadeModeStartFraction = f;
this.fadeModeThresholdFraction = calculateFadeModeThresholdFraction();
}
private void getTextPaintExpanded(TextPaint textPaint) {
textPaint.setTextSize(this.expandedTextSize);
textPaint.setTypeface(this.expandedTypeface);
textPaint.setLetterSpacing(this.expandedLetterSpacing);
}
private void getTextPaintCollapsed(TextPaint textPaint) {
textPaint.setTextSize(this.collapsedTextSize);
textPaint.setTypeface(this.collapsedTypeface);
textPaint.setLetterSpacing(this.collapsedLetterSpacing);
}
public void setExpandedTextGravity(int i) {
if (this.expandedTextGravity != i) {
this.expandedTextGravity = i;
recalculate();
}
}
public void setCollapsedTextGravity(int i) {
if (this.collapsedTextGravity != i) {
this.collapsedTextGravity = i;
recalculate();
}
}
public void setCollapsedTextAppearance(int i) {
TextAppearance textAppearance = new TextAppearance(this.view.getContext(), i);
if (textAppearance.getTextColor() != null) {
this.collapsedTextColor = textAppearance.getTextColor();
}
if (textAppearance.getTextSize() != 0.0f) {
this.collapsedTextSize = textAppearance.getTextSize();
}
if (textAppearance.shadowColor != null) {
this.collapsedShadowColor = textAppearance.shadowColor;
}
this.collapsedShadowDx = textAppearance.shadowDx;
this.collapsedShadowDy = textAppearance.shadowDy;
this.collapsedShadowRadius = textAppearance.shadowRadius;
this.collapsedLetterSpacing = textAppearance.letterSpacing;
CancelableFontCallback cancelableFontCallback = this.collapsedFontCallback;
if (cancelableFontCallback != null) {
cancelableFontCallback.cancel();
}
this.collapsedFontCallback = new CancelableFontCallback(new CancelableFontCallback.ApplyFont() { // from class: com.google.android.material.internal.CollapsingTextHelper.1
@Override // com.google.android.material.resources.CancelableFontCallback.ApplyFont
public void apply(Typeface typeface) {
CollapsingTextHelper.this.setCollapsedTypeface(typeface);
}
}, textAppearance.getFallbackFont());
textAppearance.getFontAsync(this.view.getContext(), this.collapsedFontCallback);
recalculate();
}
public void setExpandedTextAppearance(int i) {
TextAppearance textAppearance = new TextAppearance(this.view.getContext(), i);
if (textAppearance.getTextColor() != null) {
this.expandedTextColor = textAppearance.getTextColor();
}
if (textAppearance.getTextSize() != 0.0f) {
this.expandedTextSize = textAppearance.getTextSize();
}
if (textAppearance.shadowColor != null) {
this.expandedShadowColor = textAppearance.shadowColor;
}
this.expandedShadowDx = textAppearance.shadowDx;
this.expandedShadowDy = textAppearance.shadowDy;
this.expandedShadowRadius = textAppearance.shadowRadius;
this.expandedLetterSpacing = textAppearance.letterSpacing;
CancelableFontCallback cancelableFontCallback = this.expandedFontCallback;
if (cancelableFontCallback != null) {
cancelableFontCallback.cancel();
}
this.expandedFontCallback = new CancelableFontCallback(new CancelableFontCallback.ApplyFont() { // from class: com.google.android.material.internal.CollapsingTextHelper.2
@Override // com.google.android.material.resources.CancelableFontCallback.ApplyFont
public void apply(Typeface typeface) {
CollapsingTextHelper.this.setExpandedTypeface(typeface);
}
}, textAppearance.getFallbackFont());
textAppearance.getFontAsync(this.view.getContext(), this.expandedFontCallback);
recalculate();
}
public void setTitleTextEllipsize(TextUtils.TruncateAt truncateAt) {
this.titleTextEllipsize = truncateAt;
recalculate();
}
public void setCollapsedTypeface(Typeface typeface) {
if (setCollapsedTypefaceInternal(typeface)) {
recalculate();
}
}
public void setExpandedTypeface(Typeface typeface) {
if (setExpandedTypefaceInternal(typeface)) {
recalculate();
}
}
public void setTypefaces(Typeface typeface) {
boolean collapsedTypefaceInternal = setCollapsedTypefaceInternal(typeface);
boolean expandedTypefaceInternal = setExpandedTypefaceInternal(typeface);
if (collapsedTypefaceInternal || expandedTypefaceInternal) {
recalculate();
}
}
private boolean setCollapsedTypefaceInternal(Typeface typeface) {
CancelableFontCallback cancelableFontCallback = this.collapsedFontCallback;
if (cancelableFontCallback != null) {
cancelableFontCallback.cancel();
}
if (this.collapsedTypefaceDefault == typeface) {
return false;
}
this.collapsedTypefaceDefault = typeface;
Typeface maybeCopyWithFontWeightAdjustment = TypefaceUtils.maybeCopyWithFontWeightAdjustment(this.view.getContext().getResources().getConfiguration(), typeface);
this.collapsedTypefaceBold = maybeCopyWithFontWeightAdjustment;
if (maybeCopyWithFontWeightAdjustment == null) {
maybeCopyWithFontWeightAdjustment = this.collapsedTypefaceDefault;
}
this.collapsedTypeface = maybeCopyWithFontWeightAdjustment;
return true;
}
private boolean setExpandedTypefaceInternal(Typeface typeface) {
CancelableFontCallback cancelableFontCallback = this.expandedFontCallback;
if (cancelableFontCallback != null) {
cancelableFontCallback.cancel();
}
if (this.expandedTypefaceDefault == typeface) {
return false;
}
this.expandedTypefaceDefault = typeface;
Typeface maybeCopyWithFontWeightAdjustment = TypefaceUtils.maybeCopyWithFontWeightAdjustment(this.view.getContext().getResources().getConfiguration(), typeface);
this.expandedTypefaceBold = maybeCopyWithFontWeightAdjustment;
if (maybeCopyWithFontWeightAdjustment == null) {
maybeCopyWithFontWeightAdjustment = this.expandedTypefaceDefault;
}
this.expandedTypeface = maybeCopyWithFontWeightAdjustment;
return true;
}
public Typeface getCollapsedTypeface() {
Typeface typeface = this.collapsedTypeface;
return typeface != null ? typeface : Typeface.DEFAULT;
}
public Typeface getExpandedTypeface() {
Typeface typeface = this.expandedTypeface;
return typeface != null ? typeface : Typeface.DEFAULT;
}
public void maybeUpdateFontWeightAdjustment(Configuration configuration) {
if (Build.VERSION.SDK_INT >= 31) {
Typeface typeface = this.collapsedTypefaceDefault;
if (typeface != null) {
this.collapsedTypefaceBold = TypefaceUtils.maybeCopyWithFontWeightAdjustment(configuration, typeface);
}
Typeface typeface2 = this.expandedTypefaceDefault;
if (typeface2 != null) {
this.expandedTypefaceBold = TypefaceUtils.maybeCopyWithFontWeightAdjustment(configuration, typeface2);
}
Typeface typeface3 = this.collapsedTypefaceBold;
if (typeface3 == null) {
typeface3 = this.collapsedTypefaceDefault;
}
this.collapsedTypeface = typeface3;
Typeface typeface4 = this.expandedTypefaceBold;
if (typeface4 == null) {
typeface4 = this.expandedTypefaceDefault;
}
this.expandedTypeface = typeface4;
recalculate(true);
}
}
public void setExpansionFraction(float f) {
float clamp = MathUtils.clamp(f, 0.0f, 1.0f);
if (clamp != this.expandedFraction) {
this.expandedFraction = clamp;
calculateCurrentOffsets();
}
}
public final boolean setState(int[] iArr) {
this.state = iArr;
if (!isStateful()) {
return false;
}
recalculate();
return true;
}
public final boolean isStateful() {
ColorStateList colorStateList;
ColorStateList colorStateList2 = this.collapsedTextColor;
return (colorStateList2 != null && colorStateList2.isStateful()) || ((colorStateList = this.expandedTextColor) != null && colorStateList.isStateful());
}
private void calculateCurrentOffsets() {
calculateOffsets(this.expandedFraction);
}
private void calculateOffsets(float f) {
float f2;
interpolateBounds(f);
if (!this.fadeModeEnabled) {
this.currentDrawX = lerp(this.expandedDrawX, this.collapsedDrawX, f, this.positionInterpolator);
this.currentDrawY = lerp(this.expandedDrawY, this.collapsedDrawY, f, this.positionInterpolator);
setInterpolatedTextSize(f);
f2 = f;
} else if (f < this.fadeModeThresholdFraction) {
this.currentDrawX = this.expandedDrawX;
this.currentDrawY = this.expandedDrawY;
setInterpolatedTextSize(0.0f);
f2 = 0.0f;
} else {
this.currentDrawX = this.collapsedDrawX;
this.currentDrawY = this.collapsedDrawY - Math.max(0, this.currentOffsetY);
setInterpolatedTextSize(1.0f);
f2 = 1.0f;
}
setCollapsedTextBlend(1.0f - lerp(0.0f, 1.0f, 1.0f - f, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
setExpandedTextBlend(lerp(1.0f, 0.0f, f, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
if (this.collapsedTextColor != this.expandedTextColor) {
this.textPaint.setColor(blendARGB(getCurrentExpandedTextColor(), getCurrentCollapsedTextColor(), f2));
} else {
this.textPaint.setColor(getCurrentCollapsedTextColor());
}
float f3 = this.collapsedLetterSpacing;
float f4 = this.expandedLetterSpacing;
if (f3 != f4) {
this.textPaint.setLetterSpacing(lerp(f4, f3, f, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
} else {
this.textPaint.setLetterSpacing(f3);
}
this.currentShadowRadius = lerp(this.expandedShadowRadius, this.collapsedShadowRadius, f, null);
this.currentShadowDx = lerp(this.expandedShadowDx, this.collapsedShadowDx, f, null);
this.currentShadowDy = lerp(this.expandedShadowDy, this.collapsedShadowDy, f, null);
int blendARGB = blendARGB(getCurrentColor(this.expandedShadowColor), getCurrentColor(this.collapsedShadowColor), f);
this.currentShadowColor = blendARGB;
this.textPaint.setShadowLayer(this.currentShadowRadius, this.currentShadowDx, this.currentShadowDy, blendARGB);
if (this.fadeModeEnabled) {
this.textPaint.setAlpha((int) (calculateFadeModeTextAlpha(f) * this.textPaint.getAlpha()));
}
ViewCompat.postInvalidateOnAnimation(this.view);
}
private float calculateFadeModeTextAlpha(float f) {
float f2 = this.fadeModeThresholdFraction;
if (f <= f2) {
return AnimationUtils.lerp(1.0f, 0.0f, this.fadeModeStartFraction, f2, f);
}
return AnimationUtils.lerp(0.0f, 1.0f, f2, 1.0f, f);
}
private int getCurrentExpandedTextColor() {
return getCurrentColor(this.expandedTextColor);
}
public int getCurrentCollapsedTextColor() {
return getCurrentColor(this.collapsedTextColor);
}
private int getCurrentColor(ColorStateList colorStateList) {
if (colorStateList == null) {
return 0;
}
int[] iArr = this.state;
if (iArr != null) {
return colorStateList.getColorForState(iArr, 0);
}
return colorStateList.getDefaultColor();
}
private void calculateBaseOffsets(boolean z) {
StaticLayout staticLayout;
calculateUsingTextSize(1.0f, z);
CharSequence charSequence = this.textToDraw;
if (charSequence != null && (staticLayout = this.textLayout) != null) {
this.textToDrawCollapsed = TextUtils.ellipsize(charSequence, this.textPaint, staticLayout.getWidth(), this.titleTextEllipsize);
}
CharSequence charSequence2 = this.textToDrawCollapsed;
float f = 0.0f;
if (charSequence2 != null) {
this.collapsedTextWidth = measureTextWidth(this.textPaint, charSequence2);
} else {
this.collapsedTextWidth = 0.0f;
}
int absoluteGravity = GravityCompat.getAbsoluteGravity(this.collapsedTextGravity, this.isRtl ? 1 : 0);
int i = absoluteGravity & 112;
if (i == 48) {
this.collapsedDrawY = this.collapsedBounds.top;
} else if (i == 80) {
this.collapsedDrawY = this.collapsedBounds.bottom + this.textPaint.ascent();
} else {
this.collapsedDrawY = this.collapsedBounds.centerY() - ((this.textPaint.descent() - this.textPaint.ascent()) / 2.0f);
}
int i2 = absoluteGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK;
if (i2 == 1) {
this.collapsedDrawX = this.collapsedBounds.centerX() - (this.collapsedTextWidth / 2.0f);
} else if (i2 == 5) {
this.collapsedDrawX = this.collapsedBounds.right - this.collapsedTextWidth;
} else {
this.collapsedDrawX = this.collapsedBounds.left;
}
calculateUsingTextSize(0.0f, z);
float height = this.textLayout != null ? r10.getHeight() : 0.0f;
StaticLayout staticLayout2 = this.textLayout;
if (staticLayout2 == null || this.maxLines <= 1) {
CharSequence charSequence3 = this.textToDraw;
if (charSequence3 != null) {
f = measureTextWidth(this.textPaint, charSequence3);
}
} else {
f = staticLayout2.getWidth();
}
StaticLayout staticLayout3 = this.textLayout;
this.expandedLineCount = staticLayout3 != null ? staticLayout3.getLineCount() : 0;
int absoluteGravity2 = GravityCompat.getAbsoluteGravity(this.expandedTextGravity, this.isRtl ? 1 : 0);
int i3 = absoluteGravity2 & 112;
if (i3 == 48) {
this.expandedDrawY = this.expandedBounds.top;
} else if (i3 != 80) {
this.expandedDrawY = this.expandedBounds.centerY() - (height / 2.0f);
} else {
this.expandedDrawY = (this.expandedBounds.bottom - height) + this.textPaint.descent();
}
int i4 = absoluteGravity2 & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK;
if (i4 == 1) {
this.expandedDrawX = this.expandedBounds.centerX() - (f / 2.0f);
} else if (i4 == 5) {
this.expandedDrawX = this.expandedBounds.right - f;
} else {
this.expandedDrawX = this.expandedBounds.left;
}
clearTexture();
setInterpolatedTextSize(this.expandedFraction);
}
private float measureTextWidth(TextPaint textPaint, CharSequence charSequence) {
return textPaint.measureText(charSequence, 0, charSequence.length());
}
private void interpolateBounds(float f) {
if (this.fadeModeEnabled) {
this.currentBounds.set(f < this.fadeModeThresholdFraction ? this.expandedBounds : this.collapsedBounds);
return;
}
this.currentBounds.left = lerp(this.expandedBounds.left, this.collapsedBounds.left, f, this.positionInterpolator);
this.currentBounds.top = lerp(this.expandedDrawY, this.collapsedDrawY, f, this.positionInterpolator);
this.currentBounds.right = lerp(this.expandedBounds.right, this.collapsedBounds.right, f, this.positionInterpolator);
this.currentBounds.bottom = lerp(this.expandedBounds.bottom, this.collapsedBounds.bottom, f, this.positionInterpolator);
}
private void setCollapsedTextBlend(float f) {
this.collapsedTextBlend = f;
ViewCompat.postInvalidateOnAnimation(this.view);
}
private void setExpandedTextBlend(float f) {
this.expandedTextBlend = f;
ViewCompat.postInvalidateOnAnimation(this.view);
}
public void draw(Canvas canvas) {
int save = canvas.save();
if (this.textToDraw == null || this.currentBounds.width() <= 0.0f || this.currentBounds.height() <= 0.0f) {
return;
}
this.textPaint.setTextSize(this.currentTextSize);
float f = this.currentDrawX;
float f2 = this.currentDrawY;
boolean z = this.useTexture && this.expandedTitleTexture != null;
float f3 = this.scale;
if (f3 != 1.0f && !this.fadeModeEnabled) {
canvas.scale(f3, f3, f, f2);
}
if (z) {
canvas.drawBitmap(this.expandedTitleTexture, f, f2, this.texturePaint);
canvas.restoreToCount(save);
return;
}
if (shouldDrawMultiline() && (!this.fadeModeEnabled || this.expandedFraction > this.fadeModeThresholdFraction)) {
drawMultilineTransition(canvas, this.currentDrawX - this.textLayout.getLineStart(0), f2);
} else {
canvas.translate(f, f2);
this.textLayout.draw(canvas);
}
canvas.restoreToCount(save);
}
private void drawMultilineTransition(Canvas canvas, float f, float f2) {
int alpha = this.textPaint.getAlpha();
canvas.translate(f, f2);
if (!this.fadeModeEnabled) {
this.textPaint.setAlpha((int) (this.expandedTextBlend * alpha));
if (Build.VERSION.SDK_INT >= 31) {
TextPaint textPaint = this.textPaint;
textPaint.setShadowLayer(this.currentShadowRadius, this.currentShadowDx, this.currentShadowDy, MaterialColors.compositeARGBWithAlpha(this.currentShadowColor, textPaint.getAlpha()));
}
this.textLayout.draw(canvas);
}
if (!this.fadeModeEnabled) {
this.textPaint.setAlpha((int) (this.collapsedTextBlend * alpha));
}
if (Build.VERSION.SDK_INT >= 31) {
TextPaint textPaint2 = this.textPaint;
textPaint2.setShadowLayer(this.currentShadowRadius, this.currentShadowDx, this.currentShadowDy, MaterialColors.compositeARGBWithAlpha(this.currentShadowColor, textPaint2.getAlpha()));
}
int lineBaseline = this.textLayout.getLineBaseline(0);
CharSequence charSequence = this.textToDrawCollapsed;
float f3 = lineBaseline;
canvas.drawText(charSequence, 0, charSequence.length(), 0.0f, f3, this.textPaint);
if (Build.VERSION.SDK_INT >= 31) {
this.textPaint.setShadowLayer(this.currentShadowRadius, this.currentShadowDx, this.currentShadowDy, this.currentShadowColor);
}
if (this.fadeModeEnabled) {
return;
}
String trim = this.textToDrawCollapsed.toString().trim();
if (trim.endsWith(ELLIPSIS_NORMAL)) {
trim = trim.substring(0, trim.length() - 1);
}
String str = trim;
this.textPaint.setAlpha(alpha);
canvas.drawText(str, 0, Math.min(this.textLayout.getLineEnd(0), str.length()), 0.0f, f3, (Paint) this.textPaint);
}
private boolean calculateIsRtl(CharSequence charSequence) {
boolean isDefaultIsRtl = isDefaultIsRtl();
return this.isRtlTextDirectionHeuristicsEnabled ? isTextDirectionHeuristicsIsRtl(charSequence, isDefaultIsRtl) : isDefaultIsRtl;
}
private boolean isDefaultIsRtl() {
return ViewCompat.getLayoutDirection(this.view) == 1;
}
private boolean isTextDirectionHeuristicsIsRtl(CharSequence charSequence, boolean z) {
TextDirectionHeuristicCompat textDirectionHeuristicCompat;
if (z) {
textDirectionHeuristicCompat = TextDirectionHeuristicsCompat.FIRSTSTRONG_RTL;
} else {
textDirectionHeuristicCompat = TextDirectionHeuristicsCompat.FIRSTSTRONG_LTR;
}
return textDirectionHeuristicCompat.isRtl(charSequence, 0, charSequence.length());
}
private void setInterpolatedTextSize(float f) {
calculateUsingTextSize(f);
boolean z = USE_SCALING_TEXTURE && this.scale != 1.0f;
this.useTexture = z;
if (z) {
ensureExpandedTexture();
}
ViewCompat.postInvalidateOnAnimation(this.view);
}
private void calculateUsingTextSize(float f) {
calculateUsingTextSize(f, false);
}
private void calculateUsingTextSize(float f, boolean z) {
float f2;
float f3;
Typeface typeface;
if (this.text == null) {
return;
}
float width = this.collapsedBounds.width();
float width2 = this.expandedBounds.width();
if (isClose(f, 1.0f)) {
f2 = this.collapsedTextSize;
f3 = this.collapsedLetterSpacing;
this.scale = 1.0f;
typeface = this.collapsedTypeface;
} else {
float f4 = this.expandedTextSize;
float f5 = this.expandedLetterSpacing;
Typeface typeface2 = this.expandedTypeface;
if (isClose(f, 0.0f)) {
this.scale = 1.0f;
} else {
this.scale = lerp(this.expandedTextSize, this.collapsedTextSize, f, this.textSizeInterpolator) / this.expandedTextSize;
}
float f6 = this.collapsedTextSize / this.expandedTextSize;
width = (z || this.fadeModeEnabled || width2 * f6 <= width) ? width2 : Math.min(width / f6, width2);
f2 = f4;
f3 = f5;
typeface = typeface2;
}
if (width > 0.0f) {
boolean z2 = this.currentTextSize != f2;
boolean z3 = this.currentLetterSpacing != f3;
boolean z4 = this.currentTypeface != typeface;
StaticLayout staticLayout = this.textLayout;
boolean z5 = z2 || z3 || (staticLayout != null && (width > ((float) staticLayout.getWidth()) ? 1 : (width == ((float) staticLayout.getWidth()) ? 0 : -1)) != 0) || z4 || this.boundsChanged;
this.currentTextSize = f2;
this.currentLetterSpacing = f3;
this.currentTypeface = typeface;
this.boundsChanged = false;
this.textPaint.setLinearText(this.scale != 1.0f);
r5 = z5;
}
if (this.textToDraw == null || r5) {
this.textPaint.setTextSize(this.currentTextSize);
this.textPaint.setTypeface(this.currentTypeface);
this.textPaint.setLetterSpacing(this.currentLetterSpacing);
this.isRtl = calculateIsRtl(this.text);
StaticLayout createStaticLayout = createStaticLayout(shouldDrawMultiline() ? this.maxLines : 1, width, this.isRtl);
this.textLayout = createStaticLayout;
this.textToDraw = createStaticLayout.getText();
}
}
private StaticLayout createStaticLayout(int i, float f, boolean z) {
StaticLayout staticLayout;
try {
staticLayout = StaticLayoutBuilderCompat.obtain(this.text, this.textPaint, (int) f).setEllipsize(this.titleTextEllipsize).setIsRtl(z).setAlignment(i == 1 ? Layout.Alignment.ALIGN_NORMAL : getMultilineTextLayoutAlignment()).setIncludePad(false).setMaxLines(i).setLineSpacing(this.lineSpacingAdd, this.lineSpacingMultiplier).setHyphenationFrequency(this.hyphenationFrequency).setStaticLayoutBuilderConfigurer(this.staticLayoutBuilderConfigurer).build();
} catch (StaticLayoutBuilderCompat.StaticLayoutBuilderCompatException e) {
Log.e(TAG, e.getCause().getMessage(), e);
staticLayout = null;
}
return (StaticLayout) Preconditions.checkNotNull(staticLayout);
}
private Layout.Alignment getMultilineTextLayoutAlignment() {
int absoluteGravity = GravityCompat.getAbsoluteGravity(this.expandedTextGravity, this.isRtl ? 1 : 0) & 7;
if (absoluteGravity != 1) {
return absoluteGravity != 5 ? this.isRtl ? Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_NORMAL : this.isRtl ? Layout.Alignment.ALIGN_NORMAL : Layout.Alignment.ALIGN_OPPOSITE;
}
return Layout.Alignment.ALIGN_CENTER;
}
private void ensureExpandedTexture() {
if (this.expandedTitleTexture != null || this.expandedBounds.isEmpty() || TextUtils.isEmpty(this.textToDraw)) {
return;
}
calculateOffsets(0.0f);
int width = this.textLayout.getWidth();
int height = this.textLayout.getHeight();
if (width <= 0 || height <= 0) {
return;
}
this.expandedTitleTexture = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
this.textLayout.draw(new Canvas(this.expandedTitleTexture));
if (this.texturePaint == null) {
this.texturePaint = new Paint(3);
}
}
public void recalculate() {
recalculate(false);
}
public void recalculate(boolean z) {
if ((this.view.getHeight() <= 0 || this.view.getWidth() <= 0) && !z) {
return;
}
calculateBaseOffsets(z);
calculateCurrentOffsets();
}
public void setText(CharSequence charSequence) {
if (charSequence == null || !TextUtils.equals(this.text, charSequence)) {
this.text = charSequence;
this.textToDraw = null;
clearTexture();
recalculate();
}
}
private void clearTexture() {
Bitmap bitmap = this.expandedTitleTexture;
if (bitmap != null) {
bitmap.recycle();
this.expandedTitleTexture = null;
}
}
public void setMaxLines(int i) {
if (i != this.maxLines) {
this.maxLines = i;
clearTexture();
recalculate();
}
}
public int getLineCount() {
StaticLayout staticLayout = this.textLayout;
if (staticLayout != null) {
return staticLayout.getLineCount();
}
return 0;
}
public float getLineSpacingAdd() {
return this.textLayout.getSpacingAdd();
}
public float getLineSpacingMultiplier() {
return this.textLayout.getSpacingMultiplier();
}
public void setStaticLayoutBuilderConfigurer(StaticLayoutBuilderConfigurer staticLayoutBuilderConfigurer) {
if (this.staticLayoutBuilderConfigurer != staticLayoutBuilderConfigurer) {
this.staticLayoutBuilderConfigurer = staticLayoutBuilderConfigurer;
recalculate(true);
}
}
private static boolean isClose(float f, float f2) {
return Math.abs(f - f2) < 1.0E-5f;
}
private static int blendARGB(int i, int i2, float f) {
float f2 = 1.0f - f;
return Color.argb(Math.round((Color.alpha(i) * f2) + (Color.alpha(i2) * f)), Math.round((Color.red(i) * f2) + (Color.red(i2) * f)), Math.round((Color.green(i) * f2) + (Color.green(i2) * f)), Math.round((Color.blue(i) * f2) + (Color.blue(i2) * f)));
}
private static float lerp(float f, float f2, float f3, TimeInterpolator timeInterpolator) {
if (timeInterpolator != null) {
f3 = timeInterpolator.getInterpolation(f3);
}
return AnimationUtils.lerp(f, f2, f3);
}
private static boolean rectEquals(Rect rect, int i, int i2, int i3, int i4) {
return rect.left == i && rect.top == i2 && rect.right == i3 && rect.bottom == i4;
}
}

View File

@ -0,0 +1,18 @@
package com.google.android.material.internal;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
/* loaded from: classes.dex */
public class ContextUtils {
public static Activity getActivity(Context context) {
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
return (Activity) context;
}
context = ((ContextWrapper) context).getBaseContext();
}
return null;
}
}

View File

@ -0,0 +1,53 @@
package com.google.android.material.internal;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
/* loaded from: classes.dex */
public class DescendantOffsetUtils {
private static final ThreadLocal<Matrix> matrix = new ThreadLocal<>();
private static final ThreadLocal<RectF> rectF = new ThreadLocal<>();
public static void offsetDescendantRect(ViewGroup viewGroup, View view, Rect rect) {
ThreadLocal<Matrix> threadLocal = matrix;
Matrix matrix2 = threadLocal.get();
if (matrix2 == null) {
matrix2 = new Matrix();
threadLocal.set(matrix2);
} else {
matrix2.reset();
}
offsetDescendantMatrix(viewGroup, view, matrix2);
ThreadLocal<RectF> threadLocal2 = rectF;
RectF rectF2 = threadLocal2.get();
if (rectF2 == null) {
rectF2 = new RectF();
threadLocal2.set(rectF2);
}
rectF2.set(rect);
matrix2.mapRect(rectF2);
rect.set((int) (rectF2.left + 0.5f), (int) (rectF2.top + 0.5f), (int) (rectF2.right + 0.5f), (int) (rectF2.bottom + 0.5f));
}
public static void getDescendantRect(ViewGroup viewGroup, View view, Rect rect) {
rect.set(0, 0, view.getWidth(), view.getHeight());
offsetDescendantRect(viewGroup, view, rect);
}
private static void offsetDescendantMatrix(ViewParent viewParent, View view, Matrix matrix2) {
Object parent = view.getParent();
if ((parent instanceof View) && parent != viewParent) {
offsetDescendantMatrix(viewParent, (View) parent, matrix2);
matrix2.preTranslate(-r0.getScrollX(), -r0.getScrollY());
}
matrix2.preTranslate(view.getLeft(), view.getTop());
if (view.getMatrix().isIdentity()) {
return;
}
matrix2.preConcat(view.getMatrix());
}
}

View File

@ -0,0 +1,75 @@
package com.google.android.material.internal;
import android.R;
import android.content.Context;
import android.os.Build;
import android.view.Window;
import androidx.core.graphics.ColorUtils;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import com.google.android.material.color.MaterialColors;
/* loaded from: classes.dex */
public class EdgeToEdgeUtils {
private static final int EDGE_TO_EDGE_BAR_ALPHA = 128;
private EdgeToEdgeUtils() {
}
public static void applyEdgeToEdge(Window window, boolean z) {
applyEdgeToEdge(window, z, null, null);
}
public static void applyEdgeToEdge(Window window, boolean z, Integer num, Integer num2) {
boolean z2 = num == null || num.intValue() == 0;
boolean z3 = num2 == null || num2.intValue() == 0;
if (z2 || z3) {
int color = MaterialColors.getColor(window.getContext(), R.attr.colorBackground, ViewCompat.MEASURED_STATE_MASK);
if (z2) {
num = Integer.valueOf(color);
}
if (z3) {
num2 = Integer.valueOf(color);
}
}
WindowCompat.setDecorFitsSystemWindows(window, !z);
int statusBarColor = getStatusBarColor(window.getContext(), z);
int navigationBarColor = getNavigationBarColor(window.getContext(), z);
window.setStatusBarColor(statusBarColor);
window.setNavigationBarColor(navigationBarColor);
setLightStatusBar(window, isUsingLightSystemBar(statusBarColor, MaterialColors.isColorLight(num.intValue())));
setLightNavigationBar(window, isUsingLightSystemBar(navigationBarColor, MaterialColors.isColorLight(num2.intValue())));
}
public static void setLightStatusBar(Window window, boolean z) {
WindowCompat.getInsetsController(window, window.getDecorView()).setAppearanceLightStatusBars(z);
}
public static void setLightNavigationBar(Window window, boolean z) {
WindowCompat.getInsetsController(window, window.getDecorView()).setAppearanceLightNavigationBars(z);
}
private static int getStatusBarColor(Context context, boolean z) {
if (z && Build.VERSION.SDK_INT < 23) {
return ColorUtils.setAlphaComponent(MaterialColors.getColor(context, R.attr.statusBarColor, ViewCompat.MEASURED_STATE_MASK), 128);
}
if (z) {
return 0;
}
return MaterialColors.getColor(context, R.attr.statusBarColor, ViewCompat.MEASURED_STATE_MASK);
}
private static int getNavigationBarColor(Context context, boolean z) {
if (z && Build.VERSION.SDK_INT < 27) {
return ColorUtils.setAlphaComponent(MaterialColors.getColor(context, R.attr.navigationBarColor, ViewCompat.MEASURED_STATE_MASK), 128);
}
if (z) {
return 0;
}
return MaterialColors.getColor(context, R.attr.navigationBarColor, ViewCompat.MEASURED_STATE_MASK);
}
private static boolean isUsingLightSystemBar(int i, boolean z) {
return MaterialColors.isColorLight(i) || (i == 0 && z);
}
}

View File

@ -0,0 +1,145 @@
package com.google.android.material.internal;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.graphics.Rect;
import android.view.View;
import com.google.android.material.animation.AnimationUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public class ExpandCollapseAnimationHelper {
private ValueAnimator.AnimatorUpdateListener additionalUpdateListener;
private final View collapsedView;
private int collapsedViewOffsetY;
private long duration;
private final View expandedView;
private int expandedViewOffsetY;
private final List<AnimatorListenerAdapter> listeners = new ArrayList();
private final List<View> endAnchoredViews = new ArrayList();
public ExpandCollapseAnimationHelper setAdditionalUpdateListener(ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
this.additionalUpdateListener = animatorUpdateListener;
return this;
}
public ExpandCollapseAnimationHelper setCollapsedViewOffsetY(int i) {
this.collapsedViewOffsetY = i;
return this;
}
public ExpandCollapseAnimationHelper setDuration(long j) {
this.duration = j;
return this;
}
public ExpandCollapseAnimationHelper setExpandedViewOffsetY(int i) {
this.expandedViewOffsetY = i;
return this;
}
public ExpandCollapseAnimationHelper(View view, View view2) {
this.collapsedView = view;
this.expandedView = view2;
}
public Animator getExpandAnimator() {
AnimatorSet animatorSet = getAnimatorSet(true);
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.internal.ExpandCollapseAnimationHelper.1
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
ExpandCollapseAnimationHelper.this.expandedView.setVisibility(0);
}
});
addListeners(animatorSet, this.listeners);
return animatorSet;
}
public Animator getCollapseAnimator() {
AnimatorSet animatorSet = getAnimatorSet(false);
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.internal.ExpandCollapseAnimationHelper.2
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
ExpandCollapseAnimationHelper.this.expandedView.setVisibility(8);
}
});
addListeners(animatorSet, this.listeners);
return animatorSet;
}
public ExpandCollapseAnimationHelper addListener(AnimatorListenerAdapter animatorListenerAdapter) {
this.listeners.add(animatorListenerAdapter);
return this;
}
public ExpandCollapseAnimationHelper addEndAnchoredViews(View... viewArr) {
Collections.addAll(this.endAnchoredViews, viewArr);
return this;
}
public ExpandCollapseAnimationHelper addEndAnchoredViews(Collection<View> collection) {
this.endAnchoredViews.addAll(collection);
return this;
}
private AnimatorSet getAnimatorSet(boolean z) {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(getExpandCollapseAnimator(z), getExpandedViewChildrenAlphaAnimator(z), getEndAnchoredViewsTranslateAnimator(z));
return animatorSet;
}
private Animator getExpandCollapseAnimator(boolean z) {
Rect calculateRectFromBounds = ViewUtils.calculateRectFromBounds(this.collapsedView, this.collapsedViewOffsetY);
Rect calculateRectFromBounds2 = ViewUtils.calculateRectFromBounds(this.expandedView, this.expandedViewOffsetY);
final Rect rect = new Rect(calculateRectFromBounds);
ValueAnimator ofObject = ValueAnimator.ofObject(new RectEvaluator(rect), calculateRectFromBounds, calculateRectFromBounds2);
ofObject.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.internal.ExpandCollapseAnimationHelper$$ExternalSyntheticLambda0
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
ExpandCollapseAnimationHelper.this.m243xeb41e2ac(rect, valueAnimator);
}
});
ValueAnimator.AnimatorUpdateListener animatorUpdateListener = this.additionalUpdateListener;
if (animatorUpdateListener != null) {
ofObject.addUpdateListener(animatorUpdateListener);
}
ofObject.setDuration(this.duration);
ofObject.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
return ofObject;
}
/* renamed from: lambda$getExpandCollapseAnimator$0$com-google-android-material-internal-ExpandCollapseAnimationHelper, reason: not valid java name */
/* synthetic */ void m243xeb41e2ac(Rect rect, ValueAnimator valueAnimator) {
ViewUtils.setBoundsFromRect(this.expandedView, rect);
}
private Animator getExpandedViewChildrenAlphaAnimator(boolean z) {
List<View> children = ViewUtils.getChildren(this.expandedView);
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
ofFloat.addUpdateListener(MultiViewUpdateListener.alphaListener(children));
ofFloat.setDuration(this.duration);
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.LINEAR_INTERPOLATOR));
return ofFloat;
}
private Animator getEndAnchoredViewsTranslateAnimator(boolean z) {
ValueAnimator ofFloat = ValueAnimator.ofFloat((this.expandedView.getLeft() - this.collapsedView.getLeft()) + (this.collapsedView.getRight() - this.expandedView.getRight()), 0.0f);
ofFloat.addUpdateListener(MultiViewUpdateListener.translationXListener(this.endAnchoredViews));
ofFloat.setDuration(this.duration);
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
return ofFloat;
}
private void addListeners(Animator animator, List<AnimatorListenerAdapter> list) {
Iterator<AnimatorListenerAdapter> it = list.iterator();
while (it.hasNext()) {
animator.addListener(it.next());
}
}
}

View File

@ -0,0 +1,14 @@
package com.google.android.material.internal;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
@Deprecated
/* loaded from: classes.dex */
public @interface Experimental {
String value() default "";
}

View File

@ -0,0 +1,98 @@
package com.google.android.material.internal;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.drawable.Drawable;
/* loaded from: classes.dex */
public class FadeThroughDrawable extends Drawable {
private final float[] alphas;
private final Drawable fadeInDrawable;
private final Drawable fadeOutDrawable;
private float progress;
@Override // android.graphics.drawable.Drawable
public int getOpacity() {
return -3;
}
public FadeThroughDrawable(Drawable drawable, Drawable drawable2) {
this.fadeOutDrawable = drawable.getConstantState().newDrawable().mutate();
Drawable mutate = drawable2.getConstantState().newDrawable().mutate();
this.fadeInDrawable = mutate;
mutate.setAlpha(0);
this.alphas = new float[2];
}
@Override // android.graphics.drawable.Drawable
public void draw(Canvas canvas) {
this.fadeOutDrawable.draw(canvas);
this.fadeInDrawable.draw(canvas);
}
@Override // android.graphics.drawable.Drawable
public void setBounds(int i, int i2, int i3, int i4) {
super.setBounds(i, i2, i3, i4);
this.fadeOutDrawable.setBounds(i, i2, i3, i4);
this.fadeInDrawable.setBounds(i, i2, i3, i4);
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicWidth() {
return Math.max(this.fadeOutDrawable.getIntrinsicWidth(), this.fadeInDrawable.getIntrinsicWidth());
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicHeight() {
return Math.max(this.fadeOutDrawable.getIntrinsicHeight(), this.fadeInDrawable.getIntrinsicHeight());
}
@Override // android.graphics.drawable.Drawable
public int getMinimumWidth() {
return Math.max(this.fadeOutDrawable.getMinimumWidth(), this.fadeInDrawable.getMinimumWidth());
}
@Override // android.graphics.drawable.Drawable
public int getMinimumHeight() {
return Math.max(this.fadeOutDrawable.getMinimumHeight(), this.fadeInDrawable.getMinimumHeight());
}
@Override // android.graphics.drawable.Drawable
public void setAlpha(int i) {
if (this.progress <= 0.5f) {
this.fadeOutDrawable.setAlpha(i);
this.fadeInDrawable.setAlpha(0);
} else {
this.fadeOutDrawable.setAlpha(0);
this.fadeInDrawable.setAlpha(i);
}
invalidateSelf();
}
@Override // android.graphics.drawable.Drawable
public void setColorFilter(ColorFilter colorFilter) {
this.fadeOutDrawable.setColorFilter(colorFilter);
this.fadeInDrawable.setColorFilter(colorFilter);
invalidateSelf();
}
@Override // android.graphics.drawable.Drawable
public boolean isStateful() {
return this.fadeOutDrawable.isStateful() || this.fadeInDrawable.isStateful();
}
@Override // android.graphics.drawable.Drawable
public boolean setState(int[] iArr) {
return this.fadeOutDrawable.setState(iArr) || this.fadeInDrawable.setState(iArr);
}
public void setProgress(float f) {
if (this.progress != f) {
this.progress = f;
FadeThroughUtils.calculateFadeOutAndInAlphas(f, this.alphas);
this.fadeOutDrawable.setAlpha((int) (this.alphas[0] * 255.0f));
this.fadeInDrawable.setAlpha((int) (this.alphas[1] * 255.0f));
invalidateSelf();
}
}
}

View File

@ -0,0 +1,29 @@
package com.google.android.material.internal;
import android.animation.ValueAnimator;
import android.view.View;
/* loaded from: classes.dex */
public class FadeThroughUpdateListener implements ValueAnimator.AnimatorUpdateListener {
private final float[] alphas = new float[2];
private final View fadeInView;
private final View fadeOutView;
public FadeThroughUpdateListener(View view, View view2) {
this.fadeOutView = view;
this.fadeInView = view2;
}
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
FadeThroughUtils.calculateFadeOutAndInAlphas(((Float) valueAnimator.getAnimatedValue()).floatValue(), this.alphas);
View view = this.fadeOutView;
if (view != null) {
view.setAlpha(this.alphas[0]);
}
View view2 = this.fadeInView;
if (view2 != null) {
view2.setAlpha(this.alphas[1]);
}
}
}

View File

@ -0,0 +1,19 @@
package com.google.android.material.internal;
/* loaded from: classes.dex */
final class FadeThroughUtils {
static final float THRESHOLD_ALPHA = 0.5f;
static void calculateFadeOutAndInAlphas(float f, float[] fArr) {
if (f <= 0.5f) {
fArr[0] = 1.0f - (f * 2.0f);
fArr[1] = 0.0f;
} else {
fArr[0] = 0.0f;
fArr[1] = (f * 2.0f) - 1.0f;
}
}
private FadeThroughUtils() {
}
}

View File

@ -0,0 +1,189 @@
package com.google.android.material.internal;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import androidx.core.view.MarginLayoutParamsCompat;
import androidx.core.view.ViewCompat;
import com.google.android.material.R;
/* loaded from: classes.dex */
public class FlowLayout extends ViewGroup {
private int itemSpacing;
private int lineSpacing;
private int rowCount;
private boolean singleLine;
protected int getItemSpacing() {
return this.itemSpacing;
}
protected int getLineSpacing() {
return this.lineSpacing;
}
protected int getRowCount() {
return this.rowCount;
}
public boolean isSingleLine() {
return this.singleLine;
}
protected void setItemSpacing(int i) {
this.itemSpacing = i;
}
protected void setLineSpacing(int i) {
this.lineSpacing = i;
}
public void setSingleLine(boolean z) {
this.singleLine = z;
}
public FlowLayout(Context context) {
this(context, null);
}
public FlowLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public FlowLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.singleLine = false;
loadFromAttributes(context, attributeSet);
}
public FlowLayout(Context context, AttributeSet attributeSet, int i, int i2) {
super(context, attributeSet, i, i2);
this.singleLine = false;
loadFromAttributes(context, attributeSet);
}
private void loadFromAttributes(Context context, AttributeSet attributeSet) {
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, R.styleable.FlowLayout, 0, 0);
this.lineSpacing = obtainStyledAttributes.getDimensionPixelSize(R.styleable.FlowLayout_lineSpacing, 0);
this.itemSpacing = obtainStyledAttributes.getDimensionPixelSize(R.styleable.FlowLayout_itemSpacing, 0);
obtainStyledAttributes.recycle();
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
int i3;
int i4;
int i5;
int size = View.MeasureSpec.getSize(i);
int mode = View.MeasureSpec.getMode(i);
int size2 = View.MeasureSpec.getSize(i2);
int mode2 = View.MeasureSpec.getMode(i2);
int i6 = (mode == Integer.MIN_VALUE || mode == 1073741824) ? size : Integer.MAX_VALUE;
int paddingLeft = getPaddingLeft();
int paddingTop = getPaddingTop();
int paddingRight = i6 - getPaddingRight();
int i7 = paddingTop;
int i8 = 0;
for (int i9 = 0; i9 < getChildCount(); i9++) {
View childAt = getChildAt(i9);
if (childAt.getVisibility() != 8) {
measureChild(childAt, i, i2);
ViewGroup.LayoutParams layoutParams = childAt.getLayoutParams();
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
i3 = marginLayoutParams.leftMargin;
i4 = marginLayoutParams.rightMargin;
} else {
i3 = 0;
i4 = 0;
}
int i10 = paddingLeft;
if (paddingLeft + i3 + childAt.getMeasuredWidth() <= paddingRight || isSingleLine()) {
i5 = i10;
} else {
i5 = getPaddingLeft();
i7 = this.lineSpacing + paddingTop;
}
int measuredWidth = i5 + i3 + childAt.getMeasuredWidth();
int measuredHeight = i7 + childAt.getMeasuredHeight();
if (measuredWidth > i8) {
i8 = measuredWidth;
}
paddingLeft = i5 + i3 + i4 + childAt.getMeasuredWidth() + this.itemSpacing;
if (i9 == getChildCount() - 1) {
i8 += i4;
}
paddingTop = measuredHeight;
}
}
setMeasuredDimension(getMeasuredDimension(size, mode, i8 + getPaddingRight()), getMeasuredDimension(size2, mode2, paddingTop + getPaddingBottom()));
}
private static int getMeasuredDimension(int i, int i2, int i3) {
if (i2 != Integer.MIN_VALUE) {
return i2 != 1073741824 ? i3 : i;
}
return Math.min(i3, i);
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int i5;
int i6;
if (getChildCount() == 0) {
this.rowCount = 0;
return;
}
this.rowCount = 1;
boolean z2 = ViewCompat.getLayoutDirection(this) == 1;
int paddingRight = z2 ? getPaddingRight() : getPaddingLeft();
int paddingLeft = z2 ? getPaddingLeft() : getPaddingRight();
int paddingTop = getPaddingTop();
int i7 = (i3 - i) - paddingLeft;
int i8 = paddingRight;
int i9 = paddingTop;
for (int i10 = 0; i10 < getChildCount(); i10++) {
View childAt = getChildAt(i10);
if (childAt.getVisibility() == 8) {
childAt.setTag(R.id.row_index_key, -1);
} else {
ViewGroup.LayoutParams layoutParams = childAt.getLayoutParams();
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
i6 = MarginLayoutParamsCompat.getMarginStart(marginLayoutParams);
i5 = MarginLayoutParamsCompat.getMarginEnd(marginLayoutParams);
} else {
i5 = 0;
i6 = 0;
}
int measuredWidth = i8 + i6 + childAt.getMeasuredWidth();
if (!this.singleLine && measuredWidth > i7) {
i9 = this.lineSpacing + paddingTop;
this.rowCount++;
i8 = paddingRight;
}
childAt.setTag(R.id.row_index_key, Integer.valueOf(this.rowCount - 1));
int i11 = i8 + i6;
int measuredWidth2 = childAt.getMeasuredWidth() + i11;
int measuredHeight = childAt.getMeasuredHeight() + i9;
if (z2) {
childAt.layout(i7 - measuredWidth2, i9, (i7 - i8) - i6, measuredHeight);
} else {
childAt.layout(i11, i9, measuredWidth2, measuredHeight);
}
i8 += i6 + i5 + childAt.getMeasuredWidth() + this.itemSpacing;
paddingTop = measuredHeight;
}
}
}
public int getRowIndex(View view) {
Object tag = view.getTag(R.id.row_index_key);
if (tag instanceof Integer) {
return ((Integer) tag).intValue();
}
return -1;
}
}

View File

@ -0,0 +1,169 @@
package com.google.android.material.internal;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.core.view.GravityCompat;
import com.google.android.material.R;
/* loaded from: classes.dex */
public class ForegroundLinearLayout extends LinearLayoutCompat {
private Drawable foreground;
boolean foregroundBoundsChanged;
private int foregroundGravity;
protected boolean mForegroundInPadding;
private final Rect overlayBounds;
private final Rect selfBounds;
@Override // android.view.View
public Drawable getForeground() {
return this.foreground;
}
@Override // android.view.View
public int getForegroundGravity() {
return this.foregroundGravity;
}
public ForegroundLinearLayout(Context context) {
this(context, null);
}
public ForegroundLinearLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public ForegroundLinearLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.selfBounds = new Rect();
this.overlayBounds = new Rect();
this.foregroundGravity = 119;
this.mForegroundInPadding = true;
this.foregroundBoundsChanged = false;
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, attributeSet, R.styleable.ForegroundLinearLayout, i, 0, new int[0]);
this.foregroundGravity = obtainStyledAttributes.getInt(R.styleable.ForegroundLinearLayout_android_foregroundGravity, this.foregroundGravity);
Drawable drawable = obtainStyledAttributes.getDrawable(R.styleable.ForegroundLinearLayout_android_foreground);
if (drawable != null) {
setForeground(drawable);
}
this.mForegroundInPadding = obtainStyledAttributes.getBoolean(R.styleable.ForegroundLinearLayout_foregroundInsidePadding, true);
obtainStyledAttributes.recycle();
}
@Override // android.view.View
public void setForegroundGravity(int i) {
if (this.foregroundGravity != i) {
if ((8388615 & i) == 0) {
i |= GravityCompat.START;
}
if ((i & 112) == 0) {
i |= 48;
}
this.foregroundGravity = i;
if (i == 119 && this.foreground != null) {
this.foreground.getPadding(new Rect());
}
requestLayout();
}
}
@Override // android.view.View
protected boolean verifyDrawable(Drawable drawable) {
return super.verifyDrawable(drawable) || drawable == this.foreground;
}
@Override // android.view.ViewGroup, android.view.View
public void jumpDrawablesToCurrentState() {
super.jumpDrawablesToCurrentState();
Drawable drawable = this.foreground;
if (drawable != null) {
drawable.jumpToCurrentState();
}
}
@Override // android.view.ViewGroup, android.view.View
protected void drawableStateChanged() {
super.drawableStateChanged();
Drawable drawable = this.foreground;
if (drawable == null || !drawable.isStateful()) {
return;
}
this.foreground.setState(getDrawableState());
}
@Override // android.view.View
public void setForeground(Drawable drawable) {
Drawable drawable2 = this.foreground;
if (drawable2 != drawable) {
if (drawable2 != null) {
drawable2.setCallback(null);
unscheduleDrawable(this.foreground);
}
this.foreground = drawable;
this.foregroundBoundsChanged = true;
if (drawable != null) {
setWillNotDraw(false);
drawable.setCallback(this);
if (drawable.isStateful()) {
drawable.setState(getDrawableState());
}
if (this.foregroundGravity == 119) {
drawable.getPadding(new Rect());
}
} else {
setWillNotDraw(true);
}
requestLayout();
invalidate();
}
}
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
this.foregroundBoundsChanged = z | this.foregroundBoundsChanged;
}
@Override // android.view.View
protected void onSizeChanged(int i, int i2, int i3, int i4) {
super.onSizeChanged(i, i2, i3, i4);
this.foregroundBoundsChanged = true;
}
@Override // android.view.View
public void draw(Canvas canvas) {
super.draw(canvas);
Drawable drawable = this.foreground;
if (drawable != null) {
if (this.foregroundBoundsChanged) {
this.foregroundBoundsChanged = false;
Rect rect = this.selfBounds;
Rect rect2 = this.overlayBounds;
int right = getRight() - getLeft();
int bottom = getBottom() - getTop();
if (this.mForegroundInPadding) {
rect.set(0, 0, right, bottom);
} else {
rect.set(getPaddingLeft(), getPaddingTop(), right - getPaddingRight(), bottom - getPaddingBottom());
}
Gravity.apply(this.foregroundGravity, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), rect, rect2);
drawable.setBounds(rect2);
}
drawable.draw(canvas);
}
}
@Override // android.view.View
public void drawableHotspotChanged(float f, float f2) {
super.drawableHotspotChanged(f, f2);
Drawable drawable = this.foreground;
if (drawable != null) {
drawable.setHotspot(f, f2);
}
}
}

View File

@ -0,0 +1,35 @@
package com.google.android.material.internal;
import android.os.Build;
import java.util.Locale;
/* loaded from: classes.dex */
public class ManufacturerUtils {
private static final String LGE = "lge";
private static final String MEIZU = "meizu";
private static final String SAMSUNG = "samsung";
private ManufacturerUtils() {
}
public static boolean isMeizuDevice() {
return getManufacturer().equals(MEIZU);
}
public static boolean isLGEDevice() {
return getManufacturer().equals(LGE);
}
public static boolean isSamsungDevice() {
return getManufacturer().equals(SAMSUNG);
}
public static boolean isDateInputKeyboardMissingSeparatorCharacters() {
return isLGEDevice() || isSamsungDevice();
}
private static String getManufacturer() {
String str = Build.MANUFACTURER;
return str != null ? str.toLowerCase(Locale.ENGLISH) : "";
}
}

View File

@ -0,0 +1,16 @@
package com.google.android.material.internal;
import android.widget.Checkable;
import com.google.android.material.internal.MaterialCheckable;
/* loaded from: classes.dex */
public interface MaterialCheckable<T extends MaterialCheckable<T>> extends Checkable {
public interface OnCheckedChangeListener<C> {
void onCheckedChanged(C c, boolean z);
}
int getId();
void setInternalOnCheckedChangeListener(OnCheckedChangeListener<T> onCheckedChangeListener);
}

View File

@ -0,0 +1,14 @@
package com.google.android.material.internal;
import android.animation.ValueAnimator;
import android.view.View;
import com.google.android.material.internal.MultiViewUpdateListener;
/* compiled from: D8$$SyntheticClass */
/* loaded from: classes.dex */
public final /* synthetic */ class MultiViewUpdateListener$$ExternalSyntheticLambda0 implements MultiViewUpdateListener.Listener {
@Override // com.google.android.material.internal.MultiViewUpdateListener.Listener
public final void onAnimationUpdate(ValueAnimator valueAnimator, View view) {
MultiViewUpdateListener.setTranslationX(valueAnimator, view);
}
}

View File

@ -0,0 +1,14 @@
package com.google.android.material.internal;
import android.animation.ValueAnimator;
import android.view.View;
import com.google.android.material.internal.MultiViewUpdateListener;
/* compiled from: D8$$SyntheticClass */
/* loaded from: classes.dex */
public final /* synthetic */ class MultiViewUpdateListener$$ExternalSyntheticLambda1 implements MultiViewUpdateListener.Listener {
@Override // com.google.android.material.internal.MultiViewUpdateListener.Listener
public final void onAnimationUpdate(ValueAnimator valueAnimator, View view) {
MultiViewUpdateListener.setScale(valueAnimator, view);
}
}

View File

@ -0,0 +1,14 @@
package com.google.android.material.internal;
import android.animation.ValueAnimator;
import android.view.View;
import com.google.android.material.internal.MultiViewUpdateListener;
/* compiled from: D8$$SyntheticClass */
/* loaded from: classes.dex */
public final /* synthetic */ class MultiViewUpdateListener$$ExternalSyntheticLambda2 implements MultiViewUpdateListener.Listener {
@Override // com.google.android.material.internal.MultiViewUpdateListener.Listener
public final void onAnimationUpdate(ValueAnimator valueAnimator, View view) {
MultiViewUpdateListener.setTranslationY(valueAnimator, view);
}
}

View File

@ -0,0 +1,14 @@
package com.google.android.material.internal;
import android.animation.ValueAnimator;
import android.view.View;
import com.google.android.material.internal.MultiViewUpdateListener;
/* compiled from: D8$$SyntheticClass */
/* loaded from: classes.dex */
public final /* synthetic */ class MultiViewUpdateListener$$ExternalSyntheticLambda3 implements MultiViewUpdateListener.Listener {
@Override // com.google.android.material.internal.MultiViewUpdateListener.Listener
public final void onAnimationUpdate(ValueAnimator valueAnimator, View view) {
MultiViewUpdateListener.setAlpha(valueAnimator, view);
}
}

View File

@ -0,0 +1,86 @@
package com.google.android.material.internal;
import android.animation.ValueAnimator;
import android.view.View;
import java.util.Collection;
/* loaded from: classes.dex */
public class MultiViewUpdateListener implements ValueAnimator.AnimatorUpdateListener {
private final Listener listener;
private final View[] views;
interface Listener {
void onAnimationUpdate(ValueAnimator valueAnimator, View view);
}
public MultiViewUpdateListener(Listener listener, View... viewArr) {
this.listener = listener;
this.views = viewArr;
}
public MultiViewUpdateListener(Listener listener, Collection<View> collection) {
this.listener = listener;
this.views = (View[]) collection.toArray(new View[0]);
}
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
for (View view : this.views) {
this.listener.onAnimationUpdate(valueAnimator, view);
}
}
public static MultiViewUpdateListener alphaListener(View... viewArr) {
return new MultiViewUpdateListener(new MultiViewUpdateListener$$ExternalSyntheticLambda3(), viewArr);
}
public static MultiViewUpdateListener alphaListener(Collection<View> collection) {
return new MultiViewUpdateListener(new MultiViewUpdateListener$$ExternalSyntheticLambda3(), collection);
}
/* JADX INFO: Access modifiers changed from: private */
public static void setAlpha(ValueAnimator valueAnimator, View view) {
view.setAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
}
public static MultiViewUpdateListener scaleListener(View... viewArr) {
return new MultiViewUpdateListener(new MultiViewUpdateListener$$ExternalSyntheticLambda1(), viewArr);
}
public static MultiViewUpdateListener scaleListener(Collection<View> collection) {
return new MultiViewUpdateListener(new MultiViewUpdateListener$$ExternalSyntheticLambda1(), collection);
}
/* JADX INFO: Access modifiers changed from: private */
public static void setScale(ValueAnimator valueAnimator, View view) {
Float f = (Float) valueAnimator.getAnimatedValue();
view.setScaleX(f.floatValue());
view.setScaleY(f.floatValue());
}
public static MultiViewUpdateListener translationXListener(View... viewArr) {
return new MultiViewUpdateListener(new MultiViewUpdateListener$$ExternalSyntheticLambda0(), viewArr);
}
public static MultiViewUpdateListener translationXListener(Collection<View> collection) {
return new MultiViewUpdateListener(new MultiViewUpdateListener$$ExternalSyntheticLambda0(), collection);
}
/* JADX INFO: Access modifiers changed from: private */
public static void setTranslationX(ValueAnimator valueAnimator, View view) {
view.setTranslationX(((Float) valueAnimator.getAnimatedValue()).floatValue());
}
public static MultiViewUpdateListener translationYListener(View... viewArr) {
return new MultiViewUpdateListener(new MultiViewUpdateListener$$ExternalSyntheticLambda2(), viewArr);
}
public static MultiViewUpdateListener translationYListener(Collection<View> collection) {
return new MultiViewUpdateListener(new MultiViewUpdateListener$$ExternalSyntheticLambda2(), collection);
}
/* JADX INFO: Access modifiers changed from: private */
public static void setTranslationY(ValueAnimator valueAnimator, View view) {
view.setTranslationY(((Float) valueAnimator.getAnimatedValue()).floatValue());
}
}

View File

@ -0,0 +1,21 @@
package com.google.android.material.internal;
import android.content.Context;
import android.view.SubMenu;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.view.menu.MenuItemImpl;
/* loaded from: classes.dex */
public class NavigationMenu extends MenuBuilder {
public NavigationMenu(Context context) {
super(context);
}
@Override // androidx.appcompat.view.menu.MenuBuilder, android.view.Menu
public SubMenu addSubMenu(int i, int i2, int i3, CharSequence charSequence) {
MenuItemImpl menuItemImpl = (MenuItemImpl) addInternal(i, i2, i3, charSequence);
NavigationSubMenu navigationSubMenu = new NavigationSubMenu(getContext(), this, menuItemImpl);
menuItemImpl.setSubMenu(navigationSubMenu);
return navigationSubMenu;
}
}

View File

@ -0,0 +1,265 @@
package com.google.android.material.internal;
import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.CheckedTextView;
import android.widget.FrameLayout;
import androidx.appcompat.view.menu.MenuItemImpl;
import androidx.appcompat.view.menu.MenuView;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.appcompat.widget.TooltipCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.widget.TextViewCompat;
/* loaded from: classes.dex */
public class NavigationMenuItemView extends ForegroundLinearLayout implements MenuView.ItemView {
private static final int[] CHECKED_STATE_SET = {R.attr.state_checked};
private final AccessibilityDelegateCompat accessibilityDelegate;
private FrameLayout actionArea;
boolean checkable;
private Drawable emptyDrawable;
private boolean hasIconTintList;
private int iconSize;
private ColorStateList iconTintList;
boolean isBold;
private MenuItemImpl itemData;
private boolean needsEmptyIcon;
private final CheckedTextView textView;
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public MenuItemImpl getItemData() {
return this.itemData;
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public boolean prefersCondensedTitle() {
return false;
}
public void setIconSize(int i) {
this.iconSize = i;
}
public void setNeedsEmptyIcon(boolean z) {
this.needsEmptyIcon = z;
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public void setShortcut(boolean z, char c) {
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public boolean showsIcon() {
return true;
}
public NavigationMenuItemView(Context context) {
this(context, null);
}
public NavigationMenuItemView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public NavigationMenuItemView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.isBold = true;
AccessibilityDelegateCompat accessibilityDelegateCompat = new AccessibilityDelegateCompat() { // from class: com.google.android.material.internal.NavigationMenuItemView.1
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setCheckable(NavigationMenuItemView.this.checkable);
}
};
this.accessibilityDelegate = accessibilityDelegateCompat;
setOrientation(0);
LayoutInflater.from(context).inflate(com.google.android.material.R.layout.design_navigation_menu_item, (ViewGroup) this, true);
setIconSize(context.getResources().getDimensionPixelSize(com.google.android.material.R.dimen.design_navigation_icon_size));
CheckedTextView checkedTextView = (CheckedTextView) findViewById(com.google.android.material.R.id.design_menu_item_text);
this.textView = checkedTextView;
checkedTextView.setDuplicateParentStateEnabled(true);
ViewCompat.setAccessibilityDelegate(checkedTextView, accessibilityDelegateCompat);
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public void initialize(MenuItemImpl menuItemImpl, int i) {
this.itemData = menuItemImpl;
if (menuItemImpl.getItemId() > 0) {
setId(menuItemImpl.getItemId());
}
setVisibility(menuItemImpl.isVisible() ? 0 : 8);
if (getBackground() == null) {
ViewCompat.setBackground(this, createDefaultBackground());
}
setCheckable(menuItemImpl.isCheckable());
setChecked(menuItemImpl.isChecked());
setEnabled(menuItemImpl.isEnabled());
setTitle(menuItemImpl.getTitle());
setIcon(menuItemImpl.getIcon());
setActionView(menuItemImpl.getActionView());
setContentDescription(menuItemImpl.getContentDescription());
TooltipCompat.setTooltipText(this, menuItemImpl.getTooltipText());
adjustAppearance();
}
public void initialize(MenuItemImpl menuItemImpl, boolean z) {
this.isBold = z;
initialize(menuItemImpl, 0);
}
private boolean shouldExpandActionArea() {
return this.itemData.getTitle() == null && this.itemData.getIcon() == null && this.itemData.getActionView() != null;
}
private void adjustAppearance() {
if (shouldExpandActionArea()) {
this.textView.setVisibility(8);
FrameLayout frameLayout = this.actionArea;
if (frameLayout != null) {
LinearLayoutCompat.LayoutParams layoutParams = (LinearLayoutCompat.LayoutParams) frameLayout.getLayoutParams();
layoutParams.width = -1;
this.actionArea.setLayoutParams(layoutParams);
return;
}
return;
}
this.textView.setVisibility(0);
FrameLayout frameLayout2 = this.actionArea;
if (frameLayout2 != null) {
LinearLayoutCompat.LayoutParams layoutParams2 = (LinearLayoutCompat.LayoutParams) frameLayout2.getLayoutParams();
layoutParams2.width = -2;
this.actionArea.setLayoutParams(layoutParams2);
}
}
public void recycle() {
FrameLayout frameLayout = this.actionArea;
if (frameLayout != null) {
frameLayout.removeAllViews();
}
this.textView.setCompoundDrawables(null, null, null, null);
}
private void setActionView(View view) {
if (view != null) {
if (this.actionArea == null) {
this.actionArea = (FrameLayout) ((ViewStub) findViewById(com.google.android.material.R.id.design_menu_item_action_area_stub)).inflate();
}
this.actionArea.removeAllViews();
this.actionArea.addView(view);
}
}
private StateListDrawable createDefaultBackground() {
TypedValue typedValue = new TypedValue();
if (!getContext().getTheme().resolveAttribute(androidx.appcompat.R.attr.colorControlHighlight, typedValue, true)) {
return null;
}
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(CHECKED_STATE_SET, new ColorDrawable(typedValue.data));
stateListDrawable.addState(EMPTY_STATE_SET, new ColorDrawable(0));
return stateListDrawable;
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public void setTitle(CharSequence charSequence) {
this.textView.setText(charSequence);
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public void setCheckable(boolean z) {
refreshDrawableState();
if (this.checkable != z) {
this.checkable = z;
this.accessibilityDelegate.sendAccessibilityEvent(this.textView, 2048);
}
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public void setChecked(boolean z) {
refreshDrawableState();
this.textView.setChecked(z);
CheckedTextView checkedTextView = this.textView;
checkedTextView.setTypeface(checkedTextView.getTypeface(), (z && this.isBold) ? 1 : 0);
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public void setIcon(Drawable drawable) {
if (drawable != null) {
if (this.hasIconTintList) {
Drawable.ConstantState constantState = drawable.getConstantState();
if (constantState != null) {
drawable = constantState.newDrawable();
}
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTintList(drawable, this.iconTintList);
}
int i = this.iconSize;
drawable.setBounds(0, 0, i, i);
} else if (this.needsEmptyIcon) {
if (this.emptyDrawable == null) {
Drawable drawable2 = ResourcesCompat.getDrawable(getResources(), com.google.android.material.R.drawable.navigation_empty_icon, getContext().getTheme());
this.emptyDrawable = drawable2;
if (drawable2 != null) {
int i2 = this.iconSize;
drawable2.setBounds(0, 0, i2, i2);
}
}
drawable = this.emptyDrawable;
}
TextViewCompat.setCompoundDrawablesRelative(this.textView, drawable, null, null, null);
}
@Override // android.view.ViewGroup, android.view.View
protected int[] onCreateDrawableState(int i) {
int[] onCreateDrawableState = super.onCreateDrawableState(i + 1);
MenuItemImpl menuItemImpl = this.itemData;
if (menuItemImpl != null && menuItemImpl.isCheckable() && this.itemData.isChecked()) {
mergeDrawableStates(onCreateDrawableState, CHECKED_STATE_SET);
}
return onCreateDrawableState;
}
void setIconTintList(ColorStateList colorStateList) {
this.iconTintList = colorStateList;
this.hasIconTintList = colorStateList != null;
MenuItemImpl menuItemImpl = this.itemData;
if (menuItemImpl != null) {
setIcon(menuItemImpl.getIcon());
}
}
public void setTextAppearance(int i) {
TextViewCompat.setTextAppearance(this.textView, i);
}
public void setTextColor(ColorStateList colorStateList) {
this.textView.setTextColor(colorStateList);
}
public void setHorizontalPadding(int i) {
setPadding(i, getPaddingTop(), i, getPaddingBottom());
}
public void setIconPadding(int i) {
this.textView.setCompoundDrawablePadding(i);
}
public void setMaxLines(int i) {
this.textView.setMaxLines(i);
}
}

View File

@ -0,0 +1,802 @@
package com.google.android.material.internal;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.view.menu.MenuItemImpl;
import androidx.appcompat.view.menu.MenuPresenter;
import androidx.appcompat.view.menu.MenuView;
import androidx.appcompat.view.menu.SubMenuBuilder;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.widget.TextViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate;
import com.google.android.material.R;
import java.util.ArrayList;
/* loaded from: classes.dex */
public class NavigationMenuPresenter implements MenuPresenter {
public static final int NO_TEXT_APPEARANCE_SET = 0;
private static final String STATE_ADAPTER = "android:menu:adapter";
private static final String STATE_HEADER = "android:menu:header";
private static final String STATE_HIERARCHY = "android:menu:list";
NavigationMenuAdapter adapter;
private MenuPresenter.Callback callback;
int dividerInsetEnd;
int dividerInsetStart;
boolean hasCustomItemIconSize;
LinearLayout headerLayout;
ColorStateList iconTintList;
private int id;
Drawable itemBackground;
RippleDrawable itemForeground;
int itemHorizontalPadding;
int itemIconPadding;
int itemIconSize;
private int itemMaxLines;
int itemVerticalPadding;
LayoutInflater layoutInflater;
MenuBuilder menu;
private NavigationMenuView menuView;
int paddingSeparator;
private int paddingTopDefault;
ColorStateList subheaderColor;
int subheaderInsetEnd;
int subheaderInsetStart;
ColorStateList textColor;
int subheaderTextAppearance = 0;
int textAppearance = 0;
boolean textAppearanceActiveBoldEnabled = true;
boolean isBehindStatusBar = true;
private int overScrollMode = -1;
final View.OnClickListener onClickListener = new View.OnClickListener() { // from class: com.google.android.material.internal.NavigationMenuPresenter.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
boolean z = true;
NavigationMenuPresenter.this.setUpdateSuspended(true);
MenuItemImpl itemData = ((NavigationMenuItemView) view).getItemData();
boolean performItemAction = NavigationMenuPresenter.this.menu.performItemAction(itemData, NavigationMenuPresenter.this, 0);
if (itemData != null && itemData.isCheckable() && performItemAction) {
NavigationMenuPresenter.this.adapter.setCheckedItem(itemData);
} else {
z = false;
}
NavigationMenuPresenter.this.setUpdateSuspended(false);
if (z) {
NavigationMenuPresenter.this.updateMenuView(false);
}
}
};
private interface NavigationMenuItem {
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public boolean collapseItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
return false;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public boolean expandItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
return false;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public boolean flagActionItems() {
return false;
}
public int getDividerInsetEnd() {
return this.dividerInsetEnd;
}
public int getDividerInsetStart() {
return this.dividerInsetStart;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public int getId() {
return this.id;
}
public Drawable getItemBackground() {
return this.itemBackground;
}
public int getItemHorizontalPadding() {
return this.itemHorizontalPadding;
}
public int getItemIconPadding() {
return this.itemIconPadding;
}
public int getItemMaxLines() {
return this.itemMaxLines;
}
public ColorStateList getItemTextColor() {
return this.textColor;
}
public ColorStateList getItemTintList() {
return this.iconTintList;
}
public int getItemVerticalPadding() {
return this.itemVerticalPadding;
}
public int getSubheaderInsetEnd() {
return this.subheaderInsetEnd;
}
public int getSubheaderInsetStart() {
return this.subheaderInsetStart;
}
public boolean isBehindStatusBar() {
return this.isBehindStatusBar;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public boolean onSubMenuSelected(SubMenuBuilder subMenuBuilder) {
return false;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void setCallback(MenuPresenter.Callback callback) {
this.callback = callback;
}
public void setId(int i) {
this.id = i;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void initForMenu(Context context, MenuBuilder menuBuilder) {
this.layoutInflater = LayoutInflater.from(context);
this.menu = menuBuilder;
this.paddingSeparator = context.getResources().getDimensionPixelOffset(R.dimen.design_navigation_separator_vertical_padding);
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public MenuView getMenuView(ViewGroup viewGroup) {
if (this.menuView == null) {
NavigationMenuView navigationMenuView = (NavigationMenuView) this.layoutInflater.inflate(R.layout.design_navigation_menu, viewGroup, false);
this.menuView = navigationMenuView;
navigationMenuView.setAccessibilityDelegateCompat(new NavigationMenuViewAccessibilityDelegate(this.menuView));
if (this.adapter == null) {
this.adapter = new NavigationMenuAdapter();
}
int i = this.overScrollMode;
if (i != -1) {
this.menuView.setOverScrollMode(i);
}
LinearLayout linearLayout = (LinearLayout) this.layoutInflater.inflate(R.layout.design_navigation_item_header, (ViewGroup) this.menuView, false);
this.headerLayout = linearLayout;
ViewCompat.setImportantForAccessibility(linearLayout, 2);
this.menuView.setAdapter(this.adapter);
}
return this.menuView;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void updateMenuView(boolean z) {
NavigationMenuAdapter navigationMenuAdapter = this.adapter;
if (navigationMenuAdapter != null) {
navigationMenuAdapter.update();
}
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void onCloseMenu(MenuBuilder menuBuilder, boolean z) {
MenuPresenter.Callback callback = this.callback;
if (callback != null) {
callback.onCloseMenu(menuBuilder, z);
}
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public Parcelable onSaveInstanceState() {
Bundle bundle = new Bundle();
if (this.menuView != null) {
SparseArray<? extends Parcelable> sparseArray = new SparseArray<>();
this.menuView.saveHierarchyState(sparseArray);
bundle.putSparseParcelableArray("android:menu:list", sparseArray);
}
NavigationMenuAdapter navigationMenuAdapter = this.adapter;
if (navigationMenuAdapter != null) {
bundle.putBundle(STATE_ADAPTER, navigationMenuAdapter.createInstanceState());
}
if (this.headerLayout != null) {
SparseArray<? extends Parcelable> sparseArray2 = new SparseArray<>();
this.headerLayout.saveHierarchyState(sparseArray2);
bundle.putSparseParcelableArray(STATE_HEADER, sparseArray2);
}
return bundle;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void onRestoreInstanceState(Parcelable parcelable) {
if (parcelable instanceof Bundle) {
Bundle bundle = (Bundle) parcelable;
SparseArray sparseParcelableArray = bundle.getSparseParcelableArray("android:menu:list");
if (sparseParcelableArray != null) {
this.menuView.restoreHierarchyState(sparseParcelableArray);
}
Bundle bundle2 = bundle.getBundle(STATE_ADAPTER);
if (bundle2 != null) {
this.adapter.restoreInstanceState(bundle2);
}
SparseArray sparseParcelableArray2 = bundle.getSparseParcelableArray(STATE_HEADER);
if (sparseParcelableArray2 != null) {
this.headerLayout.restoreHierarchyState(sparseParcelableArray2);
}
}
}
public void setCheckedItem(MenuItemImpl menuItemImpl) {
this.adapter.setCheckedItem(menuItemImpl);
}
public MenuItemImpl getCheckedItem() {
return this.adapter.getCheckedItem();
}
public View inflateHeaderView(int i) {
View inflate = this.layoutInflater.inflate(i, (ViewGroup) this.headerLayout, false);
addHeaderView(inflate);
return inflate;
}
public void addHeaderView(View view) {
this.headerLayout.addView(view);
NavigationMenuView navigationMenuView = this.menuView;
navigationMenuView.setPadding(0, 0, 0, navigationMenuView.getPaddingBottom());
}
public void removeHeaderView(View view) {
this.headerLayout.removeView(view);
if (hasHeader()) {
return;
}
NavigationMenuView navigationMenuView = this.menuView;
navigationMenuView.setPadding(0, this.paddingTopDefault, 0, navigationMenuView.getPaddingBottom());
}
public int getHeaderCount() {
return this.headerLayout.getChildCount();
}
private boolean hasHeader() {
return getHeaderCount() > 0;
}
public View getHeaderView(int i) {
return this.headerLayout.getChildAt(i);
}
public void setSubheaderColor(ColorStateList colorStateList) {
this.subheaderColor = colorStateList;
updateMenuView(false);
}
public void setSubheaderTextAppearance(int i) {
this.subheaderTextAppearance = i;
updateMenuView(false);
}
public void setItemIconTintList(ColorStateList colorStateList) {
this.iconTintList = colorStateList;
updateMenuView(false);
}
public void setItemTextColor(ColorStateList colorStateList) {
this.textColor = colorStateList;
updateMenuView(false);
}
public void setItemTextAppearance(int i) {
this.textAppearance = i;
updateMenuView(false);
}
public void setItemTextAppearanceActiveBoldEnabled(boolean z) {
this.textAppearanceActiveBoldEnabled = z;
updateMenuView(false);
}
public void setItemBackground(Drawable drawable) {
this.itemBackground = drawable;
updateMenuView(false);
}
public void setItemForeground(RippleDrawable rippleDrawable) {
this.itemForeground = rippleDrawable;
updateMenuView(false);
}
public void setItemHorizontalPadding(int i) {
this.itemHorizontalPadding = i;
updateMenuView(false);
}
public void setItemVerticalPadding(int i) {
this.itemVerticalPadding = i;
updateMenuView(false);
}
public void setDividerInsetStart(int i) {
this.dividerInsetStart = i;
updateMenuView(false);
}
public void setDividerInsetEnd(int i) {
this.dividerInsetEnd = i;
updateMenuView(false);
}
public void setSubheaderInsetStart(int i) {
this.subheaderInsetStart = i;
updateMenuView(false);
}
public void setSubheaderInsetEnd(int i) {
this.subheaderInsetEnd = i;
updateMenuView(false);
}
public void setItemIconPadding(int i) {
this.itemIconPadding = i;
updateMenuView(false);
}
public void setItemMaxLines(int i) {
this.itemMaxLines = i;
updateMenuView(false);
}
public void setItemIconSize(int i) {
if (this.itemIconSize != i) {
this.itemIconSize = i;
this.hasCustomItemIconSize = true;
updateMenuView(false);
}
}
public void setUpdateSuspended(boolean z) {
NavigationMenuAdapter navigationMenuAdapter = this.adapter;
if (navigationMenuAdapter != null) {
navigationMenuAdapter.setUpdateSuspended(z);
}
}
public void setBehindStatusBar(boolean z) {
if (this.isBehindStatusBar != z) {
this.isBehindStatusBar = z;
updateTopPadding();
}
}
private void updateTopPadding() {
int i = (hasHeader() || !this.isBehindStatusBar) ? 0 : this.paddingTopDefault;
NavigationMenuView navigationMenuView = this.menuView;
navigationMenuView.setPadding(0, i, 0, navigationMenuView.getPaddingBottom());
}
public void dispatchApplyWindowInsets(WindowInsetsCompat windowInsetsCompat) {
int systemWindowInsetTop = windowInsetsCompat.getSystemWindowInsetTop();
if (this.paddingTopDefault != systemWindowInsetTop) {
this.paddingTopDefault = systemWindowInsetTop;
updateTopPadding();
}
NavigationMenuView navigationMenuView = this.menuView;
navigationMenuView.setPadding(0, navigationMenuView.getPaddingTop(), 0, windowInsetsCompat.getSystemWindowInsetBottom());
ViewCompat.dispatchApplyWindowInsets(this.headerLayout, windowInsetsCompat);
}
public void setOverScrollMode(int i) {
this.overScrollMode = i;
NavigationMenuView navigationMenuView = this.menuView;
if (navigationMenuView != null) {
navigationMenuView.setOverScrollMode(i);
}
}
private static abstract class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View view) {
super(view);
}
}
private static class NormalViewHolder extends ViewHolder {
public NormalViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup, View.OnClickListener onClickListener) {
super(layoutInflater.inflate(R.layout.design_navigation_item, viewGroup, false));
this.itemView.setOnClickListener(onClickListener);
}
}
private static class SubheaderViewHolder extends ViewHolder {
public SubheaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
super(layoutInflater.inflate(R.layout.design_navigation_item_subheader, viewGroup, false));
}
}
private static class SeparatorViewHolder extends ViewHolder {
public SeparatorViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
super(layoutInflater.inflate(R.layout.design_navigation_item_separator, viewGroup, false));
}
}
private static class HeaderViewHolder extends ViewHolder {
public HeaderViewHolder(View view) {
super(view);
}
}
private class NavigationMenuAdapter extends RecyclerView.Adapter<ViewHolder> {
private static final String STATE_ACTION_VIEWS = "android:menu:action_views";
private static final String STATE_CHECKED_ITEM = "android:menu:checked";
private static final int VIEW_TYPE_HEADER = 3;
private static final int VIEW_TYPE_NORMAL = 0;
private static final int VIEW_TYPE_SEPARATOR = 2;
private static final int VIEW_TYPE_SUBHEADER = 1;
private MenuItemImpl checkedItem;
private final ArrayList<NavigationMenuItem> items = new ArrayList<>();
private boolean updateSuspended;
public MenuItemImpl getCheckedItem() {
return this.checkedItem;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public long getItemId(int i) {
return i;
}
public void setUpdateSuspended(boolean z) {
this.updateSuspended = z;
}
NavigationMenuAdapter() {
prepareMenuItems();
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemCount() {
return this.items.size();
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemViewType(int i) {
NavigationMenuItem navigationMenuItem = this.items.get(i);
if (navigationMenuItem instanceof NavigationMenuSeparatorItem) {
return 2;
}
if (navigationMenuItem instanceof NavigationMenuHeaderItem) {
return 3;
}
if (navigationMenuItem instanceof NavigationMenuTextItem) {
return ((NavigationMenuTextItem) navigationMenuItem).getMenuItem().hasSubMenu() ? 1 : 0;
}
throw new RuntimeException("Unknown item type.");
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
if (i == 0) {
return new NormalViewHolder(NavigationMenuPresenter.this.layoutInflater, viewGroup, NavigationMenuPresenter.this.onClickListener);
}
if (i == 1) {
return new SubheaderViewHolder(NavigationMenuPresenter.this.layoutInflater, viewGroup);
}
if (i == 2) {
return new SeparatorViewHolder(NavigationMenuPresenter.this.layoutInflater, viewGroup);
}
if (i != 3) {
return null;
}
return new HeaderViewHolder(NavigationMenuPresenter.this.headerLayout);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onBindViewHolder(ViewHolder viewHolder, int i) {
int itemViewType = getItemViewType(i);
if (itemViewType != 0) {
if (itemViewType != 1) {
if (itemViewType != 2) {
return;
}
NavigationMenuSeparatorItem navigationMenuSeparatorItem = (NavigationMenuSeparatorItem) this.items.get(i);
viewHolder.itemView.setPadding(NavigationMenuPresenter.this.dividerInsetStart, navigationMenuSeparatorItem.getPaddingTop(), NavigationMenuPresenter.this.dividerInsetEnd, navigationMenuSeparatorItem.getPaddingBottom());
return;
}
TextView textView = (TextView) viewHolder.itemView;
textView.setText(((NavigationMenuTextItem) this.items.get(i)).getMenuItem().getTitle());
TextViewCompat.setTextAppearance(textView, NavigationMenuPresenter.this.subheaderTextAppearance);
textView.setPadding(NavigationMenuPresenter.this.subheaderInsetStart, textView.getPaddingTop(), NavigationMenuPresenter.this.subheaderInsetEnd, textView.getPaddingBottom());
if (NavigationMenuPresenter.this.subheaderColor != null) {
textView.setTextColor(NavigationMenuPresenter.this.subheaderColor);
}
setAccessibilityDelegate(textView, i, true);
return;
}
NavigationMenuItemView navigationMenuItemView = (NavigationMenuItemView) viewHolder.itemView;
navigationMenuItemView.setIconTintList(NavigationMenuPresenter.this.iconTintList);
navigationMenuItemView.setTextAppearance(NavigationMenuPresenter.this.textAppearance);
if (NavigationMenuPresenter.this.textColor != null) {
navigationMenuItemView.setTextColor(NavigationMenuPresenter.this.textColor);
}
ViewCompat.setBackground(navigationMenuItemView, NavigationMenuPresenter.this.itemBackground != null ? NavigationMenuPresenter.this.itemBackground.getConstantState().newDrawable() : null);
if (NavigationMenuPresenter.this.itemForeground != null) {
navigationMenuItemView.setForeground(NavigationMenuPresenter.this.itemForeground.getConstantState().newDrawable());
}
NavigationMenuTextItem navigationMenuTextItem = (NavigationMenuTextItem) this.items.get(i);
navigationMenuItemView.setNeedsEmptyIcon(navigationMenuTextItem.needsEmptyIcon);
navigationMenuItemView.setPadding(NavigationMenuPresenter.this.itemHorizontalPadding, NavigationMenuPresenter.this.itemVerticalPadding, NavigationMenuPresenter.this.itemHorizontalPadding, NavigationMenuPresenter.this.itemVerticalPadding);
navigationMenuItemView.setIconPadding(NavigationMenuPresenter.this.itemIconPadding);
if (NavigationMenuPresenter.this.hasCustomItemIconSize) {
navigationMenuItemView.setIconSize(NavigationMenuPresenter.this.itemIconSize);
}
navigationMenuItemView.setMaxLines(NavigationMenuPresenter.this.itemMaxLines);
navigationMenuItemView.initialize(navigationMenuTextItem.getMenuItem(), NavigationMenuPresenter.this.textAppearanceActiveBoldEnabled);
setAccessibilityDelegate(navigationMenuItemView, i, false);
}
private void setAccessibilityDelegate(View view, final int i, final boolean z) {
ViewCompat.setAccessibilityDelegate(view, new AccessibilityDelegateCompat() { // from class: com.google.android.material.internal.NavigationMenuPresenter.NavigationMenuAdapter.1
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(NavigationMenuAdapter.this.adjustItemPositionForA11yDelegate(i), 1, 1, 1, z, view2.isSelected()));
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public int adjustItemPositionForA11yDelegate(int i) {
int i2 = i;
for (int i3 = 0; i3 < i; i3++) {
if (NavigationMenuPresenter.this.adapter.getItemViewType(i3) == 2 || NavigationMenuPresenter.this.adapter.getItemViewType(i3) == 3) {
i2--;
}
}
return i2;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onViewRecycled(ViewHolder viewHolder) {
if (viewHolder instanceof NormalViewHolder) {
((NavigationMenuItemView) viewHolder.itemView).recycle();
}
}
public void update() {
prepareMenuItems();
notifyDataSetChanged();
}
private void prepareMenuItems() {
if (this.updateSuspended) {
return;
}
this.updateSuspended = true;
this.items.clear();
this.items.add(new NavigationMenuHeaderItem());
int size = NavigationMenuPresenter.this.menu.getVisibleItems().size();
int i = -1;
boolean z = false;
int i2 = 0;
for (int i3 = 0; i3 < size; i3++) {
MenuItemImpl menuItemImpl = NavigationMenuPresenter.this.menu.getVisibleItems().get(i3);
if (menuItemImpl.isChecked()) {
setCheckedItem(menuItemImpl);
}
if (menuItemImpl.isCheckable()) {
menuItemImpl.setExclusiveCheckable(false);
}
if (menuItemImpl.hasSubMenu()) {
SubMenu subMenu = menuItemImpl.getSubMenu();
if (subMenu.hasVisibleItems()) {
if (i3 != 0) {
this.items.add(new NavigationMenuSeparatorItem(NavigationMenuPresenter.this.paddingSeparator, 0));
}
this.items.add(new NavigationMenuTextItem(menuItemImpl));
int size2 = this.items.size();
int size3 = subMenu.size();
boolean z2 = false;
for (int i4 = 0; i4 < size3; i4++) {
MenuItemImpl menuItemImpl2 = (MenuItemImpl) subMenu.getItem(i4);
if (menuItemImpl2.isVisible()) {
if (!z2 && menuItemImpl2.getIcon() != null) {
z2 = true;
}
if (menuItemImpl2.isCheckable()) {
menuItemImpl2.setExclusiveCheckable(false);
}
if (menuItemImpl.isChecked()) {
setCheckedItem(menuItemImpl);
}
this.items.add(new NavigationMenuTextItem(menuItemImpl2));
}
}
if (z2) {
appendTransparentIconIfMissing(size2, this.items.size());
}
}
} else {
int groupId = menuItemImpl.getGroupId();
if (groupId != i) {
i2 = this.items.size();
z = menuItemImpl.getIcon() != null;
if (i3 != 0) {
i2++;
this.items.add(new NavigationMenuSeparatorItem(NavigationMenuPresenter.this.paddingSeparator, NavigationMenuPresenter.this.paddingSeparator));
}
} else if (!z && menuItemImpl.getIcon() != null) {
appendTransparentIconIfMissing(i2, this.items.size());
z = true;
}
NavigationMenuTextItem navigationMenuTextItem = new NavigationMenuTextItem(menuItemImpl);
navigationMenuTextItem.needsEmptyIcon = z;
this.items.add(navigationMenuTextItem);
i = groupId;
}
}
this.updateSuspended = false;
}
private void appendTransparentIconIfMissing(int i, int i2) {
while (i < i2) {
((NavigationMenuTextItem) this.items.get(i)).needsEmptyIcon = true;
i++;
}
}
public void setCheckedItem(MenuItemImpl menuItemImpl) {
if (this.checkedItem == menuItemImpl || !menuItemImpl.isCheckable()) {
return;
}
MenuItemImpl menuItemImpl2 = this.checkedItem;
if (menuItemImpl2 != null) {
menuItemImpl2.setChecked(false);
}
this.checkedItem = menuItemImpl;
menuItemImpl.setChecked(true);
}
public Bundle createInstanceState() {
Bundle bundle = new Bundle();
MenuItemImpl menuItemImpl = this.checkedItem;
if (menuItemImpl != null) {
bundle.putInt(STATE_CHECKED_ITEM, menuItemImpl.getItemId());
}
SparseArray<? extends Parcelable> sparseArray = new SparseArray<>();
int size = this.items.size();
for (int i = 0; i < size; i++) {
NavigationMenuItem navigationMenuItem = this.items.get(i);
if (navigationMenuItem instanceof NavigationMenuTextItem) {
MenuItemImpl menuItem = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
View actionView = menuItem != null ? menuItem.getActionView() : null;
if (actionView != null) {
ParcelableSparseArray parcelableSparseArray = new ParcelableSparseArray();
actionView.saveHierarchyState(parcelableSparseArray);
sparseArray.put(menuItem.getItemId(), parcelableSparseArray);
}
}
}
bundle.putSparseParcelableArray(STATE_ACTION_VIEWS, sparseArray);
return bundle;
}
public void restoreInstanceState(Bundle bundle) {
MenuItemImpl menuItem;
View actionView;
ParcelableSparseArray parcelableSparseArray;
MenuItemImpl menuItem2;
int i = bundle.getInt(STATE_CHECKED_ITEM, 0);
if (i != 0) {
this.updateSuspended = true;
int size = this.items.size();
int i2 = 0;
while (true) {
if (i2 >= size) {
break;
}
NavigationMenuItem navigationMenuItem = this.items.get(i2);
if ((navigationMenuItem instanceof NavigationMenuTextItem) && (menuItem2 = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem()) != null && menuItem2.getItemId() == i) {
setCheckedItem(menuItem2);
break;
}
i2++;
}
this.updateSuspended = false;
prepareMenuItems();
}
SparseArray sparseParcelableArray = bundle.getSparseParcelableArray(STATE_ACTION_VIEWS);
if (sparseParcelableArray != null) {
int size2 = this.items.size();
for (int i3 = 0; i3 < size2; i3++) {
NavigationMenuItem navigationMenuItem2 = this.items.get(i3);
if ((navigationMenuItem2 instanceof NavigationMenuTextItem) && (menuItem = ((NavigationMenuTextItem) navigationMenuItem2).getMenuItem()) != null && (actionView = menuItem.getActionView()) != null && (parcelableSparseArray = (ParcelableSparseArray) sparseParcelableArray.get(menuItem.getItemId())) != null) {
actionView.restoreHierarchyState(parcelableSparseArray);
}
}
}
}
int getRowCount() {
int i = 0;
for (int i2 = 0; i2 < NavigationMenuPresenter.this.adapter.getItemCount(); i2++) {
int itemViewType = NavigationMenuPresenter.this.adapter.getItemViewType(i2);
if (itemViewType == 0 || itemViewType == 1) {
i++;
}
}
return i;
}
}
private static class NavigationMenuTextItem implements NavigationMenuItem {
private final MenuItemImpl menuItem;
boolean needsEmptyIcon;
public MenuItemImpl getMenuItem() {
return this.menuItem;
}
NavigationMenuTextItem(MenuItemImpl menuItemImpl) {
this.menuItem = menuItemImpl;
}
}
private static class NavigationMenuSeparatorItem implements NavigationMenuItem {
private final int paddingBottom;
private final int paddingTop;
public int getPaddingBottom() {
return this.paddingBottom;
}
public int getPaddingTop() {
return this.paddingTop;
}
public NavigationMenuSeparatorItem(int i, int i2) {
this.paddingTop = i;
this.paddingBottom = i2;
}
}
private static class NavigationMenuHeaderItem implements NavigationMenuItem {
NavigationMenuHeaderItem() {
}
}
private class NavigationMenuViewAccessibilityDelegate extends RecyclerViewAccessibilityDelegate {
NavigationMenuViewAccessibilityDelegate(RecyclerView recyclerView) {
super(recyclerView);
}
@Override // androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate, androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setCollectionInfo(AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(NavigationMenuPresenter.this.adapter.getRowCount(), 1, false));
}
}
}

View File

@ -0,0 +1,33 @@
package com.google.android.material.internal;
import android.content.Context;
import android.util.AttributeSet;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.view.menu.MenuView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public class NavigationMenuView extends RecyclerView implements MenuView {
@Override // androidx.appcompat.view.menu.MenuView
public int getWindowAnimations() {
return 0;
}
@Override // androidx.appcompat.view.menu.MenuView
public void initialize(MenuBuilder menuBuilder) {
}
public NavigationMenuView(Context context) {
this(context, null);
}
public NavigationMenuView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public NavigationMenuView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
setLayoutManager(new LinearLayoutManager(context, 1, false));
}
}

View File

@ -0,0 +1,19 @@
package com.google.android.material.internal;
import android.content.Context;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.view.menu.MenuItemImpl;
import androidx.appcompat.view.menu.SubMenuBuilder;
/* loaded from: classes.dex */
public class NavigationSubMenu extends SubMenuBuilder {
public NavigationSubMenu(Context context, NavigationMenu navigationMenu, MenuItemImpl menuItemImpl) {
super(context, navigationMenu, menuItemImpl);
}
@Override // androidx.appcompat.view.menu.MenuBuilder
public void onItemsChanged(boolean z) {
super.onItemsChanged(z);
((MenuBuilder) getParentMenu()).onItemsChanged(z);
}
}

View File

@ -0,0 +1,58 @@
package com.google.android.material.internal;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseArray;
/* loaded from: classes.dex */
public class ParcelableSparseArray extends SparseArray<Parcelable> implements Parcelable {
public static final Parcelable.Creator<ParcelableSparseArray> CREATOR = new Parcelable.ClassLoaderCreator<ParcelableSparseArray>() { // from class: com.google.android.material.internal.ParcelableSparseArray.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.ClassLoaderCreator
public ParcelableSparseArray createFromParcel(Parcel parcel, ClassLoader classLoader) {
return new ParcelableSparseArray(parcel, classLoader);
}
@Override // android.os.Parcelable.Creator
public ParcelableSparseArray createFromParcel(Parcel parcel) {
return new ParcelableSparseArray(parcel, null);
}
@Override // android.os.Parcelable.Creator
public ParcelableSparseArray[] newArray(int i) {
return new ParcelableSparseArray[i];
}
};
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public ParcelableSparseArray() {
}
public ParcelableSparseArray(Parcel parcel, ClassLoader classLoader) {
int readInt = parcel.readInt();
int[] iArr = new int[readInt];
parcel.readIntArray(iArr);
Parcelable[] readParcelableArray = parcel.readParcelableArray(classLoader);
for (int i = 0; i < readInt; i++) {
put(iArr[i], readParcelableArray[i]);
}
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
int size = size();
int[] iArr = new int[size];
Parcelable[] parcelableArr = new Parcelable[size];
for (int i2 = 0; i2 < size; i2++) {
iArr[i2] = keyAt(i2);
parcelableArr[i2] = valueAt(i2);
}
parcel.writeInt(size);
parcel.writeIntArray(iArr);
parcel.writeParcelableArray(parcelableArr, i);
}
}

View File

@ -0,0 +1,63 @@
package com.google.android.material.internal;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseBooleanArray;
/* loaded from: classes.dex */
public class ParcelableSparseBooleanArray extends SparseBooleanArray implements Parcelable {
public static final Parcelable.Creator<ParcelableSparseBooleanArray> CREATOR = new Parcelable.Creator<ParcelableSparseBooleanArray>() { // from class: com.google.android.material.internal.ParcelableSparseBooleanArray.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public ParcelableSparseBooleanArray createFromParcel(Parcel parcel) {
int readInt = parcel.readInt();
ParcelableSparseBooleanArray parcelableSparseBooleanArray = new ParcelableSparseBooleanArray(readInt);
int[] iArr = new int[readInt];
boolean[] zArr = new boolean[readInt];
parcel.readIntArray(iArr);
parcel.readBooleanArray(zArr);
for (int i = 0; i < readInt; i++) {
parcelableSparseBooleanArray.put(iArr[i], zArr[i]);
}
return parcelableSparseBooleanArray;
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public ParcelableSparseBooleanArray[] newArray(int i) {
return new ParcelableSparseBooleanArray[i];
}
};
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public ParcelableSparseBooleanArray() {
}
public ParcelableSparseBooleanArray(int i) {
super(i);
}
public ParcelableSparseBooleanArray(SparseBooleanArray sparseBooleanArray) {
super(sparseBooleanArray.size());
for (int i = 0; i < sparseBooleanArray.size(); i++) {
put(sparseBooleanArray.keyAt(i), sparseBooleanArray.valueAt(i));
}
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
int[] iArr = new int[size()];
boolean[] zArr = new boolean[size()];
for (int i2 = 0; i2 < size(); i2++) {
iArr[i2] = keyAt(i2);
zArr[i2] = valueAt(i2);
}
parcel.writeInt(size());
parcel.writeIntArray(iArr);
parcel.writeBooleanArray(zArr);
}
}

View File

@ -0,0 +1,62 @@
package com.google.android.material.internal;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseIntArray;
/* loaded from: classes.dex */
public class ParcelableSparseIntArray extends SparseIntArray implements Parcelable {
public static final Parcelable.Creator<ParcelableSparseIntArray> CREATOR = new Parcelable.Creator<ParcelableSparseIntArray>() { // from class: com.google.android.material.internal.ParcelableSparseIntArray.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public ParcelableSparseIntArray createFromParcel(Parcel parcel) {
int readInt = parcel.readInt();
ParcelableSparseIntArray parcelableSparseIntArray = new ParcelableSparseIntArray(readInt);
int[] iArr = new int[readInt];
int[] iArr2 = new int[readInt];
parcel.readIntArray(iArr);
parcel.readIntArray(iArr2);
for (int i = 0; i < readInt; i++) {
parcelableSparseIntArray.put(iArr[i], iArr2[i]);
}
return parcelableSparseIntArray;
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public ParcelableSparseIntArray[] newArray(int i) {
return new ParcelableSparseIntArray[i];
}
};
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public ParcelableSparseIntArray() {
}
public ParcelableSparseIntArray(int i) {
super(i);
}
public ParcelableSparseIntArray(SparseIntArray sparseIntArray) {
for (int i = 0; i < sparseIntArray.size(); i++) {
put(sparseIntArray.keyAt(i), sparseIntArray.valueAt(i));
}
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
int[] iArr = new int[size()];
int[] iArr2 = new int[size()];
for (int i2 = 0; i2 < size(); i2++) {
iArr[i2] = keyAt(i2);
iArr2[i2] = valueAt(i2);
}
parcel.writeInt(size());
parcel.writeIntArray(iArr);
parcel.writeIntArray(iArr2);
}
}

View File

@ -0,0 +1,19 @@
package com.google.android.material.internal;
import android.animation.TypeEvaluator;
import android.graphics.Rect;
/* loaded from: classes.dex */
public class RectEvaluator implements TypeEvaluator<Rect> {
private final Rect rect;
public RectEvaluator(Rect rect) {
this.rect = rect;
}
@Override // android.animation.TypeEvaluator
public Rect evaluate(float f, Rect rect, Rect rect2) {
this.rect.set(rect.left + ((int) ((rect2.left - rect.left) * f)), rect.top + ((int) ((rect2.top - rect.top) * f)), rect.right + ((int) ((rect2.right - rect.right) * f)), rect.bottom + ((int) ((rect2.bottom - rect.bottom) * f)));
return this.rect;
}
}

View File

@ -0,0 +1,21 @@
package com.google.android.material.internal;
import android.animation.TimeInterpolator;
/* loaded from: classes.dex */
public class ReversableAnimatedValueInterpolator implements TimeInterpolator {
private final TimeInterpolator sourceInterpolator;
public ReversableAnimatedValueInterpolator(TimeInterpolator timeInterpolator) {
this.sourceInterpolator = timeInterpolator;
}
public static TimeInterpolator of(boolean z, TimeInterpolator timeInterpolator) {
return z ? timeInterpolator : new ReversableAnimatedValueInterpolator(timeInterpolator);
}
@Override // android.animation.TimeInterpolator
public float getInterpolation(float f) {
return 1.0f - this.sourceInterpolator.getInterpolation(f);
}
}

View File

@ -0,0 +1,133 @@
package com.google.android.material.internal;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.google.android.material.R;
/* loaded from: classes.dex */
public class ScrimInsetsFrameLayout extends FrameLayout {
private boolean drawBottomInsetForeground;
private boolean drawLeftInsetForeground;
private boolean drawRightInsetForeground;
private boolean drawTopInsetForeground;
Drawable insetForeground;
Rect insets;
private Rect tempRect;
protected void onInsetsChanged(WindowInsetsCompat windowInsetsCompat) {
}
public void setDrawBottomInsetForeground(boolean z) {
this.drawBottomInsetForeground = z;
}
public void setDrawLeftInsetForeground(boolean z) {
this.drawLeftInsetForeground = z;
}
public void setDrawRightInsetForeground(boolean z) {
this.drawRightInsetForeground = z;
}
public void setDrawTopInsetForeground(boolean z) {
this.drawTopInsetForeground = z;
}
public void setScrimInsetForeground(Drawable drawable) {
this.insetForeground = drawable;
}
public ScrimInsetsFrameLayout(Context context) {
this(context, null);
}
public ScrimInsetsFrameLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public ScrimInsetsFrameLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.tempRect = new Rect();
this.drawTopInsetForeground = true;
this.drawBottomInsetForeground = true;
this.drawLeftInsetForeground = true;
this.drawRightInsetForeground = true;
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, attributeSet, R.styleable.ScrimInsetsFrameLayout, i, R.style.Widget_Design_ScrimInsetsFrameLayout, new int[0]);
this.insetForeground = obtainStyledAttributes.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
obtainStyledAttributes.recycle();
setWillNotDraw(true);
ViewCompat.setOnApplyWindowInsetsListener(this, new OnApplyWindowInsetsListener() { // from class: com.google.android.material.internal.ScrimInsetsFrameLayout.1
@Override // androidx.core.view.OnApplyWindowInsetsListener
public WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat) {
if (ScrimInsetsFrameLayout.this.insets == null) {
ScrimInsetsFrameLayout.this.insets = new Rect();
}
ScrimInsetsFrameLayout.this.insets.set(windowInsetsCompat.getSystemWindowInsetLeft(), windowInsetsCompat.getSystemWindowInsetTop(), windowInsetsCompat.getSystemWindowInsetRight(), windowInsetsCompat.getSystemWindowInsetBottom());
ScrimInsetsFrameLayout.this.onInsetsChanged(windowInsetsCompat);
ScrimInsetsFrameLayout.this.setWillNotDraw(!windowInsetsCompat.hasSystemWindowInsets() || ScrimInsetsFrameLayout.this.insetForeground == null);
ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
return windowInsetsCompat.consumeSystemWindowInsets();
}
});
}
@Override // android.view.View
public void draw(Canvas canvas) {
super.draw(canvas);
int width = getWidth();
int height = getHeight();
if (this.insets == null || this.insetForeground == null) {
return;
}
int save = canvas.save();
canvas.translate(getScrollX(), getScrollY());
if (this.drawTopInsetForeground) {
this.tempRect.set(0, 0, width, this.insets.top);
this.insetForeground.setBounds(this.tempRect);
this.insetForeground.draw(canvas);
}
if (this.drawBottomInsetForeground) {
this.tempRect.set(0, height - this.insets.bottom, width, height);
this.insetForeground.setBounds(this.tempRect);
this.insetForeground.draw(canvas);
}
if (this.drawLeftInsetForeground) {
this.tempRect.set(0, this.insets.top, this.insets.left, height - this.insets.bottom);
this.insetForeground.setBounds(this.tempRect);
this.insetForeground.draw(canvas);
}
if (this.drawRightInsetForeground) {
this.tempRect.set(width - this.insets.right, this.insets.top, width, height - this.insets.bottom);
this.insetForeground.setBounds(this.tempRect);
this.insetForeground.draw(canvas);
}
canvas.restoreToCount(save);
}
@Override // android.view.ViewGroup, android.view.View
protected void onAttachedToWindow() {
super.onAttachedToWindow();
Drawable drawable = this.insetForeground;
if (drawable != null) {
drawable.setCallback(this);
}
}
@Override // android.view.ViewGroup, android.view.View
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
Drawable drawable = this.insetForeground;
if (drawable != null) {
drawable.setCallback(null);
}
}
}

View File

@ -0,0 +1,89 @@
package com.google.android.material.internal;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.util.StateSet;
import java.util.ArrayList;
/* loaded from: classes.dex */
public final class StateListAnimator {
private final ArrayList<Tuple> tuples = new ArrayList<>();
private Tuple lastMatch = null;
ValueAnimator runningAnimator = null;
private final Animator.AnimatorListener animationListener = new AnimatorListenerAdapter() { // from class: com.google.android.material.internal.StateListAnimator.1
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
if (StateListAnimator.this.runningAnimator == animator) {
StateListAnimator.this.runningAnimator = null;
}
}
};
public void addState(int[] iArr, ValueAnimator valueAnimator) {
Tuple tuple = new Tuple(iArr, valueAnimator);
valueAnimator.addListener(this.animationListener);
this.tuples.add(tuple);
}
public void setState(int[] iArr) {
Tuple tuple;
int size = this.tuples.size();
int i = 0;
while (true) {
if (i >= size) {
tuple = null;
break;
}
tuple = this.tuples.get(i);
if (StateSet.stateSetMatches(tuple.specs, iArr)) {
break;
} else {
i++;
}
}
Tuple tuple2 = this.lastMatch;
if (tuple == tuple2) {
return;
}
if (tuple2 != null) {
cancel();
}
this.lastMatch = tuple;
if (tuple != null) {
start(tuple);
}
}
private void start(Tuple tuple) {
ValueAnimator valueAnimator = tuple.animator;
this.runningAnimator = valueAnimator;
valueAnimator.start();
}
private void cancel() {
ValueAnimator valueAnimator = this.runningAnimator;
if (valueAnimator != null) {
valueAnimator.cancel();
this.runningAnimator = null;
}
}
public void jumpToCurrentState() {
ValueAnimator valueAnimator = this.runningAnimator;
if (valueAnimator != null) {
valueAnimator.end();
this.runningAnimator = null;
}
}
static class Tuple {
final ValueAnimator animator;
final int[] specs;
Tuple(int[] iArr, ValueAnimator valueAnimator) {
this.specs = iArr;
this.animator = valueAnimator;
}
}
}

View File

@ -0,0 +1,179 @@
package com.google.android.material.internal;
import android.os.Build;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextDirectionHeuristic;
import android.text.TextDirectionHeuristics;
import android.text.TextPaint;
import android.text.TextUtils;
import androidx.core.util.Preconditions;
import java.lang.reflect.Constructor;
/* loaded from: classes.dex */
final class StaticLayoutBuilderCompat {
static final int DEFAULT_HYPHENATION_FREQUENCY;
static final float DEFAULT_LINE_SPACING_ADD = 0.0f;
static final float DEFAULT_LINE_SPACING_MULTIPLIER = 1.0f;
private static final String TEXT_DIRS_CLASS = "android.text.TextDirectionHeuristics";
private static final String TEXT_DIR_CLASS = "android.text.TextDirectionHeuristic";
private static final String TEXT_DIR_CLASS_LTR = "LTR";
private static final String TEXT_DIR_CLASS_RTL = "RTL";
private static Constructor<StaticLayout> constructor;
private static boolean initialized;
private static Object textDirection;
private int end;
private boolean isRtl;
private final TextPaint paint;
private CharSequence source;
private StaticLayoutBuilderConfigurer staticLayoutBuilderConfigurer;
private final int width;
private int start = 0;
private Layout.Alignment alignment = Layout.Alignment.ALIGN_NORMAL;
private int maxLines = Integer.MAX_VALUE;
private float lineSpacingAdd = 0.0f;
private float lineSpacingMultiplier = 1.0f;
private int hyphenationFrequency = DEFAULT_HYPHENATION_FREQUENCY;
private boolean includePad = true;
private TextUtils.TruncateAt ellipsize = null;
static {
DEFAULT_HYPHENATION_FREQUENCY = Build.VERSION.SDK_INT >= 23 ? 1 : 0;
}
public StaticLayoutBuilderCompat setAlignment(Layout.Alignment alignment) {
this.alignment = alignment;
return this;
}
public StaticLayoutBuilderCompat setEllipsize(TextUtils.TruncateAt truncateAt) {
this.ellipsize = truncateAt;
return this;
}
public StaticLayoutBuilderCompat setEnd(int i) {
this.end = i;
return this;
}
public StaticLayoutBuilderCompat setHyphenationFrequency(int i) {
this.hyphenationFrequency = i;
return this;
}
public StaticLayoutBuilderCompat setIncludePad(boolean z) {
this.includePad = z;
return this;
}
public StaticLayoutBuilderCompat setIsRtl(boolean z) {
this.isRtl = z;
return this;
}
public StaticLayoutBuilderCompat setLineSpacing(float f, float f2) {
this.lineSpacingAdd = f;
this.lineSpacingMultiplier = f2;
return this;
}
public StaticLayoutBuilderCompat setMaxLines(int i) {
this.maxLines = i;
return this;
}
public StaticLayoutBuilderCompat setStart(int i) {
this.start = i;
return this;
}
public StaticLayoutBuilderCompat setStaticLayoutBuilderConfigurer(StaticLayoutBuilderConfigurer staticLayoutBuilderConfigurer) {
this.staticLayoutBuilderConfigurer = staticLayoutBuilderConfigurer;
return this;
}
private StaticLayoutBuilderCompat(CharSequence charSequence, TextPaint textPaint, int i) {
this.source = charSequence;
this.paint = textPaint;
this.width = i;
this.end = charSequence.length();
}
public static StaticLayoutBuilderCompat obtain(CharSequence charSequence, TextPaint textPaint, int i) {
return new StaticLayoutBuilderCompat(charSequence, textPaint, i);
}
public StaticLayout build() throws StaticLayoutBuilderCompatException {
StaticLayout.Builder obtain;
TextDirectionHeuristic textDirectionHeuristic;
StaticLayout build;
if (this.source == null) {
this.source = "";
}
int max = Math.max(0, this.width);
CharSequence charSequence = this.source;
if (this.maxLines == 1) {
charSequence = TextUtils.ellipsize(charSequence, this.paint, max, this.ellipsize);
}
this.end = Math.min(charSequence.length(), this.end);
if (Build.VERSION.SDK_INT >= 23) {
if (this.isRtl && this.maxLines == 1) {
this.alignment = Layout.Alignment.ALIGN_OPPOSITE;
}
obtain = StaticLayout.Builder.obtain(charSequence, this.start, this.end, this.paint, max);
obtain.setAlignment(this.alignment);
obtain.setIncludePad(this.includePad);
if (this.isRtl) {
textDirectionHeuristic = TextDirectionHeuristics.RTL;
} else {
textDirectionHeuristic = TextDirectionHeuristics.LTR;
}
obtain.setTextDirection(textDirectionHeuristic);
TextUtils.TruncateAt truncateAt = this.ellipsize;
if (truncateAt != null) {
obtain.setEllipsize(truncateAt);
}
obtain.setMaxLines(this.maxLines);
float f = this.lineSpacingAdd;
if (f != 0.0f || this.lineSpacingMultiplier != 1.0f) {
obtain.setLineSpacing(f, this.lineSpacingMultiplier);
}
if (this.maxLines > 1) {
obtain.setHyphenationFrequency(this.hyphenationFrequency);
}
StaticLayoutBuilderConfigurer staticLayoutBuilderConfigurer = this.staticLayoutBuilderConfigurer;
if (staticLayoutBuilderConfigurer != null) {
staticLayoutBuilderConfigurer.configure(obtain);
}
build = obtain.build();
return build;
}
createConstructorWithReflection();
try {
return (StaticLayout) ((Constructor) Preconditions.checkNotNull(constructor)).newInstance(charSequence, Integer.valueOf(this.start), Integer.valueOf(this.end), this.paint, Integer.valueOf(max), this.alignment, Preconditions.checkNotNull(textDirection), Float.valueOf(1.0f), Float.valueOf(0.0f), Boolean.valueOf(this.includePad), null, Integer.valueOf(max), Integer.valueOf(this.maxLines));
} catch (Exception e) {
throw new StaticLayoutBuilderCompatException(e);
}
}
private void createConstructorWithReflection() throws StaticLayoutBuilderCompatException {
if (initialized) {
return;
}
try {
textDirection = this.isRtl && Build.VERSION.SDK_INT >= 23 ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR;
Constructor<StaticLayout> declaredConstructor = StaticLayout.class.getDeclaredConstructor(CharSequence.class, Integer.TYPE, Integer.TYPE, TextPaint.class, Integer.TYPE, Layout.Alignment.class, TextDirectionHeuristic.class, Float.TYPE, Float.TYPE, Boolean.TYPE, TextUtils.TruncateAt.class, Integer.TYPE, Integer.TYPE);
constructor = declaredConstructor;
declaredConstructor.setAccessible(true);
initialized = true;
} catch (Exception e) {
throw new StaticLayoutBuilderCompatException(e);
}
}
static class StaticLayoutBuilderCompatException extends Exception {
StaticLayoutBuilderCompatException(Throwable th) {
super("Error thrown initializing StaticLayout " + th.getMessage(), th);
}
}
}

View File

@ -0,0 +1,8 @@
package com.google.android.material.internal;
import android.text.StaticLayout;
/* loaded from: classes.dex */
public interface StaticLayoutBuilderConfigurer {
void configure(StaticLayout.Builder builder);
}

View File

@ -0,0 +1,136 @@
package com.google.android.material.internal;
import android.content.Context;
import android.graphics.Typeface;
import android.text.TextPaint;
import com.google.android.material.resources.TextAppearance;
import com.google.android.material.resources.TextAppearanceFontCallback;
import java.lang.ref.WeakReference;
/* loaded from: classes.dex */
public class TextDrawableHelper {
private TextAppearance textAppearance;
private float textHeight;
private float textWidth;
private final TextPaint textPaint = new TextPaint(1);
private final TextAppearanceFontCallback fontCallback = new TextAppearanceFontCallback() { // from class: com.google.android.material.internal.TextDrawableHelper.1
@Override // com.google.android.material.resources.TextAppearanceFontCallback
public void onFontRetrieved(Typeface typeface, boolean z) {
if (z) {
return;
}
TextDrawableHelper.this.textSizeDirty = true;
TextDrawableDelegate textDrawableDelegate = (TextDrawableDelegate) TextDrawableHelper.this.delegate.get();
if (textDrawableDelegate != null) {
textDrawableDelegate.onTextSizeChange();
}
}
@Override // com.google.android.material.resources.TextAppearanceFontCallback
public void onFontRetrievalFailed(int i) {
TextDrawableHelper.this.textSizeDirty = true;
TextDrawableDelegate textDrawableDelegate = (TextDrawableDelegate) TextDrawableHelper.this.delegate.get();
if (textDrawableDelegate != null) {
textDrawableDelegate.onTextSizeChange();
}
}
};
private boolean textSizeDirty = true;
private WeakReference<TextDrawableDelegate> delegate = new WeakReference<>(null);
public interface TextDrawableDelegate {
int[] getState();
boolean onStateChange(int[] iArr);
void onTextSizeChange();
}
public TextAppearance getTextAppearance() {
return this.textAppearance;
}
public TextPaint getTextPaint() {
return this.textPaint;
}
public boolean isTextWidthDirty() {
return this.textSizeDirty;
}
public void setTextSizeDirty(boolean z) {
this.textSizeDirty = z;
}
public void setTextWidthDirty(boolean z) {
this.textSizeDirty = z;
}
public TextDrawableHelper(TextDrawableDelegate textDrawableDelegate) {
setDelegate(textDrawableDelegate);
}
public void setDelegate(TextDrawableDelegate textDrawableDelegate) {
this.delegate = new WeakReference<>(textDrawableDelegate);
}
private void refreshTextDimens(String str) {
this.textWidth = calculateTextWidth(str);
this.textHeight = calculateTextHeight(str);
this.textSizeDirty = false;
}
public float getTextWidth(String str) {
if (!this.textSizeDirty) {
return this.textWidth;
}
refreshTextDimens(str);
return this.textWidth;
}
private float calculateTextWidth(CharSequence charSequence) {
if (charSequence == null) {
return 0.0f;
}
return this.textPaint.measureText(charSequence, 0, charSequence.length());
}
public float getTextHeight(String str) {
if (!this.textSizeDirty) {
return this.textHeight;
}
refreshTextDimens(str);
return this.textHeight;
}
private float calculateTextHeight(String str) {
if (str == null) {
return 0.0f;
}
return Math.abs(this.textPaint.getFontMetrics().ascent);
}
public void setTextAppearance(TextAppearance textAppearance, Context context) {
if (this.textAppearance != textAppearance) {
this.textAppearance = textAppearance;
if (textAppearance != null) {
textAppearance.updateMeasureState(context, this.textPaint, this.fontCallback);
TextDrawableDelegate textDrawableDelegate = this.delegate.get();
if (textDrawableDelegate != null) {
this.textPaint.drawableState = textDrawableDelegate.getState();
}
textAppearance.updateDrawState(context, this.textPaint, this.fontCallback);
this.textSizeDirty = true;
}
TextDrawableDelegate textDrawableDelegate2 = this.delegate.get();
if (textDrawableDelegate2 != null) {
textDrawableDelegate2.onTextSizeChange();
textDrawableDelegate2.onStateChange(textDrawableDelegate2.getState());
}
}
}
public void updateTextPaintDrawState(Context context) {
this.textAppearance.updateDrawState(context, this.textPaint, this.fontCallback);
}
}

View File

@ -0,0 +1,55 @@
package com.google.android.material.internal;
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.transition.Transition;
import androidx.transition.TransitionValues;
import java.util.Map;
/* loaded from: classes.dex */
public class TextScale extends Transition {
private static final String PROPNAME_SCALE = "android:textscale:scale";
@Override // androidx.transition.Transition
public void captureStartValues(TransitionValues transitionValues) {
captureValues(transitionValues);
}
@Override // androidx.transition.Transition
public void captureEndValues(TransitionValues transitionValues) {
captureValues(transitionValues);
}
private void captureValues(TransitionValues transitionValues) {
if (transitionValues.view instanceof TextView) {
transitionValues.values.put(PROPNAME_SCALE, Float.valueOf(((TextView) transitionValues.view).getScaleX()));
}
}
@Override // androidx.transition.Transition
public Animator createAnimator(ViewGroup viewGroup, TransitionValues transitionValues, TransitionValues transitionValues2) {
if (transitionValues == null || transitionValues2 == null || !(transitionValues.view instanceof TextView) || !(transitionValues2.view instanceof TextView)) {
return null;
}
final TextView textView = (TextView) transitionValues2.view;
Map<String, Object> map = transitionValues.values;
Map<String, Object> map2 = transitionValues2.values;
float floatValue = map.get(PROPNAME_SCALE) != null ? ((Float) map.get(PROPNAME_SCALE)).floatValue() : 1.0f;
float floatValue2 = map2.get(PROPNAME_SCALE) != null ? ((Float) map2.get(PROPNAME_SCALE)).floatValue() : 1.0f;
if (floatValue == floatValue2) {
return null;
}
ValueAnimator ofFloat = ValueAnimator.ofFloat(floatValue, floatValue2);
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.internal.TextScale.1
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float floatValue3 = ((Float) valueAnimator.getAnimatedValue()).floatValue();
textView.setScaleX(floatValue3);
textView.setScaleY(floatValue3);
}
});
return ofFloat;
}
}

View File

@ -0,0 +1,19 @@
package com.google.android.material.internal;
import android.text.Editable;
import android.text.TextWatcher;
/* loaded from: classes.dex */
public class TextWatcherAdapter implements TextWatcher {
@Override // android.text.TextWatcher
public void afterTextChanged(Editable editable) {
}
@Override // android.text.TextWatcher
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override // android.text.TextWatcher
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
}

View File

@ -0,0 +1,114 @@
package com.google.android.material.internal;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import androidx.appcompat.widget.TintTypedArray;
import com.google.android.material.R;
import com.google.android.material.resources.MaterialAttributes;
/* loaded from: classes.dex */
public final class ThemeEnforcement {
private static final String APPCOMPAT_THEME_NAME = "Theme.AppCompat";
private static final String MATERIAL_THEME_NAME = "Theme.MaterialComponents";
private static final int[] APPCOMPAT_CHECK_ATTRS = {R.attr.colorPrimary};
private static final int[] MATERIAL_CHECK_ATTRS = {R.attr.colorPrimaryVariant};
private ThemeEnforcement() {
}
public static TypedArray obtainStyledAttributes(Context context, AttributeSet attributeSet, int[] iArr, int i, int i2, int... iArr2) {
checkCompatibleTheme(context, attributeSet, i, i2);
checkTextAppearance(context, attributeSet, iArr, i, i2, iArr2);
return context.obtainStyledAttributes(attributeSet, iArr, i, i2);
}
public static TintTypedArray obtainTintedStyledAttributes(Context context, AttributeSet attributeSet, int[] iArr, int i, int i2, int... iArr2) {
checkCompatibleTheme(context, attributeSet, i, i2);
checkTextAppearance(context, attributeSet, iArr, i, i2, iArr2);
return TintTypedArray.obtainStyledAttributes(context, attributeSet, iArr, i, i2);
}
private static void checkCompatibleTheme(Context context, AttributeSet attributeSet, int i, int i2) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.ThemeEnforcement, i, i2);
boolean z = obtainStyledAttributes.getBoolean(R.styleable.ThemeEnforcement_enforceMaterialTheme, false);
obtainStyledAttributes.recycle();
if (z) {
TypedValue typedValue = new TypedValue();
if (!context.getTheme().resolveAttribute(R.attr.isMaterialTheme, typedValue, true) || (typedValue.type == 18 && typedValue.data == 0)) {
checkMaterialTheme(context);
}
}
checkAppCompatTheme(context);
}
private static void checkTextAppearance(Context context, AttributeSet attributeSet, int[] iArr, int i, int i2, int... iArr2) {
boolean z;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.ThemeEnforcement, i, i2);
if (!obtainStyledAttributes.getBoolean(R.styleable.ThemeEnforcement_enforceTextAppearance, false)) {
obtainStyledAttributes.recycle();
return;
}
if (iArr2 == null || iArr2.length == 0) {
z = obtainStyledAttributes.getResourceId(R.styleable.ThemeEnforcement_android_textAppearance, -1) != -1;
} else {
z = isCustomTextAppearanceValid(context, attributeSet, iArr, i, i2, iArr2);
}
obtainStyledAttributes.recycle();
if (!z) {
throw new IllegalArgumentException("This component requires that you specify a valid TextAppearance attribute. Update your app theme to inherit from Theme.MaterialComponents (or a descendant).");
}
}
private static boolean isCustomTextAppearanceValid(Context context, AttributeSet attributeSet, int[] iArr, int i, int i2, int... iArr2) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, iArr, i, i2);
for (int i3 : iArr2) {
if (obtainStyledAttributes.getResourceId(i3, -1) == -1) {
obtainStyledAttributes.recycle();
return false;
}
}
obtainStyledAttributes.recycle();
return true;
}
public static void checkAppCompatTheme(Context context) {
checkTheme(context, APPCOMPAT_CHECK_ATTRS, APPCOMPAT_THEME_NAME);
}
public static void checkMaterialTheme(Context context) {
checkTheme(context, MATERIAL_CHECK_ATTRS, MATERIAL_THEME_NAME);
}
public static boolean isAppCompatTheme(Context context) {
return isTheme(context, APPCOMPAT_CHECK_ATTRS);
}
public static boolean isMaterialTheme(Context context) {
return isTheme(context, MATERIAL_CHECK_ATTRS);
}
public static boolean isMaterial3Theme(Context context) {
return MaterialAttributes.resolveBoolean(context, R.attr.isMaterial3Theme, false);
}
private static boolean isTheme(Context context, int[] iArr) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(iArr);
for (int i = 0; i < iArr.length; i++) {
if (!obtainStyledAttributes.hasValue(i)) {
obtainStyledAttributes.recycle();
return false;
}
}
obtainStyledAttributes.recycle();
return true;
}
private static void checkTheme(Context context, int[] iArr, String str) {
if (isTheme(context, iArr)) {
return;
}
throw new IllegalArgumentException("The style on this component requires your app theme to be " + str + " (or a descendant).");
}
}

View File

@ -0,0 +1,129 @@
package com.google.android.material.internal;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.view.menu.ActionMenuItemView;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/* loaded from: classes.dex */
public class ToolbarUtils {
private static final Comparator<View> VIEW_TOP_COMPARATOR = new Comparator<View>() { // from class: com.google.android.material.internal.ToolbarUtils.1
@Override // java.util.Comparator
public int compare(View view, View view2) {
return view.getTop() - view2.getTop();
}
};
private ToolbarUtils() {
}
public static TextView getTitleTextView(Toolbar toolbar) {
List<TextView> textViewsWithText = getTextViewsWithText(toolbar, toolbar.getTitle());
if (textViewsWithText.isEmpty()) {
return null;
}
return (TextView) Collections.min(textViewsWithText, VIEW_TOP_COMPARATOR);
}
public static TextView getSubtitleTextView(Toolbar toolbar) {
List<TextView> textViewsWithText = getTextViewsWithText(toolbar, toolbar.getSubtitle());
if (textViewsWithText.isEmpty()) {
return null;
}
return (TextView) Collections.max(textViewsWithText, VIEW_TOP_COMPARATOR);
}
private static List<TextView> getTextViewsWithText(Toolbar toolbar, CharSequence charSequence) {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < toolbar.getChildCount(); i++) {
View childAt = toolbar.getChildAt(i);
if (childAt instanceof TextView) {
TextView textView = (TextView) childAt;
if (TextUtils.equals(textView.getText(), charSequence)) {
arrayList.add(textView);
}
}
}
return arrayList;
}
public static ImageView getLogoImageView(Toolbar toolbar) {
return getImageView(toolbar, toolbar.getLogo());
}
private static ImageView getImageView(Toolbar toolbar, Drawable drawable) {
ImageView imageView;
Drawable drawable2;
if (drawable == null) {
return null;
}
for (int i = 0; i < toolbar.getChildCount(); i++) {
View childAt = toolbar.getChildAt(i);
if ((childAt instanceof ImageView) && (drawable2 = (imageView = (ImageView) childAt).getDrawable()) != null && drawable2.getConstantState() != null && drawable2.getConstantState().equals(drawable.getConstantState())) {
return imageView;
}
}
return null;
}
public static View getSecondaryActionMenuItemView(Toolbar toolbar) {
ActionMenuView actionMenuView = getActionMenuView(toolbar);
if (actionMenuView == null || actionMenuView.getChildCount() <= 1) {
return null;
}
return actionMenuView.getChildAt(0);
}
public static ActionMenuView getActionMenuView(Toolbar toolbar) {
for (int i = 0; i < toolbar.getChildCount(); i++) {
View childAt = toolbar.getChildAt(i);
if (childAt instanceof ActionMenuView) {
return (ActionMenuView) childAt;
}
}
return null;
}
public static ImageButton getNavigationIconButton(Toolbar toolbar) {
Drawable navigationIcon = toolbar.getNavigationIcon();
if (navigationIcon == null) {
return null;
}
for (int i = 0; i < toolbar.getChildCount(); i++) {
View childAt = toolbar.getChildAt(i);
if (childAt instanceof ImageButton) {
ImageButton imageButton = (ImageButton) childAt;
if (imageButton.getDrawable() == navigationIcon) {
return imageButton;
}
}
}
return null;
}
public static ActionMenuItemView getActionMenuItemView(Toolbar toolbar, int i) {
ActionMenuView actionMenuView = getActionMenuView(toolbar);
if (actionMenuView == null) {
return null;
}
for (int i2 = 0; i2 < actionMenuView.getChildCount(); i2++) {
View childAt = actionMenuView.getChildAt(i2);
if (childAt instanceof ActionMenuItemView) {
ActionMenuItemView actionMenuItemView = (ActionMenuItemView) childAt;
if (actionMenuItemView.getItemData().getItemId() == i) {
return actionMenuItemView;
}
}
}
return null;
}
}

View File

@ -0,0 +1,38 @@
package com.google.android.material.internal;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
/* loaded from: classes.dex */
public class TouchObserverFrameLayout extends FrameLayout {
private View.OnTouchListener onTouchListener;
@Override // android.view.View
public void setOnTouchListener(View.OnTouchListener onTouchListener) {
this.onTouchListener = onTouchListener;
}
public TouchObserverFrameLayout(Context context) {
super(context);
}
public TouchObserverFrameLayout(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
public TouchObserverFrameLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
}
@Override // android.view.ViewGroup
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
View.OnTouchListener onTouchListener = this.onTouchListener;
if (onTouchListener != null) {
onTouchListener.onTouch(this, motionEvent);
}
return super.onInterceptTouchEvent(motionEvent);
}
}

View File

@ -0,0 +1,26 @@
package com.google.android.material.internal;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
/* loaded from: classes.dex */
class ViewGroupOverlayApi14 extends ViewOverlayApi14 implements ViewGroupOverlayImpl {
ViewGroupOverlayApi14(Context context, ViewGroup viewGroup, View view) {
super(context, viewGroup, view);
}
static ViewGroupOverlayApi14 createFrom(ViewGroup viewGroup) {
return (ViewGroupOverlayApi14) ViewOverlayApi14.createFrom(viewGroup);
}
@Override // com.google.android.material.internal.ViewGroupOverlayImpl
public void add(View view) {
this.overlayViewGroup.add(view);
}
@Override // com.google.android.material.internal.ViewGroupOverlayImpl
public void remove(View view) {
this.overlayViewGroup.remove(view);
}
}

View File

@ -0,0 +1,35 @@
package com.google.android.material.internal;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroupOverlay;
/* loaded from: classes.dex */
class ViewGroupOverlayApi18 implements ViewGroupOverlayImpl {
private final ViewGroupOverlay viewGroupOverlay;
ViewGroupOverlayApi18(ViewGroup viewGroup) {
this.viewGroupOverlay = viewGroup.getOverlay();
}
@Override // com.google.android.material.internal.ViewOverlayImpl
public void add(Drawable drawable) {
this.viewGroupOverlay.add(drawable);
}
@Override // com.google.android.material.internal.ViewOverlayImpl
public void remove(Drawable drawable) {
this.viewGroupOverlay.remove(drawable);
}
@Override // com.google.android.material.internal.ViewGroupOverlayImpl
public void add(View view) {
this.viewGroupOverlay.add(view);
}
@Override // com.google.android.material.internal.ViewGroupOverlayImpl
public void remove(View view) {
this.viewGroupOverlay.remove(view);
}
}

View File

@ -0,0 +1,10 @@
package com.google.android.material.internal;
import android.view.View;
/* loaded from: classes.dex */
interface ViewGroupOverlayImpl extends ViewOverlayImpl {
void add(View view);
void remove(View view);
}

View File

@ -0,0 +1,217 @@
package com.google.android.material.internal;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.core.view.ViewCompat;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
/* loaded from: classes.dex */
class ViewOverlayApi14 implements ViewOverlayImpl {
protected OverlayViewGroup overlayViewGroup;
ViewOverlayApi14(Context context, ViewGroup viewGroup, View view) {
this.overlayViewGroup = new OverlayViewGroup(context, viewGroup, view, this);
}
static ViewOverlayApi14 createFrom(View view) {
ViewGroup contentView = ViewUtils.getContentView(view);
if (contentView == null) {
return null;
}
int childCount = contentView.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = contentView.getChildAt(i);
if (childAt instanceof OverlayViewGroup) {
return ((OverlayViewGroup) childAt).viewOverlay;
}
}
return new ViewGroupOverlayApi14(contentView.getContext(), contentView, view);
}
@Override // com.google.android.material.internal.ViewOverlayImpl
public void add(Drawable drawable) {
this.overlayViewGroup.add(drawable);
}
@Override // com.google.android.material.internal.ViewOverlayImpl
public void remove(Drawable drawable) {
this.overlayViewGroup.remove(drawable);
}
static class OverlayViewGroup extends ViewGroup {
static Method invalidateChildInParentFastMethod;
private boolean disposed;
ArrayList<Drawable> drawables;
ViewGroup hostView;
View requestingView;
ViewOverlayApi14 viewOverlay;
@Override // android.view.ViewGroup, android.view.View
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
return false;
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
}
static {
try {
invalidateChildInParentFastMethod = ViewGroup.class.getDeclaredMethod("invalidateChildInParentFast", Integer.TYPE, Integer.TYPE, Rect.class);
} catch (NoSuchMethodException unused) {
}
}
OverlayViewGroup(Context context, ViewGroup viewGroup, View view, ViewOverlayApi14 viewOverlayApi14) {
super(context);
this.drawables = null;
this.hostView = viewGroup;
this.requestingView = view;
setRight(viewGroup.getWidth());
setBottom(viewGroup.getHeight());
viewGroup.addView(this);
this.viewOverlay = viewOverlayApi14;
}
public void add(Drawable drawable) {
assertNotDisposed();
if (this.drawables == null) {
this.drawables = new ArrayList<>();
}
if (this.drawables.contains(drawable)) {
return;
}
this.drawables.add(drawable);
invalidate(drawable.getBounds());
drawable.setCallback(this);
}
public void remove(Drawable drawable) {
ArrayList<Drawable> arrayList = this.drawables;
if (arrayList != null) {
arrayList.remove(drawable);
invalidate(drawable.getBounds());
drawable.setCallback(null);
disposeIfEmpty();
}
}
@Override // android.view.View
protected boolean verifyDrawable(Drawable drawable) {
ArrayList<Drawable> arrayList;
return super.verifyDrawable(drawable) || ((arrayList = this.drawables) != null && arrayList.contains(drawable));
}
public void add(View view) {
assertNotDisposed();
if (view.getParent() instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view.getParent();
if (viewGroup != this.hostView && viewGroup.getParent() != null && ViewCompat.isAttachedToWindow(viewGroup)) {
int[] iArr = new int[2];
int[] iArr2 = new int[2];
viewGroup.getLocationOnScreen(iArr);
this.hostView.getLocationOnScreen(iArr2);
ViewCompat.offsetLeftAndRight(view, iArr[0] - iArr2[0]);
ViewCompat.offsetTopAndBottom(view, iArr[1] - iArr2[1]);
}
viewGroup.removeView(view);
if (view.getParent() != null) {
viewGroup.removeView(view);
}
}
super.addView(view);
}
public void remove(View view) {
super.removeView(view);
disposeIfEmpty();
}
private void assertNotDisposed() {
if (this.disposed) {
throw new IllegalStateException("This overlay was disposed already. Please use a new one via ViewGroupUtils.getOverlay()");
}
}
private void disposeIfEmpty() {
if (getChildCount() == 0) {
ArrayList<Drawable> arrayList = this.drawables;
if (arrayList == null || arrayList.size() == 0) {
this.disposed = true;
this.hostView.removeView(this);
}
}
}
@Override // android.view.View, android.graphics.drawable.Drawable.Callback
public void invalidateDrawable(Drawable drawable) {
invalidate(drawable.getBounds());
}
@Override // android.view.ViewGroup, android.view.View
protected void dispatchDraw(Canvas canvas) {
this.hostView.getLocationOnScreen(new int[2]);
this.requestingView.getLocationOnScreen(new int[2]);
canvas.translate(r0[0] - r1[0], r0[1] - r1[1]);
canvas.clipRect(new Rect(0, 0, this.requestingView.getWidth(), this.requestingView.getHeight()));
super.dispatchDraw(canvas);
ArrayList<Drawable> arrayList = this.drawables;
int size = arrayList == null ? 0 : arrayList.size();
for (int i = 0; i < size; i++) {
this.drawables.get(i).draw(canvas);
}
}
private void getOffset(int[] iArr) {
int[] iArr2 = new int[2];
int[] iArr3 = new int[2];
this.hostView.getLocationOnScreen(iArr2);
this.requestingView.getLocationOnScreen(iArr3);
iArr[0] = iArr3[0] - iArr2[0];
iArr[1] = iArr3[1] - iArr2[1];
}
protected ViewParent invalidateChildInParentFast(int i, int i2, Rect rect) {
if (this.hostView == null || invalidateChildInParentFastMethod == null) {
return null;
}
try {
getOffset(new int[2]);
invalidateChildInParentFastMethod.invoke(this.hostView, Integer.valueOf(i), Integer.valueOf(i2), rect);
return null;
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
} catch (InvocationTargetException e2) {
e2.printStackTrace();
return null;
}
}
@Override // android.view.ViewGroup, android.view.ViewParent
public ViewParent invalidateChildInParent(int[] iArr, Rect rect) {
if (this.hostView == null) {
return null;
}
rect.offset(iArr[0], iArr[1]);
if (this.hostView != null) {
iArr[0] = 0;
iArr[1] = 0;
int[] iArr2 = new int[2];
getOffset(iArr2);
rect.offset(iArr2[0], iArr2[1]);
return super.invalidateChildInParent(iArr, rect);
}
invalidate(rect);
return null;
}
}
}

View File

@ -0,0 +1,24 @@
package com.google.android.material.internal;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewOverlay;
/* loaded from: classes.dex */
class ViewOverlayApi18 implements ViewOverlayImpl {
private final ViewOverlay viewOverlay;
ViewOverlayApi18(View view) {
this.viewOverlay = view.getOverlay();
}
@Override // com.google.android.material.internal.ViewOverlayImpl
public void add(Drawable drawable) {
this.viewOverlay.add(drawable);
}
@Override // com.google.android.material.internal.ViewOverlayImpl
public void remove(Drawable drawable) {
this.viewOverlay.remove(drawable);
}
}

View File

@ -0,0 +1,10 @@
package com.google.android.material.internal;
import android.graphics.drawable.Drawable;
/* loaded from: classes.dex */
public interface ViewOverlayImpl {
void add(Drawable drawable);
void remove(Drawable drawable);
}

View File

@ -0,0 +1,299 @@
package com.google.android.material.internal;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import com.google.android.material.R;
import com.google.android.material.drawable.DrawableUtils;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
public class ViewUtils {
public static final int EDGE_TO_EDGE_FLAGS = 768;
public interface OnApplyWindowInsetsListener {
WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat, RelativePadding relativePadding);
}
private ViewUtils() {
}
public static void showKeyboard(View view) {
showKeyboard(view, true);
}
public static void showKeyboard(View view, boolean z) {
WindowInsetsControllerCompat windowInsetsController;
if (z && (windowInsetsController = ViewCompat.getWindowInsetsController(view)) != null) {
windowInsetsController.show(WindowInsetsCompat.Type.ime());
} else {
getInputMethodManager(view).showSoftInput(view, 1);
}
}
public static void requestFocusAndShowKeyboard(View view) {
requestFocusAndShowKeyboard(view, true);
}
public static void requestFocusAndShowKeyboard(final View view, final boolean z) {
view.requestFocus();
view.post(new Runnable() { // from class: com.google.android.material.internal.ViewUtils$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
ViewUtils.showKeyboard(view, z);
}
});
}
public static void hideKeyboard(View view) {
hideKeyboard(view, true);
}
public static void hideKeyboard(View view, boolean z) {
WindowInsetsControllerCompat windowInsetsController;
if (z && (windowInsetsController = ViewCompat.getWindowInsetsController(view)) != null) {
windowInsetsController.hide(WindowInsetsCompat.Type.ime());
return;
}
InputMethodManager inputMethodManager = getInputMethodManager(view);
if (inputMethodManager != null) {
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
private static InputMethodManager getInputMethodManager(View view) {
return (InputMethodManager) ContextCompat.getSystemService(view.getContext(), InputMethodManager.class);
}
public static void setBoundsFromRect(View view, Rect rect) {
view.setLeft(rect.left);
view.setTop(rect.top);
view.setRight(rect.right);
view.setBottom(rect.bottom);
}
public static Rect calculateRectFromBounds(View view) {
return calculateRectFromBounds(view, 0);
}
public static Rect calculateRectFromBounds(View view, int i) {
return new Rect(view.getLeft(), view.getTop() + i, view.getRight(), view.getBottom() + i);
}
public static Rect calculateOffsetRectFromBounds(View view, View view2) {
int[] iArr = new int[2];
view2.getLocationOnScreen(iArr);
int i = iArr[0];
int i2 = iArr[1];
int[] iArr2 = new int[2];
view.getLocationOnScreen(iArr2);
int i3 = i - iArr2[0];
int i4 = i2 - iArr2[1];
return new Rect(i3, i4, view2.getWidth() + i3, view2.getHeight() + i4);
}
public static List<View> getChildren(View view) {
ArrayList arrayList = new ArrayList();
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
arrayList.add(viewGroup.getChildAt(i));
}
}
return arrayList;
}
public static PorterDuff.Mode parseTintMode(int i, PorterDuff.Mode mode) {
if (i == 3) {
return PorterDuff.Mode.SRC_OVER;
}
if (i == 5) {
return PorterDuff.Mode.SRC_IN;
}
if (i == 9) {
return PorterDuff.Mode.SRC_ATOP;
}
switch (i) {
case 14:
return PorterDuff.Mode.MULTIPLY;
case 15:
return PorterDuff.Mode.SCREEN;
case 16:
return PorterDuff.Mode.ADD;
default:
return mode;
}
}
public static boolean isLayoutRtl(View view) {
return ViewCompat.getLayoutDirection(view) == 1;
}
public static float dpToPx(Context context, int i) {
return TypedValue.applyDimension(1, i, context.getResources().getDisplayMetrics());
}
public static class RelativePadding {
public int bottom;
public int end;
public int start;
public int top;
public RelativePadding(int i, int i2, int i3, int i4) {
this.start = i;
this.top = i2;
this.end = i3;
this.bottom = i4;
}
public RelativePadding(RelativePadding relativePadding) {
this.start = relativePadding.start;
this.top = relativePadding.top;
this.end = relativePadding.end;
this.bottom = relativePadding.bottom;
}
public void applyToView(View view) {
ViewCompat.setPaddingRelative(view, this.start, this.top, this.end, this.bottom);
}
}
public static void doOnApplyWindowInsets(View view, AttributeSet attributeSet, int i, int i2) {
doOnApplyWindowInsets(view, attributeSet, i, i2, null);
}
public static void doOnApplyWindowInsets(View view, AttributeSet attributeSet, int i, int i2, final OnApplyWindowInsetsListener onApplyWindowInsetsListener) {
TypedArray obtainStyledAttributes = view.getContext().obtainStyledAttributes(attributeSet, R.styleable.Insets, i, i2);
final boolean z = obtainStyledAttributes.getBoolean(R.styleable.Insets_paddingBottomSystemWindowInsets, false);
final boolean z2 = obtainStyledAttributes.getBoolean(R.styleable.Insets_paddingLeftSystemWindowInsets, false);
final boolean z3 = obtainStyledAttributes.getBoolean(R.styleable.Insets_paddingRightSystemWindowInsets, false);
obtainStyledAttributes.recycle();
doOnApplyWindowInsets(view, new OnApplyWindowInsetsListener() { // from class: com.google.android.material.internal.ViewUtils.1
@Override // com.google.android.material.internal.ViewUtils.OnApplyWindowInsetsListener
public WindowInsetsCompat onApplyWindowInsets(View view2, WindowInsetsCompat windowInsetsCompat, RelativePadding relativePadding) {
if (z) {
relativePadding.bottom += windowInsetsCompat.getSystemWindowInsetBottom();
}
boolean isLayoutRtl = ViewUtils.isLayoutRtl(view2);
if (z2) {
if (isLayoutRtl) {
relativePadding.end += windowInsetsCompat.getSystemWindowInsetLeft();
} else {
relativePadding.start += windowInsetsCompat.getSystemWindowInsetLeft();
}
}
if (z3) {
if (isLayoutRtl) {
relativePadding.start += windowInsetsCompat.getSystemWindowInsetRight();
} else {
relativePadding.end += windowInsetsCompat.getSystemWindowInsetRight();
}
}
relativePadding.applyToView(view2);
OnApplyWindowInsetsListener onApplyWindowInsetsListener2 = onApplyWindowInsetsListener;
return onApplyWindowInsetsListener2 != null ? onApplyWindowInsetsListener2.onApplyWindowInsets(view2, windowInsetsCompat, relativePadding) : windowInsetsCompat;
}
});
}
public static void doOnApplyWindowInsets(View view, final OnApplyWindowInsetsListener onApplyWindowInsetsListener) {
final RelativePadding relativePadding = new RelativePadding(ViewCompat.getPaddingStart(view), view.getPaddingTop(), ViewCompat.getPaddingEnd(view), view.getPaddingBottom());
ViewCompat.setOnApplyWindowInsetsListener(view, new androidx.core.view.OnApplyWindowInsetsListener() { // from class: com.google.android.material.internal.ViewUtils.2
@Override // androidx.core.view.OnApplyWindowInsetsListener
public WindowInsetsCompat onApplyWindowInsets(View view2, WindowInsetsCompat windowInsetsCompat) {
return OnApplyWindowInsetsListener.this.onApplyWindowInsets(view2, windowInsetsCompat, new RelativePadding(relativePadding));
}
});
requestApplyInsetsWhenAttached(view);
}
public static void requestApplyInsetsWhenAttached(View view) {
if (ViewCompat.isAttachedToWindow(view)) {
ViewCompat.requestApplyInsets(view);
} else {
view.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { // from class: com.google.android.material.internal.ViewUtils.3
@Override // android.view.View.OnAttachStateChangeListener
public void onViewDetachedFromWindow(View view2) {
}
@Override // android.view.View.OnAttachStateChangeListener
public void onViewAttachedToWindow(View view2) {
view2.removeOnAttachStateChangeListener(this);
ViewCompat.requestApplyInsets(view2);
}
});
}
}
public static float getParentAbsoluteElevation(View view) {
float f = 0.0f;
for (ViewParent parent = view.getParent(); parent instanceof View; parent = parent.getParent()) {
f += ViewCompat.getElevation((View) parent);
}
return f;
}
public static ViewOverlayImpl getOverlay(View view) {
if (view == null) {
return null;
}
return new ViewOverlayApi18(view);
}
public static ViewGroup getContentView(View view) {
if (view == null) {
return null;
}
View rootView = view.getRootView();
ViewGroup viewGroup = (ViewGroup) rootView.findViewById(android.R.id.content);
if (viewGroup != null) {
return viewGroup;
}
if (rootView == view || !(rootView instanceof ViewGroup)) {
return null;
}
return (ViewGroup) rootView;
}
public static ViewOverlayImpl getContentViewOverlay(View view) {
return getOverlay(getContentView(view));
}
public static void addOnGlobalLayoutListener(View view, ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener) {
if (view != null) {
view.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
}
}
public static void removeOnGlobalLayoutListener(View view, ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener) {
if (view != null) {
removeOnGlobalLayoutListener(view.getViewTreeObserver(), onGlobalLayoutListener);
}
}
public static void removeOnGlobalLayoutListener(ViewTreeObserver viewTreeObserver, ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener) {
viewTreeObserver.removeOnGlobalLayoutListener(onGlobalLayoutListener);
}
public static Integer getBackgroundColor(View view) {
ColorStateList colorStateListOrNull = DrawableUtils.getColorStateListOrNull(view.getBackground());
if (colorStateListOrNull != null) {
return Integer.valueOf(colorStateListOrNull.getDefaultColor());
}
return null;
}
}

View File

@ -0,0 +1,39 @@
package com.google.android.material.internal;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageButton;
/* loaded from: classes.dex */
public class VisibilityAwareImageButton extends ImageButton {
private int userSetVisibility;
public final int getUserSetVisibility() {
return this.userSetVisibility;
}
public VisibilityAwareImageButton(Context context) {
this(context, null);
}
public VisibilityAwareImageButton(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public VisibilityAwareImageButton(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.userSetVisibility = getVisibility();
}
@Override // android.widget.ImageView, android.view.View
public void setVisibility(int i) {
internalSetVisibility(i, true);
}
public final void internalSetVisibility(int i, boolean z) {
super.setVisibility(i);
if (z) {
this.userSetVisibility = i;
}
}
}

View File

@ -0,0 +1,90 @@
package com.google.android.material.internal;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import android.view.WindowMetrics;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/* loaded from: classes.dex */
public class WindowUtils {
private static final String TAG = "WindowUtils";
private WindowUtils() {
}
public static Rect getCurrentWindowBounds(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService("window");
if (Build.VERSION.SDK_INT >= 30) {
return Api30Impl.getCurrentWindowBounds(windowManager);
}
return Api17Impl.getCurrentWindowBounds(windowManager);
}
private static class Api30Impl {
private Api30Impl() {
}
static Rect getCurrentWindowBounds(WindowManager windowManager) {
WindowMetrics currentWindowMetrics;
Rect bounds;
currentWindowMetrics = windowManager.getCurrentWindowMetrics();
bounds = currentWindowMetrics.getBounds();
return bounds;
}
}
private static class Api17Impl {
private Api17Impl() {
}
static Rect getCurrentWindowBounds(WindowManager windowManager) {
Display defaultDisplay = windowManager.getDefaultDisplay();
Point point = new Point();
defaultDisplay.getRealSize(point);
Rect rect = new Rect();
rect.right = point.x;
rect.bottom = point.y;
return rect;
}
}
private static class Api14Impl {
private Api14Impl() {
}
static Rect getCurrentWindowBounds(WindowManager windowManager) {
Display defaultDisplay = windowManager.getDefaultDisplay();
Point realSizeForDisplay = getRealSizeForDisplay(defaultDisplay);
Rect rect = new Rect();
if (realSizeForDisplay.x == 0 || realSizeForDisplay.y == 0) {
defaultDisplay.getRectSize(rect);
} else {
rect.right = realSizeForDisplay.x;
rect.bottom = realSizeForDisplay.y;
}
return rect;
}
private static Point getRealSizeForDisplay(Display display) {
Point point = new Point();
try {
Method declaredMethod = Display.class.getDeclaredMethod("getRealSize", Point.class);
declaredMethod.setAccessible(true);
declaredMethod.invoke(display, point);
} catch (IllegalAccessException e) {
Log.w(WindowUtils.TAG, e);
} catch (NoSuchMethodException e2) {
Log.w(WindowUtils.TAG, e2);
} catch (InvocationTargetException e3) {
Log.w(WindowUtils.TAG, e3);
}
return point;
}
}
}

View File

@ -0,0 +1,2 @@
package com.google.android.material.internal;