139 lines
5.7 KiB
Java
139 lines
5.7 KiB
Java
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);
|
|
}
|
|
}
|