ADD week 5
This commit is contained in:
6827
02-Easy5/E5/sources/com/google/android/material/R.java
Normal file
6827
02-Easy5/E5/sources/com/google/android/material/R.java
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,13 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface AnimatableView {
|
||||
|
||||
public interface Listener {
|
||||
void onAnimationEnd();
|
||||
}
|
||||
|
||||
void startAnimation(Listener listener);
|
||||
|
||||
void stopAnimation();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import androidx.interpolator.view.animation.FastOutLinearInInterpolator;
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
import androidx.interpolator.view.animation.LinearOutSlowInInterpolator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AnimationUtils {
|
||||
public static final TimeInterpolator LINEAR_INTERPOLATOR = new LinearInterpolator();
|
||||
public static final TimeInterpolator FAST_OUT_SLOW_IN_INTERPOLATOR = new FastOutSlowInInterpolator();
|
||||
public static final TimeInterpolator FAST_OUT_LINEAR_IN_INTERPOLATOR = new FastOutLinearInInterpolator();
|
||||
public static final TimeInterpolator LINEAR_OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator();
|
||||
public static final TimeInterpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();
|
||||
|
||||
public static float lerp(float f, float f2, float f3) {
|
||||
return f + (f3 * (f2 - f));
|
||||
}
|
||||
|
||||
public static int lerp(int i, int i2, float f) {
|
||||
return i + Math.round(f * (i2 - i));
|
||||
}
|
||||
|
||||
public static float lerp(float f, float f2, float f3, float f4, float f5) {
|
||||
return f5 <= f3 ? f : f5 >= f4 ? f2 : lerp(f, f2, (f5 - f3) / (f4 - f3));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ValueAnimator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AnimatorSetCompat {
|
||||
public static void playTogether(AnimatorSet animatorSet, List<Animator> list) {
|
||||
int size = list.size();
|
||||
long j = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
Animator animator = list.get(i);
|
||||
j = Math.max(j, animator.getStartDelay() + animator.getDuration());
|
||||
}
|
||||
ValueAnimator ofInt = ValueAnimator.ofInt(0, 0);
|
||||
ofInt.setDuration(j);
|
||||
list.add(0, ofInt);
|
||||
animatorSet.playTogether(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.animation.TypeEvaluator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ArgbEvaluatorCompat implements TypeEvaluator<Integer> {
|
||||
private static final ArgbEvaluatorCompat instance = new ArgbEvaluatorCompat();
|
||||
|
||||
public static ArgbEvaluatorCompat getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override // android.animation.TypeEvaluator
|
||||
public Integer evaluate(float f, Integer num, Integer num2) {
|
||||
int intValue = num.intValue();
|
||||
float f2 = ((intValue >> 24) & 255) / 255.0f;
|
||||
int intValue2 = num2.intValue();
|
||||
float pow = (float) Math.pow(((intValue >> 16) & 255) / 255.0f, 2.2d);
|
||||
float pow2 = (float) Math.pow(((intValue >> 8) & 255) / 255.0f, 2.2d);
|
||||
float pow3 = (float) Math.pow((intValue & 255) / 255.0f, 2.2d);
|
||||
float pow4 = (float) Math.pow(((intValue2 >> 16) & 255) / 255.0f, 2.2d);
|
||||
float f3 = f2 + (((((intValue2 >> 24) & 255) / 255.0f) - f2) * f);
|
||||
float pow5 = pow2 + ((((float) Math.pow(((intValue2 >> 8) & 255) / 255.0f, 2.2d)) - pow2) * f);
|
||||
float pow6 = pow3 + (f * (((float) Math.pow((intValue2 & 255) / 255.0f, 2.2d)) - pow3));
|
||||
return Integer.valueOf((Math.round(((float) Math.pow(pow + ((pow4 - pow) * f), 0.45454545454545453d)) * 255.0f) << 16) | (Math.round(f3 * 255.0f) << 24) | (Math.round(((float) Math.pow(pow5, 0.45454545454545453d)) * 255.0f) << 8) | Math.round(((float) Math.pow(pow6, 0.45454545454545453d)) * 255.0f));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.util.Property;
|
||||
import android.view.ViewGroup;
|
||||
import com.google.android.material.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ChildrenAlphaProperty extends Property<ViewGroup, Float> {
|
||||
public static final Property<ViewGroup, Float> CHILDREN_ALPHA = new ChildrenAlphaProperty("childrenAlpha");
|
||||
|
||||
private ChildrenAlphaProperty(String str) {
|
||||
super(Float.class, str);
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public Float get(ViewGroup viewGroup) {
|
||||
Float f = (Float) viewGroup.getTag(R.id.mtrl_internal_children_alpha_tag);
|
||||
return f != null ? f : Float.valueOf(1.0f);
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(ViewGroup viewGroup, Float f) {
|
||||
float floatValue = f.floatValue();
|
||||
viewGroup.setTag(R.id.mtrl_internal_children_alpha_tag, Float.valueOf(floatValue));
|
||||
int childCount = viewGroup.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
viewGroup.getChildAt(i).setAlpha(floatValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Property;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DrawableAlphaProperty extends Property<Drawable, Integer> {
|
||||
public static final Property<Drawable, Integer> DRAWABLE_ALPHA_COMPAT = new DrawableAlphaProperty();
|
||||
private final WeakHashMap<Drawable, Integer> alphaCache;
|
||||
|
||||
private DrawableAlphaProperty() {
|
||||
super(Integer.class, "drawableAlphaCompat");
|
||||
this.alphaCache = new WeakHashMap<>();
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public Integer get(Drawable drawable) {
|
||||
return Integer.valueOf(drawable.getAlpha());
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(Drawable drawable, Integer num) {
|
||||
drawable.setAlpha(num.intValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
import android.util.Property;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ImageMatrixProperty extends Property<ImageView, Matrix> {
|
||||
private final Matrix matrix;
|
||||
|
||||
public ImageMatrixProperty() {
|
||||
super(Matrix.class, "imageMatrixProperty");
|
||||
this.matrix = new Matrix();
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(ImageView imageView, Matrix matrix) {
|
||||
imageView.setImageMatrix(matrix);
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public Matrix get(ImageView imageView) {
|
||||
this.matrix.set(imageView.getImageMatrix());
|
||||
return this.matrix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.graphics.Matrix;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MatrixEvaluator implements TypeEvaluator<Matrix> {
|
||||
private final float[] tempStartValues = new float[9];
|
||||
private final float[] tempEndValues = new float[9];
|
||||
private final Matrix tempMatrix = new Matrix();
|
||||
|
||||
@Override // android.animation.TypeEvaluator
|
||||
public Matrix evaluate(float f, Matrix matrix, Matrix matrix2) {
|
||||
matrix.getValues(this.tempStartValues);
|
||||
matrix2.getValues(this.tempEndValues);
|
||||
for (int i = 0; i < 9; i++) {
|
||||
float[] fArr = this.tempEndValues;
|
||||
float f2 = fArr[i];
|
||||
float f3 = this.tempStartValues[i];
|
||||
fArr[i] = f3 + ((f2 - f3) * f);
|
||||
}
|
||||
this.tempMatrix.setValues(this.tempEndValues);
|
||||
return this.tempMatrix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.Log;
|
||||
import android.util.Property;
|
||||
import androidx.collection.SimpleArrayMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MotionSpec {
|
||||
private static final String TAG = "MotionSpec";
|
||||
private final SimpleArrayMap<String, MotionTiming> timings = new SimpleArrayMap<>();
|
||||
private final SimpleArrayMap<String, PropertyValuesHolder[]> propertyValues = new SimpleArrayMap<>();
|
||||
|
||||
public boolean hasTiming(String str) {
|
||||
return this.timings.get(str) != null;
|
||||
}
|
||||
|
||||
public MotionTiming getTiming(String str) {
|
||||
if (!hasTiming(str)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return this.timings.get(str);
|
||||
}
|
||||
|
||||
public void setTiming(String str, MotionTiming motionTiming) {
|
||||
this.timings.put(str, motionTiming);
|
||||
}
|
||||
|
||||
public boolean hasPropertyValues(String str) {
|
||||
return this.propertyValues.get(str) != null;
|
||||
}
|
||||
|
||||
public PropertyValuesHolder[] getPropertyValues(String str) {
|
||||
if (!hasPropertyValues(str)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return clonePropertyValuesHolder(this.propertyValues.get(str));
|
||||
}
|
||||
|
||||
public void setPropertyValues(String str, PropertyValuesHolder[] propertyValuesHolderArr) {
|
||||
this.propertyValues.put(str, propertyValuesHolderArr);
|
||||
}
|
||||
|
||||
private PropertyValuesHolder[] clonePropertyValuesHolder(PropertyValuesHolder[] propertyValuesHolderArr) {
|
||||
PropertyValuesHolder[] propertyValuesHolderArr2 = new PropertyValuesHolder[propertyValuesHolderArr.length];
|
||||
for (int i = 0; i < propertyValuesHolderArr.length; i++) {
|
||||
propertyValuesHolderArr2[i] = propertyValuesHolderArr[i].clone();
|
||||
}
|
||||
return propertyValuesHolderArr2;
|
||||
}
|
||||
|
||||
public <T> ObjectAnimator getAnimator(String str, T t, Property<T, ?> property) {
|
||||
ObjectAnimator ofPropertyValuesHolder = ObjectAnimator.ofPropertyValuesHolder(t, getPropertyValues(str));
|
||||
ofPropertyValuesHolder.setProperty(property);
|
||||
getTiming(str).apply(ofPropertyValuesHolder);
|
||||
return ofPropertyValuesHolder;
|
||||
}
|
||||
|
||||
public long getTotalDuration() {
|
||||
int size = this.timings.size();
|
||||
long j = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
MotionTiming valueAt = this.timings.valueAt(i);
|
||||
j = Math.max(j, valueAt.getDelay() + valueAt.getDuration());
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
public static MotionSpec createFromAttribute(Context context, TypedArray typedArray, int i) {
|
||||
int resourceId;
|
||||
if (!typedArray.hasValue(i) || (resourceId = typedArray.getResourceId(i, 0)) == 0) {
|
||||
return null;
|
||||
}
|
||||
return createFromResource(context, resourceId);
|
||||
}
|
||||
|
||||
public static MotionSpec createFromResource(Context context, int i) {
|
||||
try {
|
||||
Animator loadAnimator = AnimatorInflater.loadAnimator(context, i);
|
||||
if (loadAnimator instanceof AnimatorSet) {
|
||||
return createSpecFromAnimators(((AnimatorSet) loadAnimator).getChildAnimations());
|
||||
}
|
||||
if (loadAnimator == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(loadAnimator);
|
||||
return createSpecFromAnimators(arrayList);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Can't load animation resource ID #0x" + Integer.toHexString(i), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static MotionSpec createSpecFromAnimators(List<Animator> list) {
|
||||
MotionSpec motionSpec = new MotionSpec();
|
||||
int size = list.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
addInfoFromAnimator(motionSpec, list.get(i));
|
||||
}
|
||||
return motionSpec;
|
||||
}
|
||||
|
||||
private static void addInfoFromAnimator(MotionSpec motionSpec, Animator animator) {
|
||||
if (animator instanceof ObjectAnimator) {
|
||||
ObjectAnimator objectAnimator = (ObjectAnimator) animator;
|
||||
motionSpec.setPropertyValues(objectAnimator.getPropertyName(), objectAnimator.getValues());
|
||||
motionSpec.setTiming(objectAnimator.getPropertyName(), MotionTiming.createFromAnimator(objectAnimator));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Animator must be an ObjectAnimator: " + animator);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof MotionSpec) {
|
||||
return this.timings.equals(((MotionSpec) obj).timings);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.timings.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "\n" + getClass().getName() + '{' + Integer.toHexString(System.identityHashCode(this)) + " timings: " + this.timings + "}\n";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MotionTiming {
|
||||
private long delay;
|
||||
private long duration;
|
||||
private TimeInterpolator interpolator;
|
||||
private int repeatCount;
|
||||
private int repeatMode;
|
||||
|
||||
public long getDelay() {
|
||||
return this.delay;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public int getRepeatCount() {
|
||||
return this.repeatCount;
|
||||
}
|
||||
|
||||
public int getRepeatMode() {
|
||||
return this.repeatMode;
|
||||
}
|
||||
|
||||
public MotionTiming(long j, long j2) {
|
||||
this.interpolator = null;
|
||||
this.repeatCount = 0;
|
||||
this.repeatMode = 1;
|
||||
this.delay = j;
|
||||
this.duration = j2;
|
||||
}
|
||||
|
||||
public MotionTiming(long j, long j2, TimeInterpolator timeInterpolator) {
|
||||
this.repeatCount = 0;
|
||||
this.repeatMode = 1;
|
||||
this.delay = j;
|
||||
this.duration = j2;
|
||||
this.interpolator = timeInterpolator;
|
||||
}
|
||||
|
||||
public void apply(Animator animator) {
|
||||
animator.setStartDelay(getDelay());
|
||||
animator.setDuration(getDuration());
|
||||
animator.setInterpolator(getInterpolator());
|
||||
if (animator instanceof ValueAnimator) {
|
||||
ValueAnimator valueAnimator = (ValueAnimator) animator;
|
||||
valueAnimator.setRepeatCount(getRepeatCount());
|
||||
valueAnimator.setRepeatMode(getRepeatMode());
|
||||
}
|
||||
}
|
||||
|
||||
public TimeInterpolator getInterpolator() {
|
||||
TimeInterpolator timeInterpolator = this.interpolator;
|
||||
return timeInterpolator != null ? timeInterpolator : AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR;
|
||||
}
|
||||
|
||||
static MotionTiming createFromAnimator(ValueAnimator valueAnimator) {
|
||||
MotionTiming motionTiming = new MotionTiming(valueAnimator.getStartDelay(), valueAnimator.getDuration(), getInterpolatorCompat(valueAnimator));
|
||||
motionTiming.repeatCount = valueAnimator.getRepeatCount();
|
||||
motionTiming.repeatMode = valueAnimator.getRepeatMode();
|
||||
return motionTiming;
|
||||
}
|
||||
|
||||
private static TimeInterpolator getInterpolatorCompat(ValueAnimator valueAnimator) {
|
||||
TimeInterpolator interpolator = valueAnimator.getInterpolator();
|
||||
if ((interpolator instanceof AccelerateDecelerateInterpolator) || interpolator == null) {
|
||||
return AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR;
|
||||
}
|
||||
if (interpolator instanceof AccelerateInterpolator) {
|
||||
return AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR;
|
||||
}
|
||||
return interpolator instanceof DecelerateInterpolator ? AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR : interpolator;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof MotionTiming)) {
|
||||
return false;
|
||||
}
|
||||
MotionTiming motionTiming = (MotionTiming) obj;
|
||||
if (getDelay() == motionTiming.getDelay() && getDuration() == motionTiming.getDuration() && getRepeatCount() == motionTiming.getRepeatCount() && getRepeatMode() == motionTiming.getRepeatMode()) {
|
||||
return getInterpolator().getClass().equals(motionTiming.getInterpolator().getClass());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (((((((((int) (getDelay() ^ (getDelay() >>> 32))) * 31) + ((int) (getDuration() ^ (getDuration() >>> 32)))) * 31) + getInterpolator().getClass().hashCode()) * 31) + getRepeatCount()) * 31) + getRepeatMode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "\n" + getClass().getName() + '{' + Integer.toHexString(System.identityHashCode(this)) + " delay: " + getDelay() + " duration: " + getDuration() + " interpolator: " + getInterpolator().getClass() + " repeatCount: " + getRepeatCount() + " repeatMode: " + getRepeatMode() + "}\n";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Positioning {
|
||||
public final int gravity;
|
||||
public final float xAdjustment;
|
||||
public final float yAdjustment;
|
||||
|
||||
public Positioning(int i, float f, float f2) {
|
||||
this.gravity = i;
|
||||
this.xAdjustment = f;
|
||||
this.yAdjustment = f2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.google.android.material.animation;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface TransformationCallback<T extends View> {
|
||||
void onScaleChanged(T t);
|
||||
|
||||
void onTranslationChanged(T t);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,269 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.widget.OverScroller;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.math.MathUtils;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class HeaderBehavior<V extends View> extends ViewOffsetBehavior<V> {
|
||||
private static final int INVALID_POINTER = -1;
|
||||
private int activePointerId;
|
||||
private Runnable flingRunnable;
|
||||
private boolean isBeingDragged;
|
||||
private int lastMotionY;
|
||||
OverScroller scroller;
|
||||
private int touchSlop;
|
||||
private VelocityTracker velocityTracker;
|
||||
|
||||
boolean canDragView(V v) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void onFlingFinished(CoordinatorLayout coordinatorLayout, V v) {
|
||||
}
|
||||
|
||||
public HeaderBehavior() {
|
||||
this.activePointerId = -1;
|
||||
this.touchSlop = -1;
|
||||
}
|
||||
|
||||
public HeaderBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.activePointerId = -1;
|
||||
this.touchSlop = -1;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onInterceptTouchEvent(CoordinatorLayout coordinatorLayout, V v, MotionEvent motionEvent) {
|
||||
int findPointerIndex;
|
||||
if (this.touchSlop < 0) {
|
||||
this.touchSlop = ViewConfiguration.get(coordinatorLayout.getContext()).getScaledTouchSlop();
|
||||
}
|
||||
if (motionEvent.getActionMasked() == 2 && this.isBeingDragged) {
|
||||
int i = this.activePointerId;
|
||||
if (i == -1 || (findPointerIndex = motionEvent.findPointerIndex(i)) == -1) {
|
||||
return false;
|
||||
}
|
||||
int y = (int) motionEvent.getY(findPointerIndex);
|
||||
if (Math.abs(y - this.lastMotionY) > this.touchSlop) {
|
||||
this.lastMotionY = y;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (motionEvent.getActionMasked() == 0) {
|
||||
this.activePointerId = -1;
|
||||
int x = (int) motionEvent.getX();
|
||||
int y2 = (int) motionEvent.getY();
|
||||
boolean z = canDragView(v) && coordinatorLayout.isPointInChildBounds(v, x, y2);
|
||||
this.isBeingDragged = z;
|
||||
if (z) {
|
||||
this.lastMotionY = y2;
|
||||
this.activePointerId = motionEvent.getPointerId(0);
|
||||
ensureVelocityTracker();
|
||||
OverScroller overScroller = this.scroller;
|
||||
if (overScroller != null && !overScroller.isFinished()) {
|
||||
this.scroller.abortAnimation();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
VelocityTracker velocityTracker = this.velocityTracker;
|
||||
if (velocityTracker != null) {
|
||||
velocityTracker.addMovement(motionEvent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:17:0x0085 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:20:0x008c A[ADDED_TO_REGION] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:24:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:28:0x007b */
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public boolean onTouchEvent(androidx.coordinatorlayout.widget.CoordinatorLayout r12, V r13, android.view.MotionEvent r14) {
|
||||
/*
|
||||
r11 = this;
|
||||
int r0 = r14.getActionMasked()
|
||||
r1 = -1
|
||||
r2 = 1
|
||||
r3 = 0
|
||||
if (r0 == r2) goto L4e
|
||||
r4 = 2
|
||||
if (r0 == r4) goto L2d
|
||||
r12 = 3
|
||||
if (r0 == r12) goto L72
|
||||
r12 = 6
|
||||
if (r0 == r12) goto L13
|
||||
goto L4c
|
||||
L13:
|
||||
int r12 = r14.getActionIndex()
|
||||
if (r12 != 0) goto L1b
|
||||
r12 = 1
|
||||
goto L1c
|
||||
L1b:
|
||||
r12 = 0
|
||||
L1c:
|
||||
int r13 = r14.getPointerId(r12)
|
||||
r11.activePointerId = r13
|
||||
float r12 = r14.getY(r12)
|
||||
r13 = 1056964608(0x3f000000, float:0.5)
|
||||
float r12 = r12 + r13
|
||||
int r12 = (int) r12
|
||||
r11.lastMotionY = r12
|
||||
goto L4c
|
||||
L2d:
|
||||
int r0 = r11.activePointerId
|
||||
int r0 = r14.findPointerIndex(r0)
|
||||
if (r0 != r1) goto L36
|
||||
return r3
|
||||
L36:
|
||||
float r0 = r14.getY(r0)
|
||||
int r0 = (int) r0
|
||||
int r1 = r11.lastMotionY
|
||||
int r7 = r1 - r0
|
||||
r11.lastMotionY = r0
|
||||
int r8 = r11.getMaxDragOffset(r13)
|
||||
r9 = 0
|
||||
r4 = r11
|
||||
r5 = r12
|
||||
r6 = r13
|
||||
r4.scroll(r5, r6, r7, r8, r9)
|
||||
L4c:
|
||||
r12 = 0
|
||||
goto L81
|
||||
L4e:
|
||||
android.view.VelocityTracker r0 = r11.velocityTracker
|
||||
if (r0 == 0) goto L72
|
||||
r0.addMovement(r14)
|
||||
android.view.VelocityTracker r0 = r11.velocityTracker
|
||||
r4 = 1000(0x3e8, float:1.401E-42)
|
||||
r0.computeCurrentVelocity(r4)
|
||||
android.view.VelocityTracker r0 = r11.velocityTracker
|
||||
int r4 = r11.activePointerId
|
||||
float r10 = r0.getYVelocity(r4)
|
||||
int r0 = r11.getScrollRangeForDragFling(r13)
|
||||
int r8 = -r0
|
||||
r9 = 0
|
||||
r5 = r11
|
||||
r6 = r12
|
||||
r7 = r13
|
||||
r5.fling(r6, r7, r8, r9, r10)
|
||||
r12 = 1
|
||||
goto L73
|
||||
L72:
|
||||
r12 = 0
|
||||
L73:
|
||||
r11.isBeingDragged = r3
|
||||
r11.activePointerId = r1
|
||||
android.view.VelocityTracker r13 = r11.velocityTracker
|
||||
if (r13 == 0) goto L81
|
||||
r13.recycle()
|
||||
r13 = 0
|
||||
r11.velocityTracker = r13
|
||||
L81:
|
||||
android.view.VelocityTracker r13 = r11.velocityTracker
|
||||
if (r13 == 0) goto L88
|
||||
r13.addMovement(r14)
|
||||
L88:
|
||||
boolean r13 = r11.isBeingDragged
|
||||
if (r13 != 0) goto L90
|
||||
if (r12 == 0) goto L8f
|
||||
goto L90
|
||||
L8f:
|
||||
r2 = 0
|
||||
L90:
|
||||
return r2
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.HeaderBehavior.onTouchEvent(androidx.coordinatorlayout.widget.CoordinatorLayout, android.view.View, android.view.MotionEvent):boolean");
|
||||
}
|
||||
|
||||
int setHeaderTopBottomOffset(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
return setHeaderTopBottomOffset(coordinatorLayout, v, i, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
int setHeaderTopBottomOffset(CoordinatorLayout coordinatorLayout, V v, int i, int i2, int i3) {
|
||||
int clamp;
|
||||
int topAndBottomOffset = getTopAndBottomOffset();
|
||||
if (i2 == 0 || topAndBottomOffset < i2 || topAndBottomOffset > i3 || topAndBottomOffset == (clamp = MathUtils.clamp(i, i2, i3))) {
|
||||
return 0;
|
||||
}
|
||||
setTopAndBottomOffset(clamp);
|
||||
return topAndBottomOffset - clamp;
|
||||
}
|
||||
|
||||
int getTopBottomOffsetForScrollingSibling() {
|
||||
return getTopAndBottomOffset();
|
||||
}
|
||||
|
||||
final int scroll(CoordinatorLayout coordinatorLayout, V v, int i, int i2, int i3) {
|
||||
return setHeaderTopBottomOffset(coordinatorLayout, v, getTopBottomOffsetForScrollingSibling() - i, i2, i3);
|
||||
}
|
||||
|
||||
final boolean fling(CoordinatorLayout coordinatorLayout, V v, int i, int i2, float f) {
|
||||
Runnable runnable = this.flingRunnable;
|
||||
if (runnable != null) {
|
||||
v.removeCallbacks(runnable);
|
||||
this.flingRunnable = null;
|
||||
}
|
||||
if (this.scroller == null) {
|
||||
this.scroller = new OverScroller(v.getContext());
|
||||
}
|
||||
this.scroller.fling(0, getTopAndBottomOffset(), 0, Math.round(f), 0, 0, i, i2);
|
||||
if (this.scroller.computeScrollOffset()) {
|
||||
FlingRunnable flingRunnable = new FlingRunnable(coordinatorLayout, v);
|
||||
this.flingRunnable = flingRunnable;
|
||||
ViewCompat.postOnAnimation(v, flingRunnable);
|
||||
return true;
|
||||
}
|
||||
onFlingFinished(coordinatorLayout, v);
|
||||
return false;
|
||||
}
|
||||
|
||||
int getMaxDragOffset(V v) {
|
||||
return -v.getHeight();
|
||||
}
|
||||
|
||||
int getScrollRangeForDragFling(V v) {
|
||||
return v.getHeight();
|
||||
}
|
||||
|
||||
private void ensureVelocityTracker() {
|
||||
if (this.velocityTracker == null) {
|
||||
this.velocityTracker = VelocityTracker.obtain();
|
||||
}
|
||||
}
|
||||
|
||||
private class FlingRunnable implements Runnable {
|
||||
private final V layout;
|
||||
private final CoordinatorLayout parent;
|
||||
|
||||
FlingRunnable(CoordinatorLayout coordinatorLayout, V v) {
|
||||
this.parent = coordinatorLayout;
|
||||
this.layout = v;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (this.layout == null || HeaderBehavior.this.scroller == null) {
|
||||
return;
|
||||
}
|
||||
if (HeaderBehavior.this.scroller.computeScrollOffset()) {
|
||||
HeaderBehavior headerBehavior = HeaderBehavior.this;
|
||||
headerBehavior.setHeaderTopBottomOffset(this.parent, this.layout, headerBehavior.scroller.getCurrY());
|
||||
ViewCompat.postOnAnimation(this.layout, this);
|
||||
return;
|
||||
}
|
||||
HeaderBehavior.this.onFlingFinished(this.parent, this.layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.math.MathUtils;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class HeaderScrollingViewBehavior extends ViewOffsetBehavior<View> {
|
||||
private int overlayTop;
|
||||
final Rect tempRect1;
|
||||
final Rect tempRect2;
|
||||
private int verticalLayoutGap;
|
||||
|
||||
private static int resolveGravity(int i) {
|
||||
if (i == 0) {
|
||||
return 8388659;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
abstract View findFirstDependency(List<View> list);
|
||||
|
||||
float getOverlapRatioForOffset(View view) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public final int getOverlayTop() {
|
||||
return this.overlayTop;
|
||||
}
|
||||
|
||||
final int getVerticalLayoutGap() {
|
||||
return this.verticalLayoutGap;
|
||||
}
|
||||
|
||||
public final void setOverlayTop(int i) {
|
||||
this.overlayTop = i;
|
||||
}
|
||||
|
||||
protected boolean shouldHeaderOverlapScrollingChild() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public HeaderScrollingViewBehavior() {
|
||||
this.tempRect1 = new Rect();
|
||||
this.tempRect2 = new Rect();
|
||||
this.verticalLayoutGap = 0;
|
||||
}
|
||||
|
||||
public HeaderScrollingViewBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.tempRect1 = new Rect();
|
||||
this.tempRect2 = new Rect();
|
||||
this.verticalLayoutGap = 0;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onMeasureChild(CoordinatorLayout coordinatorLayout, View view, int i, int i2, int i3, int i4) {
|
||||
View findFirstDependency;
|
||||
WindowInsetsCompat lastWindowInsets;
|
||||
int i5 = view.getLayoutParams().height;
|
||||
if ((i5 != -1 && i5 != -2) || (findFirstDependency = findFirstDependency(coordinatorLayout.getDependencies(view))) == null) {
|
||||
return false;
|
||||
}
|
||||
int size = View.MeasureSpec.getSize(i3);
|
||||
if (size > 0) {
|
||||
if (ViewCompat.getFitsSystemWindows(findFirstDependency) && (lastWindowInsets = coordinatorLayout.getLastWindowInsets()) != null) {
|
||||
size += lastWindowInsets.getSystemWindowInsetTop() + lastWindowInsets.getSystemWindowInsetBottom();
|
||||
}
|
||||
} else {
|
||||
size = coordinatorLayout.getHeight();
|
||||
}
|
||||
int scrollRange = size + getScrollRange(findFirstDependency);
|
||||
int measuredHeight = findFirstDependency.getMeasuredHeight();
|
||||
if (shouldHeaderOverlapScrollingChild()) {
|
||||
view.setTranslationY(-measuredHeight);
|
||||
} else {
|
||||
view.setTranslationY(0.0f);
|
||||
scrollRange -= measuredHeight;
|
||||
}
|
||||
coordinatorLayout.onMeasureChild(view, i, i2, View.MeasureSpec.makeMeasureSpec(scrollRange, i5 == -1 ? BasicMeasure.EXACTLY : Integer.MIN_VALUE), i4);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.appbar.ViewOffsetBehavior
|
||||
protected void layoutChild(CoordinatorLayout coordinatorLayout, View view, int i) {
|
||||
View findFirstDependency = findFirstDependency(coordinatorLayout.getDependencies(view));
|
||||
if (findFirstDependency != null) {
|
||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
|
||||
Rect rect = this.tempRect1;
|
||||
rect.set(coordinatorLayout.getPaddingLeft() + layoutParams.leftMargin, findFirstDependency.getBottom() + layoutParams.topMargin, (coordinatorLayout.getWidth() - coordinatorLayout.getPaddingRight()) - layoutParams.rightMargin, ((coordinatorLayout.getHeight() + findFirstDependency.getBottom()) - coordinatorLayout.getPaddingBottom()) - layoutParams.bottomMargin);
|
||||
WindowInsetsCompat lastWindowInsets = coordinatorLayout.getLastWindowInsets();
|
||||
if (lastWindowInsets != null && ViewCompat.getFitsSystemWindows(coordinatorLayout) && !ViewCompat.getFitsSystemWindows(view)) {
|
||||
rect.left += lastWindowInsets.getSystemWindowInsetLeft();
|
||||
rect.right -= lastWindowInsets.getSystemWindowInsetRight();
|
||||
}
|
||||
Rect rect2 = this.tempRect2;
|
||||
GravityCompat.apply(resolveGravity(layoutParams.gravity), view.getMeasuredWidth(), view.getMeasuredHeight(), rect, rect2, i);
|
||||
int overlapPixelsForOffset = getOverlapPixelsForOffset(findFirstDependency);
|
||||
view.layout(rect2.left, rect2.top - overlapPixelsForOffset, rect2.right, rect2.bottom - overlapPixelsForOffset);
|
||||
this.verticalLayoutGap = rect2.top - findFirstDependency.getBottom();
|
||||
return;
|
||||
}
|
||||
super.layoutChild(coordinatorLayout, view, i);
|
||||
this.verticalLayoutGap = 0;
|
||||
}
|
||||
|
||||
final int getOverlapPixelsForOffset(View view) {
|
||||
if (this.overlayTop == 0) {
|
||||
return 0;
|
||||
}
|
||||
float overlapRatioForOffset = getOverlapRatioForOffset(view);
|
||||
int i = this.overlayTop;
|
||||
return MathUtils.clamp((int) (overlapRatioForOffset * i), 0, i);
|
||||
}
|
||||
|
||||
int getScrollRange(View view) {
|
||||
return view.getMeasuredHeight();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.view.menu.MenuBuilder;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.drawable.DrawableUtils;
|
||||
import com.google.android.material.internal.ToolbarUtils;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.MaterialShapeUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MaterialToolbar extends Toolbar {
|
||||
private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_Toolbar;
|
||||
private static final ImageView.ScaleType[] LOGO_SCALE_TYPE_ARRAY = {ImageView.ScaleType.MATRIX, ImageView.ScaleType.FIT_XY, ImageView.ScaleType.FIT_START, ImageView.ScaleType.FIT_CENTER, ImageView.ScaleType.FIT_END, ImageView.ScaleType.CENTER, ImageView.ScaleType.CENTER_CROP, ImageView.ScaleType.CENTER_INSIDE};
|
||||
private Boolean logoAdjustViewBounds;
|
||||
private ImageView.ScaleType logoScaleType;
|
||||
private Integer navigationIconTint;
|
||||
private boolean subtitleCentered;
|
||||
private boolean titleCentered;
|
||||
|
||||
public ImageView.ScaleType getLogoScaleType() {
|
||||
return this.logoScaleType;
|
||||
}
|
||||
|
||||
public Integer getNavigationIconTint() {
|
||||
return this.navigationIconTint;
|
||||
}
|
||||
|
||||
public boolean isSubtitleCentered() {
|
||||
return this.subtitleCentered;
|
||||
}
|
||||
|
||||
public boolean isTitleCentered() {
|
||||
return this.titleCentered;
|
||||
}
|
||||
|
||||
public MaterialToolbar(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MaterialToolbar(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.toolbarStyle);
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public MaterialToolbar(android.content.Context r8, android.util.AttributeSet r9, int r10) {
|
||||
/*
|
||||
r7 = this;
|
||||
int r4 = com.google.android.material.appbar.MaterialToolbar.DEF_STYLE_RES
|
||||
android.content.Context r8 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r8, r9, r10, r4)
|
||||
r7.<init>(r8, r9, r10)
|
||||
android.content.Context r8 = r7.getContext()
|
||||
int[] r2 = com.google.android.material.R.styleable.MaterialToolbar
|
||||
r6 = 0
|
||||
int[] r5 = new int[r6]
|
||||
r0 = r8
|
||||
r1 = r9
|
||||
r3 = r10
|
||||
android.content.res.TypedArray r9 = com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(r0, r1, r2, r3, r4, r5)
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_navigationIconTint
|
||||
boolean r10 = r9.hasValue(r10)
|
||||
r0 = -1
|
||||
if (r10 == 0) goto L2b
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_navigationIconTint
|
||||
int r10 = r9.getColor(r10, r0)
|
||||
r7.setNavigationIconTint(r10)
|
||||
L2b:
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_titleCentered
|
||||
boolean r10 = r9.getBoolean(r10, r6)
|
||||
r7.titleCentered = r10
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_subtitleCentered
|
||||
boolean r10 = r9.getBoolean(r10, r6)
|
||||
r7.subtitleCentered = r10
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_logoScaleType
|
||||
int r10 = r9.getInt(r10, r0)
|
||||
if (r10 < 0) goto L4c
|
||||
android.widget.ImageView$ScaleType[] r0 = com.google.android.material.appbar.MaterialToolbar.LOGO_SCALE_TYPE_ARRAY
|
||||
int r1 = r0.length
|
||||
if (r10 >= r1) goto L4c
|
||||
r10 = r0[r10]
|
||||
r7.logoScaleType = r10
|
||||
L4c:
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_logoAdjustViewBounds
|
||||
boolean r10 = r9.hasValue(r10)
|
||||
if (r10 == 0) goto L60
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_logoAdjustViewBounds
|
||||
boolean r10 = r9.getBoolean(r10, r6)
|
||||
java.lang.Boolean r10 = java.lang.Boolean.valueOf(r10)
|
||||
r7.logoAdjustViewBounds = r10
|
||||
L60:
|
||||
r9.recycle()
|
||||
r7.initBackground(r8)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.MaterialToolbar.<init>(android.content.Context, android.util.AttributeSet, int):void");
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar
|
||||
public void inflateMenu(int i) {
|
||||
Menu menu = getMenu();
|
||||
boolean z = menu instanceof MenuBuilder;
|
||||
if (z) {
|
||||
((MenuBuilder) menu).stopDispatchingItemsChanged();
|
||||
}
|
||||
super.inflateMenu(i);
|
||||
if (z) {
|
||||
((MenuBuilder) menu).startDispatchingItemsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar, 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);
|
||||
maybeCenterTitleViews();
|
||||
updateLogoImageView();
|
||||
}
|
||||
|
||||
private void maybeCenterTitleViews() {
|
||||
if (this.titleCentered || this.subtitleCentered) {
|
||||
TextView titleTextView = ToolbarUtils.getTitleTextView(this);
|
||||
TextView subtitleTextView = ToolbarUtils.getSubtitleTextView(this);
|
||||
if (titleTextView == null && subtitleTextView == null) {
|
||||
return;
|
||||
}
|
||||
Pair<Integer, Integer> calculateTitleBoundLimits = calculateTitleBoundLimits(titleTextView, subtitleTextView);
|
||||
if (this.titleCentered && titleTextView != null) {
|
||||
layoutTitleCenteredHorizontally(titleTextView, calculateTitleBoundLimits);
|
||||
}
|
||||
if (!this.subtitleCentered || subtitleTextView == null) {
|
||||
return;
|
||||
}
|
||||
layoutTitleCenteredHorizontally(subtitleTextView, calculateTitleBoundLimits);
|
||||
}
|
||||
}
|
||||
|
||||
private Pair<Integer, Integer> calculateTitleBoundLimits(TextView textView, TextView textView2) {
|
||||
int measuredWidth = getMeasuredWidth();
|
||||
int i = measuredWidth / 2;
|
||||
int paddingLeft = getPaddingLeft();
|
||||
int paddingRight = measuredWidth - getPaddingRight();
|
||||
for (int i2 = 0; i2 < getChildCount(); i2++) {
|
||||
View childAt = getChildAt(i2);
|
||||
if (childAt.getVisibility() != 8 && childAt != textView && childAt != textView2) {
|
||||
if (childAt.getRight() < i && childAt.getRight() > paddingLeft) {
|
||||
paddingLeft = childAt.getRight();
|
||||
}
|
||||
if (childAt.getLeft() > i && childAt.getLeft() < paddingRight) {
|
||||
paddingRight = childAt.getLeft();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Pair<>(Integer.valueOf(paddingLeft), Integer.valueOf(paddingRight));
|
||||
}
|
||||
|
||||
private void layoutTitleCenteredHorizontally(View view, Pair<Integer, Integer> pair) {
|
||||
int measuredWidth = getMeasuredWidth();
|
||||
int measuredWidth2 = view.getMeasuredWidth();
|
||||
int i = (measuredWidth / 2) - (measuredWidth2 / 2);
|
||||
int i2 = measuredWidth2 + i;
|
||||
int max = Math.max(Math.max(((Integer) pair.first).intValue() - i, 0), Math.max(i2 - ((Integer) pair.second).intValue(), 0));
|
||||
if (max > 0) {
|
||||
i += max;
|
||||
i2 -= max;
|
||||
view.measure(View.MeasureSpec.makeMeasureSpec(i2 - i, BasicMeasure.EXACTLY), view.getMeasuredHeightAndState());
|
||||
}
|
||||
view.layout(i, view.getTop(), i2, view.getBottom());
|
||||
}
|
||||
|
||||
private void updateLogoImageView() {
|
||||
ImageView logoImageView = ToolbarUtils.getLogoImageView(this);
|
||||
if (logoImageView != null) {
|
||||
Boolean bool = this.logoAdjustViewBounds;
|
||||
if (bool != null) {
|
||||
logoImageView.setAdjustViewBounds(bool.booleanValue());
|
||||
}
|
||||
ImageView.ScaleType scaleType = this.logoScaleType;
|
||||
if (scaleType != null) {
|
||||
logoImageView.setScaleType(scaleType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogoScaleType(ImageView.ScaleType scaleType) {
|
||||
if (this.logoScaleType != scaleType) {
|
||||
this.logoScaleType = scaleType;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLogoAdjustViewBounds() {
|
||||
Boolean bool = this.logoAdjustViewBounds;
|
||||
return bool != null && bool.booleanValue();
|
||||
}
|
||||
|
||||
public void setLogoAdjustViewBounds(boolean z) {
|
||||
Boolean bool = this.logoAdjustViewBounds;
|
||||
if (bool == null || bool.booleanValue() != z) {
|
||||
this.logoAdjustViewBounds = Boolean.valueOf(z);
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar, android.view.ViewGroup, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
MaterialShapeUtils.setParentAbsoluteElevation(this);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setElevation(float f) {
|
||||
super.setElevation(f);
|
||||
MaterialShapeUtils.setElevation(this, f);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar
|
||||
public void setNavigationIcon(Drawable drawable) {
|
||||
super.setNavigationIcon(maybeTintNavigationIcon(drawable));
|
||||
}
|
||||
|
||||
public void setNavigationIconTint(int i) {
|
||||
this.navigationIconTint = Integer.valueOf(i);
|
||||
Drawable navigationIcon = getNavigationIcon();
|
||||
if (navigationIcon != null) {
|
||||
setNavigationIcon(navigationIcon);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearNavigationIconTint() {
|
||||
this.navigationIconTint = null;
|
||||
Drawable navigationIcon = getNavigationIcon();
|
||||
if (navigationIcon != null) {
|
||||
DrawableCompat.setTintList(DrawableCompat.wrap(navigationIcon.mutate()), null);
|
||||
setNavigationIcon(navigationIcon);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitleCentered(boolean z) {
|
||||
if (this.titleCentered != z) {
|
||||
this.titleCentered = z;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSubtitleCentered(boolean z) {
|
||||
if (this.subtitleCentered != z) {
|
||||
this.subtitleCentered = z;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private void initBackground(Context context) {
|
||||
ColorStateList colorStateListOrNull;
|
||||
Drawable background = getBackground();
|
||||
if (background == null) {
|
||||
colorStateListOrNull = ColorStateList.valueOf(0);
|
||||
} else {
|
||||
colorStateListOrNull = DrawableUtils.getColorStateListOrNull(background);
|
||||
}
|
||||
if (colorStateListOrNull != null) {
|
||||
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable();
|
||||
materialShapeDrawable.setFillColor(colorStateListOrNull);
|
||||
materialShapeDrawable.initializeElevationOverlay(context);
|
||||
materialShapeDrawable.setElevation(ViewCompat.getElevation(this));
|
||||
ViewCompat.setBackground(this, materialShapeDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
private Drawable maybeTintNavigationIcon(Drawable drawable) {
|
||||
if (drawable == null || this.navigationIconTint == null) {
|
||||
return drawable;
|
||||
}
|
||||
Drawable wrap = DrawableCompat.wrap(drawable.mutate());
|
||||
DrawableCompat.setTint(wrap, this.navigationIconTint.intValue());
|
||||
return wrap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ViewOffsetBehavior<V extends View> extends CoordinatorLayout.Behavior<V> {
|
||||
private int tempLeftRightOffset;
|
||||
private int tempTopBottomOffset;
|
||||
private ViewOffsetHelper viewOffsetHelper;
|
||||
|
||||
public ViewOffsetBehavior() {
|
||||
this.tempTopBottomOffset = 0;
|
||||
this.tempLeftRightOffset = 0;
|
||||
}
|
||||
|
||||
public ViewOffsetBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.tempTopBottomOffset = 0;
|
||||
this.tempLeftRightOffset = 0;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onLayoutChild(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
layoutChild(coordinatorLayout, v, i);
|
||||
if (this.viewOffsetHelper == null) {
|
||||
this.viewOffsetHelper = new ViewOffsetHelper(v);
|
||||
}
|
||||
this.viewOffsetHelper.onViewLayout();
|
||||
this.viewOffsetHelper.applyOffsets();
|
||||
int i2 = this.tempTopBottomOffset;
|
||||
if (i2 != 0) {
|
||||
this.viewOffsetHelper.setTopAndBottomOffset(i2);
|
||||
this.tempTopBottomOffset = 0;
|
||||
}
|
||||
int i3 = this.tempLeftRightOffset;
|
||||
if (i3 == 0) {
|
||||
return true;
|
||||
}
|
||||
this.viewOffsetHelper.setLeftAndRightOffset(i3);
|
||||
this.tempLeftRightOffset = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void layoutChild(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
coordinatorLayout.onLayoutChild(v, i);
|
||||
}
|
||||
|
||||
public boolean setTopAndBottomOffset(int i) {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.setTopAndBottomOffset(i);
|
||||
}
|
||||
this.tempTopBottomOffset = i;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setLeftAndRightOffset(int i) {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.setLeftAndRightOffset(i);
|
||||
}
|
||||
this.tempLeftRightOffset = i;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTopAndBottomOffset() {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.getTopAndBottomOffset();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getLeftAndRightOffset() {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.getLeftAndRightOffset();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setVerticalOffsetEnabled(boolean z) {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
viewOffsetHelper.setVerticalOffsetEnabled(z);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVerticalOffsetEnabled() {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
return viewOffsetHelper != null && viewOffsetHelper.isVerticalOffsetEnabled();
|
||||
}
|
||||
|
||||
public void setHorizontalOffsetEnabled(boolean z) {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
viewOffsetHelper.setHorizontalOffsetEnabled(z);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHorizontalOffsetEnabled() {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
return viewOffsetHelper != null && viewOffsetHelper.isHorizontalOffsetEnabled();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ViewOffsetHelper {
|
||||
private int layoutLeft;
|
||||
private int layoutTop;
|
||||
private int offsetLeft;
|
||||
private int offsetTop;
|
||||
private final View view;
|
||||
private boolean verticalOffsetEnabled = true;
|
||||
private boolean horizontalOffsetEnabled = true;
|
||||
|
||||
public int getLayoutLeft() {
|
||||
return this.layoutLeft;
|
||||
}
|
||||
|
||||
public int getLayoutTop() {
|
||||
return this.layoutTop;
|
||||
}
|
||||
|
||||
public int getLeftAndRightOffset() {
|
||||
return this.offsetLeft;
|
||||
}
|
||||
|
||||
public int getTopAndBottomOffset() {
|
||||
return this.offsetTop;
|
||||
}
|
||||
|
||||
public boolean isHorizontalOffsetEnabled() {
|
||||
return this.horizontalOffsetEnabled;
|
||||
}
|
||||
|
||||
public boolean isVerticalOffsetEnabled() {
|
||||
return this.verticalOffsetEnabled;
|
||||
}
|
||||
|
||||
public void setHorizontalOffsetEnabled(boolean z) {
|
||||
this.horizontalOffsetEnabled = z;
|
||||
}
|
||||
|
||||
public void setVerticalOffsetEnabled(boolean z) {
|
||||
this.verticalOffsetEnabled = z;
|
||||
}
|
||||
|
||||
public ViewOffsetHelper(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
void onViewLayout() {
|
||||
this.layoutTop = this.view.getTop();
|
||||
this.layoutLeft = this.view.getLeft();
|
||||
}
|
||||
|
||||
void applyOffsets() {
|
||||
View view = this.view;
|
||||
ViewCompat.offsetTopAndBottom(view, this.offsetTop - (view.getTop() - this.layoutTop));
|
||||
View view2 = this.view;
|
||||
ViewCompat.offsetLeftAndRight(view2, this.offsetLeft - (view2.getLeft() - this.layoutLeft));
|
||||
}
|
||||
|
||||
public boolean setTopAndBottomOffset(int i) {
|
||||
if (!this.verticalOffsetEnabled || this.offsetTop == i) {
|
||||
return false;
|
||||
}
|
||||
this.offsetTop = i;
|
||||
applyOffsets();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setLeftAndRightOffset(int i) {
|
||||
if (!this.horizontalOffsetEnabled || this.offsetLeft == i) {
|
||||
return false;
|
||||
}
|
||||
this.offsetLeft = i;
|
||||
applyOffsets();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.R;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.StateListAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ViewUtilsLollipop {
|
||||
private static final int[] STATE_LIST_ANIM_ATTRS = {R.attr.stateListAnimator};
|
||||
|
||||
ViewUtilsLollipop() {
|
||||
}
|
||||
|
||||
static void setBoundsViewOutlineProvider(View view) {
|
||||
view.setOutlineProvider(ViewOutlineProvider.BOUNDS);
|
||||
}
|
||||
|
||||
static void setStateListAnimatorFromAttrs(View view, AttributeSet attributeSet, int i, int i2) {
|
||||
Context context = view.getContext();
|
||||
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, attributeSet, STATE_LIST_ANIM_ATTRS, i, i2, new int[0]);
|
||||
try {
|
||||
if (obtainStyledAttributes.hasValue(0)) {
|
||||
view.setStateListAnimator(AnimatorInflater.loadStateListAnimator(context, obtainStyledAttributes.getResourceId(0, 0)));
|
||||
}
|
||||
} finally {
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
static void setDefaultAppBarLayoutStateListAnimator(View view, float f) {
|
||||
int integer = view.getResources().getInteger(com.google.android.material.R.integer.app_bar_elevation_anim_duration);
|
||||
StateListAnimator stateListAnimator = new StateListAnimator();
|
||||
long j = integer;
|
||||
stateListAnimator.addState(new int[]{R.attr.state_enabled, com.google.android.material.R.attr.state_liftable, -com.google.android.material.R.attr.state_lifted}, ObjectAnimator.ofFloat(view, "elevation", 0.0f).setDuration(j));
|
||||
stateListAnimator.addState(new int[]{R.attr.state_enabled}, ObjectAnimator.ofFloat(view, "elevation", f).setDuration(j));
|
||||
stateListAnimator.addState(new int[0], ObjectAnimator.ofFloat(view, "elevation", 0.0f).setDuration(0L));
|
||||
view.setStateListAnimator(stateListAnimator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,882 @@
|
||||
package com.google.android.material.badge;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.badge.BadgeState;
|
||||
import com.google.android.material.internal.TextDrawableHelper;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
import com.google.android.material.resources.TextAppearance;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BadgeDrawable extends Drawable implements TextDrawableHelper.TextDrawableDelegate {
|
||||
public static final int BADGE_CONTENT_NOT_TRUNCATED = -2;
|
||||
static final int BADGE_RADIUS_NOT_SPECIFIED = -1;
|
||||
|
||||
@Deprecated
|
||||
public static final int BOTTOM_END = 8388693;
|
||||
|
||||
@Deprecated
|
||||
public static final int BOTTOM_START = 8388691;
|
||||
static final String DEFAULT_EXCEED_MAX_BADGE_NUMBER_SUFFIX = "+";
|
||||
static final String DEFAULT_EXCEED_MAX_BADGE_TEXT_SUFFIX = "…";
|
||||
private static final int DEFAULT_STYLE = R.style.Widget_MaterialComponents_Badge;
|
||||
private static final int DEFAULT_THEME_ATTR = R.attr.badgeStyle;
|
||||
private static final float FONT_SCALE_THRESHOLD = 0.3f;
|
||||
static final int OFFSET_ALIGNMENT_MODE_EDGE = 0;
|
||||
static final int OFFSET_ALIGNMENT_MODE_LEGACY = 1;
|
||||
private static final String TAG = "Badge";
|
||||
public static final int TOP_END = 8388661;
|
||||
public static final int TOP_START = 8388659;
|
||||
private WeakReference<View> anchorViewRef;
|
||||
private final Rect badgeBounds;
|
||||
private float badgeCenterX;
|
||||
private float badgeCenterY;
|
||||
private final WeakReference<Context> contextRef;
|
||||
private float cornerRadius;
|
||||
private WeakReference<FrameLayout> customBadgeParentRef;
|
||||
private float halfBadgeHeight;
|
||||
private float halfBadgeWidth;
|
||||
private int maxBadgeNumber;
|
||||
private final MaterialShapeDrawable shapeDrawable;
|
||||
private final BadgeState state;
|
||||
private final TextDrawableHelper textDrawableHelper;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface BadgeGravity {
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getOpacity() {
|
||||
return -3;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean isStateful() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setColorFilter(ColorFilter colorFilter) {
|
||||
}
|
||||
|
||||
BadgeState.State getSavedState() {
|
||||
return this.state.getOverridingState();
|
||||
}
|
||||
|
||||
static BadgeDrawable createFromSavedState(Context context, BadgeState.State state) {
|
||||
return new BadgeDrawable(context, 0, DEFAULT_THEME_ATTR, DEFAULT_STYLE, state);
|
||||
}
|
||||
|
||||
public static BadgeDrawable create(Context context) {
|
||||
return new BadgeDrawable(context, 0, DEFAULT_THEME_ATTR, DEFAULT_STYLE, null);
|
||||
}
|
||||
|
||||
public static BadgeDrawable createFromResource(Context context, int i) {
|
||||
return new BadgeDrawable(context, i, DEFAULT_THEME_ATTR, DEFAULT_STYLE, null);
|
||||
}
|
||||
|
||||
public void setVisible(boolean z) {
|
||||
this.state.setVisible(z);
|
||||
onVisibilityUpdated();
|
||||
}
|
||||
|
||||
private void onVisibilityUpdated() {
|
||||
boolean isVisible = this.state.isVisible();
|
||||
setVisible(isVisible, false);
|
||||
if (!BadgeUtils.USE_COMPAT_PARENT || getCustomBadgeParent() == null || isVisible) {
|
||||
return;
|
||||
}
|
||||
((ViewGroup) getCustomBadgeParent().getParent()).invalidate();
|
||||
}
|
||||
|
||||
private void restoreState() {
|
||||
onBadgeShapeAppearanceUpdated();
|
||||
onBadgeTextAppearanceUpdated();
|
||||
onMaxBadgeLengthUpdated();
|
||||
onBadgeContentUpdated();
|
||||
onAlphaUpdated();
|
||||
onBackgroundColorUpdated();
|
||||
onBadgeTextColorUpdated();
|
||||
onBadgeGravityUpdated();
|
||||
updateCenterAndBounds();
|
||||
onVisibilityUpdated();
|
||||
}
|
||||
|
||||
private BadgeDrawable(Context context, int i, int i2, int i3, BadgeState.State state) {
|
||||
int badgeShapeAppearanceResId;
|
||||
int badgeShapeAppearanceOverlayResId;
|
||||
this.contextRef = new WeakReference<>(context);
|
||||
ThemeEnforcement.checkMaterialTheme(context);
|
||||
this.badgeBounds = new Rect();
|
||||
TextDrawableHelper textDrawableHelper = new TextDrawableHelper(this);
|
||||
this.textDrawableHelper = textDrawableHelper;
|
||||
textDrawableHelper.getTextPaint().setTextAlign(Paint.Align.CENTER);
|
||||
BadgeState badgeState = new BadgeState(context, i, i2, i3, state);
|
||||
this.state = badgeState;
|
||||
if (hasBadgeContent()) {
|
||||
badgeShapeAppearanceResId = badgeState.getBadgeWithTextShapeAppearanceResId();
|
||||
} else {
|
||||
badgeShapeAppearanceResId = badgeState.getBadgeShapeAppearanceResId();
|
||||
}
|
||||
if (hasBadgeContent()) {
|
||||
badgeShapeAppearanceOverlayResId = badgeState.getBadgeWithTextShapeAppearanceOverlayResId();
|
||||
} else {
|
||||
badgeShapeAppearanceOverlayResId = badgeState.getBadgeShapeAppearanceOverlayResId();
|
||||
}
|
||||
this.shapeDrawable = new MaterialShapeDrawable(ShapeAppearanceModel.builder(context, badgeShapeAppearanceResId, badgeShapeAppearanceOverlayResId).build());
|
||||
restoreState();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void updateBadgeCoordinates(View view, ViewGroup viewGroup) {
|
||||
if (!(viewGroup instanceof FrameLayout)) {
|
||||
throw new IllegalArgumentException("customBadgeParent must be a FrameLayout");
|
||||
}
|
||||
updateBadgeCoordinates(view, (FrameLayout) viewGroup);
|
||||
}
|
||||
|
||||
public void updateBadgeCoordinates(View view) {
|
||||
updateBadgeCoordinates(view, (FrameLayout) null);
|
||||
}
|
||||
|
||||
public void updateBadgeCoordinates(View view, FrameLayout frameLayout) {
|
||||
this.anchorViewRef = new WeakReference<>(view);
|
||||
if (BadgeUtils.USE_COMPAT_PARENT && frameLayout == null) {
|
||||
tryWrapAnchorInCompatParent(view);
|
||||
} else {
|
||||
this.customBadgeParentRef = new WeakReference<>(frameLayout);
|
||||
}
|
||||
if (!BadgeUtils.USE_COMPAT_PARENT) {
|
||||
updateAnchorParentToNotClip(view);
|
||||
}
|
||||
updateCenterAndBounds();
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
private boolean isAnchorViewWrappedInCompatParent() {
|
||||
FrameLayout customBadgeParent = getCustomBadgeParent();
|
||||
return customBadgeParent != null && customBadgeParent.getId() == R.id.mtrl_anchor_parent;
|
||||
}
|
||||
|
||||
public FrameLayout getCustomBadgeParent() {
|
||||
WeakReference<FrameLayout> weakReference = this.customBadgeParentRef;
|
||||
if (weakReference != null) {
|
||||
return weakReference.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void tryWrapAnchorInCompatParent(final View view) {
|
||||
ViewGroup viewGroup = (ViewGroup) view.getParent();
|
||||
if (viewGroup == null || viewGroup.getId() != R.id.mtrl_anchor_parent) {
|
||||
WeakReference<FrameLayout> weakReference = this.customBadgeParentRef;
|
||||
if (weakReference == null || weakReference.get() != viewGroup) {
|
||||
updateAnchorParentToNotClip(view);
|
||||
final FrameLayout frameLayout = new FrameLayout(view.getContext());
|
||||
frameLayout.setId(R.id.mtrl_anchor_parent);
|
||||
frameLayout.setClipChildren(false);
|
||||
frameLayout.setClipToPadding(false);
|
||||
frameLayout.setLayoutParams(view.getLayoutParams());
|
||||
frameLayout.setMinimumWidth(view.getWidth());
|
||||
frameLayout.setMinimumHeight(view.getHeight());
|
||||
int indexOfChild = viewGroup.indexOfChild(view);
|
||||
viewGroup.removeViewAt(indexOfChild);
|
||||
view.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
|
||||
frameLayout.addView(view);
|
||||
viewGroup.addView(frameLayout, indexOfChild);
|
||||
this.customBadgeParentRef = new WeakReference<>(frameLayout);
|
||||
frameLayout.post(new Runnable() { // from class: com.google.android.material.badge.BadgeDrawable.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
BadgeDrawable.this.updateBadgeCoordinates(view, frameLayout);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateAnchorParentToNotClip(View view) {
|
||||
ViewGroup viewGroup = (ViewGroup) view.getParent();
|
||||
viewGroup.setClipChildren(false);
|
||||
viewGroup.setClipToPadding(false);
|
||||
}
|
||||
|
||||
public int getBackgroundColor() {
|
||||
return this.shapeDrawable.getFillColor().getDefaultColor();
|
||||
}
|
||||
|
||||
public void setBackgroundColor(int i) {
|
||||
this.state.setBackgroundColor(i);
|
||||
onBackgroundColorUpdated();
|
||||
}
|
||||
|
||||
private void onBackgroundColorUpdated() {
|
||||
ColorStateList valueOf = ColorStateList.valueOf(this.state.getBackgroundColor());
|
||||
if (this.shapeDrawable.getFillColor() != valueOf) {
|
||||
this.shapeDrawable.setFillColor(valueOf);
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
public int getBadgeTextColor() {
|
||||
return this.textDrawableHelper.getTextPaint().getColor();
|
||||
}
|
||||
|
||||
public void setBadgeTextColor(int i) {
|
||||
if (this.textDrawableHelper.getTextPaint().getColor() != i) {
|
||||
this.state.setBadgeTextColor(i);
|
||||
onBadgeTextColorUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
private void onBadgeTextColorUpdated() {
|
||||
this.textDrawableHelper.getTextPaint().setColor(this.state.getBadgeTextColor());
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public Locale getBadgeNumberLocale() {
|
||||
return this.state.getNumberLocale();
|
||||
}
|
||||
|
||||
public void setBadgeNumberLocale(Locale locale) {
|
||||
if (locale.equals(this.state.getNumberLocale())) {
|
||||
return;
|
||||
}
|
||||
this.state.setNumberLocale(locale);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public boolean hasNumber() {
|
||||
return !this.state.hasText() && this.state.hasNumber();
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
if (this.state.hasNumber()) {
|
||||
return this.state.getNumber();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setNumber(int i) {
|
||||
int max = Math.max(0, i);
|
||||
if (this.state.getNumber() != max) {
|
||||
this.state.setNumber(max);
|
||||
onNumberUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearNumber() {
|
||||
if (this.state.hasNumber()) {
|
||||
this.state.clearNumber();
|
||||
onNumberUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
private void onNumberUpdated() {
|
||||
if (hasText()) {
|
||||
return;
|
||||
}
|
||||
onBadgeContentUpdated();
|
||||
}
|
||||
|
||||
public boolean hasText() {
|
||||
return this.state.hasText();
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.state.getText();
|
||||
}
|
||||
|
||||
public void setText(String str) {
|
||||
if (TextUtils.equals(this.state.getText(), str)) {
|
||||
return;
|
||||
}
|
||||
this.state.setText(str);
|
||||
onTextUpdated();
|
||||
}
|
||||
|
||||
public void clearText() {
|
||||
if (this.state.hasText()) {
|
||||
this.state.clearText();
|
||||
onTextUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
private void onTextUpdated() {
|
||||
onBadgeContentUpdated();
|
||||
}
|
||||
|
||||
public int getMaxCharacterCount() {
|
||||
return this.state.getMaxCharacterCount();
|
||||
}
|
||||
|
||||
public void setMaxCharacterCount(int i) {
|
||||
if (this.state.getMaxCharacterCount() != i) {
|
||||
this.state.setMaxCharacterCount(i);
|
||||
onMaxBadgeLengthUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxNumber() {
|
||||
return this.state.getMaxNumber();
|
||||
}
|
||||
|
||||
public void setMaxNumber(int i) {
|
||||
if (this.state.getMaxNumber() != i) {
|
||||
this.state.setMaxNumber(i);
|
||||
onMaxBadgeLengthUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
private void onMaxBadgeLengthUpdated() {
|
||||
updateMaxBadgeNumber();
|
||||
this.textDrawableHelper.setTextSizeDirty(true);
|
||||
updateCenterAndBounds();
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public int getBadgeGravity() {
|
||||
return this.state.getBadgeGravity();
|
||||
}
|
||||
|
||||
public void setBadgeGravity(int i) {
|
||||
if (i == 8388691 || i == 8388693) {
|
||||
Log.w(TAG, "Bottom badge gravities are deprecated; please use a top gravity instead.");
|
||||
}
|
||||
if (this.state.getBadgeGravity() != i) {
|
||||
this.state.setBadgeGravity(i);
|
||||
onBadgeGravityUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
private void onBadgeGravityUpdated() {
|
||||
WeakReference<View> weakReference = this.anchorViewRef;
|
||||
if (weakReference == null || weakReference.get() == null) {
|
||||
return;
|
||||
}
|
||||
View view = this.anchorViewRef.get();
|
||||
WeakReference<FrameLayout> weakReference2 = this.customBadgeParentRef;
|
||||
updateBadgeCoordinates(view, weakReference2 != null ? weakReference2.get() : null);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getAlpha() {
|
||||
return this.state.getAlpha();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setAlpha(int i) {
|
||||
this.state.setAlpha(i);
|
||||
onAlphaUpdated();
|
||||
}
|
||||
|
||||
private void onAlphaUpdated() {
|
||||
this.textDrawableHelper.getTextPaint().setAlpha(getAlpha());
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicHeight() {
|
||||
return this.badgeBounds.height();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicWidth() {
|
||||
return this.badgeBounds.width();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void draw(Canvas canvas) {
|
||||
if (getBounds().isEmpty() || getAlpha() == 0 || !isVisible()) {
|
||||
return;
|
||||
}
|
||||
this.shapeDrawable.draw(canvas);
|
||||
if (hasBadgeContent()) {
|
||||
drawBadgeContent(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.internal.TextDrawableHelper.TextDrawableDelegate
|
||||
public void onTextSizeChange() {
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable, com.google.android.material.internal.TextDrawableHelper.TextDrawableDelegate
|
||||
public boolean onStateChange(int[] iArr) {
|
||||
return super.onStateChange(iArr);
|
||||
}
|
||||
|
||||
public void setContentDescriptionForText(CharSequence charSequence) {
|
||||
this.state.setContentDescriptionForText(charSequence);
|
||||
}
|
||||
|
||||
public void setContentDescriptionNumberless(CharSequence charSequence) {
|
||||
this.state.setContentDescriptionNumberless(charSequence);
|
||||
}
|
||||
|
||||
public void setContentDescriptionQuantityStringsResource(int i) {
|
||||
this.state.setContentDescriptionQuantityStringsResource(i);
|
||||
}
|
||||
|
||||
public void setContentDescriptionExceedsMaxBadgeNumberStringResource(int i) {
|
||||
this.state.setContentDescriptionExceedsMaxBadgeNumberStringResource(i);
|
||||
}
|
||||
|
||||
public CharSequence getContentDescription() {
|
||||
if (!isVisible()) {
|
||||
return null;
|
||||
}
|
||||
if (hasText()) {
|
||||
return getTextContentDescription();
|
||||
}
|
||||
if (hasNumber()) {
|
||||
return getNumberContentDescription();
|
||||
}
|
||||
return getEmptyContentDescription();
|
||||
}
|
||||
|
||||
private String getNumberContentDescription() {
|
||||
Context context;
|
||||
if (this.state.getContentDescriptionQuantityStrings() == 0 || (context = this.contextRef.get()) == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.maxBadgeNumber == -2 || getNumber() <= this.maxBadgeNumber) {
|
||||
return context.getResources().getQuantityString(this.state.getContentDescriptionQuantityStrings(), getNumber(), Integer.valueOf(getNumber()));
|
||||
}
|
||||
return context.getString(this.state.getContentDescriptionExceedsMaxBadgeNumberStringResource(), Integer.valueOf(this.maxBadgeNumber));
|
||||
}
|
||||
|
||||
private CharSequence getTextContentDescription() {
|
||||
CharSequence contentDescriptionForText = this.state.getContentDescriptionForText();
|
||||
return contentDescriptionForText != null ? contentDescriptionForText : getText();
|
||||
}
|
||||
|
||||
private CharSequence getEmptyContentDescription() {
|
||||
return this.state.getContentDescriptionNumberless();
|
||||
}
|
||||
|
||||
public void setHorizontalPadding(int i) {
|
||||
if (i != this.state.getBadgeHorizontalPadding()) {
|
||||
this.state.setBadgeHorizontalPadding(i);
|
||||
updateCenterAndBounds();
|
||||
}
|
||||
}
|
||||
|
||||
public int getHorizontalPadding() {
|
||||
return this.state.getBadgeHorizontalPadding();
|
||||
}
|
||||
|
||||
public void setVerticalPadding(int i) {
|
||||
if (i != this.state.getBadgeVerticalPadding()) {
|
||||
this.state.setBadgeVerticalPadding(i);
|
||||
updateCenterAndBounds();
|
||||
}
|
||||
}
|
||||
|
||||
public int getVerticalPadding() {
|
||||
return this.state.getBadgeVerticalPadding();
|
||||
}
|
||||
|
||||
public void setHorizontalOffset(int i) {
|
||||
setHorizontalOffsetWithoutText(i);
|
||||
setHorizontalOffsetWithText(i);
|
||||
}
|
||||
|
||||
public int getHorizontalOffset() {
|
||||
return this.state.getHorizontalOffsetWithoutText();
|
||||
}
|
||||
|
||||
public void setHorizontalOffsetWithoutText(int i) {
|
||||
this.state.setHorizontalOffsetWithoutText(i);
|
||||
updateCenterAndBounds();
|
||||
}
|
||||
|
||||
public int getHorizontalOffsetWithoutText() {
|
||||
return this.state.getHorizontalOffsetWithoutText();
|
||||
}
|
||||
|
||||
public void setHorizontalOffsetWithText(int i) {
|
||||
this.state.setHorizontalOffsetWithText(i);
|
||||
updateCenterAndBounds();
|
||||
}
|
||||
|
||||
public int getHorizontalOffsetWithText() {
|
||||
return this.state.getHorizontalOffsetWithText();
|
||||
}
|
||||
|
||||
void setAdditionalHorizontalOffset(int i) {
|
||||
this.state.setAdditionalHorizontalOffset(i);
|
||||
updateCenterAndBounds();
|
||||
}
|
||||
|
||||
int getAdditionalHorizontalOffset() {
|
||||
return this.state.getAdditionalHorizontalOffset();
|
||||
}
|
||||
|
||||
public void setVerticalOffset(int i) {
|
||||
setVerticalOffsetWithoutText(i);
|
||||
setVerticalOffsetWithText(i);
|
||||
}
|
||||
|
||||
public int getVerticalOffset() {
|
||||
return this.state.getVerticalOffsetWithoutText();
|
||||
}
|
||||
|
||||
public void setVerticalOffsetWithoutText(int i) {
|
||||
this.state.setVerticalOffsetWithoutText(i);
|
||||
updateCenterAndBounds();
|
||||
}
|
||||
|
||||
public int getVerticalOffsetWithoutText() {
|
||||
return this.state.getVerticalOffsetWithoutText();
|
||||
}
|
||||
|
||||
public void setVerticalOffsetWithText(int i) {
|
||||
this.state.setVerticalOffsetWithText(i);
|
||||
updateCenterAndBounds();
|
||||
}
|
||||
|
||||
public int getVerticalOffsetWithText() {
|
||||
return this.state.getVerticalOffsetWithText();
|
||||
}
|
||||
|
||||
public void setLargeFontVerticalOffsetAdjustment(int i) {
|
||||
this.state.setLargeFontVerticalOffsetAdjustment(i);
|
||||
updateCenterAndBounds();
|
||||
}
|
||||
|
||||
public int getLargeFontVerticalOffsetAdjustment() {
|
||||
return this.state.getLargeFontVerticalOffsetAdjustment();
|
||||
}
|
||||
|
||||
void setAdditionalVerticalOffset(int i) {
|
||||
this.state.setAdditionalVerticalOffset(i);
|
||||
updateCenterAndBounds();
|
||||
}
|
||||
|
||||
int getAdditionalVerticalOffset() {
|
||||
return this.state.getAdditionalVerticalOffset();
|
||||
}
|
||||
|
||||
public void setAutoAdjustToWithinGrandparentBounds(boolean z) {
|
||||
if (this.state.isAutoAdjustedToGrandparentBounds() == z) {
|
||||
return;
|
||||
}
|
||||
this.state.setAutoAdjustToGrandparentBounds(z);
|
||||
WeakReference<View> weakReference = this.anchorViewRef;
|
||||
if (weakReference == null || weakReference.get() == null) {
|
||||
return;
|
||||
}
|
||||
autoAdjustWithinGrandparentBounds(this.anchorViewRef.get());
|
||||
}
|
||||
|
||||
public void setTextAppearance(int i) {
|
||||
this.state.setTextAppearanceResId(i);
|
||||
onBadgeTextAppearanceUpdated();
|
||||
}
|
||||
|
||||
private void onBadgeTextAppearanceUpdated() {
|
||||
TextAppearance textAppearance;
|
||||
Context context = this.contextRef.get();
|
||||
if (context == null || this.textDrawableHelper.getTextAppearance() == (textAppearance = new TextAppearance(context, this.state.getTextAppearanceResId()))) {
|
||||
return;
|
||||
}
|
||||
this.textDrawableHelper.setTextAppearance(textAppearance, context);
|
||||
onBadgeTextColorUpdated();
|
||||
updateCenterAndBounds();
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public void setBadgeWithoutTextShapeAppearance(int i) {
|
||||
this.state.setBadgeShapeAppearanceResId(i);
|
||||
onBadgeShapeAppearanceUpdated();
|
||||
}
|
||||
|
||||
public void setBadgeWithoutTextShapeAppearanceOverlay(int i) {
|
||||
this.state.setBadgeShapeAppearanceOverlayResId(i);
|
||||
onBadgeShapeAppearanceUpdated();
|
||||
}
|
||||
|
||||
public void setBadgeWithTextShapeAppearance(int i) {
|
||||
this.state.setBadgeWithTextShapeAppearanceResId(i);
|
||||
onBadgeShapeAppearanceUpdated();
|
||||
}
|
||||
|
||||
public void setBadgeWithTextShapeAppearanceOverlay(int i) {
|
||||
this.state.setBadgeWithTextShapeAppearanceOverlayResId(i);
|
||||
onBadgeShapeAppearanceUpdated();
|
||||
}
|
||||
|
||||
private void onBadgeShapeAppearanceUpdated() {
|
||||
int badgeShapeAppearanceResId;
|
||||
int badgeShapeAppearanceOverlayResId;
|
||||
Context context = this.contextRef.get();
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
MaterialShapeDrawable materialShapeDrawable = this.shapeDrawable;
|
||||
if (hasBadgeContent()) {
|
||||
badgeShapeAppearanceResId = this.state.getBadgeWithTextShapeAppearanceResId();
|
||||
} else {
|
||||
badgeShapeAppearanceResId = this.state.getBadgeShapeAppearanceResId();
|
||||
}
|
||||
if (hasBadgeContent()) {
|
||||
badgeShapeAppearanceOverlayResId = this.state.getBadgeWithTextShapeAppearanceOverlayResId();
|
||||
} else {
|
||||
badgeShapeAppearanceOverlayResId = this.state.getBadgeShapeAppearanceOverlayResId();
|
||||
}
|
||||
materialShapeDrawable.setShapeAppearanceModel(ShapeAppearanceModel.builder(context, badgeShapeAppearanceResId, badgeShapeAppearanceOverlayResId).build());
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
private void updateCenterAndBounds() {
|
||||
Context context = this.contextRef.get();
|
||||
WeakReference<View> weakReference = this.anchorViewRef;
|
||||
View view = weakReference != null ? weakReference.get() : null;
|
||||
if (context == null || view == null) {
|
||||
return;
|
||||
}
|
||||
Rect rect = new Rect();
|
||||
rect.set(this.badgeBounds);
|
||||
Rect rect2 = new Rect();
|
||||
view.getDrawingRect(rect2);
|
||||
WeakReference<FrameLayout> weakReference2 = this.customBadgeParentRef;
|
||||
FrameLayout frameLayout = weakReference2 != null ? weakReference2.get() : null;
|
||||
if (frameLayout != null || BadgeUtils.USE_COMPAT_PARENT) {
|
||||
if (frameLayout == null) {
|
||||
frameLayout = (ViewGroup) view.getParent();
|
||||
}
|
||||
frameLayout.offsetDescendantRectToMyCoords(view, rect2);
|
||||
}
|
||||
calculateCenterAndBounds(rect2, view);
|
||||
BadgeUtils.updateBadgeBounds(this.badgeBounds, this.badgeCenterX, this.badgeCenterY, this.halfBadgeWidth, this.halfBadgeHeight);
|
||||
float f = this.cornerRadius;
|
||||
if (f != -1.0f) {
|
||||
this.shapeDrawable.setCornerSize(f);
|
||||
}
|
||||
if (rect.equals(this.badgeBounds)) {
|
||||
return;
|
||||
}
|
||||
this.shapeDrawable.setBounds(this.badgeBounds);
|
||||
}
|
||||
|
||||
private int getTotalVerticalOffsetForState() {
|
||||
int verticalOffsetWithoutText = this.state.getVerticalOffsetWithoutText();
|
||||
if (hasBadgeContent()) {
|
||||
verticalOffsetWithoutText = this.state.getVerticalOffsetWithText();
|
||||
Context context = this.contextRef.get();
|
||||
if (context != null) {
|
||||
verticalOffsetWithoutText = AnimationUtils.lerp(verticalOffsetWithoutText, verticalOffsetWithoutText - this.state.getLargeFontVerticalOffsetAdjustment(), AnimationUtils.lerp(0.0f, 1.0f, FONT_SCALE_THRESHOLD, 1.0f, MaterialResources.getFontScale(context) - 1.0f));
|
||||
}
|
||||
}
|
||||
if (this.state.offsetAlignmentMode == 0) {
|
||||
verticalOffsetWithoutText -= Math.round(this.halfBadgeHeight);
|
||||
}
|
||||
return verticalOffsetWithoutText + this.state.getAdditionalVerticalOffset();
|
||||
}
|
||||
|
||||
private int getTotalHorizontalOffsetForState() {
|
||||
int horizontalOffsetWithoutText;
|
||||
if (hasBadgeContent()) {
|
||||
horizontalOffsetWithoutText = this.state.getHorizontalOffsetWithText();
|
||||
} else {
|
||||
horizontalOffsetWithoutText = this.state.getHorizontalOffsetWithoutText();
|
||||
}
|
||||
if (this.state.offsetAlignmentMode == 1) {
|
||||
horizontalOffsetWithoutText += hasBadgeContent() ? this.state.horizontalInsetWithText : this.state.horizontalInset;
|
||||
}
|
||||
return horizontalOffsetWithoutText + this.state.getAdditionalHorizontalOffset();
|
||||
}
|
||||
|
||||
private void calculateCenterAndBounds(Rect rect, View view) {
|
||||
float f;
|
||||
float f2;
|
||||
float f3 = hasBadgeContent() ? this.state.badgeWithTextRadius : this.state.badgeRadius;
|
||||
this.cornerRadius = f3;
|
||||
if (f3 != -1.0f) {
|
||||
this.halfBadgeWidth = f3;
|
||||
this.halfBadgeHeight = f3;
|
||||
} else {
|
||||
this.halfBadgeWidth = Math.round((hasBadgeContent() ? this.state.badgeWithTextWidth : this.state.badgeWidth) / 2.0f);
|
||||
this.halfBadgeHeight = Math.round((hasBadgeContent() ? this.state.badgeWithTextHeight : this.state.badgeHeight) / 2.0f);
|
||||
}
|
||||
if (hasBadgeContent()) {
|
||||
String badgeContent = getBadgeContent();
|
||||
this.halfBadgeWidth = Math.max(this.halfBadgeWidth, (this.textDrawableHelper.getTextWidth(badgeContent) / 2.0f) + this.state.getBadgeHorizontalPadding());
|
||||
float max = Math.max(this.halfBadgeHeight, (this.textDrawableHelper.getTextHeight(badgeContent) / 2.0f) + this.state.getBadgeVerticalPadding());
|
||||
this.halfBadgeHeight = max;
|
||||
this.halfBadgeWidth = Math.max(this.halfBadgeWidth, max);
|
||||
}
|
||||
int totalVerticalOffsetForState = getTotalVerticalOffsetForState();
|
||||
int badgeGravity = this.state.getBadgeGravity();
|
||||
if (badgeGravity == 8388691 || badgeGravity == 8388693) {
|
||||
this.badgeCenterY = rect.bottom - totalVerticalOffsetForState;
|
||||
} else {
|
||||
this.badgeCenterY = rect.top + totalVerticalOffsetForState;
|
||||
}
|
||||
int totalHorizontalOffsetForState = getTotalHorizontalOffsetForState();
|
||||
int badgeGravity2 = this.state.getBadgeGravity();
|
||||
if (badgeGravity2 == 8388659 || badgeGravity2 == 8388691) {
|
||||
if (ViewCompat.getLayoutDirection(view) == 0) {
|
||||
f = (rect.left - this.halfBadgeWidth) + totalHorizontalOffsetForState;
|
||||
} else {
|
||||
f = (rect.right + this.halfBadgeWidth) - totalHorizontalOffsetForState;
|
||||
}
|
||||
this.badgeCenterX = f;
|
||||
} else {
|
||||
if (ViewCompat.getLayoutDirection(view) == 0) {
|
||||
f2 = (rect.right + this.halfBadgeWidth) - totalHorizontalOffsetForState;
|
||||
} else {
|
||||
f2 = (rect.left - this.halfBadgeWidth) + totalHorizontalOffsetForState;
|
||||
}
|
||||
this.badgeCenterX = f2;
|
||||
}
|
||||
if (this.state.isAutoAdjustedToGrandparentBounds()) {
|
||||
autoAdjustWithinGrandparentBounds(view);
|
||||
}
|
||||
}
|
||||
|
||||
private void autoAdjustWithinGrandparentBounds(View view) {
|
||||
float f;
|
||||
float f2;
|
||||
View customBadgeParent = getCustomBadgeParent();
|
||||
if (customBadgeParent == null) {
|
||||
if (!(view.getParent() instanceof View)) {
|
||||
return;
|
||||
}
|
||||
float y = view.getY();
|
||||
f2 = view.getX();
|
||||
customBadgeParent = (View) view.getParent();
|
||||
f = y;
|
||||
} else if (!isAnchorViewWrappedInCompatParent()) {
|
||||
f = 0.0f;
|
||||
f2 = 0.0f;
|
||||
} else {
|
||||
if (!(customBadgeParent.getParent() instanceof View)) {
|
||||
return;
|
||||
}
|
||||
f = customBadgeParent.getY();
|
||||
f2 = customBadgeParent.getX();
|
||||
customBadgeParent = (View) customBadgeParent.getParent();
|
||||
}
|
||||
float topCutOff = getTopCutOff(customBadgeParent, f);
|
||||
float leftCutOff = getLeftCutOff(customBadgeParent, f2);
|
||||
float bottomCutOff = getBottomCutOff(customBadgeParent, f);
|
||||
float rightCutoff = getRightCutoff(customBadgeParent, f2);
|
||||
if (topCutOff < 0.0f) {
|
||||
this.badgeCenterY += Math.abs(topCutOff);
|
||||
}
|
||||
if (leftCutOff < 0.0f) {
|
||||
this.badgeCenterX += Math.abs(leftCutOff);
|
||||
}
|
||||
if (bottomCutOff > 0.0f) {
|
||||
this.badgeCenterY -= Math.abs(bottomCutOff);
|
||||
}
|
||||
if (rightCutoff > 0.0f) {
|
||||
this.badgeCenterX -= Math.abs(rightCutoff);
|
||||
}
|
||||
}
|
||||
|
||||
private float getTopCutOff(View view, float f) {
|
||||
return (this.badgeCenterY - this.halfBadgeHeight) + view.getY() + f;
|
||||
}
|
||||
|
||||
private float getLeftCutOff(View view, float f) {
|
||||
return (this.badgeCenterX - this.halfBadgeWidth) + view.getX() + f;
|
||||
}
|
||||
|
||||
private float getBottomCutOff(View view, float f) {
|
||||
if (!(view.getParent() instanceof View)) {
|
||||
return 0.0f;
|
||||
}
|
||||
return ((this.badgeCenterY + this.halfBadgeHeight) - (((View) view.getParent()).getHeight() - view.getY())) + f;
|
||||
}
|
||||
|
||||
private float getRightCutoff(View view, float f) {
|
||||
if (!(view.getParent() instanceof View)) {
|
||||
return 0.0f;
|
||||
}
|
||||
return ((this.badgeCenterX + this.halfBadgeWidth) - (((View) view.getParent()).getWidth() - view.getX())) + f;
|
||||
}
|
||||
|
||||
private void drawBadgeContent(Canvas canvas) {
|
||||
String badgeContent = getBadgeContent();
|
||||
if (badgeContent != null) {
|
||||
Rect rect = new Rect();
|
||||
this.textDrawableHelper.getTextPaint().getTextBounds(badgeContent, 0, badgeContent.length(), rect);
|
||||
float exactCenterY = this.badgeCenterY - rect.exactCenterY();
|
||||
canvas.drawText(badgeContent, this.badgeCenterX, rect.bottom <= 0 ? (int) exactCenterY : Math.round(exactCenterY), this.textDrawableHelper.getTextPaint());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasBadgeContent() {
|
||||
return hasText() || hasNumber();
|
||||
}
|
||||
|
||||
private String getBadgeContent() {
|
||||
if (hasText()) {
|
||||
return getTextBadgeText();
|
||||
}
|
||||
if (hasNumber()) {
|
||||
return getNumberBadgeText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getTextBadgeText() {
|
||||
String text = getText();
|
||||
int maxCharacterCount = getMaxCharacterCount();
|
||||
if (maxCharacterCount == -2 || text == null || text.length() <= maxCharacterCount) {
|
||||
return text;
|
||||
}
|
||||
Context context = this.contextRef.get();
|
||||
if (context == null) {
|
||||
return "";
|
||||
}
|
||||
return String.format(context.getString(R.string.m3_exceed_max_badge_text_suffix), text.substring(0, maxCharacterCount - 1), DEFAULT_EXCEED_MAX_BADGE_TEXT_SUFFIX);
|
||||
}
|
||||
|
||||
private String getNumberBadgeText() {
|
||||
if (this.maxBadgeNumber == -2 || getNumber() <= this.maxBadgeNumber) {
|
||||
return NumberFormat.getInstance(this.state.getNumberLocale()).format(getNumber());
|
||||
}
|
||||
Context context = this.contextRef.get();
|
||||
return context == null ? "" : String.format(this.state.getNumberLocale(), context.getString(R.string.mtrl_exceed_max_badge_number_suffix), Integer.valueOf(this.maxBadgeNumber), DEFAULT_EXCEED_MAX_BADGE_NUMBER_SUFFIX);
|
||||
}
|
||||
|
||||
private void onBadgeContentUpdated() {
|
||||
this.textDrawableHelper.setTextSizeDirty(true);
|
||||
onBadgeShapeAppearanceUpdated();
|
||||
updateCenterAndBounds();
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
private void updateMaxBadgeNumber() {
|
||||
if (getMaxCharacterCount() != -2) {
|
||||
this.maxBadgeNumber = ((int) Math.pow(10.0d, getMaxCharacterCount() - 1.0d)) - 1;
|
||||
} else {
|
||||
this.maxBadgeNumber = getMaxNumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,672 @@
|
||||
package com.google.android.material.badge;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.drawable.DrawableUtils;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
import com.google.android.material.resources.TextAppearance;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class BadgeState {
|
||||
private static final String BADGE_RESOURCE_TAG = "badge";
|
||||
final float badgeHeight;
|
||||
final float badgeRadius;
|
||||
final float badgeWidth;
|
||||
final float badgeWithTextHeight;
|
||||
final float badgeWithTextRadius;
|
||||
final float badgeWithTextWidth;
|
||||
private final State currentState;
|
||||
final int horizontalInset;
|
||||
final int horizontalInsetWithText;
|
||||
int offsetAlignmentMode;
|
||||
private final State overridingState;
|
||||
|
||||
State getOverridingState() {
|
||||
return this.overridingState;
|
||||
}
|
||||
|
||||
BadgeState(Context context, int i, int i2, int i3, State state) {
|
||||
CharSequence charSequence;
|
||||
int i4;
|
||||
int i5;
|
||||
int i6;
|
||||
int i7;
|
||||
int intValue;
|
||||
int intValue2;
|
||||
int intValue3;
|
||||
int intValue4;
|
||||
int intValue5;
|
||||
int intValue6;
|
||||
int intValue7;
|
||||
int intValue8;
|
||||
int intValue9;
|
||||
int intValue10;
|
||||
int intValue11;
|
||||
int intValue12;
|
||||
int intValue13;
|
||||
int intValue14;
|
||||
boolean booleanValue;
|
||||
Locale locale;
|
||||
Locale.Category category;
|
||||
State state2 = new State();
|
||||
this.currentState = state2;
|
||||
state = state == null ? new State() : state;
|
||||
if (i != 0) {
|
||||
state.badgeResId = i;
|
||||
}
|
||||
TypedArray generateTypedArray = generateTypedArray(context, state.badgeResId, i2, i3);
|
||||
Resources resources = context.getResources();
|
||||
this.badgeRadius = generateTypedArray.getDimensionPixelSize(R.styleable.Badge_badgeRadius, -1);
|
||||
this.horizontalInset = context.getResources().getDimensionPixelSize(R.dimen.mtrl_badge_horizontal_edge_offset);
|
||||
this.horizontalInsetWithText = context.getResources().getDimensionPixelSize(R.dimen.mtrl_badge_text_horizontal_edge_offset);
|
||||
this.badgeWithTextRadius = generateTypedArray.getDimensionPixelSize(R.styleable.Badge_badgeWithTextRadius, -1);
|
||||
this.badgeWidth = generateTypedArray.getDimension(R.styleable.Badge_badgeWidth, resources.getDimension(R.dimen.m3_badge_size));
|
||||
this.badgeWithTextWidth = generateTypedArray.getDimension(R.styleable.Badge_badgeWithTextWidth, resources.getDimension(R.dimen.m3_badge_with_text_size));
|
||||
this.badgeHeight = generateTypedArray.getDimension(R.styleable.Badge_badgeHeight, resources.getDimension(R.dimen.m3_badge_size));
|
||||
this.badgeWithTextHeight = generateTypedArray.getDimension(R.styleable.Badge_badgeWithTextHeight, resources.getDimension(R.dimen.m3_badge_with_text_size));
|
||||
boolean z = true;
|
||||
this.offsetAlignmentMode = generateTypedArray.getInt(R.styleable.Badge_offsetAlignmentMode, 1);
|
||||
state2.alpha = state.alpha == -2 ? 255 : state.alpha;
|
||||
if (state.number == -2) {
|
||||
if (generateTypedArray.hasValue(R.styleable.Badge_number)) {
|
||||
state2.number = generateTypedArray.getInt(R.styleable.Badge_number, 0);
|
||||
} else {
|
||||
state2.number = -1;
|
||||
}
|
||||
} else {
|
||||
state2.number = state.number;
|
||||
}
|
||||
if (state.text == null) {
|
||||
if (generateTypedArray.hasValue(R.styleable.Badge_badgeText)) {
|
||||
state2.text = generateTypedArray.getString(R.styleable.Badge_badgeText);
|
||||
}
|
||||
} else {
|
||||
state2.text = state.text;
|
||||
}
|
||||
state2.contentDescriptionForText = state.contentDescriptionForText;
|
||||
if (state.contentDescriptionNumberless == null) {
|
||||
charSequence = context.getString(R.string.mtrl_badge_numberless_content_description);
|
||||
} else {
|
||||
charSequence = state.contentDescriptionNumberless;
|
||||
}
|
||||
state2.contentDescriptionNumberless = charSequence;
|
||||
if (state.contentDescriptionQuantityStrings == 0) {
|
||||
i4 = R.plurals.mtrl_badge_content_description;
|
||||
} else {
|
||||
i4 = state.contentDescriptionQuantityStrings;
|
||||
}
|
||||
state2.contentDescriptionQuantityStrings = i4;
|
||||
if (state.contentDescriptionExceedsMaxBadgeNumberRes == 0) {
|
||||
i5 = R.string.mtrl_exceed_max_badge_number_content_description;
|
||||
} else {
|
||||
i5 = state.contentDescriptionExceedsMaxBadgeNumberRes;
|
||||
}
|
||||
state2.contentDescriptionExceedsMaxBadgeNumberRes = i5;
|
||||
if (state.isVisible != null && !state.isVisible.booleanValue()) {
|
||||
z = false;
|
||||
}
|
||||
state2.isVisible = Boolean.valueOf(z);
|
||||
if (state.maxCharacterCount == -2) {
|
||||
i6 = generateTypedArray.getInt(R.styleable.Badge_maxCharacterCount, -2);
|
||||
} else {
|
||||
i6 = state.maxCharacterCount;
|
||||
}
|
||||
state2.maxCharacterCount = i6;
|
||||
if (state.maxNumber == -2) {
|
||||
i7 = generateTypedArray.getInt(R.styleable.Badge_maxNumber, -2);
|
||||
} else {
|
||||
i7 = state.maxNumber;
|
||||
}
|
||||
state2.maxNumber = i7;
|
||||
if (state.badgeShapeAppearanceResId == null) {
|
||||
intValue = generateTypedArray.getResourceId(R.styleable.Badge_badgeShapeAppearance, R.style.ShapeAppearance_M3_Sys_Shape_Corner_Full);
|
||||
} else {
|
||||
intValue = state.badgeShapeAppearanceResId.intValue();
|
||||
}
|
||||
state2.badgeShapeAppearanceResId = Integer.valueOf(intValue);
|
||||
if (state.badgeShapeAppearanceOverlayResId == null) {
|
||||
intValue2 = generateTypedArray.getResourceId(R.styleable.Badge_badgeShapeAppearanceOverlay, 0);
|
||||
} else {
|
||||
intValue2 = state.badgeShapeAppearanceOverlayResId.intValue();
|
||||
}
|
||||
state2.badgeShapeAppearanceOverlayResId = Integer.valueOf(intValue2);
|
||||
if (state.badgeWithTextShapeAppearanceResId == null) {
|
||||
intValue3 = generateTypedArray.getResourceId(R.styleable.Badge_badgeWithTextShapeAppearance, R.style.ShapeAppearance_M3_Sys_Shape_Corner_Full);
|
||||
} else {
|
||||
intValue3 = state.badgeWithTextShapeAppearanceResId.intValue();
|
||||
}
|
||||
state2.badgeWithTextShapeAppearanceResId = Integer.valueOf(intValue3);
|
||||
if (state.badgeWithTextShapeAppearanceOverlayResId == null) {
|
||||
intValue4 = generateTypedArray.getResourceId(R.styleable.Badge_badgeWithTextShapeAppearanceOverlay, 0);
|
||||
} else {
|
||||
intValue4 = state.badgeWithTextShapeAppearanceOverlayResId.intValue();
|
||||
}
|
||||
state2.badgeWithTextShapeAppearanceOverlayResId = Integer.valueOf(intValue4);
|
||||
if (state.backgroundColor == null) {
|
||||
intValue5 = readColorFromAttributes(context, generateTypedArray, R.styleable.Badge_backgroundColor);
|
||||
} else {
|
||||
intValue5 = state.backgroundColor.intValue();
|
||||
}
|
||||
state2.backgroundColor = Integer.valueOf(intValue5);
|
||||
if (state.badgeTextAppearanceResId == null) {
|
||||
intValue6 = generateTypedArray.getResourceId(R.styleable.Badge_badgeTextAppearance, R.style.TextAppearance_MaterialComponents_Badge);
|
||||
} else {
|
||||
intValue6 = state.badgeTextAppearanceResId.intValue();
|
||||
}
|
||||
state2.badgeTextAppearanceResId = Integer.valueOf(intValue6);
|
||||
if (state.badgeTextColor == null) {
|
||||
if (generateTypedArray.hasValue(R.styleable.Badge_badgeTextColor)) {
|
||||
state2.badgeTextColor = Integer.valueOf(readColorFromAttributes(context, generateTypedArray, R.styleable.Badge_badgeTextColor));
|
||||
} else {
|
||||
state2.badgeTextColor = Integer.valueOf(new TextAppearance(context, state2.badgeTextAppearanceResId.intValue()).getTextColor().getDefaultColor());
|
||||
}
|
||||
} else {
|
||||
state2.badgeTextColor = state.badgeTextColor;
|
||||
}
|
||||
if (state.badgeGravity == null) {
|
||||
intValue7 = generateTypedArray.getInt(R.styleable.Badge_badgeGravity, 8388661);
|
||||
} else {
|
||||
intValue7 = state.badgeGravity.intValue();
|
||||
}
|
||||
state2.badgeGravity = Integer.valueOf(intValue7);
|
||||
if (state.badgeHorizontalPadding == null) {
|
||||
intValue8 = generateTypedArray.getDimensionPixelSize(R.styleable.Badge_badgeWidePadding, resources.getDimensionPixelSize(R.dimen.mtrl_badge_long_text_horizontal_padding));
|
||||
} else {
|
||||
intValue8 = state.badgeHorizontalPadding.intValue();
|
||||
}
|
||||
state2.badgeHorizontalPadding = Integer.valueOf(intValue8);
|
||||
if (state.badgeVerticalPadding == null) {
|
||||
intValue9 = generateTypedArray.getDimensionPixelSize(R.styleable.Badge_badgeVerticalPadding, resources.getDimensionPixelSize(R.dimen.m3_badge_with_text_vertical_padding));
|
||||
} else {
|
||||
intValue9 = state.badgeVerticalPadding.intValue();
|
||||
}
|
||||
state2.badgeVerticalPadding = Integer.valueOf(intValue9);
|
||||
if (state.horizontalOffsetWithoutText == null) {
|
||||
intValue10 = generateTypedArray.getDimensionPixelOffset(R.styleable.Badge_horizontalOffset, 0);
|
||||
} else {
|
||||
intValue10 = state.horizontalOffsetWithoutText.intValue();
|
||||
}
|
||||
state2.horizontalOffsetWithoutText = Integer.valueOf(intValue10);
|
||||
if (state.verticalOffsetWithoutText == null) {
|
||||
intValue11 = generateTypedArray.getDimensionPixelOffset(R.styleable.Badge_verticalOffset, 0);
|
||||
} else {
|
||||
intValue11 = state.verticalOffsetWithoutText.intValue();
|
||||
}
|
||||
state2.verticalOffsetWithoutText = Integer.valueOf(intValue11);
|
||||
if (state.horizontalOffsetWithText == null) {
|
||||
intValue12 = generateTypedArray.getDimensionPixelOffset(R.styleable.Badge_horizontalOffsetWithText, state2.horizontalOffsetWithoutText.intValue());
|
||||
} else {
|
||||
intValue12 = state.horizontalOffsetWithText.intValue();
|
||||
}
|
||||
state2.horizontalOffsetWithText = Integer.valueOf(intValue12);
|
||||
if (state.verticalOffsetWithText == null) {
|
||||
intValue13 = generateTypedArray.getDimensionPixelOffset(R.styleable.Badge_verticalOffsetWithText, state2.verticalOffsetWithoutText.intValue());
|
||||
} else {
|
||||
intValue13 = state.verticalOffsetWithText.intValue();
|
||||
}
|
||||
state2.verticalOffsetWithText = Integer.valueOf(intValue13);
|
||||
if (state.largeFontVerticalOffsetAdjustment == null) {
|
||||
intValue14 = generateTypedArray.getDimensionPixelOffset(R.styleable.Badge_largeFontVerticalOffsetAdjustment, 0);
|
||||
} else {
|
||||
intValue14 = state.largeFontVerticalOffsetAdjustment.intValue();
|
||||
}
|
||||
state2.largeFontVerticalOffsetAdjustment = Integer.valueOf(intValue14);
|
||||
state2.additionalHorizontalOffset = Integer.valueOf(state.additionalHorizontalOffset == null ? 0 : state.additionalHorizontalOffset.intValue());
|
||||
state2.additionalVerticalOffset = Integer.valueOf(state.additionalVerticalOffset == null ? 0 : state.additionalVerticalOffset.intValue());
|
||||
if (state.autoAdjustToWithinGrandparentBounds == null) {
|
||||
booleanValue = generateTypedArray.getBoolean(R.styleable.Badge_autoAdjustToWithinGrandparentBounds, false);
|
||||
} else {
|
||||
booleanValue = state.autoAdjustToWithinGrandparentBounds.booleanValue();
|
||||
}
|
||||
state2.autoAdjustToWithinGrandparentBounds = Boolean.valueOf(booleanValue);
|
||||
generateTypedArray.recycle();
|
||||
if (state.numberLocale == null) {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
category = Locale.Category.FORMAT;
|
||||
locale = Locale.getDefault(category);
|
||||
} else {
|
||||
locale = Locale.getDefault();
|
||||
}
|
||||
state2.numberLocale = locale;
|
||||
} else {
|
||||
state2.numberLocale = state.numberLocale;
|
||||
}
|
||||
this.overridingState = state;
|
||||
}
|
||||
|
||||
private TypedArray generateTypedArray(Context context, int i, int i2, int i3) {
|
||||
AttributeSet attributeSet;
|
||||
int i4;
|
||||
if (i != 0) {
|
||||
AttributeSet parseDrawableXml = DrawableUtils.parseDrawableXml(context, i, BADGE_RESOURCE_TAG);
|
||||
i4 = parseDrawableXml.getStyleAttribute();
|
||||
attributeSet = parseDrawableXml;
|
||||
} else {
|
||||
attributeSet = null;
|
||||
i4 = 0;
|
||||
}
|
||||
return ThemeEnforcement.obtainStyledAttributes(context, attributeSet, R.styleable.Badge, i2, i4 == 0 ? i3 : i4, new int[0]);
|
||||
}
|
||||
|
||||
boolean isVisible() {
|
||||
return this.currentState.isVisible.booleanValue();
|
||||
}
|
||||
|
||||
void setVisible(boolean z) {
|
||||
this.overridingState.isVisible = Boolean.valueOf(z);
|
||||
this.currentState.isVisible = Boolean.valueOf(z);
|
||||
}
|
||||
|
||||
boolean hasNumber() {
|
||||
return this.currentState.number != -1;
|
||||
}
|
||||
|
||||
int getNumber() {
|
||||
return this.currentState.number;
|
||||
}
|
||||
|
||||
void setNumber(int i) {
|
||||
this.overridingState.number = i;
|
||||
this.currentState.number = i;
|
||||
}
|
||||
|
||||
void clearNumber() {
|
||||
setNumber(-1);
|
||||
}
|
||||
|
||||
boolean hasText() {
|
||||
return this.currentState.text != null;
|
||||
}
|
||||
|
||||
String getText() {
|
||||
return this.currentState.text;
|
||||
}
|
||||
|
||||
void setText(String str) {
|
||||
this.overridingState.text = str;
|
||||
this.currentState.text = str;
|
||||
}
|
||||
|
||||
void clearText() {
|
||||
setText(null);
|
||||
}
|
||||
|
||||
int getAlpha() {
|
||||
return this.currentState.alpha;
|
||||
}
|
||||
|
||||
void setAlpha(int i) {
|
||||
this.overridingState.alpha = i;
|
||||
this.currentState.alpha = i;
|
||||
}
|
||||
|
||||
int getMaxCharacterCount() {
|
||||
return this.currentState.maxCharacterCount;
|
||||
}
|
||||
|
||||
void setMaxCharacterCount(int i) {
|
||||
this.overridingState.maxCharacterCount = i;
|
||||
this.currentState.maxCharacterCount = i;
|
||||
}
|
||||
|
||||
int getMaxNumber() {
|
||||
return this.currentState.maxNumber;
|
||||
}
|
||||
|
||||
void setMaxNumber(int i) {
|
||||
this.overridingState.maxNumber = i;
|
||||
this.currentState.maxNumber = i;
|
||||
}
|
||||
|
||||
int getBackgroundColor() {
|
||||
return this.currentState.backgroundColor.intValue();
|
||||
}
|
||||
|
||||
void setBackgroundColor(int i) {
|
||||
this.overridingState.backgroundColor = Integer.valueOf(i);
|
||||
this.currentState.backgroundColor = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getBadgeTextColor() {
|
||||
return this.currentState.badgeTextColor.intValue();
|
||||
}
|
||||
|
||||
void setBadgeTextColor(int i) {
|
||||
this.overridingState.badgeTextColor = Integer.valueOf(i);
|
||||
this.currentState.badgeTextColor = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getTextAppearanceResId() {
|
||||
return this.currentState.badgeTextAppearanceResId.intValue();
|
||||
}
|
||||
|
||||
void setTextAppearanceResId(int i) {
|
||||
this.overridingState.badgeTextAppearanceResId = Integer.valueOf(i);
|
||||
this.currentState.badgeTextAppearanceResId = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getBadgeShapeAppearanceResId() {
|
||||
return this.currentState.badgeShapeAppearanceResId.intValue();
|
||||
}
|
||||
|
||||
void setBadgeShapeAppearanceResId(int i) {
|
||||
this.overridingState.badgeShapeAppearanceResId = Integer.valueOf(i);
|
||||
this.currentState.badgeShapeAppearanceResId = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getBadgeShapeAppearanceOverlayResId() {
|
||||
return this.currentState.badgeShapeAppearanceOverlayResId.intValue();
|
||||
}
|
||||
|
||||
void setBadgeShapeAppearanceOverlayResId(int i) {
|
||||
this.overridingState.badgeShapeAppearanceOverlayResId = Integer.valueOf(i);
|
||||
this.currentState.badgeShapeAppearanceOverlayResId = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getBadgeWithTextShapeAppearanceResId() {
|
||||
return this.currentState.badgeWithTextShapeAppearanceResId.intValue();
|
||||
}
|
||||
|
||||
void setBadgeWithTextShapeAppearanceResId(int i) {
|
||||
this.overridingState.badgeWithTextShapeAppearanceResId = Integer.valueOf(i);
|
||||
this.currentState.badgeWithTextShapeAppearanceResId = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getBadgeWithTextShapeAppearanceOverlayResId() {
|
||||
return this.currentState.badgeWithTextShapeAppearanceOverlayResId.intValue();
|
||||
}
|
||||
|
||||
void setBadgeWithTextShapeAppearanceOverlayResId(int i) {
|
||||
this.overridingState.badgeWithTextShapeAppearanceOverlayResId = Integer.valueOf(i);
|
||||
this.currentState.badgeWithTextShapeAppearanceOverlayResId = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getBadgeGravity() {
|
||||
return this.currentState.badgeGravity.intValue();
|
||||
}
|
||||
|
||||
void setBadgeGravity(int i) {
|
||||
this.overridingState.badgeGravity = Integer.valueOf(i);
|
||||
this.currentState.badgeGravity = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getBadgeHorizontalPadding() {
|
||||
return this.currentState.badgeHorizontalPadding.intValue();
|
||||
}
|
||||
|
||||
void setBadgeHorizontalPadding(int i) {
|
||||
this.overridingState.badgeHorizontalPadding = Integer.valueOf(i);
|
||||
this.currentState.badgeHorizontalPadding = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getBadgeVerticalPadding() {
|
||||
return this.currentState.badgeVerticalPadding.intValue();
|
||||
}
|
||||
|
||||
void setBadgeVerticalPadding(int i) {
|
||||
this.overridingState.badgeVerticalPadding = Integer.valueOf(i);
|
||||
this.currentState.badgeVerticalPadding = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getHorizontalOffsetWithoutText() {
|
||||
return this.currentState.horizontalOffsetWithoutText.intValue();
|
||||
}
|
||||
|
||||
void setHorizontalOffsetWithoutText(int i) {
|
||||
this.overridingState.horizontalOffsetWithoutText = Integer.valueOf(i);
|
||||
this.currentState.horizontalOffsetWithoutText = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getVerticalOffsetWithoutText() {
|
||||
return this.currentState.verticalOffsetWithoutText.intValue();
|
||||
}
|
||||
|
||||
void setVerticalOffsetWithoutText(int i) {
|
||||
this.overridingState.verticalOffsetWithoutText = Integer.valueOf(i);
|
||||
this.currentState.verticalOffsetWithoutText = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getHorizontalOffsetWithText() {
|
||||
return this.currentState.horizontalOffsetWithText.intValue();
|
||||
}
|
||||
|
||||
void setHorizontalOffsetWithText(int i) {
|
||||
this.overridingState.horizontalOffsetWithText = Integer.valueOf(i);
|
||||
this.currentState.horizontalOffsetWithText = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getVerticalOffsetWithText() {
|
||||
return this.currentState.verticalOffsetWithText.intValue();
|
||||
}
|
||||
|
||||
void setVerticalOffsetWithText(int i) {
|
||||
this.overridingState.verticalOffsetWithText = Integer.valueOf(i);
|
||||
this.currentState.verticalOffsetWithText = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getLargeFontVerticalOffsetAdjustment() {
|
||||
return this.currentState.largeFontVerticalOffsetAdjustment.intValue();
|
||||
}
|
||||
|
||||
void setLargeFontVerticalOffsetAdjustment(int i) {
|
||||
this.overridingState.largeFontVerticalOffsetAdjustment = Integer.valueOf(i);
|
||||
this.currentState.largeFontVerticalOffsetAdjustment = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getAdditionalHorizontalOffset() {
|
||||
return this.currentState.additionalHorizontalOffset.intValue();
|
||||
}
|
||||
|
||||
void setAdditionalHorizontalOffset(int i) {
|
||||
this.overridingState.additionalHorizontalOffset = Integer.valueOf(i);
|
||||
this.currentState.additionalHorizontalOffset = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
int getAdditionalVerticalOffset() {
|
||||
return this.currentState.additionalVerticalOffset.intValue();
|
||||
}
|
||||
|
||||
void setAdditionalVerticalOffset(int i) {
|
||||
this.overridingState.additionalVerticalOffset = Integer.valueOf(i);
|
||||
this.currentState.additionalVerticalOffset = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
CharSequence getContentDescriptionForText() {
|
||||
return this.currentState.contentDescriptionForText;
|
||||
}
|
||||
|
||||
void setContentDescriptionForText(CharSequence charSequence) {
|
||||
this.overridingState.contentDescriptionForText = charSequence;
|
||||
this.currentState.contentDescriptionForText = charSequence;
|
||||
}
|
||||
|
||||
CharSequence getContentDescriptionNumberless() {
|
||||
return this.currentState.contentDescriptionNumberless;
|
||||
}
|
||||
|
||||
void setContentDescriptionNumberless(CharSequence charSequence) {
|
||||
this.overridingState.contentDescriptionNumberless = charSequence;
|
||||
this.currentState.contentDescriptionNumberless = charSequence;
|
||||
}
|
||||
|
||||
int getContentDescriptionQuantityStrings() {
|
||||
return this.currentState.contentDescriptionQuantityStrings;
|
||||
}
|
||||
|
||||
void setContentDescriptionQuantityStringsResource(int i) {
|
||||
this.overridingState.contentDescriptionQuantityStrings = i;
|
||||
this.currentState.contentDescriptionQuantityStrings = i;
|
||||
}
|
||||
|
||||
int getContentDescriptionExceedsMaxBadgeNumberStringResource() {
|
||||
return this.currentState.contentDescriptionExceedsMaxBadgeNumberRes;
|
||||
}
|
||||
|
||||
void setContentDescriptionExceedsMaxBadgeNumberStringResource(int i) {
|
||||
this.overridingState.contentDescriptionExceedsMaxBadgeNumberRes = i;
|
||||
this.currentState.contentDescriptionExceedsMaxBadgeNumberRes = i;
|
||||
}
|
||||
|
||||
Locale getNumberLocale() {
|
||||
return this.currentState.numberLocale;
|
||||
}
|
||||
|
||||
void setNumberLocale(Locale locale) {
|
||||
this.overridingState.numberLocale = locale;
|
||||
this.currentState.numberLocale = locale;
|
||||
}
|
||||
|
||||
boolean isAutoAdjustedToGrandparentBounds() {
|
||||
return this.currentState.autoAdjustToWithinGrandparentBounds.booleanValue();
|
||||
}
|
||||
|
||||
void setAutoAdjustToGrandparentBounds(boolean z) {
|
||||
this.overridingState.autoAdjustToWithinGrandparentBounds = Boolean.valueOf(z);
|
||||
this.currentState.autoAdjustToWithinGrandparentBounds = Boolean.valueOf(z);
|
||||
}
|
||||
|
||||
private static int readColorFromAttributes(Context context, TypedArray typedArray, int i) {
|
||||
return MaterialResources.getColorStateList(context, typedArray, i).getDefaultColor();
|
||||
}
|
||||
|
||||
public static final class State implements Parcelable {
|
||||
private static final int BADGE_NUMBER_NONE = -1;
|
||||
public static final Parcelable.Creator<State> CREATOR = new Parcelable.Creator<State>() { // from class: com.google.android.material.badge.BadgeState.State.1
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public State createFromParcel(Parcel parcel) {
|
||||
return new State(parcel);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public State[] newArray(int i) {
|
||||
return new State[i];
|
||||
}
|
||||
};
|
||||
private static final int NOT_SET = -2;
|
||||
private Integer additionalHorizontalOffset;
|
||||
private Integer additionalVerticalOffset;
|
||||
private int alpha;
|
||||
private Boolean autoAdjustToWithinGrandparentBounds;
|
||||
private Integer backgroundColor;
|
||||
private Integer badgeGravity;
|
||||
private Integer badgeHorizontalPadding;
|
||||
private int badgeResId;
|
||||
private Integer badgeShapeAppearanceOverlayResId;
|
||||
private Integer badgeShapeAppearanceResId;
|
||||
private Integer badgeTextAppearanceResId;
|
||||
private Integer badgeTextColor;
|
||||
private Integer badgeVerticalPadding;
|
||||
private Integer badgeWithTextShapeAppearanceOverlayResId;
|
||||
private Integer badgeWithTextShapeAppearanceResId;
|
||||
private int contentDescriptionExceedsMaxBadgeNumberRes;
|
||||
private CharSequence contentDescriptionForText;
|
||||
private CharSequence contentDescriptionNumberless;
|
||||
private int contentDescriptionQuantityStrings;
|
||||
private Integer horizontalOffsetWithText;
|
||||
private Integer horizontalOffsetWithoutText;
|
||||
private Boolean isVisible;
|
||||
private Integer largeFontVerticalOffsetAdjustment;
|
||||
private int maxCharacterCount;
|
||||
private int maxNumber;
|
||||
private int number;
|
||||
private Locale numberLocale;
|
||||
private String text;
|
||||
private Integer verticalOffsetWithText;
|
||||
private Integer verticalOffsetWithoutText;
|
||||
|
||||
@Override // android.os.Parcelable
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public State() {
|
||||
this.alpha = 255;
|
||||
this.number = -2;
|
||||
this.maxCharacterCount = -2;
|
||||
this.maxNumber = -2;
|
||||
this.isVisible = true;
|
||||
}
|
||||
|
||||
State(Parcel parcel) {
|
||||
this.alpha = 255;
|
||||
this.number = -2;
|
||||
this.maxCharacterCount = -2;
|
||||
this.maxNumber = -2;
|
||||
this.isVisible = true;
|
||||
this.badgeResId = parcel.readInt();
|
||||
this.backgroundColor = (Integer) parcel.readSerializable();
|
||||
this.badgeTextColor = (Integer) parcel.readSerializable();
|
||||
this.badgeTextAppearanceResId = (Integer) parcel.readSerializable();
|
||||
this.badgeShapeAppearanceResId = (Integer) parcel.readSerializable();
|
||||
this.badgeShapeAppearanceOverlayResId = (Integer) parcel.readSerializable();
|
||||
this.badgeWithTextShapeAppearanceResId = (Integer) parcel.readSerializable();
|
||||
this.badgeWithTextShapeAppearanceOverlayResId = (Integer) parcel.readSerializable();
|
||||
this.alpha = parcel.readInt();
|
||||
this.text = parcel.readString();
|
||||
this.number = parcel.readInt();
|
||||
this.maxCharacterCount = parcel.readInt();
|
||||
this.maxNumber = parcel.readInt();
|
||||
this.contentDescriptionForText = parcel.readString();
|
||||
this.contentDescriptionNumberless = parcel.readString();
|
||||
this.contentDescriptionQuantityStrings = parcel.readInt();
|
||||
this.badgeGravity = (Integer) parcel.readSerializable();
|
||||
this.badgeHorizontalPadding = (Integer) parcel.readSerializable();
|
||||
this.badgeVerticalPadding = (Integer) parcel.readSerializable();
|
||||
this.horizontalOffsetWithoutText = (Integer) parcel.readSerializable();
|
||||
this.verticalOffsetWithoutText = (Integer) parcel.readSerializable();
|
||||
this.horizontalOffsetWithText = (Integer) parcel.readSerializable();
|
||||
this.verticalOffsetWithText = (Integer) parcel.readSerializable();
|
||||
this.largeFontVerticalOffsetAdjustment = (Integer) parcel.readSerializable();
|
||||
this.additionalHorizontalOffset = (Integer) parcel.readSerializable();
|
||||
this.additionalVerticalOffset = (Integer) parcel.readSerializable();
|
||||
this.isVisible = (Boolean) parcel.readSerializable();
|
||||
this.numberLocale = (Locale) parcel.readSerializable();
|
||||
this.autoAdjustToWithinGrandparentBounds = (Boolean) parcel.readSerializable();
|
||||
}
|
||||
|
||||
@Override // android.os.Parcelable
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
parcel.writeInt(this.badgeResId);
|
||||
parcel.writeSerializable(this.backgroundColor);
|
||||
parcel.writeSerializable(this.badgeTextColor);
|
||||
parcel.writeSerializable(this.badgeTextAppearanceResId);
|
||||
parcel.writeSerializable(this.badgeShapeAppearanceResId);
|
||||
parcel.writeSerializable(this.badgeShapeAppearanceOverlayResId);
|
||||
parcel.writeSerializable(this.badgeWithTextShapeAppearanceResId);
|
||||
parcel.writeSerializable(this.badgeWithTextShapeAppearanceOverlayResId);
|
||||
parcel.writeInt(this.alpha);
|
||||
parcel.writeString(this.text);
|
||||
parcel.writeInt(this.number);
|
||||
parcel.writeInt(this.maxCharacterCount);
|
||||
parcel.writeInt(this.maxNumber);
|
||||
CharSequence charSequence = this.contentDescriptionForText;
|
||||
parcel.writeString(charSequence != null ? charSequence.toString() : null);
|
||||
CharSequence charSequence2 = this.contentDescriptionNumberless;
|
||||
parcel.writeString(charSequence2 != null ? charSequence2.toString() : null);
|
||||
parcel.writeInt(this.contentDescriptionQuantityStrings);
|
||||
parcel.writeSerializable(this.badgeGravity);
|
||||
parcel.writeSerializable(this.badgeHorizontalPadding);
|
||||
parcel.writeSerializable(this.badgeVerticalPadding);
|
||||
parcel.writeSerializable(this.horizontalOffsetWithoutText);
|
||||
parcel.writeSerializable(this.verticalOffsetWithoutText);
|
||||
parcel.writeSerializable(this.horizontalOffsetWithText);
|
||||
parcel.writeSerializable(this.verticalOffsetWithText);
|
||||
parcel.writeSerializable(this.largeFontVerticalOffsetAdjustment);
|
||||
parcel.writeSerializable(this.additionalHorizontalOffset);
|
||||
parcel.writeSerializable(this.additionalVerticalOffset);
|
||||
parcel.writeSerializable(this.isVisible);
|
||||
parcel.writeSerializable(this.numberLocale);
|
||||
parcel.writeSerializable(this.autoAdjustToWithinGrandparentBounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.google.android.material.badge;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.appcompat.view.menu.ActionMenuItemView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.view.AccessibilityDelegateCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.badge.BadgeState;
|
||||
import com.google.android.material.internal.ParcelableSparseArray;
|
||||
import com.google.android.material.internal.ToolbarUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BadgeUtils {
|
||||
private static final String LOG_TAG = "BadgeUtils";
|
||||
public static final boolean USE_COMPAT_PARENT = false;
|
||||
|
||||
private BadgeUtils() {
|
||||
}
|
||||
|
||||
public static void updateBadgeBounds(Rect rect, float f, float f2, float f3, float f4) {
|
||||
rect.set((int) (f - f3), (int) (f2 - f4), (int) (f + f3), (int) (f2 + f4));
|
||||
}
|
||||
|
||||
public static void attachBadgeDrawable(BadgeDrawable badgeDrawable, View view) {
|
||||
attachBadgeDrawable(badgeDrawable, view, (FrameLayout) null);
|
||||
}
|
||||
|
||||
public static void attachBadgeDrawable(BadgeDrawable badgeDrawable, View view, FrameLayout frameLayout) {
|
||||
setBadgeDrawableBounds(badgeDrawable, view, frameLayout);
|
||||
if (badgeDrawable.getCustomBadgeParent() != null) {
|
||||
badgeDrawable.getCustomBadgeParent().setForeground(badgeDrawable);
|
||||
} else {
|
||||
if (USE_COMPAT_PARENT) {
|
||||
throw new IllegalArgumentException("Trying to reference null customBadgeParent");
|
||||
}
|
||||
view.getOverlay().add(badgeDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
public static void attachBadgeDrawable(BadgeDrawable badgeDrawable, Toolbar toolbar, int i) {
|
||||
attachBadgeDrawable(badgeDrawable, toolbar, i, null);
|
||||
}
|
||||
|
||||
public static void attachBadgeDrawable(final BadgeDrawable badgeDrawable, final Toolbar toolbar, final int i, final FrameLayout frameLayout) {
|
||||
toolbar.post(new Runnable() { // from class: com.google.android.material.badge.BadgeUtils.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ActionMenuItemView actionMenuItemView = ToolbarUtils.getActionMenuItemView(Toolbar.this, i);
|
||||
if (actionMenuItemView != null) {
|
||||
BadgeUtils.setToolbarOffset(badgeDrawable, Toolbar.this.getResources());
|
||||
BadgeUtils.attachBadgeDrawable(badgeDrawable, actionMenuItemView, frameLayout);
|
||||
BadgeUtils.attachBadgeContentDescription(badgeDrawable, actionMenuItemView);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static void attachBadgeContentDescription(final BadgeDrawable badgeDrawable, View view) {
|
||||
View.AccessibilityDelegate accessibilityDelegate;
|
||||
if (Build.VERSION.SDK_INT >= 29 && ViewCompat.hasAccessibilityDelegate(view)) {
|
||||
accessibilityDelegate = view.getAccessibilityDelegate();
|
||||
ViewCompat.setAccessibilityDelegate(view, new AccessibilityDelegateCompat(accessibilityDelegate) { // from class: com.google.android.material.badge.BadgeUtils.2
|
||||
@Override // androidx.core.view.AccessibilityDelegateCompat
|
||||
public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||||
super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat);
|
||||
accessibilityNodeInfoCompat.setContentDescription(badgeDrawable.getContentDescription());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ViewCompat.setAccessibilityDelegate(view, new AccessibilityDelegateCompat() { // from class: com.google.android.material.badge.BadgeUtils.3
|
||||
@Override // androidx.core.view.AccessibilityDelegateCompat
|
||||
public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||||
super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat);
|
||||
accessibilityNodeInfoCompat.setContentDescription(BadgeDrawable.this.getContentDescription());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void detachBadgeDrawable(BadgeDrawable badgeDrawable, View view) {
|
||||
if (badgeDrawable == null) {
|
||||
return;
|
||||
}
|
||||
if (USE_COMPAT_PARENT || badgeDrawable.getCustomBadgeParent() != null) {
|
||||
badgeDrawable.getCustomBadgeParent().setForeground(null);
|
||||
} else {
|
||||
view.getOverlay().remove(badgeDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
public static void detachBadgeDrawable(BadgeDrawable badgeDrawable, Toolbar toolbar, int i) {
|
||||
if (badgeDrawable == null) {
|
||||
return;
|
||||
}
|
||||
ActionMenuItemView actionMenuItemView = ToolbarUtils.getActionMenuItemView(toolbar, i);
|
||||
if (actionMenuItemView != null) {
|
||||
removeToolbarOffset(badgeDrawable);
|
||||
detachBadgeDrawable(badgeDrawable, actionMenuItemView);
|
||||
detachBadgeContentDescription(actionMenuItemView);
|
||||
} else {
|
||||
Log.w(LOG_TAG, "Trying to remove badge from a null menuItemView: " + i);
|
||||
}
|
||||
}
|
||||
|
||||
private static void detachBadgeContentDescription(View view) {
|
||||
View.AccessibilityDelegate accessibilityDelegate;
|
||||
if (Build.VERSION.SDK_INT >= 29 && ViewCompat.hasAccessibilityDelegate(view)) {
|
||||
accessibilityDelegate = view.getAccessibilityDelegate();
|
||||
ViewCompat.setAccessibilityDelegate(view, new AccessibilityDelegateCompat(accessibilityDelegate) { // from class: com.google.android.material.badge.BadgeUtils.4
|
||||
@Override // androidx.core.view.AccessibilityDelegateCompat
|
||||
public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||||
super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat);
|
||||
accessibilityNodeInfoCompat.setContentDescription(null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ViewCompat.setAccessibilityDelegate(view, null);
|
||||
}
|
||||
}
|
||||
|
||||
static void setToolbarOffset(BadgeDrawable badgeDrawable, Resources resources) {
|
||||
badgeDrawable.setAdditionalHorizontalOffset(resources.getDimensionPixelOffset(R.dimen.mtrl_badge_toolbar_action_menu_item_horizontal_offset));
|
||||
badgeDrawable.setAdditionalVerticalOffset(resources.getDimensionPixelOffset(R.dimen.mtrl_badge_toolbar_action_menu_item_vertical_offset));
|
||||
}
|
||||
|
||||
static void removeToolbarOffset(BadgeDrawable badgeDrawable) {
|
||||
badgeDrawable.setAdditionalHorizontalOffset(0);
|
||||
badgeDrawable.setAdditionalVerticalOffset(0);
|
||||
}
|
||||
|
||||
public static void setBadgeDrawableBounds(BadgeDrawable badgeDrawable, View view, FrameLayout frameLayout) {
|
||||
Rect rect = new Rect();
|
||||
view.getDrawingRect(rect);
|
||||
badgeDrawable.setBounds(rect);
|
||||
badgeDrawable.updateBadgeCoordinates(view, frameLayout);
|
||||
}
|
||||
|
||||
public static ParcelableSparseArray createParcelableBadgeStates(SparseArray<BadgeDrawable> sparseArray) {
|
||||
ParcelableSparseArray parcelableSparseArray = new ParcelableSparseArray();
|
||||
for (int i = 0; i < sparseArray.size(); i++) {
|
||||
int keyAt = sparseArray.keyAt(i);
|
||||
BadgeDrawable valueAt = sparseArray.valueAt(i);
|
||||
parcelableSparseArray.put(keyAt, valueAt != null ? valueAt.getSavedState() : null);
|
||||
}
|
||||
return parcelableSparseArray;
|
||||
}
|
||||
|
||||
public static SparseArray<BadgeDrawable> createBadgeDrawablesFromSavedStates(Context context, ParcelableSparseArray parcelableSparseArray) {
|
||||
SparseArray<BadgeDrawable> sparseArray = new SparseArray<>(parcelableSparseArray.size());
|
||||
for (int i = 0; i < parcelableSparseArray.size(); i++) {
|
||||
int keyAt = parcelableSparseArray.keyAt(i);
|
||||
BadgeState.State state = (BadgeState.State) parcelableSparseArray.valueAt(i);
|
||||
sparseArray.put(keyAt, state != null ? BadgeDrawable.createFromSavedState(context, state) : null);
|
||||
}
|
||||
return sparseArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.google.android.material.badge;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.PACKAGE})
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
/* loaded from: classes.dex */
|
||||
public @interface ExperimentalBadgeUtils {
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.google.android.material.behavior;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewPropertyAnimator;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.motion.MotionUtils;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HideBottomViewOnScrollBehavior<V extends View> extends CoordinatorLayout.Behavior<V> {
|
||||
private static final int DEFAULT_ENTER_ANIMATION_DURATION_MS = 225;
|
||||
private static final int DEFAULT_EXIT_ANIMATION_DURATION_MS = 175;
|
||||
public static final int STATE_SCROLLED_DOWN = 1;
|
||||
public static final int STATE_SCROLLED_UP = 2;
|
||||
private int additionalHiddenOffsetY;
|
||||
private ViewPropertyAnimator currentAnimator;
|
||||
private int currentState;
|
||||
private int enterAnimDuration;
|
||||
private TimeInterpolator enterAnimInterpolator;
|
||||
private int exitAnimDuration;
|
||||
private TimeInterpolator exitAnimInterpolator;
|
||||
private int height;
|
||||
private final LinkedHashSet<OnScrollStateChangedListener> onScrollStateChangedListeners;
|
||||
private static final int ENTER_ANIM_DURATION_ATTR = R.attr.motionDurationLong2;
|
||||
private static final int EXIT_ANIM_DURATION_ATTR = R.attr.motionDurationMedium4;
|
||||
private static final int ENTER_EXIT_ANIM_EASING_ATTR = R.attr.motionEasingEmphasizedInterpolator;
|
||||
|
||||
public interface OnScrollStateChangedListener {
|
||||
void onStateChanged(View view, int i);
|
||||
}
|
||||
|
||||
public @interface ScrollState {
|
||||
}
|
||||
|
||||
public boolean isScrolledDown() {
|
||||
return this.currentState == 1;
|
||||
}
|
||||
|
||||
public boolean isScrolledUp() {
|
||||
return this.currentState == 2;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V v, View view, View view2, int i, int i2) {
|
||||
return i == 2;
|
||||
}
|
||||
|
||||
public HideBottomViewOnScrollBehavior() {
|
||||
this.onScrollStateChangedListeners = new LinkedHashSet<>();
|
||||
this.height = 0;
|
||||
this.currentState = 2;
|
||||
this.additionalHiddenOffsetY = 0;
|
||||
}
|
||||
|
||||
public HideBottomViewOnScrollBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.onScrollStateChangedListeners = new LinkedHashSet<>();
|
||||
this.height = 0;
|
||||
this.currentState = 2;
|
||||
this.additionalHiddenOffsetY = 0;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onLayoutChild(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
this.height = v.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) v.getLayoutParams()).bottomMargin;
|
||||
this.enterAnimDuration = MotionUtils.resolveThemeDuration(v.getContext(), ENTER_ANIM_DURATION_ATTR, DEFAULT_ENTER_ANIMATION_DURATION_MS);
|
||||
this.exitAnimDuration = MotionUtils.resolveThemeDuration(v.getContext(), EXIT_ANIM_DURATION_ATTR, DEFAULT_EXIT_ANIMATION_DURATION_MS);
|
||||
Context context = v.getContext();
|
||||
int i2 = ENTER_EXIT_ANIM_EASING_ATTR;
|
||||
this.enterAnimInterpolator = MotionUtils.resolveThemeInterpolator(context, i2, AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
|
||||
this.exitAnimInterpolator = MotionUtils.resolveThemeInterpolator(v.getContext(), i2, AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR);
|
||||
return super.onLayoutChild(coordinatorLayout, v, i);
|
||||
}
|
||||
|
||||
public void setAdditionalHiddenOffsetY(V v, int i) {
|
||||
this.additionalHiddenOffsetY = i;
|
||||
if (this.currentState == 1) {
|
||||
v.setTranslationY(this.height + i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public void onNestedScroll(CoordinatorLayout coordinatorLayout, V v, View view, int i, int i2, int i3, int i4, int i5, int[] iArr) {
|
||||
if (i2 > 0) {
|
||||
slideDown(v);
|
||||
} else if (i2 < 0) {
|
||||
slideUp(v);
|
||||
}
|
||||
}
|
||||
|
||||
public void slideUp(V v) {
|
||||
slideUp(v, true);
|
||||
}
|
||||
|
||||
public void slideUp(V v, boolean z) {
|
||||
if (isScrolledUp()) {
|
||||
return;
|
||||
}
|
||||
ViewPropertyAnimator viewPropertyAnimator = this.currentAnimator;
|
||||
if (viewPropertyAnimator != null) {
|
||||
viewPropertyAnimator.cancel();
|
||||
v.clearAnimation();
|
||||
}
|
||||
updateCurrentState(v, 2);
|
||||
if (z) {
|
||||
animateChildTo(v, 0, this.enterAnimDuration, this.enterAnimInterpolator);
|
||||
} else {
|
||||
v.setTranslationY(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void slideDown(V v) {
|
||||
slideDown(v, true);
|
||||
}
|
||||
|
||||
public void slideDown(V v, boolean z) {
|
||||
if (isScrolledDown()) {
|
||||
return;
|
||||
}
|
||||
ViewPropertyAnimator viewPropertyAnimator = this.currentAnimator;
|
||||
if (viewPropertyAnimator != null) {
|
||||
viewPropertyAnimator.cancel();
|
||||
v.clearAnimation();
|
||||
}
|
||||
updateCurrentState(v, 1);
|
||||
int i = this.height + this.additionalHiddenOffsetY;
|
||||
if (z) {
|
||||
animateChildTo(v, i, this.exitAnimDuration, this.exitAnimInterpolator);
|
||||
} else {
|
||||
v.setTranslationY(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCurrentState(V v, int i) {
|
||||
this.currentState = i;
|
||||
Iterator<OnScrollStateChangedListener> it = this.onScrollStateChangedListeners.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onStateChanged(v, this.currentState);
|
||||
}
|
||||
}
|
||||
|
||||
private void animateChildTo(V v, int i, long j, TimeInterpolator timeInterpolator) {
|
||||
this.currentAnimator = v.animate().translationY(i).setInterpolator(timeInterpolator).setDuration(j).setListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.behavior.HideBottomViewOnScrollBehavior.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
HideBottomViewOnScrollBehavior.this.currentAnimator = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addOnScrollStateChangedListener(OnScrollStateChangedListener onScrollStateChangedListener) {
|
||||
this.onScrollStateChangedListeners.add(onScrollStateChangedListener);
|
||||
}
|
||||
|
||||
public void removeOnScrollStateChangedListener(OnScrollStateChangedListener onScrollStateChangedListener) {
|
||||
this.onScrollStateChangedListeners.remove(onScrollStateChangedListener);
|
||||
}
|
||||
|
||||
public void clearOnScrollStateChangedListeners() {
|
||||
this.onScrollStateChangedListeners.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
package com.google.android.material.behavior;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityViewCommand;
|
||||
import androidx.customview.widget.ViewDragHelper;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SwipeDismissBehavior<V extends View> extends CoordinatorLayout.Behavior<V> {
|
||||
private static final float DEFAULT_ALPHA_END_DISTANCE = 0.5f;
|
||||
private static final float DEFAULT_ALPHA_START_DISTANCE = 0.0f;
|
||||
private static final float DEFAULT_DRAG_DISMISS_THRESHOLD = 0.5f;
|
||||
public static final int STATE_DRAGGING = 1;
|
||||
public static final int STATE_IDLE = 0;
|
||||
public static final int STATE_SETTLING = 2;
|
||||
public static final int SWIPE_DIRECTION_ANY = 2;
|
||||
public static final int SWIPE_DIRECTION_END_TO_START = 1;
|
||||
public static final int SWIPE_DIRECTION_START_TO_END = 0;
|
||||
private boolean interceptingEvents;
|
||||
OnDismissListener listener;
|
||||
private boolean requestingDisallowInterceptTouchEvent;
|
||||
private boolean sensitivitySet;
|
||||
ViewDragHelper viewDragHelper;
|
||||
private float sensitivity = 0.0f;
|
||||
int swipeDirection = 2;
|
||||
float dragDismissThreshold = 0.5f;
|
||||
float alphaStartSwipeDistance = 0.0f;
|
||||
float alphaEndSwipeDistance = 0.5f;
|
||||
private final ViewDragHelper.Callback dragCallback = new ViewDragHelper.Callback() { // from class: com.google.android.material.behavior.SwipeDismissBehavior.1
|
||||
private static final int INVALID_POINTER_ID = -1;
|
||||
private int activePointerId = -1;
|
||||
private int originalCapturedViewLeft;
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public boolean tryCaptureView(View view, int i) {
|
||||
int i2 = this.activePointerId;
|
||||
return (i2 == -1 || i2 == i) && SwipeDismissBehavior.this.canSwipeDismissView(view);
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewCaptured(View view, int i) {
|
||||
this.activePointerId = i;
|
||||
this.originalCapturedViewLeft = view.getLeft();
|
||||
ViewParent parent = view.getParent();
|
||||
if (parent != null) {
|
||||
SwipeDismissBehavior.this.requestingDisallowInterceptTouchEvent = true;
|
||||
parent.requestDisallowInterceptTouchEvent(true);
|
||||
SwipeDismissBehavior.this.requestingDisallowInterceptTouchEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewDragStateChanged(int i) {
|
||||
if (SwipeDismissBehavior.this.listener != null) {
|
||||
SwipeDismissBehavior.this.listener.onDragStateChanged(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewReleased(View view, float f, float f2) {
|
||||
int i;
|
||||
boolean z;
|
||||
this.activePointerId = -1;
|
||||
int width = view.getWidth();
|
||||
if (shouldDismiss(view, f)) {
|
||||
if (f >= 0.0f) {
|
||||
int left = view.getLeft();
|
||||
int i2 = this.originalCapturedViewLeft;
|
||||
if (left >= i2) {
|
||||
i = i2 + width;
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
i = this.originalCapturedViewLeft - width;
|
||||
z = true;
|
||||
} else {
|
||||
i = this.originalCapturedViewLeft;
|
||||
z = false;
|
||||
}
|
||||
if (SwipeDismissBehavior.this.viewDragHelper.settleCapturedViewAt(i, view.getTop())) {
|
||||
ViewCompat.postOnAnimation(view, new SettleRunnable(view, z));
|
||||
} else {
|
||||
if (!z || SwipeDismissBehavior.this.listener == null) {
|
||||
return;
|
||||
}
|
||||
SwipeDismissBehavior.this.listener.onDismiss(view);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldDismiss(View view, float f) {
|
||||
if (f == 0.0f) {
|
||||
return Math.abs(view.getLeft() - this.originalCapturedViewLeft) >= Math.round(((float) view.getWidth()) * SwipeDismissBehavior.this.dragDismissThreshold);
|
||||
}
|
||||
boolean z = ViewCompat.getLayoutDirection(view) == 1;
|
||||
if (SwipeDismissBehavior.this.swipeDirection == 2) {
|
||||
return true;
|
||||
}
|
||||
if (SwipeDismissBehavior.this.swipeDirection == 0) {
|
||||
if (z) {
|
||||
if (f >= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
} else if (f <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (SwipeDismissBehavior.this.swipeDirection != 1) {
|
||||
return false;
|
||||
}
|
||||
if (z) {
|
||||
if (f <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
} else if (f >= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public int getViewHorizontalDragRange(View view) {
|
||||
return view.getWidth();
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public int clampViewPositionHorizontal(View view, int i, int i2) {
|
||||
int width;
|
||||
int width2;
|
||||
int width3;
|
||||
boolean z = ViewCompat.getLayoutDirection(view) == 1;
|
||||
if (SwipeDismissBehavior.this.swipeDirection == 0) {
|
||||
if (z) {
|
||||
width = this.originalCapturedViewLeft - view.getWidth();
|
||||
width2 = this.originalCapturedViewLeft;
|
||||
} else {
|
||||
width = this.originalCapturedViewLeft;
|
||||
width3 = view.getWidth();
|
||||
width2 = width3 + width;
|
||||
}
|
||||
} else if (SwipeDismissBehavior.this.swipeDirection != 1) {
|
||||
width = this.originalCapturedViewLeft - view.getWidth();
|
||||
width2 = view.getWidth() + this.originalCapturedViewLeft;
|
||||
} else if (z) {
|
||||
width = this.originalCapturedViewLeft;
|
||||
width3 = view.getWidth();
|
||||
width2 = width3 + width;
|
||||
} else {
|
||||
width = this.originalCapturedViewLeft - view.getWidth();
|
||||
width2 = this.originalCapturedViewLeft;
|
||||
}
|
||||
return SwipeDismissBehavior.clamp(width, i, width2);
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public int clampViewPositionVertical(View view, int i, int i2) {
|
||||
return view.getTop();
|
||||
}
|
||||
|
||||
@Override // androidx.customview.widget.ViewDragHelper.Callback
|
||||
public void onViewPositionChanged(View view, int i, int i2, int i3, int i4) {
|
||||
float width = view.getWidth() * SwipeDismissBehavior.this.alphaStartSwipeDistance;
|
||||
float width2 = view.getWidth() * SwipeDismissBehavior.this.alphaEndSwipeDistance;
|
||||
float abs = Math.abs(i - this.originalCapturedViewLeft);
|
||||
if (abs <= width) {
|
||||
view.setAlpha(1.0f);
|
||||
} else if (abs >= width2) {
|
||||
view.setAlpha(0.0f);
|
||||
} else {
|
||||
view.setAlpha(SwipeDismissBehavior.clamp(0.0f, 1.0f - SwipeDismissBehavior.fraction(width, width2, abs), 1.0f));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public interface OnDismissListener {
|
||||
void onDismiss(View view);
|
||||
|
||||
void onDragStateChanged(int i);
|
||||
}
|
||||
|
||||
static float fraction(float f, float f2, float f3) {
|
||||
return (f3 - f) / (f2 - f);
|
||||
}
|
||||
|
||||
public boolean canSwipeDismissView(View view) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public OnDismissListener getListener() {
|
||||
return this.listener;
|
||||
}
|
||||
|
||||
public void setListener(OnDismissListener onDismissListener) {
|
||||
this.listener = onDismissListener;
|
||||
}
|
||||
|
||||
public void setSensitivity(float f) {
|
||||
this.sensitivity = f;
|
||||
this.sensitivitySet = true;
|
||||
}
|
||||
|
||||
public void setSwipeDirection(int i) {
|
||||
this.swipeDirection = i;
|
||||
}
|
||||
|
||||
public void setDragDismissDistance(float f) {
|
||||
this.dragDismissThreshold = clamp(0.0f, f, 1.0f);
|
||||
}
|
||||
|
||||
public void setStartAlphaSwipeDistance(float f) {
|
||||
this.alphaStartSwipeDistance = clamp(0.0f, f, 1.0f);
|
||||
}
|
||||
|
||||
public void setEndAlphaSwipeDistance(float f) {
|
||||
this.alphaEndSwipeDistance = clamp(0.0f, f, 1.0f);
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onLayoutChild(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
boolean onLayoutChild = super.onLayoutChild(coordinatorLayout, v, i);
|
||||
if (ViewCompat.getImportantForAccessibility(v) == 0) {
|
||||
ViewCompat.setImportantForAccessibility(v, 1);
|
||||
updateAccessibilityActions(v);
|
||||
}
|
||||
return onLayoutChild;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onInterceptTouchEvent(CoordinatorLayout coordinatorLayout, V v, MotionEvent motionEvent) {
|
||||
boolean z = this.interceptingEvents;
|
||||
int actionMasked = motionEvent.getActionMasked();
|
||||
if (actionMasked == 0) {
|
||||
z = coordinatorLayout.isPointInChildBounds(v, (int) motionEvent.getX(), (int) motionEvent.getY());
|
||||
this.interceptingEvents = z;
|
||||
} else if (actionMasked == 1 || actionMasked == 3) {
|
||||
this.interceptingEvents = false;
|
||||
}
|
||||
if (!z) {
|
||||
return false;
|
||||
}
|
||||
ensureViewDragHelper(coordinatorLayout);
|
||||
return !this.requestingDisallowInterceptTouchEvent && this.viewDragHelper.shouldInterceptTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onTouchEvent(CoordinatorLayout coordinatorLayout, V v, MotionEvent motionEvent) {
|
||||
if (this.viewDragHelper == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.requestingDisallowInterceptTouchEvent && motionEvent.getActionMasked() == 3) {
|
||||
return true;
|
||||
}
|
||||
this.viewDragHelper.processTouchEvent(motionEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ensureViewDragHelper(ViewGroup viewGroup) {
|
||||
ViewDragHelper create;
|
||||
if (this.viewDragHelper == null) {
|
||||
if (this.sensitivitySet) {
|
||||
create = ViewDragHelper.create(viewGroup, this.sensitivity, this.dragCallback);
|
||||
} else {
|
||||
create = ViewDragHelper.create(viewGroup, this.dragCallback);
|
||||
}
|
||||
this.viewDragHelper = create;
|
||||
}
|
||||
}
|
||||
|
||||
private class SettleRunnable implements Runnable {
|
||||
private final boolean dismiss;
|
||||
private final View view;
|
||||
|
||||
SettleRunnable(View view, boolean z) {
|
||||
this.view = view;
|
||||
this.dismiss = z;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (SwipeDismissBehavior.this.viewDragHelper != null && SwipeDismissBehavior.this.viewDragHelper.continueSettling(true)) {
|
||||
ViewCompat.postOnAnimation(this.view, this);
|
||||
} else {
|
||||
if (!this.dismiss || SwipeDismissBehavior.this.listener == null) {
|
||||
return;
|
||||
}
|
||||
SwipeDismissBehavior.this.listener.onDismiss(this.view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAccessibilityActions(View view) {
|
||||
ViewCompat.removeAccessibilityAction(view, 1048576);
|
||||
if (canSwipeDismissView(view)) {
|
||||
ViewCompat.replaceAccessibilityAction(view, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_DISMISS, null, new AccessibilityViewCommand() { // from class: com.google.android.material.behavior.SwipeDismissBehavior.2
|
||||
@Override // androidx.core.view.accessibility.AccessibilityViewCommand
|
||||
public boolean perform(View view2, AccessibilityViewCommand.CommandArguments commandArguments) {
|
||||
if (!SwipeDismissBehavior.this.canSwipeDismissView(view2)) {
|
||||
return false;
|
||||
}
|
||||
boolean z = ViewCompat.getLayoutDirection(view2) == 1;
|
||||
ViewCompat.offsetLeftAndRight(view2, (!(SwipeDismissBehavior.this.swipeDirection == 0 && z) && (SwipeDismissBehavior.this.swipeDirection != 1 || z)) ? view2.getWidth() : -view2.getWidth());
|
||||
view2.setAlpha(0.0f);
|
||||
if (SwipeDismissBehavior.this.listener != null) {
|
||||
SwipeDismissBehavior.this.listener.onDismiss(view2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static float clamp(float f, float f2, float f3) {
|
||||
return Math.min(Math.max(f, f2), f3);
|
||||
}
|
||||
|
||||
static int clamp(int i, int i2, int i3) {
|
||||
return Math.min(Math.max(i, i2), i3);
|
||||
}
|
||||
|
||||
public int getDragState() {
|
||||
ViewDragHelper viewDragHelper = this.viewDragHelper;
|
||||
if (viewDragHelper != null) {
|
||||
return viewDragHelper.getViewDragState();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,920 @@
|
||||
package com.google.android.material.bottomappbar;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.appcompat.widget.ActionMenuView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.customview.view.AbsSavedState;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.animation.TransformationCallback;
|
||||
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior;
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import com.google.android.material.motion.MotionUtils;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.MaterialShapeUtils;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BottomAppBar extends Toolbar implements CoordinatorLayout.AttachedBehavior {
|
||||
private static final int FAB_ALIGNMENT_ANIM_DURATION_DEFAULT = 300;
|
||||
private static final float FAB_ALIGNMENT_ANIM_EASING_MIDPOINT = 0.2f;
|
||||
public static final int FAB_ALIGNMENT_MODE_CENTER = 0;
|
||||
public static final int FAB_ALIGNMENT_MODE_END = 1;
|
||||
public static final int FAB_ANCHOR_MODE_CRADLE = 1;
|
||||
public static final int FAB_ANCHOR_MODE_EMBED = 0;
|
||||
public static final int FAB_ANIMATION_MODE_SCALE = 0;
|
||||
public static final int FAB_ANIMATION_MODE_SLIDE = 1;
|
||||
public static final int MENU_ALIGNMENT_MODE_AUTO = 0;
|
||||
public static final int MENU_ALIGNMENT_MODE_START = 1;
|
||||
private static final int NO_FAB_END_MARGIN = -1;
|
||||
private static final int NO_MENU_RES_ID = 0;
|
||||
private int animatingModeChangeCounter;
|
||||
private ArrayList<AnimationListener> animationListeners;
|
||||
private Behavior behavior;
|
||||
private int bottomInset;
|
||||
private int fabAlignmentMode;
|
||||
private int fabAlignmentModeEndMargin;
|
||||
private int fabAnchorMode;
|
||||
AnimatorListenerAdapter fabAnimationListener;
|
||||
private int fabAnimationMode;
|
||||
private boolean fabAttached;
|
||||
private final int fabOffsetEndMode;
|
||||
TransformationCallback<FloatingActionButton> fabTransformationCallback;
|
||||
private boolean hideOnScroll;
|
||||
private int leftInset;
|
||||
private final MaterialShapeDrawable materialShapeDrawable;
|
||||
private int menuAlignmentMode;
|
||||
private boolean menuAnimatingWithFabAlignmentMode;
|
||||
private Animator menuAnimator;
|
||||
private Animator modeAnimator;
|
||||
private Integer navigationIconTint;
|
||||
private final boolean paddingBottomSystemWindowInsets;
|
||||
private final boolean paddingLeftSystemWindowInsets;
|
||||
private final boolean paddingRightSystemWindowInsets;
|
||||
private int pendingMenuResId;
|
||||
private final boolean removeEmbeddedFabElevation;
|
||||
private int rightInset;
|
||||
private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_BottomAppBar;
|
||||
private static final int FAB_ALIGNMENT_ANIM_DURATION_ATTR = R.attr.motionDurationLong2;
|
||||
private static final int FAB_ALIGNMENT_ANIM_EASING_ATTR = R.attr.motionEasingEmphasizedInterpolator;
|
||||
|
||||
interface AnimationListener {
|
||||
void onAnimationEnd(BottomAppBar bottomAppBar);
|
||||
|
||||
void onAnimationStart(BottomAppBar bottomAppBar);
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FabAlignmentMode {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FabAnchorMode {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FabAnimationMode {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface MenuAlignmentMode {
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getBottomInset() {
|
||||
return this.bottomInset;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getLeftInset() {
|
||||
return this.leftInset;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getRightInset() {
|
||||
return this.rightInset;
|
||||
}
|
||||
|
||||
public int getFabAlignmentMode() {
|
||||
return this.fabAlignmentMode;
|
||||
}
|
||||
|
||||
public int getFabAlignmentModeEndMargin() {
|
||||
return this.fabAlignmentModeEndMargin;
|
||||
}
|
||||
|
||||
public int getFabAnchorMode() {
|
||||
return this.fabAnchorMode;
|
||||
}
|
||||
|
||||
public int getFabAnimationMode() {
|
||||
return this.fabAnimationMode;
|
||||
}
|
||||
|
||||
public boolean getHideOnScroll() {
|
||||
return this.hideOnScroll;
|
||||
}
|
||||
|
||||
public int getMenuAlignmentMode() {
|
||||
return this.menuAlignmentMode;
|
||||
}
|
||||
|
||||
public void setFabAnimationMode(int i) {
|
||||
this.fabAnimationMode = i;
|
||||
}
|
||||
|
||||
public void setHideOnScroll(boolean z) {
|
||||
this.hideOnScroll = z;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar
|
||||
public void setSubtitle(CharSequence charSequence) {
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar
|
||||
public void setTitle(CharSequence charSequence) {
|
||||
}
|
||||
|
||||
public BottomAppBar(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BottomAppBar(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.bottomAppBarStyle);
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public BottomAppBar(android.content.Context r13, android.util.AttributeSet r14, int r15) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 277
|
||||
To view this dump add '--comments-level debug' option
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomappbar.BottomAppBar.<init>(android.content.Context, android.util.AttributeSet, int):void");
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar
|
||||
public void setNavigationIcon(Drawable drawable) {
|
||||
super.setNavigationIcon(maybeTintNavigationIcon(drawable));
|
||||
}
|
||||
|
||||
public void setNavigationIconTint(int i) {
|
||||
this.navigationIconTint = Integer.valueOf(i);
|
||||
Drawable navigationIcon = getNavigationIcon();
|
||||
if (navigationIcon != null) {
|
||||
setNavigationIcon(navigationIcon);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFabAlignmentMode(int i) {
|
||||
setFabAlignmentModeAndReplaceMenu(i, 0);
|
||||
}
|
||||
|
||||
public void setFabAlignmentModeAndReplaceMenu(int i, int i2) {
|
||||
this.pendingMenuResId = i2;
|
||||
this.menuAnimatingWithFabAlignmentMode = true;
|
||||
maybeAnimateMenuView(i, this.fabAttached);
|
||||
maybeAnimateModeChange(i);
|
||||
this.fabAlignmentMode = i;
|
||||
}
|
||||
|
||||
public void setFabAnchorMode(int i) {
|
||||
this.fabAnchorMode = i;
|
||||
setCutoutStateAndTranslateFab();
|
||||
View findDependentView = findDependentView();
|
||||
if (findDependentView != null) {
|
||||
updateFabAnchorGravity(this, findDependentView);
|
||||
findDependentView.requestLayout();
|
||||
this.materialShapeDrawable.invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static void updateFabAnchorGravity(BottomAppBar bottomAppBar, View view) {
|
||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
|
||||
layoutParams.anchorGravity = 17;
|
||||
if (bottomAppBar.fabAnchorMode == 1) {
|
||||
layoutParams.anchorGravity |= 48;
|
||||
}
|
||||
if (bottomAppBar.fabAnchorMode == 0) {
|
||||
layoutParams.anchorGravity |= 80;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMenuAlignmentMode(int i) {
|
||||
if (this.menuAlignmentMode != i) {
|
||||
this.menuAlignmentMode = i;
|
||||
ActionMenuView actionMenuView = getActionMenuView();
|
||||
if (actionMenuView != null) {
|
||||
translateActionMenuView(actionMenuView, this.fabAlignmentMode, isFabVisibleOrWillBeShown());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBackgroundTint(ColorStateList colorStateList) {
|
||||
DrawableCompat.setTintList(this.materialShapeDrawable, colorStateList);
|
||||
}
|
||||
|
||||
public ColorStateList getBackgroundTint() {
|
||||
return this.materialShapeDrawable.getTintList();
|
||||
}
|
||||
|
||||
public float getFabCradleMargin() {
|
||||
return getTopEdgeTreatment().getFabCradleMargin();
|
||||
}
|
||||
|
||||
public void setFabCradleMargin(float f) {
|
||||
if (f != getFabCradleMargin()) {
|
||||
getTopEdgeTreatment().setFabCradleMargin(f);
|
||||
this.materialShapeDrawable.invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
public float getFabCradleRoundedCornerRadius() {
|
||||
return getTopEdgeTreatment().getFabCradleRoundedCornerRadius();
|
||||
}
|
||||
|
||||
public void setFabCradleRoundedCornerRadius(float f) {
|
||||
if (f != getFabCradleRoundedCornerRadius()) {
|
||||
getTopEdgeTreatment().setFabCradleRoundedCornerRadius(f);
|
||||
this.materialShapeDrawable.invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
public float getCradleVerticalOffset() {
|
||||
return getTopEdgeTreatment().getCradleVerticalOffset();
|
||||
}
|
||||
|
||||
public void setCradleVerticalOffset(float f) {
|
||||
if (f != getCradleVerticalOffset()) {
|
||||
getTopEdgeTreatment().setCradleVerticalOffset(f);
|
||||
this.materialShapeDrawable.invalidateSelf();
|
||||
setCutoutStateAndTranslateFab();
|
||||
}
|
||||
}
|
||||
|
||||
public void setFabAlignmentModeEndMargin(int i) {
|
||||
if (this.fabAlignmentModeEndMargin != i) {
|
||||
this.fabAlignmentModeEndMargin = i;
|
||||
setCutoutStateAndTranslateFab();
|
||||
}
|
||||
}
|
||||
|
||||
public void performHide() {
|
||||
performHide(true);
|
||||
}
|
||||
|
||||
public void performHide(boolean z) {
|
||||
getBehavior().slideDown(this, z);
|
||||
}
|
||||
|
||||
public void performShow() {
|
||||
performShow(true);
|
||||
}
|
||||
|
||||
public void performShow(boolean z) {
|
||||
getBehavior().slideUp(this, z);
|
||||
}
|
||||
|
||||
public boolean isScrolledDown() {
|
||||
return getBehavior().isScrolledDown();
|
||||
}
|
||||
|
||||
public boolean isScrolledUp() {
|
||||
return getBehavior().isScrolledUp();
|
||||
}
|
||||
|
||||
public void addOnScrollStateChangedListener(HideBottomViewOnScrollBehavior.OnScrollStateChangedListener onScrollStateChangedListener) {
|
||||
getBehavior().addOnScrollStateChangedListener(onScrollStateChangedListener);
|
||||
}
|
||||
|
||||
public void removeOnScrollStateChangedListener(HideBottomViewOnScrollBehavior.OnScrollStateChangedListener onScrollStateChangedListener) {
|
||||
getBehavior().removeOnScrollStateChangedListener(onScrollStateChangedListener);
|
||||
}
|
||||
|
||||
public void clearOnScrollStateChangedListeners() {
|
||||
getBehavior().clearOnScrollStateChangedListeners();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setElevation(float f) {
|
||||
this.materialShapeDrawable.setElevation(f);
|
||||
getBehavior().setAdditionalHiddenOffsetY(this, this.materialShapeDrawable.getShadowRadius() - this.materialShapeDrawable.getShadowOffsetY());
|
||||
}
|
||||
|
||||
public void replaceMenu(int i) {
|
||||
if (i != 0) {
|
||||
this.pendingMenuResId = 0;
|
||||
getMenu().clear();
|
||||
inflateMenu(i);
|
||||
}
|
||||
}
|
||||
|
||||
void addAnimationListener(AnimationListener animationListener) {
|
||||
if (this.animationListeners == null) {
|
||||
this.animationListeners = new ArrayList<>();
|
||||
}
|
||||
this.animationListeners.add(animationListener);
|
||||
}
|
||||
|
||||
void removeAnimationListener(AnimationListener animationListener) {
|
||||
ArrayList<AnimationListener> arrayList = this.animationListeners;
|
||||
if (arrayList == null) {
|
||||
return;
|
||||
}
|
||||
arrayList.remove(animationListener);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void dispatchAnimationStart() {
|
||||
ArrayList<AnimationListener> arrayList;
|
||||
int i = this.animatingModeChangeCounter;
|
||||
this.animatingModeChangeCounter = i + 1;
|
||||
if (i != 0 || (arrayList = this.animationListeners) == null) {
|
||||
return;
|
||||
}
|
||||
Iterator<AnimationListener> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onAnimationStart(this);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void dispatchAnimationEnd() {
|
||||
ArrayList<AnimationListener> arrayList;
|
||||
int i = this.animatingModeChangeCounter - 1;
|
||||
this.animatingModeChangeCounter = i;
|
||||
if (i != 0 || (arrayList = this.animationListeners) == null) {
|
||||
return;
|
||||
}
|
||||
Iterator<AnimationListener> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onAnimationEnd(this);
|
||||
}
|
||||
}
|
||||
|
||||
boolean setFabDiameter(int i) {
|
||||
float f = i;
|
||||
if (f == getTopEdgeTreatment().getFabDiameter()) {
|
||||
return false;
|
||||
}
|
||||
getTopEdgeTreatment().setFabDiameter(f);
|
||||
this.materialShapeDrawable.invalidateSelf();
|
||||
return true;
|
||||
}
|
||||
|
||||
void setFabCornerSize(float f) {
|
||||
if (f != getTopEdgeTreatment().getFabCornerRadius()) {
|
||||
getTopEdgeTreatment().setFabCornerSize(f);
|
||||
this.materialShapeDrawable.invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
private void maybeAnimateModeChange(int i) {
|
||||
if (this.fabAlignmentMode == i || !ViewCompat.isLaidOut(this)) {
|
||||
return;
|
||||
}
|
||||
Animator animator = this.modeAnimator;
|
||||
if (animator != null) {
|
||||
animator.cancel();
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (this.fabAnimationMode == 1) {
|
||||
createFabTranslationXAnimation(i, arrayList);
|
||||
} else {
|
||||
createFabDefaultXAnimation(i, arrayList);
|
||||
}
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(arrayList);
|
||||
animatorSet.setInterpolator(MotionUtils.resolveThemeInterpolator(getContext(), FAB_ALIGNMENT_ANIM_EASING_ATTR, AnimationUtils.LINEAR_INTERPOLATOR));
|
||||
this.modeAnimator = animatorSet;
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.bottomappbar.BottomAppBar.4
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator2) {
|
||||
BottomAppBar.this.dispatchAnimationStart();
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator2) {
|
||||
BottomAppBar.this.dispatchAnimationEnd();
|
||||
BottomAppBar.this.modeAnimator = null;
|
||||
}
|
||||
});
|
||||
this.modeAnimator.start();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public FloatingActionButton findDependentFab() {
|
||||
View findDependentView = findDependentView();
|
||||
if (findDependentView instanceof FloatingActionButton) {
|
||||
return (FloatingActionButton) findDependentView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public View findDependentView() {
|
||||
if (!(getParent() instanceof CoordinatorLayout)) {
|
||||
return null;
|
||||
}
|
||||
for (View view : ((CoordinatorLayout) getParent()).getDependents(this)) {
|
||||
if ((view instanceof FloatingActionButton) || (view instanceof ExtendedFloatingActionButton)) {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isFabVisibleOrWillBeShown() {
|
||||
FloatingActionButton findDependentFab = findDependentFab();
|
||||
return findDependentFab != null && findDependentFab.isOrWillBeShown();
|
||||
}
|
||||
|
||||
protected void createFabDefaultXAnimation(final int i, List<Animator> list) {
|
||||
FloatingActionButton findDependentFab = findDependentFab();
|
||||
if (findDependentFab == null || findDependentFab.isOrWillBeHidden()) {
|
||||
return;
|
||||
}
|
||||
dispatchAnimationStart();
|
||||
findDependentFab.hide(new FloatingActionButton.OnVisibilityChangedListener() { // from class: com.google.android.material.bottomappbar.BottomAppBar.5
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButton.OnVisibilityChangedListener
|
||||
public void onHidden(FloatingActionButton floatingActionButton) {
|
||||
floatingActionButton.setTranslationX(BottomAppBar.this.getFabTranslationX(i));
|
||||
floatingActionButton.show(new FloatingActionButton.OnVisibilityChangedListener() { // from class: com.google.android.material.bottomappbar.BottomAppBar.5.1
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButton.OnVisibilityChangedListener
|
||||
public void onShown(FloatingActionButton floatingActionButton2) {
|
||||
BottomAppBar.this.dispatchAnimationEnd();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createFabTranslationXAnimation(int i, List<Animator> list) {
|
||||
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(findDependentFab(), "translationX", getFabTranslationX(i));
|
||||
ofFloat.setDuration(getFabAlignmentAnimationDuration());
|
||||
list.add(ofFloat);
|
||||
}
|
||||
|
||||
private int getFabAlignmentAnimationDuration() {
|
||||
return MotionUtils.resolveThemeDuration(getContext(), FAB_ALIGNMENT_ANIM_DURATION_ATTR, 300);
|
||||
}
|
||||
|
||||
private Drawable maybeTintNavigationIcon(Drawable drawable) {
|
||||
if (drawable == null || this.navigationIconTint == null) {
|
||||
return drawable;
|
||||
}
|
||||
Drawable wrap = DrawableCompat.wrap(drawable.mutate());
|
||||
DrawableCompat.setTint(wrap, this.navigationIconTint.intValue());
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void maybeAnimateMenuView(int i, boolean z) {
|
||||
if (!ViewCompat.isLaidOut(this)) {
|
||||
this.menuAnimatingWithFabAlignmentMode = false;
|
||||
replaceMenu(this.pendingMenuResId);
|
||||
return;
|
||||
}
|
||||
Animator animator = this.menuAnimator;
|
||||
if (animator != null) {
|
||||
animator.cancel();
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (!isFabVisibleOrWillBeShown()) {
|
||||
i = 0;
|
||||
z = false;
|
||||
}
|
||||
createMenuViewTranslationAnimation(i, z, arrayList);
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(arrayList);
|
||||
this.menuAnimator = animatorSet;
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.bottomappbar.BottomAppBar.6
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator2) {
|
||||
BottomAppBar.this.dispatchAnimationStart();
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator2) {
|
||||
BottomAppBar.this.dispatchAnimationEnd();
|
||||
BottomAppBar.this.menuAnimatingWithFabAlignmentMode = false;
|
||||
BottomAppBar.this.menuAnimator = null;
|
||||
}
|
||||
});
|
||||
this.menuAnimator.start();
|
||||
}
|
||||
|
||||
private void createMenuViewTranslationAnimation(final int i, final boolean z, List<Animator> list) {
|
||||
final ActionMenuView actionMenuView = getActionMenuView();
|
||||
if (actionMenuView == null) {
|
||||
return;
|
||||
}
|
||||
float fabAlignmentAnimationDuration = getFabAlignmentAnimationDuration();
|
||||
Animator ofFloat = ObjectAnimator.ofFloat(actionMenuView, "alpha", 1.0f);
|
||||
ofFloat.setDuration((long) (0.8f * fabAlignmentAnimationDuration));
|
||||
if (Math.abs(actionMenuView.getTranslationX() - getActionMenuViewTranslationX(actionMenuView, i, z)) <= 1.0f) {
|
||||
if (actionMenuView.getAlpha() < 1.0f) {
|
||||
list.add(ofFloat);
|
||||
}
|
||||
} else {
|
||||
ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(actionMenuView, "alpha", 0.0f);
|
||||
ofFloat2.setDuration((long) (fabAlignmentAnimationDuration * 0.2f));
|
||||
ofFloat2.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.bottomappbar.BottomAppBar.7
|
||||
public boolean cancelled;
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
this.cancelled = true;
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
if (this.cancelled) {
|
||||
return;
|
||||
}
|
||||
boolean z2 = BottomAppBar.this.pendingMenuResId != 0;
|
||||
BottomAppBar bottomAppBar = BottomAppBar.this;
|
||||
bottomAppBar.replaceMenu(bottomAppBar.pendingMenuResId);
|
||||
BottomAppBar.this.translateActionMenuView(actionMenuView, i, z, z2);
|
||||
}
|
||||
});
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playSequentially(ofFloat2, ofFloat);
|
||||
list.add(animatorSet);
|
||||
}
|
||||
}
|
||||
|
||||
private float getFabTranslationY() {
|
||||
if (this.fabAnchorMode == 1) {
|
||||
return -getTopEdgeTreatment().getCradleVerticalOffset();
|
||||
}
|
||||
return findDependentView() != null ? (-((getMeasuredHeight() + getBottomInset()) - r0.getMeasuredHeight())) / 2 : 0;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public float getFabTranslationX(int i) {
|
||||
boolean isLayoutRtl = ViewUtils.isLayoutRtl(this);
|
||||
if (i != 1) {
|
||||
return 0.0f;
|
||||
}
|
||||
return ((getMeasuredWidth() / 2) - ((isLayoutRtl ? this.leftInset : this.rightInset) + ((this.fabAlignmentModeEndMargin == -1 || findDependentView() == null) ? this.fabOffsetEndMode : (r6.getMeasuredWidth() / 2) + this.fabAlignmentModeEndMargin))) * (isLayoutRtl ? -1 : 1);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public float getFabTranslationX() {
|
||||
return getFabTranslationX(this.fabAlignmentMode);
|
||||
}
|
||||
|
||||
private ActionMenuView getActionMenuView() {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View childAt = getChildAt(i);
|
||||
if (childAt instanceof ActionMenuView) {
|
||||
return (ActionMenuView) childAt;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void translateActionMenuView(ActionMenuView actionMenuView, int i, boolean z) {
|
||||
translateActionMenuView(actionMenuView, i, z, false);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void translateActionMenuView(final ActionMenuView actionMenuView, final int i, final boolean z, boolean z2) {
|
||||
Runnable runnable = new Runnable() { // from class: com.google.android.material.bottomappbar.BottomAppBar.8
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
actionMenuView.setTranslationX(BottomAppBar.this.getActionMenuViewTranslationX(r0, i, z));
|
||||
}
|
||||
};
|
||||
if (z2) {
|
||||
actionMenuView.post(runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
protected int getActionMenuViewTranslationX(ActionMenuView actionMenuView, int i, boolean z) {
|
||||
int i2 = 0;
|
||||
if (this.menuAlignmentMode != 1 && (i != 1 || !z)) {
|
||||
return 0;
|
||||
}
|
||||
boolean isLayoutRtl = ViewUtils.isLayoutRtl(this);
|
||||
int measuredWidth = isLayoutRtl ? getMeasuredWidth() : 0;
|
||||
for (int i3 = 0; i3 < getChildCount(); i3++) {
|
||||
View childAt = getChildAt(i3);
|
||||
if ((childAt.getLayoutParams() instanceof Toolbar.LayoutParams) && (((Toolbar.LayoutParams) childAt.getLayoutParams()).gravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 8388611) {
|
||||
if (isLayoutRtl) {
|
||||
measuredWidth = Math.min(measuredWidth, childAt.getLeft());
|
||||
} else {
|
||||
measuredWidth = Math.max(measuredWidth, childAt.getRight());
|
||||
}
|
||||
}
|
||||
}
|
||||
int right = isLayoutRtl ? actionMenuView.getRight() : actionMenuView.getLeft();
|
||||
int i4 = isLayoutRtl ? this.rightInset : -this.leftInset;
|
||||
if (getNavigationIcon() == null) {
|
||||
i2 = getResources().getDimensionPixelOffset(R.dimen.m3_bottomappbar_horizontal_padding);
|
||||
if (!isLayoutRtl) {
|
||||
i2 = -i2;
|
||||
}
|
||||
}
|
||||
return measuredWidth - ((right + i4) + i2);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void cancelAnimations() {
|
||||
Animator animator = this.menuAnimator;
|
||||
if (animator != null) {
|
||||
animator.cancel();
|
||||
}
|
||||
Animator animator2 = this.modeAnimator;
|
||||
if (animator2 != null) {
|
||||
animator2.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar, 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);
|
||||
if (z) {
|
||||
cancelAnimations();
|
||||
setCutoutStateAndTranslateFab();
|
||||
final View findDependentView = findDependentView();
|
||||
if (findDependentView != null && ViewCompat.isLaidOut(findDependentView)) {
|
||||
findDependentView.post(new Runnable() { // from class: com.google.android.material.bottomappbar.BottomAppBar$$ExternalSyntheticLambda2
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
findDependentView.requestLayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
setActionMenuViewPosition();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public BottomAppBarTopEdgeTreatment getTopEdgeTreatment() {
|
||||
return (BottomAppBarTopEdgeTreatment) this.materialShapeDrawable.getShapeAppearanceModel().getTopEdge();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setCutoutStateAndTranslateFab() {
|
||||
getTopEdgeTreatment().setHorizontalOffset(getFabTranslationX());
|
||||
this.materialShapeDrawable.setInterpolation((this.fabAttached && isFabVisibleOrWillBeShown() && this.fabAnchorMode == 1) ? 1.0f : 0.0f);
|
||||
View findDependentView = findDependentView();
|
||||
if (findDependentView != null) {
|
||||
findDependentView.setTranslationY(getFabTranslationY());
|
||||
findDependentView.setTranslationX(getFabTranslationX());
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setActionMenuViewPosition() {
|
||||
ActionMenuView actionMenuView = getActionMenuView();
|
||||
if (actionMenuView == null || this.menuAnimator != null) {
|
||||
return;
|
||||
}
|
||||
actionMenuView.setAlpha(1.0f);
|
||||
if (!isFabVisibleOrWillBeShown()) {
|
||||
translateActionMenuView(actionMenuView, 0, false);
|
||||
} else {
|
||||
translateActionMenuView(actionMenuView, this.fabAlignmentMode, this.fabAttached);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void addFabAnimationListeners(FloatingActionButton floatingActionButton) {
|
||||
floatingActionButton.addOnHideAnimationListener(this.fabAnimationListener);
|
||||
floatingActionButton.addOnShowAnimationListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.bottomappbar.BottomAppBar.9
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
BottomAppBar.this.fabAnimationListener.onAnimationStart(animator);
|
||||
FloatingActionButton findDependentFab = BottomAppBar.this.findDependentFab();
|
||||
if (findDependentFab != null) {
|
||||
findDependentFab.setTranslationX(BottomAppBar.this.getFabTranslationX());
|
||||
}
|
||||
}
|
||||
});
|
||||
floatingActionButton.addTransformationCallback(this.fabTransformationCallback);
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.AttachedBehavior
|
||||
public Behavior getBehavior() {
|
||||
if (this.behavior == null) {
|
||||
this.behavior = new Behavior();
|
||||
}
|
||||
return this.behavior;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar, android.view.ViewGroup, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
MaterialShapeUtils.setParentAbsoluteElevation(this, this.materialShapeDrawable);
|
||||
if (getParent() instanceof ViewGroup) {
|
||||
((ViewGroup) getParent()).setClipChildren(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Behavior extends HideBottomViewOnScrollBehavior<BottomAppBar> {
|
||||
private final Rect fabContentRect;
|
||||
private final View.OnLayoutChangeListener fabLayoutListener;
|
||||
private int originalBottomMargin;
|
||||
private WeakReference<BottomAppBar> viewRef;
|
||||
|
||||
public Behavior() {
|
||||
this.fabLayoutListener = new View.OnLayoutChangeListener() { // from class: com.google.android.material.bottomappbar.BottomAppBar.Behavior.1
|
||||
@Override // android.view.View.OnLayoutChangeListener
|
||||
public void onLayoutChange(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
|
||||
boolean z;
|
||||
BottomAppBar bottomAppBar = (BottomAppBar) Behavior.this.viewRef.get();
|
||||
if (bottomAppBar == null || (!((z = view instanceof FloatingActionButton)) && !(view instanceof ExtendedFloatingActionButton))) {
|
||||
view.removeOnLayoutChangeListener(this);
|
||||
return;
|
||||
}
|
||||
int height = view.getHeight();
|
||||
if (z) {
|
||||
FloatingActionButton floatingActionButton = (FloatingActionButton) view;
|
||||
floatingActionButton.getMeasuredContentRect(Behavior.this.fabContentRect);
|
||||
height = Behavior.this.fabContentRect.height();
|
||||
bottomAppBar.setFabDiameter(height);
|
||||
bottomAppBar.setFabCornerSize(floatingActionButton.getShapeAppearanceModel().getTopLeftCornerSize().getCornerSize(new RectF(Behavior.this.fabContentRect)));
|
||||
}
|
||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
|
||||
if (Behavior.this.originalBottomMargin == 0) {
|
||||
if (bottomAppBar.fabAnchorMode == 1) {
|
||||
layoutParams.bottomMargin = bottomAppBar.getBottomInset() + (bottomAppBar.getResources().getDimensionPixelOffset(R.dimen.mtrl_bottomappbar_fab_bottom_margin) - ((view.getMeasuredHeight() - height) / 2));
|
||||
}
|
||||
layoutParams.leftMargin = bottomAppBar.getLeftInset();
|
||||
layoutParams.rightMargin = bottomAppBar.getRightInset();
|
||||
if (ViewUtils.isLayoutRtl(view)) {
|
||||
layoutParams.leftMargin += bottomAppBar.fabOffsetEndMode;
|
||||
} else {
|
||||
layoutParams.rightMargin += bottomAppBar.fabOffsetEndMode;
|
||||
}
|
||||
}
|
||||
bottomAppBar.setCutoutStateAndTranslateFab();
|
||||
}
|
||||
};
|
||||
this.fabContentRect = new Rect();
|
||||
}
|
||||
|
||||
public Behavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.fabLayoutListener = new View.OnLayoutChangeListener() { // from class: com.google.android.material.bottomappbar.BottomAppBar.Behavior.1
|
||||
@Override // android.view.View.OnLayoutChangeListener
|
||||
public void onLayoutChange(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
|
||||
boolean z;
|
||||
BottomAppBar bottomAppBar = (BottomAppBar) Behavior.this.viewRef.get();
|
||||
if (bottomAppBar == null || (!((z = view instanceof FloatingActionButton)) && !(view instanceof ExtendedFloatingActionButton))) {
|
||||
view.removeOnLayoutChangeListener(this);
|
||||
return;
|
||||
}
|
||||
int height = view.getHeight();
|
||||
if (z) {
|
||||
FloatingActionButton floatingActionButton = (FloatingActionButton) view;
|
||||
floatingActionButton.getMeasuredContentRect(Behavior.this.fabContentRect);
|
||||
height = Behavior.this.fabContentRect.height();
|
||||
bottomAppBar.setFabDiameter(height);
|
||||
bottomAppBar.setFabCornerSize(floatingActionButton.getShapeAppearanceModel().getTopLeftCornerSize().getCornerSize(new RectF(Behavior.this.fabContentRect)));
|
||||
}
|
||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
|
||||
if (Behavior.this.originalBottomMargin == 0) {
|
||||
if (bottomAppBar.fabAnchorMode == 1) {
|
||||
layoutParams.bottomMargin = bottomAppBar.getBottomInset() + (bottomAppBar.getResources().getDimensionPixelOffset(R.dimen.mtrl_bottomappbar_fab_bottom_margin) - ((view.getMeasuredHeight() - height) / 2));
|
||||
}
|
||||
layoutParams.leftMargin = bottomAppBar.getLeftInset();
|
||||
layoutParams.rightMargin = bottomAppBar.getRightInset();
|
||||
if (ViewUtils.isLayoutRtl(view)) {
|
||||
layoutParams.leftMargin += bottomAppBar.fabOffsetEndMode;
|
||||
} else {
|
||||
layoutParams.rightMargin += bottomAppBar.fabOffsetEndMode;
|
||||
}
|
||||
}
|
||||
bottomAppBar.setCutoutStateAndTranslateFab();
|
||||
}
|
||||
};
|
||||
this.fabContentRect = new Rect();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.behavior.HideBottomViewOnScrollBehavior, androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onLayoutChild(CoordinatorLayout coordinatorLayout, BottomAppBar bottomAppBar, int i) {
|
||||
this.viewRef = new WeakReference<>(bottomAppBar);
|
||||
View findDependentView = bottomAppBar.findDependentView();
|
||||
if (findDependentView != null && !ViewCompat.isLaidOut(findDependentView)) {
|
||||
BottomAppBar.updateFabAnchorGravity(bottomAppBar, findDependentView);
|
||||
this.originalBottomMargin = ((CoordinatorLayout.LayoutParams) findDependentView.getLayoutParams()).bottomMargin;
|
||||
if (findDependentView instanceof FloatingActionButton) {
|
||||
FloatingActionButton floatingActionButton = (FloatingActionButton) findDependentView;
|
||||
if (bottomAppBar.fabAnchorMode == 0 && bottomAppBar.removeEmbeddedFabElevation) {
|
||||
ViewCompat.setElevation(floatingActionButton, 0.0f);
|
||||
floatingActionButton.setCompatElevation(0.0f);
|
||||
}
|
||||
if (floatingActionButton.getShowMotionSpec() == null) {
|
||||
floatingActionButton.setShowMotionSpecResource(R.animator.mtrl_fab_show_motion_spec);
|
||||
}
|
||||
if (floatingActionButton.getHideMotionSpec() == null) {
|
||||
floatingActionButton.setHideMotionSpecResource(R.animator.mtrl_fab_hide_motion_spec);
|
||||
}
|
||||
bottomAppBar.addFabAnimationListeners(floatingActionButton);
|
||||
}
|
||||
findDependentView.addOnLayoutChangeListener(this.fabLayoutListener);
|
||||
bottomAppBar.setCutoutStateAndTranslateFab();
|
||||
}
|
||||
coordinatorLayout.onLayoutChild(bottomAppBar, i);
|
||||
return super.onLayoutChild(coordinatorLayout, (CoordinatorLayout) bottomAppBar, i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.behavior.HideBottomViewOnScrollBehavior, androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, BottomAppBar bottomAppBar, View view, View view2, int i, int i2) {
|
||||
return bottomAppBar.getHideOnScroll() && super.onStartNestedScroll(coordinatorLayout, (CoordinatorLayout) bottomAppBar, view, view2, i, i2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar, android.view.View
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
||||
savedState.fabAlignmentMode = this.fabAlignmentMode;
|
||||
savedState.fabAttached = this.fabAttached;
|
||||
return savedState;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar, android.view.View
|
||||
protected void onRestoreInstanceState(Parcelable parcelable) {
|
||||
if (!(parcelable instanceof SavedState)) {
|
||||
super.onRestoreInstanceState(parcelable);
|
||||
return;
|
||||
}
|
||||
SavedState savedState = (SavedState) parcelable;
|
||||
super.onRestoreInstanceState(savedState.getSuperState());
|
||||
this.fabAlignmentMode = savedState.fabAlignmentMode;
|
||||
this.fabAttached = savedState.fabAttached;
|
||||
}
|
||||
|
||||
static class SavedState extends AbsSavedState {
|
||||
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: com.google.android.material.bottomappbar.BottomAppBar.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];
|
||||
}
|
||||
};
|
||||
int fabAlignmentMode;
|
||||
boolean fabAttached;
|
||||
|
||||
public SavedState(Parcelable parcelable) {
|
||||
super(parcelable);
|
||||
}
|
||||
|
||||
public SavedState(Parcel parcel, ClassLoader classLoader) {
|
||||
super(parcel, classLoader);
|
||||
this.fabAlignmentMode = parcel.readInt();
|
||||
this.fabAttached = parcel.readInt() != 0;
|
||||
}
|
||||
|
||||
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
super.writeToParcel(parcel, i);
|
||||
parcel.writeInt(this.fabAlignmentMode);
|
||||
parcel.writeInt(this.fabAttached ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.google.android.material.bottomappbar;
|
||||
|
||||
import com.google.android.material.shape.EdgeTreatment;
|
||||
import com.google.android.material.shape.ShapePath;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BottomAppBarTopEdgeTreatment extends EdgeTreatment implements Cloneable {
|
||||
private static final int ANGLE_LEFT = 180;
|
||||
private static final int ANGLE_UP = 270;
|
||||
private static final int ARC_HALF = 180;
|
||||
private static final int ARC_QUARTER = 90;
|
||||
private static final float ROUNDED_CORNER_FAB_OFFSET = 1.75f;
|
||||
private float cradleVerticalOffset;
|
||||
private float fabCornerSize = -1.0f;
|
||||
private float fabDiameter;
|
||||
private float fabMargin;
|
||||
private float horizontalOffset;
|
||||
private float roundedCornerRadius;
|
||||
|
||||
float getCradleVerticalOffset() {
|
||||
return this.cradleVerticalOffset;
|
||||
}
|
||||
|
||||
public float getFabCornerRadius() {
|
||||
return this.fabCornerSize;
|
||||
}
|
||||
|
||||
float getFabCradleMargin() {
|
||||
return this.fabMargin;
|
||||
}
|
||||
|
||||
float getFabCradleRoundedCornerRadius() {
|
||||
return this.roundedCornerRadius;
|
||||
}
|
||||
|
||||
public float getFabDiameter() {
|
||||
return this.fabDiameter;
|
||||
}
|
||||
|
||||
public float getHorizontalOffset() {
|
||||
return this.horizontalOffset;
|
||||
}
|
||||
|
||||
public void setFabCornerSize(float f) {
|
||||
this.fabCornerSize = f;
|
||||
}
|
||||
|
||||
void setFabCradleMargin(float f) {
|
||||
this.fabMargin = f;
|
||||
}
|
||||
|
||||
void setFabCradleRoundedCornerRadius(float f) {
|
||||
this.roundedCornerRadius = f;
|
||||
}
|
||||
|
||||
public void setFabDiameter(float f) {
|
||||
this.fabDiameter = f;
|
||||
}
|
||||
|
||||
void setHorizontalOffset(float f) {
|
||||
this.horizontalOffset = f;
|
||||
}
|
||||
|
||||
public BottomAppBarTopEdgeTreatment(float f, float f2, float f3) {
|
||||
this.fabMargin = f;
|
||||
this.roundedCornerRadius = f2;
|
||||
setCradleVerticalOffset(f3);
|
||||
this.horizontalOffset = 0.0f;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.EdgeTreatment
|
||||
public void getEdgePath(float f, float f2, float f3, ShapePath shapePath) {
|
||||
float f4;
|
||||
float f5;
|
||||
float f6 = this.fabDiameter;
|
||||
if (f6 == 0.0f) {
|
||||
shapePath.lineTo(f, 0.0f);
|
||||
return;
|
||||
}
|
||||
float f7 = ((this.fabMargin * 2.0f) + f6) / 2.0f;
|
||||
float f8 = f3 * this.roundedCornerRadius;
|
||||
float f9 = f2 + this.horizontalOffset;
|
||||
float f10 = (this.cradleVerticalOffset * f3) + ((1.0f - f3) * f7);
|
||||
if (f10 / f7 >= 1.0f) {
|
||||
shapePath.lineTo(f, 0.0f);
|
||||
return;
|
||||
}
|
||||
float f11 = this.fabCornerSize;
|
||||
float f12 = f11 * f3;
|
||||
boolean z = f11 == -1.0f || Math.abs((f11 * 2.0f) - f6) < 0.1f;
|
||||
if (z) {
|
||||
f4 = f10;
|
||||
f5 = 0.0f;
|
||||
} else {
|
||||
f5 = ROUNDED_CORNER_FAB_OFFSET;
|
||||
f4 = 0.0f;
|
||||
}
|
||||
float f13 = f7 + f8;
|
||||
float f14 = f4 + f8;
|
||||
float sqrt = (float) Math.sqrt((f13 * f13) - (f14 * f14));
|
||||
float f15 = f9 - sqrt;
|
||||
float f16 = f9 + sqrt;
|
||||
float degrees = (float) Math.toDegrees(Math.atan(sqrt / f14));
|
||||
float f17 = (90.0f - degrees) + f5;
|
||||
shapePath.lineTo(f15, 0.0f);
|
||||
float f18 = f8 * 2.0f;
|
||||
shapePath.addArc(f15 - f8, 0.0f, f15 + f8, f18, 270.0f, degrees);
|
||||
if (z) {
|
||||
shapePath.addArc(f9 - f7, (-f7) - f4, f9 + f7, f7 - f4, 180.0f - f17, (f17 * 2.0f) - 180.0f);
|
||||
} else {
|
||||
float f19 = this.fabMargin;
|
||||
float f20 = f12 * 2.0f;
|
||||
float f21 = f9 - f7;
|
||||
shapePath.addArc(f21, -(f12 + f19), f21 + f19 + f20, f19 + f12, 180.0f - f17, ((f17 * 2.0f) - 180.0f) / 2.0f);
|
||||
float f22 = f9 + f7;
|
||||
float f23 = this.fabMargin;
|
||||
shapePath.lineTo(f22 - ((f23 / 2.0f) + f12), f23 + f12);
|
||||
float f24 = this.fabMargin;
|
||||
shapePath.addArc(f22 - (f20 + f24), -(f12 + f24), f22, f24 + f12, 90.0f, f17 - 90.0f);
|
||||
}
|
||||
shapePath.addArc(f16 - f8, 0.0f, f16 + f8, f18, 270.0f - degrees, degrees);
|
||||
shapePath.lineTo(f, 0.0f);
|
||||
}
|
||||
|
||||
void setCradleVerticalOffset(float f) {
|
||||
if (f < 0.0f) {
|
||||
throw new IllegalArgumentException("cradleVerticalOffset must be positive.");
|
||||
}
|
||||
this.cradleVerticalOffset = f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.google.android.material.bottomnavigation;
|
||||
|
||||
import android.content.Context;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.navigation.NavigationBarItemView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BottomNavigationItemView extends NavigationBarItemView {
|
||||
public BottomNavigationItemView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.navigation.NavigationBarItemView
|
||||
protected int getItemLayoutResId() {
|
||||
return R.layout.design_bottom_navigation_item;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.navigation.NavigationBarItemView
|
||||
protected int getItemDefaultMarginResId() {
|
||||
return R.dimen.design_bottom_navigation_margin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.google.android.material.bottomnavigation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.appcompat.view.menu.MenuBuilder;
|
||||
import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.navigation.NavigationBarItemView;
|
||||
import com.google.android.material.navigation.NavigationBarMenuView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BottomNavigationMenuView extends NavigationBarMenuView {
|
||||
private final int activeItemMaxWidth;
|
||||
private final int activeItemMinWidth;
|
||||
private final int inactiveItemMaxWidth;
|
||||
private final int inactiveItemMinWidth;
|
||||
private boolean itemHorizontalTranslationEnabled;
|
||||
private final List<Integer> tempChildWidths;
|
||||
|
||||
public boolean isItemHorizontalTranslationEnabled() {
|
||||
return this.itemHorizontalTranslationEnabled;
|
||||
}
|
||||
|
||||
public void setItemHorizontalTranslationEnabled(boolean z) {
|
||||
this.itemHorizontalTranslationEnabled = z;
|
||||
}
|
||||
|
||||
public BottomNavigationMenuView(Context context) {
|
||||
super(context);
|
||||
this.tempChildWidths = new ArrayList();
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2);
|
||||
layoutParams.gravity = 17;
|
||||
setLayoutParams(layoutParams);
|
||||
Resources resources = getResources();
|
||||
this.inactiveItemMaxWidth = resources.getDimensionPixelSize(R.dimen.design_bottom_navigation_item_max_width);
|
||||
this.inactiveItemMinWidth = resources.getDimensionPixelSize(R.dimen.design_bottom_navigation_item_min_width);
|
||||
this.activeItemMaxWidth = resources.getDimensionPixelSize(R.dimen.design_bottom_navigation_active_item_max_width);
|
||||
this.activeItemMinWidth = resources.getDimensionPixelSize(R.dimen.design_bottom_navigation_active_item_min_width);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
int i3;
|
||||
int i4;
|
||||
MenuBuilder menu = getMenu();
|
||||
int size = View.MeasureSpec.getSize(i);
|
||||
int size2 = menu.getVisibleItems().size();
|
||||
int childCount = getChildCount();
|
||||
this.tempChildWidths.clear();
|
||||
int size3 = View.MeasureSpec.getSize(i2);
|
||||
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(size3, BasicMeasure.EXACTLY);
|
||||
if (isShifting(getLabelVisibilityMode(), size2) && isItemHorizontalTranslationEnabled()) {
|
||||
View childAt = getChildAt(getSelectedItemPosition());
|
||||
int i5 = this.activeItemMinWidth;
|
||||
if (childAt.getVisibility() != 8) {
|
||||
childAt.measure(View.MeasureSpec.makeMeasureSpec(this.activeItemMaxWidth, Integer.MIN_VALUE), makeMeasureSpec);
|
||||
i5 = Math.max(i5, childAt.getMeasuredWidth());
|
||||
}
|
||||
int i6 = size2 - (childAt.getVisibility() != 8 ? 1 : 0);
|
||||
int min = Math.min(size - (this.inactiveItemMinWidth * i6), Math.min(i5, this.activeItemMaxWidth));
|
||||
int i7 = size - min;
|
||||
int min2 = Math.min(i7 / (i6 != 0 ? i6 : 1), this.inactiveItemMaxWidth);
|
||||
int i8 = i7 - (i6 * min2);
|
||||
int i9 = 0;
|
||||
while (i9 < childCount) {
|
||||
if (getChildAt(i9).getVisibility() != 8) {
|
||||
i4 = i9 == getSelectedItemPosition() ? min : min2;
|
||||
if (i8 > 0) {
|
||||
i4++;
|
||||
i8--;
|
||||
}
|
||||
} else {
|
||||
i4 = 0;
|
||||
}
|
||||
this.tempChildWidths.add(Integer.valueOf(i4));
|
||||
i9++;
|
||||
}
|
||||
} else {
|
||||
int min3 = Math.min(size / (size2 != 0 ? size2 : 1), this.activeItemMaxWidth);
|
||||
int i10 = size - (size2 * min3);
|
||||
for (int i11 = 0; i11 < childCount; i11++) {
|
||||
if (getChildAt(i11).getVisibility() == 8) {
|
||||
i3 = 0;
|
||||
} else if (i10 > 0) {
|
||||
i3 = min3 + 1;
|
||||
i10--;
|
||||
} else {
|
||||
i3 = min3;
|
||||
}
|
||||
this.tempChildWidths.add(Integer.valueOf(i3));
|
||||
}
|
||||
}
|
||||
int i12 = 0;
|
||||
for (int i13 = 0; i13 < childCount; i13++) {
|
||||
View childAt2 = getChildAt(i13);
|
||||
if (childAt2.getVisibility() != 8) {
|
||||
childAt2.measure(View.MeasureSpec.makeMeasureSpec(this.tempChildWidths.get(i13).intValue(), BasicMeasure.EXACTLY), makeMeasureSpec);
|
||||
childAt2.getLayoutParams().width = childAt2.getMeasuredWidth();
|
||||
i12 += childAt2.getMeasuredWidth();
|
||||
}
|
||||
}
|
||||
setMeasuredDimension(i12, size3);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
||||
int childCount = getChildCount();
|
||||
int i5 = i3 - i;
|
||||
int i6 = i4 - i2;
|
||||
int i7 = 0;
|
||||
for (int i8 = 0; i8 < childCount; i8++) {
|
||||
View childAt = getChildAt(i8);
|
||||
if (childAt.getVisibility() != 8) {
|
||||
if (ViewCompat.getLayoutDirection(this) == 1) {
|
||||
int i9 = i5 - i7;
|
||||
childAt.layout(i9 - childAt.getMeasuredWidth(), 0, i9, i6);
|
||||
} else {
|
||||
childAt.layout(i7, 0, childAt.getMeasuredWidth() + i7, i6);
|
||||
}
|
||||
i7 += childAt.getMeasuredWidth();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.navigation.NavigationBarMenuView
|
||||
protected NavigationBarItemView createNavigationBarItemView(Context context) {
|
||||
return new BottomNavigationItemView(context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.google.android.material.bottomnavigation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.appcompat.widget.TintTypedArray;
|
||||
import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import com.google.android.material.navigation.NavigationBarMenuView;
|
||||
import com.google.android.material.navigation.NavigationBarView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BottomNavigationView extends NavigationBarView {
|
||||
private static final int MAX_ITEM_COUNT = 5;
|
||||
|
||||
@Deprecated
|
||||
public interface OnNavigationItemReselectedListener extends NavigationBarView.OnItemReselectedListener {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public interface OnNavigationItemSelectedListener extends NavigationBarView.OnItemSelectedListener {
|
||||
}
|
||||
|
||||
private boolean shouldDrawCompatibilityTopDivider() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.navigation.NavigationBarView
|
||||
public int getMaxItemCount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
public BottomNavigationView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BottomNavigationView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.bottomNavigationStyle);
|
||||
}
|
||||
|
||||
public BottomNavigationView(Context context, AttributeSet attributeSet, int i) {
|
||||
this(context, attributeSet, i, R.style.Widget_Design_BottomNavigationView);
|
||||
}
|
||||
|
||||
public BottomNavigationView(Context context, AttributeSet attributeSet, int i, int i2) {
|
||||
super(context, attributeSet, i, i2);
|
||||
Context context2 = getContext();
|
||||
TintTypedArray obtainTintedStyledAttributes = ThemeEnforcement.obtainTintedStyledAttributes(context2, attributeSet, R.styleable.BottomNavigationView, i, i2, new int[0]);
|
||||
setItemHorizontalTranslationEnabled(obtainTintedStyledAttributes.getBoolean(R.styleable.BottomNavigationView_itemHorizontalTranslationEnabled, true));
|
||||
if (obtainTintedStyledAttributes.hasValue(R.styleable.BottomNavigationView_android_minHeight)) {
|
||||
setMinimumHeight(obtainTintedStyledAttributes.getDimensionPixelSize(R.styleable.BottomNavigationView_android_minHeight, 0));
|
||||
}
|
||||
if (obtainTintedStyledAttributes.getBoolean(R.styleable.BottomNavigationView_compatShadowEnabled, true) && shouldDrawCompatibilityTopDivider()) {
|
||||
addCompatibilityTopDivider(context2);
|
||||
}
|
||||
obtainTintedStyledAttributes.recycle();
|
||||
applyWindowInsets();
|
||||
}
|
||||
|
||||
private void applyWindowInsets() {
|
||||
ViewUtils.doOnApplyWindowInsets(this, new ViewUtils.OnApplyWindowInsetsListener() { // from class: com.google.android.material.bottomnavigation.BottomNavigationView.1
|
||||
@Override // com.google.android.material.internal.ViewUtils.OnApplyWindowInsetsListener
|
||||
public WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat, ViewUtils.RelativePadding relativePadding) {
|
||||
relativePadding.bottom += windowInsetsCompat.getSystemWindowInsetBottom();
|
||||
boolean z = ViewCompat.getLayoutDirection(view) == 1;
|
||||
int systemWindowInsetLeft = windowInsetsCompat.getSystemWindowInsetLeft();
|
||||
int systemWindowInsetRight = windowInsetsCompat.getSystemWindowInsetRight();
|
||||
relativePadding.start += z ? systemWindowInsetRight : systemWindowInsetLeft;
|
||||
int i = relativePadding.end;
|
||||
if (!z) {
|
||||
systemWindowInsetLeft = systemWindowInsetRight;
|
||||
}
|
||||
relativePadding.end = i + systemWindowInsetLeft;
|
||||
relativePadding.applyToView(view);
|
||||
return windowInsetsCompat;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // android.widget.FrameLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
super.onMeasure(i, makeMinHeightSpec(i2));
|
||||
}
|
||||
|
||||
private int makeMinHeightSpec(int i) {
|
||||
int suggestedMinimumHeight = getSuggestedMinimumHeight();
|
||||
if (View.MeasureSpec.getMode(i) == 1073741824 || suggestedMinimumHeight <= 0) {
|
||||
return i;
|
||||
}
|
||||
return View.MeasureSpec.makeMeasureSpec(Math.min(View.MeasureSpec.getSize(i), suggestedMinimumHeight + getPaddingTop() + getPaddingBottom()), BasicMeasure.EXACTLY);
|
||||
}
|
||||
|
||||
public void setItemHorizontalTranslationEnabled(boolean z) {
|
||||
BottomNavigationMenuView bottomNavigationMenuView = (BottomNavigationMenuView) getMenuView();
|
||||
if (bottomNavigationMenuView.isItemHorizontalTranslationEnabled() != z) {
|
||||
bottomNavigationMenuView.setItemHorizontalTranslationEnabled(z);
|
||||
getPresenter().updateMenuView(false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isItemHorizontalTranslationEnabled() {
|
||||
return ((BottomNavigationMenuView) getMenuView()).isItemHorizontalTranslationEnabled();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.navigation.NavigationBarView
|
||||
protected NavigationBarMenuView createNavigationBarMenuView(Context context) {
|
||||
return new BottomNavigationMenuView(context);
|
||||
}
|
||||
|
||||
private void addCompatibilityTopDivider(Context context) {
|
||||
View view = new View(context);
|
||||
view.setBackgroundColor(ContextCompat.getColor(context, R.color.design_bottom_navigation_shadow_color));
|
||||
view.setLayoutParams(new FrameLayout.LayoutParams(-1, getResources().getDimensionPixelSize(R.dimen.design_bottom_navigation_shadow_height)));
|
||||
addView(view);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setOnNavigationItemSelectedListener(OnNavigationItemSelectedListener onNavigationItemSelectedListener) {
|
||||
setOnItemSelectedListener(onNavigationItemSelectedListener);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setOnNavigationItemReselectedListener(OnNavigationItemReselectedListener onNavigationItemReselectedListener) {
|
||||
setOnItemReselectedListener(onNavigationItemReselectedListener);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.google.android.material.bottomnavigation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public @interface LabelVisibilityMode {
|
||||
public static final int LABEL_VISIBILITY_AUTO = -1;
|
||||
public static final int LABEL_VISIBILITY_LABELED = 1;
|
||||
public static final int LABEL_VISIBILITY_SELECTED = 0;
|
||||
public static final int LABEL_VISIBILITY_UNLABELED = 2;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,420 @@
|
||||
package com.google.android.material.bottomsheet;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.appcompat.app.AppCompatDialog;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.AccessibilityDelegateCompat;
|
||||
import androidx.core.view.OnApplyWindowInsetsListener;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.internal.EdgeToEdgeUtils;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import com.google.android.material.motion.MaterialBackOrchestrator;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BottomSheetDialog extends AppCompatDialog {
|
||||
private MaterialBackOrchestrator backOrchestrator;
|
||||
private BottomSheetBehavior<FrameLayout> behavior;
|
||||
private FrameLayout bottomSheet;
|
||||
private BottomSheetBehavior.BottomSheetCallback bottomSheetCallback;
|
||||
boolean cancelable;
|
||||
private boolean canceledOnTouchOutside;
|
||||
private boolean canceledOnTouchOutsideSet;
|
||||
private FrameLayout container;
|
||||
private CoordinatorLayout coordinator;
|
||||
boolean dismissWithAnimation;
|
||||
private EdgeToEdgeCallback edgeToEdgeCallback;
|
||||
private boolean edgeToEdgeEnabled;
|
||||
|
||||
public boolean getDismissWithAnimation() {
|
||||
return this.dismissWithAnimation;
|
||||
}
|
||||
|
||||
public boolean getEdgeToEdgeEnabled() {
|
||||
return this.edgeToEdgeEnabled;
|
||||
}
|
||||
|
||||
public void setDismissWithAnimation(boolean z) {
|
||||
this.dismissWithAnimation = z;
|
||||
}
|
||||
|
||||
public BottomSheetDialog(Context context) {
|
||||
this(context, 0);
|
||||
this.edgeToEdgeEnabled = getContext().getTheme().obtainStyledAttributes(new int[]{R.attr.enableEdgeToEdge}).getBoolean(0, false);
|
||||
}
|
||||
|
||||
public BottomSheetDialog(Context context, int i) {
|
||||
super(context, getThemeResId(context, i));
|
||||
this.cancelable = true;
|
||||
this.canceledOnTouchOutside = true;
|
||||
this.bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.5
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onSlide(View view, float f) {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onStateChanged(View view, int i2) {
|
||||
if (i2 == 5) {
|
||||
BottomSheetDialog.this.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
supportRequestWindowFeature(1);
|
||||
this.edgeToEdgeEnabled = getContext().getTheme().obtainStyledAttributes(new int[]{R.attr.enableEdgeToEdge}).getBoolean(0, false);
|
||||
}
|
||||
|
||||
protected BottomSheetDialog(Context context, boolean z, DialogInterface.OnCancelListener onCancelListener) {
|
||||
super(context, z, onCancelListener);
|
||||
this.cancelable = true;
|
||||
this.canceledOnTouchOutside = true;
|
||||
this.bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.5
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onSlide(View view, float f) {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onStateChanged(View view, int i2) {
|
||||
if (i2 == 5) {
|
||||
BottomSheetDialog.this.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
supportRequestWindowFeature(1);
|
||||
this.cancelable = z;
|
||||
this.edgeToEdgeEnabled = getContext().getTheme().obtainStyledAttributes(new int[]{R.attr.enableEdgeToEdge}).getBoolean(0, false);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
public void setContentView(int i) {
|
||||
super.setContentView(wrapInBottomSheet(i, null, null));
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.setStatusBarColor(0);
|
||||
window.addFlags(Integer.MIN_VALUE);
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
window.addFlags(67108864);
|
||||
}
|
||||
window.setLayout(-1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
public void setContentView(View view) {
|
||||
super.setContentView(wrapInBottomSheet(0, view, null));
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatDialog, androidx.activity.ComponentDialog, android.app.Dialog
|
||||
public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
|
||||
super.setContentView(wrapInBottomSheet(0, view, layoutParams));
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog
|
||||
public void setCancelable(boolean z) {
|
||||
super.setCancelable(z);
|
||||
if (this.cancelable != z) {
|
||||
this.cancelable = z;
|
||||
BottomSheetBehavior<FrameLayout> bottomSheetBehavior = this.behavior;
|
||||
if (bottomSheetBehavior != null) {
|
||||
bottomSheetBehavior.setHideable(z);
|
||||
}
|
||||
if (getWindow() != null) {
|
||||
updateListeningForBackCallbacks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.activity.ComponentDialog, android.app.Dialog
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
BottomSheetBehavior<FrameLayout> bottomSheetBehavior = this.behavior;
|
||||
if (bottomSheetBehavior == null || bottomSheetBehavior.getState() != 5) {
|
||||
return;
|
||||
}
|
||||
this.behavior.setState(4);
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog, android.view.Window.Callback
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
boolean z = this.edgeToEdgeEnabled && Color.alpha(window.getNavigationBarColor()) < 255;
|
||||
FrameLayout frameLayout = this.container;
|
||||
if (frameLayout != null) {
|
||||
frameLayout.setFitsSystemWindows(!z);
|
||||
}
|
||||
CoordinatorLayout coordinatorLayout = this.coordinator;
|
||||
if (coordinatorLayout != null) {
|
||||
coordinatorLayout.setFitsSystemWindows(!z);
|
||||
}
|
||||
WindowCompat.setDecorFitsSystemWindows(window, !z);
|
||||
EdgeToEdgeCallback edgeToEdgeCallback = this.edgeToEdgeCallback;
|
||||
if (edgeToEdgeCallback != null) {
|
||||
edgeToEdgeCallback.setWindow(window);
|
||||
}
|
||||
}
|
||||
updateListeningForBackCallbacks();
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog, android.view.Window.Callback
|
||||
public void onDetachedFromWindow() {
|
||||
EdgeToEdgeCallback edgeToEdgeCallback = this.edgeToEdgeCallback;
|
||||
if (edgeToEdgeCallback != null) {
|
||||
edgeToEdgeCallback.setWindow(null);
|
||||
}
|
||||
MaterialBackOrchestrator materialBackOrchestrator = this.backOrchestrator;
|
||||
if (materialBackOrchestrator != null) {
|
||||
materialBackOrchestrator.stopListeningForBackCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog, android.content.DialogInterface
|
||||
public void cancel() {
|
||||
BottomSheetBehavior<FrameLayout> behavior = getBehavior();
|
||||
if (!this.dismissWithAnimation || behavior.getState() == 5) {
|
||||
super.cancel();
|
||||
} else {
|
||||
behavior.setState(5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog
|
||||
public void setCanceledOnTouchOutside(boolean z) {
|
||||
super.setCanceledOnTouchOutside(z);
|
||||
if (z && !this.cancelable) {
|
||||
this.cancelable = true;
|
||||
}
|
||||
this.canceledOnTouchOutside = z;
|
||||
this.canceledOnTouchOutsideSet = true;
|
||||
}
|
||||
|
||||
public BottomSheetBehavior<FrameLayout> getBehavior() {
|
||||
if (this.behavior == null) {
|
||||
ensureContainerAndBehavior();
|
||||
}
|
||||
return this.behavior;
|
||||
}
|
||||
|
||||
private FrameLayout ensureContainerAndBehavior() {
|
||||
if (this.container == null) {
|
||||
FrameLayout frameLayout = (FrameLayout) View.inflate(getContext(), R.layout.design_bottom_sheet_dialog, null);
|
||||
this.container = frameLayout;
|
||||
this.coordinator = (CoordinatorLayout) frameLayout.findViewById(R.id.coordinator);
|
||||
FrameLayout frameLayout2 = (FrameLayout) this.container.findViewById(R.id.design_bottom_sheet);
|
||||
this.bottomSheet = frameLayout2;
|
||||
BottomSheetBehavior<FrameLayout> from = BottomSheetBehavior.from(frameLayout2);
|
||||
this.behavior = from;
|
||||
from.addBottomSheetCallback(this.bottomSheetCallback);
|
||||
this.behavior.setHideable(this.cancelable);
|
||||
this.backOrchestrator = new MaterialBackOrchestrator(this.behavior, this.bottomSheet);
|
||||
}
|
||||
return this.container;
|
||||
}
|
||||
|
||||
private View wrapInBottomSheet(int i, View view, ViewGroup.LayoutParams layoutParams) {
|
||||
ensureContainerAndBehavior();
|
||||
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) this.container.findViewById(R.id.coordinator);
|
||||
if (i != 0 && view == null) {
|
||||
view = getLayoutInflater().inflate(i, (ViewGroup) coordinatorLayout, false);
|
||||
}
|
||||
if (this.edgeToEdgeEnabled) {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this.bottomSheet, new OnApplyWindowInsetsListener() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.1
|
||||
@Override // androidx.core.view.OnApplyWindowInsetsListener
|
||||
public WindowInsetsCompat onApplyWindowInsets(View view2, WindowInsetsCompat windowInsetsCompat) {
|
||||
if (BottomSheetDialog.this.edgeToEdgeCallback != null) {
|
||||
BottomSheetDialog.this.behavior.removeBottomSheetCallback(BottomSheetDialog.this.edgeToEdgeCallback);
|
||||
}
|
||||
if (windowInsetsCompat != null) {
|
||||
BottomSheetDialog bottomSheetDialog = BottomSheetDialog.this;
|
||||
bottomSheetDialog.edgeToEdgeCallback = new EdgeToEdgeCallback(bottomSheetDialog.bottomSheet, windowInsetsCompat);
|
||||
BottomSheetDialog.this.edgeToEdgeCallback.setWindow(BottomSheetDialog.this.getWindow());
|
||||
BottomSheetDialog.this.behavior.addBottomSheetCallback(BottomSheetDialog.this.edgeToEdgeCallback);
|
||||
}
|
||||
return windowInsetsCompat;
|
||||
}
|
||||
});
|
||||
}
|
||||
this.bottomSheet.removeAllViews();
|
||||
if (layoutParams == null) {
|
||||
this.bottomSheet.addView(view);
|
||||
} else {
|
||||
this.bottomSheet.addView(view, layoutParams);
|
||||
}
|
||||
coordinatorLayout.findViewById(R.id.touch_outside).setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.2
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view2) {
|
||||
if (BottomSheetDialog.this.cancelable && BottomSheetDialog.this.isShowing() && BottomSheetDialog.this.shouldWindowCloseOnTouchOutside()) {
|
||||
BottomSheetDialog.this.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
ViewCompat.setAccessibilityDelegate(this.bottomSheet, new AccessibilityDelegateCompat() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.3
|
||||
@Override // androidx.core.view.AccessibilityDelegateCompat
|
||||
public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||||
super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat);
|
||||
if (BottomSheetDialog.this.cancelable) {
|
||||
accessibilityNodeInfoCompat.addAction(1048576);
|
||||
accessibilityNodeInfoCompat.setDismissable(true);
|
||||
} else {
|
||||
accessibilityNodeInfoCompat.setDismissable(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.AccessibilityDelegateCompat
|
||||
public boolean performAccessibilityAction(View view2, int i2, Bundle bundle) {
|
||||
if (i2 == 1048576 && BottomSheetDialog.this.cancelable) {
|
||||
BottomSheetDialog.this.cancel();
|
||||
return true;
|
||||
}
|
||||
return super.performAccessibilityAction(view2, i2, bundle);
|
||||
}
|
||||
});
|
||||
this.bottomSheet.setOnTouchListener(new View.OnTouchListener() { // from class: com.google.android.material.bottomsheet.BottomSheetDialog.4
|
||||
@Override // android.view.View.OnTouchListener
|
||||
public boolean onTouch(View view2, MotionEvent motionEvent) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return this.container;
|
||||
}
|
||||
|
||||
private void updateListeningForBackCallbacks() {
|
||||
MaterialBackOrchestrator materialBackOrchestrator = this.backOrchestrator;
|
||||
if (materialBackOrchestrator == null) {
|
||||
return;
|
||||
}
|
||||
if (this.cancelable) {
|
||||
materialBackOrchestrator.startListeningForBackCallbacks();
|
||||
} else {
|
||||
materialBackOrchestrator.stopListeningForBackCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
boolean shouldWindowCloseOnTouchOutside() {
|
||||
if (!this.canceledOnTouchOutsideSet) {
|
||||
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(new int[]{android.R.attr.windowCloseOnTouchOutside});
|
||||
this.canceledOnTouchOutside = obtainStyledAttributes.getBoolean(0, true);
|
||||
obtainStyledAttributes.recycle();
|
||||
this.canceledOnTouchOutsideSet = true;
|
||||
}
|
||||
return this.canceledOnTouchOutside;
|
||||
}
|
||||
|
||||
private static int getThemeResId(Context context, int i) {
|
||||
if (i != 0) {
|
||||
return i;
|
||||
}
|
||||
TypedValue typedValue = new TypedValue();
|
||||
if (context.getTheme().resolveAttribute(R.attr.bottomSheetDialogTheme, typedValue, true)) {
|
||||
return typedValue.resourceId;
|
||||
}
|
||||
return R.style.Theme_Design_Light_BottomSheetDialog;
|
||||
}
|
||||
|
||||
void removeDefaultCallback() {
|
||||
this.behavior.removeBottomSheetCallback(this.bottomSheetCallback);
|
||||
}
|
||||
|
||||
private static class EdgeToEdgeCallback extends BottomSheetBehavior.BottomSheetCallback {
|
||||
private final WindowInsetsCompat insetsCompat;
|
||||
private final Boolean lightBottomSheet;
|
||||
private boolean lightStatusBar;
|
||||
private Window window;
|
||||
|
||||
private EdgeToEdgeCallback(View view, WindowInsetsCompat windowInsetsCompat) {
|
||||
ColorStateList backgroundTintList;
|
||||
this.insetsCompat = windowInsetsCompat;
|
||||
MaterialShapeDrawable materialShapeDrawable = BottomSheetBehavior.from(view).getMaterialShapeDrawable();
|
||||
if (materialShapeDrawable != null) {
|
||||
backgroundTintList = materialShapeDrawable.getFillColor();
|
||||
} else {
|
||||
backgroundTintList = ViewCompat.getBackgroundTintList(view);
|
||||
}
|
||||
if (backgroundTintList != null) {
|
||||
this.lightBottomSheet = Boolean.valueOf(MaterialColors.isColorLight(backgroundTintList.getDefaultColor()));
|
||||
return;
|
||||
}
|
||||
Integer backgroundColor = ViewUtils.getBackgroundColor(view);
|
||||
if (backgroundColor != null) {
|
||||
this.lightBottomSheet = Boolean.valueOf(MaterialColors.isColorLight(backgroundColor.intValue()));
|
||||
} else {
|
||||
this.lightBottomSheet = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onStateChanged(View view, int i) {
|
||||
setPaddingForPosition(view);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onSlide(View view, float f) {
|
||||
setPaddingForPosition(view);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
void onLayout(View view) {
|
||||
setPaddingForPosition(view);
|
||||
}
|
||||
|
||||
void setWindow(Window window) {
|
||||
if (this.window == window) {
|
||||
return;
|
||||
}
|
||||
this.window = window;
|
||||
if (window != null) {
|
||||
this.lightStatusBar = WindowCompat.getInsetsController(window, window.getDecorView()).isAppearanceLightStatusBars();
|
||||
}
|
||||
}
|
||||
|
||||
private void setPaddingForPosition(View view) {
|
||||
if (view.getTop() < this.insetsCompat.getSystemWindowInsetTop()) {
|
||||
Window window = this.window;
|
||||
if (window != null) {
|
||||
Boolean bool = this.lightBottomSheet;
|
||||
EdgeToEdgeUtils.setLightStatusBar(window, bool == null ? this.lightStatusBar : bool.booleanValue());
|
||||
}
|
||||
view.setPadding(view.getPaddingLeft(), this.insetsCompat.getSystemWindowInsetTop() - view.getTop(), view.getPaddingRight(), view.getPaddingBottom());
|
||||
return;
|
||||
}
|
||||
if (view.getTop() != 0) {
|
||||
Window window2 = this.window;
|
||||
if (window2 != null) {
|
||||
EdgeToEdgeUtils.setLightStatusBar(window2, this.lightStatusBar);
|
||||
}
|
||||
view.setPadding(view.getPaddingLeft(), 0, view.getPaddingRight(), view.getPaddingBottom());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void setLightStatusBar(View view, boolean z) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
int systemUiVisibility = view.getSystemUiVisibility();
|
||||
view.setSystemUiVisibility(z ? systemUiVisibility | 8192 : systemUiVisibility & (-8193));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.google.android.material.bottomsheet;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.appcompat.app.AppCompatDialogFragment;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BottomSheetDialogFragment extends AppCompatDialogFragment {
|
||||
private boolean waitingForDismissAllowingStateLoss;
|
||||
|
||||
public BottomSheetDialogFragment() {
|
||||
}
|
||||
|
||||
public BottomSheetDialogFragment(int i) {
|
||||
super(i);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatDialogFragment, androidx.fragment.app.DialogFragment
|
||||
public Dialog onCreateDialog(Bundle bundle) {
|
||||
return new BottomSheetDialog(getContext(), getTheme());
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.DialogFragment
|
||||
public void dismiss() {
|
||||
if (tryDismissWithAnimation(false)) {
|
||||
return;
|
||||
}
|
||||
super.dismiss();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.DialogFragment
|
||||
public void dismissAllowingStateLoss() {
|
||||
if (tryDismissWithAnimation(true)) {
|
||||
return;
|
||||
}
|
||||
super.dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
private boolean tryDismissWithAnimation(boolean z) {
|
||||
Dialog dialog = getDialog();
|
||||
if (!(dialog instanceof BottomSheetDialog)) {
|
||||
return false;
|
||||
}
|
||||
BottomSheetDialog bottomSheetDialog = (BottomSheetDialog) dialog;
|
||||
BottomSheetBehavior<FrameLayout> behavior = bottomSheetDialog.getBehavior();
|
||||
if (!behavior.isHideable() || !bottomSheetDialog.getDismissWithAnimation()) {
|
||||
return false;
|
||||
}
|
||||
dismissWithAnimation(behavior, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dismissWithAnimation(BottomSheetBehavior<?> bottomSheetBehavior, boolean z) {
|
||||
this.waitingForDismissAllowingStateLoss = z;
|
||||
if (bottomSheetBehavior.getState() == 5) {
|
||||
dismissAfterAnimation();
|
||||
return;
|
||||
}
|
||||
if (getDialog() instanceof BottomSheetDialog) {
|
||||
((BottomSheetDialog) getDialog()).removeDefaultCallback();
|
||||
}
|
||||
bottomSheetBehavior.addBottomSheetCallback(new BottomSheetDismissCallback());
|
||||
bottomSheetBehavior.setState(5);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void dismissAfterAnimation() {
|
||||
if (this.waitingForDismissAllowingStateLoss) {
|
||||
super.dismissAllowingStateLoss();
|
||||
} else {
|
||||
super.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private class BottomSheetDismissCallback extends BottomSheetBehavior.BottomSheetCallback {
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onSlide(View view, float f) {
|
||||
}
|
||||
|
||||
private BottomSheetDismissCallback() {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onStateChanged(View view, int i) {
|
||||
if (i == 5) {
|
||||
BottomSheetDialogFragment.this.dismissAfterAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.google.android.material.bottomsheet;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.AccessibilityDelegateCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityViewCommand;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.theme.overlay.MaterialThemeOverlay;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BottomSheetDragHandleView extends AppCompatImageView implements AccessibilityManager.AccessibilityStateChangeListener {
|
||||
private static final int DEF_STYLE_RES = R.style.Widget_Material3_BottomSheet_DragHandle;
|
||||
private final AccessibilityManager accessibilityManager;
|
||||
private boolean accessibilityServiceEnabled;
|
||||
private BottomSheetBehavior<?> bottomSheetBehavior;
|
||||
private final BottomSheetBehavior.BottomSheetCallback bottomSheetCallback;
|
||||
private final String clickFeedback;
|
||||
private final String clickToCollapseActionLabel;
|
||||
private boolean clickToExpand;
|
||||
private final String clickToExpandActionLabel;
|
||||
private boolean interactable;
|
||||
|
||||
public BottomSheetDragHandleView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BottomSheetDragHandleView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.bottomSheetDragHandleStyle);
|
||||
}
|
||||
|
||||
public BottomSheetDragHandleView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(MaterialThemeOverlay.wrap(context, attributeSet, i, DEF_STYLE_RES), attributeSet, i);
|
||||
this.clickToExpandActionLabel = getResources().getString(R.string.bottomsheet_action_expand);
|
||||
this.clickToCollapseActionLabel = getResources().getString(R.string.bottomsheet_action_collapse);
|
||||
this.clickFeedback = getResources().getString(R.string.bottomsheet_drag_handle_clicked);
|
||||
this.bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() { // from class: com.google.android.material.bottomsheet.BottomSheetDragHandleView.1
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onSlide(View view, float f) {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
public void onStateChanged(View view, int i2) {
|
||||
BottomSheetDragHandleView.this.onBottomSheetStateChanged(i2);
|
||||
}
|
||||
};
|
||||
this.accessibilityManager = (AccessibilityManager) getContext().getSystemService("accessibility");
|
||||
updateInteractableState();
|
||||
ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegateCompat() { // from class: com.google.android.material.bottomsheet.BottomSheetDragHandleView.2
|
||||
@Override // androidx.core.view.AccessibilityDelegateCompat
|
||||
public void onPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
|
||||
super.onPopulateAccessibilityEvent(view, accessibilityEvent);
|
||||
if (accessibilityEvent.getEventType() == 1) {
|
||||
BottomSheetDragHandleView.this.expandOrCollapseBottomSheetIfPossible();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
setBottomSheetBehavior(findParentBottomSheetBehavior());
|
||||
AccessibilityManager accessibilityManager = this.accessibilityManager;
|
||||
if (accessibilityManager != null) {
|
||||
accessibilityManager.addAccessibilityStateChangeListener(this);
|
||||
onAccessibilityStateChanged(this.accessibilityManager.isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onDetachedFromWindow() {
|
||||
AccessibilityManager accessibilityManager = this.accessibilityManager;
|
||||
if (accessibilityManager != null) {
|
||||
accessibilityManager.removeAccessibilityStateChangeListener(this);
|
||||
}
|
||||
setBottomSheetBehavior(null);
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@Override // android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener
|
||||
public void onAccessibilityStateChanged(boolean z) {
|
||||
this.accessibilityServiceEnabled = z;
|
||||
updateInteractableState();
|
||||
}
|
||||
|
||||
private void setBottomSheetBehavior(BottomSheetBehavior<?> bottomSheetBehavior) {
|
||||
BottomSheetBehavior<?> bottomSheetBehavior2 = this.bottomSheetBehavior;
|
||||
if (bottomSheetBehavior2 != null) {
|
||||
bottomSheetBehavior2.removeBottomSheetCallback(this.bottomSheetCallback);
|
||||
this.bottomSheetBehavior.setAccessibilityDelegateView(null);
|
||||
}
|
||||
this.bottomSheetBehavior = bottomSheetBehavior;
|
||||
if (bottomSheetBehavior != null) {
|
||||
bottomSheetBehavior.setAccessibilityDelegateView(this);
|
||||
onBottomSheetStateChanged(this.bottomSheetBehavior.getState());
|
||||
this.bottomSheetBehavior.addBottomSheetCallback(this.bottomSheetCallback);
|
||||
}
|
||||
updateInteractableState();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void onBottomSheetStateChanged(int i) {
|
||||
if (i == 4) {
|
||||
this.clickToExpand = true;
|
||||
} else if (i == 3) {
|
||||
this.clickToExpand = false;
|
||||
}
|
||||
ViewCompat.replaceAccessibilityAction(this, AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CLICK, this.clickToExpand ? this.clickToExpandActionLabel : this.clickToCollapseActionLabel, new AccessibilityViewCommand() { // from class: com.google.android.material.bottomsheet.BottomSheetDragHandleView$$ExternalSyntheticLambda0
|
||||
@Override // androidx.core.view.accessibility.AccessibilityViewCommand
|
||||
public final boolean perform(View view, AccessibilityViewCommand.CommandArguments commandArguments) {
|
||||
return BottomSheetDragHandleView.this.m192xa7b4c95f(view, commandArguments);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* renamed from: lambda$onBottomSheetStateChanged$0$com-google-android-material-bottomsheet-BottomSheetDragHandleView, reason: not valid java name */
|
||||
/* synthetic */ boolean m192xa7b4c95f(View view, AccessibilityViewCommand.CommandArguments commandArguments) {
|
||||
return expandOrCollapseBottomSheetIfPossible();
|
||||
}
|
||||
|
||||
private void updateInteractableState() {
|
||||
this.interactable = this.accessibilityServiceEnabled && this.bottomSheetBehavior != null;
|
||||
ViewCompat.setImportantForAccessibility(this, this.bottomSheetBehavior == null ? 2 : 1);
|
||||
setClickable(this.interactable);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean expandOrCollapseBottomSheetIfPossible() {
|
||||
boolean z = false;
|
||||
if (!this.interactable) {
|
||||
return false;
|
||||
}
|
||||
announceAccessibilityEvent(this.clickFeedback);
|
||||
if (!this.bottomSheetBehavior.isFitToContents() && !this.bottomSheetBehavior.shouldSkipHalfExpandedStateWhenDragging()) {
|
||||
z = true;
|
||||
}
|
||||
int state = this.bottomSheetBehavior.getState();
|
||||
int i = 6;
|
||||
if (state == 4) {
|
||||
if (!z) {
|
||||
i = 3;
|
||||
}
|
||||
} else if (state != 3) {
|
||||
i = this.clickToExpand ? 3 : 4;
|
||||
} else if (!z) {
|
||||
i = 4;
|
||||
}
|
||||
this.bottomSheetBehavior.setState(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void announceAccessibilityEvent(String str) {
|
||||
if (this.accessibilityManager == null) {
|
||||
return;
|
||||
}
|
||||
AccessibilityEvent obtain = AccessibilityEvent.obtain(16384);
|
||||
obtain.getText().add(str);
|
||||
this.accessibilityManager.sendAccessibilityEvent(obtain);
|
||||
}
|
||||
|
||||
private BottomSheetBehavior<?> findParentBottomSheetBehavior() {
|
||||
View view = this;
|
||||
while (true) {
|
||||
view = getParentView(view);
|
||||
if (view == null) {
|
||||
return null;
|
||||
}
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
if (layoutParams instanceof CoordinatorLayout.LayoutParams) {
|
||||
CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) layoutParams).getBehavior();
|
||||
if (behavior instanceof BottomSheetBehavior) {
|
||||
return (BottomSheetBehavior) behavior;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static View getParentView(View view) {
|
||||
Object parent = view.getParent();
|
||||
if (parent instanceof View) {
|
||||
return (View) parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.google.android.material.bottomsheet;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.core.view.WindowInsetsAnimationCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class InsetsAnimationCallback extends WindowInsetsAnimationCompat.Callback {
|
||||
private int startTranslationY;
|
||||
private int startY;
|
||||
private final int[] tmpLocation;
|
||||
private final View view;
|
||||
|
||||
public InsetsAnimationCallback(View view) {
|
||||
super(0);
|
||||
this.tmpLocation = new int[2];
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.WindowInsetsAnimationCompat.Callback
|
||||
public void onPrepare(WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
|
||||
this.view.getLocationOnScreen(this.tmpLocation);
|
||||
this.startY = this.tmpLocation[1];
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.WindowInsetsAnimationCompat.Callback
|
||||
public WindowInsetsAnimationCompat.BoundsCompat onStart(WindowInsetsAnimationCompat windowInsetsAnimationCompat, WindowInsetsAnimationCompat.BoundsCompat boundsCompat) {
|
||||
this.view.getLocationOnScreen(this.tmpLocation);
|
||||
int i = this.startY - this.tmpLocation[1];
|
||||
this.startTranslationY = i;
|
||||
this.view.setTranslationY(i);
|
||||
return boundsCompat;
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.WindowInsetsAnimationCompat.Callback
|
||||
public WindowInsetsCompat onProgress(WindowInsetsCompat windowInsetsCompat, List<WindowInsetsAnimationCompat> list) {
|
||||
Iterator<WindowInsetsAnimationCompat> it = list.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
if ((it.next().getTypeMask() & WindowInsetsCompat.Type.ime()) != 0) {
|
||||
this.view.setTranslationY(AnimationUtils.lerp(this.startTranslationY, 0, r0.getInterpolatedFraction()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return windowInsetsCompat;
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.WindowInsetsAnimationCompat.Callback
|
||||
public void onEnd(WindowInsetsAnimationCompat windowInsetsAnimationCompat) {
|
||||
this.view.setTranslationY(0.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,860 @@
|
||||
package com.google.android.material.button;
|
||||
|
||||
import android.R;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.Layout;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.inspector.PropertyMapper;
|
||||
import android.view.inspector.PropertyReader;
|
||||
import android.widget.Button;
|
||||
import android.widget.Checkable;
|
||||
import android.widget.CompoundButton;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.widget.TextViewCompat;
|
||||
import androidx.customview.view.AbsSavedState;
|
||||
import androidx.tracing.Trace$$ExternalSyntheticApiModelOutline0;
|
||||
import com.google.android.material.shape.MaterialShapeUtils;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.google.android.material.shape.Shapeable;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MaterialButton extends AppCompatButton implements Checkable, Shapeable {
|
||||
private static final int[] CHECKABLE_STATE_SET = {R.attr.state_checkable};
|
||||
private static final int[] CHECKED_STATE_SET = {R.attr.state_checked};
|
||||
private static final int DEF_STYLE_RES = com.google.android.material.R.style.Widget_MaterialComponents_Button;
|
||||
public static final int ICON_GRAVITY_END = 3;
|
||||
public static final int ICON_GRAVITY_START = 1;
|
||||
public static final int ICON_GRAVITY_TEXT_END = 4;
|
||||
public static final int ICON_GRAVITY_TEXT_START = 2;
|
||||
public static final int ICON_GRAVITY_TEXT_TOP = 32;
|
||||
public static final int ICON_GRAVITY_TOP = 16;
|
||||
private static final String LOG_TAG = "MaterialButton";
|
||||
private String accessibilityClassName;
|
||||
private boolean broadcasting;
|
||||
private boolean checked;
|
||||
private Drawable icon;
|
||||
private int iconGravity;
|
||||
private int iconLeft;
|
||||
private int iconPadding;
|
||||
private int iconSize;
|
||||
private ColorStateList iconTint;
|
||||
private PorterDuff.Mode iconTintMode;
|
||||
private int iconTop;
|
||||
private final MaterialButtonHelper materialButtonHelper;
|
||||
private final LinkedHashSet<OnCheckedChangeListener> onCheckedChangeListeners;
|
||||
private OnPressedChangeListener onPressedChangeListenerInternal;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface IconGravity {
|
||||
}
|
||||
|
||||
public interface OnCheckedChangeListener {
|
||||
void onCheckedChanged(MaterialButton materialButton, boolean z);
|
||||
}
|
||||
|
||||
interface OnPressedChangeListener {
|
||||
void onPressedChanged(MaterialButton materialButton, boolean z);
|
||||
}
|
||||
|
||||
private boolean isIconEnd() {
|
||||
int i = this.iconGravity;
|
||||
return i == 3 || i == 4;
|
||||
}
|
||||
|
||||
private boolean isIconStart() {
|
||||
int i = this.iconGravity;
|
||||
return i == 1 || i == 2;
|
||||
}
|
||||
|
||||
private boolean isIconTop() {
|
||||
int i = this.iconGravity;
|
||||
return i == 16 || i == 32;
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
public int getIconGravity() {
|
||||
return this.iconGravity;
|
||||
}
|
||||
|
||||
public int getIconPadding() {
|
||||
return this.iconPadding;
|
||||
}
|
||||
|
||||
public int getIconSize() {
|
||||
return this.iconSize;
|
||||
}
|
||||
|
||||
public ColorStateList getIconTint() {
|
||||
return this.iconTint;
|
||||
}
|
||||
|
||||
public PorterDuff.Mode getIconTintMode() {
|
||||
return this.iconTintMode;
|
||||
}
|
||||
|
||||
@Override // android.widget.Checkable
|
||||
public boolean isChecked() {
|
||||
return this.checked;
|
||||
}
|
||||
|
||||
void setA11yClassName(String str) {
|
||||
this.accessibilityClassName = str;
|
||||
}
|
||||
|
||||
void setOnPressedChangeListenerInternal(OnPressedChangeListener onPressedChangeListener) {
|
||||
this.onPressedChangeListenerInternal = onPressedChangeListener;
|
||||
}
|
||||
|
||||
public final class InspectionCompanion implements android.view.inspector.InspectionCompanion<MaterialButton> {
|
||||
private int mIconPaddingId;
|
||||
private boolean mPropertiesMapped = false;
|
||||
|
||||
@Override // android.view.inspector.InspectionCompanion
|
||||
public void mapProperties(PropertyMapper propertyMapper) {
|
||||
int mapInt;
|
||||
mapInt = propertyMapper.mapInt("iconPadding", com.google.android.material.R.attr.iconPadding);
|
||||
this.mIconPaddingId = mapInt;
|
||||
this.mPropertiesMapped = true;
|
||||
}
|
||||
|
||||
@Override // android.view.inspector.InspectionCompanion
|
||||
public void readProperties(MaterialButton materialButton, PropertyReader propertyReader) {
|
||||
if (!this.mPropertiesMapped) {
|
||||
throw Trace$$ExternalSyntheticApiModelOutline0.m176m();
|
||||
}
|
||||
propertyReader.readInt(this.mIconPaddingId, materialButton.getIconPadding());
|
||||
}
|
||||
}
|
||||
|
||||
public MaterialButton(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MaterialButton(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, com.google.android.material.R.attr.materialButtonStyle);
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public MaterialButton(android.content.Context r9, android.util.AttributeSet r10, int r11) {
|
||||
/*
|
||||
r8 = this;
|
||||
int r6 = com.google.android.material.button.MaterialButton.DEF_STYLE_RES
|
||||
android.content.Context r9 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r9, r10, r11, r6)
|
||||
r8.<init>(r9, r10, r11)
|
||||
java.util.LinkedHashSet r9 = new java.util.LinkedHashSet
|
||||
r9.<init>()
|
||||
r8.onCheckedChangeListeners = r9
|
||||
r9 = 0
|
||||
r8.checked = r9
|
||||
r8.broadcasting = r9
|
||||
android.content.Context r7 = r8.getContext()
|
||||
int[] r2 = com.google.android.material.R.styleable.MaterialButton
|
||||
int[] r5 = new int[r9]
|
||||
r0 = r7
|
||||
r1 = r10
|
||||
r3 = r11
|
||||
r4 = r6
|
||||
android.content.res.TypedArray r0 = com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(r0, r1, r2, r3, r4, r5)
|
||||
int r1 = com.google.android.material.R.styleable.MaterialButton_iconPadding
|
||||
int r1 = r0.getDimensionPixelSize(r1, r9)
|
||||
r8.iconPadding = r1
|
||||
int r1 = com.google.android.material.R.styleable.MaterialButton_iconTintMode
|
||||
r2 = -1
|
||||
int r1 = r0.getInt(r1, r2)
|
||||
android.graphics.PorterDuff$Mode r2 = android.graphics.PorterDuff.Mode.SRC_IN
|
||||
android.graphics.PorterDuff$Mode r1 = com.google.android.material.internal.ViewUtils.parseTintMode(r1, r2)
|
||||
r8.iconTintMode = r1
|
||||
android.content.Context r1 = r8.getContext()
|
||||
int r2 = com.google.android.material.R.styleable.MaterialButton_iconTint
|
||||
android.content.res.ColorStateList r1 = com.google.android.material.resources.MaterialResources.getColorStateList(r1, r0, r2)
|
||||
r8.iconTint = r1
|
||||
android.content.Context r1 = r8.getContext()
|
||||
int r2 = com.google.android.material.R.styleable.MaterialButton_icon
|
||||
android.graphics.drawable.Drawable r1 = com.google.android.material.resources.MaterialResources.getDrawable(r1, r0, r2)
|
||||
r8.icon = r1
|
||||
int r1 = com.google.android.material.R.styleable.MaterialButton_iconGravity
|
||||
r2 = 1
|
||||
int r1 = r0.getInteger(r1, r2)
|
||||
r8.iconGravity = r1
|
||||
int r1 = com.google.android.material.R.styleable.MaterialButton_iconSize
|
||||
int r1 = r0.getDimensionPixelSize(r1, r9)
|
||||
r8.iconSize = r1
|
||||
com.google.android.material.shape.ShapeAppearanceModel$Builder r10 = com.google.android.material.shape.ShapeAppearanceModel.builder(r7, r10, r11, r6)
|
||||
com.google.android.material.shape.ShapeAppearanceModel r10 = r10.build()
|
||||
com.google.android.material.button.MaterialButtonHelper r11 = new com.google.android.material.button.MaterialButtonHelper
|
||||
r11.<init>(r8, r10)
|
||||
r8.materialButtonHelper = r11
|
||||
r11.loadFromAttributes(r0)
|
||||
r0.recycle()
|
||||
int r10 = r8.iconPadding
|
||||
r8.setCompoundDrawablePadding(r10)
|
||||
android.graphics.drawable.Drawable r10 = r8.icon
|
||||
if (r10 == 0) goto L84
|
||||
r9 = 1
|
||||
L84:
|
||||
r8.updateIcon(r9)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.button.MaterialButton.<init>(android.content.Context, android.util.AttributeSet, int):void");
|
||||
}
|
||||
|
||||
String getA11yClassName() {
|
||||
if (TextUtils.isEmpty(this.accessibilityClassName)) {
|
||||
return (isCheckable() ? CompoundButton.class : Button.class).getName();
|
||||
}
|
||||
return this.accessibilityClassName;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||||
accessibilityNodeInfo.setClassName(getA11yClassName());
|
||||
accessibilityNodeInfo.setCheckable(isCheckable());
|
||||
accessibilityNodeInfo.setChecked(isChecked());
|
||||
accessibilityNodeInfo.setClickable(isClickable());
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
|
||||
public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
||||
super.onInitializeAccessibilityEvent(accessibilityEvent);
|
||||
accessibilityEvent.setClassName(getA11yClassName());
|
||||
accessibilityEvent.setChecked(isChecked());
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
public Parcelable onSaveInstanceState() {
|
||||
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
||||
savedState.checked = this.checked;
|
||||
return savedState;
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
public void onRestoreInstanceState(Parcelable parcelable) {
|
||||
if (!(parcelable instanceof SavedState)) {
|
||||
super.onRestoreInstanceState(parcelable);
|
||||
return;
|
||||
}
|
||||
SavedState savedState = (SavedState) parcelable;
|
||||
super.onRestoreInstanceState(savedState.getSuperState());
|
||||
setChecked(savedState.checked);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, androidx.core.view.TintableBackgroundView
|
||||
public void setSupportBackgroundTintList(ColorStateList colorStateList) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setSupportBackgroundTintList(colorStateList);
|
||||
} else {
|
||||
super.setSupportBackgroundTintList(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, androidx.core.view.TintableBackgroundView
|
||||
public ColorStateList getSupportBackgroundTintList() {
|
||||
if (isUsingOriginalBackground()) {
|
||||
return this.materialButtonHelper.getSupportBackgroundTintList();
|
||||
}
|
||||
return super.getSupportBackgroundTintList();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, androidx.core.view.TintableBackgroundView
|
||||
public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setSupportBackgroundTintMode(mode);
|
||||
} else {
|
||||
super.setSupportBackgroundTintMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, androidx.core.view.TintableBackgroundView
|
||||
public PorterDuff.Mode getSupportBackgroundTintMode() {
|
||||
if (isUsingOriginalBackground()) {
|
||||
return this.materialButtonHelper.getSupportBackgroundTintMode();
|
||||
}
|
||||
return super.getSupportBackgroundTintMode();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundTintList(ColorStateList colorStateList) {
|
||||
setSupportBackgroundTintList(colorStateList);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public ColorStateList getBackgroundTintList() {
|
||||
return getSupportBackgroundTintList();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundTintMode(PorterDuff.Mode mode) {
|
||||
setSupportBackgroundTintMode(mode);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public PorterDuff.Mode getBackgroundTintMode() {
|
||||
return getSupportBackgroundTintMode();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundColor(int i) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setBackgroundColor(i);
|
||||
} else {
|
||||
super.setBackgroundColor(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackground(Drawable drawable) {
|
||||
setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
|
||||
public void setBackgroundResource(int i) {
|
||||
setBackgroundDrawable(i != 0 ? AppCompatResources.getDrawable(getContext(), i) : null);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
|
||||
public void setBackgroundDrawable(Drawable drawable) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
if (drawable != getBackground()) {
|
||||
Log.w(LOG_TAG, "MaterialButton manages its own background to control elevation, shape, color and states. Consider using backgroundTint, shapeAppearance and other attributes where available. A custom background will ignore these attributes and you should consider handling interaction states such as pressed, focused and disabled");
|
||||
this.materialButtonHelper.setBackgroundOverwritten();
|
||||
super.setBackgroundDrawable(drawable);
|
||||
return;
|
||||
}
|
||||
getBackground().setState(drawable.getState());
|
||||
return;
|
||||
}
|
||||
super.setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, android.widget.TextView, android.view.View
|
||||
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
||||
MaterialButtonHelper materialButtonHelper;
|
||||
super.onLayout(z, i, i2, i3, i4);
|
||||
if (Build.VERSION.SDK_INT == 21 && (materialButtonHelper = this.materialButtonHelper) != null) {
|
||||
materialButtonHelper.updateMaskBounds(i4 - i2, i3 - i);
|
||||
}
|
||||
updateIconPosition(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatButton, android.widget.TextView
|
||||
protected void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
super.onTextChanged(charSequence, i, i2, i3);
|
||||
updateIconPosition(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (isUsingOriginalBackground()) {
|
||||
MaterialShapeUtils.setParentAbsoluteElevation(this, this.materialButtonHelper.getMaterialShapeDrawable());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setElevation(float f) {
|
||||
super.setElevation(f);
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.getMaterialShapeDrawable().setElevation(f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void refreshDrawableState() {
|
||||
super.refreshDrawableState();
|
||||
if (this.icon != null) {
|
||||
if (this.icon.setState(getDrawableState())) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setTextAlignment(int i) {
|
||||
super.setTextAlignment(i);
|
||||
updateIconPosition(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
|
||||
private Layout.Alignment getGravityTextAlignment() {
|
||||
int gravity = getGravity() & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK;
|
||||
if (gravity == 1) {
|
||||
return Layout.Alignment.ALIGN_CENTER;
|
||||
}
|
||||
if (gravity == 5 || gravity == 8388613) {
|
||||
return Layout.Alignment.ALIGN_OPPOSITE;
|
||||
}
|
||||
return Layout.Alignment.ALIGN_NORMAL;
|
||||
}
|
||||
|
||||
private Layout.Alignment getActualTextAlignment() {
|
||||
int textAlignment = getTextAlignment();
|
||||
if (textAlignment == 1) {
|
||||
return getGravityTextAlignment();
|
||||
}
|
||||
if (textAlignment == 6 || textAlignment == 3) {
|
||||
return Layout.Alignment.ALIGN_OPPOSITE;
|
||||
}
|
||||
if (textAlignment == 4) {
|
||||
return Layout.Alignment.ALIGN_CENTER;
|
||||
}
|
||||
return Layout.Alignment.ALIGN_NORMAL;
|
||||
}
|
||||
|
||||
private void updateIconPosition(int i, int i2) {
|
||||
if (this.icon == null || getLayout() == null) {
|
||||
return;
|
||||
}
|
||||
if (isIconStart() || isIconEnd()) {
|
||||
this.iconTop = 0;
|
||||
Layout.Alignment actualTextAlignment = getActualTextAlignment();
|
||||
int i3 = this.iconGravity;
|
||||
if (i3 == 1 || i3 == 3 || ((i3 == 2 && actualTextAlignment == Layout.Alignment.ALIGN_NORMAL) || (this.iconGravity == 4 && actualTextAlignment == Layout.Alignment.ALIGN_OPPOSITE))) {
|
||||
this.iconLeft = 0;
|
||||
updateIcon(false);
|
||||
return;
|
||||
}
|
||||
int i4 = this.iconSize;
|
||||
if (i4 == 0) {
|
||||
i4 = this.icon.getIntrinsicWidth();
|
||||
}
|
||||
int textLayoutWidth = ((((i - getTextLayoutWidth()) - ViewCompat.getPaddingEnd(this)) - i4) - this.iconPadding) - ViewCompat.getPaddingStart(this);
|
||||
if (actualTextAlignment == Layout.Alignment.ALIGN_CENTER) {
|
||||
textLayoutWidth /= 2;
|
||||
}
|
||||
if (isLayoutRTL() != (this.iconGravity == 4)) {
|
||||
textLayoutWidth = -textLayoutWidth;
|
||||
}
|
||||
if (this.iconLeft != textLayoutWidth) {
|
||||
this.iconLeft = textLayoutWidth;
|
||||
updateIcon(false);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isIconTop()) {
|
||||
this.iconLeft = 0;
|
||||
if (this.iconGravity == 16) {
|
||||
this.iconTop = 0;
|
||||
updateIcon(false);
|
||||
return;
|
||||
}
|
||||
int i5 = this.iconSize;
|
||||
if (i5 == 0) {
|
||||
i5 = this.icon.getIntrinsicHeight();
|
||||
}
|
||||
int max = Math.max(0, (((((i2 - getTextHeight()) - getPaddingTop()) - i5) - this.iconPadding) - getPaddingBottom()) / 2);
|
||||
if (this.iconTop != max) {
|
||||
this.iconTop = max;
|
||||
updateIcon(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getTextLayoutWidth() {
|
||||
int lineCount = getLineCount();
|
||||
float f = 0.0f;
|
||||
for (int i = 0; i < lineCount; i++) {
|
||||
f = Math.max(f, getLayout().getLineWidth(i));
|
||||
}
|
||||
return (int) Math.ceil(f);
|
||||
}
|
||||
|
||||
private int getTextHeight() {
|
||||
if (getLineCount() > 1) {
|
||||
return getLayout().getHeight();
|
||||
}
|
||||
TextPaint paint = getPaint();
|
||||
String charSequence = getText().toString();
|
||||
if (getTransformationMethod() != null) {
|
||||
charSequence = getTransformationMethod().getTransformation(charSequence, this).toString();
|
||||
}
|
||||
Rect rect = new Rect();
|
||||
paint.getTextBounds(charSequence, 0, charSequence.length(), rect);
|
||||
return Math.min(rect.height(), getLayout().getHeight());
|
||||
}
|
||||
|
||||
private boolean isLayoutRTL() {
|
||||
return ViewCompat.getLayoutDirection(this) == 1;
|
||||
}
|
||||
|
||||
void setInternalBackground(Drawable drawable) {
|
||||
super.setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
public void setIconPadding(int i) {
|
||||
if (this.iconPadding != i) {
|
||||
this.iconPadding = i;
|
||||
setCompoundDrawablePadding(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIconSize(int i) {
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("iconSize cannot be less than 0");
|
||||
}
|
||||
if (this.iconSize != i) {
|
||||
this.iconSize = i;
|
||||
updateIcon(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIcon(Drawable drawable) {
|
||||
if (this.icon != drawable) {
|
||||
this.icon = drawable;
|
||||
updateIcon(true);
|
||||
updateIconPosition(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public void setIconResource(int i) {
|
||||
setIcon(i != 0 ? AppCompatResources.getDrawable(getContext(), i) : null);
|
||||
}
|
||||
|
||||
public void setIconTint(ColorStateList colorStateList) {
|
||||
if (this.iconTint != colorStateList) {
|
||||
this.iconTint = colorStateList;
|
||||
updateIcon(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIconTintResource(int i) {
|
||||
setIconTint(AppCompatResources.getColorStateList(getContext(), i));
|
||||
}
|
||||
|
||||
public void setIconTintMode(PorterDuff.Mode mode) {
|
||||
if (this.iconTintMode != mode) {
|
||||
this.iconTintMode = mode;
|
||||
updateIcon(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIcon(boolean z) {
|
||||
Drawable drawable = this.icon;
|
||||
if (drawable != null) {
|
||||
Drawable mutate = DrawableCompat.wrap(drawable).mutate();
|
||||
this.icon = mutate;
|
||||
DrawableCompat.setTintList(mutate, this.iconTint);
|
||||
PorterDuff.Mode mode = this.iconTintMode;
|
||||
if (mode != null) {
|
||||
DrawableCompat.setTintMode(this.icon, mode);
|
||||
}
|
||||
int i = this.iconSize;
|
||||
if (i == 0) {
|
||||
i = this.icon.getIntrinsicWidth();
|
||||
}
|
||||
int i2 = this.iconSize;
|
||||
if (i2 == 0) {
|
||||
i2 = this.icon.getIntrinsicHeight();
|
||||
}
|
||||
Drawable drawable2 = this.icon;
|
||||
int i3 = this.iconLeft;
|
||||
int i4 = this.iconTop;
|
||||
drawable2.setBounds(i3, i4, i + i3, i2 + i4);
|
||||
this.icon.setVisible(true, z);
|
||||
}
|
||||
if (z) {
|
||||
resetIconDrawable();
|
||||
return;
|
||||
}
|
||||
Drawable[] compoundDrawablesRelative = TextViewCompat.getCompoundDrawablesRelative(this);
|
||||
Drawable drawable3 = compoundDrawablesRelative[0];
|
||||
Drawable drawable4 = compoundDrawablesRelative[1];
|
||||
Drawable drawable5 = compoundDrawablesRelative[2];
|
||||
if ((!isIconStart() || drawable3 == this.icon) && ((!isIconEnd() || drawable5 == this.icon) && (!isIconTop() || drawable4 == this.icon))) {
|
||||
return;
|
||||
}
|
||||
resetIconDrawable();
|
||||
}
|
||||
|
||||
private void resetIconDrawable() {
|
||||
if (isIconStart()) {
|
||||
TextViewCompat.setCompoundDrawablesRelative(this, this.icon, null, null, null);
|
||||
} else if (isIconEnd()) {
|
||||
TextViewCompat.setCompoundDrawablesRelative(this, null, null, this.icon, null);
|
||||
} else if (isIconTop()) {
|
||||
TextViewCompat.setCompoundDrawablesRelative(this, null, this.icon, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRippleColor(ColorStateList colorStateList) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setRippleColor(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRippleColorResource(int i) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
setRippleColor(AppCompatResources.getColorStateList(getContext(), i));
|
||||
}
|
||||
}
|
||||
|
||||
public ColorStateList getRippleColor() {
|
||||
if (isUsingOriginalBackground()) {
|
||||
return this.materialButtonHelper.getRippleColor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setStrokeColor(ColorStateList colorStateList) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setStrokeColor(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStrokeColorResource(int i) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
setStrokeColor(AppCompatResources.getColorStateList(getContext(), i));
|
||||
}
|
||||
}
|
||||
|
||||
public ColorStateList getStrokeColor() {
|
||||
if (isUsingOriginalBackground()) {
|
||||
return this.materialButtonHelper.getStrokeColor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setStrokeWidth(int i) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setStrokeWidth(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStrokeWidthResource(int i) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
setStrokeWidth(getResources().getDimensionPixelSize(i));
|
||||
}
|
||||
}
|
||||
|
||||
public int getStrokeWidth() {
|
||||
if (isUsingOriginalBackground()) {
|
||||
return this.materialButtonHelper.getStrokeWidth();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setCornerRadius(int i) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setCornerRadius(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCornerRadiusResource(int i) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
setCornerRadius(getResources().getDimensionPixelSize(i));
|
||||
}
|
||||
}
|
||||
|
||||
public int getCornerRadius() {
|
||||
if (isUsingOriginalBackground()) {
|
||||
return this.materialButtonHelper.getCornerRadius();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setIconGravity(int i) {
|
||||
if (this.iconGravity != i) {
|
||||
this.iconGravity = i;
|
||||
updateIconPosition(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public void setInsetBottom(int i) {
|
||||
this.materialButtonHelper.setInsetBottom(i);
|
||||
}
|
||||
|
||||
public int getInsetBottom() {
|
||||
return this.materialButtonHelper.getInsetBottom();
|
||||
}
|
||||
|
||||
public void setInsetTop(int i) {
|
||||
this.materialButtonHelper.setInsetTop(i);
|
||||
}
|
||||
|
||||
public int getInsetTop() {
|
||||
return this.materialButtonHelper.getInsetTop();
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
protected int[] onCreateDrawableState(int i) {
|
||||
int[] onCreateDrawableState = super.onCreateDrawableState(i + 2);
|
||||
if (isCheckable()) {
|
||||
mergeDrawableStates(onCreateDrawableState, CHECKABLE_STATE_SET);
|
||||
}
|
||||
if (isChecked()) {
|
||||
mergeDrawableStates(onCreateDrawableState, CHECKED_STATE_SET);
|
||||
}
|
||||
return onCreateDrawableState;
|
||||
}
|
||||
|
||||
public void addOnCheckedChangeListener(OnCheckedChangeListener onCheckedChangeListener) {
|
||||
this.onCheckedChangeListeners.add(onCheckedChangeListener);
|
||||
}
|
||||
|
||||
public void removeOnCheckedChangeListener(OnCheckedChangeListener onCheckedChangeListener) {
|
||||
this.onCheckedChangeListeners.remove(onCheckedChangeListener);
|
||||
}
|
||||
|
||||
public void clearOnCheckedChangeListeners() {
|
||||
this.onCheckedChangeListeners.clear();
|
||||
}
|
||||
|
||||
@Override // android.widget.Checkable
|
||||
public void setChecked(boolean z) {
|
||||
if (isCheckable() && isEnabled() && this.checked != z) {
|
||||
this.checked = z;
|
||||
refreshDrawableState();
|
||||
if (getParent() instanceof MaterialButtonToggleGroup) {
|
||||
((MaterialButtonToggleGroup) getParent()).onButtonCheckedStateChanged(this, this.checked);
|
||||
}
|
||||
if (this.broadcasting) {
|
||||
return;
|
||||
}
|
||||
this.broadcasting = true;
|
||||
Iterator<OnCheckedChangeListener> it = this.onCheckedChangeListeners.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onCheckedChanged(this, this.checked);
|
||||
}
|
||||
this.broadcasting = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.Checkable
|
||||
public void toggle() {
|
||||
setChecked(!this.checked);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean performClick() {
|
||||
if (this.materialButtonHelper.isToggleCheckedStateOnClick()) {
|
||||
toggle();
|
||||
}
|
||||
return super.performClick();
|
||||
}
|
||||
|
||||
public boolean isToggleCheckedStateOnClick() {
|
||||
return this.materialButtonHelper.isToggleCheckedStateOnClick();
|
||||
}
|
||||
|
||||
public void setToggleCheckedStateOnClick(boolean z) {
|
||||
this.materialButtonHelper.setToggleCheckedStateOnClick(z);
|
||||
}
|
||||
|
||||
public boolean isCheckable() {
|
||||
MaterialButtonHelper materialButtonHelper = this.materialButtonHelper;
|
||||
return materialButtonHelper != null && materialButtonHelper.isCheckable();
|
||||
}
|
||||
|
||||
public void setCheckable(boolean z) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setCheckable(z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.Shapeable
|
||||
public void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setShapeAppearanceModel(shapeAppearanceModel);
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("Attempted to set ShapeAppearanceModel on a MaterialButton which has an overwritten background.");
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.Shapeable
|
||||
public ShapeAppearanceModel getShapeAppearanceModel() {
|
||||
if (isUsingOriginalBackground()) {
|
||||
return this.materialButtonHelper.getShapeAppearanceModel();
|
||||
}
|
||||
throw new IllegalStateException("Attempted to get ShapeAppearanceModel from a MaterialButton which has an overwritten background.");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setPressed(boolean z) {
|
||||
OnPressedChangeListener onPressedChangeListener = this.onPressedChangeListenerInternal;
|
||||
if (onPressedChangeListener != null) {
|
||||
onPressedChangeListener.onPressedChanged(this, z);
|
||||
}
|
||||
super.setPressed(z);
|
||||
}
|
||||
|
||||
private boolean isUsingOriginalBackground() {
|
||||
MaterialButtonHelper materialButtonHelper = this.materialButtonHelper;
|
||||
return (materialButtonHelper == null || materialButtonHelper.isBackgroundOverwritten()) ? false : true;
|
||||
}
|
||||
|
||||
void setShouldDrawSurfaceColorStroke(boolean z) {
|
||||
if (isUsingOriginalBackground()) {
|
||||
this.materialButtonHelper.setShouldDrawSurfaceColorStroke(z);
|
||||
}
|
||||
}
|
||||
|
||||
static class SavedState extends AbsSavedState {
|
||||
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: com.google.android.material.button.MaterialButton.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);
|
||||
if (classLoader == null) {
|
||||
getClass().getClassLoader();
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
package com.google.android.material.button;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.graphics.drawable.RippleDrawable;
|
||||
import android.os.Build;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
import com.google.android.material.ripple.RippleDrawableCompat;
|
||||
import com.google.android.material.ripple.RippleUtils;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.google.android.material.shape.Shapeable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class MaterialButtonHelper {
|
||||
private static final boolean IS_LOLLIPOP;
|
||||
private static final boolean IS_MIN_LOLLIPOP = true;
|
||||
private ColorStateList backgroundTint;
|
||||
private PorterDuff.Mode backgroundTintMode;
|
||||
private boolean checkable;
|
||||
private int cornerRadius;
|
||||
private int elevation;
|
||||
private int insetBottom;
|
||||
private int insetLeft;
|
||||
private int insetRight;
|
||||
private int insetTop;
|
||||
private Drawable maskDrawable;
|
||||
private final MaterialButton materialButton;
|
||||
private ColorStateList rippleColor;
|
||||
private LayerDrawable rippleDrawable;
|
||||
private ShapeAppearanceModel shapeAppearanceModel;
|
||||
private ColorStateList strokeColor;
|
||||
private int strokeWidth;
|
||||
private boolean shouldDrawSurfaceColorStroke = false;
|
||||
private boolean backgroundOverwritten = false;
|
||||
private boolean cornerRadiusSet = false;
|
||||
private boolean toggleCheckedStateOnClick = true;
|
||||
|
||||
static {
|
||||
IS_LOLLIPOP = Build.VERSION.SDK_INT <= 22;
|
||||
}
|
||||
|
||||
int getCornerRadius() {
|
||||
return this.cornerRadius;
|
||||
}
|
||||
|
||||
public int getInsetBottom() {
|
||||
return this.insetBottom;
|
||||
}
|
||||
|
||||
public int getInsetTop() {
|
||||
return this.insetTop;
|
||||
}
|
||||
|
||||
ColorStateList getRippleColor() {
|
||||
return this.rippleColor;
|
||||
}
|
||||
|
||||
ShapeAppearanceModel getShapeAppearanceModel() {
|
||||
return this.shapeAppearanceModel;
|
||||
}
|
||||
|
||||
ColorStateList getStrokeColor() {
|
||||
return this.strokeColor;
|
||||
}
|
||||
|
||||
int getStrokeWidth() {
|
||||
return this.strokeWidth;
|
||||
}
|
||||
|
||||
ColorStateList getSupportBackgroundTintList() {
|
||||
return this.backgroundTint;
|
||||
}
|
||||
|
||||
PorterDuff.Mode getSupportBackgroundTintMode() {
|
||||
return this.backgroundTintMode;
|
||||
}
|
||||
|
||||
boolean isBackgroundOverwritten() {
|
||||
return this.backgroundOverwritten;
|
||||
}
|
||||
|
||||
boolean isCheckable() {
|
||||
return this.checkable;
|
||||
}
|
||||
|
||||
boolean isToggleCheckedStateOnClick() {
|
||||
return this.toggleCheckedStateOnClick;
|
||||
}
|
||||
|
||||
void setCheckable(boolean z) {
|
||||
this.checkable = z;
|
||||
}
|
||||
|
||||
void setToggleCheckedStateOnClick(boolean z) {
|
||||
this.toggleCheckedStateOnClick = z;
|
||||
}
|
||||
|
||||
MaterialButtonHelper(MaterialButton materialButton, ShapeAppearanceModel shapeAppearanceModel) {
|
||||
this.materialButton = materialButton;
|
||||
this.shapeAppearanceModel = shapeAppearanceModel;
|
||||
}
|
||||
|
||||
void loadFromAttributes(TypedArray typedArray) {
|
||||
this.insetLeft = typedArray.getDimensionPixelOffset(R.styleable.MaterialButton_android_insetLeft, 0);
|
||||
this.insetRight = typedArray.getDimensionPixelOffset(R.styleable.MaterialButton_android_insetRight, 0);
|
||||
this.insetTop = typedArray.getDimensionPixelOffset(R.styleable.MaterialButton_android_insetTop, 0);
|
||||
this.insetBottom = typedArray.getDimensionPixelOffset(R.styleable.MaterialButton_android_insetBottom, 0);
|
||||
if (typedArray.hasValue(R.styleable.MaterialButton_cornerRadius)) {
|
||||
int dimensionPixelSize = typedArray.getDimensionPixelSize(R.styleable.MaterialButton_cornerRadius, -1);
|
||||
this.cornerRadius = dimensionPixelSize;
|
||||
setShapeAppearanceModel(this.shapeAppearanceModel.withCornerSize(dimensionPixelSize));
|
||||
this.cornerRadiusSet = true;
|
||||
}
|
||||
this.strokeWidth = typedArray.getDimensionPixelSize(R.styleable.MaterialButton_strokeWidth, 0);
|
||||
this.backgroundTintMode = ViewUtils.parseTintMode(typedArray.getInt(R.styleable.MaterialButton_backgroundTintMode, -1), PorterDuff.Mode.SRC_IN);
|
||||
this.backgroundTint = MaterialResources.getColorStateList(this.materialButton.getContext(), typedArray, R.styleable.MaterialButton_backgroundTint);
|
||||
this.strokeColor = MaterialResources.getColorStateList(this.materialButton.getContext(), typedArray, R.styleable.MaterialButton_strokeColor);
|
||||
this.rippleColor = MaterialResources.getColorStateList(this.materialButton.getContext(), typedArray, R.styleable.MaterialButton_rippleColor);
|
||||
this.checkable = typedArray.getBoolean(R.styleable.MaterialButton_android_checkable, false);
|
||||
this.elevation = typedArray.getDimensionPixelSize(R.styleable.MaterialButton_elevation, 0);
|
||||
this.toggleCheckedStateOnClick = typedArray.getBoolean(R.styleable.MaterialButton_toggleCheckedStateOnClick, true);
|
||||
int paddingStart = ViewCompat.getPaddingStart(this.materialButton);
|
||||
int paddingTop = this.materialButton.getPaddingTop();
|
||||
int paddingEnd = ViewCompat.getPaddingEnd(this.materialButton);
|
||||
int paddingBottom = this.materialButton.getPaddingBottom();
|
||||
if (typedArray.hasValue(R.styleable.MaterialButton_android_background)) {
|
||||
setBackgroundOverwritten();
|
||||
} else {
|
||||
updateBackground();
|
||||
}
|
||||
ViewCompat.setPaddingRelative(this.materialButton, paddingStart + this.insetLeft, paddingTop + this.insetTop, paddingEnd + this.insetRight, paddingBottom + this.insetBottom);
|
||||
}
|
||||
|
||||
private void updateBackground() {
|
||||
this.materialButton.setInternalBackground(createBackground());
|
||||
MaterialShapeDrawable materialShapeDrawable = getMaterialShapeDrawable();
|
||||
if (materialShapeDrawable != null) {
|
||||
materialShapeDrawable.setElevation(this.elevation);
|
||||
materialShapeDrawable.setState(this.materialButton.getDrawableState());
|
||||
}
|
||||
}
|
||||
|
||||
void setBackgroundOverwritten() {
|
||||
this.backgroundOverwritten = true;
|
||||
this.materialButton.setSupportBackgroundTintList(this.backgroundTint);
|
||||
this.materialButton.setSupportBackgroundTintMode(this.backgroundTintMode);
|
||||
}
|
||||
|
||||
private InsetDrawable wrapDrawableWithInset(Drawable drawable) {
|
||||
return new InsetDrawable(drawable, this.insetLeft, this.insetTop, this.insetRight, this.insetBottom);
|
||||
}
|
||||
|
||||
void setSupportBackgroundTintList(ColorStateList colorStateList) {
|
||||
if (this.backgroundTint != colorStateList) {
|
||||
this.backgroundTint = colorStateList;
|
||||
if (getMaterialShapeDrawable() != null) {
|
||||
DrawableCompat.setTintList(getMaterialShapeDrawable(), this.backgroundTint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
|
||||
if (this.backgroundTintMode != mode) {
|
||||
this.backgroundTintMode = mode;
|
||||
if (getMaterialShapeDrawable() == null || this.backgroundTintMode == null) {
|
||||
return;
|
||||
}
|
||||
DrawableCompat.setTintMode(getMaterialShapeDrawable(), this.backgroundTintMode);
|
||||
}
|
||||
}
|
||||
|
||||
void setShouldDrawSurfaceColorStroke(boolean z) {
|
||||
this.shouldDrawSurfaceColorStroke = z;
|
||||
updateStroke();
|
||||
}
|
||||
|
||||
private Drawable createBackground() {
|
||||
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(this.shapeAppearanceModel);
|
||||
materialShapeDrawable.initializeElevationOverlay(this.materialButton.getContext());
|
||||
DrawableCompat.setTintList(materialShapeDrawable, this.backgroundTint);
|
||||
PorterDuff.Mode mode = this.backgroundTintMode;
|
||||
if (mode != null) {
|
||||
DrawableCompat.setTintMode(materialShapeDrawable, mode);
|
||||
}
|
||||
materialShapeDrawable.setStroke(this.strokeWidth, this.strokeColor);
|
||||
MaterialShapeDrawable materialShapeDrawable2 = new MaterialShapeDrawable(this.shapeAppearanceModel);
|
||||
materialShapeDrawable2.setTint(0);
|
||||
materialShapeDrawable2.setStroke(this.strokeWidth, this.shouldDrawSurfaceColorStroke ? MaterialColors.getColor(this.materialButton, R.attr.colorSurface) : 0);
|
||||
if (IS_MIN_LOLLIPOP) {
|
||||
MaterialShapeDrawable materialShapeDrawable3 = new MaterialShapeDrawable(this.shapeAppearanceModel);
|
||||
this.maskDrawable = materialShapeDrawable3;
|
||||
DrawableCompat.setTint(materialShapeDrawable3, -1);
|
||||
RippleDrawable rippleDrawable = new RippleDrawable(RippleUtils.sanitizeRippleDrawableColor(this.rippleColor), wrapDrawableWithInset(new LayerDrawable(new Drawable[]{materialShapeDrawable2, materialShapeDrawable})), this.maskDrawable);
|
||||
this.rippleDrawable = rippleDrawable;
|
||||
return rippleDrawable;
|
||||
}
|
||||
RippleDrawableCompat rippleDrawableCompat = new RippleDrawableCompat(this.shapeAppearanceModel);
|
||||
this.maskDrawable = rippleDrawableCompat;
|
||||
DrawableCompat.setTintList(rippleDrawableCompat, RippleUtils.sanitizeRippleDrawableColor(this.rippleColor));
|
||||
LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{materialShapeDrawable2, materialShapeDrawable, this.maskDrawable});
|
||||
this.rippleDrawable = layerDrawable;
|
||||
return wrapDrawableWithInset(layerDrawable);
|
||||
}
|
||||
|
||||
void updateMaskBounds(int i, int i2) {
|
||||
Drawable drawable = this.maskDrawable;
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(this.insetLeft, this.insetTop, i2 - this.insetRight, i - this.insetBottom);
|
||||
}
|
||||
}
|
||||
|
||||
void setBackgroundColor(int i) {
|
||||
if (getMaterialShapeDrawable() != null) {
|
||||
getMaterialShapeDrawable().setTint(i);
|
||||
}
|
||||
}
|
||||
|
||||
void setRippleColor(ColorStateList colorStateList) {
|
||||
if (this.rippleColor != colorStateList) {
|
||||
this.rippleColor = colorStateList;
|
||||
boolean z = IS_MIN_LOLLIPOP;
|
||||
if (z && (this.materialButton.getBackground() instanceof RippleDrawable)) {
|
||||
((RippleDrawable) this.materialButton.getBackground()).setColor(RippleUtils.sanitizeRippleDrawableColor(colorStateList));
|
||||
} else {
|
||||
if (z || !(this.materialButton.getBackground() instanceof RippleDrawableCompat)) {
|
||||
return;
|
||||
}
|
||||
((RippleDrawableCompat) this.materialButton.getBackground()).setTintList(RippleUtils.sanitizeRippleDrawableColor(colorStateList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setStrokeColor(ColorStateList colorStateList) {
|
||||
if (this.strokeColor != colorStateList) {
|
||||
this.strokeColor = colorStateList;
|
||||
updateStroke();
|
||||
}
|
||||
}
|
||||
|
||||
void setStrokeWidth(int i) {
|
||||
if (this.strokeWidth != i) {
|
||||
this.strokeWidth = i;
|
||||
updateStroke();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStroke() {
|
||||
MaterialShapeDrawable materialShapeDrawable = getMaterialShapeDrawable();
|
||||
MaterialShapeDrawable surfaceColorStrokeDrawable = getSurfaceColorStrokeDrawable();
|
||||
if (materialShapeDrawable != null) {
|
||||
materialShapeDrawable.setStroke(this.strokeWidth, this.strokeColor);
|
||||
if (surfaceColorStrokeDrawable != null) {
|
||||
surfaceColorStrokeDrawable.setStroke(this.strokeWidth, this.shouldDrawSurfaceColorStroke ? MaterialColors.getColor(this.materialButton, R.attr.colorSurface) : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setCornerRadius(int i) {
|
||||
if (this.cornerRadiusSet && this.cornerRadius == i) {
|
||||
return;
|
||||
}
|
||||
this.cornerRadius = i;
|
||||
this.cornerRadiusSet = true;
|
||||
setShapeAppearanceModel(this.shapeAppearanceModel.withCornerSize(i));
|
||||
}
|
||||
|
||||
private MaterialShapeDrawable getMaterialShapeDrawable(boolean z) {
|
||||
LayerDrawable layerDrawable = this.rippleDrawable;
|
||||
if (layerDrawable == null || layerDrawable.getNumberOfLayers() <= 0) {
|
||||
return null;
|
||||
}
|
||||
if (IS_MIN_LOLLIPOP) {
|
||||
return (MaterialShapeDrawable) ((LayerDrawable) ((InsetDrawable) this.rippleDrawable.getDrawable(0)).getDrawable()).getDrawable(!z ? 1 : 0);
|
||||
}
|
||||
return (MaterialShapeDrawable) this.rippleDrawable.getDrawable(!z ? 1 : 0);
|
||||
}
|
||||
|
||||
MaterialShapeDrawable getMaterialShapeDrawable() {
|
||||
return getMaterialShapeDrawable(false);
|
||||
}
|
||||
|
||||
private MaterialShapeDrawable getSurfaceColorStrokeDrawable() {
|
||||
return getMaterialShapeDrawable(true);
|
||||
}
|
||||
|
||||
private void updateButtonShape(ShapeAppearanceModel shapeAppearanceModel) {
|
||||
if (IS_LOLLIPOP && !this.backgroundOverwritten) {
|
||||
int paddingStart = ViewCompat.getPaddingStart(this.materialButton);
|
||||
int paddingTop = this.materialButton.getPaddingTop();
|
||||
int paddingEnd = ViewCompat.getPaddingEnd(this.materialButton);
|
||||
int paddingBottom = this.materialButton.getPaddingBottom();
|
||||
updateBackground();
|
||||
ViewCompat.setPaddingRelative(this.materialButton, paddingStart, paddingTop, paddingEnd, paddingBottom);
|
||||
return;
|
||||
}
|
||||
if (getMaterialShapeDrawable() != null) {
|
||||
getMaterialShapeDrawable().setShapeAppearanceModel(shapeAppearanceModel);
|
||||
}
|
||||
if (getSurfaceColorStrokeDrawable() != null) {
|
||||
getSurfaceColorStrokeDrawable().setShapeAppearanceModel(shapeAppearanceModel);
|
||||
}
|
||||
if (getMaskDrawable() != null) {
|
||||
getMaskDrawable().setShapeAppearanceModel(shapeAppearanceModel);
|
||||
}
|
||||
}
|
||||
|
||||
public Shapeable getMaskDrawable() {
|
||||
LayerDrawable layerDrawable = this.rippleDrawable;
|
||||
if (layerDrawable == null || layerDrawable.getNumberOfLayers() <= 1) {
|
||||
return null;
|
||||
}
|
||||
if (this.rippleDrawable.getNumberOfLayers() > 2) {
|
||||
return (Shapeable) this.rippleDrawable.getDrawable(2);
|
||||
}
|
||||
return (Shapeable) this.rippleDrawable.getDrawable(1);
|
||||
}
|
||||
|
||||
void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) {
|
||||
this.shapeAppearanceModel = shapeAppearanceModel;
|
||||
updateButtonShape(shapeAppearanceModel);
|
||||
}
|
||||
|
||||
public void setInsetBottom(int i) {
|
||||
setVerticalInsets(this.insetTop, i);
|
||||
}
|
||||
|
||||
public void setInsetTop(int i) {
|
||||
setVerticalInsets(i, this.insetBottom);
|
||||
}
|
||||
|
||||
private void setVerticalInsets(int i, int i2) {
|
||||
int paddingStart = ViewCompat.getPaddingStart(this.materialButton);
|
||||
int paddingTop = this.materialButton.getPaddingTop();
|
||||
int paddingEnd = ViewCompat.getPaddingEnd(this.materialButton);
|
||||
int paddingBottom = this.materialButton.getPaddingBottom();
|
||||
int i3 = this.insetTop;
|
||||
int i4 = this.insetBottom;
|
||||
this.insetBottom = i2;
|
||||
this.insetTop = i;
|
||||
if (!this.backgroundOverwritten) {
|
||||
updateBackground();
|
||||
}
|
||||
ViewCompat.setPaddingRelative(this.materialButton, paddingStart, (paddingTop + i) - i3, paddingEnd, (paddingBottom + i2) - i4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,547 @@
|
||||
package com.google.android.material.button;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.ToggleButton;
|
||||
import androidx.core.view.AccessibilityDelegateCompat;
|
||||
import androidx.core.view.MarginLayoutParamsCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import com.google.android.material.shape.AbsoluteCornerSize;
|
||||
import com.google.android.material.shape.CornerSize;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MaterialButtonToggleGroup extends LinearLayout {
|
||||
private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_MaterialButtonToggleGroup;
|
||||
private static final String LOG_TAG = "MButtonToggleGroup";
|
||||
private Set<Integer> checkedIds;
|
||||
private Integer[] childOrder;
|
||||
private final Comparator<MaterialButton> childOrderComparator;
|
||||
private final int defaultCheckId;
|
||||
private final LinkedHashSet<OnButtonCheckedListener> onButtonCheckedListeners;
|
||||
private final List<CornerData> originalCornerData;
|
||||
private final PressedStateTracker pressedStateTracker;
|
||||
private boolean selectionRequired;
|
||||
private boolean singleSelection;
|
||||
private boolean skipCheckedStateTracker;
|
||||
|
||||
public interface OnButtonCheckedListener {
|
||||
void onButtonChecked(MaterialButtonToggleGroup materialButtonToggleGroup, int i, boolean z);
|
||||
}
|
||||
|
||||
public boolean isSelectionRequired() {
|
||||
return this.selectionRequired;
|
||||
}
|
||||
|
||||
public boolean isSingleSelection() {
|
||||
return this.singleSelection;
|
||||
}
|
||||
|
||||
public void setSelectionRequired(boolean z) {
|
||||
this.selectionRequired = z;
|
||||
}
|
||||
|
||||
public MaterialButtonToggleGroup(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MaterialButtonToggleGroup(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.materialButtonToggleGroupStyle);
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public MaterialButtonToggleGroup(android.content.Context r7, android.util.AttributeSet r8, int r9) {
|
||||
/*
|
||||
r6 = this;
|
||||
int r4 = com.google.android.material.button.MaterialButtonToggleGroup.DEF_STYLE_RES
|
||||
android.content.Context r7 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r7, r8, r9, r4)
|
||||
r6.<init>(r7, r8, r9)
|
||||
java.util.ArrayList r7 = new java.util.ArrayList
|
||||
r7.<init>()
|
||||
r6.originalCornerData = r7
|
||||
com.google.android.material.button.MaterialButtonToggleGroup$PressedStateTracker r7 = new com.google.android.material.button.MaterialButtonToggleGroup$PressedStateTracker
|
||||
r0 = 0
|
||||
r7.<init>()
|
||||
r6.pressedStateTracker = r7
|
||||
java.util.LinkedHashSet r7 = new java.util.LinkedHashSet
|
||||
r7.<init>()
|
||||
r6.onButtonCheckedListeners = r7
|
||||
com.google.android.material.button.MaterialButtonToggleGroup$1 r7 = new com.google.android.material.button.MaterialButtonToggleGroup$1
|
||||
r7.<init>()
|
||||
r6.childOrderComparator = r7
|
||||
r7 = 0
|
||||
r6.skipCheckedStateTracker = r7
|
||||
java.util.HashSet r0 = new java.util.HashSet
|
||||
r0.<init>()
|
||||
r6.checkedIds = r0
|
||||
android.content.Context r0 = r6.getContext()
|
||||
int[] r2 = com.google.android.material.R.styleable.MaterialButtonToggleGroup
|
||||
int[] r5 = new int[r7]
|
||||
r1 = r8
|
||||
r3 = r9
|
||||
android.content.res.TypedArray r8 = com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(r0, r1, r2, r3, r4, r5)
|
||||
int r9 = com.google.android.material.R.styleable.MaterialButtonToggleGroup_singleSelection
|
||||
boolean r9 = r8.getBoolean(r9, r7)
|
||||
r6.setSingleSelection(r9)
|
||||
int r9 = com.google.android.material.R.styleable.MaterialButtonToggleGroup_checkedButton
|
||||
r0 = -1
|
||||
int r9 = r8.getResourceId(r9, r0)
|
||||
r6.defaultCheckId = r9
|
||||
int r9 = com.google.android.material.R.styleable.MaterialButtonToggleGroup_selectionRequired
|
||||
boolean r7 = r8.getBoolean(r9, r7)
|
||||
r6.selectionRequired = r7
|
||||
r7 = 1
|
||||
r6.setChildrenDrawingOrderEnabled(r7)
|
||||
int r9 = com.google.android.material.R.styleable.MaterialButtonToggleGroup_android_enabled
|
||||
boolean r9 = r8.getBoolean(r9, r7)
|
||||
r6.setEnabled(r9)
|
||||
r8.recycle()
|
||||
androidx.core.view.ViewCompat.setImportantForAccessibility(r6, r7)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.button.MaterialButtonToggleGroup.<init>(android.content.Context, android.util.AttributeSet, int):void");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
int i = this.defaultCheckId;
|
||||
if (i != -1) {
|
||||
updateCheckedIds(Collections.singleton(Integer.valueOf(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
updateChildOrder();
|
||||
super.dispatchDraw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
|
||||
if (!(view instanceof MaterialButton)) {
|
||||
Log.e(LOG_TAG, "Child views must be of type MaterialButton.");
|
||||
return;
|
||||
}
|
||||
super.addView(view, i, layoutParams);
|
||||
MaterialButton materialButton = (MaterialButton) view;
|
||||
setGeneratedIdIfNeeded(materialButton);
|
||||
setupButtonChild(materialButton);
|
||||
checkInternal(materialButton.getId(), materialButton.isChecked());
|
||||
ShapeAppearanceModel shapeAppearanceModel = materialButton.getShapeAppearanceModel();
|
||||
this.originalCornerData.add(new CornerData(shapeAppearanceModel.getTopLeftCornerSize(), shapeAppearanceModel.getBottomLeftCornerSize(), shapeAppearanceModel.getTopRightCornerSize(), shapeAppearanceModel.getBottomRightCornerSize()));
|
||||
materialButton.setEnabled(isEnabled());
|
||||
ViewCompat.setAccessibilityDelegate(materialButton, new AccessibilityDelegateCompat() { // from class: com.google.android.material.button.MaterialButtonToggleGroup.2
|
||||
@Override // androidx.core.view.AccessibilityDelegateCompat
|
||||
public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||||
super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat);
|
||||
accessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(0, 1, MaterialButtonToggleGroup.this.getIndexWithinVisibleButtons(view2), 1, false, ((MaterialButton) view2).isChecked()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
public void onViewRemoved(View view) {
|
||||
super.onViewRemoved(view);
|
||||
if (view instanceof MaterialButton) {
|
||||
((MaterialButton) view).setOnPressedChangeListenerInternal(null);
|
||||
}
|
||||
int indexOfChild = indexOfChild(view);
|
||||
if (indexOfChild >= 0) {
|
||||
this.originalCornerData.remove(indexOfChild);
|
||||
}
|
||||
updateChildShapes();
|
||||
adjustChildMarginsAndUpdateLayout();
|
||||
}
|
||||
|
||||
@Override // android.widget.LinearLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
updateChildShapes();
|
||||
adjustChildMarginsAndUpdateLayout();
|
||||
super.onMeasure(i, i2);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||||
AccessibilityNodeInfoCompat.wrap(accessibilityNodeInfo).setCollectionInfo(AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(1, getVisibleButtonCount(), false, isSingleSelection() ? 1 : 2));
|
||||
}
|
||||
|
||||
public void check(int i) {
|
||||
checkInternal(i, true);
|
||||
}
|
||||
|
||||
public void uncheck(int i) {
|
||||
checkInternal(i, false);
|
||||
}
|
||||
|
||||
public void clearChecked() {
|
||||
updateCheckedIds(new HashSet());
|
||||
}
|
||||
|
||||
public int getCheckedButtonId() {
|
||||
if (!this.singleSelection || this.checkedIds.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
return this.checkedIds.iterator().next().intValue();
|
||||
}
|
||||
|
||||
public List<Integer> getCheckedButtonIds() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
int id = getChildButton(i).getId();
|
||||
if (this.checkedIds.contains(Integer.valueOf(id))) {
|
||||
arrayList.add(Integer.valueOf(id));
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public void addOnButtonCheckedListener(OnButtonCheckedListener onButtonCheckedListener) {
|
||||
this.onButtonCheckedListeners.add(onButtonCheckedListener);
|
||||
}
|
||||
|
||||
public void removeOnButtonCheckedListener(OnButtonCheckedListener onButtonCheckedListener) {
|
||||
this.onButtonCheckedListeners.remove(onButtonCheckedListener);
|
||||
}
|
||||
|
||||
public void clearOnButtonCheckedListeners() {
|
||||
this.onButtonCheckedListeners.clear();
|
||||
}
|
||||
|
||||
public void setSingleSelection(boolean z) {
|
||||
if (this.singleSelection != z) {
|
||||
this.singleSelection = z;
|
||||
clearChecked();
|
||||
}
|
||||
updateChildrenA11yClassName();
|
||||
}
|
||||
|
||||
private void updateChildrenA11yClassName() {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
getChildButton(i).setA11yClassName((this.singleSelection ? RadioButton.class : ToggleButton.class).getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void setSingleSelection(int i) {
|
||||
setSingleSelection(getResources().getBoolean(i));
|
||||
}
|
||||
|
||||
private void setCheckedStateForView(int i, boolean z) {
|
||||
View findViewById = findViewById(i);
|
||||
if (findViewById instanceof MaterialButton) {
|
||||
this.skipCheckedStateTracker = true;
|
||||
((MaterialButton) findViewById).setChecked(z);
|
||||
this.skipCheckedStateTracker = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void adjustChildMarginsAndUpdateLayout() {
|
||||
int firstVisibleChildIndex = getFirstVisibleChildIndex();
|
||||
if (firstVisibleChildIndex == -1) {
|
||||
return;
|
||||
}
|
||||
for (int i = firstVisibleChildIndex + 1; i < getChildCount(); i++) {
|
||||
MaterialButton childButton = getChildButton(i);
|
||||
int min = Math.min(childButton.getStrokeWidth(), getChildButton(i - 1).getStrokeWidth());
|
||||
LinearLayout.LayoutParams buildLayoutParams = buildLayoutParams(childButton);
|
||||
if (getOrientation() == 0) {
|
||||
MarginLayoutParamsCompat.setMarginEnd(buildLayoutParams, 0);
|
||||
MarginLayoutParamsCompat.setMarginStart(buildLayoutParams, -min);
|
||||
buildLayoutParams.topMargin = 0;
|
||||
} else {
|
||||
buildLayoutParams.bottomMargin = 0;
|
||||
buildLayoutParams.topMargin = -min;
|
||||
MarginLayoutParamsCompat.setMarginStart(buildLayoutParams, 0);
|
||||
}
|
||||
childButton.setLayoutParams(buildLayoutParams);
|
||||
}
|
||||
resetChildMargins(firstVisibleChildIndex);
|
||||
}
|
||||
|
||||
private MaterialButton getChildButton(int i) {
|
||||
return (MaterialButton) getChildAt(i);
|
||||
}
|
||||
|
||||
private void resetChildMargins(int i) {
|
||||
if (getChildCount() == 0 || i == -1) {
|
||||
return;
|
||||
}
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getChildButton(i).getLayoutParams();
|
||||
if (getOrientation() == 1) {
|
||||
layoutParams.topMargin = 0;
|
||||
layoutParams.bottomMargin = 0;
|
||||
} else {
|
||||
MarginLayoutParamsCompat.setMarginEnd(layoutParams, 0);
|
||||
MarginLayoutParamsCompat.setMarginStart(layoutParams, 0);
|
||||
layoutParams.leftMargin = 0;
|
||||
layoutParams.rightMargin = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void updateChildShapes() {
|
||||
int childCount = getChildCount();
|
||||
int firstVisibleChildIndex = getFirstVisibleChildIndex();
|
||||
int lastVisibleChildIndex = getLastVisibleChildIndex();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
MaterialButton childButton = getChildButton(i);
|
||||
if (childButton.getVisibility() != 8) {
|
||||
ShapeAppearanceModel.Builder builder = childButton.getShapeAppearanceModel().toBuilder();
|
||||
updateBuilderWithCornerData(builder, getNewCornerData(i, firstVisibleChildIndex, lastVisibleChildIndex));
|
||||
childButton.setShapeAppearanceModel(builder.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getFirstVisibleChildIndex() {
|
||||
int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
if (isChildVisible(i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int getLastVisibleChildIndex() {
|
||||
for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
|
||||
if (isChildVisible(childCount)) {
|
||||
return childCount;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean isChildVisible(int i) {
|
||||
return getChildAt(i).getVisibility() != 8;
|
||||
}
|
||||
|
||||
private int getVisibleButtonCount() {
|
||||
int i = 0;
|
||||
for (int i2 = 0; i2 < getChildCount(); i2++) {
|
||||
if ((getChildAt(i2) instanceof MaterialButton) && isChildVisible(i2)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getIndexWithinVisibleButtons(View view) {
|
||||
if (!(view instanceof MaterialButton)) {
|
||||
return -1;
|
||||
}
|
||||
int i = 0;
|
||||
for (int i2 = 0; i2 < getChildCount(); i2++) {
|
||||
if (getChildAt(i2) == view) {
|
||||
return i;
|
||||
}
|
||||
if ((getChildAt(i2) instanceof MaterialButton) && isChildVisible(i2)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private CornerData getNewCornerData(int i, int i2, int i3) {
|
||||
CornerData cornerData = this.originalCornerData.get(i);
|
||||
if (i2 == i3) {
|
||||
return cornerData;
|
||||
}
|
||||
boolean z = getOrientation() == 0;
|
||||
if (i == i2) {
|
||||
return z ? CornerData.start(cornerData, this) : CornerData.top(cornerData);
|
||||
}
|
||||
if (i == i3) {
|
||||
return z ? CornerData.end(cornerData, this) : CornerData.bottom(cornerData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void updateBuilderWithCornerData(ShapeAppearanceModel.Builder builder, CornerData cornerData) {
|
||||
if (cornerData == null) {
|
||||
builder.setAllCornerSizes(0.0f);
|
||||
} else {
|
||||
builder.setTopLeftCornerSize(cornerData.topLeft).setBottomLeftCornerSize(cornerData.bottomLeft).setTopRightCornerSize(cornerData.topRight).setBottomRightCornerSize(cornerData.bottomRight);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkInternal(int i, boolean z) {
|
||||
if (i == -1) {
|
||||
Log.e(LOG_TAG, "Button ID is not valid: " + i);
|
||||
return;
|
||||
}
|
||||
HashSet hashSet = new HashSet(this.checkedIds);
|
||||
if (z && !hashSet.contains(Integer.valueOf(i))) {
|
||||
if (this.singleSelection && !hashSet.isEmpty()) {
|
||||
hashSet.clear();
|
||||
}
|
||||
hashSet.add(Integer.valueOf(i));
|
||||
} else {
|
||||
if (z || !hashSet.contains(Integer.valueOf(i))) {
|
||||
return;
|
||||
}
|
||||
if (!this.selectionRequired || hashSet.size() > 1) {
|
||||
hashSet.remove(Integer.valueOf(i));
|
||||
}
|
||||
}
|
||||
updateCheckedIds(hashSet);
|
||||
}
|
||||
|
||||
private void updateCheckedIds(Set<Integer> set) {
|
||||
Set<Integer> set2 = this.checkedIds;
|
||||
this.checkedIds = new HashSet(set);
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
int id = getChildButton(i).getId();
|
||||
setCheckedStateForView(id, set.contains(Integer.valueOf(id)));
|
||||
if (set2.contains(Integer.valueOf(id)) != set.contains(Integer.valueOf(id))) {
|
||||
dispatchOnButtonChecked(id, set.contains(Integer.valueOf(id)));
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void dispatchOnButtonChecked(int i, boolean z) {
|
||||
Iterator<OnButtonCheckedListener> it = this.onButtonCheckedListeners.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onButtonChecked(this, i, z);
|
||||
}
|
||||
}
|
||||
|
||||
private void setGeneratedIdIfNeeded(MaterialButton materialButton) {
|
||||
if (materialButton.getId() == -1) {
|
||||
materialButton.setId(ViewCompat.generateViewId());
|
||||
}
|
||||
}
|
||||
|
||||
private void setupButtonChild(MaterialButton materialButton) {
|
||||
materialButton.setMaxLines(1);
|
||||
materialButton.setEllipsize(TextUtils.TruncateAt.END);
|
||||
materialButton.setCheckable(true);
|
||||
materialButton.setOnPressedChangeListenerInternal(this.pressedStateTracker);
|
||||
materialButton.setShouldDrawSurfaceColorStroke(true);
|
||||
}
|
||||
|
||||
private LinearLayout.LayoutParams buildLayoutParams(View view) {
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
if (layoutParams instanceof LinearLayout.LayoutParams) {
|
||||
return (LinearLayout.LayoutParams) layoutParams;
|
||||
}
|
||||
return new LinearLayout.LayoutParams(layoutParams.width, layoutParams.height);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
protected int getChildDrawingOrder(int i, int i2) {
|
||||
Integer[] numArr = this.childOrder;
|
||||
if (numArr == null || i2 >= numArr.length) {
|
||||
Log.w(LOG_TAG, "Child order wasn't updated");
|
||||
return i2;
|
||||
}
|
||||
return numArr[i2].intValue();
|
||||
}
|
||||
|
||||
private void updateChildOrder() {
|
||||
TreeMap treeMap = new TreeMap(this.childOrderComparator);
|
||||
int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
treeMap.put(getChildButton(i), Integer.valueOf(i));
|
||||
}
|
||||
this.childOrder = (Integer[]) treeMap.values().toArray(new Integer[0]);
|
||||
}
|
||||
|
||||
void onButtonCheckedStateChanged(MaterialButton materialButton, boolean z) {
|
||||
if (this.skipCheckedStateTracker) {
|
||||
return;
|
||||
}
|
||||
checkInternal(materialButton.getId(), z);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setEnabled(boolean z) {
|
||||
super.setEnabled(z);
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
getChildButton(i).setEnabled(z);
|
||||
}
|
||||
}
|
||||
|
||||
private class PressedStateTracker implements MaterialButton.OnPressedChangeListener {
|
||||
private PressedStateTracker() {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.button.MaterialButton.OnPressedChangeListener
|
||||
public void onPressedChanged(MaterialButton materialButton, boolean z) {
|
||||
MaterialButtonToggleGroup.this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private static class CornerData {
|
||||
private static final CornerSize noCorner = new AbsoluteCornerSize(0.0f);
|
||||
CornerSize bottomLeft;
|
||||
CornerSize bottomRight;
|
||||
CornerSize topLeft;
|
||||
CornerSize topRight;
|
||||
|
||||
CornerData(CornerSize cornerSize, CornerSize cornerSize2, CornerSize cornerSize3, CornerSize cornerSize4) {
|
||||
this.topLeft = cornerSize;
|
||||
this.topRight = cornerSize3;
|
||||
this.bottomRight = cornerSize4;
|
||||
this.bottomLeft = cornerSize2;
|
||||
}
|
||||
|
||||
public static CornerData start(CornerData cornerData, View view) {
|
||||
return ViewUtils.isLayoutRtl(view) ? right(cornerData) : left(cornerData);
|
||||
}
|
||||
|
||||
public static CornerData end(CornerData cornerData, View view) {
|
||||
return ViewUtils.isLayoutRtl(view) ? left(cornerData) : right(cornerData);
|
||||
}
|
||||
|
||||
public static CornerData left(CornerData cornerData) {
|
||||
CornerSize cornerSize = cornerData.topLeft;
|
||||
CornerSize cornerSize2 = cornerData.bottomLeft;
|
||||
CornerSize cornerSize3 = noCorner;
|
||||
return new CornerData(cornerSize, cornerSize2, cornerSize3, cornerSize3);
|
||||
}
|
||||
|
||||
public static CornerData right(CornerData cornerData) {
|
||||
CornerSize cornerSize = noCorner;
|
||||
return new CornerData(cornerSize, cornerSize, cornerData.topRight, cornerData.bottomRight);
|
||||
}
|
||||
|
||||
public static CornerData top(CornerData cornerData) {
|
||||
CornerSize cornerSize = cornerData.topLeft;
|
||||
CornerSize cornerSize2 = noCorner;
|
||||
return new CornerData(cornerSize, cornerSize2, cornerData.topRight, cornerSize2);
|
||||
}
|
||||
|
||||
public static CornerData bottom(CornerData cornerData) {
|
||||
CornerSize cornerSize = noCorner;
|
||||
return new CornerData(cornerSize, cornerData.bottomLeft, cornerSize, cornerData.bottomRight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.google.android.material.canvas;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CanvasCompat {
|
||||
|
||||
public interface CanvasOperation {
|
||||
void run(Canvas canvas);
|
||||
}
|
||||
|
||||
private CanvasCompat() {
|
||||
}
|
||||
|
||||
public static int saveLayerAlpha(Canvas canvas, RectF rectF, int i) {
|
||||
if (Build.VERSION.SDK_INT > 21) {
|
||||
return canvas.saveLayerAlpha(rectF, i);
|
||||
}
|
||||
return canvas.saveLayerAlpha(rectF, i, 31);
|
||||
}
|
||||
|
||||
public static int saveLayerAlpha(Canvas canvas, float f, float f2, float f3, float f4, int i) {
|
||||
if (Build.VERSION.SDK_INT > 21) {
|
||||
return canvas.saveLayerAlpha(f, f2, f3, f4, i);
|
||||
}
|
||||
return canvas.saveLayerAlpha(f, f2, f3, f4, i, 31);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
package com.google.android.material.card;
|
||||
|
||||
import android.R;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.Checkable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import com.google.android.material.shape.MaterialShapeUtils;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.google.android.material.shape.Shapeable;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MaterialCardView extends CardView implements Checkable, Shapeable {
|
||||
private static final String ACCESSIBILITY_CLASS_NAME = "androidx.cardview.widget.CardView";
|
||||
public static final int CHECKED_ICON_GRAVITY_BOTTOM_END = 8388693;
|
||||
public static final int CHECKED_ICON_GRAVITY_BOTTOM_START = 8388691;
|
||||
public static final int CHECKED_ICON_GRAVITY_TOP_END = 8388661;
|
||||
public static final int CHECKED_ICON_GRAVITY_TOP_START = 8388659;
|
||||
private static final String LOG_TAG = "MaterialCardView";
|
||||
private final MaterialCardViewHelper cardViewHelper;
|
||||
private boolean checked;
|
||||
private boolean dragged;
|
||||
private boolean isParentCardViewDoneInitializing;
|
||||
private OnCheckedChangeListener onCheckedChangeListener;
|
||||
private static final int[] CHECKABLE_STATE_SET = {R.attr.state_checkable};
|
||||
private static final int[] CHECKED_STATE_SET = {R.attr.state_checked};
|
||||
private static final int[] DRAGGED_STATE_SET = {com.google.android.material.R.attr.state_dragged};
|
||||
private static final int DEF_STYLE_RES = com.google.android.material.R.style.Widget_MaterialComponents_CardView;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface CheckedIconGravity {
|
||||
}
|
||||
|
||||
public interface OnCheckedChangeListener {
|
||||
void onCheckedChanged(MaterialCardView materialCardView, boolean z);
|
||||
}
|
||||
|
||||
@Override // android.widget.Checkable
|
||||
public boolean isChecked() {
|
||||
return this.checked;
|
||||
}
|
||||
|
||||
public boolean isDragged() {
|
||||
return this.dragged;
|
||||
}
|
||||
|
||||
public void setOnCheckedChangeListener(OnCheckedChangeListener onCheckedChangeListener) {
|
||||
this.onCheckedChangeListener = onCheckedChangeListener;
|
||||
}
|
||||
|
||||
public MaterialCardView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MaterialCardView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, com.google.android.material.R.attr.materialCardViewStyle);
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public MaterialCardView(android.content.Context r8, android.util.AttributeSet r9, int r10) {
|
||||
/*
|
||||
r7 = this;
|
||||
int r6 = com.google.android.material.card.MaterialCardView.DEF_STYLE_RES
|
||||
android.content.Context r8 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r8, r9, r10, r6)
|
||||
r7.<init>(r8, r9, r10)
|
||||
r8 = 0
|
||||
r7.checked = r8
|
||||
r7.dragged = r8
|
||||
r0 = 1
|
||||
r7.isParentCardViewDoneInitializing = r0
|
||||
android.content.Context r0 = r7.getContext()
|
||||
int[] r2 = com.google.android.material.R.styleable.MaterialCardView
|
||||
int[] r5 = new int[r8]
|
||||
r1 = r9
|
||||
r3 = r10
|
||||
r4 = r6
|
||||
android.content.res.TypedArray r8 = com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(r0, r1, r2, r3, r4, r5)
|
||||
com.google.android.material.card.MaterialCardViewHelper r0 = new com.google.android.material.card.MaterialCardViewHelper
|
||||
r0.<init>(r7, r9, r10, r6)
|
||||
r7.cardViewHelper = r0
|
||||
android.content.res.ColorStateList r9 = super.getCardBackgroundColor()
|
||||
r0.setCardBackgroundColor(r9)
|
||||
int r9 = super.getContentPaddingLeft()
|
||||
int r10 = super.getContentPaddingTop()
|
||||
int r1 = super.getContentPaddingRight()
|
||||
int r2 = super.getContentPaddingBottom()
|
||||
r0.setUserContentPadding(r9, r10, r1, r2)
|
||||
r0.loadFromAttributes(r8)
|
||||
r8.recycle()
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.card.MaterialCardView.<init>(android.content.Context, android.util.AttributeSet, int):void");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||||
accessibilityNodeInfo.setClassName(ACCESSIBILITY_CLASS_NAME);
|
||||
accessibilityNodeInfo.setCheckable(isCheckable());
|
||||
accessibilityNodeInfo.setClickable(isClickable());
|
||||
accessibilityNodeInfo.setChecked(isChecked());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
||||
super.onInitializeAccessibilityEvent(accessibilityEvent);
|
||||
accessibilityEvent.setClassName(ACCESSIBILITY_CLASS_NAME);
|
||||
accessibilityEvent.setChecked(isChecked());
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView, android.widget.FrameLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
super.onMeasure(i, i2);
|
||||
this.cardViewHelper.recalculateCheckedIconPosition(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
|
||||
public void setStrokeColor(int i) {
|
||||
setStrokeColor(ColorStateList.valueOf(i));
|
||||
}
|
||||
|
||||
public void setStrokeColor(ColorStateList colorStateList) {
|
||||
this.cardViewHelper.setStrokeColor(colorStateList);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getStrokeColor() {
|
||||
return this.cardViewHelper.getStrokeColor();
|
||||
}
|
||||
|
||||
public ColorStateList getStrokeColorStateList() {
|
||||
return this.cardViewHelper.getStrokeColorStateList();
|
||||
}
|
||||
|
||||
public void setStrokeWidth(int i) {
|
||||
this.cardViewHelper.setStrokeWidth(i);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getStrokeWidth() {
|
||||
return this.cardViewHelper.getStrokeWidth();
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public void setRadius(float f) {
|
||||
super.setRadius(f);
|
||||
this.cardViewHelper.setCornerRadius(f);
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public float getRadius() {
|
||||
return this.cardViewHelper.getCornerRadius();
|
||||
}
|
||||
|
||||
float getCardViewRadius() {
|
||||
return super.getRadius();
|
||||
}
|
||||
|
||||
public void setProgress(float f) {
|
||||
this.cardViewHelper.setProgress(f);
|
||||
}
|
||||
|
||||
public float getProgress() {
|
||||
return this.cardViewHelper.getProgress();
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public void setContentPadding(int i, int i2, int i3, int i4) {
|
||||
this.cardViewHelper.setUserContentPadding(i, i2, i3, i4);
|
||||
}
|
||||
|
||||
void setAncestorContentPadding(int i, int i2, int i3, int i4) {
|
||||
super.setContentPadding(i, i2, i3, i4);
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public int getContentPaddingLeft() {
|
||||
return this.cardViewHelper.getUserContentPadding().left;
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public int getContentPaddingTop() {
|
||||
return this.cardViewHelper.getUserContentPadding().top;
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public int getContentPaddingRight() {
|
||||
return this.cardViewHelper.getUserContentPadding().right;
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public int getContentPaddingBottom() {
|
||||
return this.cardViewHelper.getUserContentPadding().bottom;
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public void setCardBackgroundColor(int i) {
|
||||
this.cardViewHelper.setCardBackgroundColor(ColorStateList.valueOf(i));
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public void setCardBackgroundColor(ColorStateList colorStateList) {
|
||||
this.cardViewHelper.setCardBackgroundColor(colorStateList);
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public ColorStateList getCardBackgroundColor() {
|
||||
return this.cardViewHelper.getCardBackgroundColor();
|
||||
}
|
||||
|
||||
public void setCardForegroundColor(ColorStateList colorStateList) {
|
||||
this.cardViewHelper.setCardForegroundColor(colorStateList);
|
||||
}
|
||||
|
||||
public ColorStateList getCardForegroundColor() {
|
||||
return this.cardViewHelper.getCardForegroundColor();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setClickable(boolean z) {
|
||||
super.setClickable(z);
|
||||
MaterialCardViewHelper materialCardViewHelper = this.cardViewHelper;
|
||||
if (materialCardViewHelper != null) {
|
||||
materialCardViewHelper.updateClickable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
this.cardViewHelper.updateClickable();
|
||||
MaterialShapeUtils.setParentAbsoluteElevation(this, this.cardViewHelper.getBackground());
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public void setCardElevation(float f) {
|
||||
super.setCardElevation(f);
|
||||
this.cardViewHelper.updateElevation();
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public void setMaxCardElevation(float f) {
|
||||
super.setMaxCardElevation(f);
|
||||
this.cardViewHelper.updateInsets();
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public void setUseCompatPadding(boolean z) {
|
||||
super.setUseCompatPadding(z);
|
||||
this.cardViewHelper.updateInsets();
|
||||
this.cardViewHelper.updateContentPadding();
|
||||
}
|
||||
|
||||
@Override // androidx.cardview.widget.CardView
|
||||
public void setPreventCornerOverlap(boolean z) {
|
||||
super.setPreventCornerOverlap(z);
|
||||
this.cardViewHelper.updateInsets();
|
||||
this.cardViewHelper.updateContentPadding();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackground(Drawable drawable) {
|
||||
setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundDrawable(Drawable drawable) {
|
||||
if (this.isParentCardViewDoneInitializing) {
|
||||
if (!this.cardViewHelper.isBackgroundOverwritten()) {
|
||||
Log.i(LOG_TAG, "Setting a custom background is not supported.");
|
||||
this.cardViewHelper.setBackgroundOverwritten(true);
|
||||
}
|
||||
super.setBackgroundDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
void setBackgroundInternal(Drawable drawable) {
|
||||
super.setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // android.widget.Checkable
|
||||
public void setChecked(boolean z) {
|
||||
if (this.checked != z) {
|
||||
toggle();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDragged(boolean z) {
|
||||
if (this.dragged != z) {
|
||||
this.dragged = z;
|
||||
refreshDrawableState();
|
||||
forceRippleRedrawIfNeeded();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCheckable() {
|
||||
MaterialCardViewHelper materialCardViewHelper = this.cardViewHelper;
|
||||
return materialCardViewHelper != null && materialCardViewHelper.isCheckable();
|
||||
}
|
||||
|
||||
public void setCheckable(boolean z) {
|
||||
this.cardViewHelper.setCheckable(z);
|
||||
}
|
||||
|
||||
@Override // android.widget.Checkable
|
||||
public void toggle() {
|
||||
if (isCheckable() && isEnabled()) {
|
||||
this.checked = !this.checked;
|
||||
refreshDrawableState();
|
||||
forceRippleRedrawIfNeeded();
|
||||
this.cardViewHelper.setChecked(this.checked, true);
|
||||
OnCheckedChangeListener onCheckedChangeListener = this.onCheckedChangeListener;
|
||||
if (onCheckedChangeListener != null) {
|
||||
onCheckedChangeListener.onCheckedChanged(this, this.checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected int[] onCreateDrawableState(int i) {
|
||||
int[] onCreateDrawableState = super.onCreateDrawableState(i + 3);
|
||||
if (isCheckable()) {
|
||||
mergeDrawableStates(onCreateDrawableState, CHECKABLE_STATE_SET);
|
||||
}
|
||||
if (isChecked()) {
|
||||
mergeDrawableStates(onCreateDrawableState, CHECKED_STATE_SET);
|
||||
}
|
||||
if (isDragged()) {
|
||||
mergeDrawableStates(onCreateDrawableState, DRAGGED_STATE_SET);
|
||||
}
|
||||
return onCreateDrawableState;
|
||||
}
|
||||
|
||||
public void setRippleColor(ColorStateList colorStateList) {
|
||||
this.cardViewHelper.setRippleColor(colorStateList);
|
||||
}
|
||||
|
||||
public void setRippleColorResource(int i) {
|
||||
this.cardViewHelper.setRippleColor(AppCompatResources.getColorStateList(getContext(), i));
|
||||
}
|
||||
|
||||
public ColorStateList getRippleColor() {
|
||||
return this.cardViewHelper.getRippleColor();
|
||||
}
|
||||
|
||||
public Drawable getCheckedIcon() {
|
||||
return this.cardViewHelper.getCheckedIcon();
|
||||
}
|
||||
|
||||
public void setCheckedIconResource(int i) {
|
||||
this.cardViewHelper.setCheckedIcon(AppCompatResources.getDrawable(getContext(), i));
|
||||
}
|
||||
|
||||
public void setCheckedIcon(Drawable drawable) {
|
||||
this.cardViewHelper.setCheckedIcon(drawable);
|
||||
}
|
||||
|
||||
public ColorStateList getCheckedIconTint() {
|
||||
return this.cardViewHelper.getCheckedIconTint();
|
||||
}
|
||||
|
||||
public void setCheckedIconTint(ColorStateList colorStateList) {
|
||||
this.cardViewHelper.setCheckedIconTint(colorStateList);
|
||||
}
|
||||
|
||||
public int getCheckedIconSize() {
|
||||
return this.cardViewHelper.getCheckedIconSize();
|
||||
}
|
||||
|
||||
public void setCheckedIconSize(int i) {
|
||||
this.cardViewHelper.setCheckedIconSize(i);
|
||||
}
|
||||
|
||||
public void setCheckedIconSizeResource(int i) {
|
||||
if (i != 0) {
|
||||
this.cardViewHelper.setCheckedIconSize(getResources().getDimensionPixelSize(i));
|
||||
}
|
||||
}
|
||||
|
||||
public int getCheckedIconMargin() {
|
||||
return this.cardViewHelper.getCheckedIconMargin();
|
||||
}
|
||||
|
||||
public void setCheckedIconMargin(int i) {
|
||||
this.cardViewHelper.setCheckedIconMargin(i);
|
||||
}
|
||||
|
||||
public void setCheckedIconMarginResource(int i) {
|
||||
if (i != -1) {
|
||||
this.cardViewHelper.setCheckedIconMargin(getResources().getDimensionPixelSize(i));
|
||||
}
|
||||
}
|
||||
|
||||
private RectF getBoundsAsRectF() {
|
||||
RectF rectF = new RectF();
|
||||
rectF.set(this.cardViewHelper.getBackground().getBounds());
|
||||
return rectF;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.Shapeable
|
||||
public void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) {
|
||||
setClipToOutline(shapeAppearanceModel.isRoundRect(getBoundsAsRectF()));
|
||||
this.cardViewHelper.setShapeAppearanceModel(shapeAppearanceModel);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.Shapeable
|
||||
public ShapeAppearanceModel getShapeAppearanceModel() {
|
||||
return this.cardViewHelper.getShapeAppearanceModel();
|
||||
}
|
||||
|
||||
private void forceRippleRedrawIfNeeded() {
|
||||
if (Build.VERSION.SDK_INT > 26) {
|
||||
this.cardViewHelper.forceRippleRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
public int getCheckedIconGravity() {
|
||||
return this.cardViewHelper.getCheckedIconGravity();
|
||||
}
|
||||
|
||||
public void setCheckedIconGravity(int i) {
|
||||
if (this.cardViewHelper.getCheckedIconGravity() != i) {
|
||||
this.cardViewHelper.setCheckedIconGravity(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,569 @@
|
||||
package com.google.android.material.card;
|
||||
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.graphics.drawable.RippleDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.motion.MotionUtils;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
import com.google.android.material.ripple.RippleUtils;
|
||||
import com.google.android.material.shape.CornerTreatment;
|
||||
import com.google.android.material.shape.CutCornerTreatment;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.RoundedCornerTreatment;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class MaterialCardViewHelper {
|
||||
private static final float CARD_VIEW_SHADOW_MULTIPLIER = 1.5f;
|
||||
private static final int CHECKED_ICON_LAYER_INDEX = 2;
|
||||
private static final Drawable CHECKED_ICON_NONE;
|
||||
private static final double COS_45 = Math.cos(Math.toRadians(45.0d));
|
||||
public static final int DEFAULT_FADE_ANIM_DURATION = 300;
|
||||
private static final int DEFAULT_STROKE_VALUE = -1;
|
||||
private final MaterialShapeDrawable bgDrawable;
|
||||
private boolean checkable;
|
||||
private Drawable checkedIcon;
|
||||
private int checkedIconGravity;
|
||||
private int checkedIconMargin;
|
||||
private int checkedIconSize;
|
||||
private ColorStateList checkedIconTint;
|
||||
private LayerDrawable clickableForegroundDrawable;
|
||||
private MaterialShapeDrawable compatRippleDrawable;
|
||||
private Drawable fgDrawable;
|
||||
private final MaterialShapeDrawable foregroundContentDrawable;
|
||||
private MaterialShapeDrawable foregroundShapeDrawable;
|
||||
private ValueAnimator iconAnimator;
|
||||
private final TimeInterpolator iconFadeAnimInterpolator;
|
||||
private final int iconFadeInAnimDuration;
|
||||
private final int iconFadeOutAnimDuration;
|
||||
private final MaterialCardView materialCardView;
|
||||
private ColorStateList rippleColor;
|
||||
private Drawable rippleDrawable;
|
||||
private ShapeAppearanceModel shapeAppearanceModel;
|
||||
private ColorStateList strokeColor;
|
||||
private int strokeWidth;
|
||||
private final Rect userContentPadding = new Rect();
|
||||
private boolean isBackgroundOverwritten = false;
|
||||
private float checkedAnimationProgress = 0.0f;
|
||||
|
||||
private boolean isCheckedIconBottom() {
|
||||
return (this.checkedIconGravity & 80) == 80;
|
||||
}
|
||||
|
||||
private boolean isCheckedIconEnd() {
|
||||
return (this.checkedIconGravity & GravityCompat.END) == 8388613;
|
||||
}
|
||||
|
||||
MaterialShapeDrawable getBackground() {
|
||||
return this.bgDrawable;
|
||||
}
|
||||
|
||||
Drawable getCheckedIcon() {
|
||||
return this.checkedIcon;
|
||||
}
|
||||
|
||||
int getCheckedIconGravity() {
|
||||
return this.checkedIconGravity;
|
||||
}
|
||||
|
||||
int getCheckedIconMargin() {
|
||||
return this.checkedIconMargin;
|
||||
}
|
||||
|
||||
int getCheckedIconSize() {
|
||||
return this.checkedIconSize;
|
||||
}
|
||||
|
||||
ColorStateList getCheckedIconTint() {
|
||||
return this.checkedIconTint;
|
||||
}
|
||||
|
||||
ColorStateList getRippleColor() {
|
||||
return this.rippleColor;
|
||||
}
|
||||
|
||||
ShapeAppearanceModel getShapeAppearanceModel() {
|
||||
return this.shapeAppearanceModel;
|
||||
}
|
||||
|
||||
ColorStateList getStrokeColorStateList() {
|
||||
return this.strokeColor;
|
||||
}
|
||||
|
||||
int getStrokeWidth() {
|
||||
return this.strokeWidth;
|
||||
}
|
||||
|
||||
Rect getUserContentPadding() {
|
||||
return this.userContentPadding;
|
||||
}
|
||||
|
||||
boolean isBackgroundOverwritten() {
|
||||
return this.isBackgroundOverwritten;
|
||||
}
|
||||
|
||||
boolean isCheckable() {
|
||||
return this.checkable;
|
||||
}
|
||||
|
||||
void setBackgroundOverwritten(boolean z) {
|
||||
this.isBackgroundOverwritten = z;
|
||||
}
|
||||
|
||||
void setCheckable(boolean z) {
|
||||
this.checkable = z;
|
||||
}
|
||||
|
||||
void setCheckedIconMargin(int i) {
|
||||
this.checkedIconMargin = i;
|
||||
}
|
||||
|
||||
void setCheckedIconSize(int i) {
|
||||
this.checkedIconSize = i;
|
||||
}
|
||||
|
||||
static {
|
||||
CHECKED_ICON_NONE = Build.VERSION.SDK_INT <= 28 ? new ColorDrawable() : null;
|
||||
}
|
||||
|
||||
public MaterialCardViewHelper(MaterialCardView materialCardView, AttributeSet attributeSet, int i, int i2) {
|
||||
this.materialCardView = materialCardView;
|
||||
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(materialCardView.getContext(), attributeSet, i, i2);
|
||||
this.bgDrawable = materialShapeDrawable;
|
||||
materialShapeDrawable.initializeElevationOverlay(materialCardView.getContext());
|
||||
materialShapeDrawable.setShadowColor(-12303292);
|
||||
ShapeAppearanceModel.Builder builder = materialShapeDrawable.getShapeAppearanceModel().toBuilder();
|
||||
TypedArray obtainStyledAttributes = materialCardView.getContext().obtainStyledAttributes(attributeSet, R.styleable.CardView, i, R.style.CardView);
|
||||
if (obtainStyledAttributes.hasValue(R.styleable.CardView_cardCornerRadius)) {
|
||||
builder.setAllCornerSizes(obtainStyledAttributes.getDimension(R.styleable.CardView_cardCornerRadius, 0.0f));
|
||||
}
|
||||
this.foregroundContentDrawable = new MaterialShapeDrawable();
|
||||
setShapeAppearanceModel(builder.build());
|
||||
this.iconFadeAnimInterpolator = MotionUtils.resolveThemeInterpolator(materialCardView.getContext(), R.attr.motionEasingLinearInterpolator, AnimationUtils.LINEAR_INTERPOLATOR);
|
||||
this.iconFadeInAnimDuration = MotionUtils.resolveThemeDuration(materialCardView.getContext(), R.attr.motionDurationShort2, DEFAULT_FADE_ANIM_DURATION);
|
||||
this.iconFadeOutAnimDuration = MotionUtils.resolveThemeDuration(materialCardView.getContext(), R.attr.motionDurationShort1, DEFAULT_FADE_ANIM_DURATION);
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
void loadFromAttributes(TypedArray typedArray) {
|
||||
ColorStateList colorStateList = MaterialResources.getColorStateList(this.materialCardView.getContext(), typedArray, R.styleable.MaterialCardView_strokeColor);
|
||||
this.strokeColor = colorStateList;
|
||||
if (colorStateList == null) {
|
||||
this.strokeColor = ColorStateList.valueOf(-1);
|
||||
}
|
||||
this.strokeWidth = typedArray.getDimensionPixelSize(R.styleable.MaterialCardView_strokeWidth, 0);
|
||||
boolean z = typedArray.getBoolean(R.styleable.MaterialCardView_android_checkable, false);
|
||||
this.checkable = z;
|
||||
this.materialCardView.setLongClickable(z);
|
||||
this.checkedIconTint = MaterialResources.getColorStateList(this.materialCardView.getContext(), typedArray, R.styleable.MaterialCardView_checkedIconTint);
|
||||
setCheckedIcon(MaterialResources.getDrawable(this.materialCardView.getContext(), typedArray, R.styleable.MaterialCardView_checkedIcon));
|
||||
setCheckedIconSize(typedArray.getDimensionPixelSize(R.styleable.MaterialCardView_checkedIconSize, 0));
|
||||
setCheckedIconMargin(typedArray.getDimensionPixelSize(R.styleable.MaterialCardView_checkedIconMargin, 0));
|
||||
this.checkedIconGravity = typedArray.getInteger(R.styleable.MaterialCardView_checkedIconGravity, 8388661);
|
||||
ColorStateList colorStateList2 = MaterialResources.getColorStateList(this.materialCardView.getContext(), typedArray, R.styleable.MaterialCardView_rippleColor);
|
||||
this.rippleColor = colorStateList2;
|
||||
if (colorStateList2 == null) {
|
||||
this.rippleColor = ColorStateList.valueOf(MaterialColors.getColor(this.materialCardView, R.attr.colorControlHighlight));
|
||||
}
|
||||
setCardForegroundColor(MaterialResources.getColorStateList(this.materialCardView.getContext(), typedArray, R.styleable.MaterialCardView_cardForegroundColor));
|
||||
updateRippleColor();
|
||||
updateElevation();
|
||||
updateStroke();
|
||||
this.materialCardView.setBackgroundInternal(insetDrawable(this.bgDrawable));
|
||||
Drawable clickableForeground = shouldUseClickableForeground() ? getClickableForeground() : this.foregroundContentDrawable;
|
||||
this.fgDrawable = clickableForeground;
|
||||
this.materialCardView.setForeground(insetDrawable(clickableForeground));
|
||||
}
|
||||
|
||||
void setStrokeColor(ColorStateList colorStateList) {
|
||||
if (this.strokeColor == colorStateList) {
|
||||
return;
|
||||
}
|
||||
this.strokeColor = colorStateList;
|
||||
updateStroke();
|
||||
}
|
||||
|
||||
int getStrokeColor() {
|
||||
ColorStateList colorStateList = this.strokeColor;
|
||||
if (colorStateList == null) {
|
||||
return -1;
|
||||
}
|
||||
return colorStateList.getDefaultColor();
|
||||
}
|
||||
|
||||
void setStrokeWidth(int i) {
|
||||
if (i == this.strokeWidth) {
|
||||
return;
|
||||
}
|
||||
this.strokeWidth = i;
|
||||
updateStroke();
|
||||
}
|
||||
|
||||
void setCardBackgroundColor(ColorStateList colorStateList) {
|
||||
this.bgDrawable.setFillColor(colorStateList);
|
||||
}
|
||||
|
||||
ColorStateList getCardBackgroundColor() {
|
||||
return this.bgDrawable.getFillColor();
|
||||
}
|
||||
|
||||
void setCardForegroundColor(ColorStateList colorStateList) {
|
||||
MaterialShapeDrawable materialShapeDrawable = this.foregroundContentDrawable;
|
||||
if (colorStateList == null) {
|
||||
colorStateList = ColorStateList.valueOf(0);
|
||||
}
|
||||
materialShapeDrawable.setFillColor(colorStateList);
|
||||
}
|
||||
|
||||
ColorStateList getCardForegroundColor() {
|
||||
return this.foregroundContentDrawable.getFillColor();
|
||||
}
|
||||
|
||||
void setUserContentPadding(int i, int i2, int i3, int i4) {
|
||||
this.userContentPadding.set(i, i2, i3, i4);
|
||||
updateContentPadding();
|
||||
}
|
||||
|
||||
void updateClickable() {
|
||||
Drawable drawable = this.fgDrawable;
|
||||
Drawable clickableForeground = shouldUseClickableForeground() ? getClickableForeground() : this.foregroundContentDrawable;
|
||||
this.fgDrawable = clickableForeground;
|
||||
if (drawable != clickableForeground) {
|
||||
updateInsetForeground(clickableForeground);
|
||||
}
|
||||
}
|
||||
|
||||
public void animateCheckedIcon(boolean z) {
|
||||
float f = z ? 1.0f : 0.0f;
|
||||
float f2 = z ? 1.0f - this.checkedAnimationProgress : this.checkedAnimationProgress;
|
||||
ValueAnimator valueAnimator = this.iconAnimator;
|
||||
if (valueAnimator != null) {
|
||||
valueAnimator.cancel();
|
||||
this.iconAnimator = null;
|
||||
}
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(this.checkedAnimationProgress, f);
|
||||
this.iconAnimator = ofFloat;
|
||||
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.card.MaterialCardViewHelper$$ExternalSyntheticLambda1
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
|
||||
MaterialCardViewHelper.this.m193xa4d79c2b(valueAnimator2);
|
||||
}
|
||||
});
|
||||
this.iconAnimator.setInterpolator(this.iconFadeAnimInterpolator);
|
||||
this.iconAnimator.setDuration((long) ((z ? this.iconFadeInAnimDuration : this.iconFadeOutAnimDuration) * f2));
|
||||
this.iconAnimator.start();
|
||||
}
|
||||
|
||||
/* renamed from: lambda$animateCheckedIcon$0$com-google-android-material-card-MaterialCardViewHelper, reason: not valid java name */
|
||||
/* synthetic */ void m193xa4d79c2b(ValueAnimator valueAnimator) {
|
||||
float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
|
||||
this.checkedIcon.setAlpha((int) (255.0f * floatValue));
|
||||
this.checkedAnimationProgress = floatValue;
|
||||
}
|
||||
|
||||
void setCornerRadius(float f) {
|
||||
setShapeAppearanceModel(this.shapeAppearanceModel.withCornerSize(f));
|
||||
this.fgDrawable.invalidateSelf();
|
||||
if (shouldAddCornerPaddingOutsideCardBackground() || shouldAddCornerPaddingInsideCardBackground()) {
|
||||
updateContentPadding();
|
||||
}
|
||||
if (shouldAddCornerPaddingOutsideCardBackground()) {
|
||||
updateInsets();
|
||||
}
|
||||
}
|
||||
|
||||
float getCornerRadius() {
|
||||
return this.bgDrawable.getTopLeftCornerResolvedSize();
|
||||
}
|
||||
|
||||
void setProgress(float f) {
|
||||
this.bgDrawable.setInterpolation(f);
|
||||
MaterialShapeDrawable materialShapeDrawable = this.foregroundContentDrawable;
|
||||
if (materialShapeDrawable != null) {
|
||||
materialShapeDrawable.setInterpolation(f);
|
||||
}
|
||||
MaterialShapeDrawable materialShapeDrawable2 = this.foregroundShapeDrawable;
|
||||
if (materialShapeDrawable2 != null) {
|
||||
materialShapeDrawable2.setInterpolation(f);
|
||||
}
|
||||
}
|
||||
|
||||
float getProgress() {
|
||||
return this.bgDrawable.getInterpolation();
|
||||
}
|
||||
|
||||
void updateElevation() {
|
||||
this.bgDrawable.setElevation(this.materialCardView.getCardElevation());
|
||||
}
|
||||
|
||||
void updateInsets() {
|
||||
if (!isBackgroundOverwritten()) {
|
||||
this.materialCardView.setBackgroundInternal(insetDrawable(this.bgDrawable));
|
||||
}
|
||||
this.materialCardView.setForeground(insetDrawable(this.fgDrawable));
|
||||
}
|
||||
|
||||
void updateStroke() {
|
||||
this.foregroundContentDrawable.setStroke(this.strokeWidth, this.strokeColor);
|
||||
}
|
||||
|
||||
void updateContentPadding() {
|
||||
int calculateActualCornerPadding = (int) (((shouldAddCornerPaddingInsideCardBackground() || shouldAddCornerPaddingOutsideCardBackground()) ? calculateActualCornerPadding() : 0.0f) - getParentCardViewCalculatedCornerPadding());
|
||||
this.materialCardView.setAncestorContentPadding(this.userContentPadding.left + calculateActualCornerPadding, this.userContentPadding.top + calculateActualCornerPadding, this.userContentPadding.right + calculateActualCornerPadding, this.userContentPadding.bottom + calculateActualCornerPadding);
|
||||
}
|
||||
|
||||
void setRippleColor(ColorStateList colorStateList) {
|
||||
this.rippleColor = colorStateList;
|
||||
updateRippleColor();
|
||||
}
|
||||
|
||||
void setCheckedIconTint(ColorStateList colorStateList) {
|
||||
this.checkedIconTint = colorStateList;
|
||||
Drawable drawable = this.checkedIcon;
|
||||
if (drawable != null) {
|
||||
DrawableCompat.setTintList(drawable, colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
void setCheckedIcon(Drawable drawable) {
|
||||
if (drawable != null) {
|
||||
Drawable mutate = DrawableCompat.wrap(drawable).mutate();
|
||||
this.checkedIcon = mutate;
|
||||
DrawableCompat.setTintList(mutate, this.checkedIconTint);
|
||||
setChecked(this.materialCardView.isChecked());
|
||||
} else {
|
||||
this.checkedIcon = CHECKED_ICON_NONE;
|
||||
}
|
||||
LayerDrawable layerDrawable = this.clickableForegroundDrawable;
|
||||
if (layerDrawable != null) {
|
||||
layerDrawable.setDrawableByLayerId(R.id.mtrl_card_checked_layer_id, this.checkedIcon);
|
||||
}
|
||||
}
|
||||
|
||||
void recalculateCheckedIconPosition(int i, int i2) {
|
||||
int i3;
|
||||
int i4;
|
||||
int i5;
|
||||
int i6;
|
||||
if (this.clickableForegroundDrawable != null) {
|
||||
if (this.materialCardView.getUseCompatPadding()) {
|
||||
i3 = (int) Math.ceil(calculateVerticalBackgroundPadding() * 2.0f);
|
||||
i4 = (int) Math.ceil(calculateHorizontalBackgroundPadding() * 2.0f);
|
||||
} else {
|
||||
i3 = 0;
|
||||
i4 = 0;
|
||||
}
|
||||
int i7 = isCheckedIconEnd() ? ((i - this.checkedIconMargin) - this.checkedIconSize) - i4 : this.checkedIconMargin;
|
||||
int i8 = isCheckedIconBottom() ? this.checkedIconMargin : ((i2 - this.checkedIconMargin) - this.checkedIconSize) - i3;
|
||||
int i9 = isCheckedIconEnd() ? this.checkedIconMargin : ((i - this.checkedIconMargin) - this.checkedIconSize) - i4;
|
||||
int i10 = isCheckedIconBottom() ? ((i2 - this.checkedIconMargin) - this.checkedIconSize) - i3 : this.checkedIconMargin;
|
||||
if (ViewCompat.getLayoutDirection(this.materialCardView) == 1) {
|
||||
i6 = i9;
|
||||
i5 = i7;
|
||||
} else {
|
||||
i5 = i9;
|
||||
i6 = i7;
|
||||
}
|
||||
this.clickableForegroundDrawable.setLayerInset(2, i6, i10, i5, i8);
|
||||
}
|
||||
}
|
||||
|
||||
void forceRippleRedraw() {
|
||||
Drawable drawable = this.rippleDrawable;
|
||||
if (drawable != null) {
|
||||
Rect bounds = drawable.getBounds();
|
||||
int i = bounds.bottom;
|
||||
this.rippleDrawable.setBounds(bounds.left, bounds.top, bounds.right, i - 1);
|
||||
this.rippleDrawable.setBounds(bounds.left, bounds.top, bounds.right, i);
|
||||
}
|
||||
}
|
||||
|
||||
void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) {
|
||||
this.shapeAppearanceModel = shapeAppearanceModel;
|
||||
this.bgDrawable.setShapeAppearanceModel(shapeAppearanceModel);
|
||||
this.bgDrawable.setShadowBitmapDrawingEnable(!r0.isRoundRect());
|
||||
MaterialShapeDrawable materialShapeDrawable = this.foregroundContentDrawable;
|
||||
if (materialShapeDrawable != null) {
|
||||
materialShapeDrawable.setShapeAppearanceModel(shapeAppearanceModel);
|
||||
}
|
||||
MaterialShapeDrawable materialShapeDrawable2 = this.foregroundShapeDrawable;
|
||||
if (materialShapeDrawable2 != null) {
|
||||
materialShapeDrawable2.setShapeAppearanceModel(shapeAppearanceModel);
|
||||
}
|
||||
MaterialShapeDrawable materialShapeDrawable3 = this.compatRippleDrawable;
|
||||
if (materialShapeDrawable3 != null) {
|
||||
materialShapeDrawable3.setShapeAppearanceModel(shapeAppearanceModel);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInsetForeground(Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= 23 && (this.materialCardView.getForeground() instanceof InsetDrawable)) {
|
||||
((InsetDrawable) this.materialCardView.getForeground()).setDrawable(drawable);
|
||||
} else {
|
||||
this.materialCardView.setForeground(insetDrawable(drawable));
|
||||
}
|
||||
}
|
||||
|
||||
private Drawable insetDrawable(Drawable drawable) {
|
||||
int i;
|
||||
int i2;
|
||||
if (this.materialCardView.getUseCompatPadding()) {
|
||||
i2 = (int) Math.ceil(calculateVerticalBackgroundPadding());
|
||||
i = (int) Math.ceil(calculateHorizontalBackgroundPadding());
|
||||
} else {
|
||||
i = 0;
|
||||
i2 = 0;
|
||||
}
|
||||
return new InsetDrawable(drawable, i, i2, i, i2) { // from class: com.google.android.material.card.MaterialCardViewHelper.1
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getMinimumHeight() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getMinimumWidth() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.InsetDrawable, android.graphics.drawable.DrawableWrapper, android.graphics.drawable.Drawable
|
||||
public boolean getPadding(Rect rect) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private float calculateVerticalBackgroundPadding() {
|
||||
return (this.materialCardView.getMaxCardElevation() * CARD_VIEW_SHADOW_MULTIPLIER) + (shouldAddCornerPaddingOutsideCardBackground() ? calculateActualCornerPadding() : 0.0f);
|
||||
}
|
||||
|
||||
private float calculateHorizontalBackgroundPadding() {
|
||||
return this.materialCardView.getMaxCardElevation() + (shouldAddCornerPaddingOutsideCardBackground() ? calculateActualCornerPadding() : 0.0f);
|
||||
}
|
||||
|
||||
private boolean canClipToOutline() {
|
||||
return this.bgDrawable.isRoundRect();
|
||||
}
|
||||
|
||||
private float getParentCardViewCalculatedCornerPadding() {
|
||||
if (this.materialCardView.getPreventCornerOverlap() && this.materialCardView.getUseCompatPadding()) {
|
||||
return (float) ((1.0d - COS_45) * this.materialCardView.getCardViewRadius());
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
private boolean shouldAddCornerPaddingInsideCardBackground() {
|
||||
return this.materialCardView.getPreventCornerOverlap() && !canClipToOutline();
|
||||
}
|
||||
|
||||
private boolean shouldAddCornerPaddingOutsideCardBackground() {
|
||||
return this.materialCardView.getPreventCornerOverlap() && canClipToOutline() && this.materialCardView.getUseCompatPadding();
|
||||
}
|
||||
|
||||
private float calculateActualCornerPadding() {
|
||||
return Math.max(Math.max(calculateCornerPaddingForCornerTreatment(this.shapeAppearanceModel.getTopLeftCorner(), this.bgDrawable.getTopLeftCornerResolvedSize()), calculateCornerPaddingForCornerTreatment(this.shapeAppearanceModel.getTopRightCorner(), this.bgDrawable.getTopRightCornerResolvedSize())), Math.max(calculateCornerPaddingForCornerTreatment(this.shapeAppearanceModel.getBottomRightCorner(), this.bgDrawable.getBottomRightCornerResolvedSize()), calculateCornerPaddingForCornerTreatment(this.shapeAppearanceModel.getBottomLeftCorner(), this.bgDrawable.getBottomLeftCornerResolvedSize())));
|
||||
}
|
||||
|
||||
private float calculateCornerPaddingForCornerTreatment(CornerTreatment cornerTreatment, float f) {
|
||||
if (cornerTreatment instanceof RoundedCornerTreatment) {
|
||||
return (float) ((1.0d - COS_45) * f);
|
||||
}
|
||||
if (cornerTreatment instanceof CutCornerTreatment) {
|
||||
return f / 2.0f;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
private boolean shouldUseClickableForeground() {
|
||||
if (this.materialCardView.isClickable()) {
|
||||
return true;
|
||||
}
|
||||
View view = this.materialCardView;
|
||||
while (view.isDuplicateParentStateEnabled() && (view.getParent() instanceof View)) {
|
||||
view = (View) view.getParent();
|
||||
}
|
||||
return view.isClickable();
|
||||
}
|
||||
|
||||
private Drawable getClickableForeground() {
|
||||
if (this.rippleDrawable == null) {
|
||||
this.rippleDrawable = createForegroundRippleDrawable();
|
||||
}
|
||||
if (this.clickableForegroundDrawable == null) {
|
||||
LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{this.rippleDrawable, this.foregroundContentDrawable, this.checkedIcon});
|
||||
this.clickableForegroundDrawable = layerDrawable;
|
||||
layerDrawable.setId(2, R.id.mtrl_card_checked_layer_id);
|
||||
}
|
||||
return this.clickableForegroundDrawable;
|
||||
}
|
||||
|
||||
private Drawable createForegroundRippleDrawable() {
|
||||
if (RippleUtils.USE_FRAMEWORK_RIPPLE) {
|
||||
this.foregroundShapeDrawable = createForegroundShapeDrawable();
|
||||
return new RippleDrawable(this.rippleColor, null, this.foregroundShapeDrawable);
|
||||
}
|
||||
return createCompatRippleDrawable();
|
||||
}
|
||||
|
||||
private Drawable createCompatRippleDrawable() {
|
||||
StateListDrawable stateListDrawable = new StateListDrawable();
|
||||
MaterialShapeDrawable createForegroundShapeDrawable = createForegroundShapeDrawable();
|
||||
this.compatRippleDrawable = createForegroundShapeDrawable;
|
||||
createForegroundShapeDrawable.setFillColor(this.rippleColor);
|
||||
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, this.compatRippleDrawable);
|
||||
return stateListDrawable;
|
||||
}
|
||||
|
||||
private void updateRippleColor() {
|
||||
Drawable drawable;
|
||||
if (RippleUtils.USE_FRAMEWORK_RIPPLE && (drawable = this.rippleDrawable) != null) {
|
||||
((RippleDrawable) drawable).setColor(this.rippleColor);
|
||||
return;
|
||||
}
|
||||
MaterialShapeDrawable materialShapeDrawable = this.compatRippleDrawable;
|
||||
if (materialShapeDrawable != null) {
|
||||
materialShapeDrawable.setFillColor(this.rippleColor);
|
||||
}
|
||||
}
|
||||
|
||||
private MaterialShapeDrawable createForegroundShapeDrawable() {
|
||||
return new MaterialShapeDrawable(this.shapeAppearanceModel);
|
||||
}
|
||||
|
||||
public void setChecked(boolean z) {
|
||||
setChecked(z, false);
|
||||
}
|
||||
|
||||
public void setChecked(boolean z, boolean z2) {
|
||||
Drawable drawable = this.checkedIcon;
|
||||
if (drawable != null) {
|
||||
if (z2) {
|
||||
animateCheckedIcon(z);
|
||||
} else {
|
||||
drawable.setAlpha(z ? 255 : 0);
|
||||
this.checkedAnimationProgress = z ? 1.0f : 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setCheckedIconGravity(int i) {
|
||||
this.checkedIconGravity = i;
|
||||
recalculateCheckedIconPosition(this.materialCardView.getMeasuredWidth(), this.materialCardView.getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import androidx.core.math.MathUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class Arrangement {
|
||||
private static final float MEDIUM_ITEM_FLEX_PERCENTAGE = 0.1f;
|
||||
final float cost;
|
||||
final int largeCount;
|
||||
float largeSize;
|
||||
int mediumCount;
|
||||
float mediumSize;
|
||||
final int priority;
|
||||
int smallCount;
|
||||
float smallSize;
|
||||
|
||||
private float calculateLargeSize(float f, int i, float f2, int i2, int i3) {
|
||||
if (i <= 0) {
|
||||
f2 = 0.0f;
|
||||
}
|
||||
float f3 = i2 / 2.0f;
|
||||
return (f - ((i + f3) * f2)) / (i3 + f3);
|
||||
}
|
||||
|
||||
private float getSpace() {
|
||||
return (this.largeSize * this.largeCount) + (this.mediumSize * this.mediumCount) + (this.smallSize * this.smallCount);
|
||||
}
|
||||
|
||||
private boolean isValid() {
|
||||
int i = this.largeCount;
|
||||
if (i <= 0 || this.smallCount <= 0 || this.mediumCount <= 0) {
|
||||
return i <= 0 || this.smallCount <= 0 || this.largeSize > this.smallSize;
|
||||
}
|
||||
float f = this.largeSize;
|
||||
float f2 = this.mediumSize;
|
||||
return f > f2 && f2 > this.smallSize;
|
||||
}
|
||||
|
||||
int getItemCount() {
|
||||
return this.smallCount + this.mediumCount + this.largeCount;
|
||||
}
|
||||
|
||||
Arrangement(int i, float f, float f2, float f3, int i2, float f4, int i3, float f5, int i4, float f6) {
|
||||
this.priority = i;
|
||||
this.smallSize = MathUtils.clamp(f, f2, f3);
|
||||
this.smallCount = i2;
|
||||
this.mediumSize = f4;
|
||||
this.mediumCount = i3;
|
||||
this.largeSize = f5;
|
||||
this.largeCount = i4;
|
||||
fit(f6, f2, f3, f5);
|
||||
this.cost = cost(f5);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Arrangement [priority=" + this.priority + ", smallCount=" + this.smallCount + ", smallSize=" + this.smallSize + ", mediumCount=" + this.mediumCount + ", mediumSize=" + this.mediumSize + ", largeCount=" + this.largeCount + ", largeSize=" + this.largeSize + ", cost=" + this.cost + "]";
|
||||
}
|
||||
|
||||
private void fit(float f, float f2, float f3, float f4) {
|
||||
float space = f - getSpace();
|
||||
int i = this.smallCount;
|
||||
if (i > 0 && space > 0.0f) {
|
||||
float f5 = this.smallSize;
|
||||
this.smallSize = f5 + Math.min(space / i, f3 - f5);
|
||||
} else if (i > 0 && space < 0.0f) {
|
||||
float f6 = this.smallSize;
|
||||
this.smallSize = f6 + Math.max(space / i, f2 - f6);
|
||||
}
|
||||
int i2 = this.smallCount;
|
||||
float f7 = i2 > 0 ? this.smallSize : 0.0f;
|
||||
this.smallSize = f7;
|
||||
float calculateLargeSize = calculateLargeSize(f, i2, f7, this.mediumCount, this.largeCount);
|
||||
this.largeSize = calculateLargeSize;
|
||||
float f8 = (this.smallSize + calculateLargeSize) / 2.0f;
|
||||
this.mediumSize = f8;
|
||||
int i3 = this.mediumCount;
|
||||
if (i3 <= 0 || calculateLargeSize == f4) {
|
||||
return;
|
||||
}
|
||||
float f9 = (f4 - calculateLargeSize) * this.largeCount;
|
||||
float min = Math.min(Math.abs(f9), f8 * 0.1f * i3);
|
||||
if (f9 > 0.0f) {
|
||||
this.mediumSize -= min / this.mediumCount;
|
||||
this.largeSize += min / this.largeCount;
|
||||
} else {
|
||||
this.mediumSize += min / this.mediumCount;
|
||||
this.largeSize -= min / this.largeCount;
|
||||
}
|
||||
}
|
||||
|
||||
private float cost(float f) {
|
||||
if (isValid()) {
|
||||
return Math.abs(f - this.largeSize) * this.priority;
|
||||
}
|
||||
return Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
static Arrangement findLowestCostArrangement(float f, float f2, float f3, float f4, int[] iArr, float f5, int[] iArr2, float f6, int[] iArr3) {
|
||||
Arrangement arrangement = null;
|
||||
int i = 1;
|
||||
for (int i2 : iArr3) {
|
||||
int length = iArr2.length;
|
||||
int i3 = 0;
|
||||
while (i3 < length) {
|
||||
int i4 = iArr2[i3];
|
||||
int length2 = iArr.length;
|
||||
int i5 = 0;
|
||||
while (i5 < length2) {
|
||||
int i6 = i5;
|
||||
int i7 = length2;
|
||||
int i8 = i3;
|
||||
int i9 = length;
|
||||
Arrangement arrangement2 = new Arrangement(i, f2, f3, f4, iArr[i5], f5, i4, f6, i2, f);
|
||||
if (arrangement == null || arrangement2.cost < arrangement.cost) {
|
||||
if (arrangement2.cost == 0.0f) {
|
||||
return arrangement2;
|
||||
}
|
||||
arrangement = arrangement2;
|
||||
}
|
||||
i++;
|
||||
i5 = i6 + 1;
|
||||
length2 = i7;
|
||||
i3 = i8;
|
||||
length = i9;
|
||||
}
|
||||
i3++;
|
||||
}
|
||||
}
|
||||
return arrangement;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface Carousel {
|
||||
int getCarouselAlignment();
|
||||
|
||||
int getContainerHeight();
|
||||
|
||||
int getContainerWidth();
|
||||
|
||||
int getItemCount();
|
||||
|
||||
boolean isHorizontal();
|
||||
}
|
||||
@@ -0,0 +1,965 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.core.math.MathUtils;
|
||||
import androidx.core.util.Preconditions;
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.carousel.KeylineState;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CarouselLayoutManager extends RecyclerView.LayoutManager implements Carousel, RecyclerView.SmoothScroller.ScrollVectorProvider {
|
||||
public static final int ALIGNMENT_CENTER = 1;
|
||||
public static final int ALIGNMENT_START = 0;
|
||||
public static final int HORIZONTAL = 0;
|
||||
private static final String TAG = "CarouselLayoutManager";
|
||||
public static final int VERTICAL = 1;
|
||||
private int carouselAlignment;
|
||||
private CarouselStrategy carouselStrategy;
|
||||
private int currentEstimatedPosition;
|
||||
private int currentFillStartPosition;
|
||||
private KeylineState currentKeylineState;
|
||||
private final DebugItemDecoration debugItemDecoration;
|
||||
private boolean isDebuggingEnabled;
|
||||
private KeylineStateList keylineStateList;
|
||||
private Map<Integer, KeylineState> keylineStatePositionMap;
|
||||
private int lastItemCount;
|
||||
int maxScroll;
|
||||
int minScroll;
|
||||
private CarouselOrientationHelper orientationHelper;
|
||||
private final View.OnLayoutChangeListener recyclerViewSizeChangeListener;
|
||||
int scrollOffset;
|
||||
|
||||
private static int calculateShouldScrollBy(int i, int i2, int i3, int i4) {
|
||||
int i5 = i2 + i;
|
||||
return i5 < i3 ? i3 - i2 : i5 > i4 ? i4 - i2 : i;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public int computeHorizontalScrollOffset(RecyclerView.State state) {
|
||||
return this.scrollOffset;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public int computeHorizontalScrollRange(RecyclerView.State state) {
|
||||
return this.maxScroll - this.minScroll;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public int computeVerticalScrollOffset(RecyclerView.State state) {
|
||||
return this.scrollOffset;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public int computeVerticalScrollRange(RecyclerView.State state) {
|
||||
return this.maxScroll - this.minScroll;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.Carousel
|
||||
public int getCarouselAlignment() {
|
||||
return this.carouselAlignment;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$new$0$com-google-android-material-carousel-CarouselLayoutManager, reason: not valid java name */
|
||||
/* synthetic */ void m195x2ff337cb(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
|
||||
if (i == i5 && i2 == i6 && i3 == i7 && i4 == i8) {
|
||||
return;
|
||||
}
|
||||
view.post(new Runnable() { // from class: com.google.android.material.carousel.CarouselLayoutManager$$ExternalSyntheticLambda0
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
CarouselLayoutManager.this.refreshKeylineState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final class ChildCalculations {
|
||||
final float center;
|
||||
final View child;
|
||||
final float offsetCenter;
|
||||
final KeylineRange range;
|
||||
|
||||
ChildCalculations(View view, float f, float f2, KeylineRange keylineRange) {
|
||||
this.child = view;
|
||||
this.center = f;
|
||||
this.offsetCenter = f2;
|
||||
this.range = keylineRange;
|
||||
}
|
||||
}
|
||||
|
||||
public CarouselLayoutManager() {
|
||||
this(new MultiBrowseCarouselStrategy());
|
||||
}
|
||||
|
||||
public CarouselLayoutManager(CarouselStrategy carouselStrategy) {
|
||||
this(carouselStrategy, 0);
|
||||
}
|
||||
|
||||
public CarouselLayoutManager(CarouselStrategy carouselStrategy, int i) {
|
||||
this.isDebuggingEnabled = false;
|
||||
this.debugItemDecoration = new DebugItemDecoration();
|
||||
this.currentFillStartPosition = 0;
|
||||
this.recyclerViewSizeChangeListener = new View.OnLayoutChangeListener() { // from class: com.google.android.material.carousel.CarouselLayoutManager$$ExternalSyntheticLambda1
|
||||
@Override // android.view.View.OnLayoutChangeListener
|
||||
public final void onLayoutChange(View view, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9) {
|
||||
CarouselLayoutManager.this.m195x2ff337cb(view, i2, i3, i4, i5, i6, i7, i8, i9);
|
||||
}
|
||||
};
|
||||
this.currentEstimatedPosition = -1;
|
||||
this.carouselAlignment = 0;
|
||||
setCarouselStrategy(carouselStrategy);
|
||||
setOrientation(i);
|
||||
}
|
||||
|
||||
public CarouselLayoutManager(Context context, AttributeSet attributeSet, int i, int i2) {
|
||||
this.isDebuggingEnabled = false;
|
||||
this.debugItemDecoration = new DebugItemDecoration();
|
||||
this.currentFillStartPosition = 0;
|
||||
this.recyclerViewSizeChangeListener = new View.OnLayoutChangeListener() { // from class: com.google.android.material.carousel.CarouselLayoutManager$$ExternalSyntheticLambda1
|
||||
@Override // android.view.View.OnLayoutChangeListener
|
||||
public final void onLayoutChange(View view, int i22, int i3, int i4, int i5, int i6, int i7, int i8, int i9) {
|
||||
CarouselLayoutManager.this.m195x2ff337cb(view, i22, i3, i4, i5, i6, i7, i8, i9);
|
||||
}
|
||||
};
|
||||
this.currentEstimatedPosition = -1;
|
||||
this.carouselAlignment = 0;
|
||||
setCarouselStrategy(new MultiBrowseCarouselStrategy());
|
||||
setCarouselAttributes(context, attributeSet);
|
||||
}
|
||||
|
||||
private void setCarouselAttributes(Context context, AttributeSet attributeSet) {
|
||||
if (attributeSet != null) {
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.Carousel);
|
||||
setCarouselAlignment(obtainStyledAttributes.getInt(R.styleable.Carousel_carousel_alignment, 0));
|
||||
setOrientation(obtainStyledAttributes.getInt(R.styleable.RecyclerView_android_orientation, 0));
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCarouselAlignment(int i) {
|
||||
this.carouselAlignment = i;
|
||||
refreshKeylineState();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public RecyclerView.LayoutParams generateDefaultLayoutParams() {
|
||||
return new RecyclerView.LayoutParams(-2, -2);
|
||||
}
|
||||
|
||||
public void setCarouselStrategy(CarouselStrategy carouselStrategy) {
|
||||
this.carouselStrategy = carouselStrategy;
|
||||
refreshKeylineState();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void onAttachedToWindow(RecyclerView recyclerView) {
|
||||
super.onAttachedToWindow(recyclerView);
|
||||
refreshKeylineState();
|
||||
recyclerView.addOnLayoutChangeListener(this.recyclerViewSizeChangeListener);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void onDetachedFromWindow(RecyclerView recyclerView, RecyclerView.Recycler recycler) {
|
||||
super.onDetachedFromWindow(recyclerView, recycler);
|
||||
recyclerView.removeOnLayoutChangeListener(this.recyclerViewSizeChangeListener);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
if (state.getItemCount() <= 0 || getContainerSize() <= 0.0f) {
|
||||
removeAndRecycleAllViews(recycler);
|
||||
this.currentFillStartPosition = 0;
|
||||
return;
|
||||
}
|
||||
boolean isLayoutRtl = isLayoutRtl();
|
||||
boolean z = this.keylineStateList == null;
|
||||
if (z) {
|
||||
recalculateKeylineStateList(recycler);
|
||||
}
|
||||
int calculateStartScroll = calculateStartScroll(this.keylineStateList);
|
||||
int calculateEndScroll = calculateEndScroll(state, this.keylineStateList);
|
||||
this.minScroll = isLayoutRtl ? calculateEndScroll : calculateStartScroll;
|
||||
if (isLayoutRtl) {
|
||||
calculateEndScroll = calculateStartScroll;
|
||||
}
|
||||
this.maxScroll = calculateEndScroll;
|
||||
if (z) {
|
||||
this.scrollOffset = calculateStartScroll;
|
||||
this.keylineStatePositionMap = this.keylineStateList.getKeylineStateForPositionMap(getItemCount(), this.minScroll, this.maxScroll, isLayoutRtl());
|
||||
int i = this.currentEstimatedPosition;
|
||||
if (i != -1) {
|
||||
this.scrollOffset = getScrollOffsetForPosition(i, getKeylineStateForPosition(i));
|
||||
}
|
||||
}
|
||||
int i2 = this.scrollOffset;
|
||||
this.scrollOffset = i2 + calculateShouldScrollBy(0, i2, this.minScroll, this.maxScroll);
|
||||
this.currentFillStartPosition = MathUtils.clamp(this.currentFillStartPosition, 0, state.getItemCount());
|
||||
updateCurrentKeylineStateForScrollOffset(this.keylineStateList);
|
||||
detachAndScrapAttachedViews(recycler);
|
||||
fill(recycler, state);
|
||||
this.lastItemCount = getItemCount();
|
||||
}
|
||||
|
||||
private void recalculateKeylineStateList(RecyclerView.Recycler recycler) {
|
||||
View viewForPosition = recycler.getViewForPosition(0);
|
||||
measureChildWithMargins(viewForPosition, 0, 0);
|
||||
KeylineState onFirstChildMeasuredWithMargins = this.carouselStrategy.onFirstChildMeasuredWithMargins(this, viewForPosition);
|
||||
if (isLayoutRtl()) {
|
||||
onFirstChildMeasuredWithMargins = KeylineState.reverse(onFirstChildMeasuredWithMargins, getContainerSize());
|
||||
}
|
||||
this.keylineStateList = KeylineStateList.from(this, onFirstChildMeasuredWithMargins);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void refreshKeylineState() {
|
||||
this.keylineStateList = null;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
private void fill(RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
removeAndRecycleOutOfBoundsViews(recycler);
|
||||
if (getChildCount() == 0) {
|
||||
addViewsStart(recycler, this.currentFillStartPosition - 1);
|
||||
addViewsEnd(recycler, state, this.currentFillStartPosition);
|
||||
} else {
|
||||
int position = getPosition(getChildAt(0));
|
||||
int position2 = getPosition(getChildAt(getChildCount() - 1));
|
||||
addViewsStart(recycler, position - 1);
|
||||
addViewsEnd(recycler, state, position2 + 1);
|
||||
}
|
||||
validateChildOrderIfDebugging();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void onLayoutCompleted(RecyclerView.State state) {
|
||||
super.onLayoutCompleted(state);
|
||||
if (getChildCount() == 0) {
|
||||
this.currentFillStartPosition = 0;
|
||||
} else {
|
||||
this.currentFillStartPosition = getPosition(getChildAt(0));
|
||||
}
|
||||
validateChildOrderIfDebugging();
|
||||
}
|
||||
|
||||
private void addViewsStart(RecyclerView.Recycler recycler, int i) {
|
||||
float calculateChildStartForFill = calculateChildStartForFill(i);
|
||||
while (i >= 0) {
|
||||
ChildCalculations makeChildCalculations = makeChildCalculations(recycler, calculateChildStartForFill, i);
|
||||
if (isLocOffsetOutOfFillBoundsStart(makeChildCalculations.offsetCenter, makeChildCalculations.range)) {
|
||||
return;
|
||||
}
|
||||
calculateChildStartForFill = addStart(calculateChildStartForFill, this.currentKeylineState.getItemSize());
|
||||
if (!isLocOffsetOutOfFillBoundsEnd(makeChildCalculations.offsetCenter, makeChildCalculations.range)) {
|
||||
addAndLayoutView(makeChildCalculations.child, 0, makeChildCalculations);
|
||||
}
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
private void addViewAtPosition(RecyclerView.Recycler recycler, int i, int i2) {
|
||||
if (i < 0 || i >= getItemCount()) {
|
||||
return;
|
||||
}
|
||||
ChildCalculations makeChildCalculations = makeChildCalculations(recycler, calculateChildStartForFill(i), i);
|
||||
addAndLayoutView(makeChildCalculations.child, i2, makeChildCalculations);
|
||||
}
|
||||
|
||||
private void addViewsEnd(RecyclerView.Recycler recycler, RecyclerView.State state, int i) {
|
||||
float calculateChildStartForFill = calculateChildStartForFill(i);
|
||||
while (i < state.getItemCount()) {
|
||||
ChildCalculations makeChildCalculations = makeChildCalculations(recycler, calculateChildStartForFill, i);
|
||||
if (isLocOffsetOutOfFillBoundsEnd(makeChildCalculations.offsetCenter, makeChildCalculations.range)) {
|
||||
return;
|
||||
}
|
||||
calculateChildStartForFill = addEnd(calculateChildStartForFill, this.currentKeylineState.getItemSize());
|
||||
if (!isLocOffsetOutOfFillBoundsStart(makeChildCalculations.offsetCenter, makeChildCalculations.range)) {
|
||||
addAndLayoutView(makeChildCalculations.child, -1, makeChildCalculations);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private void logChildrenIfDebugging() {
|
||||
if (this.isDebuggingEnabled && Log.isLoggable(TAG, 3)) {
|
||||
Log.d(TAG, "internal representation of views on the screen");
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View childAt = getChildAt(i);
|
||||
Log.d(TAG, "item position " + getPosition(childAt) + ", center:" + getDecoratedCenterWithMargins(childAt) + ", child index:" + i);
|
||||
}
|
||||
Log.d(TAG, "==============");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateChildOrderIfDebugging() {
|
||||
if (!this.isDebuggingEnabled || getChildCount() < 1) {
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
while (i < getChildCount() - 1) {
|
||||
int position = getPosition(getChildAt(i));
|
||||
int i2 = i + 1;
|
||||
int position2 = getPosition(getChildAt(i2));
|
||||
if (position > position2) {
|
||||
logChildrenIfDebugging();
|
||||
throw new IllegalStateException("Detected invalid child order. Child at index [" + i + "] had adapter position [" + position + "] and child at index [" + i2 + "] had adapter position [" + position2 + "].");
|
||||
}
|
||||
i = i2;
|
||||
}
|
||||
}
|
||||
|
||||
private ChildCalculations makeChildCalculations(RecyclerView.Recycler recycler, float f, int i) {
|
||||
View viewForPosition = recycler.getViewForPosition(i);
|
||||
measureChildWithMargins(viewForPosition, 0, 0);
|
||||
float addEnd = addEnd(f, this.currentKeylineState.getItemSize() / 2.0f);
|
||||
KeylineRange surroundingKeylineRange = getSurroundingKeylineRange(this.currentKeylineState.getKeylines(), addEnd, false);
|
||||
return new ChildCalculations(viewForPosition, addEnd, calculateChildOffsetCenterForLocation(viewForPosition, addEnd, surroundingKeylineRange), surroundingKeylineRange);
|
||||
}
|
||||
|
||||
private void addAndLayoutView(View view, int i, ChildCalculations childCalculations) {
|
||||
float itemSize = this.currentKeylineState.getItemSize() / 2.0f;
|
||||
addView(view, i);
|
||||
this.orientationHelper.layoutDecoratedWithMargins(view, (int) (childCalculations.offsetCenter - itemSize), (int) (childCalculations.offsetCenter + itemSize));
|
||||
updateChildMaskForLocation(view, childCalculations.center, childCalculations.range);
|
||||
}
|
||||
|
||||
private boolean isLocOffsetOutOfFillBoundsStart(float f, KeylineRange keylineRange) {
|
||||
float addEnd = addEnd(f, getMaskedItemSizeForLocOffset(f, keylineRange) / 2.0f);
|
||||
if (isLayoutRtl()) {
|
||||
if (addEnd > getContainerSize()) {
|
||||
return true;
|
||||
}
|
||||
} else if (addEnd < 0.0f) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.Carousel
|
||||
public boolean isHorizontal() {
|
||||
return this.orientationHelper.orientation == 0;
|
||||
}
|
||||
|
||||
private boolean isLocOffsetOutOfFillBoundsEnd(float f, KeylineRange keylineRange) {
|
||||
float addStart = addStart(f, getMaskedItemSizeForLocOffset(f, keylineRange) / 2.0f);
|
||||
if (isLayoutRtl()) {
|
||||
if (addStart < 0.0f) {
|
||||
return true;
|
||||
}
|
||||
} else if (addStart > getContainerSize()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void getDecoratedBoundsWithMargins(View view, Rect rect) {
|
||||
super.getDecoratedBoundsWithMargins(view, rect);
|
||||
float centerY = rect.centerY();
|
||||
if (isHorizontal()) {
|
||||
centerY = rect.centerX();
|
||||
}
|
||||
float maskedItemSizeForLocOffset = getMaskedItemSizeForLocOffset(centerY, getSurroundingKeylineRange(this.currentKeylineState.getKeylines(), centerY, true));
|
||||
float width = isHorizontal() ? (rect.width() - maskedItemSizeForLocOffset) / 2.0f : 0.0f;
|
||||
float height = isHorizontal() ? 0.0f : (rect.height() - maskedItemSizeForLocOffset) / 2.0f;
|
||||
rect.set((int) (rect.left + width), (int) (rect.top + height), (int) (rect.right - width), (int) (rect.bottom - height));
|
||||
}
|
||||
|
||||
private float getDecoratedCenterWithMargins(View view) {
|
||||
int centerY;
|
||||
Rect rect = new Rect();
|
||||
super.getDecoratedBoundsWithMargins(view, rect);
|
||||
if (isHorizontal()) {
|
||||
centerY = rect.centerX();
|
||||
} else {
|
||||
centerY = rect.centerY();
|
||||
}
|
||||
return centerY;
|
||||
}
|
||||
|
||||
private void removeAndRecycleOutOfBoundsViews(RecyclerView.Recycler recycler) {
|
||||
while (getChildCount() > 0) {
|
||||
View childAt = getChildAt(0);
|
||||
float decoratedCenterWithMargins = getDecoratedCenterWithMargins(childAt);
|
||||
if (!isLocOffsetOutOfFillBoundsStart(decoratedCenterWithMargins, getSurroundingKeylineRange(this.currentKeylineState.getKeylines(), decoratedCenterWithMargins, true))) {
|
||||
break;
|
||||
} else {
|
||||
removeAndRecycleView(childAt, recycler);
|
||||
}
|
||||
}
|
||||
while (getChildCount() - 1 >= 0) {
|
||||
View childAt2 = getChildAt(getChildCount() - 1);
|
||||
float decoratedCenterWithMargins2 = getDecoratedCenterWithMargins(childAt2);
|
||||
if (!isLocOffsetOutOfFillBoundsEnd(decoratedCenterWithMargins2, getSurroundingKeylineRange(this.currentKeylineState.getKeylines(), decoratedCenterWithMargins2, true))) {
|
||||
return;
|
||||
} else {
|
||||
removeAndRecycleView(childAt2, recycler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static KeylineRange getSurroundingKeylineRange(List<KeylineState.Keyline> list, float f, boolean z) {
|
||||
float f2 = Float.MAX_VALUE;
|
||||
float f3 = Float.MAX_VALUE;
|
||||
float f4 = Float.MAX_VALUE;
|
||||
float f5 = -3.4028235E38f;
|
||||
int i = -1;
|
||||
int i2 = -1;
|
||||
int i3 = -1;
|
||||
int i4 = -1;
|
||||
for (int i5 = 0; i5 < list.size(); i5++) {
|
||||
KeylineState.Keyline keyline = list.get(i5);
|
||||
float f6 = z ? keyline.locOffset : keyline.loc;
|
||||
float abs = Math.abs(f6 - f);
|
||||
if (f6 <= f && abs <= f2) {
|
||||
i = i5;
|
||||
f2 = abs;
|
||||
}
|
||||
if (f6 > f && abs <= f3) {
|
||||
i3 = i5;
|
||||
f3 = abs;
|
||||
}
|
||||
if (f6 <= f4) {
|
||||
i2 = i5;
|
||||
f4 = f6;
|
||||
}
|
||||
if (f6 > f5) {
|
||||
i4 = i5;
|
||||
f5 = f6;
|
||||
}
|
||||
}
|
||||
if (i == -1) {
|
||||
i = i2;
|
||||
}
|
||||
if (i3 == -1) {
|
||||
i3 = i4;
|
||||
}
|
||||
return new KeylineRange(list.get(i), list.get(i3));
|
||||
}
|
||||
|
||||
private void updateCurrentKeylineStateForScrollOffset(KeylineStateList keylineStateList) {
|
||||
int i = this.maxScroll;
|
||||
int i2 = this.minScroll;
|
||||
if (i <= i2) {
|
||||
this.currentKeylineState = isLayoutRtl() ? keylineStateList.getEndState() : keylineStateList.getStartState();
|
||||
} else {
|
||||
this.currentKeylineState = keylineStateList.getShiftedState(this.scrollOffset, i2, i);
|
||||
}
|
||||
this.debugItemDecoration.setKeylines(this.currentKeylineState.getKeylines());
|
||||
}
|
||||
|
||||
private int calculateStartScroll(KeylineStateList keylineStateList) {
|
||||
boolean isLayoutRtl = isLayoutRtl();
|
||||
KeylineState endState = isLayoutRtl ? keylineStateList.getEndState() : keylineStateList.getStartState();
|
||||
return (int) (((getPaddingStart() * (isLayoutRtl ? 1 : -1)) + getParentStart()) - addStart((isLayoutRtl ? endState.getLastFocalKeyline() : endState.getFirstFocalKeyline()).loc, endState.getItemSize() / 2.0f));
|
||||
}
|
||||
|
||||
private int calculateEndScroll(RecyclerView.State state, KeylineStateList keylineStateList) {
|
||||
boolean isLayoutRtl = isLayoutRtl();
|
||||
KeylineState startState = isLayoutRtl ? keylineStateList.getStartState() : keylineStateList.getEndState();
|
||||
KeylineState.Keyline firstFocalKeyline = isLayoutRtl ? startState.getFirstFocalKeyline() : startState.getLastFocalKeyline();
|
||||
int itemCount = (int) ((((((state.getItemCount() - 1) * startState.getItemSize()) + getPaddingEnd()) * (isLayoutRtl ? -1.0f : 1.0f)) - (firstFocalKeyline.loc - getParentStart())) + (getParentEnd() - firstFocalKeyline.loc));
|
||||
return isLayoutRtl ? Math.min(0, itemCount) : Math.max(0, itemCount);
|
||||
}
|
||||
|
||||
private float calculateChildStartForFill(int i) {
|
||||
return addEnd(getParentStart() - this.scrollOffset, this.currentKeylineState.getItemSize() * i);
|
||||
}
|
||||
|
||||
private float calculateChildOffsetCenterForLocation(View view, float f, KeylineRange keylineRange) {
|
||||
float lerp = AnimationUtils.lerp(keylineRange.leftOrTop.locOffset, keylineRange.rightOrBottom.locOffset, keylineRange.leftOrTop.loc, keylineRange.rightOrBottom.loc, f);
|
||||
if (keylineRange.rightOrBottom != this.currentKeylineState.getFirstKeyline() && keylineRange.leftOrTop != this.currentKeylineState.getLastKeyline()) {
|
||||
return lerp;
|
||||
}
|
||||
return lerp + ((f - keylineRange.rightOrBottom.loc) * ((1.0f - keylineRange.rightOrBottom.mask) + (this.orientationHelper.getMaskMargins((RecyclerView.LayoutParams) view.getLayoutParams()) / this.currentKeylineState.getItemSize())));
|
||||
}
|
||||
|
||||
private float getMaskedItemSizeForLocOffset(float f, KeylineRange keylineRange) {
|
||||
return AnimationUtils.lerp(keylineRange.leftOrTop.maskedItemSize, keylineRange.rightOrBottom.maskedItemSize, keylineRange.leftOrTop.locOffset, keylineRange.rightOrBottom.locOffset, f);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
private void updateChildMaskForLocation(View view, float f, KeylineRange keylineRange) {
|
||||
if (view instanceof Maskable) {
|
||||
float lerp = AnimationUtils.lerp(keylineRange.leftOrTop.mask, keylineRange.rightOrBottom.mask, keylineRange.leftOrTop.loc, keylineRange.rightOrBottom.loc, f);
|
||||
float height = view.getHeight();
|
||||
float width = view.getWidth();
|
||||
RectF maskRect = this.orientationHelper.getMaskRect(height, width, AnimationUtils.lerp(0.0f, height / 2.0f, 0.0f, 1.0f, lerp), AnimationUtils.lerp(0.0f, width / 2.0f, 0.0f, 1.0f, lerp));
|
||||
float calculateChildOffsetCenterForLocation = calculateChildOffsetCenterForLocation(view, f, keylineRange);
|
||||
RectF rectF = new RectF(calculateChildOffsetCenterForLocation - (maskRect.width() / 2.0f), calculateChildOffsetCenterForLocation - (maskRect.height() / 2.0f), calculateChildOffsetCenterForLocation + (maskRect.width() / 2.0f), (maskRect.height() / 2.0f) + calculateChildOffsetCenterForLocation);
|
||||
RectF rectF2 = new RectF(getParentLeft(), getParentTop(), getParentRight(), getParentBottom());
|
||||
if (this.carouselStrategy.isContained()) {
|
||||
this.orientationHelper.containMaskWithinBounds(maskRect, rectF, rectF2);
|
||||
}
|
||||
this.orientationHelper.moveMaskOnEdgeOutsideBounds(maskRect, rectF, rectF2);
|
||||
((Maskable) view).setMaskRectF(maskRect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void measureChildWithMargins(View view, int i, int i2) {
|
||||
float f;
|
||||
float f2;
|
||||
if (!(view instanceof Maskable)) {
|
||||
throw new IllegalStateException("All children of a RecyclerView using CarouselLayoutManager must use MaskableFrameLayout as their root ViewGroup.");
|
||||
}
|
||||
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
Rect rect = new Rect();
|
||||
calculateItemDecorationsForChild(view, rect);
|
||||
int i3 = i + rect.left + rect.right;
|
||||
int i4 = i2 + rect.top + rect.bottom;
|
||||
if (this.keylineStateList != null && this.orientationHelper.orientation == 0) {
|
||||
f = this.keylineStateList.getDefaultState().getItemSize();
|
||||
} else {
|
||||
f = layoutParams.width;
|
||||
}
|
||||
if (this.keylineStateList != null && this.orientationHelper.orientation == 1) {
|
||||
f2 = this.keylineStateList.getDefaultState().getItemSize();
|
||||
} else {
|
||||
f2 = layoutParams.height;
|
||||
}
|
||||
view.measure(getChildMeasureSpec(getWidth(), getWidthMode(), getPaddingLeft() + getPaddingRight() + layoutParams.leftMargin + layoutParams.rightMargin + i3, (int) f, canScrollHorizontally()), getChildMeasureSpec(getHeight(), getHeightMode(), getPaddingTop() + getPaddingBottom() + layoutParams.topMargin + layoutParams.bottomMargin + i4, (int) f2, canScrollVertically()));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getParentLeft() {
|
||||
return this.orientationHelper.getParentLeft();
|
||||
}
|
||||
|
||||
private int getParentStart() {
|
||||
return this.orientationHelper.getParentStart();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getParentRight() {
|
||||
return this.orientationHelper.getParentRight();
|
||||
}
|
||||
|
||||
private int getParentEnd() {
|
||||
return this.orientationHelper.getParentEnd();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getParentTop() {
|
||||
return this.orientationHelper.getParentTop();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getParentBottom() {
|
||||
return this.orientationHelper.getParentBottom();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.Carousel
|
||||
public int getContainerWidth() {
|
||||
return getWidth();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.Carousel
|
||||
public int getContainerHeight() {
|
||||
return getHeight();
|
||||
}
|
||||
|
||||
private int getContainerSize() {
|
||||
if (isHorizontal()) {
|
||||
return getContainerWidth();
|
||||
}
|
||||
return getContainerHeight();
|
||||
}
|
||||
|
||||
boolean isLayoutRtl() {
|
||||
return isHorizontal() && getLayoutDirection() == 1;
|
||||
}
|
||||
|
||||
private float addStart(float f, float f2) {
|
||||
return isLayoutRtl() ? f + f2 : f - f2;
|
||||
}
|
||||
|
||||
private float addEnd(float f, float f2) {
|
||||
return isLayoutRtl() ? f - f2 : f + f2;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
||||
super.onInitializeAccessibilityEvent(accessibilityEvent);
|
||||
if (getChildCount() > 0) {
|
||||
accessibilityEvent.setFromIndex(getPosition(getChildAt(0)));
|
||||
accessibilityEvent.setToIndex(getPosition(getChildAt(getChildCount() - 1)));
|
||||
}
|
||||
}
|
||||
|
||||
private int getScrollOffsetForPosition(int i, KeylineState keylineState) {
|
||||
if (isLayoutRtl()) {
|
||||
return (int) (((getContainerSize() - keylineState.getLastFocalKeyline().loc) - (i * keylineState.getItemSize())) - (keylineState.getItemSize() / 2.0f));
|
||||
}
|
||||
return (int) (((i * keylineState.getItemSize()) - keylineState.getFirstFocalKeyline().loc) + (keylineState.getItemSize() / 2.0f));
|
||||
}
|
||||
|
||||
private int getSmallestScrollOffsetToFocalKeyline(int i, KeylineState keylineState) {
|
||||
int i2;
|
||||
int i3 = Integer.MAX_VALUE;
|
||||
for (KeylineState.Keyline keyline : keylineState.getFocalKeylines()) {
|
||||
float itemSize = (i * keylineState.getItemSize()) + (keylineState.getItemSize() / 2.0f);
|
||||
if (isLayoutRtl()) {
|
||||
i2 = (int) ((getContainerSize() - keyline.loc) - itemSize);
|
||||
} else {
|
||||
i2 = (int) (itemSize - keyline.loc);
|
||||
}
|
||||
int i4 = i2 - this.scrollOffset;
|
||||
if (Math.abs(i3) > Math.abs(i4)) {
|
||||
i3 = i4;
|
||||
}
|
||||
}
|
||||
return i3;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.SmoothScroller.ScrollVectorProvider
|
||||
public PointF computeScrollVectorForPosition(int i) {
|
||||
if (this.keylineStateList == null) {
|
||||
return null;
|
||||
}
|
||||
int offsetToScrollToPosition = getOffsetToScrollToPosition(i, getKeylineStateForPosition(i));
|
||||
if (isHorizontal()) {
|
||||
return new PointF(offsetToScrollToPosition, 0.0f);
|
||||
}
|
||||
return new PointF(0.0f, offsetToScrollToPosition);
|
||||
}
|
||||
|
||||
int getOffsetToScrollToPosition(int i, KeylineState keylineState) {
|
||||
return getScrollOffsetForPosition(i, keylineState) - this.scrollOffset;
|
||||
}
|
||||
|
||||
int getOffsetToScrollToPositionForSnap(int i, boolean z) {
|
||||
int offsetToScrollToPosition = getOffsetToScrollToPosition(i, this.keylineStateList.getShiftedState(this.scrollOffset, this.minScroll, this.maxScroll, true));
|
||||
int offsetToScrollToPosition2 = this.keylineStatePositionMap != null ? getOffsetToScrollToPosition(i, getKeylineStateForPosition(i)) : offsetToScrollToPosition;
|
||||
return (!z || Math.abs(offsetToScrollToPosition2) >= Math.abs(offsetToScrollToPosition)) ? offsetToScrollToPosition : offsetToScrollToPosition2;
|
||||
}
|
||||
|
||||
private KeylineState getKeylineStateForPosition(int i) {
|
||||
KeylineState keylineState;
|
||||
Map<Integer, KeylineState> map = this.keylineStatePositionMap;
|
||||
return (map == null || (keylineState = map.get(Integer.valueOf(MathUtils.clamp(i, 0, Math.max(0, getItemCount() + (-1)))))) == null) ? this.keylineStateList.getDefaultState() : keylineState;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void scrollToPosition(int i) {
|
||||
this.currentEstimatedPosition = i;
|
||||
if (this.keylineStateList == null) {
|
||||
return;
|
||||
}
|
||||
this.scrollOffset = getScrollOffsetForPosition(i, getKeylineStateForPosition(i));
|
||||
this.currentFillStartPosition = MathUtils.clamp(i, 0, Math.max(0, getItemCount() - 1));
|
||||
updateCurrentKeylineStateForScrollOffset(this.keylineStateList);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int i) {
|
||||
LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(recyclerView.getContext()) { // from class: com.google.android.material.carousel.CarouselLayoutManager.1
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.SmoothScroller
|
||||
public PointF computeScrollVectorForPosition(int i2) {
|
||||
return CarouselLayoutManager.this.computeScrollVectorForPosition(i2);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.LinearSmoothScroller
|
||||
public int calculateDxToMakeVisible(View view, int i2) {
|
||||
if (CarouselLayoutManager.this.keylineStateList == null || !CarouselLayoutManager.this.isHorizontal()) {
|
||||
return 0;
|
||||
}
|
||||
CarouselLayoutManager carouselLayoutManager = CarouselLayoutManager.this;
|
||||
return carouselLayoutManager.calculateScrollDeltaToMakePositionVisible(carouselLayoutManager.getPosition(view));
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.LinearSmoothScroller
|
||||
public int calculateDyToMakeVisible(View view, int i2) {
|
||||
if (CarouselLayoutManager.this.keylineStateList == null || CarouselLayoutManager.this.isHorizontal()) {
|
||||
return 0;
|
||||
}
|
||||
CarouselLayoutManager carouselLayoutManager = CarouselLayoutManager.this;
|
||||
return carouselLayoutManager.calculateScrollDeltaToMakePositionVisible(carouselLayoutManager.getPosition(view));
|
||||
}
|
||||
};
|
||||
linearSmoothScroller.setTargetPosition(i);
|
||||
startSmoothScroll(linearSmoothScroller);
|
||||
}
|
||||
|
||||
int calculateScrollDeltaToMakePositionVisible(int i) {
|
||||
return (int) (this.scrollOffset - getScrollOffsetForPosition(i, getKeylineStateForPosition(i)));
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public boolean canScrollHorizontally() {
|
||||
return isHorizontal();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public int scrollHorizontallyBy(int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
if (canScrollHorizontally()) {
|
||||
return scrollBy(i, recycler, state);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public boolean canScrollVertically() {
|
||||
return !isHorizontal();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public int scrollVerticallyBy(int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
if (canScrollVertically()) {
|
||||
return scrollBy(i, recycler, state);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static class LayoutDirection {
|
||||
private static final int INVALID_LAYOUT = Integer.MIN_VALUE;
|
||||
private static final int LAYOUT_END = 1;
|
||||
private static final int LAYOUT_START = -1;
|
||||
|
||||
private LayoutDirection() {
|
||||
}
|
||||
}
|
||||
|
||||
private int convertFocusDirectionToLayoutDirection(int i) {
|
||||
int orientation = getOrientation();
|
||||
if (i == 1) {
|
||||
return -1;
|
||||
}
|
||||
if (i == 2) {
|
||||
return 1;
|
||||
}
|
||||
if (i == 17) {
|
||||
if (orientation == 0) {
|
||||
return isLayoutRtl() ? 1 : -1;
|
||||
}
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
if (i == 33) {
|
||||
return orientation == 1 ? -1 : Integer.MIN_VALUE;
|
||||
}
|
||||
if (i == 66) {
|
||||
if (orientation == 0) {
|
||||
return isLayoutRtl() ? -1 : 1;
|
||||
}
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
if (i == 130) {
|
||||
return orientation == 1 ? 1 : Integer.MIN_VALUE;
|
||||
}
|
||||
Log.d(TAG, "Unknown focus request:" + i);
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public View onFocusSearchFailed(View view, int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
int convertFocusDirectionToLayoutDirection;
|
||||
if (getChildCount() == 0 || (convertFocusDirectionToLayoutDirection = convertFocusDirectionToLayoutDirection(i)) == Integer.MIN_VALUE) {
|
||||
return null;
|
||||
}
|
||||
if (convertFocusDirectionToLayoutDirection == -1) {
|
||||
if (getPosition(view) == 0) {
|
||||
return null;
|
||||
}
|
||||
addViewAtPosition(recycler, getPosition(getChildAt(0)) - 1, 0);
|
||||
return getChildClosestToStart();
|
||||
}
|
||||
if (getPosition(view) == getItemCount() - 1) {
|
||||
return null;
|
||||
}
|
||||
addViewAtPosition(recycler, getPosition(getChildAt(getChildCount() - 1)) + 1, -1);
|
||||
return getChildClosestToEnd();
|
||||
}
|
||||
|
||||
private View getChildClosestToStart() {
|
||||
return getChildAt(isLayoutRtl() ? getChildCount() - 1 : 0);
|
||||
}
|
||||
|
||||
private View getChildClosestToEnd() {
|
||||
return getChildAt(isLayoutRtl() ? 0 : getChildCount() - 1);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public boolean requestChildRectangleOnScreen(RecyclerView recyclerView, View view, Rect rect, boolean z, boolean z2) {
|
||||
int smallestScrollOffsetToFocalKeyline;
|
||||
if (this.keylineStateList == null || (smallestScrollOffsetToFocalKeyline = getSmallestScrollOffsetToFocalKeyline(getPosition(view), getKeylineStateForPosition(getPosition(view)))) == 0) {
|
||||
return false;
|
||||
}
|
||||
scrollBy(recyclerView, getSmallestScrollOffsetToFocalKeyline(getPosition(view), this.keylineStateList.getShiftedState(this.scrollOffset + calculateShouldScrollBy(smallestScrollOffsetToFocalKeyline, this.scrollOffset, this.minScroll, this.maxScroll), this.minScroll, this.maxScroll)));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void scrollBy(RecyclerView recyclerView, int i) {
|
||||
if (isHorizontal()) {
|
||||
recyclerView.scrollBy(i, 0);
|
||||
} else {
|
||||
recyclerView.scrollBy(0, i);
|
||||
}
|
||||
}
|
||||
|
||||
private int scrollBy(int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
float f;
|
||||
if (getChildCount() == 0 || i == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (this.keylineStateList == null) {
|
||||
recalculateKeylineStateList(recycler);
|
||||
}
|
||||
int calculateShouldScrollBy = calculateShouldScrollBy(i, this.scrollOffset, this.minScroll, this.maxScroll);
|
||||
this.scrollOffset += calculateShouldScrollBy;
|
||||
updateCurrentKeylineStateForScrollOffset(this.keylineStateList);
|
||||
float itemSize = this.currentKeylineState.getItemSize() / 2.0f;
|
||||
float calculateChildStartForFill = calculateChildStartForFill(getPosition(getChildAt(0)));
|
||||
Rect rect = new Rect();
|
||||
if (isLayoutRtl()) {
|
||||
f = this.currentKeylineState.getLastFocalKeyline().locOffset;
|
||||
} else {
|
||||
f = this.currentKeylineState.getFirstFocalKeyline().locOffset;
|
||||
}
|
||||
float f2 = Float.MAX_VALUE;
|
||||
for (int i2 = 0; i2 < getChildCount(); i2++) {
|
||||
View childAt = getChildAt(i2);
|
||||
float abs = Math.abs(f - offsetChild(childAt, calculateChildStartForFill, itemSize, rect));
|
||||
if (childAt != null && abs < f2) {
|
||||
this.currentEstimatedPosition = getPosition(childAt);
|
||||
f2 = abs;
|
||||
}
|
||||
calculateChildStartForFill = addEnd(calculateChildStartForFill, this.currentKeylineState.getItemSize());
|
||||
}
|
||||
fill(recycler, state);
|
||||
return calculateShouldScrollBy;
|
||||
}
|
||||
|
||||
private float offsetChild(View view, float f, float f2, Rect rect) {
|
||||
float addEnd = addEnd(f, f2);
|
||||
KeylineRange surroundingKeylineRange = getSurroundingKeylineRange(this.currentKeylineState.getKeylines(), addEnd, false);
|
||||
float calculateChildOffsetCenterForLocation = calculateChildOffsetCenterForLocation(view, addEnd, surroundingKeylineRange);
|
||||
super.getDecoratedBoundsWithMargins(view, rect);
|
||||
updateChildMaskForLocation(view, addEnd, surroundingKeylineRange);
|
||||
this.orientationHelper.offsetChild(view, rect, f2, calculateChildOffsetCenterForLocation);
|
||||
return calculateChildOffsetCenterForLocation;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public int computeHorizontalScrollExtent(RecyclerView.State state) {
|
||||
if (getChildCount() == 0 || this.keylineStateList == null || getItemCount() <= 1) {
|
||||
return 0;
|
||||
}
|
||||
return (int) (getWidth() * (this.keylineStateList.getDefaultState().getItemSize() / computeHorizontalScrollRange(state)));
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public int computeVerticalScrollExtent(RecyclerView.State state) {
|
||||
if (getChildCount() == 0 || this.keylineStateList == null || getItemCount() <= 1) {
|
||||
return 0;
|
||||
}
|
||||
return (int) (getHeight() * (this.keylineStateList.getDefaultState().getItemSize() / computeVerticalScrollRange(state)));
|
||||
}
|
||||
|
||||
public int getOrientation() {
|
||||
return this.orientationHelper.orientation;
|
||||
}
|
||||
|
||||
public void setOrientation(int i) {
|
||||
if (i != 0 && i != 1) {
|
||||
throw new IllegalArgumentException("invalid orientation:" + i);
|
||||
}
|
||||
assertNotInLayoutOrScroll(null);
|
||||
CarouselOrientationHelper carouselOrientationHelper = this.orientationHelper;
|
||||
if (carouselOrientationHelper == null || i != carouselOrientationHelper.orientation) {
|
||||
this.orientationHelper = CarouselOrientationHelper.createOrientationHelper(this, i);
|
||||
refreshKeylineState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void onItemsAdded(RecyclerView recyclerView, int i, int i2) {
|
||||
super.onItemsAdded(recyclerView, i, i2);
|
||||
updateItemCount();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
public void onItemsRemoved(RecyclerView recyclerView, int i, int i2) {
|
||||
super.onItemsRemoved(recyclerView, i, i2);
|
||||
updateItemCount();
|
||||
}
|
||||
|
||||
private void updateItemCount() {
|
||||
int itemCount = getItemCount();
|
||||
int i = this.lastItemCount;
|
||||
if (itemCount == i || this.keylineStateList == null) {
|
||||
return;
|
||||
}
|
||||
if (this.carouselStrategy.shouldRefreshKeylineState(this, i)) {
|
||||
refreshKeylineState();
|
||||
}
|
||||
this.lastItemCount = itemCount;
|
||||
}
|
||||
|
||||
public void setDebuggingEnabled(RecyclerView recyclerView, boolean z) {
|
||||
this.isDebuggingEnabled = z;
|
||||
recyclerView.removeItemDecoration(this.debugItemDecoration);
|
||||
if (z) {
|
||||
recyclerView.addItemDecoration(this.debugItemDecoration);
|
||||
}
|
||||
recyclerView.invalidateItemDecorations();
|
||||
}
|
||||
|
||||
private static class KeylineRange {
|
||||
final KeylineState.Keyline leftOrTop;
|
||||
final KeylineState.Keyline rightOrBottom;
|
||||
|
||||
KeylineRange(KeylineState.Keyline keyline, KeylineState.Keyline keyline2) {
|
||||
Preconditions.checkArgument(keyline.loc <= keyline2.loc);
|
||||
this.leftOrTop = keyline;
|
||||
this.rightOrBottom = keyline2;
|
||||
}
|
||||
}
|
||||
|
||||
private static class DebugItemDecoration extends RecyclerView.ItemDecoration {
|
||||
private List<KeylineState.Keyline> keylines;
|
||||
private final Paint linePaint;
|
||||
|
||||
DebugItemDecoration() {
|
||||
Paint paint = new Paint();
|
||||
this.linePaint = paint;
|
||||
this.keylines = Collections.unmodifiableList(new ArrayList());
|
||||
paint.setStrokeWidth(5.0f);
|
||||
paint.setColor(-65281);
|
||||
}
|
||||
|
||||
void setKeylines(List<KeylineState.Keyline> list) {
|
||||
this.keylines = Collections.unmodifiableList(list);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
public void onDrawOver(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state) {
|
||||
super.onDrawOver(canvas, recyclerView, state);
|
||||
this.linePaint.setStrokeWidth(recyclerView.getResources().getDimension(R.dimen.m3_carousel_debug_keyline_width));
|
||||
for (KeylineState.Keyline keyline : this.keylines) {
|
||||
this.linePaint.setColor(ColorUtils.blendARGB(-65281, -16776961, keyline.mask));
|
||||
if (((CarouselLayoutManager) recyclerView.getLayoutManager()).isHorizontal()) {
|
||||
canvas.drawLine(keyline.locOffset, ((CarouselLayoutManager) recyclerView.getLayoutManager()).getParentTop(), keyline.locOffset, ((CarouselLayoutManager) recyclerView.getLayoutManager()).getParentBottom(), this.linePaint);
|
||||
} else {
|
||||
canvas.drawLine(((CarouselLayoutManager) recyclerView.getLayoutManager()).getParentLeft(), keyline.locOffset, ((CarouselLayoutManager) recyclerView.getLayoutManager()).getParentRight(), keyline.locOffset, this.linePaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.view.View;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class CarouselOrientationHelper {
|
||||
final int orientation;
|
||||
|
||||
abstract void containMaskWithinBounds(RectF rectF, RectF rectF2, RectF rectF3);
|
||||
|
||||
abstract float getMaskMargins(RecyclerView.LayoutParams layoutParams);
|
||||
|
||||
abstract RectF getMaskRect(float f, float f2, float f3, float f4);
|
||||
|
||||
abstract int getParentBottom();
|
||||
|
||||
abstract int getParentEnd();
|
||||
|
||||
abstract int getParentLeft();
|
||||
|
||||
abstract int getParentRight();
|
||||
|
||||
abstract int getParentStart();
|
||||
|
||||
abstract int getParentTop();
|
||||
|
||||
abstract void layoutDecoratedWithMargins(View view, int i, int i2);
|
||||
|
||||
abstract void moveMaskOnEdgeOutsideBounds(RectF rectF, RectF rectF2, RectF rectF3);
|
||||
|
||||
abstract void offsetChild(View view, Rect rect, float f, float f2);
|
||||
|
||||
private CarouselOrientationHelper(int i) {
|
||||
this.orientation = i;
|
||||
}
|
||||
|
||||
static CarouselOrientationHelper createOrientationHelper(CarouselLayoutManager carouselLayoutManager, int i) {
|
||||
if (i == 0) {
|
||||
return createHorizontalHelper(carouselLayoutManager);
|
||||
}
|
||||
if (i == 1) {
|
||||
return createVerticalHelper(carouselLayoutManager);
|
||||
}
|
||||
throw new IllegalArgumentException("invalid orientation");
|
||||
}
|
||||
|
||||
private static CarouselOrientationHelper createVerticalHelper(final CarouselLayoutManager carouselLayoutManager) {
|
||||
return new CarouselOrientationHelper(1) { // from class: com.google.android.material.carousel.CarouselOrientationHelper.1
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentTop() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentLeft() {
|
||||
return carouselLayoutManager.getPaddingLeft();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentStart() {
|
||||
return getParentTop();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentRight() {
|
||||
return carouselLayoutManager.getWidth() - carouselLayoutManager.getPaddingRight();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentEnd() {
|
||||
return getParentBottom();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentBottom() {
|
||||
return carouselLayoutManager.getHeight();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public void layoutDecoratedWithMargins(View view, int i, int i2) {
|
||||
carouselLayoutManager.layoutDecoratedWithMargins(view, getParentLeft(), i, getParentRight(), i2);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public float getMaskMargins(RecyclerView.LayoutParams layoutParams) {
|
||||
return layoutParams.topMargin + layoutParams.bottomMargin;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public RectF getMaskRect(float f, float f2, float f3, float f4) {
|
||||
return new RectF(0.0f, f3, f2, f - f3);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public void containMaskWithinBounds(RectF rectF, RectF rectF2, RectF rectF3) {
|
||||
if (rectF2.top < rectF3.top && rectF2.bottom > rectF3.top) {
|
||||
float f = rectF3.top - rectF2.top;
|
||||
rectF.top += f;
|
||||
rectF3.top += f;
|
||||
}
|
||||
if (rectF2.bottom <= rectF3.bottom || rectF2.top >= rectF3.bottom) {
|
||||
return;
|
||||
}
|
||||
float f2 = rectF2.bottom - rectF3.bottom;
|
||||
rectF.bottom = Math.max(rectF.bottom - f2, rectF.top);
|
||||
rectF2.bottom = Math.max(rectF2.bottom - f2, rectF2.top);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public void moveMaskOnEdgeOutsideBounds(RectF rectF, RectF rectF2, RectF rectF3) {
|
||||
if (rectF2.bottom <= rectF3.top) {
|
||||
rectF.bottom = ((float) Math.floor(rectF.bottom)) - 1.0f;
|
||||
rectF.top = Math.min(rectF.top, rectF.bottom);
|
||||
}
|
||||
if (rectF2.top >= rectF3.bottom) {
|
||||
rectF.top = ((float) Math.ceil(rectF.top)) + 1.0f;
|
||||
rectF.bottom = Math.max(rectF.top, rectF.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public void offsetChild(View view, Rect rect, float f, float f2) {
|
||||
view.offsetTopAndBottom((int) (f2 - (rect.top + f)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static CarouselOrientationHelper createHorizontalHelper(final CarouselLayoutManager carouselLayoutManager) {
|
||||
return new CarouselOrientationHelper(0) { // from class: com.google.android.material.carousel.CarouselOrientationHelper.2
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentLeft() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentStart() {
|
||||
return carouselLayoutManager.isLayoutRtl() ? getParentRight() : getParentLeft();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentRight() {
|
||||
return carouselLayoutManager.getWidth();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentEnd() {
|
||||
return carouselLayoutManager.isLayoutRtl() ? getParentLeft() : getParentRight();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentTop() {
|
||||
return carouselLayoutManager.getPaddingTop();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
int getParentBottom() {
|
||||
return carouselLayoutManager.getHeight() - carouselLayoutManager.getPaddingBottom();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public void layoutDecoratedWithMargins(View view, int i, int i2) {
|
||||
carouselLayoutManager.layoutDecoratedWithMargins(view, i, getParentTop(), i2, getParentBottom());
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public float getMaskMargins(RecyclerView.LayoutParams layoutParams) {
|
||||
return layoutParams.rightMargin + layoutParams.leftMargin;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public RectF getMaskRect(float f, float f2, float f3, float f4) {
|
||||
return new RectF(f4, 0.0f, f2 - f4, f);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public void containMaskWithinBounds(RectF rectF, RectF rectF2, RectF rectF3) {
|
||||
if (rectF2.left < rectF3.left && rectF2.right > rectF3.left) {
|
||||
float f = rectF3.left - rectF2.left;
|
||||
rectF.left += f;
|
||||
rectF2.left += f;
|
||||
}
|
||||
if (rectF2.right <= rectF3.right || rectF2.left >= rectF3.right) {
|
||||
return;
|
||||
}
|
||||
float f2 = rectF2.right - rectF3.right;
|
||||
rectF.right = Math.max(rectF.right - f2, rectF.left);
|
||||
rectF2.right = Math.max(rectF2.right - f2, rectF2.left);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public void moveMaskOnEdgeOutsideBounds(RectF rectF, RectF rectF2, RectF rectF3) {
|
||||
if (rectF2.right <= rectF3.left) {
|
||||
rectF.right = ((float) Math.floor(rectF.right)) - 1.0f;
|
||||
rectF.left = Math.min(rectF.left, rectF.right);
|
||||
}
|
||||
if (rectF2.left >= rectF3.right) {
|
||||
rectF.left = ((float) Math.ceil(rectF.left)) + 1.0f;
|
||||
rectF.right = Math.max(rectF.left, rectF.right);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselOrientationHelper
|
||||
public void offsetChild(View view, Rect rect, float f, float f2) {
|
||||
view.offsetLeftAndRight((int) (f2 - (rect.left + f)));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SnapHelper;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CarouselSnapHelper extends SnapHelper {
|
||||
private static final float HORIZONTAL_SNAP_SPEED = 100.0f;
|
||||
private static final float VERTICAL_SNAP_SPEED = 50.0f;
|
||||
private final boolean disableFling;
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
public CarouselSnapHelper() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
public CarouselSnapHelper(boolean z) {
|
||||
this.disableFling = z;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.SnapHelper
|
||||
public void attachToRecyclerView(RecyclerView recyclerView) {
|
||||
super.attachToRecyclerView(recyclerView);
|
||||
this.recyclerView = recyclerView;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.SnapHelper
|
||||
public int[] calculateDistanceToFinalSnap(RecyclerView.LayoutManager layoutManager, View view) {
|
||||
return calculateDistanceToSnap(layoutManager, view, false);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int[] calculateDistanceToSnap(RecyclerView.LayoutManager layoutManager, View view, boolean z) {
|
||||
if (!(layoutManager instanceof CarouselLayoutManager)) {
|
||||
return new int[]{0, 0};
|
||||
}
|
||||
int distanceToFirstFocalKeyline = distanceToFirstFocalKeyline(view, (CarouselLayoutManager) layoutManager, z);
|
||||
return layoutManager.canScrollHorizontally() ? new int[]{distanceToFirstFocalKeyline, 0} : layoutManager.canScrollVertically() ? new int[]{0, distanceToFirstFocalKeyline} : new int[]{0, 0};
|
||||
}
|
||||
|
||||
private int distanceToFirstFocalKeyline(View view, CarouselLayoutManager carouselLayoutManager, boolean z) {
|
||||
return carouselLayoutManager.getOffsetToScrollToPositionForSnap(carouselLayoutManager.getPosition(view), z);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.SnapHelper
|
||||
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
|
||||
return findViewNearestFirstKeyline(layoutManager);
|
||||
}
|
||||
|
||||
private View findViewNearestFirstKeyline(RecyclerView.LayoutManager layoutManager) {
|
||||
int childCount = layoutManager.getChildCount();
|
||||
View view = null;
|
||||
if (childCount != 0 && (layoutManager instanceof CarouselLayoutManager)) {
|
||||
CarouselLayoutManager carouselLayoutManager = (CarouselLayoutManager) layoutManager;
|
||||
int i = Integer.MAX_VALUE;
|
||||
for (int i2 = 0; i2 < childCount; i2++) {
|
||||
View childAt = layoutManager.getChildAt(i2);
|
||||
int abs = Math.abs(carouselLayoutManager.getOffsetToScrollToPositionForSnap(layoutManager.getPosition(childAt), false));
|
||||
if (abs < i) {
|
||||
view = childAt;
|
||||
i = abs;
|
||||
}
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.SnapHelper
|
||||
public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int i, int i2) {
|
||||
int itemCount;
|
||||
if (!this.disableFling || (itemCount = layoutManager.getItemCount()) == 0) {
|
||||
return -1;
|
||||
}
|
||||
int childCount = layoutManager.getChildCount();
|
||||
View view = null;
|
||||
View view2 = null;
|
||||
int i3 = Integer.MIN_VALUE;
|
||||
int i4 = Integer.MAX_VALUE;
|
||||
for (int i5 = 0; i5 < childCount; i5++) {
|
||||
View childAt = layoutManager.getChildAt(i5);
|
||||
if (childAt != null) {
|
||||
int distanceToFirstFocalKeyline = distanceToFirstFocalKeyline(childAt, (CarouselLayoutManager) layoutManager, false);
|
||||
if (distanceToFirstFocalKeyline <= 0 && distanceToFirstFocalKeyline > i3) {
|
||||
view2 = childAt;
|
||||
i3 = distanceToFirstFocalKeyline;
|
||||
}
|
||||
if (distanceToFirstFocalKeyline >= 0 && distanceToFirstFocalKeyline < i4) {
|
||||
view = childAt;
|
||||
i4 = distanceToFirstFocalKeyline;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean isForwardFling = isForwardFling(layoutManager, i, i2);
|
||||
if (isForwardFling && view != null) {
|
||||
return layoutManager.getPosition(view);
|
||||
}
|
||||
if (!isForwardFling && view2 != null) {
|
||||
return layoutManager.getPosition(view2);
|
||||
}
|
||||
if (isForwardFling) {
|
||||
view = view2;
|
||||
}
|
||||
if (view == null) {
|
||||
return -1;
|
||||
}
|
||||
int position = layoutManager.getPosition(view) + (isReverseLayout(layoutManager) == isForwardFling ? -1 : 1);
|
||||
if (position < 0 || position >= itemCount) {
|
||||
return -1;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
private boolean isForwardFling(RecyclerView.LayoutManager layoutManager, int i, int i2) {
|
||||
return layoutManager.canScrollHorizontally() ? i > 0 : i2 > 0;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
private boolean isReverseLayout(RecyclerView.LayoutManager layoutManager) {
|
||||
PointF computeScrollVectorForPosition;
|
||||
int itemCount = layoutManager.getItemCount();
|
||||
if (!(layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider) || (computeScrollVectorForPosition = ((RecyclerView.SmoothScroller.ScrollVectorProvider) layoutManager).computeScrollVectorForPosition(itemCount - 1)) == null) {
|
||||
return false;
|
||||
}
|
||||
return computeScrollVectorForPosition.x < 0.0f || computeScrollVectorForPosition.y < 0.0f;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.SnapHelper
|
||||
protected RecyclerView.SmoothScroller createScroller(final RecyclerView.LayoutManager layoutManager) {
|
||||
if (layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider) {
|
||||
return new LinearSmoothScroller(this.recyclerView.getContext()) { // from class: com.google.android.material.carousel.CarouselSnapHelper.1
|
||||
@Override // androidx.recyclerview.widget.LinearSmoothScroller, androidx.recyclerview.widget.RecyclerView.SmoothScroller
|
||||
protected void onTargetFound(View view, RecyclerView.State state, RecyclerView.SmoothScroller.Action action) {
|
||||
if (CarouselSnapHelper.this.recyclerView != null) {
|
||||
CarouselSnapHelper carouselSnapHelper = CarouselSnapHelper.this;
|
||||
int[] calculateDistanceToSnap = carouselSnapHelper.calculateDistanceToSnap(carouselSnapHelper.recyclerView.getLayoutManager(), view, true);
|
||||
int i = calculateDistanceToSnap[0];
|
||||
int i2 = calculateDistanceToSnap[1];
|
||||
int calculateTimeForDeceleration = calculateTimeForDeceleration(Math.max(Math.abs(i), Math.abs(i2)));
|
||||
if (calculateTimeForDeceleration > 0) {
|
||||
action.update(i, i2, calculateTimeForDeceleration, this.mDecelerateInterpolator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.LinearSmoothScroller
|
||||
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
|
||||
float f;
|
||||
float f2;
|
||||
if (layoutManager.canScrollVertically()) {
|
||||
f = displayMetrics.densityDpi;
|
||||
f2 = 50.0f;
|
||||
} else {
|
||||
f = displayMetrics.densityDpi;
|
||||
f2 = CarouselSnapHelper.HORIZONTAL_SNAP_SPEED;
|
||||
}
|
||||
return f2 / f;
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class CarouselStrategy {
|
||||
static float getChildMaskPercentage(float f, float f2, float f3) {
|
||||
return 1.0f - ((f - f3) / (f2 - f3));
|
||||
}
|
||||
|
||||
boolean isContained() {
|
||||
return true;
|
||||
}
|
||||
|
||||
abstract KeylineState onFirstChildMeasuredWithMargins(Carousel carousel, View view);
|
||||
|
||||
boolean shouldRefreshKeylineState(Carousel carousel, int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static int[] doubleCounts(int[] iArr) {
|
||||
int length = iArr.length;
|
||||
int[] iArr2 = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
iArr2[i] = iArr[i] * 2;
|
||||
}
|
||||
return iArr2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.content.Context;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.carousel.KeylineState;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class CarouselStrategyHelper {
|
||||
static float addStart(float f, float f2, int i) {
|
||||
return i > 0 ? f + (f2 / 2.0f) : f;
|
||||
}
|
||||
|
||||
static float updateCurPosition(float f, float f2, float f3, int i) {
|
||||
return i > 0 ? f2 + (f3 / 2.0f) : f;
|
||||
}
|
||||
|
||||
private CarouselStrategyHelper() {
|
||||
}
|
||||
|
||||
static float getExtraSmallSize(Context context) {
|
||||
return context.getResources().getDimension(R.dimen.m3_carousel_gone_size);
|
||||
}
|
||||
|
||||
static float getSmallSizeMin(Context context) {
|
||||
return context.getResources().getDimension(R.dimen.m3_carousel_small_item_size_min);
|
||||
}
|
||||
|
||||
static float getSmallSizeMax(Context context) {
|
||||
return context.getResources().getDimension(R.dimen.m3_carousel_small_item_size_max);
|
||||
}
|
||||
|
||||
static KeylineState createKeylineState(Context context, float f, float f2, Arrangement arrangement, int i) {
|
||||
if (i == 1) {
|
||||
return createCenterAlignedKeylineState(context, f, f2, arrangement);
|
||||
}
|
||||
return createLeftAlignedKeylineState(context, f, f2, arrangement);
|
||||
}
|
||||
|
||||
static KeylineState createLeftAlignedKeylineState(Context context, float f, float f2, Arrangement arrangement) {
|
||||
float min = Math.min(getExtraSmallSize(context) + f, arrangement.largeSize);
|
||||
float f3 = min / 2.0f;
|
||||
float f4 = 0.0f - f3;
|
||||
float addStart = addStart(0.0f, arrangement.largeSize, arrangement.largeCount);
|
||||
float updateCurPosition = updateCurPosition(0.0f, addEnd(addStart, arrangement.largeSize, arrangement.largeCount), arrangement.largeSize, arrangement.largeCount);
|
||||
float addStart2 = addStart(updateCurPosition, arrangement.mediumSize, arrangement.mediumCount);
|
||||
float addStart3 = addStart(updateCurPosition(updateCurPosition, addStart2, arrangement.mediumSize, arrangement.mediumCount), arrangement.smallSize, arrangement.smallCount);
|
||||
float f5 = f3 + f2;
|
||||
float childMaskPercentage = CarouselStrategy.getChildMaskPercentage(min, arrangement.largeSize, f);
|
||||
float childMaskPercentage2 = CarouselStrategy.getChildMaskPercentage(arrangement.smallSize, arrangement.largeSize, f);
|
||||
float childMaskPercentage3 = CarouselStrategy.getChildMaskPercentage(arrangement.mediumSize, arrangement.largeSize, f);
|
||||
KeylineState.Builder addKeylineRange = new KeylineState.Builder(arrangement.largeSize, f2).addAnchorKeyline(f4, childMaskPercentage, min).addKeylineRange(addStart, 0.0f, arrangement.largeSize, arrangement.largeCount, true);
|
||||
if (arrangement.mediumCount > 0) {
|
||||
addKeylineRange.addKeyline(addStart2, childMaskPercentage3, arrangement.mediumSize);
|
||||
}
|
||||
if (arrangement.smallCount > 0) {
|
||||
addKeylineRange.addKeylineRange(addStart3, childMaskPercentage2, arrangement.smallSize, arrangement.smallCount);
|
||||
}
|
||||
addKeylineRange.addAnchorKeyline(f5, childMaskPercentage, min);
|
||||
return addKeylineRange.build();
|
||||
}
|
||||
|
||||
static KeylineState createCenterAlignedKeylineState(Context context, float f, float f2, Arrangement arrangement) {
|
||||
float f3;
|
||||
float min = Math.min(getExtraSmallSize(context) + f, arrangement.largeSize);
|
||||
float f4 = min / 2.0f;
|
||||
float f5 = 0.0f - f4;
|
||||
float addStart = addStart(0.0f, arrangement.smallSize, arrangement.smallCount);
|
||||
float updateCurPosition = updateCurPosition(0.0f, addEnd(addStart, arrangement.smallSize, (int) Math.floor(arrangement.smallCount / 2.0f)), arrangement.smallSize, arrangement.smallCount);
|
||||
float addStart2 = addStart(updateCurPosition, arrangement.mediumSize, arrangement.mediumCount);
|
||||
float updateCurPosition2 = updateCurPosition(updateCurPosition, addEnd(addStart2, arrangement.mediumSize, (int) Math.floor(arrangement.mediumCount / 2.0f)), arrangement.mediumSize, arrangement.mediumCount);
|
||||
float addStart3 = addStart(updateCurPosition2, arrangement.largeSize, arrangement.largeCount);
|
||||
float updateCurPosition3 = updateCurPosition(updateCurPosition2, addEnd(addStart3, arrangement.largeSize, arrangement.largeCount), arrangement.largeSize, arrangement.largeCount);
|
||||
float addStart4 = addStart(updateCurPosition3, arrangement.mediumSize, arrangement.mediumCount);
|
||||
float addStart5 = addStart(updateCurPosition(updateCurPosition3, addEnd(addStart4, arrangement.mediumSize, (int) Math.ceil(arrangement.mediumCount / 2.0f)), arrangement.mediumSize, arrangement.mediumCount), arrangement.smallSize, arrangement.smallCount);
|
||||
float f6 = f4 + f2;
|
||||
float childMaskPercentage = CarouselStrategy.getChildMaskPercentage(min, arrangement.largeSize, f);
|
||||
float childMaskPercentage2 = CarouselStrategy.getChildMaskPercentage(arrangement.smallSize, arrangement.largeSize, f);
|
||||
float childMaskPercentage3 = CarouselStrategy.getChildMaskPercentage(arrangement.mediumSize, arrangement.largeSize, f);
|
||||
KeylineState.Builder addAnchorKeyline = new KeylineState.Builder(arrangement.largeSize, f2).addAnchorKeyline(f5, childMaskPercentage, min);
|
||||
if (arrangement.smallCount > 0) {
|
||||
f3 = f6;
|
||||
addAnchorKeyline.addKeylineRange(addStart, childMaskPercentage2, arrangement.smallSize, (int) Math.floor(arrangement.smallCount / 2.0f));
|
||||
} else {
|
||||
f3 = f6;
|
||||
}
|
||||
if (arrangement.mediumCount > 0) {
|
||||
addAnchorKeyline.addKeylineRange(addStart2, childMaskPercentage3, arrangement.mediumSize, (int) Math.floor(arrangement.mediumCount / 2.0f));
|
||||
}
|
||||
addAnchorKeyline.addKeylineRange(addStart3, 0.0f, arrangement.largeSize, arrangement.largeCount, true);
|
||||
if (arrangement.mediumCount > 0) {
|
||||
addAnchorKeyline.addKeylineRange(addStart4, childMaskPercentage3, arrangement.mediumSize, (int) Math.ceil(arrangement.mediumCount / 2.0f));
|
||||
}
|
||||
if (arrangement.smallCount > 0) {
|
||||
addAnchorKeyline.addKeylineRange(addStart5, childMaskPercentage2, arrangement.smallSize, (int) Math.ceil(arrangement.smallCount / 2.0f));
|
||||
}
|
||||
addAnchorKeyline.addAnchorKeyline(f3, childMaskPercentage, min);
|
||||
return addAnchorKeyline.build();
|
||||
}
|
||||
|
||||
static int maxValue(int[] iArr) {
|
||||
int i = Integer.MIN_VALUE;
|
||||
for (int i2 : iArr) {
|
||||
if (i2 > i) {
|
||||
i = i2;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static float addEnd(float f, float f2, int i) {
|
||||
return f + (Math.max(0, i - 1) * f2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FullScreenCarouselStrategy extends CarouselStrategy {
|
||||
@Override // com.google.android.material.carousel.CarouselStrategy
|
||||
KeylineState onFirstChildMeasuredWithMargins(Carousel carousel, View view) {
|
||||
float containerHeight;
|
||||
int i;
|
||||
int i2;
|
||||
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
if (carousel.isHorizontal()) {
|
||||
containerHeight = carousel.getContainerWidth();
|
||||
i = layoutParams.leftMargin;
|
||||
i2 = layoutParams.rightMargin;
|
||||
} else {
|
||||
containerHeight = carousel.getContainerHeight();
|
||||
i = layoutParams.topMargin;
|
||||
i2 = layoutParams.bottomMargin;
|
||||
}
|
||||
float f = i + i2;
|
||||
return CarouselStrategyHelper.createLeftAlignedKeylineState(view.getContext(), f, containerHeight, new Arrangement(0, 0.0f, 0.0f, 0.0f, 0, 0.0f, 0, Math.min(containerHeight + f, containerHeight), 1, containerHeight));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.core.math.MathUtils;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HeroCarouselStrategy extends CarouselStrategy {
|
||||
private int keylineCount = 0;
|
||||
private static final int[] SMALL_COUNTS = {1};
|
||||
private static final int[] MEDIUM_COUNTS = {0, 1};
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselStrategy
|
||||
KeylineState onFirstChildMeasuredWithMargins(Carousel carousel, View view) {
|
||||
int i;
|
||||
int containerHeight = carousel.getContainerHeight();
|
||||
if (carousel.isHorizontal()) {
|
||||
containerHeight = carousel.getContainerWidth();
|
||||
}
|
||||
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
float f = layoutParams.topMargin + layoutParams.bottomMargin;
|
||||
float measuredWidth = view.getMeasuredWidth() * 2;
|
||||
if (carousel.isHorizontal()) {
|
||||
f = layoutParams.leftMargin + layoutParams.rightMargin;
|
||||
measuredWidth = view.getMeasuredHeight() * 2;
|
||||
}
|
||||
float smallSizeMin = CarouselStrategyHelper.getSmallSizeMin(view.getContext()) + f;
|
||||
float smallSizeMax = CarouselStrategyHelper.getSmallSizeMax(view.getContext()) + f;
|
||||
float f2 = containerHeight;
|
||||
float min = Math.min(measuredWidth + f, f2);
|
||||
float clamp = MathUtils.clamp((measuredWidth / 3.0f) + f, CarouselStrategyHelper.getSmallSizeMin(view.getContext()) + f, CarouselStrategyHelper.getSmallSizeMax(view.getContext()) + f);
|
||||
float f3 = (min + clamp) / 2.0f;
|
||||
int[] iArr = f2 < 2.0f * smallSizeMin ? new int[]{0} : SMALL_COUNTS;
|
||||
int max = (int) Math.max(1.0d, Math.floor((f2 - (CarouselStrategyHelper.maxValue(r4) * smallSizeMax)) / min));
|
||||
int ceil = (((int) Math.ceil(f2 / min)) - max) + 1;
|
||||
int[] iArr2 = new int[ceil];
|
||||
for (int i2 = 0; i2 < ceil; i2++) {
|
||||
iArr2[i2] = max + i2;
|
||||
}
|
||||
int i3 = carousel.getCarouselAlignment() == 1 ? 1 : 0;
|
||||
Arrangement findLowestCostArrangement = Arrangement.findLowestCostArrangement(f2, clamp, smallSizeMin, smallSizeMax, i3 != 0 ? doubleCounts(iArr) : iArr, f3, i3 != 0 ? doubleCounts(MEDIUM_COUNTS) : MEDIUM_COUNTS, min, iArr2);
|
||||
this.keylineCount = findLowestCostArrangement.getItemCount();
|
||||
if (findLowestCostArrangement.getItemCount() > carousel.getItemCount()) {
|
||||
findLowestCostArrangement = Arrangement.findLowestCostArrangement(f2, clamp, smallSizeMin, smallSizeMax, iArr, f3, MEDIUM_COUNTS, min, iArr2);
|
||||
i = 0;
|
||||
} else {
|
||||
i = i3;
|
||||
}
|
||||
return CarouselStrategyHelper.createKeylineState(view.getContext(), f, f2, findLowestCostArrangement, i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselStrategy
|
||||
boolean shouldRefreshKeylineState(Carousel carousel, int i) {
|
||||
if (carousel.getCarouselAlignment() == 1) {
|
||||
if (i < this.keylineCount && carousel.getItemCount() >= this.keylineCount) {
|
||||
return true;
|
||||
}
|
||||
if (i >= this.keylineCount && carousel.getItemCount() < this.keylineCount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class KeylineState {
|
||||
private final int firstFocalKeylineIndex;
|
||||
private final float itemSize;
|
||||
private final List<Keyline> keylines;
|
||||
private final int lastFocalKeylineIndex;
|
||||
|
||||
int getFirstFocalKeylineIndex() {
|
||||
return this.firstFocalKeylineIndex;
|
||||
}
|
||||
|
||||
float getItemSize() {
|
||||
return this.itemSize;
|
||||
}
|
||||
|
||||
List<Keyline> getKeylines() {
|
||||
return this.keylines;
|
||||
}
|
||||
|
||||
int getLastFocalKeylineIndex() {
|
||||
return this.lastFocalKeylineIndex;
|
||||
}
|
||||
|
||||
private KeylineState(float f, List<Keyline> list, int i, int i2) {
|
||||
this.itemSize = f;
|
||||
this.keylines = Collections.unmodifiableList(list);
|
||||
this.firstFocalKeylineIndex = i;
|
||||
this.lastFocalKeylineIndex = i2;
|
||||
}
|
||||
|
||||
Keyline getFirstFocalKeyline() {
|
||||
return this.keylines.get(this.firstFocalKeylineIndex);
|
||||
}
|
||||
|
||||
Keyline getLastFocalKeyline() {
|
||||
return this.keylines.get(this.lastFocalKeylineIndex);
|
||||
}
|
||||
|
||||
List<Keyline> getFocalKeylines() {
|
||||
return this.keylines.subList(this.firstFocalKeylineIndex, this.lastFocalKeylineIndex + 1);
|
||||
}
|
||||
|
||||
Keyline getFirstKeyline() {
|
||||
return this.keylines.get(0);
|
||||
}
|
||||
|
||||
Keyline getLastKeyline() {
|
||||
return this.keylines.get(r0.size() - 1);
|
||||
}
|
||||
|
||||
Keyline getFirstNonAnchorKeyline() {
|
||||
for (int i = 0; i < this.keylines.size(); i++) {
|
||||
Keyline keyline = this.keylines.get(i);
|
||||
if (!keyline.isAnchor) {
|
||||
return keyline;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Keyline getLastNonAnchorKeyline() {
|
||||
for (int size = this.keylines.size() - 1; size >= 0; size--) {
|
||||
Keyline keyline = this.keylines.get(size);
|
||||
if (!keyline.isAnchor) {
|
||||
return keyline;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static KeylineState lerp(KeylineState keylineState, KeylineState keylineState2, float f) {
|
||||
if (keylineState.getItemSize() != keylineState2.getItemSize()) {
|
||||
throw new IllegalArgumentException("Keylines being linearly interpolated must have the same item size.");
|
||||
}
|
||||
List<Keyline> keylines = keylineState.getKeylines();
|
||||
List<Keyline> keylines2 = keylineState2.getKeylines();
|
||||
if (keylines.size() != keylines2.size()) {
|
||||
throw new IllegalArgumentException("Keylines being linearly interpolated must have the same number of keylines.");
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (int i = 0; i < keylineState.getKeylines().size(); i++) {
|
||||
arrayList.add(Keyline.lerp(keylines.get(i), keylines2.get(i), f));
|
||||
}
|
||||
return new KeylineState(keylineState.getItemSize(), arrayList, AnimationUtils.lerp(keylineState.getFirstFocalKeylineIndex(), keylineState2.getFirstFocalKeylineIndex(), f), AnimationUtils.lerp(keylineState.getLastFocalKeylineIndex(), keylineState2.getLastFocalKeylineIndex(), f));
|
||||
}
|
||||
|
||||
static KeylineState reverse(KeylineState keylineState, float f) {
|
||||
Builder builder = new Builder(keylineState.getItemSize(), f);
|
||||
float f2 = (f - keylineState.getLastKeyline().locOffset) - (keylineState.getLastKeyline().maskedItemSize / 2.0f);
|
||||
int size = keylineState.getKeylines().size() - 1;
|
||||
while (size >= 0) {
|
||||
Keyline keyline = keylineState.getKeylines().get(size);
|
||||
builder.addKeyline(f2 + (keyline.maskedItemSize / 2.0f), keyline.mask, keyline.maskedItemSize, size >= keylineState.getFirstFocalKeylineIndex() && size <= keylineState.getLastFocalKeylineIndex(), keyline.isAnchor);
|
||||
f2 += keyline.maskedItemSize;
|
||||
size--;
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
static final class Builder {
|
||||
private static final int NO_INDEX = -1;
|
||||
private static final float UNKNOWN_LOC = Float.MIN_VALUE;
|
||||
private final float availableSpace;
|
||||
private final float itemSize;
|
||||
private Keyline tmpFirstFocalKeyline;
|
||||
private Keyline tmpLastFocalKeyline;
|
||||
private final List<Keyline> tmpKeylines = new ArrayList();
|
||||
private int firstFocalKeylineIndex = -1;
|
||||
private int lastFocalKeylineIndex = -1;
|
||||
private float lastKeylineMaskedSize = 0.0f;
|
||||
private int latestAnchorKeylineIndex = -1;
|
||||
|
||||
private static float calculateKeylineLocationForItemPosition(float f, float f2, int i, int i2) {
|
||||
return (f - (i * f2)) + (i2 * f2);
|
||||
}
|
||||
|
||||
Builder(float f, float f2) {
|
||||
this.itemSize = f;
|
||||
this.availableSpace = f2;
|
||||
}
|
||||
|
||||
Builder addKeyline(float f, float f2, float f3, boolean z) {
|
||||
return addKeyline(f, f2, f3, z, false);
|
||||
}
|
||||
|
||||
Builder addKeyline(float f, float f2, float f3) {
|
||||
return addKeyline(f, f2, f3, false);
|
||||
}
|
||||
|
||||
Builder addKeyline(float f, float f2, float f3, boolean z, boolean z2, float f4) {
|
||||
if (f3 <= 0.0f) {
|
||||
return this;
|
||||
}
|
||||
if (z2) {
|
||||
if (z) {
|
||||
throw new IllegalArgumentException("Anchor keylines cannot be focal.");
|
||||
}
|
||||
int i = this.latestAnchorKeylineIndex;
|
||||
if (i != -1 && i != 0) {
|
||||
throw new IllegalArgumentException("Anchor keylines must be either the first or last keyline.");
|
||||
}
|
||||
this.latestAnchorKeylineIndex = this.tmpKeylines.size();
|
||||
}
|
||||
Keyline keyline = new Keyline(Float.MIN_VALUE, f, f2, f3, z2, f4);
|
||||
if (z) {
|
||||
if (this.tmpFirstFocalKeyline == null) {
|
||||
this.tmpFirstFocalKeyline = keyline;
|
||||
this.firstFocalKeylineIndex = this.tmpKeylines.size();
|
||||
}
|
||||
if (this.lastFocalKeylineIndex != -1 && this.tmpKeylines.size() - this.lastFocalKeylineIndex > 1) {
|
||||
throw new IllegalArgumentException("Keylines marked as focal must be placed next to each other. There cannot be non-focal keylines between focal keylines.");
|
||||
}
|
||||
if (f3 != this.tmpFirstFocalKeyline.maskedItemSize) {
|
||||
throw new IllegalArgumentException("Keylines that are marked as focal must all have the same masked item size.");
|
||||
}
|
||||
this.tmpLastFocalKeyline = keyline;
|
||||
this.lastFocalKeylineIndex = this.tmpKeylines.size();
|
||||
} else {
|
||||
if (this.tmpFirstFocalKeyline == null && keyline.maskedItemSize < this.lastKeylineMaskedSize) {
|
||||
throw new IllegalArgumentException("Keylines before the first focal keyline must be ordered by incrementing masked item size.");
|
||||
}
|
||||
if (this.tmpLastFocalKeyline != null && keyline.maskedItemSize > this.lastKeylineMaskedSize) {
|
||||
throw new IllegalArgumentException("Keylines after the last focal keyline must be ordered by decreasing masked item size.");
|
||||
}
|
||||
}
|
||||
this.lastKeylineMaskedSize = keyline.maskedItemSize;
|
||||
this.tmpKeylines.add(keyline);
|
||||
return this;
|
||||
}
|
||||
|
||||
Builder addKeyline(float f, float f2, float f3, boolean z, boolean z2) {
|
||||
float f4;
|
||||
float abs;
|
||||
float f5 = f3 / 2.0f;
|
||||
float f6 = f - f5;
|
||||
float f7 = f5 + f;
|
||||
float f8 = this.availableSpace;
|
||||
if (f7 > f8) {
|
||||
abs = Math.abs(f7 - Math.max(f7 - f3, f8));
|
||||
} else if (f6 < 0.0f) {
|
||||
abs = Math.abs(f6 - Math.min(f6 + f3, 0.0f));
|
||||
} else {
|
||||
f4 = 0.0f;
|
||||
return addKeyline(f, f2, f3, z, z2, f4);
|
||||
}
|
||||
f4 = abs;
|
||||
return addKeyline(f, f2, f3, z, z2, f4);
|
||||
}
|
||||
|
||||
Builder addAnchorKeyline(float f, float f2, float f3) {
|
||||
return addKeyline(f, f2, f3, false, true);
|
||||
}
|
||||
|
||||
Builder addKeylineRange(float f, float f2, float f3, int i) {
|
||||
return addKeylineRange(f, f2, f3, i, false);
|
||||
}
|
||||
|
||||
Builder addKeylineRange(float f, float f2, float f3, int i, boolean z) {
|
||||
if (i > 0 && f3 > 0.0f) {
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
addKeyline((i2 * f3) + f, f2, f3, z);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
KeylineState build() {
|
||||
if (this.tmpFirstFocalKeyline == null) {
|
||||
throw new IllegalStateException("There must be a keyline marked as focal.");
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (int i = 0; i < this.tmpKeylines.size(); i++) {
|
||||
Keyline keyline = this.tmpKeylines.get(i);
|
||||
arrayList.add(new Keyline(calculateKeylineLocationForItemPosition(this.tmpFirstFocalKeyline.locOffset, this.itemSize, this.firstFocalKeylineIndex, i), keyline.locOffset, keyline.mask, keyline.maskedItemSize, keyline.isAnchor, keyline.cutoff));
|
||||
}
|
||||
return new KeylineState(this.itemSize, arrayList, this.firstFocalKeylineIndex, this.lastFocalKeylineIndex);
|
||||
}
|
||||
}
|
||||
|
||||
static final class Keyline {
|
||||
final float cutoff;
|
||||
final boolean isAnchor;
|
||||
final float loc;
|
||||
final float locOffset;
|
||||
final float mask;
|
||||
final float maskedItemSize;
|
||||
|
||||
Keyline(float f, float f2, float f3, float f4) {
|
||||
this(f, f2, f3, f4, false, 0.0f);
|
||||
}
|
||||
|
||||
Keyline(float f, float f2, float f3, float f4, boolean z, float f5) {
|
||||
this.loc = f;
|
||||
this.locOffset = f2;
|
||||
this.mask = f3;
|
||||
this.maskedItemSize = f4;
|
||||
this.isAnchor = z;
|
||||
this.cutoff = f5;
|
||||
}
|
||||
|
||||
static Keyline lerp(Keyline keyline, Keyline keyline2, float f) {
|
||||
return new Keyline(AnimationUtils.lerp(keyline.loc, keyline2.loc, f), AnimationUtils.lerp(keyline.locOffset, keyline2.locOffset, f), AnimationUtils.lerp(keyline.mask, keyline2.mask, f), AnimationUtils.lerp(keyline.maskedItemSize, keyline2.maskedItemSize, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import androidx.core.math.MathUtils;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.carousel.KeylineState;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class KeylineStateList {
|
||||
private static final int NO_INDEX = -1;
|
||||
private final KeylineState defaultState;
|
||||
private final float endShiftRange;
|
||||
private final List<KeylineState> endStateSteps;
|
||||
private final float[] endStateStepsInterpolationPoints;
|
||||
private final float startShiftRange;
|
||||
private final List<KeylineState> startStateSteps;
|
||||
private final float[] startStateStepsInterpolationPoints;
|
||||
|
||||
KeylineState getDefaultState() {
|
||||
return this.defaultState;
|
||||
}
|
||||
|
||||
private KeylineStateList(KeylineState keylineState, List<KeylineState> list, List<KeylineState> list2) {
|
||||
this.defaultState = keylineState;
|
||||
this.startStateSteps = Collections.unmodifiableList(list);
|
||||
this.endStateSteps = Collections.unmodifiableList(list2);
|
||||
float f = list.get(list.size() - 1).getFirstKeyline().loc - keylineState.getFirstKeyline().loc;
|
||||
this.startShiftRange = f;
|
||||
float f2 = keylineState.getLastKeyline().loc - list2.get(list2.size() - 1).getLastKeyline().loc;
|
||||
this.endShiftRange = f2;
|
||||
this.startStateStepsInterpolationPoints = getStateStepInterpolationPoints(f, list, true);
|
||||
this.endStateStepsInterpolationPoints = getStateStepInterpolationPoints(f2, list2, false);
|
||||
}
|
||||
|
||||
static KeylineStateList from(Carousel carousel, KeylineState keylineState) {
|
||||
return new KeylineStateList(keylineState, getStateStepsStart(carousel, keylineState), getStateStepsEnd(carousel, keylineState));
|
||||
}
|
||||
|
||||
KeylineState getStartState() {
|
||||
return this.startStateSteps.get(r0.size() - 1);
|
||||
}
|
||||
|
||||
KeylineState getEndState() {
|
||||
return this.endStateSteps.get(r0.size() - 1);
|
||||
}
|
||||
|
||||
public KeylineState getShiftedState(float f, float f2, float f3) {
|
||||
return getShiftedState(f, f2, f3, false);
|
||||
}
|
||||
|
||||
KeylineState getShiftedState(float f, float f2, float f3, boolean z) {
|
||||
float lerp;
|
||||
List<KeylineState> list;
|
||||
float[] fArr;
|
||||
float f4 = this.startShiftRange + f2;
|
||||
float f5 = f3 - this.endShiftRange;
|
||||
if (f < f4) {
|
||||
lerp = AnimationUtils.lerp(1.0f, 0.0f, f2, f4, f);
|
||||
list = this.startStateSteps;
|
||||
fArr = this.startStateStepsInterpolationPoints;
|
||||
} else {
|
||||
if (f <= f5) {
|
||||
return this.defaultState;
|
||||
}
|
||||
lerp = AnimationUtils.lerp(0.0f, 1.0f, f5, f3, f);
|
||||
list = this.endStateSteps;
|
||||
fArr = this.endStateStepsInterpolationPoints;
|
||||
}
|
||||
if (z) {
|
||||
return closestStateStepFromInterpolation(list, lerp, fArr);
|
||||
}
|
||||
return lerp(list, lerp, fArr);
|
||||
}
|
||||
|
||||
private static KeylineState lerp(List<KeylineState> list, float f, float[] fArr) {
|
||||
float[] stateStepsRange = getStateStepsRange(list, f, fArr);
|
||||
return KeylineState.lerp(list.get((int) stateStepsRange[1]), list.get((int) stateStepsRange[2]), stateStepsRange[0]);
|
||||
}
|
||||
|
||||
private static float[] getStateStepsRange(List<KeylineState> list, float f, float[] fArr) {
|
||||
int size = list.size();
|
||||
float f2 = fArr[0];
|
||||
int i = 1;
|
||||
while (i < size) {
|
||||
float f3 = fArr[i];
|
||||
if (f <= f3) {
|
||||
return new float[]{AnimationUtils.lerp(0.0f, 1.0f, f2, f3, f), i - 1, i};
|
||||
}
|
||||
i++;
|
||||
f2 = f3;
|
||||
}
|
||||
return new float[]{0.0f, 0.0f, 0.0f};
|
||||
}
|
||||
|
||||
private KeylineState closestStateStepFromInterpolation(List<KeylineState> list, float f, float[] fArr) {
|
||||
float[] stateStepsRange = getStateStepsRange(list, f, fArr);
|
||||
if (stateStepsRange[0] > 0.5f) {
|
||||
return list.get((int) stateStepsRange[2]);
|
||||
}
|
||||
return list.get((int) stateStepsRange[1]);
|
||||
}
|
||||
|
||||
private static float[] getStateStepInterpolationPoints(float f, List<KeylineState> list, boolean z) {
|
||||
float f2;
|
||||
int size = list.size();
|
||||
float[] fArr = new float[size];
|
||||
int i = 1;
|
||||
while (i < size) {
|
||||
int i2 = i - 1;
|
||||
KeylineState keylineState = list.get(i2);
|
||||
KeylineState keylineState2 = list.get(i);
|
||||
if (z) {
|
||||
f2 = keylineState2.getFirstKeyline().loc - keylineState.getFirstKeyline().loc;
|
||||
} else {
|
||||
f2 = keylineState.getLastKeyline().loc - keylineState2.getLastKeyline().loc;
|
||||
}
|
||||
fArr[i] = i == size + (-1) ? 1.0f : fArr[i2] + (f2 / f);
|
||||
i++;
|
||||
}
|
||||
return fArr;
|
||||
}
|
||||
|
||||
private static boolean isFirstFocalItemAtLeftOfContainer(KeylineState keylineState) {
|
||||
return keylineState.getFirstFocalKeyline().locOffset - (keylineState.getFirstFocalKeyline().maskedItemSize / 2.0f) >= 0.0f && keylineState.getFirstFocalKeyline() == keylineState.getFirstNonAnchorKeyline();
|
||||
}
|
||||
|
||||
private static boolean isLastFocalItemVisibleAtRightOfContainer(Carousel carousel, KeylineState keylineState) {
|
||||
int containerHeight = carousel.getContainerHeight();
|
||||
if (carousel.isHorizontal()) {
|
||||
containerHeight = carousel.getContainerWidth();
|
||||
}
|
||||
return keylineState.getLastFocalKeyline().locOffset + (keylineState.getLastFocalKeyline().maskedItemSize / 2.0f) <= ((float) containerHeight) && keylineState.getLastFocalKeyline() == keylineState.getLastNonAnchorKeyline();
|
||||
}
|
||||
|
||||
private static List<KeylineState> getStateStepsStart(Carousel carousel, KeylineState keylineState) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(keylineState);
|
||||
int findFirstNonAnchorKeylineIndex = findFirstNonAnchorKeylineIndex(keylineState);
|
||||
if (!isFirstFocalItemAtLeftOfContainer(keylineState) && findFirstNonAnchorKeylineIndex != -1) {
|
||||
int firstFocalKeylineIndex = keylineState.getFirstFocalKeylineIndex() - findFirstNonAnchorKeylineIndex;
|
||||
float containerWidth = carousel.isHorizontal() ? carousel.getContainerWidth() : carousel.getContainerHeight();
|
||||
float f = keylineState.getFirstKeyline().locOffset - (keylineState.getFirstKeyline().maskedItemSize / 2.0f);
|
||||
float f2 = 0.0f;
|
||||
if (firstFocalKeylineIndex <= 0 && keylineState.getFirstFocalKeyline().cutoff > 0.0f) {
|
||||
arrayList.add(shiftKeylinesAndCreateKeylineState(keylineState, f + keylineState.getFirstFocalKeyline().cutoff, containerWidth));
|
||||
return arrayList;
|
||||
}
|
||||
int i = 0;
|
||||
while (i < firstFocalKeylineIndex) {
|
||||
KeylineState keylineState2 = (KeylineState) arrayList.get(arrayList.size() - 1);
|
||||
int i2 = findFirstNonAnchorKeylineIndex + i;
|
||||
int size = keylineState.getKeylines().size() - 1;
|
||||
float f3 = f2 + keylineState.getKeylines().get(i2).cutoff;
|
||||
arrayList.add(moveKeylineAndCreateKeylineState(keylineState2, findFirstNonAnchorKeylineIndex, i2 - 1 >= 0 ? findFirstIndexAfterLastFocalKeylineWithMask(keylineState2, keylineState.getKeylines().get(r3).mask) - 1 : size, f + f3, (keylineState.getFirstFocalKeylineIndex() - i) - 1, (keylineState.getLastFocalKeylineIndex() - i) - 1, containerWidth));
|
||||
i++;
|
||||
f2 = f3;
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private static List<KeylineState> getStateStepsEnd(Carousel carousel, KeylineState keylineState) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(keylineState);
|
||||
int findLastNonAnchorKeylineIndex = findLastNonAnchorKeylineIndex(keylineState);
|
||||
if (!isLastFocalItemVisibleAtRightOfContainer(carousel, keylineState) && findLastNonAnchorKeylineIndex != -1) {
|
||||
int lastFocalKeylineIndex = findLastNonAnchorKeylineIndex - keylineState.getLastFocalKeylineIndex();
|
||||
float containerWidth = carousel.isHorizontal() ? carousel.getContainerWidth() : carousel.getContainerHeight();
|
||||
float f = keylineState.getFirstKeyline().locOffset - (keylineState.getFirstKeyline().maskedItemSize / 2.0f);
|
||||
float f2 = 0.0f;
|
||||
if (lastFocalKeylineIndex <= 0 && keylineState.getLastFocalKeyline().cutoff > 0.0f) {
|
||||
arrayList.add(shiftKeylinesAndCreateKeylineState(keylineState, f - keylineState.getLastFocalKeyline().cutoff, containerWidth));
|
||||
return arrayList;
|
||||
}
|
||||
int i = 0;
|
||||
while (i < lastFocalKeylineIndex) {
|
||||
KeylineState keylineState2 = (KeylineState) arrayList.get(arrayList.size() - 1);
|
||||
int i2 = findLastNonAnchorKeylineIndex - i;
|
||||
float f3 = f2 + keylineState.getKeylines().get(i2).cutoff;
|
||||
int i3 = i2 + 1;
|
||||
arrayList.add(moveKeylineAndCreateKeylineState(keylineState2, findLastNonAnchorKeylineIndex, i3 < keylineState.getKeylines().size() ? findLastIndexBeforeFirstFocalKeylineWithMask(keylineState2, keylineState.getKeylines().get(i3).mask) + 1 : 0, f - f3, keylineState.getFirstFocalKeylineIndex() + i + 1, keylineState.getLastFocalKeylineIndex() + i + 1, containerWidth));
|
||||
i++;
|
||||
f2 = f3;
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private static KeylineState shiftKeylinesAndCreateKeylineState(KeylineState keylineState, float f, float f2) {
|
||||
return moveKeylineAndCreateKeylineState(keylineState, 0, 0, f, keylineState.getFirstFocalKeylineIndex(), keylineState.getLastFocalKeylineIndex(), f2);
|
||||
}
|
||||
|
||||
private static KeylineState moveKeylineAndCreateKeylineState(KeylineState keylineState, int i, int i2, float f, int i3, int i4, float f2) {
|
||||
ArrayList arrayList = new ArrayList(keylineState.getKeylines());
|
||||
arrayList.add(i2, (KeylineState.Keyline) arrayList.remove(i));
|
||||
KeylineState.Builder builder = new KeylineState.Builder(keylineState.getItemSize(), f2);
|
||||
int i5 = 0;
|
||||
while (i5 < arrayList.size()) {
|
||||
KeylineState.Keyline keyline = (KeylineState.Keyline) arrayList.get(i5);
|
||||
builder.addKeyline(f + (keyline.maskedItemSize / 2.0f), keyline.mask, keyline.maskedItemSize, i5 >= i3 && i5 <= i4, keyline.isAnchor, keyline.cutoff);
|
||||
f += keyline.maskedItemSize;
|
||||
i5++;
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static int findFirstIndexAfterLastFocalKeylineWithMask(KeylineState keylineState, float f) {
|
||||
for (int lastFocalKeylineIndex = keylineState.getLastFocalKeylineIndex(); lastFocalKeylineIndex < keylineState.getKeylines().size(); lastFocalKeylineIndex++) {
|
||||
if (f == keylineState.getKeylines().get(lastFocalKeylineIndex).mask) {
|
||||
return lastFocalKeylineIndex;
|
||||
}
|
||||
}
|
||||
return keylineState.getKeylines().size() - 1;
|
||||
}
|
||||
|
||||
private static int findLastIndexBeforeFirstFocalKeylineWithMask(KeylineState keylineState, float f) {
|
||||
for (int firstFocalKeylineIndex = keylineState.getFirstFocalKeylineIndex() - 1; firstFocalKeylineIndex >= 0; firstFocalKeylineIndex--) {
|
||||
if (f == keylineState.getKeylines().get(firstFocalKeylineIndex).mask) {
|
||||
return firstFocalKeylineIndex;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int findFirstNonAnchorKeylineIndex(KeylineState keylineState) {
|
||||
for (int i = 0; i < keylineState.getKeylines().size(); i++) {
|
||||
if (!keylineState.getKeylines().get(i).isAnchor) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static int findLastNonAnchorKeylineIndex(KeylineState keylineState) {
|
||||
for (int size = keylineState.getKeylines().size() - 1; size >= 0; size--) {
|
||||
if (!keylineState.getKeylines().get(size).isAnchor) {
|
||||
return size;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Map<Integer, KeylineState> getKeylineStateForPositionMap(int i, int i2, int i3, boolean z) {
|
||||
float itemSize = this.defaultState.getItemSize();
|
||||
HashMap hashMap = new HashMap();
|
||||
int i4 = 0;
|
||||
int i5 = 0;
|
||||
while (true) {
|
||||
if (i4 >= i) {
|
||||
break;
|
||||
}
|
||||
int i6 = z ? (i - i4) - 1 : i4;
|
||||
if (i6 * itemSize * (z ? -1 : 1) > i3 - this.endShiftRange || i4 >= i - this.endStateSteps.size()) {
|
||||
Integer valueOf = Integer.valueOf(i6);
|
||||
List<KeylineState> list = this.endStateSteps;
|
||||
hashMap.put(valueOf, list.get(MathUtils.clamp(i5, 0, list.size() - 1)));
|
||||
i5++;
|
||||
}
|
||||
i4++;
|
||||
}
|
||||
int i7 = 0;
|
||||
for (int i8 = i - 1; i8 >= 0; i8--) {
|
||||
int i9 = z ? (i - i8) - 1 : i8;
|
||||
if (i9 * itemSize * (z ? -1 : 1) < i2 + this.startShiftRange || i8 < this.startStateSteps.size()) {
|
||||
Integer valueOf2 = Integer.valueOf(i9);
|
||||
List<KeylineState> list2 = this.startStateSteps;
|
||||
hashMap.put(valueOf2, list2.get(MathUtils.clamp(i7, 0, list2.size() - 1)));
|
||||
i7++;
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.graphics.RectF;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface Maskable {
|
||||
RectF getMaskRectF();
|
||||
|
||||
@Deprecated
|
||||
float getMaskXPercentage();
|
||||
|
||||
void setMaskRectF(RectF rectF);
|
||||
|
||||
@Deprecated
|
||||
void setMaskXPercentage(float f);
|
||||
|
||||
void setOnMaskChangedListener(OnMaskChangedListener onMaskChangedListener);
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.core.math.MathUtils;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.canvas.CanvasCompat;
|
||||
import com.google.android.material.shape.AbsoluteCornerSize;
|
||||
import com.google.android.material.shape.ClampedCornerSize;
|
||||
import com.google.android.material.shape.CornerSize;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.google.android.material.shape.Shapeable;
|
||||
import com.google.android.material.shape.ShapeableDelegate;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MaskableFrameLayout extends FrameLayout implements Maskable, Shapeable {
|
||||
private static final int NOT_SET = -1;
|
||||
private final RectF maskRect;
|
||||
private float maskXPercentage;
|
||||
private OnMaskChangedListener onMaskChangedListener;
|
||||
private Boolean savedForceCompatClippingEnabled;
|
||||
private ShapeAppearanceModel shapeAppearanceModel;
|
||||
private final ShapeableDelegate shapeableDelegate;
|
||||
|
||||
@Override // com.google.android.material.carousel.Maskable
|
||||
public RectF getMaskRectF() {
|
||||
return this.maskRect;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.Maskable
|
||||
@Deprecated
|
||||
public float getMaskXPercentage() {
|
||||
return this.maskXPercentage;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.Shapeable
|
||||
public ShapeAppearanceModel getShapeAppearanceModel() {
|
||||
return this.shapeAppearanceModel;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.Maskable
|
||||
public void setOnMaskChangedListener(OnMaskChangedListener onMaskChangedListener) {
|
||||
this.onMaskChangedListener = onMaskChangedListener;
|
||||
}
|
||||
|
||||
public MaskableFrameLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MaskableFrameLayout(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public MaskableFrameLayout(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.maskXPercentage = -1.0f;
|
||||
this.maskRect = new RectF();
|
||||
this.shapeableDelegate = ShapeableDelegate.create(this);
|
||||
this.savedForceCompatClippingEnabled = null;
|
||||
setShapeAppearanceModel(ShapeAppearanceModel.builder(context, attributeSet, i, 0, 0).build());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onSizeChanged(int i, int i2, int i3, int i4) {
|
||||
super.onSizeChanged(i, i2, i3, i4);
|
||||
if (this.maskXPercentage != -1.0f) {
|
||||
updateMaskRectForMaskXPercentage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void getFocusedRect(Rect rect) {
|
||||
rect.set((int) this.maskRect.left, (int) this.maskRect.top, (int) this.maskRect.right, (int) this.maskRect.bottom);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
Boolean bool = this.savedForceCompatClippingEnabled;
|
||||
if (bool != null) {
|
||||
this.shapeableDelegate.setForceCompatClippingEnabled(this, bool.booleanValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void onDetachedFromWindow() {
|
||||
this.savedForceCompatClippingEnabled = Boolean.valueOf(this.shapeableDelegate.isForceCompatClippingEnabled());
|
||||
this.shapeableDelegate.setForceCompatClippingEnabled(this, true);
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.Shapeable
|
||||
public void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) {
|
||||
ShapeAppearanceModel withTransformedCornerSizes = shapeAppearanceModel.withTransformedCornerSizes(new ShapeAppearanceModel.CornerSizeUnaryOperator() { // from class: com.google.android.material.carousel.MaskableFrameLayout$$ExternalSyntheticLambda1
|
||||
@Override // com.google.android.material.shape.ShapeAppearanceModel.CornerSizeUnaryOperator
|
||||
public final CornerSize apply(CornerSize cornerSize) {
|
||||
return MaskableFrameLayout.lambda$setShapeAppearanceModel$0(cornerSize);
|
||||
}
|
||||
});
|
||||
this.shapeAppearanceModel = withTransformedCornerSizes;
|
||||
this.shapeableDelegate.onShapeAppearanceChanged(this, withTransformedCornerSizes);
|
||||
}
|
||||
|
||||
static /* synthetic */ CornerSize lambda$setShapeAppearanceModel$0(CornerSize cornerSize) {
|
||||
return cornerSize instanceof AbsoluteCornerSize ? ClampedCornerSize.createFromCornerSize((AbsoluteCornerSize) cornerSize) : cornerSize;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.Maskable
|
||||
@Deprecated
|
||||
public void setMaskXPercentage(float f) {
|
||||
float clamp = MathUtils.clamp(f, 0.0f, 1.0f);
|
||||
if (this.maskXPercentage != clamp) {
|
||||
this.maskXPercentage = clamp;
|
||||
updateMaskRectForMaskXPercentage();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMaskRectForMaskXPercentage() {
|
||||
if (this.maskXPercentage != -1.0f) {
|
||||
float lerp = AnimationUtils.lerp(0.0f, getWidth() / 2.0f, 0.0f, 1.0f, this.maskXPercentage);
|
||||
setMaskRectF(new RectF(lerp, 0.0f, getWidth() - lerp, getHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.Maskable
|
||||
public void setMaskRectF(RectF rectF) {
|
||||
this.maskRect.set(rectF);
|
||||
onMaskChanged();
|
||||
}
|
||||
|
||||
private void onMaskChanged() {
|
||||
this.shapeableDelegate.onMaskChanged(this, this.maskRect);
|
||||
OnMaskChangedListener onMaskChangedListener = this.onMaskChangedListener;
|
||||
if (onMaskChangedListener != null) {
|
||||
onMaskChangedListener.onMaskChanged(this.maskRect);
|
||||
}
|
||||
}
|
||||
|
||||
public void setForceCompatClipping(boolean z) {
|
||||
this.shapeableDelegate.setForceCompatClippingEnabled(this, z);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
if (!this.maskRect.isEmpty() && motionEvent.getAction() == 0) {
|
||||
if (!this.maskRect.contains(motionEvent.getX(), motionEvent.getY())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
this.shapeableDelegate.maybeClip(canvas, new CanvasCompat.CanvasOperation() { // from class: com.google.android.material.carousel.MaskableFrameLayout$$ExternalSyntheticLambda0
|
||||
@Override // com.google.android.material.canvas.CanvasCompat.CanvasOperation
|
||||
public final void run(Canvas canvas2) {
|
||||
MaskableFrameLayout.this.m196x418c47c0(canvas2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* renamed from: lambda$dispatchDraw$1$com-google-android-material-carousel-MaskableFrameLayout, reason: not valid java name */
|
||||
/* synthetic */ void m196x418c47c0(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.core.math.MathUtils;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MultiBrowseCarouselStrategy extends CarouselStrategy {
|
||||
private int keylineCount = 0;
|
||||
private static final int[] SMALL_COUNTS = {1};
|
||||
private static final int[] MEDIUM_COUNTS = {1, 0};
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselStrategy
|
||||
KeylineState onFirstChildMeasuredWithMargins(Carousel carousel, View view) {
|
||||
float containerHeight = carousel.getContainerHeight();
|
||||
if (carousel.isHorizontal()) {
|
||||
containerHeight = carousel.getContainerWidth();
|
||||
}
|
||||
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
float f = layoutParams.topMargin + layoutParams.bottomMargin;
|
||||
float measuredHeight = view.getMeasuredHeight();
|
||||
if (carousel.isHorizontal()) {
|
||||
f = layoutParams.leftMargin + layoutParams.rightMargin;
|
||||
measuredHeight = view.getMeasuredWidth();
|
||||
}
|
||||
float f2 = f;
|
||||
float smallSizeMin = CarouselStrategyHelper.getSmallSizeMin(view.getContext()) + f2;
|
||||
float smallSizeMax = CarouselStrategyHelper.getSmallSizeMax(view.getContext()) + f2;
|
||||
float min = Math.min(measuredHeight + f2, containerHeight);
|
||||
float clamp = MathUtils.clamp((measuredHeight / 3.0f) + f2, CarouselStrategyHelper.getSmallSizeMin(view.getContext()) + f2, CarouselStrategyHelper.getSmallSizeMax(view.getContext()) + f2);
|
||||
float f3 = (min + clamp) / 2.0f;
|
||||
int[] iArr = SMALL_COUNTS;
|
||||
if (containerHeight < 2.0f * smallSizeMin) {
|
||||
iArr = new int[]{0};
|
||||
}
|
||||
int[] iArr2 = MEDIUM_COUNTS;
|
||||
if (carousel.getCarouselAlignment() == 1) {
|
||||
iArr = doubleCounts(iArr);
|
||||
iArr2 = doubleCounts(iArr2);
|
||||
}
|
||||
int[] iArr3 = iArr;
|
||||
int[] iArr4 = iArr2;
|
||||
int max = (int) Math.max(1.0d, Math.floor(((containerHeight - (CarouselStrategyHelper.maxValue(iArr4) * f3)) - (CarouselStrategyHelper.maxValue(iArr3) * smallSizeMax)) / min));
|
||||
int ceil = (int) Math.ceil(containerHeight / min);
|
||||
int i = (ceil - max) + 1;
|
||||
int[] iArr5 = new int[i];
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
iArr5[i2] = ceil - i2;
|
||||
}
|
||||
Arrangement findLowestCostArrangement = Arrangement.findLowestCostArrangement(containerHeight, clamp, smallSizeMin, smallSizeMax, iArr3, f3, iArr4, min, iArr5);
|
||||
this.keylineCount = findLowestCostArrangement.getItemCount();
|
||||
if (ensureArrangementFitsItemCount(findLowestCostArrangement, carousel.getItemCount())) {
|
||||
findLowestCostArrangement = Arrangement.findLowestCostArrangement(containerHeight, clamp, smallSizeMin, smallSizeMax, new int[]{findLowestCostArrangement.smallCount}, f3, new int[]{findLowestCostArrangement.mediumCount}, min, new int[]{findLowestCostArrangement.largeCount});
|
||||
}
|
||||
return CarouselStrategyHelper.createKeylineState(view.getContext(), f2, containerHeight, findLowestCostArrangement, carousel.getCarouselAlignment());
|
||||
}
|
||||
|
||||
boolean ensureArrangementFitsItemCount(Arrangement arrangement, int i) {
|
||||
int itemCount = arrangement.getItemCount() - i;
|
||||
boolean z = itemCount > 0 && (arrangement.smallCount > 0 || arrangement.mediumCount > 1);
|
||||
while (itemCount > 0) {
|
||||
if (arrangement.smallCount > 0) {
|
||||
arrangement.smallCount--;
|
||||
} else if (arrangement.mediumCount > 1) {
|
||||
arrangement.mediumCount--;
|
||||
}
|
||||
itemCount--;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselStrategy
|
||||
boolean shouldRefreshKeylineState(Carousel carousel, int i) {
|
||||
return (i < this.keylineCount && carousel.getItemCount() >= this.keylineCount) || (i >= this.keylineCount && carousel.getItemCount() < this.keylineCount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.graphics.RectF;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface OnMaskChangedListener {
|
||||
void onMaskChanged(RectF rectF);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.google.android.material.carousel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.carousel.KeylineState;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class UncontainedCarouselStrategy extends CarouselStrategy {
|
||||
private static final float MEDIUM_LARGE_ITEM_PERCENTAGE_THRESHOLD = 0.85f;
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselStrategy
|
||||
boolean isContained() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.carousel.CarouselStrategy
|
||||
KeylineState onFirstChildMeasuredWithMargins(Carousel carousel, View view) {
|
||||
float f;
|
||||
float containerWidth = carousel.isHorizontal() ? carousel.getContainerWidth() : carousel.getContainerHeight();
|
||||
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
float f2 = layoutParams.topMargin + layoutParams.bottomMargin;
|
||||
float measuredHeight = view.getMeasuredHeight();
|
||||
if (carousel.isHorizontal()) {
|
||||
float f3 = layoutParams.leftMargin + layoutParams.rightMargin;
|
||||
measuredHeight = view.getMeasuredWidth();
|
||||
f = f3;
|
||||
} else {
|
||||
f = f2;
|
||||
}
|
||||
float f4 = measuredHeight + f;
|
||||
float extraSmallSize = CarouselStrategyHelper.getExtraSmallSize(view.getContext()) + f;
|
||||
float extraSmallSize2 = CarouselStrategyHelper.getExtraSmallSize(view.getContext()) + f;
|
||||
int max = Math.max(1, (int) Math.floor(containerWidth / f4));
|
||||
float f5 = containerWidth - (max * f4);
|
||||
if (carousel.getCarouselAlignment() == 1) {
|
||||
float f6 = f5 / 2.0f;
|
||||
return createCenterAlignedKeylineState(containerWidth, f, f4, max, Math.max(Math.min(3.0f * f6, f4), CarouselStrategyHelper.getSmallSizeMin(view.getContext()) + f), extraSmallSize2, f6);
|
||||
}
|
||||
return createLeftAlignedKeylineState(view.getContext(), f, containerWidth, f4, max, calculateMediumChildSize(extraSmallSize, f4, f5), f5 > 0.0f ? 1 : 0, extraSmallSize2);
|
||||
}
|
||||
|
||||
private float calculateMediumChildSize(float f, float f2, float f3) {
|
||||
float max = Math.max(1.5f * f3, f);
|
||||
float f4 = MEDIUM_LARGE_ITEM_PERCENTAGE_THRESHOLD * f2;
|
||||
if (max > f4) {
|
||||
max = Math.max(f4, f3 * 1.2f);
|
||||
}
|
||||
return Math.min(f2, max);
|
||||
}
|
||||
|
||||
private KeylineState createCenterAlignedKeylineState(float f, float f2, float f3, int i, float f4, float f5, float f6) {
|
||||
float min = Math.min(f5, f3);
|
||||
float childMaskPercentage = getChildMaskPercentage(min, f3, f2);
|
||||
float childMaskPercentage2 = getChildMaskPercentage(f4, f3, f2);
|
||||
float f7 = f4 / 2.0f;
|
||||
float f8 = (f6 + 0.0f) - f7;
|
||||
float f9 = f8 + f7;
|
||||
float f10 = min / 2.0f;
|
||||
float f11 = (i * f3) + f9;
|
||||
KeylineState.Builder addKeylineRange = new KeylineState.Builder(f3, f).addAnchorKeyline((f8 - f7) - f10, childMaskPercentage, min).addKeyline(f8, childMaskPercentage2, f4, false).addKeylineRange((f3 / 2.0f) + f9, 0.0f, f3, i, true);
|
||||
addKeylineRange.addKeyline(f7 + f11, childMaskPercentage2, f4, false);
|
||||
addKeylineRange.addAnchorKeyline(f11 + f4 + f10, childMaskPercentage, min);
|
||||
return addKeylineRange.build();
|
||||
}
|
||||
|
||||
private KeylineState createLeftAlignedKeylineState(Context context, float f, float f2, float f3, int i, float f4, int i2, float f5) {
|
||||
float min = Math.min(f5, f3);
|
||||
float max = Math.max(min, 0.5f * f4);
|
||||
float childMaskPercentage = getChildMaskPercentage(max, f3, f);
|
||||
float childMaskPercentage2 = getChildMaskPercentage(min, f3, f);
|
||||
float childMaskPercentage3 = getChildMaskPercentage(f4, f3, f);
|
||||
float f6 = (i * f3) + 0.0f;
|
||||
KeylineState.Builder addKeylineRange = new KeylineState.Builder(f3, f2).addAnchorKeyline(0.0f - (max / 2.0f), childMaskPercentage, max).addKeylineRange(f3 / 2.0f, 0.0f, f3, i, true);
|
||||
if (i2 > 0) {
|
||||
float f7 = (f4 / 2.0f) + f6;
|
||||
f6 += f4;
|
||||
addKeylineRange.addKeyline(f7, childMaskPercentage3, f4, false);
|
||||
}
|
||||
addKeylineRange.addAnchorKeyline(f6 + (CarouselStrategyHelper.getExtraSmallSize(context) / 2.0f), childMaskPercentage2, min);
|
||||
return addKeylineRange.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.google.android.material.checkbox;
|
||||
|
||||
/* compiled from: D8$$SyntheticClass */
|
||||
/* loaded from: classes.dex */
|
||||
public final /* synthetic */ class MaterialCheckBox$$ExternalSyntheticLambda3 implements Runnable {
|
||||
public final /* synthetic */ MaterialCheckBox f$0;
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
this.f$0.m197xdf87d0bf();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,610 @@
|
||||
package com.google.android.material.checkbox;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.AnimatedStateListDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.autofill.AutofillManager;
|
||||
import android.widget.CompoundButton;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.appcompat.widget.AppCompatCheckBox;
|
||||
import androidx.appcompat.widget.TintTypedArray;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.widget.CompoundButtonCompat;
|
||||
import androidx.tracing.Trace$$ExternalSyntheticApiModelOutline0;
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.drawable.DrawableUtils;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import kotlin.io.path.PathTreeWalk$$ExternalSyntheticApiModelOutline0;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MaterialCheckBox extends AppCompatCheckBox {
|
||||
public static final int STATE_CHECKED = 1;
|
||||
public static final int STATE_INDETERMINATE = 2;
|
||||
public static final int STATE_UNCHECKED = 0;
|
||||
private boolean broadcasting;
|
||||
private Drawable buttonDrawable;
|
||||
private Drawable buttonIconDrawable;
|
||||
ColorStateList buttonIconTintList;
|
||||
private PorterDuff.Mode buttonIconTintMode;
|
||||
ColorStateList buttonTintList;
|
||||
private boolean centerIfNoTextEnabled;
|
||||
private int checkedState;
|
||||
private int[] currentStateChecked;
|
||||
private CharSequence customStateDescription;
|
||||
private CharSequence errorAccessibilityLabel;
|
||||
private boolean errorShown;
|
||||
private ColorStateList materialThemeColorsTintList;
|
||||
private CompoundButton.OnCheckedChangeListener onCheckedChangeListener;
|
||||
private final LinkedHashSet<OnCheckedStateChangedListener> onCheckedStateChangedListeners;
|
||||
private final LinkedHashSet<OnErrorChangedListener> onErrorChangedListeners;
|
||||
private final AnimatedVectorDrawableCompat transitionToUnchecked;
|
||||
private final Animatable2Compat.AnimationCallback transitionToUncheckedCallback;
|
||||
private boolean useMaterialThemeColors;
|
||||
private boolean usingMaterialButtonDrawable;
|
||||
private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_CompoundButton_CheckBox;
|
||||
private static final int[] INDETERMINATE_STATE_SET = {R.attr.state_indeterminate};
|
||||
private static final int[] ERROR_STATE_SET = {R.attr.state_error};
|
||||
private static final int[][] CHECKBOX_STATES = {new int[]{android.R.attr.state_enabled, R.attr.state_error}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, -16842912}, new int[]{-16842910, android.R.attr.state_checked}, new int[]{-16842910, -16842912}};
|
||||
private static final int FRAMEWORK_BUTTON_DRAWABLE_RES_ID = Resources.getSystem().getIdentifier("btn_check_material_anim", "drawable", "android");
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface CheckedState {
|
||||
}
|
||||
|
||||
public interface OnCheckedStateChangedListener {
|
||||
void onCheckedStateChangedListener(MaterialCheckBox materialCheckBox, int i);
|
||||
}
|
||||
|
||||
public interface OnErrorChangedListener {
|
||||
void onErrorChanged(MaterialCheckBox materialCheckBox, boolean z);
|
||||
}
|
||||
|
||||
private void updateIconTintIfNeeded() {
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton
|
||||
public Drawable getButtonDrawable() {
|
||||
return this.buttonDrawable;
|
||||
}
|
||||
|
||||
public Drawable getButtonIconDrawable() {
|
||||
return this.buttonIconDrawable;
|
||||
}
|
||||
|
||||
public ColorStateList getButtonIconTintList() {
|
||||
return this.buttonIconTintList;
|
||||
}
|
||||
|
||||
public PorterDuff.Mode getButtonIconTintMode() {
|
||||
return this.buttonIconTintMode;
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton
|
||||
public ColorStateList getButtonTintList() {
|
||||
return this.buttonTintList;
|
||||
}
|
||||
|
||||
public int getCheckedState() {
|
||||
return this.checkedState;
|
||||
}
|
||||
|
||||
public CharSequence getErrorAccessibilityLabel() {
|
||||
return this.errorAccessibilityLabel;
|
||||
}
|
||||
|
||||
public boolean isCenterIfNoTextEnabled() {
|
||||
return this.centerIfNoTextEnabled;
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton, android.widget.Checkable
|
||||
public boolean isChecked() {
|
||||
return this.checkedState == 1;
|
||||
}
|
||||
|
||||
public boolean isErrorShown() {
|
||||
return this.errorShown;
|
||||
}
|
||||
|
||||
public boolean isUseMaterialThemeColors() {
|
||||
return this.useMaterialThemeColors;
|
||||
}
|
||||
|
||||
public void setCenterIfNoTextEnabled(boolean z) {
|
||||
this.centerIfNoTextEnabled = z;
|
||||
}
|
||||
|
||||
public void setErrorAccessibilityLabel(CharSequence charSequence) {
|
||||
this.errorAccessibilityLabel = charSequence;
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton
|
||||
public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
|
||||
this.onCheckedChangeListener = onCheckedChangeListener;
|
||||
}
|
||||
|
||||
public MaterialCheckBox(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MaterialCheckBox(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.checkboxStyle);
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public MaterialCheckBox(android.content.Context r9, android.util.AttributeSet r10, int r11) {
|
||||
/*
|
||||
r8 = this;
|
||||
int r4 = com.google.android.material.checkbox.MaterialCheckBox.DEF_STYLE_RES
|
||||
android.content.Context r9 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r9, r10, r11, r4)
|
||||
r8.<init>(r9, r10, r11)
|
||||
java.util.LinkedHashSet r9 = new java.util.LinkedHashSet
|
||||
r9.<init>()
|
||||
r8.onErrorChangedListeners = r9
|
||||
java.util.LinkedHashSet r9 = new java.util.LinkedHashSet
|
||||
r9.<init>()
|
||||
r8.onCheckedStateChangedListeners = r9
|
||||
android.content.Context r9 = r8.getContext()
|
||||
int r0 = com.google.android.material.R.drawable.mtrl_checkbox_button_checked_unchecked
|
||||
androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat r9 = androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat.create(r9, r0)
|
||||
r8.transitionToUnchecked = r9
|
||||
com.google.android.material.checkbox.MaterialCheckBox$1 r9 = new com.google.android.material.checkbox.MaterialCheckBox$1
|
||||
r9.<init>()
|
||||
r8.transitionToUncheckedCallback = r9
|
||||
android.content.Context r9 = r8.getContext()
|
||||
android.graphics.drawable.Drawable r0 = androidx.core.widget.CompoundButtonCompat.getButtonDrawable(r8)
|
||||
r8.buttonDrawable = r0
|
||||
android.content.res.ColorStateList r0 = r8.getSuperButtonTintList()
|
||||
r8.buttonTintList = r0
|
||||
r6 = 0
|
||||
r8.setSupportButtonTintList(r6)
|
||||
int[] r2 = com.google.android.material.R.styleable.MaterialCheckBox
|
||||
r7 = 0
|
||||
int[] r5 = new int[r7]
|
||||
r0 = r9
|
||||
r1 = r10
|
||||
r3 = r11
|
||||
androidx.appcompat.widget.TintTypedArray r10 = com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes(r0, r1, r2, r3, r4, r5)
|
||||
int r11 = com.google.android.material.R.styleable.MaterialCheckBox_buttonIcon
|
||||
android.graphics.drawable.Drawable r11 = r10.getDrawable(r11)
|
||||
r8.buttonIconDrawable = r11
|
||||
android.graphics.drawable.Drawable r11 = r8.buttonDrawable
|
||||
r0 = 1
|
||||
if (r11 == 0) goto L7c
|
||||
boolean r11 = com.google.android.material.internal.ThemeEnforcement.isMaterial3Theme(r9)
|
||||
if (r11 == 0) goto L7c
|
||||
boolean r11 = r8.isButtonDrawableLegacy(r10)
|
||||
if (r11 == 0) goto L7c
|
||||
super.setButtonDrawable(r6)
|
||||
int r11 = com.google.android.material.R.drawable.mtrl_checkbox_button
|
||||
android.graphics.drawable.Drawable r11 = androidx.appcompat.content.res.AppCompatResources.getDrawable(r9, r11)
|
||||
r8.buttonDrawable = r11
|
||||
r8.usingMaterialButtonDrawable = r0
|
||||
android.graphics.drawable.Drawable r11 = r8.buttonIconDrawable
|
||||
if (r11 != 0) goto L7c
|
||||
int r11 = com.google.android.material.R.drawable.mtrl_checkbox_button_icon
|
||||
android.graphics.drawable.Drawable r11 = androidx.appcompat.content.res.AppCompatResources.getDrawable(r9, r11)
|
||||
r8.buttonIconDrawable = r11
|
||||
L7c:
|
||||
int r11 = com.google.android.material.R.styleable.MaterialCheckBox_buttonIconTint
|
||||
android.content.res.ColorStateList r9 = com.google.android.material.resources.MaterialResources.getColorStateList(r9, r10, r11)
|
||||
r8.buttonIconTintList = r9
|
||||
int r9 = com.google.android.material.R.styleable.MaterialCheckBox_buttonIconTintMode
|
||||
r11 = -1
|
||||
int r9 = r10.getInt(r9, r11)
|
||||
android.graphics.PorterDuff$Mode r11 = android.graphics.PorterDuff.Mode.SRC_IN
|
||||
android.graphics.PorterDuff$Mode r9 = com.google.android.material.internal.ViewUtils.parseTintMode(r9, r11)
|
||||
r8.buttonIconTintMode = r9
|
||||
int r9 = com.google.android.material.R.styleable.MaterialCheckBox_useMaterialThemeColors
|
||||
boolean r9 = r10.getBoolean(r9, r7)
|
||||
r8.useMaterialThemeColors = r9
|
||||
int r9 = com.google.android.material.R.styleable.MaterialCheckBox_centerIfNoTextEnabled
|
||||
boolean r9 = r10.getBoolean(r9, r0)
|
||||
r8.centerIfNoTextEnabled = r9
|
||||
int r9 = com.google.android.material.R.styleable.MaterialCheckBox_errorShown
|
||||
boolean r9 = r10.getBoolean(r9, r7)
|
||||
r8.errorShown = r9
|
||||
int r9 = com.google.android.material.R.styleable.MaterialCheckBox_errorAccessibilityLabel
|
||||
java.lang.CharSequence r9 = r10.getText(r9)
|
||||
r8.errorAccessibilityLabel = r9
|
||||
int r9 = com.google.android.material.R.styleable.MaterialCheckBox_checkedState
|
||||
boolean r9 = r10.hasValue(r9)
|
||||
if (r9 == 0) goto Lc4
|
||||
int r9 = com.google.android.material.R.styleable.MaterialCheckBox_checkedState
|
||||
int r9 = r10.getInt(r9, r7)
|
||||
r8.setCheckedState(r9)
|
||||
Lc4:
|
||||
r10.recycle()
|
||||
r8.refreshButtonDrawable()
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.checkbox.MaterialCheckBox.<init>(android.content.Context, android.util.AttributeSet, int):void");
|
||||
}
|
||||
|
||||
/* renamed from: lambda$new$0$com-google-android-material-checkbox-MaterialCheckBox, reason: not valid java name */
|
||||
/* synthetic */ void m197xdf87d0bf() {
|
||||
this.buttonIconDrawable.jumpToCurrentState();
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
Drawable buttonDrawable;
|
||||
if (this.centerIfNoTextEnabled && TextUtils.isEmpty(getText()) && (buttonDrawable = CompoundButtonCompat.getButtonDrawable(this)) != null) {
|
||||
int width = ((getWidth() - buttonDrawable.getIntrinsicWidth()) / 2) * (ViewUtils.isLayoutRtl(this) ? -1 : 1);
|
||||
int save = canvas.save();
|
||||
canvas.translate(width, 0.0f);
|
||||
super.onDraw(canvas);
|
||||
canvas.restoreToCount(save);
|
||||
if (getBackground() != null) {
|
||||
Rect bounds = buttonDrawable.getBounds();
|
||||
DrawableCompat.setHotspotBounds(getBackground(), bounds.left + width, bounds.top, bounds.right + width, bounds.bottom);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (this.useMaterialThemeColors && this.buttonTintList == null && this.buttonIconTintList == null) {
|
||||
setUseMaterialThemeColors(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
|
||||
protected int[] onCreateDrawableState(int i) {
|
||||
int[] onCreateDrawableState = super.onCreateDrawableState(i + 2);
|
||||
if (getCheckedState() == 2) {
|
||||
mergeDrawableStates(onCreateDrawableState, INDETERMINATE_STATE_SET);
|
||||
}
|
||||
if (isErrorShown()) {
|
||||
mergeDrawableStates(onCreateDrawableState, ERROR_STATE_SET);
|
||||
}
|
||||
this.currentStateChecked = DrawableUtils.getCheckedState(onCreateDrawableState);
|
||||
updateIconTintIfNeeded();
|
||||
return onCreateDrawableState;
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
public void setEnabled(boolean z) {
|
||||
super.setEnabled(z);
|
||||
updateIconTintIfNeeded();
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton, android.widget.Checkable
|
||||
public void setChecked(boolean z) {
|
||||
setCheckedState(z ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton, android.widget.Checkable
|
||||
public void toggle() {
|
||||
setChecked(!isChecked());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||||
if (accessibilityNodeInfo != null && isErrorShown()) {
|
||||
accessibilityNodeInfo.setText(((Object) accessibilityNodeInfo.getText()) + ", " + ((Object) this.errorAccessibilityLabel));
|
||||
}
|
||||
}
|
||||
|
||||
public void setCheckedState(int i) {
|
||||
Object systemService;
|
||||
CompoundButton.OnCheckedChangeListener onCheckedChangeListener;
|
||||
if (this.checkedState != i) {
|
||||
this.checkedState = i;
|
||||
super.setChecked(i == 1);
|
||||
refreshDrawableState();
|
||||
setDefaultStateDescription();
|
||||
if (this.broadcasting) {
|
||||
return;
|
||||
}
|
||||
this.broadcasting = true;
|
||||
LinkedHashSet<OnCheckedStateChangedListener> linkedHashSet = this.onCheckedStateChangedListeners;
|
||||
if (linkedHashSet != null) {
|
||||
Iterator<OnCheckedStateChangedListener> it = linkedHashSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onCheckedStateChangedListener(this, this.checkedState);
|
||||
}
|
||||
}
|
||||
if (this.checkedState != 2 && (onCheckedChangeListener = this.onCheckedChangeListener) != null) {
|
||||
onCheckedChangeListener.onCheckedChanged(this, isChecked());
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
systemService = getContext().getSystemService((Class<Object>) Trace$$ExternalSyntheticApiModelOutline0.m177m());
|
||||
AutofillManager m1512m = PathTreeWalk$$ExternalSyntheticApiModelOutline0.m1512m(systemService);
|
||||
if (m1512m != null) {
|
||||
m1512m.notifyValueChanged(this);
|
||||
}
|
||||
}
|
||||
this.broadcasting = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void addOnCheckedStateChangedListener(OnCheckedStateChangedListener onCheckedStateChangedListener) {
|
||||
this.onCheckedStateChangedListeners.add(onCheckedStateChangedListener);
|
||||
}
|
||||
|
||||
public void removeOnCheckedStateChangedListener(OnCheckedStateChangedListener onCheckedStateChangedListener) {
|
||||
this.onCheckedStateChangedListeners.remove(onCheckedStateChangedListener);
|
||||
}
|
||||
|
||||
public void clearOnCheckedStateChangedListeners() {
|
||||
this.onCheckedStateChangedListeners.clear();
|
||||
}
|
||||
|
||||
public void setErrorShown(boolean z) {
|
||||
if (this.errorShown == z) {
|
||||
return;
|
||||
}
|
||||
this.errorShown = z;
|
||||
refreshDrawableState();
|
||||
Iterator<OnErrorChangedListener> it = this.onErrorChangedListeners.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onErrorChanged(this, this.errorShown);
|
||||
}
|
||||
}
|
||||
|
||||
public void setErrorAccessibilityLabelResource(int i) {
|
||||
setErrorAccessibilityLabel(i != 0 ? getResources().getText(i) : null);
|
||||
}
|
||||
|
||||
public void addOnErrorChangedListener(OnErrorChangedListener onErrorChangedListener) {
|
||||
this.onErrorChangedListeners.add(onErrorChangedListener);
|
||||
}
|
||||
|
||||
public void removeOnErrorChangedListener(OnErrorChangedListener onErrorChangedListener) {
|
||||
this.onErrorChangedListeners.remove(onErrorChangedListener);
|
||||
}
|
||||
|
||||
public void clearOnErrorChangedListeners() {
|
||||
this.onErrorChangedListeners.clear();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatCheckBox, android.widget.CompoundButton
|
||||
public void setButtonDrawable(int i) {
|
||||
setButtonDrawable(AppCompatResources.getDrawable(getContext(), i));
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatCheckBox, android.widget.CompoundButton
|
||||
public void setButtonDrawable(Drawable drawable) {
|
||||
this.buttonDrawable = drawable;
|
||||
this.usingMaterialButtonDrawable = false;
|
||||
refreshButtonDrawable();
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton
|
||||
public void setButtonTintList(ColorStateList colorStateList) {
|
||||
if (this.buttonTintList == colorStateList) {
|
||||
return;
|
||||
}
|
||||
this.buttonTintList = colorStateList;
|
||||
refreshButtonDrawable();
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton
|
||||
public void setButtonTintMode(PorterDuff.Mode mode) {
|
||||
setSupportButtonTintMode(mode);
|
||||
refreshButtonDrawable();
|
||||
}
|
||||
|
||||
public void setButtonIconDrawableResource(int i) {
|
||||
setButtonIconDrawable(AppCompatResources.getDrawable(getContext(), i));
|
||||
}
|
||||
|
||||
public void setButtonIconDrawable(Drawable drawable) {
|
||||
this.buttonIconDrawable = drawable;
|
||||
refreshButtonDrawable();
|
||||
}
|
||||
|
||||
public void setButtonIconTintList(ColorStateList colorStateList) {
|
||||
if (this.buttonIconTintList == colorStateList) {
|
||||
return;
|
||||
}
|
||||
this.buttonIconTintList = colorStateList;
|
||||
refreshButtonDrawable();
|
||||
}
|
||||
|
||||
public void setButtonIconTintMode(PorterDuff.Mode mode) {
|
||||
if (this.buttonIconTintMode == mode) {
|
||||
return;
|
||||
}
|
||||
this.buttonIconTintMode = mode;
|
||||
refreshButtonDrawable();
|
||||
}
|
||||
|
||||
public void setUseMaterialThemeColors(boolean z) {
|
||||
this.useMaterialThemeColors = z;
|
||||
if (z) {
|
||||
CompoundButtonCompat.setButtonTintList(this, getMaterialThemeColorsTintList());
|
||||
} else {
|
||||
CompoundButtonCompat.setButtonTintList(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshButtonDrawable() {
|
||||
this.buttonDrawable = DrawableUtils.createTintableMutatedDrawableIfNeeded(this.buttonDrawable, this.buttonTintList, CompoundButtonCompat.getButtonTintMode(this));
|
||||
this.buttonIconDrawable = DrawableUtils.createTintableMutatedDrawableIfNeeded(this.buttonIconDrawable, this.buttonIconTintList, this.buttonIconTintMode);
|
||||
setUpDefaultButtonDrawableAnimationIfNeeded();
|
||||
updateButtonTints();
|
||||
super.setButtonDrawable(DrawableUtils.compositeTwoLayeredDrawable(this.buttonDrawable, this.buttonIconDrawable));
|
||||
refreshDrawableState();
|
||||
}
|
||||
|
||||
private void setUpDefaultButtonDrawableAnimationIfNeeded() {
|
||||
if (this.usingMaterialButtonDrawable) {
|
||||
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = this.transitionToUnchecked;
|
||||
if (animatedVectorDrawableCompat != null) {
|
||||
animatedVectorDrawableCompat.unregisterAnimationCallback(this.transitionToUncheckedCallback);
|
||||
this.transitionToUnchecked.registerAnimationCallback(this.transitionToUncheckedCallback);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
Drawable drawable = this.buttonDrawable;
|
||||
if (!(drawable instanceof AnimatedStateListDrawable) || this.transitionToUnchecked == null) {
|
||||
return;
|
||||
}
|
||||
((AnimatedStateListDrawable) drawable).addTransition(R.id.checked, R.id.unchecked, this.transitionToUnchecked, false);
|
||||
((AnimatedStateListDrawable) this.buttonDrawable).addTransition(R.id.indeterminate, R.id.unchecked, this.transitionToUnchecked, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateButtonTints() {
|
||||
ColorStateList colorStateList;
|
||||
ColorStateList colorStateList2;
|
||||
Drawable drawable = this.buttonDrawable;
|
||||
if (drawable != null && (colorStateList2 = this.buttonTintList) != null) {
|
||||
DrawableCompat.setTintList(drawable, colorStateList2);
|
||||
}
|
||||
Drawable drawable2 = this.buttonIconDrawable;
|
||||
if (drawable2 == null || (colorStateList = this.buttonIconTintList) == null) {
|
||||
return;
|
||||
}
|
||||
DrawableCompat.setTintList(drawable2, colorStateList);
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton, android.view.View
|
||||
public void setStateDescription(CharSequence charSequence) {
|
||||
this.customStateDescription = charSequence;
|
||||
if (charSequence == null) {
|
||||
setDefaultStateDescription();
|
||||
} else {
|
||||
super.setStateDescription(charSequence);
|
||||
}
|
||||
}
|
||||
|
||||
private void setDefaultStateDescription() {
|
||||
if (Build.VERSION.SDK_INT < 30 || this.customStateDescription != null) {
|
||||
return;
|
||||
}
|
||||
super.setStateDescription(getButtonStateDescription());
|
||||
}
|
||||
|
||||
private String getButtonStateDescription() {
|
||||
int i = this.checkedState;
|
||||
if (i == 1) {
|
||||
return getResources().getString(R.string.mtrl_checkbox_state_description_checked);
|
||||
}
|
||||
if (i == 0) {
|
||||
return getResources().getString(R.string.mtrl_checkbox_state_description_unchecked);
|
||||
}
|
||||
return getResources().getString(R.string.mtrl_checkbox_state_description_indeterminate);
|
||||
}
|
||||
|
||||
private ColorStateList getSuperButtonTintList() {
|
||||
ColorStateList colorStateList = this.buttonTintList;
|
||||
if (colorStateList != null) {
|
||||
return colorStateList;
|
||||
}
|
||||
if (super.getButtonTintList() != null) {
|
||||
return super.getButtonTintList();
|
||||
}
|
||||
return getSupportButtonTintList();
|
||||
}
|
||||
|
||||
private boolean isButtonDrawableLegacy(TintTypedArray tintTypedArray) {
|
||||
return tintTypedArray.getResourceId(R.styleable.MaterialCheckBox_android_button, 0) == FRAMEWORK_BUTTON_DRAWABLE_RES_ID && tintTypedArray.getResourceId(R.styleable.MaterialCheckBox_buttonCompat, 0) == 0;
|
||||
}
|
||||
|
||||
private ColorStateList getMaterialThemeColorsTintList() {
|
||||
if (this.materialThemeColorsTintList == null) {
|
||||
int[][] iArr = CHECKBOX_STATES;
|
||||
int[] iArr2 = new int[iArr.length];
|
||||
int color = MaterialColors.getColor(this, R.attr.colorControlActivated);
|
||||
int color2 = MaterialColors.getColor(this, R.attr.colorError);
|
||||
int color3 = MaterialColors.getColor(this, R.attr.colorSurface);
|
||||
int color4 = MaterialColors.getColor(this, R.attr.colorOnSurface);
|
||||
iArr2[0] = MaterialColors.layer(color3, color2, 1.0f);
|
||||
iArr2[1] = MaterialColors.layer(color3, color, 1.0f);
|
||||
iArr2[2] = MaterialColors.layer(color3, color4, 0.54f);
|
||||
iArr2[3] = MaterialColors.layer(color3, color4, 0.38f);
|
||||
iArr2[4] = MaterialColors.layer(color3, color4, 0.38f);
|
||||
this.materialThemeColorsTintList = new ColorStateList(iArr, iArr2);
|
||||
}
|
||||
return this.materialThemeColorsTintList;
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
|
||||
public Parcelable onSaveInstanceState() {
|
||||
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
||||
savedState.checkedState = getCheckedState();
|
||||
return savedState;
|
||||
}
|
||||
|
||||
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
|
||||
public void onRestoreInstanceState(Parcelable parcelable) {
|
||||
if (!(parcelable instanceof SavedState)) {
|
||||
super.onRestoreInstanceState(parcelable);
|
||||
return;
|
||||
}
|
||||
SavedState savedState = (SavedState) parcelable;
|
||||
super.onRestoreInstanceState(savedState.getSuperState());
|
||||
setCheckedState(savedState.checkedState);
|
||||
}
|
||||
|
||||
static class SavedState extends View.BaseSavedState {
|
||||
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() { // from class: com.google.android.material.checkbox.MaterialCheckBox.SavedState.1
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public SavedState createFromParcel(Parcel parcel) {
|
||||
return new SavedState(parcel);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public SavedState[] newArray(int i) {
|
||||
return new SavedState[i];
|
||||
}
|
||||
};
|
||||
int checkedState;
|
||||
|
||||
private String getCheckedStateString() {
|
||||
int i = this.checkedState;
|
||||
return i != 1 ? i != 2 ? "unchecked" : "indeterminate" : "checked";
|
||||
}
|
||||
|
||||
SavedState(Parcelable parcelable) {
|
||||
super(parcelable);
|
||||
}
|
||||
|
||||
private SavedState(Parcel parcel) {
|
||||
super(parcel);
|
||||
this.checkedState = ((Integer) parcel.readValue(getClass().getClassLoader())).intValue();
|
||||
}
|
||||
|
||||
@Override // android.view.View.BaseSavedState, android.view.AbsSavedState, android.os.Parcelable
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
super.writeToParcel(parcel, i);
|
||||
parcel.writeValue(Integer.valueOf(this.checkedState));
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "MaterialCheckBox.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " CheckedState=" + getCheckedStateString() + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
1730
02-Easy5/E5/sources/com/google/android/material/chip/Chip.java
Normal file
1730
02-Easy5/E5/sources/com/google/android/material/chip/Chip.java
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,358 @@
|
||||
package com.google.android.material.chip;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.internal.CheckableGroup;
|
||||
import com.google.android.material.internal.FlowLayout;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ChipGroup extends FlowLayout {
|
||||
private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_ChipGroup;
|
||||
private final CheckableGroup<Chip> checkableGroup;
|
||||
private int chipSpacingHorizontal;
|
||||
private int chipSpacingVertical;
|
||||
private final int defaultCheckedId;
|
||||
private OnCheckedStateChangeListener onCheckedStateChangeListener;
|
||||
private final PassThroughHierarchyChangeListener passThroughListener;
|
||||
|
||||
@Deprecated
|
||||
public interface OnCheckedChangeListener {
|
||||
void onCheckedChanged(ChipGroup chipGroup, int i);
|
||||
}
|
||||
|
||||
public interface OnCheckedStateChangeListener {
|
||||
void onCheckedChanged(ChipGroup chipGroup, List<Integer> list);
|
||||
}
|
||||
|
||||
public int getChipSpacingHorizontal() {
|
||||
return this.chipSpacingHorizontal;
|
||||
}
|
||||
|
||||
public int getChipSpacingVertical() {
|
||||
return this.chipSpacingVertical;
|
||||
}
|
||||
|
||||
public void setOnCheckedStateChangeListener(OnCheckedStateChangeListener onCheckedStateChangeListener) {
|
||||
this.onCheckedStateChangeListener = onCheckedStateChangeListener;
|
||||
}
|
||||
|
||||
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
|
||||
public LayoutParams(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
|
||||
super(layoutParams);
|
||||
}
|
||||
|
||||
public LayoutParams(int i, int i2) {
|
||||
super(i, i2);
|
||||
}
|
||||
|
||||
public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) {
|
||||
super(marginLayoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
public ChipGroup(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ChipGroup(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.chipGroupStyle);
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public ChipGroup(android.content.Context r9, android.util.AttributeSet r10, int r11) {
|
||||
/*
|
||||
r8 = this;
|
||||
int r4 = com.google.android.material.chip.ChipGroup.DEF_STYLE_RES
|
||||
android.content.Context r9 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r9, r10, r11, r4)
|
||||
r8.<init>(r9, r10, r11)
|
||||
com.google.android.material.internal.CheckableGroup r9 = new com.google.android.material.internal.CheckableGroup
|
||||
r9.<init>()
|
||||
r8.checkableGroup = r9
|
||||
com.google.android.material.chip.ChipGroup$PassThroughHierarchyChangeListener r6 = new com.google.android.material.chip.ChipGroup$PassThroughHierarchyChangeListener
|
||||
r0 = 0
|
||||
r6.<init>()
|
||||
r8.passThroughListener = r6
|
||||
android.content.Context r0 = r8.getContext()
|
||||
int[] r2 = com.google.android.material.R.styleable.ChipGroup
|
||||
r7 = 0
|
||||
int[] r5 = new int[r7]
|
||||
r1 = r10
|
||||
r3 = r11
|
||||
android.content.res.TypedArray r10 = com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(r0, r1, r2, r3, r4, r5)
|
||||
int r11 = com.google.android.material.R.styleable.ChipGroup_chipSpacing
|
||||
int r11 = r10.getDimensionPixelOffset(r11, r7)
|
||||
int r0 = com.google.android.material.R.styleable.ChipGroup_chipSpacingHorizontal
|
||||
int r0 = r10.getDimensionPixelOffset(r0, r11)
|
||||
r8.setChipSpacingHorizontal(r0)
|
||||
int r0 = com.google.android.material.R.styleable.ChipGroup_chipSpacingVertical
|
||||
int r11 = r10.getDimensionPixelOffset(r0, r11)
|
||||
r8.setChipSpacingVertical(r11)
|
||||
int r11 = com.google.android.material.R.styleable.ChipGroup_singleLine
|
||||
boolean r11 = r10.getBoolean(r11, r7)
|
||||
r8.setSingleLine(r11)
|
||||
int r11 = com.google.android.material.R.styleable.ChipGroup_singleSelection
|
||||
boolean r11 = r10.getBoolean(r11, r7)
|
||||
r8.setSingleSelection(r11)
|
||||
int r11 = com.google.android.material.R.styleable.ChipGroup_selectionRequired
|
||||
boolean r11 = r10.getBoolean(r11, r7)
|
||||
r8.setSelectionRequired(r11)
|
||||
int r11 = com.google.android.material.R.styleable.ChipGroup_checkedChip
|
||||
r0 = -1
|
||||
int r11 = r10.getResourceId(r11, r0)
|
||||
r8.defaultCheckedId = r11
|
||||
r10.recycle()
|
||||
com.google.android.material.chip.ChipGroup$1 r10 = new com.google.android.material.chip.ChipGroup$1
|
||||
r10.<init>()
|
||||
r9.setOnCheckedStateChangeListener(r10)
|
||||
super.setOnHierarchyChangeListener(r6)
|
||||
r9 = 1
|
||||
androidx.core.view.ViewCompat.setImportantForAccessibility(r8, r9)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.chip.ChipGroup.<init>(android.content.Context, android.util.AttributeSet, int):void");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||||
AccessibilityNodeInfoCompat.wrap(accessibilityNodeInfo).setCollectionInfo(AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(getRowCount(), isSingleLine() ? getVisibleChipCount() : -1, false, isSingleSelection() ? 1 : 2));
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
||||
return new LayoutParams(getContext(), attributeSet);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
||||
return new LayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
||||
return new LayoutParams(-2, -2);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
||||
return super.checkLayoutParams(layoutParams) && (layoutParams instanceof LayoutParams);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
public void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener) {
|
||||
this.passThroughListener.onHierarchyChangeListener = onHierarchyChangeListener;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
int i = this.defaultCheckedId;
|
||||
if (i != -1) {
|
||||
this.checkableGroup.check(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDividerDrawableHorizontal(Drawable drawable) {
|
||||
throw new UnsupportedOperationException("Changing divider drawables have no effect. ChipGroup do not use divider drawables as spacing.");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDividerDrawableVertical(Drawable drawable) {
|
||||
throw new UnsupportedOperationException("Changing divider drawables have no effect. ChipGroup do not use divider drawables as spacing.");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setShowDividerHorizontal(int i) {
|
||||
throw new UnsupportedOperationException("Changing divider modes has no effect. ChipGroup do not use divider drawables as spacing.");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setShowDividerVertical(int i) {
|
||||
throw new UnsupportedOperationException("Changing divider modes has no effect. ChipGroup do not use divider drawables as spacing.");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setFlexWrap(int i) {
|
||||
throw new UnsupportedOperationException("Changing flex wrap not allowed. ChipGroup exposes a singleLine attribute instead.");
|
||||
}
|
||||
|
||||
public void check(int i) {
|
||||
this.checkableGroup.check(i);
|
||||
}
|
||||
|
||||
public int getCheckedChipId() {
|
||||
return this.checkableGroup.getSingleCheckedId();
|
||||
}
|
||||
|
||||
public List<Integer> getCheckedChipIds() {
|
||||
return this.checkableGroup.getCheckedIdsSortedByChildOrder(this);
|
||||
}
|
||||
|
||||
public void clearCheck() {
|
||||
this.checkableGroup.clearCheck();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setOnCheckedChangeListener(final OnCheckedChangeListener onCheckedChangeListener) {
|
||||
if (onCheckedChangeListener == null) {
|
||||
setOnCheckedStateChangeListener(null);
|
||||
} else {
|
||||
setOnCheckedStateChangeListener(new OnCheckedStateChangeListener() { // from class: com.google.android.material.chip.ChipGroup.2
|
||||
@Override // com.google.android.material.chip.ChipGroup.OnCheckedStateChangeListener
|
||||
public void onCheckedChanged(ChipGroup chipGroup, List<Integer> list) {
|
||||
if (ChipGroup.this.checkableGroup.isSingleSelection()) {
|
||||
onCheckedChangeListener.onCheckedChanged(chipGroup, ChipGroup.this.getCheckedChipId());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private int getVisibleChipCount() {
|
||||
int i = 0;
|
||||
for (int i2 = 0; i2 < getChildCount(); i2++) {
|
||||
if ((getChildAt(i2) instanceof Chip) && isChildVisible(i2)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int getIndexOfChip(View view) {
|
||||
if (!(view instanceof Chip)) {
|
||||
return -1;
|
||||
}
|
||||
int i = 0;
|
||||
for (int i2 = 0; i2 < getChildCount(); i2++) {
|
||||
View childAt = getChildAt(i2);
|
||||
if ((childAt instanceof Chip) && isChildVisible(i2)) {
|
||||
if (((Chip) childAt) == view) {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean isChildVisible(int i) {
|
||||
return getChildAt(i).getVisibility() == 0;
|
||||
}
|
||||
|
||||
public void setChipSpacing(int i) {
|
||||
setChipSpacingHorizontal(i);
|
||||
setChipSpacingVertical(i);
|
||||
}
|
||||
|
||||
public void setChipSpacingResource(int i) {
|
||||
setChipSpacing(getResources().getDimensionPixelOffset(i));
|
||||
}
|
||||
|
||||
public void setChipSpacingHorizontal(int i) {
|
||||
if (this.chipSpacingHorizontal != i) {
|
||||
this.chipSpacingHorizontal = i;
|
||||
setItemSpacing(i);
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public void setChipSpacingHorizontalResource(int i) {
|
||||
setChipSpacingHorizontal(getResources().getDimensionPixelOffset(i));
|
||||
}
|
||||
|
||||
public void setChipSpacingVertical(int i) {
|
||||
if (this.chipSpacingVertical != i) {
|
||||
this.chipSpacingVertical = i;
|
||||
setLineSpacing(i);
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public void setChipSpacingVerticalResource(int i) {
|
||||
setChipSpacingVertical(getResources().getDimensionPixelOffset(i));
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.internal.FlowLayout
|
||||
public boolean isSingleLine() {
|
||||
return super.isSingleLine();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.internal.FlowLayout
|
||||
public void setSingleLine(boolean z) {
|
||||
super.setSingleLine(z);
|
||||
}
|
||||
|
||||
public void setSingleLine(int i) {
|
||||
setSingleLine(getResources().getBoolean(i));
|
||||
}
|
||||
|
||||
public boolean isSingleSelection() {
|
||||
return this.checkableGroup.isSingleSelection();
|
||||
}
|
||||
|
||||
public void setSingleSelection(boolean z) {
|
||||
this.checkableGroup.setSingleSelection(z);
|
||||
}
|
||||
|
||||
public void setSingleSelection(int i) {
|
||||
setSingleSelection(getResources().getBoolean(i));
|
||||
}
|
||||
|
||||
public void setSelectionRequired(boolean z) {
|
||||
this.checkableGroup.setSelectionRequired(z);
|
||||
}
|
||||
|
||||
public boolean isSelectionRequired() {
|
||||
return this.checkableGroup.isSelectionRequired();
|
||||
}
|
||||
|
||||
private class PassThroughHierarchyChangeListener implements ViewGroup.OnHierarchyChangeListener {
|
||||
private ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener;
|
||||
|
||||
private PassThroughHierarchyChangeListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup.OnHierarchyChangeListener
|
||||
public void onChildViewAdded(View view, View view2) {
|
||||
if (view == ChipGroup.this && (view2 instanceof Chip)) {
|
||||
if (view2.getId() == -1) {
|
||||
view2.setId(ViewCompat.generateViewId());
|
||||
}
|
||||
ChipGroup.this.checkableGroup.addCheckable((Chip) view2);
|
||||
}
|
||||
ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener = this.onHierarchyChangeListener;
|
||||
if (onHierarchyChangeListener != null) {
|
||||
onHierarchyChangeListener.onChildViewAdded(view, view2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup.OnHierarchyChangeListener
|
||||
public void onChildViewRemoved(View view, View view2) {
|
||||
ChipGroup chipGroup = ChipGroup.this;
|
||||
if (view == chipGroup && (view2 instanceof Chip)) {
|
||||
chipGroup.checkableGroup.removeCheckable((Chip) view2);
|
||||
}
|
||||
ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener = this.onHierarchyChangeListener;
|
||||
if (onHierarchyChangeListener != null) {
|
||||
onHierarchyChangeListener.onChildViewRemoved(view, view2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.google.android.material.circularreveal;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.util.Property;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import com.google.android.material.circularreveal.CircularRevealWidget;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class CircularRevealCompat {
|
||||
private CircularRevealCompat() {
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static Animator createCircularReveal(CircularRevealWidget circularRevealWidget, float f, float f2, float f3) {
|
||||
ObjectAnimator ofObject = ObjectAnimator.ofObject(circularRevealWidget, (Property<CircularRevealWidget, V>) CircularRevealWidget.CircularRevealProperty.CIRCULAR_REVEAL, (TypeEvaluator) CircularRevealWidget.CircularRevealEvaluator.CIRCULAR_REVEAL, (Object[]) new CircularRevealWidget.RevealInfo[]{new CircularRevealWidget.RevealInfo(f, f2, f3)});
|
||||
CircularRevealWidget.RevealInfo revealInfo = circularRevealWidget.getRevealInfo();
|
||||
if (revealInfo == null) {
|
||||
throw new IllegalStateException("Caller must set a non-null RevealInfo before calling this.");
|
||||
}
|
||||
Animator createCircularReveal = ViewAnimationUtils.createCircularReveal((View) circularRevealWidget, (int) f, (int) f2, revealInfo.radius, f3);
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(ofObject, createCircularReveal);
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static Animator createCircularReveal(CircularRevealWidget circularRevealWidget, float f, float f2, float f3, float f4) {
|
||||
ObjectAnimator ofObject = ObjectAnimator.ofObject(circularRevealWidget, (Property<CircularRevealWidget, V>) CircularRevealWidget.CircularRevealProperty.CIRCULAR_REVEAL, (TypeEvaluator) CircularRevealWidget.CircularRevealEvaluator.CIRCULAR_REVEAL, (Object[]) new CircularRevealWidget.RevealInfo[]{new CircularRevealWidget.RevealInfo(f, f2, f3), new CircularRevealWidget.RevealInfo(f, f2, f4)});
|
||||
Animator createCircularReveal = ViewAnimationUtils.createCircularReveal((View) circularRevealWidget, (int) f, (int) f2, f3, f4);
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(ofObject, createCircularReveal);
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
public static Animator.AnimatorListener createCircularRevealListener(final CircularRevealWidget circularRevealWidget) {
|
||||
return new AnimatorListenerAdapter() { // from class: com.google.android.material.circularreveal.CircularRevealCompat.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
CircularRevealWidget.this.buildCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
CircularRevealWidget.this.destroyCircularRevealCache();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.google.android.material.circularreveal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
import com.google.android.material.circularreveal.CircularRevealWidget;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircularRevealFrameLayout extends FrameLayout implements CircularRevealWidget {
|
||||
private final CircularRevealHelper helper;
|
||||
|
||||
public CircularRevealFrameLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public CircularRevealFrameLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.helper = new CircularRevealHelper(this);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void buildCircularRevealCache() {
|
||||
this.helper.buildCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void destroyCircularRevealCache() {
|
||||
this.helper.destroyCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public CircularRevealWidget.RevealInfo getRevealInfo() {
|
||||
return this.helper.getRevealInfo();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setRevealInfo(CircularRevealWidget.RevealInfo revealInfo) {
|
||||
this.helper.setRevealInfo(revealInfo);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public int getCircularRevealScrimColor() {
|
||||
return this.helper.getCircularRevealScrimColor();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealScrimColor(int i) {
|
||||
this.helper.setCircularRevealScrimColor(i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public Drawable getCircularRevealOverlayDrawable() {
|
||||
return this.helper.getCircularRevealOverlayDrawable();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealOverlayDrawable(Drawable drawable) {
|
||||
this.helper.setCircularRevealOverlayDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void draw(Canvas canvas) {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
circularRevealHelper.draw(canvas);
|
||||
} else {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public void actualDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public boolean isOpaque() {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
return circularRevealHelper.isOpaque();
|
||||
}
|
||||
return super.isOpaque();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public boolean actualIsOpaque() {
|
||||
return super.isOpaque();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.google.android.material.circularreveal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.GridLayout;
|
||||
import com.google.android.material.circularreveal.CircularRevealWidget;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircularRevealGridLayout extends GridLayout implements CircularRevealWidget {
|
||||
private final CircularRevealHelper helper;
|
||||
|
||||
public CircularRevealGridLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public CircularRevealGridLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.helper = new CircularRevealHelper(this);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void buildCircularRevealCache() {
|
||||
this.helper.buildCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void destroyCircularRevealCache() {
|
||||
this.helper.destroyCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public CircularRevealWidget.RevealInfo getRevealInfo() {
|
||||
return this.helper.getRevealInfo();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setRevealInfo(CircularRevealWidget.RevealInfo revealInfo) {
|
||||
this.helper.setRevealInfo(revealInfo);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public int getCircularRevealScrimColor() {
|
||||
return this.helper.getCircularRevealScrimColor();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealScrimColor(int i) {
|
||||
this.helper.setCircularRevealScrimColor(i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public Drawable getCircularRevealOverlayDrawable() {
|
||||
return this.helper.getCircularRevealOverlayDrawable();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealOverlayDrawable(Drawable drawable) {
|
||||
this.helper.setCircularRevealOverlayDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void draw(Canvas canvas) {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
circularRevealHelper.draw(canvas);
|
||||
} else {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public void actualDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public boolean isOpaque() {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
return circularRevealHelper.isOpaque();
|
||||
}
|
||||
return super.isOpaque();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public boolean actualIsOpaque() {
|
||||
return super.isOpaque();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
package com.google.android.material.circularreveal;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import androidx.core.internal.view.SupportMenu;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.circularreveal.CircularRevealWidget;
|
||||
import com.google.android.material.math.MathUtils;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircularRevealHelper {
|
||||
public static final int BITMAP_SHADER = 0;
|
||||
public static final int CLIP_PATH = 1;
|
||||
private static final boolean DEBUG = false;
|
||||
public static final int REVEAL_ANIMATOR = 2;
|
||||
public static final int STRATEGY = 2;
|
||||
private boolean buildingCircularRevealCache;
|
||||
private Paint debugPaint;
|
||||
private final Delegate delegate;
|
||||
private boolean hasCircularRevealCache;
|
||||
private Drawable overlayDrawable;
|
||||
private CircularRevealWidget.RevealInfo revealInfo;
|
||||
private final Paint revealPaint;
|
||||
private final Path revealPath;
|
||||
private final Paint scrimPaint;
|
||||
private final View view;
|
||||
|
||||
public interface Delegate {
|
||||
void actualDraw(Canvas canvas);
|
||||
|
||||
boolean actualIsOpaque();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface Strategy {
|
||||
}
|
||||
|
||||
private boolean shouldDrawOverlayDrawable() {
|
||||
return (this.buildingCircularRevealCache || this.overlayDrawable == null || this.revealInfo == null) ? false : true;
|
||||
}
|
||||
|
||||
public Drawable getCircularRevealOverlayDrawable() {
|
||||
return this.overlayDrawable;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public CircularRevealHelper(Delegate delegate) {
|
||||
this.delegate = delegate;
|
||||
View view = (View) delegate;
|
||||
this.view = view;
|
||||
view.setWillNotDraw(false);
|
||||
this.revealPath = new Path();
|
||||
this.revealPaint = new Paint(7);
|
||||
Paint paint = new Paint(1);
|
||||
this.scrimPaint = paint;
|
||||
paint.setColor(0);
|
||||
}
|
||||
|
||||
public void buildCircularRevealCache() {
|
||||
if (STRATEGY == 0) {
|
||||
this.buildingCircularRevealCache = true;
|
||||
this.hasCircularRevealCache = false;
|
||||
this.view.buildDrawingCache();
|
||||
Bitmap drawingCache = this.view.getDrawingCache();
|
||||
if (drawingCache == null && this.view.getWidth() != 0 && this.view.getHeight() != 0) {
|
||||
drawingCache = Bitmap.createBitmap(this.view.getWidth(), this.view.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
this.view.draw(new Canvas(drawingCache));
|
||||
}
|
||||
if (drawingCache != null) {
|
||||
this.revealPaint.setShader(new BitmapShader(drawingCache, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
|
||||
}
|
||||
this.buildingCircularRevealCache = false;
|
||||
this.hasCircularRevealCache = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyCircularRevealCache() {
|
||||
if (STRATEGY == 0) {
|
||||
this.hasCircularRevealCache = false;
|
||||
this.view.destroyDrawingCache();
|
||||
this.revealPaint.setShader(null);
|
||||
this.view.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setRevealInfo(CircularRevealWidget.RevealInfo revealInfo) {
|
||||
if (revealInfo == null) {
|
||||
this.revealInfo = null;
|
||||
} else {
|
||||
CircularRevealWidget.RevealInfo revealInfo2 = this.revealInfo;
|
||||
if (revealInfo2 == null) {
|
||||
this.revealInfo = new CircularRevealWidget.RevealInfo(revealInfo);
|
||||
} else {
|
||||
revealInfo2.set(revealInfo);
|
||||
}
|
||||
if (MathUtils.geq(revealInfo.radius, getDistanceToFurthestCorner(revealInfo), 1.0E-4f)) {
|
||||
this.revealInfo.radius = Float.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
invalidateRevealInfo();
|
||||
}
|
||||
|
||||
public CircularRevealWidget.RevealInfo getRevealInfo() {
|
||||
CircularRevealWidget.RevealInfo revealInfo = this.revealInfo;
|
||||
if (revealInfo == null) {
|
||||
return null;
|
||||
}
|
||||
CircularRevealWidget.RevealInfo revealInfo2 = new CircularRevealWidget.RevealInfo(revealInfo);
|
||||
if (revealInfo2.isInvalid()) {
|
||||
revealInfo2.radius = getDistanceToFurthestCorner(revealInfo2);
|
||||
}
|
||||
return revealInfo2;
|
||||
}
|
||||
|
||||
public void setCircularRevealScrimColor(int i) {
|
||||
this.scrimPaint.setColor(i);
|
||||
this.view.invalidate();
|
||||
}
|
||||
|
||||
public int getCircularRevealScrimColor() {
|
||||
return this.scrimPaint.getColor();
|
||||
}
|
||||
|
||||
public void setCircularRevealOverlayDrawable(Drawable drawable) {
|
||||
this.overlayDrawable = drawable;
|
||||
this.view.invalidate();
|
||||
}
|
||||
|
||||
private void invalidateRevealInfo() {
|
||||
if (STRATEGY == 1) {
|
||||
this.revealPath.rewind();
|
||||
CircularRevealWidget.RevealInfo revealInfo = this.revealInfo;
|
||||
if (revealInfo != null) {
|
||||
this.revealPath.addCircle(revealInfo.centerX, this.revealInfo.centerY, this.revealInfo.radius, Path.Direction.CW);
|
||||
}
|
||||
}
|
||||
this.view.invalidate();
|
||||
}
|
||||
|
||||
private float getDistanceToFurthestCorner(CircularRevealWidget.RevealInfo revealInfo) {
|
||||
return MathUtils.distanceToFurthestCorner(revealInfo.centerX, revealInfo.centerY, 0.0f, 0.0f, this.view.getWidth(), this.view.getHeight());
|
||||
}
|
||||
|
||||
public void draw(Canvas canvas) {
|
||||
if (shouldDrawCircularReveal()) {
|
||||
int i = STRATEGY;
|
||||
if (i == 0) {
|
||||
canvas.drawCircle(this.revealInfo.centerX, this.revealInfo.centerY, this.revealInfo.radius, this.revealPaint);
|
||||
if (shouldDrawScrim()) {
|
||||
canvas.drawCircle(this.revealInfo.centerX, this.revealInfo.centerY, this.revealInfo.radius, this.scrimPaint);
|
||||
}
|
||||
} else if (i == 1) {
|
||||
int save = canvas.save();
|
||||
canvas.clipPath(this.revealPath);
|
||||
this.delegate.actualDraw(canvas);
|
||||
if (shouldDrawScrim()) {
|
||||
canvas.drawRect(0.0f, 0.0f, this.view.getWidth(), this.view.getHeight(), this.scrimPaint);
|
||||
}
|
||||
canvas.restoreToCount(save);
|
||||
} else if (i == 2) {
|
||||
this.delegate.actualDraw(canvas);
|
||||
if (shouldDrawScrim()) {
|
||||
canvas.drawRect(0.0f, 0.0f, this.view.getWidth(), this.view.getHeight(), this.scrimPaint);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Unsupported strategy " + i);
|
||||
}
|
||||
} else {
|
||||
this.delegate.actualDraw(canvas);
|
||||
if (shouldDrawScrim()) {
|
||||
canvas.drawRect(0.0f, 0.0f, this.view.getWidth(), this.view.getHeight(), this.scrimPaint);
|
||||
}
|
||||
}
|
||||
drawOverlayDrawable(canvas);
|
||||
}
|
||||
|
||||
private void drawOverlayDrawable(Canvas canvas) {
|
||||
if (shouldDrawOverlayDrawable()) {
|
||||
Rect bounds = this.overlayDrawable.getBounds();
|
||||
float width = this.revealInfo.centerX - (bounds.width() / 2.0f);
|
||||
float height = this.revealInfo.centerY - (bounds.height() / 2.0f);
|
||||
canvas.translate(width, height);
|
||||
this.overlayDrawable.draw(canvas);
|
||||
canvas.translate(-width, -height);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOpaque() {
|
||||
return this.delegate.actualIsOpaque() && !shouldDrawCircularReveal();
|
||||
}
|
||||
|
||||
private boolean shouldDrawCircularReveal() {
|
||||
CircularRevealWidget.RevealInfo revealInfo = this.revealInfo;
|
||||
boolean z = revealInfo == null || revealInfo.isInvalid();
|
||||
return STRATEGY == 0 ? !z && this.hasCircularRevealCache : !z;
|
||||
}
|
||||
|
||||
private boolean shouldDrawScrim() {
|
||||
return (this.buildingCircularRevealCache || Color.alpha(this.scrimPaint.getColor()) == 0) ? false : true;
|
||||
}
|
||||
|
||||
private void drawDebugMode(Canvas canvas) {
|
||||
this.delegate.actualDraw(canvas);
|
||||
if (shouldDrawScrim()) {
|
||||
canvas.drawCircle(this.revealInfo.centerX, this.revealInfo.centerY, this.revealInfo.radius, this.scrimPaint);
|
||||
}
|
||||
if (shouldDrawCircularReveal()) {
|
||||
drawDebugCircle(canvas, ViewCompat.MEASURED_STATE_MASK, 10.0f);
|
||||
drawDebugCircle(canvas, SupportMenu.CATEGORY_MASK, 5.0f);
|
||||
}
|
||||
drawOverlayDrawable(canvas);
|
||||
}
|
||||
|
||||
private void drawDebugCircle(Canvas canvas, int i, float f) {
|
||||
this.debugPaint.setColor(i);
|
||||
this.debugPaint.setStrokeWidth(f);
|
||||
canvas.drawCircle(this.revealInfo.centerX, this.revealInfo.centerY, this.revealInfo.radius - (f / 2.0f), this.debugPaint);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.google.android.material.circularreveal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
import com.google.android.material.circularreveal.CircularRevealWidget;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircularRevealLinearLayout extends LinearLayout implements CircularRevealWidget {
|
||||
private final CircularRevealHelper helper;
|
||||
|
||||
public CircularRevealLinearLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public CircularRevealLinearLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.helper = new CircularRevealHelper(this);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void buildCircularRevealCache() {
|
||||
this.helper.buildCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void destroyCircularRevealCache() {
|
||||
this.helper.destroyCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public CircularRevealWidget.RevealInfo getRevealInfo() {
|
||||
return this.helper.getRevealInfo();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setRevealInfo(CircularRevealWidget.RevealInfo revealInfo) {
|
||||
this.helper.setRevealInfo(revealInfo);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public int getCircularRevealScrimColor() {
|
||||
return this.helper.getCircularRevealScrimColor();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealScrimColor(int i) {
|
||||
this.helper.setCircularRevealScrimColor(i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public Drawable getCircularRevealOverlayDrawable() {
|
||||
return this.helper.getCircularRevealOverlayDrawable();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealOverlayDrawable(Drawable drawable) {
|
||||
this.helper.setCircularRevealOverlayDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void draw(Canvas canvas) {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
circularRevealHelper.draw(canvas);
|
||||
} else {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public void actualDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public boolean isOpaque() {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
return circularRevealHelper.isOpaque();
|
||||
}
|
||||
return super.isOpaque();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public boolean actualIsOpaque() {
|
||||
return super.isOpaque();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.google.android.material.circularreveal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RelativeLayout;
|
||||
import com.google.android.material.circularreveal.CircularRevealWidget;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircularRevealRelativeLayout extends RelativeLayout implements CircularRevealWidget {
|
||||
private final CircularRevealHelper helper;
|
||||
|
||||
public CircularRevealRelativeLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public CircularRevealRelativeLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.helper = new CircularRevealHelper(this);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void buildCircularRevealCache() {
|
||||
this.helper.buildCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void destroyCircularRevealCache() {
|
||||
this.helper.destroyCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public CircularRevealWidget.RevealInfo getRevealInfo() {
|
||||
return this.helper.getRevealInfo();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setRevealInfo(CircularRevealWidget.RevealInfo revealInfo) {
|
||||
this.helper.setRevealInfo(revealInfo);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public int getCircularRevealScrimColor() {
|
||||
return this.helper.getCircularRevealScrimColor();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealScrimColor(int i) {
|
||||
this.helper.setCircularRevealScrimColor(i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public Drawable getCircularRevealOverlayDrawable() {
|
||||
return this.helper.getCircularRevealOverlayDrawable();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealOverlayDrawable(Drawable drawable) {
|
||||
this.helper.setCircularRevealOverlayDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void draw(Canvas canvas) {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
circularRevealHelper.draw(canvas);
|
||||
} else {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public void actualDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public boolean isOpaque() {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
return circularRevealHelper.isOpaque();
|
||||
}
|
||||
return super.isOpaque();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public boolean actualIsOpaque() {
|
||||
return super.isOpaque();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.google.android.material.circularreveal;
|
||||
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Property;
|
||||
import com.google.android.material.circularreveal.CircularRevealHelper;
|
||||
import com.google.android.material.math.MathUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface CircularRevealWidget extends CircularRevealHelper.Delegate {
|
||||
void buildCircularRevealCache();
|
||||
|
||||
void destroyCircularRevealCache();
|
||||
|
||||
void draw(Canvas canvas);
|
||||
|
||||
Drawable getCircularRevealOverlayDrawable();
|
||||
|
||||
int getCircularRevealScrimColor();
|
||||
|
||||
RevealInfo getRevealInfo();
|
||||
|
||||
boolean isOpaque();
|
||||
|
||||
void setCircularRevealOverlayDrawable(Drawable drawable);
|
||||
|
||||
void setCircularRevealScrimColor(int i);
|
||||
|
||||
void setRevealInfo(RevealInfo revealInfo);
|
||||
|
||||
public static class RevealInfo {
|
||||
public static final float INVALID_RADIUS = Float.MAX_VALUE;
|
||||
public float centerX;
|
||||
public float centerY;
|
||||
public float radius;
|
||||
|
||||
public boolean isInvalid() {
|
||||
return this.radius == Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
public void set(float f, float f2, float f3) {
|
||||
this.centerX = f;
|
||||
this.centerY = f2;
|
||||
this.radius = f3;
|
||||
}
|
||||
|
||||
private RevealInfo() {
|
||||
}
|
||||
|
||||
public RevealInfo(float f, float f2, float f3) {
|
||||
this.centerX = f;
|
||||
this.centerY = f2;
|
||||
this.radius = f3;
|
||||
}
|
||||
|
||||
public RevealInfo(RevealInfo revealInfo) {
|
||||
this(revealInfo.centerX, revealInfo.centerY, revealInfo.radius);
|
||||
}
|
||||
|
||||
public void set(RevealInfo revealInfo) {
|
||||
set(revealInfo.centerX, revealInfo.centerY, revealInfo.radius);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CircularRevealProperty extends Property<CircularRevealWidget, RevealInfo> {
|
||||
public static final Property<CircularRevealWidget, RevealInfo> CIRCULAR_REVEAL = new CircularRevealProperty("circularReveal");
|
||||
|
||||
private CircularRevealProperty(String str) {
|
||||
super(RevealInfo.class, str);
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public RevealInfo get(CircularRevealWidget circularRevealWidget) {
|
||||
return circularRevealWidget.getRevealInfo();
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(CircularRevealWidget circularRevealWidget, RevealInfo revealInfo) {
|
||||
circularRevealWidget.setRevealInfo(revealInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CircularRevealEvaluator implements TypeEvaluator<RevealInfo> {
|
||||
public static final TypeEvaluator<RevealInfo> CIRCULAR_REVEAL = new CircularRevealEvaluator();
|
||||
private final RevealInfo revealInfo = new RevealInfo();
|
||||
|
||||
@Override // android.animation.TypeEvaluator
|
||||
public RevealInfo evaluate(float f, RevealInfo revealInfo, RevealInfo revealInfo2) {
|
||||
this.revealInfo.set(MathUtils.lerp(revealInfo.centerX, revealInfo2.centerX, f), MathUtils.lerp(revealInfo.centerY, revealInfo2.centerY, f), MathUtils.lerp(revealInfo.radius, revealInfo2.radius, f));
|
||||
return this.revealInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CircularRevealScrimColorProperty extends Property<CircularRevealWidget, Integer> {
|
||||
public static final Property<CircularRevealWidget, Integer> CIRCULAR_REVEAL_SCRIM_COLOR = new CircularRevealScrimColorProperty("circularRevealScrimColor");
|
||||
|
||||
private CircularRevealScrimColorProperty(String str) {
|
||||
super(Integer.class, str);
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public Integer get(CircularRevealWidget circularRevealWidget) {
|
||||
return Integer.valueOf(circularRevealWidget.getCircularRevealScrimColor());
|
||||
}
|
||||
|
||||
@Override // android.util.Property
|
||||
public void set(CircularRevealWidget circularRevealWidget, Integer num) {
|
||||
circularRevealWidget.setCircularRevealScrimColor(num.intValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.google.android.material.circularreveal.cardview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
import com.google.android.material.circularreveal.CircularRevealHelper;
|
||||
import com.google.android.material.circularreveal.CircularRevealWidget;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircularRevealCardView extends MaterialCardView implements CircularRevealWidget {
|
||||
private final CircularRevealHelper helper;
|
||||
|
||||
public CircularRevealCardView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public CircularRevealCardView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.helper = new CircularRevealHelper(this);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void buildCircularRevealCache() {
|
||||
this.helper.buildCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void destroyCircularRevealCache() {
|
||||
this.helper.destroyCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setRevealInfo(CircularRevealWidget.RevealInfo revealInfo) {
|
||||
this.helper.setRevealInfo(revealInfo);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public CircularRevealWidget.RevealInfo getRevealInfo() {
|
||||
return this.helper.getRevealInfo();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealScrimColor(int i) {
|
||||
this.helper.setCircularRevealScrimColor(i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public int getCircularRevealScrimColor() {
|
||||
return this.helper.getCircularRevealScrimColor();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public Drawable getCircularRevealOverlayDrawable() {
|
||||
return this.helper.getCircularRevealOverlayDrawable();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealOverlayDrawable(Drawable drawable) {
|
||||
this.helper.setCircularRevealOverlayDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void draw(Canvas canvas) {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
circularRevealHelper.draw(canvas);
|
||||
} else {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public void actualDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public boolean isOpaque() {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
return circularRevealHelper.isOpaque();
|
||||
}
|
||||
return super.isOpaque();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public boolean actualIsOpaque() {
|
||||
return super.isOpaque();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.google.android.material.circularreveal.coordinatorlayout;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.google.android.material.circularreveal.CircularRevealHelper;
|
||||
import com.google.android.material.circularreveal.CircularRevealWidget;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircularRevealCoordinatorLayout extends CoordinatorLayout implements CircularRevealWidget {
|
||||
private final CircularRevealHelper helper;
|
||||
|
||||
public CircularRevealCoordinatorLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public CircularRevealCoordinatorLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.helper = new CircularRevealHelper(this);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void buildCircularRevealCache() {
|
||||
this.helper.buildCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void destroyCircularRevealCache() {
|
||||
this.helper.destroyCircularRevealCache();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setRevealInfo(CircularRevealWidget.RevealInfo revealInfo) {
|
||||
this.helper.setRevealInfo(revealInfo);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public CircularRevealWidget.RevealInfo getRevealInfo() {
|
||||
return this.helper.getRevealInfo();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealScrimColor(int i) {
|
||||
this.helper.setCircularRevealScrimColor(i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public int getCircularRevealScrimColor() {
|
||||
return this.helper.getCircularRevealScrimColor();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public Drawable getCircularRevealOverlayDrawable() {
|
||||
return this.helper.getCircularRevealOverlayDrawable();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void setCircularRevealOverlayDrawable(Drawable drawable) {
|
||||
this.helper.setCircularRevealOverlayDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public void draw(Canvas canvas) {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
circularRevealHelper.draw(canvas);
|
||||
} else {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public void actualDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.view.View, com.google.android.material.circularreveal.CircularRevealWidget
|
||||
public boolean isOpaque() {
|
||||
CircularRevealHelper circularRevealHelper = this.helper;
|
||||
if (circularRevealHelper != null) {
|
||||
return circularRevealHelper.isOpaque();
|
||||
}
|
||||
return super.isOpaque();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.circularreveal.CircularRevealHelper.Delegate
|
||||
public boolean actualIsOpaque() {
|
||||
return super.isOpaque();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.app.UiModeManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ColorContrast {
|
||||
private static final float HIGH_CONTRAST_THRESHOLD = 0.6666667f;
|
||||
private static final float MEDIUM_CONTRAST_THRESHOLD = 0.33333334f;
|
||||
|
||||
public static boolean isContrastAvailable() {
|
||||
return Build.VERSION.SDK_INT >= 34;
|
||||
}
|
||||
|
||||
private ColorContrast() {
|
||||
}
|
||||
|
||||
public static void applyToActivitiesIfAvailable(Application application, ColorContrastOptions colorContrastOptions) {
|
||||
if (isContrastAvailable()) {
|
||||
application.registerActivityLifecycleCallbacks(new ColorContrastActivityLifecycleCallbacks(colorContrastOptions));
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyToActivityIfAvailable(Activity activity, ColorContrastOptions colorContrastOptions) {
|
||||
int contrastThemeOverlayResourceId;
|
||||
if (isContrastAvailable() && (contrastThemeOverlayResourceId = getContrastThemeOverlayResourceId(activity, colorContrastOptions)) != 0) {
|
||||
ThemeUtils.applyThemeOverlay(activity, contrastThemeOverlayResourceId);
|
||||
}
|
||||
}
|
||||
|
||||
public static Context wrapContextIfAvailable(Context context, ColorContrastOptions colorContrastOptions) {
|
||||
int contrastThemeOverlayResourceId;
|
||||
return (isContrastAvailable() && (contrastThemeOverlayResourceId = getContrastThemeOverlayResourceId(context, colorContrastOptions)) != 0) ? new ContextThemeWrapper(context, contrastThemeOverlayResourceId) : context;
|
||||
}
|
||||
|
||||
private static int getContrastThemeOverlayResourceId(Context context, ColorContrastOptions colorContrastOptions) {
|
||||
float contrast;
|
||||
UiModeManager uiModeManager = (UiModeManager) context.getSystemService("uimode");
|
||||
if (isContrastAvailable() && uiModeManager != null) {
|
||||
contrast = uiModeManager.getContrast();
|
||||
int mediumContrastThemeOverlay = colorContrastOptions.getMediumContrastThemeOverlay();
|
||||
int highContrastThemeOverlay = colorContrastOptions.getHighContrastThemeOverlay();
|
||||
if (contrast >= HIGH_CONTRAST_THRESHOLD) {
|
||||
return highContrastThemeOverlay == 0 ? mediumContrastThemeOverlay : highContrastThemeOverlay;
|
||||
}
|
||||
if (contrast >= MEDIUM_CONTRAST_THRESHOLD) {
|
||||
return mediumContrastThemeOverlay == 0 ? highContrastThemeOverlay : mediumContrastThemeOverlay;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static class ColorContrastActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
|
||||
private final Set<Activity> activitiesInStack = new LinkedHashSet();
|
||||
private final ColorContrastOptions colorContrastOptions;
|
||||
private UiModeManager.ContrastChangeListener contrastChangeListener;
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityCreated(Activity activity, Bundle bundle) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityPaused(Activity activity) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityResumed(Activity activity) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityStarted(Activity activity) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityStopped(Activity activity) {
|
||||
}
|
||||
|
||||
ColorContrastActivityLifecycleCallbacks(ColorContrastOptions colorContrastOptions) {
|
||||
this.colorContrastOptions = colorContrastOptions;
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityPreCreated(Activity activity, Bundle bundle) {
|
||||
UiModeManager uiModeManager = (UiModeManager) activity.getSystemService("uimode");
|
||||
if (uiModeManager != null && this.activitiesInStack.isEmpty() && this.contrastChangeListener == null) {
|
||||
this.contrastChangeListener = new UiModeManager.ContrastChangeListener() { // from class: com.google.android.material.color.ColorContrast.ColorContrastActivityLifecycleCallbacks.1
|
||||
@Override // android.app.UiModeManager.ContrastChangeListener
|
||||
public void onContrastChanged(float f) {
|
||||
Iterator it = ColorContrastActivityLifecycleCallbacks.this.activitiesInStack.iterator();
|
||||
while (it.hasNext()) {
|
||||
((Activity) it.next()).recreate();
|
||||
}
|
||||
}
|
||||
};
|
||||
uiModeManager.addContrastChangeListener(ContextCompat.getMainExecutor(activity.getApplicationContext()), this.contrastChangeListener);
|
||||
}
|
||||
this.activitiesInStack.add(activity);
|
||||
if (uiModeManager != null) {
|
||||
ColorContrast.applyToActivityIfAvailable(activity, this.colorContrastOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
this.activitiesInStack.remove(activity);
|
||||
UiModeManager uiModeManager = (UiModeManager) activity.getSystemService("uimode");
|
||||
if (uiModeManager == null || this.contrastChangeListener == null || !this.activitiesInStack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
uiModeManager.removeContrastChangeListener(this.contrastChangeListener);
|
||||
this.contrastChangeListener = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ColorContrastOptions {
|
||||
private final int highContrastThemeOverlayResourceId;
|
||||
private final int mediumContrastThemeOverlayResourceId;
|
||||
|
||||
public int getHighContrastThemeOverlay() {
|
||||
return this.highContrastThemeOverlayResourceId;
|
||||
}
|
||||
|
||||
public int getMediumContrastThemeOverlay() {
|
||||
return this.mediumContrastThemeOverlayResourceId;
|
||||
}
|
||||
|
||||
private ColorContrastOptions(Builder builder) {
|
||||
this.mediumContrastThemeOverlayResourceId = builder.mediumContrastThemeOverlayResourceId;
|
||||
this.highContrastThemeOverlayResourceId = builder.highContrastThemeOverlayResourceId;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int highContrastThemeOverlayResourceId;
|
||||
private int mediumContrastThemeOverlayResourceId;
|
||||
|
||||
public Builder setHighContrastThemeOverlay(int i) {
|
||||
this.highContrastThemeOverlayResourceId = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMediumContrastThemeOverlay(int i) {
|
||||
this.mediumContrastThemeOverlayResourceId = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ColorContrastOptions build() {
|
||||
return new ColorContrastOptions(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.loader.ResourcesLoader;
|
||||
import android.content.res.loader.ResourcesProvider;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.system.Os;
|
||||
import android.util.Log;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Map;
|
||||
import kotlin.io.path.PathTreeWalk$$ExternalSyntheticApiModelOutline0;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class ColorResourcesLoaderCreator {
|
||||
private static final String TAG = "ColorResLoaderCreator";
|
||||
|
||||
private ColorResourcesLoaderCreator() {
|
||||
}
|
||||
|
||||
static ResourcesLoader create(Context context, Map<Integer, Integer> map) {
|
||||
FileDescriptor fileDescriptor;
|
||||
ResourcesProvider loadFromTable;
|
||||
try {
|
||||
byte[] create = ColorResourcesTableCreator.create(context, map);
|
||||
Log.i(TAG, "Table created, length: " + create.length);
|
||||
if (create.length == 0) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
fileDescriptor = Os.memfd_create("temp.arsc", 0);
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
fileDescriptor = null;
|
||||
}
|
||||
try {
|
||||
if (fileDescriptor == null) {
|
||||
Log.w(TAG, "Cannot create memory file descriptor.");
|
||||
if (fileDescriptor != null) {
|
||||
Os.close(fileDescriptor);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(fileDescriptor);
|
||||
try {
|
||||
fileOutputStream.write(create);
|
||||
ParcelFileDescriptor dup = ParcelFileDescriptor.dup(fileDescriptor);
|
||||
try {
|
||||
PathTreeWalk$$ExternalSyntheticApiModelOutline0.m1528m();
|
||||
ResourcesLoader m = PathTreeWalk$$ExternalSyntheticApiModelOutline0.m();
|
||||
loadFromTable = ResourcesProvider.loadFromTable(dup, null);
|
||||
m.addProvider(loadFromTable);
|
||||
if (dup != null) {
|
||||
dup.close();
|
||||
}
|
||||
fileOutputStream.close();
|
||||
if (fileDescriptor != null) {
|
||||
Os.close(fileDescriptor);
|
||||
}
|
||||
return m;
|
||||
} finally {
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
if (fileDescriptor != null) {
|
||||
Os.close(fileDescriptor);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to create the ColorResourcesTableCreator.", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ColorResourcesOverride {
|
||||
boolean applyIfPossible(Context context, Map<Integer, Integer> map);
|
||||
|
||||
Context wrapContextIfPossible(Context context, Map<Integer, Integer> map);
|
||||
|
||||
/* renamed from: com.google.android.material.color.ColorResourcesOverride$-CC, reason: invalid class name */
|
||||
public final /* synthetic */ class CC {
|
||||
public static ColorResourcesOverride getInstance() {
|
||||
if (30 <= Build.VERSION.SDK_INT && Build.VERSION.SDK_INT <= 33) {
|
||||
return ResourcesLoaderColorResourcesOverride.getInstance();
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 34) {
|
||||
return ResourcesLoaderColorResourcesOverride.getInstance();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,502 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Pair;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import kotlin.UByte;
|
||||
import kotlinx.coroutines.scheduling.WorkQueueKt;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class ColorResourcesTableCreator {
|
||||
private static final byte ANDROID_PACKAGE_ID = 1;
|
||||
private static final byte APPLICATION_PACKAGE_ID = Byte.MAX_VALUE;
|
||||
private static final short HEADER_TYPE_PACKAGE = 512;
|
||||
private static final short HEADER_TYPE_RES_TABLE = 2;
|
||||
private static final short HEADER_TYPE_STRING_POOL = 1;
|
||||
private static final short HEADER_TYPE_TYPE = 513;
|
||||
private static final short HEADER_TYPE_TYPE_SPEC = 514;
|
||||
private static final String RESOURCE_TYPE_NAME_COLOR = "color";
|
||||
private static byte typeIdColor;
|
||||
private static final PackageInfo ANDROID_PACKAGE_INFO = new PackageInfo(1, "android");
|
||||
private static final Comparator<ColorResource> COLOR_RESOURCE_COMPARATOR = new Comparator<ColorResource>() { // from class: com.google.android.material.color.ColorResourcesTableCreator.1
|
||||
@Override // java.util.Comparator
|
||||
public int compare(ColorResource colorResource, ColorResource colorResource2) {
|
||||
return colorResource.entryId - colorResource2.entryId;
|
||||
}
|
||||
};
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static byte[] charToByteArray(char c) {
|
||||
return new byte[]{(byte) (c & 255), (byte) ((c >> '\b') & 255)};
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static byte[] intToByteArray(int i) {
|
||||
return new byte[]{(byte) (i & 255), (byte) ((i >> 8) & 255), (byte) ((i >> 16) & 255), (byte) ((i >> 24) & 255)};
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static byte[] shortToByteArray(short s) {
|
||||
return new byte[]{(byte) (s & 255), (byte) ((s >> 8) & 255)};
|
||||
}
|
||||
|
||||
private ColorResourcesTableCreator() {
|
||||
}
|
||||
|
||||
static byte[] create(Context context, Map<Integer, Integer> map) throws IOException {
|
||||
PackageInfo packageInfo;
|
||||
if (map.entrySet().isEmpty()) {
|
||||
throw new IllegalArgumentException("No color resources provided for harmonization.");
|
||||
}
|
||||
PackageInfo packageInfo2 = new PackageInfo(WorkQueueKt.MASK, context.getPackageName());
|
||||
HashMap hashMap = new HashMap();
|
||||
ColorResource colorResource = null;
|
||||
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
|
||||
ColorResource colorResource2 = new ColorResource(entry.getKey().intValue(), context.getResources().getResourceName(entry.getKey().intValue()), entry.getValue().intValue());
|
||||
if (!context.getResources().getResourceTypeName(entry.getKey().intValue()).equals("color")) {
|
||||
throw new IllegalArgumentException("Non color resource found: name=" + colorResource2.name + ", typeId=" + Integer.toHexString(colorResource2.typeId & UByte.MAX_VALUE));
|
||||
}
|
||||
if (colorResource2.packageId == 1) {
|
||||
packageInfo = ANDROID_PACKAGE_INFO;
|
||||
} else {
|
||||
if (colorResource2.packageId != Byte.MAX_VALUE) {
|
||||
throw new IllegalArgumentException("Not supported with unknown package id: " + ((int) colorResource2.packageId));
|
||||
}
|
||||
packageInfo = packageInfo2;
|
||||
}
|
||||
if (!hashMap.containsKey(packageInfo)) {
|
||||
hashMap.put(packageInfo, new ArrayList());
|
||||
}
|
||||
((List) hashMap.get(packageInfo)).add(colorResource2);
|
||||
colorResource = colorResource2;
|
||||
}
|
||||
byte b = colorResource.typeId;
|
||||
typeIdColor = b;
|
||||
if (b == 0) {
|
||||
throw new IllegalArgumentException("No color resources found for harmonization.");
|
||||
}
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
new ResTable(hashMap).writeTo(byteArrayOutputStream);
|
||||
return byteArrayOutputStream.toByteArray();
|
||||
}
|
||||
|
||||
private static class ResTable {
|
||||
private static final short HEADER_SIZE = 12;
|
||||
private final ResChunkHeader header;
|
||||
private final int packageCount;
|
||||
private final List<PackageChunk> packageChunks = new ArrayList();
|
||||
private final StringPoolChunk stringPool = new StringPoolChunk(new String[0]);
|
||||
|
||||
ResTable(Map<PackageInfo, List<ColorResource>> map) {
|
||||
this.packageCount = map.size();
|
||||
for (Map.Entry<PackageInfo, List<ColorResource>> entry : map.entrySet()) {
|
||||
List<ColorResource> value = entry.getValue();
|
||||
Collections.sort(value, ColorResourcesTableCreator.COLOR_RESOURCE_COMPARATOR);
|
||||
this.packageChunks.add(new PackageChunk(entry.getKey(), value));
|
||||
}
|
||||
this.header = new ResChunkHeader(ColorResourcesTableCreator.HEADER_TYPE_RES_TABLE, HEADER_SIZE, getOverallSize());
|
||||
}
|
||||
|
||||
void writeTo(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
|
||||
this.header.writeTo(byteArrayOutputStream);
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.packageCount));
|
||||
this.stringPool.writeTo(byteArrayOutputStream);
|
||||
Iterator<PackageChunk> it = this.packageChunks.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().writeTo(byteArrayOutputStream);
|
||||
}
|
||||
}
|
||||
|
||||
private int getOverallSize() {
|
||||
Iterator<PackageChunk> it = this.packageChunks.iterator();
|
||||
int i = 0;
|
||||
while (it.hasNext()) {
|
||||
i += it.next().getChunkSize();
|
||||
}
|
||||
return this.stringPool.getChunkSize() + 12 + i;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ResChunkHeader {
|
||||
private final int chunkSize;
|
||||
private final short headerSize;
|
||||
private final short type;
|
||||
|
||||
ResChunkHeader(short s, short s2, int i) {
|
||||
this.type = s;
|
||||
this.headerSize = s2;
|
||||
this.chunkSize = i;
|
||||
}
|
||||
|
||||
void writeTo(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.shortToByteArray(this.type));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.shortToByteArray(this.headerSize));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.chunkSize));
|
||||
}
|
||||
}
|
||||
|
||||
private static class StringPoolChunk {
|
||||
private static final int FLAG_UTF8 = 256;
|
||||
private static final short HEADER_SIZE = 28;
|
||||
private static final int STYLED_SPAN_LIST_END = -1;
|
||||
private final int chunkSize;
|
||||
private final ResChunkHeader header;
|
||||
private final int stringCount;
|
||||
private final List<Integer> stringIndex;
|
||||
private final List<byte[]> strings;
|
||||
private final int stringsPaddingSize;
|
||||
private final int stringsStart;
|
||||
private final int styledSpanCount;
|
||||
private final List<Integer> styledSpanIndex;
|
||||
private final List<List<StringStyledSpan>> styledSpans;
|
||||
private final int styledSpansStart;
|
||||
private final boolean utf8Encode;
|
||||
|
||||
int getChunkSize() {
|
||||
return this.chunkSize;
|
||||
}
|
||||
|
||||
StringPoolChunk(String... strArr) {
|
||||
this(false, strArr);
|
||||
}
|
||||
|
||||
StringPoolChunk(boolean z, String... strArr) {
|
||||
this.stringIndex = new ArrayList();
|
||||
this.styledSpanIndex = new ArrayList();
|
||||
this.strings = new ArrayList();
|
||||
this.styledSpans = new ArrayList();
|
||||
this.utf8Encode = z;
|
||||
int i = 0;
|
||||
for (String str : strArr) {
|
||||
Pair<byte[], List<StringStyledSpan>> processString = processString(str);
|
||||
this.stringIndex.add(Integer.valueOf(i));
|
||||
i += ((byte[]) processString.first).length;
|
||||
this.strings.add((byte[]) processString.first);
|
||||
this.styledSpans.add((List) processString.second);
|
||||
}
|
||||
int i2 = 0;
|
||||
for (List<StringStyledSpan> list : this.styledSpans) {
|
||||
for (StringStyledSpan stringStyledSpan : list) {
|
||||
this.stringIndex.add(Integer.valueOf(i));
|
||||
i += stringStyledSpan.styleString.length;
|
||||
this.strings.add(stringStyledSpan.styleString);
|
||||
}
|
||||
this.styledSpanIndex.add(Integer.valueOf(i2));
|
||||
i2 += (list.size() * 12) + 4;
|
||||
}
|
||||
int i3 = i % 4;
|
||||
int i4 = i3 == 0 ? 0 : 4 - i3;
|
||||
this.stringsPaddingSize = i4;
|
||||
int size = this.strings.size();
|
||||
this.stringCount = size;
|
||||
this.styledSpanCount = this.strings.size() - strArr.length;
|
||||
boolean z2 = this.strings.size() - strArr.length > 0;
|
||||
if (!z2) {
|
||||
this.styledSpanIndex.clear();
|
||||
this.styledSpans.clear();
|
||||
}
|
||||
int size2 = (size * 4) + 28 + (this.styledSpanIndex.size() * 4);
|
||||
this.stringsStart = size2;
|
||||
int i5 = i + i4;
|
||||
this.styledSpansStart = z2 ? size2 + i5 : 0;
|
||||
int i6 = size2 + i5 + (z2 ? i2 : 0);
|
||||
this.chunkSize = i6;
|
||||
this.header = new ResChunkHeader(ColorResourcesTableCreator.HEADER_TYPE_STRING_POOL, HEADER_SIZE, i6);
|
||||
}
|
||||
|
||||
void writeTo(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
|
||||
this.header.writeTo(byteArrayOutputStream);
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.stringCount));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.styledSpanCount));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.utf8Encode ? 256 : 0));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.stringsStart));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.styledSpansStart));
|
||||
Iterator<Integer> it = this.stringIndex.iterator();
|
||||
while (it.hasNext()) {
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(it.next().intValue()));
|
||||
}
|
||||
Iterator<Integer> it2 = this.styledSpanIndex.iterator();
|
||||
while (it2.hasNext()) {
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(it2.next().intValue()));
|
||||
}
|
||||
Iterator<byte[]> it3 = this.strings.iterator();
|
||||
while (it3.hasNext()) {
|
||||
byteArrayOutputStream.write(it3.next());
|
||||
}
|
||||
int i = this.stringsPaddingSize;
|
||||
if (i > 0) {
|
||||
byteArrayOutputStream.write(new byte[i]);
|
||||
}
|
||||
Iterator<List<StringStyledSpan>> it4 = this.styledSpans.iterator();
|
||||
while (it4.hasNext()) {
|
||||
Iterator<StringStyledSpan> it5 = it4.next().iterator();
|
||||
while (it5.hasNext()) {
|
||||
it5.next().writeTo(byteArrayOutputStream);
|
||||
}
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(-1));
|
||||
}
|
||||
}
|
||||
|
||||
private Pair<byte[], List<StringStyledSpan>> processString(String str) {
|
||||
return new Pair<>(this.utf8Encode ? ColorResourcesTableCreator.stringToByteArrayUtf8(str) : ColorResourcesTableCreator.stringToByteArray(str), Collections.emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
private static class StringStyledSpan {
|
||||
private int firstCharacterIndex;
|
||||
private int lastCharacterIndex;
|
||||
private int nameReference;
|
||||
private byte[] styleString;
|
||||
|
||||
private StringStyledSpan() {
|
||||
}
|
||||
|
||||
void writeTo(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.nameReference));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.firstCharacterIndex));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.lastCharacterIndex));
|
||||
}
|
||||
}
|
||||
|
||||
private static class PackageChunk {
|
||||
private static final short HEADER_SIZE = 288;
|
||||
private static final int PACKAGE_NAME_MAX_LENGTH = 128;
|
||||
private final ResChunkHeader header;
|
||||
private final StringPoolChunk keyStrings;
|
||||
private final PackageInfo packageInfo;
|
||||
private final TypeSpecChunk typeSpecChunk;
|
||||
private final StringPoolChunk typeStrings = new StringPoolChunk(false, "?1", "?2", "?3", "?4", "?5", "color");
|
||||
|
||||
PackageChunk(PackageInfo packageInfo, List<ColorResource> list) {
|
||||
this.packageInfo = packageInfo;
|
||||
String[] strArr = new String[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
strArr[i] = list.get(i).name;
|
||||
}
|
||||
this.keyStrings = new StringPoolChunk(true, strArr);
|
||||
this.typeSpecChunk = new TypeSpecChunk(list);
|
||||
this.header = new ResChunkHeader(ColorResourcesTableCreator.HEADER_TYPE_PACKAGE, HEADER_SIZE, getChunkSize());
|
||||
}
|
||||
|
||||
void writeTo(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
|
||||
this.header.writeTo(byteArrayOutputStream);
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.packageInfo.id));
|
||||
char[] charArray = this.packageInfo.name.toCharArray();
|
||||
for (int i = 0; i < 128; i++) {
|
||||
if (i < charArray.length) {
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.charToByteArray(charArray[i]));
|
||||
} else {
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.charToByteArray((char) 0));
|
||||
}
|
||||
}
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(288));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(0));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.typeStrings.getChunkSize() + 288));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(0));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(0));
|
||||
this.typeStrings.writeTo(byteArrayOutputStream);
|
||||
this.keyStrings.writeTo(byteArrayOutputStream);
|
||||
this.typeSpecChunk.writeTo(byteArrayOutputStream);
|
||||
}
|
||||
|
||||
int getChunkSize() {
|
||||
return this.typeStrings.getChunkSize() + 288 + this.keyStrings.getChunkSize() + this.typeSpecChunk.getChunkSizeWithTypeChunk();
|
||||
}
|
||||
}
|
||||
|
||||
private static class TypeSpecChunk {
|
||||
private static final short HEADER_SIZE = 16;
|
||||
private static final int SPEC_PUBLIC = 1073741824;
|
||||
private final int entryCount;
|
||||
private final int[] entryFlags;
|
||||
private final ResChunkHeader header;
|
||||
private final TypeChunk typeChunk;
|
||||
|
||||
private int getChunkSize() {
|
||||
return (this.entryCount * 4) + 16;
|
||||
}
|
||||
|
||||
TypeSpecChunk(List<ColorResource> list) {
|
||||
this.entryCount = list.get(list.size() - 1).entryId + ColorResourcesTableCreator.HEADER_TYPE_STRING_POOL;
|
||||
HashSet hashSet = new HashSet();
|
||||
Iterator<ColorResource> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
hashSet.add(Short.valueOf(it.next().entryId));
|
||||
}
|
||||
this.entryFlags = new int[this.entryCount];
|
||||
for (short s = 0; s < this.entryCount; s = (short) (s + ColorResourcesTableCreator.HEADER_TYPE_STRING_POOL)) {
|
||||
if (hashSet.contains(Short.valueOf(s))) {
|
||||
this.entryFlags[s] = 1073741824;
|
||||
}
|
||||
}
|
||||
this.header = new ResChunkHeader(ColorResourcesTableCreator.HEADER_TYPE_TYPE_SPEC, HEADER_SIZE, getChunkSize());
|
||||
this.typeChunk = new TypeChunk(list, hashSet, this.entryCount);
|
||||
}
|
||||
|
||||
void writeTo(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
|
||||
this.header.writeTo(byteArrayOutputStream);
|
||||
byteArrayOutputStream.write(new byte[]{ColorResourcesTableCreator.typeIdColor, 0, 0, 0});
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.entryCount));
|
||||
for (int i : this.entryFlags) {
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(i));
|
||||
}
|
||||
this.typeChunk.writeTo(byteArrayOutputStream);
|
||||
}
|
||||
|
||||
int getChunkSizeWithTypeChunk() {
|
||||
return getChunkSize() + this.typeChunk.getChunkSize();
|
||||
}
|
||||
}
|
||||
|
||||
private static class TypeChunk {
|
||||
private static final byte CONFIG_SIZE = 64;
|
||||
private static final short HEADER_SIZE = 84;
|
||||
private static final int OFFSET_NO_ENTRY = -1;
|
||||
private final byte[] config;
|
||||
private final int entryCount;
|
||||
private final ResChunkHeader header;
|
||||
private final int[] offsetTable;
|
||||
private final ResEntry[] resEntries;
|
||||
|
||||
TypeChunk(List<ColorResource> list, Set<Short> set, int i) {
|
||||
byte[] bArr = new byte[64];
|
||||
this.config = bArr;
|
||||
this.entryCount = i;
|
||||
bArr[0] = CONFIG_SIZE;
|
||||
this.resEntries = new ResEntry[list.size()];
|
||||
for (int i2 = 0; i2 < list.size(); i2++) {
|
||||
this.resEntries[i2] = new ResEntry(i2, list.get(i2).value);
|
||||
}
|
||||
this.offsetTable = new int[i];
|
||||
int i3 = 0;
|
||||
for (short s = 0; s < i; s = (short) (s + ColorResourcesTableCreator.HEADER_TYPE_STRING_POOL)) {
|
||||
if (set.contains(Short.valueOf(s))) {
|
||||
this.offsetTable[s] = i3;
|
||||
i3 += 16;
|
||||
} else {
|
||||
this.offsetTable[s] = -1;
|
||||
}
|
||||
}
|
||||
this.header = new ResChunkHeader(ColorResourcesTableCreator.HEADER_TYPE_TYPE, HEADER_SIZE, getChunkSize());
|
||||
}
|
||||
|
||||
void writeTo(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
|
||||
this.header.writeTo(byteArrayOutputStream);
|
||||
byteArrayOutputStream.write(new byte[]{ColorResourcesTableCreator.typeIdColor, 0, 0, 0});
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.entryCount));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(getEntryStart()));
|
||||
byteArrayOutputStream.write(this.config);
|
||||
for (int i : this.offsetTable) {
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(i));
|
||||
}
|
||||
for (ResEntry resEntry : this.resEntries) {
|
||||
resEntry.writeTo(byteArrayOutputStream);
|
||||
}
|
||||
}
|
||||
|
||||
int getChunkSize() {
|
||||
return getEntryStart() + (this.resEntries.length * 16);
|
||||
}
|
||||
|
||||
private int getEntryStart() {
|
||||
return getOffsetTableSize() + 84;
|
||||
}
|
||||
|
||||
private int getOffsetTableSize() {
|
||||
return this.offsetTable.length * 4;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ResEntry {
|
||||
private static final byte DATA_TYPE_AARRGGBB = 28;
|
||||
private static final short ENTRY_SIZE = 8;
|
||||
private static final short FLAG_PUBLIC = 2;
|
||||
private static final int SIZE = 16;
|
||||
private static final short VALUE_SIZE = 8;
|
||||
private final int data;
|
||||
private final int keyStringIndex;
|
||||
|
||||
ResEntry(int i, int i2) {
|
||||
this.keyStringIndex = i;
|
||||
this.data = i2;
|
||||
}
|
||||
|
||||
void writeTo(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.shortToByteArray((short) 8));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.shortToByteArray(FLAG_PUBLIC));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.keyStringIndex));
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.shortToByteArray((short) 8));
|
||||
byteArrayOutputStream.write(new byte[]{0, DATA_TYPE_AARRGGBB});
|
||||
byteArrayOutputStream.write(ColorResourcesTableCreator.intToByteArray(this.data));
|
||||
}
|
||||
}
|
||||
|
||||
static class PackageInfo {
|
||||
private final int id;
|
||||
private final String name;
|
||||
|
||||
PackageInfo(int i, String str) {
|
||||
this.id = i;
|
||||
this.name = str;
|
||||
}
|
||||
}
|
||||
|
||||
static class ColorResource {
|
||||
private final short entryId;
|
||||
private final String name;
|
||||
private final byte packageId;
|
||||
private final byte typeId;
|
||||
private final int value;
|
||||
|
||||
ColorResource(int i, String str, int i2) {
|
||||
this.name = str;
|
||||
this.value = i2;
|
||||
this.entryId = (short) (65535 & i);
|
||||
this.typeId = (byte) ((i >> 16) & 255);
|
||||
this.packageId = (byte) ((i >> 24) & 255);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static byte[] stringToByteArray(String str) {
|
||||
char[] charArray = str.toCharArray();
|
||||
int length = charArray.length * 2;
|
||||
byte[] bArr = new byte[length + 4];
|
||||
byte[] shortToByteArray = shortToByteArray((short) charArray.length);
|
||||
bArr[0] = shortToByteArray[0];
|
||||
bArr[1] = shortToByteArray[1];
|
||||
for (int i = 0; i < charArray.length; i++) {
|
||||
byte[] charToByteArray = charToByteArray(charArray[i]);
|
||||
int i2 = i * 2;
|
||||
bArr[i2 + 2] = charToByteArray[0];
|
||||
bArr[i2 + 3] = charToByteArray[1];
|
||||
}
|
||||
bArr[length + 2] = 0;
|
||||
bArr[length + 3] = 0;
|
||||
return bArr;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static byte[] stringToByteArrayUtf8(String str) {
|
||||
byte[] bytes = str.getBytes(Charset.forName("UTF-8"));
|
||||
byte length = (byte) bytes.length;
|
||||
int length2 = bytes.length;
|
||||
byte[] bArr = new byte[length2 + 3];
|
||||
System.arraycopy(bytes, 0, bArr, 2, length);
|
||||
bArr[1] = length;
|
||||
bArr[0] = length;
|
||||
bArr[length2 + 2] = 0;
|
||||
return bArr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ColorRoles {
|
||||
private final int accent;
|
||||
private final int accentContainer;
|
||||
private final int onAccent;
|
||||
private final int onAccentContainer;
|
||||
|
||||
public int getAccent() {
|
||||
return this.accent;
|
||||
}
|
||||
|
||||
public int getAccentContainer() {
|
||||
return this.accentContainer;
|
||||
}
|
||||
|
||||
public int getOnAccent() {
|
||||
return this.onAccent;
|
||||
}
|
||||
|
||||
public int getOnAccentContainer() {
|
||||
return this.onAccentContainer;
|
||||
}
|
||||
|
||||
ColorRoles(int i, int i2, int i3, int i4) {
|
||||
this.accent = i;
|
||||
this.onAccent = i2;
|
||||
this.accentContainer = i3;
|
||||
this.onAccentContainer = i4;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.app.UiModeManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import androidx.core.os.BuildCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.color.ColorResourcesOverride;
|
||||
import com.google.android.material.color.DynamicColorsOptions;
|
||||
import com.google.android.material.color.utilities.Hct;
|
||||
import com.google.android.material.color.utilities.SchemeContent;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DynamicColors {
|
||||
private static final DeviceSupportCondition DEFAULT_DEVICE_SUPPORT_CONDITION;
|
||||
private static final Map<String, DeviceSupportCondition> DYNAMIC_COLOR_SUPPORTED_BRANDS;
|
||||
private static final Map<String, DeviceSupportCondition> DYNAMIC_COLOR_SUPPORTED_MANUFACTURERS;
|
||||
private static final int[] DYNAMIC_COLOR_THEME_OVERLAY_ATTRIBUTE = {R.attr.dynamicColorThemeOverlay};
|
||||
private static final DeviceSupportCondition SAMSUNG_DEVICE_SUPPORT_CONDITION;
|
||||
private static final String TAG;
|
||||
private static final int USE_DEFAULT_THEME_OVERLAY = 0;
|
||||
|
||||
private interface DeviceSupportCondition {
|
||||
boolean isSupported();
|
||||
}
|
||||
|
||||
public interface OnAppliedCallback {
|
||||
void onApplied(Activity activity);
|
||||
}
|
||||
|
||||
public interface Precondition {
|
||||
boolean shouldApplyDynamicColors(Activity activity, int i);
|
||||
}
|
||||
|
||||
static {
|
||||
DeviceSupportCondition deviceSupportCondition = new DeviceSupportCondition() { // from class: com.google.android.material.color.DynamicColors.1
|
||||
@Override // com.google.android.material.color.DynamicColors.DeviceSupportCondition
|
||||
public boolean isSupported() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
DEFAULT_DEVICE_SUPPORT_CONDITION = deviceSupportCondition;
|
||||
DeviceSupportCondition deviceSupportCondition2 = new DeviceSupportCondition() { // from class: com.google.android.material.color.DynamicColors.2
|
||||
private Long version;
|
||||
|
||||
@Override // com.google.android.material.color.DynamicColors.DeviceSupportCondition
|
||||
public boolean isSupported() {
|
||||
if (this.version == null) {
|
||||
try {
|
||||
Method declaredMethod = Build.class.getDeclaredMethod("getLong", String.class);
|
||||
declaredMethod.setAccessible(true);
|
||||
this.version = Long.valueOf(((Long) declaredMethod.invoke(null, "ro.build.version.oneui")).longValue());
|
||||
} catch (Exception unused) {
|
||||
this.version = -1L;
|
||||
}
|
||||
}
|
||||
return this.version.longValue() >= 40100;
|
||||
}
|
||||
};
|
||||
SAMSUNG_DEVICE_SUPPORT_CONDITION = deviceSupportCondition2;
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put("fcnt", deviceSupportCondition);
|
||||
hashMap.put("google", deviceSupportCondition);
|
||||
hashMap.put("hmd global", deviceSupportCondition);
|
||||
hashMap.put("infinix", deviceSupportCondition);
|
||||
hashMap.put("infinix mobility limited", deviceSupportCondition);
|
||||
hashMap.put("itel", deviceSupportCondition);
|
||||
hashMap.put("kyocera", deviceSupportCondition);
|
||||
hashMap.put("lenovo", deviceSupportCondition);
|
||||
hashMap.put("lge", deviceSupportCondition);
|
||||
hashMap.put("meizu", deviceSupportCondition);
|
||||
hashMap.put("motorola", deviceSupportCondition);
|
||||
hashMap.put("nothing", deviceSupportCondition);
|
||||
hashMap.put("oneplus", deviceSupportCondition);
|
||||
hashMap.put("oppo", deviceSupportCondition);
|
||||
hashMap.put("realme", deviceSupportCondition);
|
||||
hashMap.put("robolectric", deviceSupportCondition);
|
||||
hashMap.put("samsung", deviceSupportCondition2);
|
||||
hashMap.put("sharp", deviceSupportCondition);
|
||||
hashMap.put("shift", deviceSupportCondition);
|
||||
hashMap.put("sony", deviceSupportCondition);
|
||||
hashMap.put("tcl", deviceSupportCondition);
|
||||
hashMap.put("tecno", deviceSupportCondition);
|
||||
hashMap.put("tecno mobile limited", deviceSupportCondition);
|
||||
hashMap.put("vivo", deviceSupportCondition);
|
||||
hashMap.put("wingtech", deviceSupportCondition);
|
||||
hashMap.put("xiaomi", deviceSupportCondition);
|
||||
DYNAMIC_COLOR_SUPPORTED_MANUFACTURERS = Collections.unmodifiableMap(hashMap);
|
||||
HashMap hashMap2 = new HashMap();
|
||||
hashMap2.put("asus", deviceSupportCondition);
|
||||
hashMap2.put("jio", deviceSupportCondition);
|
||||
DYNAMIC_COLOR_SUPPORTED_BRANDS = Collections.unmodifiableMap(hashMap2);
|
||||
TAG = "DynamicColors";
|
||||
}
|
||||
|
||||
private DynamicColors() {
|
||||
}
|
||||
|
||||
public static void applyToActivitiesIfAvailable(Application application) {
|
||||
applyToActivitiesIfAvailable(application, new DynamicColorsOptions.Builder().build());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void applyToActivitiesIfAvailable(Application application, int i) {
|
||||
applyToActivitiesIfAvailable(application, new DynamicColorsOptions.Builder().setThemeOverlay(i).build());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void applyToActivitiesIfAvailable(Application application, Precondition precondition) {
|
||||
applyToActivitiesIfAvailable(application, new DynamicColorsOptions.Builder().setPrecondition(precondition).build());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void applyToActivitiesIfAvailable(Application application, int i, Precondition precondition) {
|
||||
applyToActivitiesIfAvailable(application, new DynamicColorsOptions.Builder().setThemeOverlay(i).setPrecondition(precondition).build());
|
||||
}
|
||||
|
||||
public static void applyToActivitiesIfAvailable(Application application, DynamicColorsOptions dynamicColorsOptions) {
|
||||
application.registerActivityLifecycleCallbacks(new DynamicColorsActivityLifecycleCallbacks(dynamicColorsOptions));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void applyIfAvailable(Activity activity) {
|
||||
applyToActivityIfAvailable(activity);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void applyIfAvailable(Activity activity, int i) {
|
||||
applyToActivityIfAvailable(activity, new DynamicColorsOptions.Builder().setThemeOverlay(i).build());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void applyIfAvailable(Activity activity, Precondition precondition) {
|
||||
applyToActivityIfAvailable(activity, new DynamicColorsOptions.Builder().setPrecondition(precondition).build());
|
||||
}
|
||||
|
||||
public static void applyToActivityIfAvailable(Activity activity) {
|
||||
applyToActivityIfAvailable(activity, new DynamicColorsOptions.Builder().build());
|
||||
}
|
||||
|
||||
public static void applyToActivityIfAvailable(Activity activity, DynamicColorsOptions dynamicColorsOptions) {
|
||||
int i;
|
||||
if (isDynamicColorAvailable()) {
|
||||
if (dynamicColorsOptions.getContentBasedSeedColor() != null) {
|
||||
i = 0;
|
||||
} else if (dynamicColorsOptions.getThemeOverlay() == 0) {
|
||||
i = getDefaultThemeOverlay(activity, DYNAMIC_COLOR_THEME_OVERLAY_ATTRIBUTE);
|
||||
} else {
|
||||
i = dynamicColorsOptions.getThemeOverlay();
|
||||
}
|
||||
if (dynamicColorsOptions.getPrecondition().shouldApplyDynamicColors(activity, i)) {
|
||||
if (dynamicColorsOptions.getContentBasedSeedColor() != null) {
|
||||
SchemeContent schemeContent = new SchemeContent(Hct.fromInt(dynamicColorsOptions.getContentBasedSeedColor().intValue()), !MaterialColors.isLightTheme(activity), getSystemContrast(activity));
|
||||
ColorResourcesOverride cc = ColorResourcesOverride.CC.getInstance();
|
||||
if (cc == null || !cc.applyIfPossible(activity, MaterialColorUtilitiesHelper.createColorResourcesIdsToColorValues(schemeContent))) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ThemeUtils.applyThemeOverlay(activity, i);
|
||||
}
|
||||
dynamicColorsOptions.getOnAppliedCallback().onApplied(activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Context wrapContextIfAvailable(Context context) {
|
||||
return wrapContextIfAvailable(context, 0);
|
||||
}
|
||||
|
||||
public static Context wrapContextIfAvailable(Context context, int i) {
|
||||
return wrapContextIfAvailable(context, new DynamicColorsOptions.Builder().setThemeOverlay(i).build());
|
||||
}
|
||||
|
||||
public static Context wrapContextIfAvailable(Context context, DynamicColorsOptions dynamicColorsOptions) {
|
||||
if (!isDynamicColorAvailable()) {
|
||||
return context;
|
||||
}
|
||||
int themeOverlay = dynamicColorsOptions.getThemeOverlay();
|
||||
if (themeOverlay == 0) {
|
||||
themeOverlay = getDefaultThemeOverlay(context, DYNAMIC_COLOR_THEME_OVERLAY_ATTRIBUTE);
|
||||
}
|
||||
if (themeOverlay == 0) {
|
||||
return context;
|
||||
}
|
||||
if (dynamicColorsOptions.getContentBasedSeedColor() != null) {
|
||||
SchemeContent schemeContent = new SchemeContent(Hct.fromInt(dynamicColorsOptions.getContentBasedSeedColor().intValue()), !MaterialColors.isLightTheme(context), getSystemContrast(context));
|
||||
ColorResourcesOverride cc = ColorResourcesOverride.CC.getInstance();
|
||||
if (cc != null) {
|
||||
return cc.wrapContextIfPossible(context, MaterialColorUtilitiesHelper.createColorResourcesIdsToColorValues(schemeContent));
|
||||
}
|
||||
}
|
||||
return new ContextThemeWrapper(context, themeOverlay);
|
||||
}
|
||||
|
||||
public static boolean isDynamicColorAvailable() {
|
||||
if (Build.VERSION.SDK_INT < 31) {
|
||||
return false;
|
||||
}
|
||||
if (BuildCompat.isAtLeastT()) {
|
||||
return true;
|
||||
}
|
||||
DeviceSupportCondition deviceSupportCondition = DYNAMIC_COLOR_SUPPORTED_MANUFACTURERS.get(Build.MANUFACTURER.toLowerCase(Locale.ROOT));
|
||||
if (deviceSupportCondition == null) {
|
||||
deviceSupportCondition = DYNAMIC_COLOR_SUPPORTED_BRANDS.get(Build.BRAND.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
return deviceSupportCondition != null && deviceSupportCondition.isSupported();
|
||||
}
|
||||
|
||||
private static int getDefaultThemeOverlay(Context context, int[] iArr) {
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(iArr);
|
||||
int resourceId = obtainStyledAttributes.getResourceId(0, 0);
|
||||
obtainStyledAttributes.recycle();
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
private static class DynamicColorsActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
|
||||
private final DynamicColorsOptions dynamicColorsOptions;
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityCreated(Activity activity, Bundle bundle) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityPaused(Activity activity) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityResumed(Activity activity) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityStarted(Activity activity) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityStopped(Activity activity) {
|
||||
}
|
||||
|
||||
DynamicColorsActivityLifecycleCallbacks(DynamicColorsOptions dynamicColorsOptions) {
|
||||
this.dynamicColorsOptions = dynamicColorsOptions;
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityPreCreated(Activity activity, Bundle bundle) {
|
||||
DynamicColors.applyToActivityIfAvailable(activity, this.dynamicColorsOptions);
|
||||
}
|
||||
}
|
||||
|
||||
private static float getSystemContrast(Context context) {
|
||||
float contrast;
|
||||
UiModeManager uiModeManager = (UiModeManager) context.getSystemService("uimode");
|
||||
if (uiModeManager == null || Build.VERSION.SDK_INT < 34) {
|
||||
return 0.0f;
|
||||
}
|
||||
contrast = uiModeManager.getContrast();
|
||||
return contrast;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
import com.google.android.material.color.utilities.QuantizerCelebi;
|
||||
import com.google.android.material.color.utilities.Score;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DynamicColorsOptions {
|
||||
private static final DynamicColors.Precondition ALWAYS_ALLOW = new DynamicColors.Precondition() { // from class: com.google.android.material.color.DynamicColorsOptions.1
|
||||
@Override // com.google.android.material.color.DynamicColors.Precondition
|
||||
public boolean shouldApplyDynamicColors(Activity activity, int i) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
private static final DynamicColors.OnAppliedCallback NO_OP_CALLBACK = new DynamicColors.OnAppliedCallback() { // from class: com.google.android.material.color.DynamicColorsOptions.2
|
||||
@Override // com.google.android.material.color.DynamicColors.OnAppliedCallback
|
||||
public void onApplied(Activity activity) {
|
||||
}
|
||||
};
|
||||
private Integer contentBasedSeedColor;
|
||||
private final DynamicColors.OnAppliedCallback onAppliedCallback;
|
||||
private final DynamicColors.Precondition precondition;
|
||||
private final int themeOverlay;
|
||||
|
||||
public Integer getContentBasedSeedColor() {
|
||||
return this.contentBasedSeedColor;
|
||||
}
|
||||
|
||||
public DynamicColors.OnAppliedCallback getOnAppliedCallback() {
|
||||
return this.onAppliedCallback;
|
||||
}
|
||||
|
||||
public DynamicColors.Precondition getPrecondition() {
|
||||
return this.precondition;
|
||||
}
|
||||
|
||||
public int getThemeOverlay() {
|
||||
return this.themeOverlay;
|
||||
}
|
||||
|
||||
private DynamicColorsOptions(Builder builder) {
|
||||
this.themeOverlay = builder.themeOverlay;
|
||||
this.precondition = builder.precondition;
|
||||
this.onAppliedCallback = builder.onAppliedCallback;
|
||||
if (builder.contentBasedSourceColor != null) {
|
||||
this.contentBasedSeedColor = builder.contentBasedSourceColor;
|
||||
} else if (builder.contentBasedSourceBitmap != null) {
|
||||
this.contentBasedSeedColor = Integer.valueOf(extractSeedColorFromImage(builder.contentBasedSourceBitmap));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private Bitmap contentBasedSourceBitmap;
|
||||
private Integer contentBasedSourceColor;
|
||||
private int themeOverlay;
|
||||
private DynamicColors.Precondition precondition = DynamicColorsOptions.ALWAYS_ALLOW;
|
||||
private DynamicColors.OnAppliedCallback onAppliedCallback = DynamicColorsOptions.NO_OP_CALLBACK;
|
||||
|
||||
public Builder setContentBasedSource(Bitmap bitmap) {
|
||||
this.contentBasedSourceBitmap = bitmap;
|
||||
this.contentBasedSourceColor = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setOnAppliedCallback(DynamicColors.OnAppliedCallback onAppliedCallback) {
|
||||
this.onAppliedCallback = onAppliedCallback;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPrecondition(DynamicColors.Precondition precondition) {
|
||||
this.precondition = precondition;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setThemeOverlay(int i) {
|
||||
this.themeOverlay = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setContentBasedSource(int i) {
|
||||
this.contentBasedSourceBitmap = null;
|
||||
this.contentBasedSourceColor = Integer.valueOf(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DynamicColorsOptions build() {
|
||||
return new DynamicColorsOptions(this);
|
||||
}
|
||||
}
|
||||
|
||||
private static int extractSeedColorFromImage(Bitmap bitmap) {
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
int[] iArr = new int[width * height];
|
||||
bitmap.getPixels(iArr, 0, width, 0, 0, width, height);
|
||||
return Score.score(QuantizerCelebi.quantize(iArr, 128)).get(0).intValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import com.google.android.material.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class HarmonizedColorAttributes {
|
||||
private static final int[] HARMONIZED_MATERIAL_ATTRIBUTES = {R.attr.colorError, R.attr.colorOnError, R.attr.colorErrorContainer, R.attr.colorOnErrorContainer};
|
||||
private final int[] attributes;
|
||||
private final int themeOverlay;
|
||||
|
||||
public int[] getAttributes() {
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
public int getThemeOverlay() {
|
||||
return this.themeOverlay;
|
||||
}
|
||||
|
||||
public static HarmonizedColorAttributes create(int[] iArr) {
|
||||
return new HarmonizedColorAttributes(iArr, 0);
|
||||
}
|
||||
|
||||
public static HarmonizedColorAttributes create(int[] iArr, int i) {
|
||||
return new HarmonizedColorAttributes(iArr, i);
|
||||
}
|
||||
|
||||
public static HarmonizedColorAttributes createMaterialDefaults() {
|
||||
return create(HARMONIZED_MATERIAL_ATTRIBUTES, R.style.ThemeOverlay_Material3_HarmonizedColors);
|
||||
}
|
||||
|
||||
private HarmonizedColorAttributes(int[] iArr, int i) {
|
||||
if (i != 0 && iArr.length == 0) {
|
||||
throw new IllegalArgumentException("Theme overlay should be used with the accompanying int[] attributes.");
|
||||
}
|
||||
this.attributes = iArr;
|
||||
this.themeOverlay = i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.google.android.material.R;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HarmonizedColors {
|
||||
private static final String TAG = "HarmonizedColors";
|
||||
|
||||
public static boolean isHarmonizedColorAvailable() {
|
||||
return Build.VERSION.SDK_INT >= 30;
|
||||
}
|
||||
|
||||
private HarmonizedColors() {
|
||||
}
|
||||
|
||||
public static void applyToContextIfAvailable(Context context, HarmonizedColorsOptions harmonizedColorsOptions) {
|
||||
if (isHarmonizedColorAvailable()) {
|
||||
Map<Integer, Integer> createHarmonizedColorReplacementMap = createHarmonizedColorReplacementMap(context, harmonizedColorsOptions);
|
||||
int themeOverlayResourceId = harmonizedColorsOptions.getThemeOverlayResourceId(0);
|
||||
if (!ResourcesLoaderUtils.addResourcesLoaderToContext(context, createHarmonizedColorReplacementMap) || themeOverlayResourceId == 0) {
|
||||
return;
|
||||
}
|
||||
ThemeUtils.applyThemeOverlay(context, themeOverlayResourceId);
|
||||
}
|
||||
}
|
||||
|
||||
public static Context wrapContextIfAvailable(Context context, HarmonizedColorsOptions harmonizedColorsOptions) {
|
||||
if (!isHarmonizedColorAvailable()) {
|
||||
return context;
|
||||
}
|
||||
Map<Integer, Integer> createHarmonizedColorReplacementMap = createHarmonizedColorReplacementMap(context, harmonizedColorsOptions);
|
||||
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, harmonizedColorsOptions.getThemeOverlayResourceId(R.style.ThemeOverlay_Material3_HarmonizedColors_Empty));
|
||||
contextThemeWrapper.applyOverrideConfiguration(new Configuration());
|
||||
return ResourcesLoaderUtils.addResourcesLoaderToContext(contextThemeWrapper, createHarmonizedColorReplacementMap) ? contextThemeWrapper : context;
|
||||
}
|
||||
|
||||
private static Map<Integer, Integer> createHarmonizedColorReplacementMap(Context context, HarmonizedColorsOptions harmonizedColorsOptions) {
|
||||
HashMap hashMap = new HashMap();
|
||||
int color = MaterialColors.getColor(context, harmonizedColorsOptions.getColorAttributeToHarmonizeWith(), TAG);
|
||||
for (int i : harmonizedColorsOptions.getColorResourceIds()) {
|
||||
hashMap.put(Integer.valueOf(i), Integer.valueOf(MaterialColors.harmonize(ContextCompat.getColor(context, i), color)));
|
||||
}
|
||||
HarmonizedColorAttributes colorAttributes = harmonizedColorsOptions.getColorAttributes();
|
||||
if (colorAttributes != null) {
|
||||
int[] attributes = colorAttributes.getAttributes();
|
||||
if (attributes.length > 0) {
|
||||
int themeOverlay = colorAttributes.getThemeOverlay();
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributes);
|
||||
TypedArray obtainStyledAttributes2 = themeOverlay != 0 ? new ContextThemeWrapper(context, themeOverlay).obtainStyledAttributes(attributes) : null;
|
||||
addHarmonizedColorAttributesToReplacementMap(hashMap, obtainStyledAttributes, obtainStyledAttributes2, color);
|
||||
obtainStyledAttributes.recycle();
|
||||
if (obtainStyledAttributes2 != null) {
|
||||
obtainStyledAttributes2.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
private static void addHarmonizedColorAttributesToReplacementMap(Map<Integer, Integer> map, TypedArray typedArray, TypedArray typedArray2, int i) {
|
||||
if (typedArray2 == null) {
|
||||
typedArray2 = typedArray;
|
||||
}
|
||||
for (int i2 = 0; i2 < typedArray.getIndexCount(); i2++) {
|
||||
int resourceId = typedArray2.getResourceId(i2, 0);
|
||||
if (resourceId != 0 && typedArray.hasValue(i2) && ResourcesLoaderUtils.isColorResource(typedArray.getType(i2))) {
|
||||
map.put(Integer.valueOf(resourceId), Integer.valueOf(MaterialColors.harmonize(typedArray.getColor(i2, 0), i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import com.google.android.material.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HarmonizedColorsOptions {
|
||||
private final int colorAttributeToHarmonizeWith;
|
||||
private final HarmonizedColorAttributes colorAttributes;
|
||||
private final int[] colorResourceIds;
|
||||
|
||||
public int getColorAttributeToHarmonizeWith() {
|
||||
return this.colorAttributeToHarmonizeWith;
|
||||
}
|
||||
|
||||
public HarmonizedColorAttributes getColorAttributes() {
|
||||
return this.colorAttributes;
|
||||
}
|
||||
|
||||
public int[] getColorResourceIds() {
|
||||
return this.colorResourceIds;
|
||||
}
|
||||
|
||||
public static HarmonizedColorsOptions createMaterialDefaults() {
|
||||
return new Builder().setColorAttributes(HarmonizedColorAttributes.createMaterialDefaults()).build();
|
||||
}
|
||||
|
||||
private HarmonizedColorsOptions(Builder builder) {
|
||||
this.colorResourceIds = builder.colorResourceIds;
|
||||
this.colorAttributes = builder.colorAttributes;
|
||||
this.colorAttributeToHarmonizeWith = builder.colorAttributeToHarmonizeWith;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private HarmonizedColorAttributes colorAttributes;
|
||||
private int[] colorResourceIds = new int[0];
|
||||
private int colorAttributeToHarmonizeWith = R.attr.colorPrimary;
|
||||
|
||||
public Builder setColorAttributeToHarmonizeWith(int i) {
|
||||
this.colorAttributeToHarmonizeWith = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setColorAttributes(HarmonizedColorAttributes harmonizedColorAttributes) {
|
||||
this.colorAttributes = harmonizedColorAttributes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setColorResourceIds(int[] iArr) {
|
||||
this.colorResourceIds = iArr;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HarmonizedColorsOptions build() {
|
||||
return new HarmonizedColorsOptions(this);
|
||||
}
|
||||
}
|
||||
|
||||
int getThemeOverlayResourceId(int i) {
|
||||
HarmonizedColorAttributes harmonizedColorAttributes = this.colorAttributes;
|
||||
return (harmonizedColorAttributes == null || harmonizedColorAttributes.getThemeOverlay() == 0) ? i : this.colorAttributes.getThemeOverlay();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.color.utilities.DynamicColor;
|
||||
import com.google.android.material.color.utilities.DynamicScheme;
|
||||
import com.google.android.material.color.utilities.MaterialDynamicColors;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MaterialColorUtilitiesHelper {
|
||||
private static final Map<Integer, DynamicColor> colorResourceIdToColorValue;
|
||||
private static final MaterialDynamicColors dynamicColors;
|
||||
|
||||
private MaterialColorUtilitiesHelper() {
|
||||
}
|
||||
|
||||
static {
|
||||
MaterialDynamicColors materialDynamicColors = new MaterialDynamicColors();
|
||||
dynamicColors = materialDynamicColors;
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_primary), materialDynamicColors.primary());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_primary), materialDynamicColors.onPrimary());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_primary_inverse), materialDynamicColors.inversePrimary());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_primary_container), materialDynamicColors.primaryContainer());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_primary_container), materialDynamicColors.onPrimaryContainer());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_secondary), materialDynamicColors.secondary());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_secondary), materialDynamicColors.onSecondary());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_secondary_container), materialDynamicColors.secondaryContainer());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_secondary_container), materialDynamicColors.onSecondaryContainer());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_tertiary), materialDynamicColors.tertiary());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_tertiary), materialDynamicColors.onTertiary());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_tertiary_container), materialDynamicColors.tertiaryContainer());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_tertiary_container), materialDynamicColors.onTertiaryContainer());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_background), materialDynamicColors.background());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_background), materialDynamicColors.onBackground());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface), materialDynamicColors.surface());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_surface), materialDynamicColors.onSurface());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface_variant), materialDynamicColors.surfaceVariant());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_surface_variant), materialDynamicColors.onSurfaceVariant());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface_inverse), materialDynamicColors.inverseSurface());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_surface_inverse), materialDynamicColors.inverseOnSurface());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface_bright), materialDynamicColors.surfaceBright());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface_dim), materialDynamicColors.surfaceDim());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface_container), materialDynamicColors.surfaceContainer());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface_container_low), materialDynamicColors.surfaceContainerLow());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface_container_high), materialDynamicColors.surfaceContainerHigh());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface_container_lowest), materialDynamicColors.surfaceContainerLowest());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_surface_container_highest), materialDynamicColors.surfaceContainerHighest());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_outline), materialDynamicColors.outline());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_outline_variant), materialDynamicColors.outlineVariant());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_error), materialDynamicColors.error());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_error), materialDynamicColors.onError());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_error_container), materialDynamicColors.errorContainer());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_on_error_container), materialDynamicColors.onErrorContainer());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_control_activated), materialDynamicColors.controlActivated());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_control_normal), materialDynamicColors.controlNormal());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_control_highlight), materialDynamicColors.controlHighlight());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_text_primary_inverse), materialDynamicColors.textPrimaryInverse());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_text_secondary_and_tertiary_inverse), materialDynamicColors.textSecondaryAndTertiaryInverse());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_text_secondary_and_tertiary_inverse_disabled), materialDynamicColors.textSecondaryAndTertiaryInverseDisabled());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_text_primary_inverse_disable_only), materialDynamicColors.textPrimaryInverseDisableOnly());
|
||||
hashMap.put(Integer.valueOf(R.color.material_personalized_color_text_hint_foreground_inverse), materialDynamicColors.textHintInverse());
|
||||
colorResourceIdToColorValue = Collections.unmodifiableMap(hashMap);
|
||||
}
|
||||
|
||||
public static Map<Integer, Integer> createColorResourcesIdsToColorValues(DynamicScheme dynamicScheme) {
|
||||
HashMap hashMap = new HashMap();
|
||||
for (Map.Entry<Integer, DynamicColor> entry : colorResourceIdToColorValue.entrySet()) {
|
||||
hashMap.put(entry.getKey(), Integer.valueOf(entry.getValue().getArgb(dynamicScheme)));
|
||||
}
|
||||
return Collections.unmodifiableMap(hashMap);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.color.utilities.Blend;
|
||||
import com.google.android.material.color.utilities.Hct;
|
||||
import com.google.android.material.resources.MaterialAttributes;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MaterialColors {
|
||||
public static final float ALPHA_DISABLED = 0.38f;
|
||||
public static final float ALPHA_DISABLED_LOW = 0.12f;
|
||||
public static final float ALPHA_FULL = 1.0f;
|
||||
public static final float ALPHA_LOW = 0.32f;
|
||||
public static final float ALPHA_MEDIUM = 0.54f;
|
||||
private static final int CHROMA_NEUTRAL = 6;
|
||||
private static final int TONE_ACCENT_CONTAINER_DARK = 30;
|
||||
private static final int TONE_ACCENT_CONTAINER_LIGHT = 90;
|
||||
private static final int TONE_ACCENT_DARK = 80;
|
||||
private static final int TONE_ACCENT_LIGHT = 40;
|
||||
private static final int TONE_ON_ACCENT_CONTAINER_DARK = 90;
|
||||
private static final int TONE_ON_ACCENT_CONTAINER_LIGHT = 10;
|
||||
private static final int TONE_ON_ACCENT_DARK = 20;
|
||||
private static final int TONE_ON_ACCENT_LIGHT = 100;
|
||||
private static final int TONE_SURFACE_CONTAINER_DARK = 12;
|
||||
private static final int TONE_SURFACE_CONTAINER_HIGH_DARK = 17;
|
||||
private static final int TONE_SURFACE_CONTAINER_HIGH_LIGHT = 92;
|
||||
private static final int TONE_SURFACE_CONTAINER_LIGHT = 94;
|
||||
|
||||
private MaterialColors() {
|
||||
}
|
||||
|
||||
public static int getColor(View view, int i) {
|
||||
return resolveColor(view.getContext(), MaterialAttributes.resolveTypedValueOrThrow(view, i));
|
||||
}
|
||||
|
||||
public static int getColor(Context context, int i, String str) {
|
||||
return resolveColor(context, MaterialAttributes.resolveTypedValueOrThrow(context, i, str));
|
||||
}
|
||||
|
||||
public static int getColor(View view, int i, int i2) {
|
||||
return getColor(view.getContext(), i, i2);
|
||||
}
|
||||
|
||||
public static int getColor(Context context, int i, int i2) {
|
||||
Integer colorOrNull = getColorOrNull(context, i);
|
||||
return colorOrNull != null ? colorOrNull.intValue() : i2;
|
||||
}
|
||||
|
||||
public static Integer getColorOrNull(Context context, int i) {
|
||||
TypedValue resolve = MaterialAttributes.resolve(context, i);
|
||||
if (resolve != null) {
|
||||
return Integer.valueOf(resolveColor(context, resolve));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ColorStateList getColorStateList(Context context, int i, ColorStateList colorStateList) {
|
||||
TypedValue resolve = MaterialAttributes.resolve(context, i);
|
||||
ColorStateList resolveColorStateList = resolve != null ? resolveColorStateList(context, resolve) : null;
|
||||
return resolveColorStateList == null ? colorStateList : resolveColorStateList;
|
||||
}
|
||||
|
||||
public static ColorStateList getColorStateListOrNull(Context context, int i) {
|
||||
TypedValue resolve = MaterialAttributes.resolve(context, i);
|
||||
if (resolve == null) {
|
||||
return null;
|
||||
}
|
||||
if (resolve.resourceId != 0) {
|
||||
return ContextCompat.getColorStateList(context, resolve.resourceId);
|
||||
}
|
||||
if (resolve.data != 0) {
|
||||
return ColorStateList.valueOf(resolve.data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int resolveColor(Context context, TypedValue typedValue) {
|
||||
if (typedValue.resourceId != 0) {
|
||||
return ContextCompat.getColor(context, typedValue.resourceId);
|
||||
}
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
private static ColorStateList resolveColorStateList(Context context, TypedValue typedValue) {
|
||||
if (typedValue.resourceId != 0) {
|
||||
return ContextCompat.getColorStateList(context, typedValue.resourceId);
|
||||
}
|
||||
return ColorStateList.valueOf(typedValue.data);
|
||||
}
|
||||
|
||||
public static int layer(View view, int i, int i2) {
|
||||
return layer(view, i, i2, 1.0f);
|
||||
}
|
||||
|
||||
public static int layer(View view, int i, int i2, float f) {
|
||||
return layer(getColor(view, i), getColor(view, i2), f);
|
||||
}
|
||||
|
||||
public static int layer(int i, int i2, float f) {
|
||||
return layer(i, ColorUtils.setAlphaComponent(i2, Math.round(Color.alpha(i2) * f)));
|
||||
}
|
||||
|
||||
public static int layer(int i, int i2) {
|
||||
return ColorUtils.compositeColors(i2, i);
|
||||
}
|
||||
|
||||
public static int compositeARGBWithAlpha(int i, int i2) {
|
||||
return ColorUtils.setAlphaComponent(i, (Color.alpha(i) * i2) / 255);
|
||||
}
|
||||
|
||||
public static boolean isColorLight(int i) {
|
||||
return i != 0 && ColorUtils.calculateLuminance(i) > 0.5d;
|
||||
}
|
||||
|
||||
public static int harmonizeWithPrimary(Context context, int i) {
|
||||
return harmonize(i, getColor(context, R.attr.colorPrimary, MaterialColors.class.getCanonicalName()));
|
||||
}
|
||||
|
||||
public static int harmonize(int i, int i2) {
|
||||
return Blend.harmonize(i, i2);
|
||||
}
|
||||
|
||||
public static ColorRoles getColorRoles(Context context, int i) {
|
||||
return getColorRoles(i, isLightTheme(context));
|
||||
}
|
||||
|
||||
public static ColorRoles getColorRoles(int i, boolean z) {
|
||||
if (z) {
|
||||
return new ColorRoles(getColorRole(i, 40), getColorRole(i, 100), getColorRole(i, 90), getColorRole(i, 10));
|
||||
}
|
||||
return new ColorRoles(getColorRole(i, 80), getColorRole(i, 20), getColorRole(i, 30), getColorRole(i, 90));
|
||||
}
|
||||
|
||||
public static int getSurfaceContainerFromSeed(Context context, int i) {
|
||||
return getColorRole(i, isLightTheme(context) ? 94 : 12, 6);
|
||||
}
|
||||
|
||||
public static int getSurfaceContainerHighFromSeed(Context context, int i) {
|
||||
return getColorRole(i, isLightTheme(context) ? 92 : 17, 6);
|
||||
}
|
||||
|
||||
static boolean isLightTheme(Context context) {
|
||||
return MaterialAttributes.resolveBoolean(context, R.attr.isLightTheme, true);
|
||||
}
|
||||
|
||||
private static int getColorRole(int i, int i2) {
|
||||
Hct fromInt = Hct.fromInt(i);
|
||||
fromInt.setTone(i2);
|
||||
return fromInt.toInt();
|
||||
}
|
||||
|
||||
private static int getColorRole(int i, int i2, int i3) {
|
||||
Hct fromInt = Hct.fromInt(getColorRole(i, i2));
|
||||
fromInt.setChroma(i3);
|
||||
return fromInt.toInt();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import com.google.android.material.R;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ResourcesLoaderColorResourcesOverride implements ColorResourcesOverride {
|
||||
private ResourcesLoaderColorResourcesOverride() {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.color.ColorResourcesOverride
|
||||
public boolean applyIfPossible(Context context, Map<Integer, Integer> map) {
|
||||
if (!ResourcesLoaderUtils.addResourcesLoaderToContext(context, map)) {
|
||||
return false;
|
||||
}
|
||||
ThemeUtils.applyThemeOverlay(context, R.style.ThemeOverlay_Material3_PersonalizedColors);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.color.ColorResourcesOverride
|
||||
public Context wrapContextIfPossible(Context context, Map<Integer, Integer> map) {
|
||||
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, R.style.ThemeOverlay_Material3_PersonalizedColors);
|
||||
contextThemeWrapper.applyOverrideConfiguration(new Configuration());
|
||||
return ResourcesLoaderUtils.addResourcesLoaderToContext(contextThemeWrapper, map) ? contextThemeWrapper : context;
|
||||
}
|
||||
|
||||
static ColorResourcesOverride getInstance() {
|
||||
return ResourcesLoaderColorResourcesOverrideSingleton.INSTANCE;
|
||||
}
|
||||
|
||||
private static class ResourcesLoaderColorResourcesOverrideSingleton {
|
||||
private static final ResourcesLoaderColorResourcesOverride INSTANCE = new ResourcesLoaderColorResourcesOverride();
|
||||
|
||||
private ResourcesLoaderColorResourcesOverrideSingleton() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.loader.ResourcesLoader;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class ResourcesLoaderUtils {
|
||||
static boolean isColorResource(int i) {
|
||||
return 28 <= i && i <= 31;
|
||||
}
|
||||
|
||||
private ResourcesLoaderUtils() {
|
||||
}
|
||||
|
||||
static boolean addResourcesLoaderToContext(Context context, Map<Integer, Integer> map) {
|
||||
ResourcesLoader create = ColorResourcesLoaderCreator.create(context, map);
|
||||
if (create == null) {
|
||||
return false;
|
||||
}
|
||||
context.getResources().addLoaders(create);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.google.android.material.color;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ThemeUtils {
|
||||
private ThemeUtils() {
|
||||
}
|
||||
|
||||
public static void applyThemeOverlay(Context context, int i) {
|
||||
Resources.Theme windowDecorViewTheme;
|
||||
context.getTheme().applyStyle(i, true);
|
||||
if (!(context instanceof Activity) || (windowDecorViewTheme = getWindowDecorViewTheme((Activity) context)) == null) {
|
||||
return;
|
||||
}
|
||||
windowDecorViewTheme.applyStyle(i, true);
|
||||
}
|
||||
|
||||
private static Resources.Theme getWindowDecorViewTheme(Activity activity) {
|
||||
View peekDecorView;
|
||||
Context context;
|
||||
Window window = activity.getWindow();
|
||||
if (window == null || (peekDecorView = window.peekDecorView()) == null || (context = peekDecorView.getContext()) == null) {
|
||||
return null;
|
||||
}
|
||||
return context.getTheme();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Blend {
|
||||
private Blend() {
|
||||
}
|
||||
|
||||
public static int harmonize(int i, int i2) {
|
||||
Hct fromInt = Hct.fromInt(i);
|
||||
Hct fromInt2 = Hct.fromInt(i2);
|
||||
return Hct.from(MathUtils.sanitizeDegreesDouble(fromInt.getHue() + (Math.min(MathUtils.differenceDegrees(fromInt.getHue(), fromInt2.getHue()) * 0.5d, 15.0d) * MathUtils.rotationDirection(fromInt.getHue(), fromInt2.getHue()))), fromInt.getChroma(), fromInt.getTone()).toInt();
|
||||
}
|
||||
|
||||
public static int hctHue(int i, int i2, double d) {
|
||||
return Hct.from(Cam16.fromInt(cam16Ucs(i, i2, d)).getHue(), Cam16.fromInt(i).getChroma(), ColorUtils.lstarFromArgb(i)).toInt();
|
||||
}
|
||||
|
||||
public static int cam16Ucs(int i, int i2, double d) {
|
||||
Cam16 fromInt = Cam16.fromInt(i);
|
||||
Cam16 fromInt2 = Cam16.fromInt(i2);
|
||||
double jstar = fromInt.getJstar();
|
||||
double astar = fromInt.getAstar();
|
||||
double bstar = fromInt.getBstar();
|
||||
return Cam16.fromUcs(jstar + ((fromInt2.getJstar() - jstar) * d), astar + ((fromInt2.getAstar() - astar) * d), bstar + ((fromInt2.getBstar() - bstar) * d)).toInt();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Cam16 {
|
||||
private final double astar;
|
||||
private final double bstar;
|
||||
private final double chroma;
|
||||
private final double hue;
|
||||
private final double j;
|
||||
private final double jstar;
|
||||
private final double m;
|
||||
private final double q;
|
||||
private final double s;
|
||||
private final double[] tempArray = {0.0d, 0.0d, 0.0d};
|
||||
static final double[][] XYZ_TO_CAM16RGB = {new double[]{0.401288d, 0.650173d, -0.051461d}, new double[]{-0.250268d, 1.204414d, 0.045854d}, new double[]{-0.002079d, 0.048952d, 0.953127d}};
|
||||
static final double[][] CAM16RGB_TO_XYZ = {new double[]{1.8620678d, -1.0112547d, 0.14918678d}, new double[]{0.38752654d, 0.62144744d, -0.00897398d}, new double[]{-0.0158415d, -0.03412294d, 1.0499644d}};
|
||||
|
||||
public double getAstar() {
|
||||
return this.astar;
|
||||
}
|
||||
|
||||
public double getBstar() {
|
||||
return this.bstar;
|
||||
}
|
||||
|
||||
public double getChroma() {
|
||||
return this.chroma;
|
||||
}
|
||||
|
||||
public double getHue() {
|
||||
return this.hue;
|
||||
}
|
||||
|
||||
public double getJ() {
|
||||
return this.j;
|
||||
}
|
||||
|
||||
public double getJstar() {
|
||||
return this.jstar;
|
||||
}
|
||||
|
||||
public double getM() {
|
||||
return this.m;
|
||||
}
|
||||
|
||||
public double getQ() {
|
||||
return this.q;
|
||||
}
|
||||
|
||||
public double getS() {
|
||||
return this.s;
|
||||
}
|
||||
|
||||
double distance(Cam16 cam16) {
|
||||
double jstar = getJstar() - cam16.getJstar();
|
||||
double astar = getAstar() - cam16.getAstar();
|
||||
double bstar = getBstar() - cam16.getBstar();
|
||||
return Math.pow(Math.sqrt((jstar * jstar) + (astar * astar) + (bstar * bstar)), 0.63d) * 1.41d;
|
||||
}
|
||||
|
||||
private Cam16(double d, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9) {
|
||||
this.hue = d;
|
||||
this.chroma = d2;
|
||||
this.j = d3;
|
||||
this.q = d4;
|
||||
this.m = d5;
|
||||
this.s = d6;
|
||||
this.jstar = d7;
|
||||
this.astar = d8;
|
||||
this.bstar = d9;
|
||||
}
|
||||
|
||||
public static Cam16 fromInt(int i) {
|
||||
return fromIntInViewingConditions(i, ViewingConditions.DEFAULT);
|
||||
}
|
||||
|
||||
static Cam16 fromIntInViewingConditions(int i, ViewingConditions viewingConditions) {
|
||||
double linearized = ColorUtils.linearized((16711680 & i) >> 16);
|
||||
double linearized2 = ColorUtils.linearized((65280 & i) >> 8);
|
||||
double linearized3 = ColorUtils.linearized(i & 255);
|
||||
return fromXyzInViewingConditions((0.41233895d * linearized) + (0.35762064d * linearized2) + (0.18051042d * linearized3), (0.2126d * linearized) + (0.7152d * linearized2) + (0.0722d * linearized3), (linearized * 0.01932141d) + (linearized2 * 0.11916382d) + (linearized3 * 0.95034478d), viewingConditions);
|
||||
}
|
||||
|
||||
static Cam16 fromXyzInViewingConditions(double d, double d2, double d3, ViewingConditions viewingConditions) {
|
||||
double[][] dArr = XYZ_TO_CAM16RGB;
|
||||
double[] dArr2 = dArr[0];
|
||||
double d4 = (dArr2[0] * d) + (dArr2[1] * d2) + (dArr2[2] * d3);
|
||||
double[] dArr3 = dArr[1];
|
||||
double d5 = (dArr3[0] * d) + (dArr3[1] * d2) + (dArr3[2] * d3);
|
||||
double[] dArr4 = dArr[2];
|
||||
double d6 = (dArr4[0] * d) + (dArr4[1] * d2) + (dArr4[2] * d3);
|
||||
double d7 = viewingConditions.getRgbD()[0] * d4;
|
||||
double d8 = viewingConditions.getRgbD()[1] * d5;
|
||||
double d9 = viewingConditions.getRgbD()[2] * d6;
|
||||
double pow = Math.pow((viewingConditions.getFl() * Math.abs(d7)) / 100.0d, 0.42d);
|
||||
double pow2 = Math.pow((viewingConditions.getFl() * Math.abs(d8)) / 100.0d, 0.42d);
|
||||
double pow3 = Math.pow((viewingConditions.getFl() * Math.abs(d9)) / 100.0d, 0.42d);
|
||||
double signum = ((Math.signum(d7) * 400.0d) * pow) / (pow + 27.13d);
|
||||
double signum2 = ((Math.signum(d8) * 400.0d) * pow2) / (pow2 + 27.13d);
|
||||
double signum3 = ((Math.signum(d9) * 400.0d) * pow3) / (pow3 + 27.13d);
|
||||
double d10 = (((signum * 11.0d) + ((-12.0d) * signum2)) + signum3) / 11.0d;
|
||||
double d11 = ((signum + signum2) - (signum3 * 2.0d)) / 9.0d;
|
||||
double d12 = signum2 * 20.0d;
|
||||
double d13 = (((signum * 20.0d) + d12) + (21.0d * signum3)) / 20.0d;
|
||||
double d14 = (((signum * 40.0d) + d12) + signum3) / 20.0d;
|
||||
double degrees = Math.toDegrees(Math.atan2(d11, d10));
|
||||
if (degrees < 0.0d) {
|
||||
degrees += 360.0d;
|
||||
} else if (degrees >= 360.0d) {
|
||||
degrees -= 360.0d;
|
||||
}
|
||||
double d15 = degrees;
|
||||
double radians = Math.toRadians(d15);
|
||||
double pow4 = Math.pow((d14 * viewingConditions.getNbb()) / viewingConditions.getAw(), viewingConditions.getC() * viewingConditions.getZ()) * 100.0d;
|
||||
double d16 = pow4 / 100.0d;
|
||||
double c = (4.0d / viewingConditions.getC()) * Math.sqrt(d16) * (viewingConditions.getAw() + 4.0d) * viewingConditions.getFlRoot();
|
||||
double pow5 = Math.pow(1.64d - Math.pow(0.29d, viewingConditions.getN()), 0.73d) * Math.pow(((((((Math.cos(Math.toRadians(d15 < 20.14d ? d15 + 360.0d : d15) + 2.0d) + 3.8d) * 0.25d) * 3846.153846153846d) * viewingConditions.getNc()) * viewingConditions.getNcb()) * Math.hypot(d10, d11)) / (d13 + 0.305d), 0.9d);
|
||||
double sqrt = Math.sqrt(d16) * pow5;
|
||||
double flRoot = sqrt * viewingConditions.getFlRoot();
|
||||
double log1p = Math.log1p(flRoot * 0.0228d) * 43.859649122807014d;
|
||||
return new Cam16(d15, sqrt, pow4, c, flRoot, Math.sqrt((pow5 * viewingConditions.getC()) / (viewingConditions.getAw() + 4.0d)) * 50.0d, (1.7000000000000002d * pow4) / ((0.007d * pow4) + 1.0d), log1p * Math.cos(radians), log1p * Math.sin(radians));
|
||||
}
|
||||
|
||||
static Cam16 fromJch(double d, double d2, double d3) {
|
||||
return fromJchInViewingConditions(d, d2, d3, ViewingConditions.DEFAULT);
|
||||
}
|
||||
|
||||
private static Cam16 fromJchInViewingConditions(double d, double d2, double d3, ViewingConditions viewingConditions) {
|
||||
double d4 = d / 100.0d;
|
||||
double c = (4.0d / viewingConditions.getC()) * Math.sqrt(d4) * (viewingConditions.getAw() + 4.0d) * viewingConditions.getFlRoot();
|
||||
double flRoot = d2 * viewingConditions.getFlRoot();
|
||||
double sqrt = Math.sqrt(((d2 / Math.sqrt(d4)) * viewingConditions.getC()) / (viewingConditions.getAw() + 4.0d)) * 50.0d;
|
||||
double radians = Math.toRadians(d3);
|
||||
double d5 = (1.7000000000000002d * d) / ((0.007d * d) + 1.0d);
|
||||
double log1p = 43.859649122807014d * Math.log1p(flRoot * 0.0228d);
|
||||
return new Cam16(d3, d2, d, c, flRoot, sqrt, d5, Math.cos(radians) * log1p, Math.sin(radians) * log1p);
|
||||
}
|
||||
|
||||
public static Cam16 fromUcs(double d, double d2, double d3) {
|
||||
return fromUcsInViewingConditions(d, d2, d3, ViewingConditions.DEFAULT);
|
||||
}
|
||||
|
||||
public static Cam16 fromUcsInViewingConditions(double d, double d2, double d3, ViewingConditions viewingConditions) {
|
||||
double expm1 = (Math.expm1(Math.hypot(d2, d3) * 0.0228d) / 0.0228d) / viewingConditions.getFlRoot();
|
||||
double atan2 = Math.atan2(d3, d2) * 57.29577951308232d;
|
||||
if (atan2 < 0.0d) {
|
||||
atan2 += 360.0d;
|
||||
}
|
||||
return fromJchInViewingConditions(d / (1.0d - ((d - 100.0d) * 0.007d)), expm1, atan2, viewingConditions);
|
||||
}
|
||||
|
||||
public int toInt() {
|
||||
return viewed(ViewingConditions.DEFAULT);
|
||||
}
|
||||
|
||||
int viewed(ViewingConditions viewingConditions) {
|
||||
double[] xyzInViewingConditions = xyzInViewingConditions(viewingConditions, this.tempArray);
|
||||
return ColorUtils.argbFromXyz(xyzInViewingConditions[0], xyzInViewingConditions[1], xyzInViewingConditions[2]);
|
||||
}
|
||||
|
||||
double[] xyzInViewingConditions(ViewingConditions viewingConditions, double[] dArr) {
|
||||
double pow = Math.pow(((getChroma() == 0.0d || getJ() == 0.0d) ? 0.0d : getChroma() / Math.sqrt(getJ() / 100.0d)) / Math.pow(1.64d - Math.pow(0.29d, viewingConditions.getN()), 0.73d), 1.1111111111111112d);
|
||||
double radians = Math.toRadians(getHue());
|
||||
double cos = (Math.cos(2.0d + radians) + 3.8d) * 0.25d;
|
||||
double aw = viewingConditions.getAw() * Math.pow(getJ() / 100.0d, (1.0d / viewingConditions.getC()) / viewingConditions.getZ());
|
||||
double nc = cos * 3846.153846153846d * viewingConditions.getNc() * viewingConditions.getNcb();
|
||||
double nbb = aw / viewingConditions.getNbb();
|
||||
double sin = Math.sin(radians);
|
||||
double cos2 = Math.cos(radians);
|
||||
double d = (((0.305d + nbb) * 23.0d) * pow) / (((nc * 23.0d) + ((11.0d * pow) * cos2)) + ((pow * 108.0d) * sin));
|
||||
double d2 = cos2 * d;
|
||||
double d3 = d * sin;
|
||||
double d4 = nbb * 460.0d;
|
||||
double d5 = (((451.0d * d2) + d4) + (288.0d * d3)) / 1403.0d;
|
||||
double d6 = ((d4 - (891.0d * d2)) - (261.0d * d3)) / 1403.0d;
|
||||
double d7 = ((d4 - (d2 * 220.0d)) - (d3 * 6300.0d)) / 1403.0d;
|
||||
double signum = Math.signum(d5) * (100.0d / viewingConditions.getFl()) * Math.pow(Math.max(0.0d, (Math.abs(d5) * 27.13d) / (400.0d - Math.abs(d5))), 2.380952380952381d);
|
||||
double signum2 = Math.signum(d6) * (100.0d / viewingConditions.getFl()) * Math.pow(Math.max(0.0d, (Math.abs(d6) * 27.13d) / (400.0d - Math.abs(d6))), 2.380952380952381d);
|
||||
double signum3 = Math.signum(d7) * (100.0d / viewingConditions.getFl()) * Math.pow(Math.max(0.0d, (Math.abs(d7) * 27.13d) / (400.0d - Math.abs(d7))), 2.380952380952381d);
|
||||
double d8 = signum / viewingConditions.getRgbD()[0];
|
||||
double d9 = signum2 / viewingConditions.getRgbD()[1];
|
||||
double d10 = signum3 / viewingConditions.getRgbD()[2];
|
||||
double[][] dArr2 = CAM16RGB_TO_XYZ;
|
||||
double[] dArr3 = dArr2[0];
|
||||
double d11 = (dArr3[0] * d8) + (dArr3[1] * d9) + (dArr3[2] * d10);
|
||||
double[] dArr4 = dArr2[1];
|
||||
double d12 = (dArr4[0] * d8) + (dArr4[1] * d9) + (dArr4[2] * d10);
|
||||
double[] dArr5 = dArr2[2];
|
||||
double d13 = (d8 * dArr5[0]) + (d9 * dArr5[1]) + (d10 * dArr5[2]);
|
||||
if (dArr == null) {
|
||||
return new double[]{d11, d12, d13};
|
||||
}
|
||||
dArr[0] = d11;
|
||||
dArr[1] = d12;
|
||||
dArr[2] = d13;
|
||||
return dArr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ColorUtils {
|
||||
static final double[][] SRGB_TO_XYZ = {new double[]{0.41233895d, 0.35762064d, 0.18051042d}, new double[]{0.2126d, 0.7152d, 0.0722d}, new double[]{0.01932141d, 0.11916382d, 0.95034478d}};
|
||||
static final double[][] XYZ_TO_SRGB = {new double[]{3.2413774792388685d, -1.5376652402851851d, -0.49885366846268053d}, new double[]{-0.9691452513005321d, 1.8758853451067872d, 0.04156585616912061d}, new double[]{0.05562093689691305d, -0.20395524564742123d, 1.0571799111220335d}};
|
||||
static final double[] WHITE_POINT_D65 = {95.047d, 100.0d, 108.883d};
|
||||
|
||||
public static int alphaFromArgb(int i) {
|
||||
return (i >> 24) & 255;
|
||||
}
|
||||
|
||||
public static int argbFromRgb(int i, int i2, int i3) {
|
||||
return ((i & 255) << 16) | ViewCompat.MEASURED_STATE_MASK | ((i2 & 255) << 8) | (i3 & 255);
|
||||
}
|
||||
|
||||
public static int blueFromArgb(int i) {
|
||||
return i & 255;
|
||||
}
|
||||
|
||||
public static int greenFromArgb(int i) {
|
||||
return (i >> 8) & 255;
|
||||
}
|
||||
|
||||
static double labInvf(double d) {
|
||||
double d2 = d * d * d;
|
||||
return d2 > 0.008856451679035631d ? d2 : ((d * 116.0d) - 16.0d) / 903.2962962962963d;
|
||||
}
|
||||
|
||||
public static int redFromArgb(int i) {
|
||||
return (i >> 16) & 255;
|
||||
}
|
||||
|
||||
public static double[] whitePointD65() {
|
||||
return WHITE_POINT_D65;
|
||||
}
|
||||
|
||||
private ColorUtils() {
|
||||
}
|
||||
|
||||
public static int argbFromLinrgb(double[] dArr) {
|
||||
return argbFromRgb(delinearized(dArr[0]), delinearized(dArr[1]), delinearized(dArr[2]));
|
||||
}
|
||||
|
||||
public static boolean isOpaque(int i) {
|
||||
return alphaFromArgb(i) >= 255;
|
||||
}
|
||||
|
||||
public static int argbFromXyz(double d, double d2, double d3) {
|
||||
double[][] dArr = XYZ_TO_SRGB;
|
||||
double[] dArr2 = dArr[0];
|
||||
double d4 = (dArr2[0] * d) + (dArr2[1] * d2) + (dArr2[2] * d3);
|
||||
double[] dArr3 = dArr[1];
|
||||
double d5 = (dArr3[0] * d) + (dArr3[1] * d2) + (dArr3[2] * d3);
|
||||
double[] dArr4 = dArr[2];
|
||||
return argbFromRgb(delinearized(d4), delinearized(d5), delinearized((dArr4[0] * d) + (dArr4[1] * d2) + (dArr4[2] * d3)));
|
||||
}
|
||||
|
||||
public static double[] xyzFromArgb(int i) {
|
||||
return MathUtils.matrixMultiply(new double[]{linearized(redFromArgb(i)), linearized(greenFromArgb(i)), linearized(blueFromArgb(i))}, SRGB_TO_XYZ);
|
||||
}
|
||||
|
||||
public static int argbFromLab(double d, double d2, double d3) {
|
||||
double[] dArr = WHITE_POINT_D65;
|
||||
double d4 = (d + 16.0d) / 116.0d;
|
||||
double d5 = d4 - (d3 / 200.0d);
|
||||
return argbFromXyz(labInvf((d2 / 500.0d) + d4) * dArr[0], labInvf(d4) * dArr[1], labInvf(d5) * dArr[2]);
|
||||
}
|
||||
|
||||
public static double[] labFromArgb(int i) {
|
||||
double linearized = linearized(redFromArgb(i));
|
||||
double linearized2 = linearized(greenFromArgb(i));
|
||||
double linearized3 = linearized(blueFromArgb(i));
|
||||
double[][] dArr = SRGB_TO_XYZ;
|
||||
double[] dArr2 = dArr[0];
|
||||
double d = (dArr2[0] * linearized) + (dArr2[1] * linearized2) + (dArr2[2] * linearized3);
|
||||
double[] dArr3 = dArr[1];
|
||||
double d2 = (dArr3[0] * linearized) + (dArr3[1] * linearized2) + (dArr3[2] * linearized3);
|
||||
double[] dArr4 = dArr[2];
|
||||
double d3 = (dArr4[0] * linearized) + (dArr4[1] * linearized2) + (dArr4[2] * linearized3);
|
||||
double[] dArr5 = WHITE_POINT_D65;
|
||||
double d4 = d / dArr5[0];
|
||||
double d5 = d2 / dArr5[1];
|
||||
double d6 = d3 / dArr5[2];
|
||||
double labF = labF(d4);
|
||||
double labF2 = labF(d5);
|
||||
return new double[]{(116.0d * labF2) - 16.0d, (labF - labF2) * 500.0d, (labF2 - labF(d6)) * 200.0d};
|
||||
}
|
||||
|
||||
public static int argbFromLstar(double d) {
|
||||
int delinearized = delinearized(yFromLstar(d));
|
||||
return argbFromRgb(delinearized, delinearized, delinearized);
|
||||
}
|
||||
|
||||
public static double lstarFromArgb(int i) {
|
||||
return (labF(xyzFromArgb(i)[1] / 100.0d) * 116.0d) - 16.0d;
|
||||
}
|
||||
|
||||
public static double yFromLstar(double d) {
|
||||
return labInvf((d + 16.0d) / 116.0d) * 100.0d;
|
||||
}
|
||||
|
||||
public static double lstarFromY(double d) {
|
||||
return (labF(d / 100.0d) * 116.0d) - 16.0d;
|
||||
}
|
||||
|
||||
public static double linearized(int i) {
|
||||
double d = i / 255.0d;
|
||||
return (d <= 0.040449936d ? d / 12.92d : Math.pow((d + 0.055d) / 1.055d, 2.4d)) * 100.0d;
|
||||
}
|
||||
|
||||
public static int delinearized(double d) {
|
||||
double d2 = d / 100.0d;
|
||||
return MathUtils.clampInt(0, 255, (int) Math.round((d2 <= 0.0031308d ? d2 * 12.92d : (Math.pow(d2, 0.4166666666666667d) * 1.055d) - 0.055d) * 255.0d));
|
||||
}
|
||||
|
||||
static double labF(double d) {
|
||||
return d > 0.008856451679035631d ? Math.pow(d, 0.3333333333333333d) : ((d * 903.2962962962963d) + 16.0d) / 116.0d;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Contrast {
|
||||
private static final double CONTRAST_RATIO_EPSILON = 0.04d;
|
||||
private static final double LUMINANCE_GAMUT_MAP_TOLERANCE = 0.4d;
|
||||
public static final double RATIO_30 = 3.0d;
|
||||
public static final double RATIO_45 = 4.5d;
|
||||
public static final double RATIO_70 = 7.0d;
|
||||
public static final double RATIO_MAX = 21.0d;
|
||||
public static final double RATIO_MIN = 1.0d;
|
||||
|
||||
private Contrast() {
|
||||
}
|
||||
|
||||
public static double ratioOfYs(double d, double d2) {
|
||||
double max = Math.max(d, d2);
|
||||
if (max != d2) {
|
||||
d = d2;
|
||||
}
|
||||
return (max + 5.0d) / (d + 5.0d);
|
||||
}
|
||||
|
||||
public static double ratioOfTones(double d, double d2) {
|
||||
return ratioOfYs(ColorUtils.yFromLstar(d), ColorUtils.yFromLstar(d2));
|
||||
}
|
||||
|
||||
public static double lighter(double d, double d2) {
|
||||
if (d >= 0.0d && d <= 100.0d) {
|
||||
double yFromLstar = ColorUtils.yFromLstar(d);
|
||||
double d3 = ((yFromLstar + 5.0d) * d2) - 5.0d;
|
||||
if (d3 >= 0.0d && d3 <= 100.0d) {
|
||||
double ratioOfYs = ratioOfYs(d3, yFromLstar);
|
||||
double abs = Math.abs(ratioOfYs - d2);
|
||||
if (ratioOfYs < d2 && abs > CONTRAST_RATIO_EPSILON) {
|
||||
return -1.0d;
|
||||
}
|
||||
double lstarFromY = ColorUtils.lstarFromY(d3) + LUMINANCE_GAMUT_MAP_TOLERANCE;
|
||||
if (lstarFromY >= 0.0d && lstarFromY <= 100.0d) {
|
||||
return lstarFromY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1.0d;
|
||||
}
|
||||
|
||||
public static double lighterUnsafe(double d, double d2) {
|
||||
double lighter = lighter(d, d2);
|
||||
if (lighter < 0.0d) {
|
||||
return 100.0d;
|
||||
}
|
||||
return lighter;
|
||||
}
|
||||
|
||||
public static double darker(double d, double d2) {
|
||||
if (d >= 0.0d && d <= 100.0d) {
|
||||
double yFromLstar = ColorUtils.yFromLstar(d);
|
||||
double d3 = ((yFromLstar + 5.0d) / d2) - 5.0d;
|
||||
if (d3 >= 0.0d && d3 <= 100.0d) {
|
||||
double ratioOfYs = ratioOfYs(yFromLstar, d3);
|
||||
double abs = Math.abs(ratioOfYs - d2);
|
||||
if (ratioOfYs < d2 && abs > CONTRAST_RATIO_EPSILON) {
|
||||
return -1.0d;
|
||||
}
|
||||
double lstarFromY = ColorUtils.lstarFromY(d3) - LUMINANCE_GAMUT_MAP_TOLERANCE;
|
||||
if (lstarFromY >= 0.0d && lstarFromY <= 100.0d) {
|
||||
return lstarFromY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1.0d;
|
||||
}
|
||||
|
||||
public static double darkerUnsafe(double d, double d2) {
|
||||
return Math.max(0.0d, darker(d, d2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ContrastCurve {
|
||||
private final double high;
|
||||
private final double low;
|
||||
private final double medium;
|
||||
private final double normal;
|
||||
|
||||
public ContrastCurve(double d, double d2, double d3, double d4) {
|
||||
this.low = d;
|
||||
this.normal = d2;
|
||||
this.medium = d3;
|
||||
this.high = d4;
|
||||
}
|
||||
|
||||
public double getContrast(double d) {
|
||||
if (d <= -1.0d) {
|
||||
return this.low;
|
||||
}
|
||||
if (d < 0.0d) {
|
||||
return MathUtils.lerp(this.low, this.normal, (d - (-1.0d)) / 1.0d);
|
||||
}
|
||||
if (d < 0.5d) {
|
||||
return MathUtils.lerp(this.normal, this.medium, (d - 0.0d) / 0.5d);
|
||||
}
|
||||
return d < 1.0d ? MathUtils.lerp(this.medium, this.high, (d - 0.5d) / 0.5d) : this.high;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class CorePalette {
|
||||
public TonalPalette a1;
|
||||
public TonalPalette a2;
|
||||
public TonalPalette a3;
|
||||
public TonalPalette error;
|
||||
public TonalPalette n1;
|
||||
public TonalPalette n2;
|
||||
|
||||
public static CorePalette of(int i) {
|
||||
return new CorePalette(i, false);
|
||||
}
|
||||
|
||||
public static CorePalette contentOf(int i) {
|
||||
return new CorePalette(i, true);
|
||||
}
|
||||
|
||||
private CorePalette(int i, boolean z) {
|
||||
Hct fromInt = Hct.fromInt(i);
|
||||
double hue = fromInt.getHue();
|
||||
double chroma = fromInt.getChroma();
|
||||
if (z) {
|
||||
this.a1 = TonalPalette.fromHueAndChroma(hue, chroma);
|
||||
this.a2 = TonalPalette.fromHueAndChroma(hue, chroma / 3.0d);
|
||||
this.a3 = TonalPalette.fromHueAndChroma(60.0d + hue, chroma / 2.0d);
|
||||
this.n1 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 12.0d, 4.0d));
|
||||
this.n2 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 6.0d, 8.0d));
|
||||
} else {
|
||||
this.a1 = TonalPalette.fromHueAndChroma(hue, Math.max(48.0d, chroma));
|
||||
this.a2 = TonalPalette.fromHueAndChroma(hue, 16.0d);
|
||||
this.a3 = TonalPalette.fromHueAndChroma(60.0d + hue, 24.0d);
|
||||
this.n1 = TonalPalette.fromHueAndChroma(hue, 4.0d);
|
||||
this.n2 = TonalPalette.fromHueAndChroma(hue, 8.0d);
|
||||
}
|
||||
this.error = TonalPalette.fromHueAndChroma(25.0d, 84.0d);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class DislikeAnalyzer {
|
||||
private DislikeAnalyzer() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static boolean isDisliked(Hct hct) {
|
||||
return ((((double) Math.round(hct.getHue())) > 90.0d ? 1 : (((double) Math.round(hct.getHue())) == 90.0d ? 0 : -1)) >= 0 && (((double) Math.round(hct.getHue())) > 111.0d ? 1 : (((double) Math.round(hct.getHue())) == 111.0d ? 0 : -1)) <= 0) && ((((double) Math.round(hct.getChroma())) > 16.0d ? 1 : (((double) Math.round(hct.getChroma())) == 16.0d ? 0 : -1)) > 0) && ((((double) Math.round(hct.getTone())) > 65.0d ? 1 : (((double) Math.round(hct.getTone())) == 65.0d ? 0 : -1)) < 0);
|
||||
}
|
||||
|
||||
public static Hct fixIfDisliked(Hct hct) {
|
||||
return isDisliked(hct) ? Hct.from(hct.getHue(), hct.getChroma(), 70.0d) : hct;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
import androidx.core.view.ViewCompat;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class DynamicColor {
|
||||
public final Function<DynamicScheme, DynamicColor> background;
|
||||
public final ContrastCurve contrastCurve;
|
||||
private final HashMap<DynamicScheme, Hct> hctCache;
|
||||
public final boolean isBackground;
|
||||
public final String name;
|
||||
public final Function<DynamicScheme, Double> opacity;
|
||||
public final Function<DynamicScheme, TonalPalette> palette;
|
||||
public final Function<DynamicScheme, DynamicColor> secondBackground;
|
||||
public final Function<DynamicScheme, Double> tone;
|
||||
public final Function<DynamicScheme, ToneDeltaPair> toneDeltaPair;
|
||||
|
||||
static /* synthetic */ TonalPalette lambda$fromArgb$0(TonalPalette tonalPalette, DynamicScheme dynamicScheme) {
|
||||
return tonalPalette;
|
||||
}
|
||||
|
||||
public DynamicColor(String str, Function<DynamicScheme, TonalPalette> function, Function<DynamicScheme, Double> function2, boolean z, Function<DynamicScheme, DynamicColor> function3, Function<DynamicScheme, DynamicColor> function4, ContrastCurve contrastCurve, Function<DynamicScheme, ToneDeltaPair> function5) {
|
||||
this.hctCache = new HashMap<>();
|
||||
this.name = str;
|
||||
this.palette = function;
|
||||
this.tone = function2;
|
||||
this.isBackground = z;
|
||||
this.background = function3;
|
||||
this.secondBackground = function4;
|
||||
this.contrastCurve = contrastCurve;
|
||||
this.toneDeltaPair = function5;
|
||||
this.opacity = null;
|
||||
}
|
||||
|
||||
public DynamicColor(String str, Function<DynamicScheme, TonalPalette> function, Function<DynamicScheme, Double> function2, boolean z, Function<DynamicScheme, DynamicColor> function3, Function<DynamicScheme, DynamicColor> function4, ContrastCurve contrastCurve, Function<DynamicScheme, ToneDeltaPair> function5, Function<DynamicScheme, Double> function6) {
|
||||
this.hctCache = new HashMap<>();
|
||||
this.name = str;
|
||||
this.palette = function;
|
||||
this.tone = function2;
|
||||
this.isBackground = z;
|
||||
this.background = function3;
|
||||
this.secondBackground = function4;
|
||||
this.contrastCurve = contrastCurve;
|
||||
this.toneDeltaPair = function5;
|
||||
this.opacity = function6;
|
||||
}
|
||||
|
||||
public static DynamicColor fromPalette(String str, Function<DynamicScheme, TonalPalette> function, Function<DynamicScheme, Double> function2) {
|
||||
return new DynamicColor(str, function, function2, false, null, null, null, null);
|
||||
}
|
||||
|
||||
public static DynamicColor fromPalette(String str, Function<DynamicScheme, TonalPalette> function, Function<DynamicScheme, Double> function2, boolean z) {
|
||||
return new DynamicColor(str, function, function2, z, null, null, null, null);
|
||||
}
|
||||
|
||||
public static DynamicColor fromArgb(String str, int i) {
|
||||
final Hct fromInt = Hct.fromInt(i);
|
||||
final TonalPalette fromInt2 = TonalPalette.fromInt(i);
|
||||
return fromPalette(str, new Function() { // from class: com.google.android.material.color.utilities.DynamicColor$$ExternalSyntheticLambda1
|
||||
@Override // java.util.function.Function
|
||||
public final Object apply(Object obj) {
|
||||
return DynamicColor.lambda$fromArgb$0(TonalPalette.this, (DynamicScheme) obj);
|
||||
}
|
||||
}, new Function() { // from class: com.google.android.material.color.utilities.DynamicColor$$ExternalSyntheticLambda2
|
||||
@Override // java.util.function.Function
|
||||
public final Object apply(Object obj) {
|
||||
Double valueOf;
|
||||
valueOf = Double.valueOf(Hct.this.getTone());
|
||||
return valueOf;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int getArgb(DynamicScheme dynamicScheme) {
|
||||
Object apply;
|
||||
int i = getHct(dynamicScheme).toInt();
|
||||
Function<DynamicScheme, Double> function = this.opacity;
|
||||
if (function == null) {
|
||||
return i;
|
||||
}
|
||||
apply = function.apply(dynamicScheme);
|
||||
return (MathUtils.clampInt(0, 255, (int) Math.round(((Double) apply).doubleValue() * 255.0d)) << 24) | (i & ViewCompat.MEASURED_SIZE_MASK);
|
||||
}
|
||||
|
||||
public Hct getHct(DynamicScheme dynamicScheme) {
|
||||
Object apply;
|
||||
Hct hct = this.hctCache.get(dynamicScheme);
|
||||
if (hct != null) {
|
||||
return hct;
|
||||
}
|
||||
double tone = getTone(dynamicScheme);
|
||||
apply = this.palette.apply(dynamicScheme);
|
||||
Hct hct2 = ((TonalPalette) apply).getHct(tone);
|
||||
if (this.hctCache.size() > 4) {
|
||||
this.hctCache.clear();
|
||||
}
|
||||
this.hctCache.put(dynamicScheme, hct2);
|
||||
return hct2;
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:114:0x022b A[RETURN] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:88:0x01ab */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public double getTone(com.google.android.material.color.utilities.DynamicScheme r31) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 556
|
||||
To view this dump add '--comments-level debug' option
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.color.utilities.DynamicColor.getTone(com.google.android.material.color.utilities.DynamicScheme):double");
|
||||
}
|
||||
|
||||
public static double foregroundTone(double d, double d2) {
|
||||
double lighterUnsafe = Contrast.lighterUnsafe(d, d2);
|
||||
double darkerUnsafe = Contrast.darkerUnsafe(d, d2);
|
||||
double ratioOfTones = Contrast.ratioOfTones(lighterUnsafe, d);
|
||||
double ratioOfTones2 = Contrast.ratioOfTones(darkerUnsafe, d);
|
||||
if (tonePrefersLightForeground(d)) {
|
||||
return (ratioOfTones >= d2 || ratioOfTones >= ratioOfTones2 || ((Math.abs(ratioOfTones - ratioOfTones2) > 0.1d ? 1 : (Math.abs(ratioOfTones - ratioOfTones2) == 0.1d ? 0 : -1)) < 0 && (ratioOfTones > d2 ? 1 : (ratioOfTones == d2 ? 0 : -1)) < 0 && (ratioOfTones2 > d2 ? 1 : (ratioOfTones2 == d2 ? 0 : -1)) < 0)) ? lighterUnsafe : darkerUnsafe;
|
||||
}
|
||||
return (ratioOfTones2 >= d2 || ratioOfTones2 >= ratioOfTones) ? darkerUnsafe : lighterUnsafe;
|
||||
}
|
||||
|
||||
public static double enableLightForeground(double d) {
|
||||
if (!tonePrefersLightForeground(d) || toneAllowsLightForeground(d)) {
|
||||
return d;
|
||||
}
|
||||
return 49.0d;
|
||||
}
|
||||
|
||||
public static boolean tonePrefersLightForeground(double d) {
|
||||
return Math.round(d) < 60;
|
||||
}
|
||||
|
||||
public static boolean toneAllowsLightForeground(double d) {
|
||||
return Math.round(d) <= 49;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DynamicScheme {
|
||||
public final double contrastLevel;
|
||||
public final TonalPalette errorPalette = TonalPalette.fromHueAndChroma(25.0d, 84.0d);
|
||||
public final boolean isDark;
|
||||
public final TonalPalette neutralPalette;
|
||||
public final TonalPalette neutralVariantPalette;
|
||||
public final TonalPalette primaryPalette;
|
||||
public final TonalPalette secondaryPalette;
|
||||
public final int sourceColorArgb;
|
||||
public final Hct sourceColorHct;
|
||||
public final TonalPalette tertiaryPalette;
|
||||
public final Variant variant;
|
||||
|
||||
public DynamicScheme(Hct hct, Variant variant, boolean z, double d, TonalPalette tonalPalette, TonalPalette tonalPalette2, TonalPalette tonalPalette3, TonalPalette tonalPalette4, TonalPalette tonalPalette5) {
|
||||
this.sourceColorArgb = hct.toInt();
|
||||
this.sourceColorHct = hct;
|
||||
this.variant = variant;
|
||||
this.isDark = z;
|
||||
this.contrastLevel = d;
|
||||
this.primaryPalette = tonalPalette;
|
||||
this.secondaryPalette = tonalPalette2;
|
||||
this.tertiaryPalette = tonalPalette3;
|
||||
this.neutralPalette = tonalPalette4;
|
||||
this.neutralVariantPalette = tonalPalette5;
|
||||
}
|
||||
|
||||
public static double getRotatedHue(Hct hct, double[] dArr, double[] dArr2) {
|
||||
double hue = hct.getHue();
|
||||
int i = 0;
|
||||
if (dArr2.length == 1) {
|
||||
return MathUtils.sanitizeDegreesDouble(hue + dArr2[0]);
|
||||
}
|
||||
int length = dArr.length;
|
||||
while (i <= length - 2) {
|
||||
double d = dArr[i];
|
||||
int i2 = i + 1;
|
||||
double d2 = dArr[i2];
|
||||
if (d < hue && hue < d2) {
|
||||
return MathUtils.sanitizeDegreesDouble(hue + dArr2[i]);
|
||||
}
|
||||
i = i2;
|
||||
}
|
||||
return hue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.google.android.material.color.utilities;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Hct {
|
||||
private int argb;
|
||||
private double chroma;
|
||||
private double hue;
|
||||
private double tone;
|
||||
|
||||
public double getChroma() {
|
||||
return this.chroma;
|
||||
}
|
||||
|
||||
public double getHue() {
|
||||
return this.hue;
|
||||
}
|
||||
|
||||
public double getTone() {
|
||||
return this.tone;
|
||||
}
|
||||
|
||||
public int toInt() {
|
||||
return this.argb;
|
||||
}
|
||||
|
||||
public static Hct from(double d, double d2, double d3) {
|
||||
return new Hct(HctSolver.solveToInt(d, d2, d3));
|
||||
}
|
||||
|
||||
public static Hct fromInt(int i) {
|
||||
return new Hct(i);
|
||||
}
|
||||
|
||||
private Hct(int i) {
|
||||
setInternalState(i);
|
||||
}
|
||||
|
||||
public void setHue(double d) {
|
||||
setInternalState(HctSolver.solveToInt(d, this.chroma, this.tone));
|
||||
}
|
||||
|
||||
public void setChroma(double d) {
|
||||
setInternalState(HctSolver.solveToInt(this.hue, d, this.tone));
|
||||
}
|
||||
|
||||
public void setTone(double d) {
|
||||
setInternalState(HctSolver.solveToInt(this.hue, this.chroma, d));
|
||||
}
|
||||
|
||||
public Hct inViewingConditions(ViewingConditions viewingConditions) {
|
||||
double[] xyzInViewingConditions = Cam16.fromInt(toInt()).xyzInViewingConditions(viewingConditions, null);
|
||||
Cam16 fromXyzInViewingConditions = Cam16.fromXyzInViewingConditions(xyzInViewingConditions[0], xyzInViewingConditions[1], xyzInViewingConditions[2], ViewingConditions.DEFAULT);
|
||||
return from(fromXyzInViewingConditions.getHue(), fromXyzInViewingConditions.getChroma(), ColorUtils.lstarFromY(xyzInViewingConditions[1]));
|
||||
}
|
||||
|
||||
private void setInternalState(int i) {
|
||||
this.argb = i;
|
||||
Cam16 fromInt = Cam16.fromInt(i);
|
||||
this.hue = fromInt.getHue();
|
||||
this.chroma = fromInt.getChroma();
|
||||
this.tone = ColorUtils.lstarFromArgb(i);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user