Initial commit
This commit is contained in:
@@ -0,0 +1,669 @@
|
||||
package com.google.android.material.floatingactionbutton;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.appcompat.widget.AppCompatDrawableManager;
|
||||
import androidx.appcompat.widget.AppCompatImageHelper;
|
||||
import androidx.collection.SimpleArrayMap;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.TintableBackgroundView;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.widget.TintableImageSourceView;
|
||||
import com.google.android.material.R$dimen;
|
||||
import com.google.android.material.R$styleable;
|
||||
import com.google.android.material.animation.MotionSpec;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.expandable.ExpandableTransformationWidget;
|
||||
import com.google.android.material.expandable.ExpandableWidgetHelper;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButtonImpl;
|
||||
import com.google.android.material.internal.DescendantOffsetUtils;
|
||||
import com.google.android.material.internal.VisibilityAwareImageButton;
|
||||
import com.google.android.material.shadow.ShadowViewDelegate;
|
||||
import com.google.android.material.stateful.ExtendableSavedState;
|
||||
import java.util.List;
|
||||
|
||||
@CoordinatorLayout.DefaultBehavior(Behavior.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class FloatingActionButton extends VisibilityAwareImageButton implements TintableBackgroundView, TintableImageSourceView, ExpandableTransformationWidget {
|
||||
private ColorStateList b;
|
||||
private PorterDuff.Mode c;
|
||||
private ColorStateList d;
|
||||
private PorterDuff.Mode e;
|
||||
private ColorStateList f;
|
||||
private int g;
|
||||
private int h;
|
||||
private int i;
|
||||
private int j;
|
||||
boolean k;
|
||||
final Rect l;
|
||||
private final Rect m;
|
||||
private final AppCompatImageHelper n;
|
||||
private final ExpandableWidgetHelper o;
|
||||
private FloatingActionButtonImpl p;
|
||||
|
||||
protected static class BaseBehavior<T extends FloatingActionButton> extends CoordinatorLayout.Behavior<T> {
|
||||
private Rect a;
|
||||
private OnVisibilityChangedListener b;
|
||||
private boolean c;
|
||||
|
||||
public BaseBehavior() {
|
||||
this.c = true;
|
||||
}
|
||||
|
||||
private boolean b(View view, FloatingActionButton floatingActionButton) {
|
||||
if (!a(view, floatingActionButton)) {
|
||||
return false;
|
||||
}
|
||||
if (view.getTop() < (floatingActionButton.getHeight() / 2) + ((ViewGroup.MarginLayoutParams) ((CoordinatorLayout.LayoutParams) floatingActionButton.getLayoutParams())).topMargin) {
|
||||
floatingActionButton.a(this.b, false);
|
||||
return true;
|
||||
}
|
||||
floatingActionButton.b(this.b, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public BaseBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.FloatingActionButton_Behavior_Layout);
|
||||
this.c = obtainStyledAttributes.getBoolean(R$styleable.FloatingActionButton_Behavior_Layout_behavior_autoHide, true);
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public void a(CoordinatorLayout.LayoutParams layoutParams) {
|
||||
if (layoutParams.h == 0) {
|
||||
layoutParams.h = 80;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public boolean b(CoordinatorLayout coordinatorLayout, FloatingActionButton floatingActionButton, View view) {
|
||||
if (view instanceof AppBarLayout) {
|
||||
a(coordinatorLayout, (AppBarLayout) view, floatingActionButton);
|
||||
return false;
|
||||
}
|
||||
if (!a(view)) {
|
||||
return false;
|
||||
}
|
||||
b(view, floatingActionButton);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean a(View view) {
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
if (layoutParams instanceof CoordinatorLayout.LayoutParams) {
|
||||
return ((CoordinatorLayout.LayoutParams) layoutParams).d() instanceof BottomSheetBehavior;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean a(View view, FloatingActionButton floatingActionButton) {
|
||||
return this.c && ((CoordinatorLayout.LayoutParams) floatingActionButton.getLayoutParams()).c() == view.getId() && floatingActionButton.getUserSetVisibility() == 0;
|
||||
}
|
||||
|
||||
private boolean a(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, FloatingActionButton floatingActionButton) {
|
||||
if (!a(appBarLayout, floatingActionButton)) {
|
||||
return false;
|
||||
}
|
||||
if (this.a == null) {
|
||||
this.a = new Rect();
|
||||
}
|
||||
Rect rect = this.a;
|
||||
DescendantOffsetUtils.a(coordinatorLayout, appBarLayout, rect);
|
||||
if (rect.bottom <= appBarLayout.getMinimumHeightForVisibleOverlappingContent()) {
|
||||
floatingActionButton.a(this.b, false);
|
||||
return true;
|
||||
}
|
||||
floatingActionButton.b(this.b, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean a(CoordinatorLayout coordinatorLayout, FloatingActionButton floatingActionButton, int i) {
|
||||
List<View> b = coordinatorLayout.b(floatingActionButton);
|
||||
int size = b.size();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
View view = b.get(i2);
|
||||
if (view instanceof AppBarLayout) {
|
||||
if (a(coordinatorLayout, (AppBarLayout) view, floatingActionButton)) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (a(view) && b(view, floatingActionButton)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
coordinatorLayout.c(floatingActionButton, i);
|
||||
a(coordinatorLayout, floatingActionButton);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean a(CoordinatorLayout coordinatorLayout, FloatingActionButton floatingActionButton, Rect rect) {
|
||||
Rect rect2 = floatingActionButton.l;
|
||||
rect.set(floatingActionButton.getLeft() + rect2.left, floatingActionButton.getTop() + rect2.top, floatingActionButton.getRight() - rect2.right, floatingActionButton.getBottom() - rect2.bottom);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void a(CoordinatorLayout coordinatorLayout, FloatingActionButton floatingActionButton) {
|
||||
int i;
|
||||
Rect rect = floatingActionButton.l;
|
||||
if (rect == null || rect.centerX() <= 0 || rect.centerY() <= 0) {
|
||||
return;
|
||||
}
|
||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) floatingActionButton.getLayoutParams();
|
||||
int i2 = 0;
|
||||
if (floatingActionButton.getRight() >= coordinatorLayout.getWidth() - ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin) {
|
||||
i = rect.right;
|
||||
} else {
|
||||
i = floatingActionButton.getLeft() <= ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin ? -rect.left : 0;
|
||||
}
|
||||
if (floatingActionButton.getBottom() >= coordinatorLayout.getHeight() - ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin) {
|
||||
i2 = rect.bottom;
|
||||
} else if (floatingActionButton.getTop() <= ((ViewGroup.MarginLayoutParams) layoutParams).topMargin) {
|
||||
i2 = -rect.top;
|
||||
}
|
||||
if (i2 != 0) {
|
||||
ViewCompat.d((View) floatingActionButton, i2);
|
||||
}
|
||||
if (i != 0) {
|
||||
ViewCompat.c((View) floatingActionButton, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Behavior extends BaseBehavior<FloatingActionButton> {
|
||||
public Behavior() {
|
||||
}
|
||||
|
||||
public Behavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class OnVisibilityChangedListener {
|
||||
public abstract void a(FloatingActionButton floatingActionButton);
|
||||
|
||||
public abstract void b(FloatingActionButton floatingActionButton);
|
||||
}
|
||||
|
||||
private void c() {
|
||||
Drawable drawable = getDrawable();
|
||||
if (drawable == null) {
|
||||
return;
|
||||
}
|
||||
ColorStateList colorStateList = this.d;
|
||||
if (colorStateList == null) {
|
||||
DrawableCompat.b(drawable);
|
||||
return;
|
||||
}
|
||||
int colorForState = colorStateList.getColorForState(getDrawableState(), 0);
|
||||
PorterDuff.Mode mode = this.e;
|
||||
if (mode == null) {
|
||||
mode = PorterDuff.Mode.SRC_IN;
|
||||
}
|
||||
drawable.mutate().setColorFilter(AppCompatDrawableManager.a(colorForState, mode));
|
||||
}
|
||||
|
||||
private FloatingActionButtonImpl getImpl() {
|
||||
if (this.p == null) {
|
||||
this.p = b();
|
||||
}
|
||||
return this.p;
|
||||
}
|
||||
|
||||
void b(OnVisibilityChangedListener onVisibilityChangedListener, boolean z) {
|
||||
getImpl().b(a(onVisibilityChangedListener), z);
|
||||
}
|
||||
|
||||
public void d(Animator.AnimatorListener animatorListener) {
|
||||
getImpl().d(animatorListener);
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void drawableStateChanged() {
|
||||
super.drawableStateChanged();
|
||||
getImpl().a(getDrawableState());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public ColorStateList getBackgroundTintList() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public PorterDuff.Mode getBackgroundTintMode() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public float getCompatElevation() {
|
||||
return getImpl().b();
|
||||
}
|
||||
|
||||
public float getCompatHoveredFocusedTranslationZ() {
|
||||
return getImpl().d();
|
||||
}
|
||||
|
||||
public float getCompatPressedTranslationZ() {
|
||||
return getImpl().e();
|
||||
}
|
||||
|
||||
public Drawable getContentBackground() {
|
||||
return getImpl().a();
|
||||
}
|
||||
|
||||
public int getCustomSize() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
public int getExpandedComponentIdHint() {
|
||||
this.o.a();
|
||||
throw null;
|
||||
}
|
||||
|
||||
public MotionSpec getHideMotionSpec() {
|
||||
return getImpl().c();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getRippleColor() {
|
||||
ColorStateList colorStateList = this.f;
|
||||
if (colorStateList != null) {
|
||||
return colorStateList.getDefaultColor();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ColorStateList getRippleColorStateList() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public MotionSpec getShowMotionSpec() {
|
||||
return getImpl().f();
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
int getSizeDimension() {
|
||||
return a(this.g);
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.TintableBackgroundView
|
||||
public ColorStateList getSupportBackgroundTintList() {
|
||||
return getBackgroundTintList();
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.TintableBackgroundView
|
||||
public PorterDuff.Mode getSupportBackgroundTintMode() {
|
||||
return getBackgroundTintMode();
|
||||
}
|
||||
|
||||
@Override // androidx.core.widget.TintableImageSourceView
|
||||
public ColorStateList getSupportImageTintList() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
@Override // androidx.core.widget.TintableImageSourceView
|
||||
public PorterDuff.Mode getSupportImageTintMode() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public boolean getUseCompatPadding() {
|
||||
return this.k;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.expandable.ExpandableWidget
|
||||
public boolean isExpanded() {
|
||||
this.o.b();
|
||||
throw null;
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
public void jumpDrawablesToCurrentState() {
|
||||
super.jumpDrawablesToCurrentState();
|
||||
getImpl().i();
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
getImpl().j();
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
getImpl().l();
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
int sizeDimension = getSizeDimension();
|
||||
this.i = (sizeDimension - this.j) / 2;
|
||||
getImpl().p();
|
||||
int min = Math.min(a(sizeDimension, i), a(sizeDimension, i2));
|
||||
Rect rect = this.l;
|
||||
setMeasuredDimension(rect.left + min + rect.right, min + rect.top + rect.bottom);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onRestoreInstanceState(Parcelable parcelable) {
|
||||
if (!(parcelable instanceof ExtendableSavedState)) {
|
||||
super.onRestoreInstanceState(parcelable);
|
||||
return;
|
||||
}
|
||||
ExtendableSavedState extendableSavedState = (ExtendableSavedState) parcelable;
|
||||
super.onRestoreInstanceState(extendableSavedState.getSuperState());
|
||||
this.o.a(extendableSavedState.extendableStates.get("expandableWidgetHelper"));
|
||||
throw null;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
SimpleArrayMap<String, Bundle> simpleArrayMap = new ExtendableSavedState(super.onSaveInstanceState()).extendableStates;
|
||||
this.o.c();
|
||||
throw null;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
if (motionEvent.getAction() == 0 && a(this.m) && !this.m.contains((int) motionEvent.getX(), (int) motionEvent.getY())) {
|
||||
return false;
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundColor(int i) {
|
||||
Log.i("FloatingActionButton", "Setting a custom background is not supported.");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundDrawable(Drawable drawable) {
|
||||
Log.i("FloatingActionButton", "Setting a custom background is not supported.");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundResource(int i) {
|
||||
Log.i("FloatingActionButton", "Setting a custom background is not supported.");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundTintList(ColorStateList colorStateList) {
|
||||
if (this.b != colorStateList) {
|
||||
this.b = colorStateList;
|
||||
getImpl().a(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundTintMode(PorterDuff.Mode mode) {
|
||||
if (this.c != mode) {
|
||||
this.c = mode;
|
||||
getImpl().a(mode);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompatElevation(float f) {
|
||||
getImpl().a(f);
|
||||
}
|
||||
|
||||
public void setCompatElevationResource(int i) {
|
||||
setCompatElevation(getResources().getDimension(i));
|
||||
}
|
||||
|
||||
public void setCompatHoveredFocusedTranslationZ(float f) {
|
||||
getImpl().b(f);
|
||||
}
|
||||
|
||||
public void setCompatHoveredFocusedTranslationZResource(int i) {
|
||||
setCompatHoveredFocusedTranslationZ(getResources().getDimension(i));
|
||||
}
|
||||
|
||||
public void setCompatPressedTranslationZ(float f) {
|
||||
getImpl().d(f);
|
||||
}
|
||||
|
||||
public void setCompatPressedTranslationZResource(int i) {
|
||||
setCompatPressedTranslationZ(getResources().getDimension(i));
|
||||
}
|
||||
|
||||
public void setCustomSize(int i) {
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("Custom size must be non-negative");
|
||||
}
|
||||
this.h = i;
|
||||
}
|
||||
|
||||
public void setExpandedComponentIdHint(int i) {
|
||||
this.o.a(i);
|
||||
throw null;
|
||||
}
|
||||
|
||||
public void setHideMotionSpec(MotionSpec motionSpec) {
|
||||
getImpl().a(motionSpec);
|
||||
}
|
||||
|
||||
public void setHideMotionSpecResource(int i) {
|
||||
setHideMotionSpec(MotionSpec.a(getContext(), i));
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView
|
||||
public void setImageDrawable(Drawable drawable) {
|
||||
super.setImageDrawable(drawable);
|
||||
getImpl().o();
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView
|
||||
public void setImageResource(int i) {
|
||||
this.n.a(i);
|
||||
}
|
||||
|
||||
public void setRippleColor(int i) {
|
||||
setRippleColor(ColorStateList.valueOf(i));
|
||||
}
|
||||
|
||||
public void setShowMotionSpec(MotionSpec motionSpec) {
|
||||
getImpl().b(motionSpec);
|
||||
}
|
||||
|
||||
public void setShowMotionSpecResource(int i) {
|
||||
setShowMotionSpec(MotionSpec.a(getContext(), i));
|
||||
}
|
||||
|
||||
public void setSize(int i) {
|
||||
this.h = 0;
|
||||
if (i != this.g) {
|
||||
this.g = i;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.TintableBackgroundView
|
||||
public void setSupportBackgroundTintList(ColorStateList colorStateList) {
|
||||
setBackgroundTintList(colorStateList);
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.TintableBackgroundView
|
||||
public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
|
||||
setBackgroundTintMode(mode);
|
||||
}
|
||||
|
||||
@Override // androidx.core.widget.TintableImageSourceView
|
||||
public void setSupportImageTintList(ColorStateList colorStateList) {
|
||||
if (this.d != colorStateList) {
|
||||
this.d = colorStateList;
|
||||
c();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.widget.TintableImageSourceView
|
||||
public void setSupportImageTintMode(PorterDuff.Mode mode) {
|
||||
if (this.e != mode) {
|
||||
this.e = mode;
|
||||
c();
|
||||
}
|
||||
}
|
||||
|
||||
public void setUseCompatPadding(boolean z) {
|
||||
if (this.k != z) {
|
||||
this.k = z;
|
||||
getImpl().k();
|
||||
}
|
||||
}
|
||||
|
||||
public void b(Animator.AnimatorListener animatorListener) {
|
||||
getImpl().b(animatorListener);
|
||||
}
|
||||
|
||||
public void setRippleColor(ColorStateList colorStateList) {
|
||||
if (this.f != colorStateList) {
|
||||
this.f = colorStateList;
|
||||
getImpl().b(this.f);
|
||||
}
|
||||
}
|
||||
|
||||
void a(OnVisibilityChangedListener onVisibilityChangedListener, boolean z) {
|
||||
getImpl().a(a(onVisibilityChangedListener), z);
|
||||
}
|
||||
|
||||
public void b(Rect rect) {
|
||||
rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
|
||||
c(rect);
|
||||
}
|
||||
|
||||
private class ShadowDelegateImpl implements ShadowViewDelegate {
|
||||
ShadowDelegateImpl() {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shadow.ShadowViewDelegate
|
||||
public void a(int i, int i2, int i3, int i4) {
|
||||
FloatingActionButton.this.l.set(i, i2, i3, i4);
|
||||
FloatingActionButton floatingActionButton = FloatingActionButton.this;
|
||||
floatingActionButton.setPadding(i + floatingActionButton.i, i2 + FloatingActionButton.this.i, i3 + FloatingActionButton.this.i, i4 + FloatingActionButton.this.i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shadow.ShadowViewDelegate
|
||||
public float b() {
|
||||
return FloatingActionButton.this.getSizeDimension() / 2.0f;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shadow.ShadowViewDelegate
|
||||
public void a(Drawable drawable) {
|
||||
FloatingActionButton.super.setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shadow.ShadowViewDelegate
|
||||
public boolean a() {
|
||||
return FloatingActionButton.this.k;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Animator.AnimatorListener animatorListener) {
|
||||
getImpl().a(animatorListener);
|
||||
}
|
||||
|
||||
private FloatingActionButtonImpl.InternalVisibilityChangedListener a(final OnVisibilityChangedListener onVisibilityChangedListener) {
|
||||
if (onVisibilityChangedListener == null) {
|
||||
return null;
|
||||
}
|
||||
return new FloatingActionButtonImpl.InternalVisibilityChangedListener() { // from class: com.google.android.material.floatingactionbutton.FloatingActionButton.1
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl.InternalVisibilityChangedListener
|
||||
public void a() {
|
||||
onVisibilityChangedListener.b(FloatingActionButton.this);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl.InternalVisibilityChangedListener
|
||||
public void b() {
|
||||
onVisibilityChangedListener.a(FloatingActionButton.this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private FloatingActionButtonImpl b() {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return new FloatingActionButtonImplLollipop(this, new ShadowDelegateImpl());
|
||||
}
|
||||
return new FloatingActionButtonImpl(this, new ShadowDelegateImpl());
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
return getImpl().h();
|
||||
}
|
||||
|
||||
private int a(int i) {
|
||||
int i2 = this.h;
|
||||
if (i2 != 0) {
|
||||
return i2;
|
||||
}
|
||||
Resources resources = getResources();
|
||||
if (i != -1) {
|
||||
if (i != 1) {
|
||||
return resources.getDimensionPixelSize(R$dimen.design_fab_size_normal);
|
||||
}
|
||||
return resources.getDimensionPixelSize(R$dimen.design_fab_size_mini);
|
||||
}
|
||||
if (Math.max(resources.getConfiguration().screenWidthDp, resources.getConfiguration().screenHeightDp) < 470) {
|
||||
return a(1);
|
||||
}
|
||||
return a(0);
|
||||
}
|
||||
|
||||
public void c(Animator.AnimatorListener animatorListener) {
|
||||
getImpl().c(animatorListener);
|
||||
}
|
||||
|
||||
private void c(Rect rect) {
|
||||
int i = rect.left;
|
||||
Rect rect2 = this.l;
|
||||
rect.left = i + rect2.left;
|
||||
rect.top += rect2.top;
|
||||
rect.right -= rect2.right;
|
||||
rect.bottom -= rect2.bottom;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean a(Rect rect) {
|
||||
if (!ViewCompat.x(this)) {
|
||||
return false;
|
||||
}
|
||||
rect.set(0, 0, getWidth(), getHeight());
|
||||
c(rect);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int a(int i, int i2) {
|
||||
int mode = View.MeasureSpec.getMode(i2);
|
||||
int size = View.MeasureSpec.getSize(i2);
|
||||
if (mode == Integer.MIN_VALUE) {
|
||||
return Math.min(i, size);
|
||||
}
|
||||
if (mode == 0) {
|
||||
return i;
|
||||
}
|
||||
if (mode == 1073741824) {
|
||||
return size;
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
@@ -0,0 +1,552 @@
|
||||
package com.google.android.material.floatingactionbutton;
|
||||
|
||||
import android.R;
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.Property;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R$animator;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.animation.AnimatorSetCompat;
|
||||
import com.google.android.material.animation.ImageMatrixProperty;
|
||||
import com.google.android.material.animation.MatrixEvaluator;
|
||||
import com.google.android.material.animation.MotionSpec;
|
||||
import com.google.android.material.internal.CircularBorderDrawable;
|
||||
import com.google.android.material.internal.StateListAnimator;
|
||||
import com.google.android.material.internal.VisibilityAwareImageButton;
|
||||
import com.google.android.material.ripple.RippleUtils;
|
||||
import com.google.android.material.shadow.ShadowDrawableWrapper;
|
||||
import com.google.android.material.shadow.ShadowViewDelegate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class FloatingActionButtonImpl {
|
||||
static final TimeInterpolator B = AnimationUtils.c;
|
||||
static final int[] C = {R.attr.state_pressed, R.attr.state_enabled};
|
||||
static final int[] D = {R.attr.state_hovered, R.attr.state_focused, R.attr.state_enabled};
|
||||
static final int[] E = {R.attr.state_focused, R.attr.state_enabled};
|
||||
static final int[] F = {R.attr.state_hovered, R.attr.state_enabled};
|
||||
static final int[] G = {R.attr.state_enabled};
|
||||
static final int[] H = new int[0];
|
||||
private ViewTreeObserver.OnPreDrawListener A;
|
||||
Animator b;
|
||||
MotionSpec c;
|
||||
MotionSpec d;
|
||||
private MotionSpec e;
|
||||
private MotionSpec f;
|
||||
ShadowDrawableWrapper h;
|
||||
private float i;
|
||||
Drawable j;
|
||||
Drawable k;
|
||||
CircularBorderDrawable l;
|
||||
Drawable m;
|
||||
float n;
|
||||
float o;
|
||||
float p;
|
||||
int q;
|
||||
private ArrayList<Animator.AnimatorListener> s;
|
||||
private ArrayList<Animator.AnimatorListener> t;
|
||||
final VisibilityAwareImageButton u;
|
||||
final ShadowViewDelegate v;
|
||||
int a = 0;
|
||||
float r = 1.0f;
|
||||
private final Rect w = new Rect();
|
||||
private final RectF x = new RectF();
|
||||
private final RectF y = new RectF();
|
||||
private final Matrix z = new Matrix();
|
||||
private final StateListAnimator g = new StateListAnimator();
|
||||
|
||||
private class DisabledElevationAnimation extends ShadowAnimatorImpl {
|
||||
DisabledElevationAnimation(FloatingActionButtonImpl floatingActionButtonImpl) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
private class ElevateToHoveredFocusedTranslationZAnimation extends ShadowAnimatorImpl {
|
||||
ElevateToHoveredFocusedTranslationZAnimation() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
private class ElevateToPressedTranslationZAnimation extends ShadowAnimatorImpl {
|
||||
ElevateToPressedTranslationZAnimation() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
interface InternalVisibilityChangedListener {
|
||||
void a();
|
||||
|
||||
void b();
|
||||
}
|
||||
|
||||
private class ResetElevationAnimation extends ShadowAnimatorImpl {
|
||||
ResetElevationAnimation() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
private abstract class ShadowAnimatorImpl extends AnimatorListenerAdapter implements ValueAnimator.AnimatorUpdateListener {
|
||||
private boolean a;
|
||||
private float b;
|
||||
private float c;
|
||||
|
||||
private ShadowAnimatorImpl() {
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
FloatingActionButtonImpl.this.h.b(this.c);
|
||||
throw null;
|
||||
}
|
||||
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
if (!this.a) {
|
||||
FloatingActionButtonImpl.this.h.b();
|
||||
throw null;
|
||||
}
|
||||
ShadowDrawableWrapper shadowDrawableWrapper = FloatingActionButtonImpl.this.h;
|
||||
float f = this.b;
|
||||
shadowDrawableWrapper.b(f + ((this.c - f) * valueAnimator.getAnimatedFraction()));
|
||||
throw null;
|
||||
}
|
||||
}
|
||||
|
||||
FloatingActionButtonImpl(VisibilityAwareImageButton visibilityAwareImageButton, ShadowViewDelegate shadowViewDelegate) {
|
||||
this.u = visibilityAwareImageButton;
|
||||
this.v = shadowViewDelegate;
|
||||
this.g.a(C, a((ShadowAnimatorImpl) new ElevateToPressedTranslationZAnimation()));
|
||||
this.g.a(D, a((ShadowAnimatorImpl) new ElevateToHoveredFocusedTranslationZAnimation()));
|
||||
this.g.a(E, a((ShadowAnimatorImpl) new ElevateToHoveredFocusedTranslationZAnimation()));
|
||||
this.g.a(F, a((ShadowAnimatorImpl) new ElevateToHoveredFocusedTranslationZAnimation()));
|
||||
this.g.a(G, a((ShadowAnimatorImpl) new ResetElevationAnimation()));
|
||||
this.g.a(H, a((ShadowAnimatorImpl) new DisabledElevationAnimation(this)));
|
||||
this.i = this.u.getRotation();
|
||||
}
|
||||
|
||||
private void q() {
|
||||
if (this.A == null) {
|
||||
this.A = new ViewTreeObserver.OnPreDrawListener() { // from class: com.google.android.material.floatingactionbutton.FloatingActionButtonImpl.3
|
||||
@Override // android.view.ViewTreeObserver.OnPreDrawListener
|
||||
public boolean onPreDraw() {
|
||||
FloatingActionButtonImpl.this.m();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private MotionSpec r() {
|
||||
if (this.f == null) {
|
||||
this.f = MotionSpec.a(this.u.getContext(), R$animator.design_fab_hide_motion_spec);
|
||||
}
|
||||
return this.f;
|
||||
}
|
||||
|
||||
private MotionSpec s() {
|
||||
if (this.e == null) {
|
||||
this.e = MotionSpec.a(this.u.getContext(), R$animator.design_fab_show_motion_spec);
|
||||
}
|
||||
return this.e;
|
||||
}
|
||||
|
||||
private boolean t() {
|
||||
return ViewCompat.x(this.u) && !this.u.isInEditMode();
|
||||
}
|
||||
|
||||
private void u() {
|
||||
if (Build.VERSION.SDK_INT == 19) {
|
||||
if (this.i % 90.0f != 0.0f) {
|
||||
if (this.u.getLayerType() != 1) {
|
||||
this.u.setLayerType(1, null);
|
||||
}
|
||||
} else if (this.u.getLayerType() != 0) {
|
||||
this.u.setLayerType(0, null);
|
||||
}
|
||||
}
|
||||
ShadowDrawableWrapper shadowDrawableWrapper = this.h;
|
||||
if (shadowDrawableWrapper != null) {
|
||||
shadowDrawableWrapper.a(-this.i);
|
||||
throw null;
|
||||
}
|
||||
CircularBorderDrawable circularBorderDrawable = this.l;
|
||||
if (circularBorderDrawable == null) {
|
||||
return;
|
||||
}
|
||||
circularBorderDrawable.a(-this.i);
|
||||
throw null;
|
||||
}
|
||||
|
||||
void a(ColorStateList colorStateList) {
|
||||
Drawable drawable = this.j;
|
||||
if (drawable != null) {
|
||||
DrawableCompat.a(drawable, colorStateList);
|
||||
}
|
||||
CircularBorderDrawable circularBorderDrawable = this.l;
|
||||
if (circularBorderDrawable == null) {
|
||||
return;
|
||||
}
|
||||
circularBorderDrawable.a(colorStateList);
|
||||
throw null;
|
||||
}
|
||||
|
||||
void b(ColorStateList colorStateList) {
|
||||
Drawable drawable = this.k;
|
||||
if (drawable != null) {
|
||||
DrawableCompat.a(drawable, RippleUtils.a(colorStateList));
|
||||
}
|
||||
}
|
||||
|
||||
void b(Rect rect) {
|
||||
}
|
||||
|
||||
final void c(float f) {
|
||||
this.r = f;
|
||||
Matrix matrix = this.z;
|
||||
a(f, matrix);
|
||||
this.u.setImageMatrix(matrix);
|
||||
}
|
||||
|
||||
float d() {
|
||||
return this.o;
|
||||
}
|
||||
|
||||
float e() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
final MotionSpec f() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
boolean g() {
|
||||
return this.u.getVisibility() == 0 ? this.a == 1 : this.a != 2;
|
||||
}
|
||||
|
||||
boolean h() {
|
||||
return this.u.getVisibility() != 0 ? this.a == 2 : this.a != 1;
|
||||
}
|
||||
|
||||
void i() {
|
||||
this.g.a();
|
||||
}
|
||||
|
||||
void j() {
|
||||
if (n()) {
|
||||
q();
|
||||
this.u.getViewTreeObserver().addOnPreDrawListener(this.A);
|
||||
}
|
||||
}
|
||||
|
||||
void k() {
|
||||
}
|
||||
|
||||
void l() {
|
||||
if (this.A != null) {
|
||||
this.u.getViewTreeObserver().removeOnPreDrawListener(this.A);
|
||||
this.A = null;
|
||||
}
|
||||
}
|
||||
|
||||
void m() {
|
||||
float rotation = this.u.getRotation();
|
||||
if (this.i != rotation) {
|
||||
this.i = rotation;
|
||||
u();
|
||||
}
|
||||
}
|
||||
|
||||
boolean n() {
|
||||
return true;
|
||||
}
|
||||
|
||||
final void o() {
|
||||
c(this.r);
|
||||
}
|
||||
|
||||
final void p() {
|
||||
Rect rect = this.w;
|
||||
a(rect);
|
||||
b(rect);
|
||||
this.v.a(rect.left, rect.top, rect.right, rect.bottom);
|
||||
}
|
||||
|
||||
final void d(float f) {
|
||||
if (this.p != f) {
|
||||
this.p = f;
|
||||
a(this.n, this.o, this.p);
|
||||
}
|
||||
}
|
||||
|
||||
float b() {
|
||||
return this.n;
|
||||
}
|
||||
|
||||
void a(PorterDuff.Mode mode) {
|
||||
Drawable drawable = this.j;
|
||||
if (drawable != null) {
|
||||
DrawableCompat.a(drawable, mode);
|
||||
}
|
||||
}
|
||||
|
||||
final void b(float f) {
|
||||
if (this.o != f) {
|
||||
this.o = f;
|
||||
a(this.n, this.o, this.p);
|
||||
}
|
||||
}
|
||||
|
||||
final MotionSpec c() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
void d(Animator.AnimatorListener animatorListener) {
|
||||
ArrayList<Animator.AnimatorListener> arrayList = this.s;
|
||||
if (arrayList == null) {
|
||||
return;
|
||||
}
|
||||
arrayList.remove(animatorListener);
|
||||
}
|
||||
|
||||
public void c(Animator.AnimatorListener animatorListener) {
|
||||
ArrayList<Animator.AnimatorListener> arrayList = this.t;
|
||||
if (arrayList == null) {
|
||||
return;
|
||||
}
|
||||
arrayList.remove(animatorListener);
|
||||
}
|
||||
|
||||
final void a(float f) {
|
||||
if (this.n != f) {
|
||||
this.n = f;
|
||||
a(this.n, this.o, this.p);
|
||||
}
|
||||
}
|
||||
|
||||
final void b(MotionSpec motionSpec) {
|
||||
this.c = motionSpec;
|
||||
}
|
||||
|
||||
void b(Animator.AnimatorListener animatorListener) {
|
||||
if (this.s == null) {
|
||||
this.s = new ArrayList<>();
|
||||
}
|
||||
this.s.add(animatorListener);
|
||||
}
|
||||
|
||||
private void a(float f, Matrix matrix) {
|
||||
matrix.reset();
|
||||
if (this.u.getDrawable() == null || this.q == 0) {
|
||||
return;
|
||||
}
|
||||
RectF rectF = this.x;
|
||||
RectF rectF2 = this.y;
|
||||
rectF.set(0.0f, 0.0f, r0.getIntrinsicWidth(), r0.getIntrinsicHeight());
|
||||
int i = this.q;
|
||||
rectF2.set(0.0f, 0.0f, i, i);
|
||||
matrix.setRectToRect(rectF, rectF2, Matrix.ScaleToFit.CENTER);
|
||||
int i2 = this.q;
|
||||
matrix.postScale(f, f, i2 / 2.0f, i2 / 2.0f);
|
||||
}
|
||||
|
||||
void b(final InternalVisibilityChangedListener internalVisibilityChangedListener, final boolean z) {
|
||||
if (h()) {
|
||||
return;
|
||||
}
|
||||
Animator animator = this.b;
|
||||
if (animator != null) {
|
||||
animator.cancel();
|
||||
}
|
||||
if (t()) {
|
||||
if (this.u.getVisibility() != 0) {
|
||||
this.u.setAlpha(0.0f);
|
||||
this.u.setScaleY(0.0f);
|
||||
this.u.setScaleX(0.0f);
|
||||
c(0.0f);
|
||||
}
|
||||
MotionSpec motionSpec = this.c;
|
||||
if (motionSpec == null) {
|
||||
motionSpec = s();
|
||||
}
|
||||
AnimatorSet a = a(motionSpec, 1.0f, 1.0f, 1.0f);
|
||||
a.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.floatingactionbutton.FloatingActionButtonImpl.2
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator2) {
|
||||
FloatingActionButtonImpl floatingActionButtonImpl = FloatingActionButtonImpl.this;
|
||||
floatingActionButtonImpl.a = 0;
|
||||
floatingActionButtonImpl.b = null;
|
||||
InternalVisibilityChangedListener internalVisibilityChangedListener2 = internalVisibilityChangedListener;
|
||||
if (internalVisibilityChangedListener2 != null) {
|
||||
internalVisibilityChangedListener2.a();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator2) {
|
||||
FloatingActionButtonImpl.this.u.a(0, z);
|
||||
FloatingActionButtonImpl floatingActionButtonImpl = FloatingActionButtonImpl.this;
|
||||
floatingActionButtonImpl.a = 2;
|
||||
floatingActionButtonImpl.b = animator2;
|
||||
}
|
||||
});
|
||||
ArrayList<Animator.AnimatorListener> arrayList = this.s;
|
||||
if (arrayList != null) {
|
||||
Iterator<Animator.AnimatorListener> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
a.addListener(it.next());
|
||||
}
|
||||
}
|
||||
a.start();
|
||||
return;
|
||||
}
|
||||
this.u.a(0, z);
|
||||
this.u.setAlpha(1.0f);
|
||||
this.u.setScaleY(1.0f);
|
||||
this.u.setScaleX(1.0f);
|
||||
c(1.0f);
|
||||
if (internalVisibilityChangedListener != null) {
|
||||
internalVisibilityChangedListener.a();
|
||||
}
|
||||
}
|
||||
|
||||
final void a(MotionSpec motionSpec) {
|
||||
this.d = motionSpec;
|
||||
}
|
||||
|
||||
void a(float f, float f2, float f3) {
|
||||
ShadowDrawableWrapper shadowDrawableWrapper = this.h;
|
||||
if (shadowDrawableWrapper == null) {
|
||||
return;
|
||||
}
|
||||
shadowDrawableWrapper.a(f, this.p + f);
|
||||
throw null;
|
||||
}
|
||||
|
||||
void a(int[] iArr) {
|
||||
this.g.a(iArr);
|
||||
}
|
||||
|
||||
public void a(Animator.AnimatorListener animatorListener) {
|
||||
if (this.t == null) {
|
||||
this.t = new ArrayList<>();
|
||||
}
|
||||
this.t.add(animatorListener);
|
||||
}
|
||||
|
||||
void a(final InternalVisibilityChangedListener internalVisibilityChangedListener, final boolean z) {
|
||||
if (g()) {
|
||||
return;
|
||||
}
|
||||
Animator animator = this.b;
|
||||
if (animator != null) {
|
||||
animator.cancel();
|
||||
}
|
||||
if (t()) {
|
||||
MotionSpec motionSpec = this.d;
|
||||
if (motionSpec == null) {
|
||||
motionSpec = r();
|
||||
}
|
||||
AnimatorSet a = a(motionSpec, 0.0f, 0.0f, 0.0f);
|
||||
a.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.floatingactionbutton.FloatingActionButtonImpl.1
|
||||
private boolean a;
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationCancel(Animator animator2) {
|
||||
this.a = true;
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator2) {
|
||||
FloatingActionButtonImpl floatingActionButtonImpl = FloatingActionButtonImpl.this;
|
||||
floatingActionButtonImpl.a = 0;
|
||||
floatingActionButtonImpl.b = null;
|
||||
if (this.a) {
|
||||
return;
|
||||
}
|
||||
floatingActionButtonImpl.u.a(z ? 8 : 4, z);
|
||||
InternalVisibilityChangedListener internalVisibilityChangedListener2 = internalVisibilityChangedListener;
|
||||
if (internalVisibilityChangedListener2 != null) {
|
||||
internalVisibilityChangedListener2.b();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator2) {
|
||||
FloatingActionButtonImpl.this.u.a(0, z);
|
||||
FloatingActionButtonImpl floatingActionButtonImpl = FloatingActionButtonImpl.this;
|
||||
floatingActionButtonImpl.a = 1;
|
||||
floatingActionButtonImpl.b = animator2;
|
||||
this.a = false;
|
||||
}
|
||||
});
|
||||
ArrayList<Animator.AnimatorListener> arrayList = this.t;
|
||||
if (arrayList != null) {
|
||||
Iterator<Animator.AnimatorListener> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
a.addListener(it.next());
|
||||
}
|
||||
}
|
||||
a.start();
|
||||
return;
|
||||
}
|
||||
this.u.a(z ? 8 : 4, z);
|
||||
if (internalVisibilityChangedListener != null) {
|
||||
internalVisibilityChangedListener.b();
|
||||
}
|
||||
}
|
||||
|
||||
private AnimatorSet a(MotionSpec motionSpec, float f, float f2, float f3) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.u, (Property<VisibilityAwareImageButton, Float>) View.ALPHA, f);
|
||||
motionSpec.a("opacity").a((Animator) ofFloat);
|
||||
arrayList.add(ofFloat);
|
||||
ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this.u, (Property<VisibilityAwareImageButton, Float>) View.SCALE_X, f2);
|
||||
motionSpec.a("scale").a((Animator) ofFloat2);
|
||||
arrayList.add(ofFloat2);
|
||||
ObjectAnimator ofFloat3 = ObjectAnimator.ofFloat(this.u, (Property<VisibilityAwareImageButton, Float>) View.SCALE_Y, f2);
|
||||
motionSpec.a("scale").a((Animator) ofFloat3);
|
||||
arrayList.add(ofFloat3);
|
||||
a(f3, this.z);
|
||||
ObjectAnimator ofObject = ObjectAnimator.ofObject(this.u, new ImageMatrixProperty(), new MatrixEvaluator(), new Matrix(this.z));
|
||||
motionSpec.a("iconScale").a((Animator) ofObject);
|
||||
arrayList.add(ofObject);
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
AnimatorSetCompat.a(animatorSet, arrayList);
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
final Drawable a() {
|
||||
return this.m;
|
||||
}
|
||||
|
||||
void a(Rect rect) {
|
||||
this.h.getPadding(rect);
|
||||
throw null;
|
||||
}
|
||||
|
||||
private ValueAnimator a(ShadowAnimatorImpl shadowAnimatorImpl) {
|
||||
ValueAnimator valueAnimator = new ValueAnimator();
|
||||
valueAnimator.setInterpolator(B);
|
||||
valueAnimator.setDuration(100L);
|
||||
valueAnimator.addListener(shadowAnimatorImpl);
|
||||
valueAnimator.addUpdateListener(shadowAnimatorImpl);
|
||||
valueAnimator.setFloatValues(0.0f, 1.0f);
|
||||
return valueAnimator;
|
||||
}
|
||||
}
|
@@ -0,0 +1,138 @@
|
||||
package com.google.android.material.floatingactionbutton;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.StateListAnimator;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.graphics.drawable.RippleDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.Property;
|
||||
import android.view.View;
|
||||
import com.google.android.material.internal.VisibilityAwareImageButton;
|
||||
import com.google.android.material.ripple.RippleUtils;
|
||||
import com.google.android.material.shadow.ShadowDrawableWrapper;
|
||||
import com.google.android.material.shadow.ShadowViewDelegate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class FloatingActionButtonImplLollipop extends FloatingActionButtonImpl {
|
||||
private InsetDrawable I;
|
||||
|
||||
FloatingActionButtonImplLollipop(VisibilityAwareImageButton visibilityAwareImageButton, ShadowViewDelegate shadowViewDelegate) {
|
||||
super(visibilityAwareImageButton, shadowViewDelegate);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl
|
||||
void a(float f, float f2, float f3) {
|
||||
if (Build.VERSION.SDK_INT == 21) {
|
||||
this.u.refreshDrawableState();
|
||||
} else {
|
||||
StateListAnimator stateListAnimator = new StateListAnimator();
|
||||
stateListAnimator.addState(FloatingActionButtonImpl.C, a(f, f3));
|
||||
stateListAnimator.addState(FloatingActionButtonImpl.D, a(f, f2));
|
||||
stateListAnimator.addState(FloatingActionButtonImpl.E, a(f, f2));
|
||||
stateListAnimator.addState(FloatingActionButtonImpl.F, a(f, f2));
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(ObjectAnimator.ofFloat(this.u, "elevation", f).setDuration(0L));
|
||||
int i = Build.VERSION.SDK_INT;
|
||||
if (i >= 22 && i <= 24) {
|
||||
VisibilityAwareImageButton visibilityAwareImageButton = this.u;
|
||||
arrayList.add(ObjectAnimator.ofFloat(visibilityAwareImageButton, (Property<VisibilityAwareImageButton, Float>) View.TRANSLATION_Z, visibilityAwareImageButton.getTranslationZ()).setDuration(100L));
|
||||
}
|
||||
arrayList.add(ObjectAnimator.ofFloat(this.u, (Property<VisibilityAwareImageButton, Float>) View.TRANSLATION_Z, 0.0f).setDuration(100L));
|
||||
animatorSet.playSequentially((Animator[]) arrayList.toArray(new Animator[0]));
|
||||
animatorSet.setInterpolator(FloatingActionButtonImpl.B);
|
||||
stateListAnimator.addState(FloatingActionButtonImpl.G, animatorSet);
|
||||
stateListAnimator.addState(FloatingActionButtonImpl.H, a(0.0f, 0.0f));
|
||||
this.u.setStateListAnimator(stateListAnimator);
|
||||
}
|
||||
if (this.v.a()) {
|
||||
p();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl
|
||||
void b(ColorStateList colorStateList) {
|
||||
Drawable drawable = this.k;
|
||||
if (drawable instanceof RippleDrawable) {
|
||||
((RippleDrawable) drawable).setColor(RippleUtils.a(colorStateList));
|
||||
} else {
|
||||
super.b(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl
|
||||
void i() {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl
|
||||
void k() {
|
||||
p();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl
|
||||
boolean n() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl
|
||||
public float b() {
|
||||
return this.u.getElevation();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl
|
||||
void b(Rect rect) {
|
||||
if (this.v.a()) {
|
||||
this.I = new InsetDrawable(this.k, rect.left, rect.top, rect.right, rect.bottom);
|
||||
this.v.a(this.I);
|
||||
} else {
|
||||
this.v.a(this.k);
|
||||
}
|
||||
}
|
||||
|
||||
private Animator a(float f, float f2) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.play(ObjectAnimator.ofFloat(this.u, "elevation", f).setDuration(0L)).with(ObjectAnimator.ofFloat(this.u, (Property<VisibilityAwareImageButton, Float>) View.TRANSLATION_Z, f2).setDuration(100L));
|
||||
animatorSet.setInterpolator(FloatingActionButtonImpl.B);
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl
|
||||
void a(int[] iArr) {
|
||||
if (Build.VERSION.SDK_INT == 21) {
|
||||
if (this.u.isEnabled()) {
|
||||
this.u.setElevation(this.n);
|
||||
if (this.u.isPressed()) {
|
||||
this.u.setTranslationZ(this.p);
|
||||
return;
|
||||
} else if (!this.u.isFocused() && !this.u.isHovered()) {
|
||||
this.u.setTranslationZ(0.0f);
|
||||
return;
|
||||
} else {
|
||||
this.u.setTranslationZ(this.o);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.u.setElevation(0.0f);
|
||||
this.u.setTranslationZ(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl
|
||||
void a(Rect rect) {
|
||||
if (this.v.a()) {
|
||||
float b = this.v.b();
|
||||
float b2 = b() + this.p;
|
||||
int ceil = (int) Math.ceil(ShadowDrawableWrapper.a(b2, b, false));
|
||||
int ceil2 = (int) Math.ceil(ShadowDrawableWrapper.b(b2, b, false));
|
||||
rect.set(ceil, ceil2, ceil, ceil2);
|
||||
return;
|
||||
}
|
||||
rect.set(0, 0, 0, 0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user