230 lines
7.0 KiB
Java
230 lines
7.0 KiB
Java
package c.q.a.l;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Matrix;
|
|
import android.graphics.Point;
|
|
import android.graphics.RectF;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.util.AttributeSet;
|
|
import android.util.Log;
|
|
import android.view.WindowManager;
|
|
import android.view.animation.AccelerateInterpolator;
|
|
import android.widget.ImageView;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.appcompat.widget.AppCompatImageView;
|
|
import c.q.a.i.b;
|
|
import com.yalantis.ucrop.UCropActivity;
|
|
/* compiled from: TransformImageView */
|
|
public class c extends AppCompatImageView {
|
|
public final float[] i;
|
|
public final float[] j;
|
|
public final float[] k;
|
|
public Matrix l;
|
|
public int m;
|
|
public int n;
|
|
public a o;
|
|
public float[] p;
|
|
public float[] q;
|
|
public boolean r;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public boolean f1532s;
|
|
public int t;
|
|
public String u;
|
|
public String v;
|
|
public b w;
|
|
|
|
/* compiled from: TransformImageView */
|
|
public interface a {
|
|
}
|
|
|
|
public c(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public c(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.i = new float[8];
|
|
this.j = new float[2];
|
|
this.k = new float[9];
|
|
this.l = new Matrix();
|
|
this.r = false;
|
|
this.f1532s = false;
|
|
this.t = 0;
|
|
c();
|
|
}
|
|
|
|
public float a(@NonNull Matrix matrix) {
|
|
matrix.getValues(this.k);
|
|
float[] fArr = this.k;
|
|
matrix.getValues(fArr);
|
|
return (float) (-(Math.atan2((double) fArr[1], (double) this.k[0]) * 57.29577951308232d));
|
|
}
|
|
|
|
public float b(@NonNull Matrix matrix) {
|
|
matrix.getValues(this.k);
|
|
double pow = Math.pow((double) this.k[0], 2.0d);
|
|
matrix.getValues(this.k);
|
|
return (float) Math.sqrt(Math.pow((double) this.k[3], 2.0d) + pow);
|
|
}
|
|
|
|
public void c() {
|
|
setScaleType(ImageView.ScaleType.MATRIX);
|
|
}
|
|
|
|
public void d() {
|
|
Drawable drawable = getDrawable();
|
|
if (drawable != null) {
|
|
float intrinsicWidth = (float) drawable.getIntrinsicWidth();
|
|
float intrinsicHeight = (float) drawable.getIntrinsicHeight();
|
|
Log.d("TransformImageView", String.format("Image size: [%d:%d]", Integer.valueOf((int) intrinsicWidth), Integer.valueOf((int) intrinsicHeight)));
|
|
RectF rectF = new RectF(0.0f, 0.0f, intrinsicWidth, intrinsicHeight);
|
|
this.p = c.q.a.k.a.s(rectF);
|
|
this.q = c.q.a.k.a.q(rectF);
|
|
this.f1532s = true;
|
|
a aVar = this.o;
|
|
if (aVar != null) {
|
|
UCropActivity.a aVar2 = (UCropActivity.a) aVar;
|
|
UCropActivity.this.u.animate().alpha(1.0f).setDuration(300).setInterpolator(new AccelerateInterpolator());
|
|
UCropActivity.this.G.setClickable(false);
|
|
UCropActivity uCropActivity = UCropActivity.this;
|
|
uCropActivity.t = false;
|
|
uCropActivity.supportInvalidateOptionsMenu();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void e(float f, float f2, float f3) {
|
|
if (f != 0.0f) {
|
|
this.l.postRotate(f, f2, f3);
|
|
setImageMatrix(this.l);
|
|
a aVar = this.o;
|
|
if (aVar != null) {
|
|
((UCropActivity.a) aVar).a(a(this.l));
|
|
}
|
|
}
|
|
}
|
|
|
|
public void f(float f, float f2, float f3) {
|
|
if (f != 0.0f) {
|
|
this.l.postScale(f, f, f2, f3);
|
|
setImageMatrix(this.l);
|
|
a aVar = this.o;
|
|
if (aVar != null) {
|
|
((UCropActivity.a) aVar).b(b(this.l));
|
|
}
|
|
}
|
|
}
|
|
|
|
public void g(float f, float f2) {
|
|
if (f != 0.0f || f2 != 0.0f) {
|
|
this.l.postTranslate(f, f2);
|
|
setImageMatrix(this.l);
|
|
}
|
|
}
|
|
|
|
public float getCurrentAngle() {
|
|
return a(this.l);
|
|
}
|
|
|
|
public float getCurrentScale() {
|
|
return b(this.l);
|
|
}
|
|
|
|
public b getExifInfo() {
|
|
return this.w;
|
|
}
|
|
|
|
public String getImageInputPath() {
|
|
return this.u;
|
|
}
|
|
|
|
public String getImageOutputPath() {
|
|
return this.v;
|
|
}
|
|
|
|
public int getMaxBitmapSize() {
|
|
int i;
|
|
if (this.t <= 0) {
|
|
WindowManager windowManager = (WindowManager) getContext().getSystemService("window");
|
|
Point point = new Point();
|
|
if (windowManager != null) {
|
|
windowManager.getDefaultDisplay().getSize(point);
|
|
}
|
|
int i2 = point.x;
|
|
int i3 = point.y;
|
|
int sqrt = (int) Math.sqrt(Math.pow((double) i3, 2.0d) + Math.pow((double) i2, 2.0d));
|
|
Canvas canvas = new Canvas();
|
|
int min = Math.min(canvas.getMaximumBitmapWidth(), canvas.getMaximumBitmapHeight());
|
|
if (min > 0) {
|
|
sqrt = Math.min(sqrt, min);
|
|
}
|
|
try {
|
|
i = c.q.a.k.a.v();
|
|
} catch (Exception e) {
|
|
Log.d("EglUtils", "getMaxTextureSize: ", e);
|
|
i = 0;
|
|
}
|
|
if (i > 0) {
|
|
sqrt = Math.min(sqrt, i);
|
|
}
|
|
c.d.b.a.a.d0("maxBitmapSize: ", sqrt, "BitmapLoadUtils");
|
|
this.t = sqrt;
|
|
}
|
|
return this.t;
|
|
}
|
|
|
|
@Nullable
|
|
public Bitmap getViewBitmap() {
|
|
if (getDrawable() == null || !(getDrawable() instanceof c.q.a.k.b)) {
|
|
return null;
|
|
}
|
|
return ((c.q.a.k.b) getDrawable()).b;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onLayout(boolean z2, int i, int i2, int i3, int i4) {
|
|
super.onLayout(z2, i, i2, i3, i4);
|
|
if (z2 || (this.r && !this.f1532s)) {
|
|
int paddingLeft = getPaddingLeft();
|
|
int paddingTop = getPaddingTop();
|
|
this.m = (getWidth() - getPaddingRight()) - paddingLeft;
|
|
this.n = (getHeight() - getPaddingBottom()) - paddingTop;
|
|
d();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatImageView, android.widget.ImageView
|
|
public void setImageBitmap(Bitmap bitmap) {
|
|
setImageDrawable(new c.q.a.k.b(bitmap));
|
|
}
|
|
|
|
@Override // android.widget.ImageView
|
|
public void setImageMatrix(Matrix matrix) {
|
|
super.setImageMatrix(matrix);
|
|
this.l.set(matrix);
|
|
this.l.mapPoints(this.i, this.p);
|
|
this.l.mapPoints(this.j, this.q);
|
|
}
|
|
|
|
public void setMaxBitmapSize(int i) {
|
|
this.t = i;
|
|
}
|
|
|
|
@Override // android.widget.ImageView
|
|
public void setScaleType(ImageView.ScaleType scaleType) {
|
|
if (scaleType == ImageView.ScaleType.MATRIX) {
|
|
super.setScaleType(scaleType);
|
|
} else {
|
|
Log.w("TransformImageView", "Invalid ScaleType. Only ScaleType.MATRIX can be used");
|
|
}
|
|
}
|
|
|
|
public void setTransformImageListener(a aVar) {
|
|
this.o = aVar;
|
|
}
|
|
}
|