1196 lines
42 KiB
Java
1196 lines
42 KiB
Java
|
package com.kofax.kmc.kui.uicontrols;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.res.TypedArray;
|
||
|
import android.graphics.Bitmap;
|
||
|
import android.graphics.Canvas;
|
||
|
import android.graphics.Color;
|
||
|
import android.graphics.DashPathEffect;
|
||
|
import android.graphics.Paint;
|
||
|
import android.graphics.Path;
|
||
|
import android.graphics.Point;
|
||
|
import android.graphics.Rect;
|
||
|
import android.os.Bundle;
|
||
|
import android.os.Parcelable;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.MotionEvent;
|
||
|
import android.view.ScaleGestureDetector;
|
||
|
import android.view.View;
|
||
|
import android.view.WindowManager;
|
||
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||
|
import com.kofax.BuildConfig;
|
||
|
import com.kofax.R;
|
||
|
import com.kofax.kmc.ken.engines.data.BoundingRect;
|
||
|
import com.kofax.kmc.ken.engines.data.BoundingTetragon;
|
||
|
import com.kofax.kmc.ken.engines.data.Image;
|
||
|
import com.kofax.kmc.kui.uicontrols.data.ImageCacheType;
|
||
|
import com.kofax.kmc.kut.utilities.Licensing;
|
||
|
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
|
||
|
import com.kofax.kmc.kut.utilities.error.IllegalArgumentException;
|
||
|
import com.kofax.kmc.kut.utilities.error.KmcException;
|
||
|
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
|
||
|
import com.kofax.mobile.sdk._internal.c;
|
||
|
import com.kofax.mobile.sdk._internal.dagger.Injector;
|
||
|
import com.kofax.mobile.sdk._internal.k;
|
||
|
import java.io.IOException;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Collections;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.UUID;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class ImgReviewEditCntrl extends View implements View.OnTouchListener {
|
||
|
private static final String TAG = "ImgReviewEditCntrl";
|
||
|
private static final float kT = 25.0f;
|
||
|
private static final int kU = 35;
|
||
|
private Image image;
|
||
|
private int kV;
|
||
|
private int kW;
|
||
|
private Point kX;
|
||
|
private Point kY;
|
||
|
private Point kZ;
|
||
|
private Point lA;
|
||
|
private Point lB;
|
||
|
private int lC;
|
||
|
private int lD;
|
||
|
private int lE;
|
||
|
private Line_Style_Solid lF;
|
||
|
private BoundingTetragon lG;
|
||
|
private String lH;
|
||
|
private boolean lI;
|
||
|
private c lJ;
|
||
|
private ImageCacheType lK;
|
||
|
private final List<BoundingRect> lL;
|
||
|
private final Rect lM;
|
||
|
private boolean lN;
|
||
|
private float lO;
|
||
|
private Point la;
|
||
|
private int lb;
|
||
|
private Paint lc;
|
||
|
private Paint ld;
|
||
|
private boolean le;
|
||
|
private boolean lf;
|
||
|
private int lg;
|
||
|
private boolean lh;
|
||
|
boolean li;
|
||
|
private float lj;
|
||
|
private float lk;
|
||
|
private float ll;
|
||
|
private float lm;
|
||
|
private float ln;
|
||
|
private float lo;
|
||
|
private Point lp;
|
||
|
private Point lq;
|
||
|
private Point lr;
|
||
|
private Point ls;
|
||
|
private boolean lt;
|
||
|
private float lu;
|
||
|
private float lv;
|
||
|
private Bitmap lw;
|
||
|
private Point lx;
|
||
|
private Point ly;
|
||
|
private Rect lz;
|
||
|
private int rotation;
|
||
|
public ScaleGestureDetector scaleGestureDetector;
|
||
|
private int state;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public enum Line_Style_Solid {
|
||
|
LINE_STYLE_SOLID,
|
||
|
LINE_STYLE_DOTTED
|
||
|
}
|
||
|
|
||
|
public void setImage(Image image) throws KmcException {
|
||
|
az();
|
||
|
this.image = image;
|
||
|
if (image != null) {
|
||
|
this.lO = image.getImageBitmapScaling().floatValue();
|
||
|
this.image.getImageRepresentation();
|
||
|
if (this.image.getImageRepresentation().equals(Image.ImageRep.IMAGE_REP_BITMAP) || this.image.getImageRepresentation().equals(Image.ImageRep.IMAGE_REP_BOTH)) {
|
||
|
if (this.image.getImageBitmapScaling().floatValue() == 1.0f) {
|
||
|
String str = TAG;
|
||
|
StringBuilder sb = new StringBuilder("[Bitmap]bm.getHeight() = ");
|
||
|
sb.append(this.image.getImageBitmapHeight());
|
||
|
k.e(str, sb.toString());
|
||
|
StringBuilder sb2 = new StringBuilder("[Bitmap]bm.getWidth() = ");
|
||
|
sb2.append(this.image.getImageBitmapWidth());
|
||
|
k.e(str, sb2.toString());
|
||
|
this.lO = 0.5f;
|
||
|
this.lw = this.image.createScaledBitmap(0.5f);
|
||
|
}
|
||
|
if (this.lw != null) {
|
||
|
av();
|
||
|
invalidate();
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
if (this.image.getImageRepresentation().equals(Image.ImageRep.IMAGE_REP_FILE)) {
|
||
|
try {
|
||
|
if (this.image.getImageBitmapScaling().floatValue() == 1.0f) {
|
||
|
this.lO = 0.5f;
|
||
|
}
|
||
|
if (this.image.getImageFileRep() == Image.ImageFileRep.FILE_STORED) {
|
||
|
Integer imageDPI = this.image.getImageDPI();
|
||
|
String imageMetaData = this.image.getImageMetaData();
|
||
|
Image.FriendI friendI = new Image.FriendI(this.image, BuildConfig.APPLICATION_ID);
|
||
|
this.image.imageReadFromFile(this.lO);
|
||
|
friendI.setImageMetaData(imageMetaData);
|
||
|
if (imageDPI != null) {
|
||
|
this.image.setImageDPI(imageDPI.intValue());
|
||
|
}
|
||
|
} else {
|
||
|
this.image.imageReadFromFileBuffer(this.lO);
|
||
|
}
|
||
|
Bitmap bitmap = this.lw;
|
||
|
if (bitmap != null) {
|
||
|
bitmap.recycle();
|
||
|
this.lw = null;
|
||
|
}
|
||
|
Bitmap v = v(this.image);
|
||
|
this.lw = v;
|
||
|
if (v != null) {
|
||
|
this.image.imageClearBitmap();
|
||
|
k.c(TAG, "--------------image.imageClearBitmap()");
|
||
|
}
|
||
|
if (this.lw != null) {
|
||
|
av();
|
||
|
invalidate();
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
} catch (KmcException unused) {
|
||
|
throw new KmcException(ErrorInfo.KMC_UI_SCALING_FACTOR);
|
||
|
}
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
throw new KmcException(ErrorInfo.KMC_UI_IMAGE_NULL);
|
||
|
}
|
||
|
|
||
|
private Bitmap v(Image image) {
|
||
|
Bitmap imageBitmap = image.getImageBitmap();
|
||
|
int width = imageBitmap.getWidth();
|
||
|
int height = imageBitmap.getHeight();
|
||
|
Bitmap createBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||
|
int[] iArr = new int[width * height];
|
||
|
imageBitmap.getPixels(iArr, 0, width, 0, 0, width, height);
|
||
|
createBitmap.setPixels(iArr, 0, width, 0, 0, width, height);
|
||
|
return createBitmap;
|
||
|
}
|
||
|
|
||
|
private void av() {
|
||
|
this.lk = this.lw.getHeight();
|
||
|
this.lj = this.lw.getWidth();
|
||
|
String str = TAG;
|
||
|
StringBuilder sb = new StringBuilder("image Wd&ht = ");
|
||
|
sb.append(this.lj);
|
||
|
sb.append(" ");
|
||
|
sb.append(this.lk);
|
||
|
k.c(str, sb.toString());
|
||
|
float height = getHeight();
|
||
|
float width = getWidth();
|
||
|
StringBuilder sb2 = new StringBuilder("displayHt ");
|
||
|
sb2.append(height);
|
||
|
sb2.append(" displayWd = ");
|
||
|
sb2.append(width);
|
||
|
k.c("InitImage", sb2.toString());
|
||
|
Point d = d(new Point((int) width, (int) height), new Point((int) this.lj, (int) this.lk));
|
||
|
this.ll = (width - d.x) / 2.0f;
|
||
|
this.lm = (height - d.y) / 2.0f;
|
||
|
this.ln = this.lj / d.x;
|
||
|
this.lz = a(this.lj, this.lk, d.x, d.y);
|
||
|
this.state = 0;
|
||
|
this.ly.x = 0;
|
||
|
this.ly.y = 0;
|
||
|
this.lu = 1.0f;
|
||
|
this.lv = 1.0f;
|
||
|
this.le = false;
|
||
|
this.lo = getDisplayToBitmapScalingFactor();
|
||
|
}
|
||
|
|
||
|
public void showCropRectangle(boolean z) {
|
||
|
this.lt = z;
|
||
|
invalidate();
|
||
|
}
|
||
|
|
||
|
public void setCropLineColor(int i) {
|
||
|
this.lC = i;
|
||
|
invalidate();
|
||
|
}
|
||
|
|
||
|
public void setCropCornerColor(int i) {
|
||
|
this.lD = i;
|
||
|
invalidate();
|
||
|
}
|
||
|
|
||
|
public void setCropLineStyle(Line_Style_Solid line_Style_Solid) {
|
||
|
this.lF = line_Style_Solid;
|
||
|
invalidate();
|
||
|
}
|
||
|
|
||
|
public void setCropTetragon(BoundingTetragon boundingTetragon) {
|
||
|
this.lG = boundingTetragon;
|
||
|
if (boundingTetragon != null) {
|
||
|
String str = TAG;
|
||
|
StringBuilder sb = new StringBuilder("setCropTetragon[scale value = ]");
|
||
|
sb.append(this.lO);
|
||
|
k.c(str, sb.toString());
|
||
|
this.ls.x = (int) (this.lG.getTopLeft().x * this.lO);
|
||
|
this.ls.y = (int) (this.lG.getTopLeft().y * this.lO);
|
||
|
this.lr.x = (int) (this.lG.getTopRight().x * this.lO);
|
||
|
this.lr.y = (int) (this.lG.getTopRight().y * this.lO);
|
||
|
this.lq.x = (int) (this.lG.getBottomLeft().x * this.lO);
|
||
|
this.lq.y = (int) (this.lG.getBottomLeft().y * this.lO);
|
||
|
this.lp.x = (int) (this.lG.getBottomRight().x * this.lO);
|
||
|
this.lp.y = (int) (this.lG.getBottomRight().y * this.lO);
|
||
|
this.lN = true;
|
||
|
}
|
||
|
invalidate();
|
||
|
}
|
||
|
|
||
|
public void showHighlights(BoundingRect[] boundingRectArr) {
|
||
|
clearHighlights();
|
||
|
if (boundingRectArr != null) {
|
||
|
Collections.addAll(this.lL, boundingRectArr);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void clearHighlights() {
|
||
|
this.lL.clear();
|
||
|
}
|
||
|
|
||
|
public void setHighlightColor(int i) {
|
||
|
this.lE = i;
|
||
|
invalidate();
|
||
|
}
|
||
|
|
||
|
public BoundingTetragon getCropTetragon() {
|
||
|
if (this.lG == null) {
|
||
|
this.lG = new BoundingTetragon();
|
||
|
}
|
||
|
try {
|
||
|
this.lG.setTopLeft(new Point((int) (this.ls.x / this.lO), (int) (this.ls.y / this.lO)));
|
||
|
this.lG.setTopRight(new Point((int) (this.lr.x / this.lO), (int) (this.lr.y / this.lO)));
|
||
|
this.lG.setBottomLeft(new Point((int) (this.lq.x / this.lO), (int) (this.lq.y / this.lO)));
|
||
|
this.lG.setBottomRight(new Point((int) (this.lp.x / this.lO), (int) (this.lp.y / this.lO)));
|
||
|
} catch (NullPointerException unused) {
|
||
|
}
|
||
|
return this.lG;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: com.kofax.kmc.kui.uicontrols.ImgReviewEditCntrl$1, reason: invalid class name */
|
||
|
/* loaded from: classes3.dex */
|
||
|
public static /* synthetic */ class AnonymousClass1 {
|
||
|
static final int[] lP;
|
||
|
|
||
|
static {
|
||
|
int[] iArr = new int[ImageCacheType.values().length];
|
||
|
lP = iArr;
|
||
|
try {
|
||
|
iArr[ImageCacheType.MEMORY.ordinal()] = 1;
|
||
|
} catch (NoSuchFieldError unused) {
|
||
|
}
|
||
|
try {
|
||
|
lP[ImageCacheType.DISK.ordinal()] = 2;
|
||
|
} catch (NoSuchFieldError unused2) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setImageCacheType(ImageCacheType imageCacheType) {
|
||
|
int i = AnonymousClass1.lP[imageCacheType.ordinal()];
|
||
|
if (i == 1) {
|
||
|
this.lJ = Injector.getInjector(getContext()).getMemoryBitmapCache();
|
||
|
} else if (i == 2) {
|
||
|
this.lJ = Injector.getInjector(getContext()).getDiskBitmapCache();
|
||
|
} else {
|
||
|
throw new IllegalArgumentException("Invalid ImageCacheType ".concat(String.valueOf(imageCacheType)));
|
||
|
}
|
||
|
this.lK = imageCacheType;
|
||
|
}
|
||
|
|
||
|
public ImgReviewEditCntrl(Context context) {
|
||
|
super(context);
|
||
|
this.kV = 0;
|
||
|
this.kX = new Point();
|
||
|
this.kY = new Point();
|
||
|
this.le = false;
|
||
|
this.lf = true;
|
||
|
this.lg = -1;
|
||
|
this.state = 0;
|
||
|
this.lh = false;
|
||
|
this.li = false;
|
||
|
this.lo = 1.0f;
|
||
|
this.lu = BitmapDescriptorFactory.HUE_RED;
|
||
|
this.lv = 1.0f;
|
||
|
this.lx = new Point();
|
||
|
this.ly = new Point();
|
||
|
this.lA = new Point(0, 0);
|
||
|
this.lC = -16776961;
|
||
|
this.lD = -16776961;
|
||
|
this.lE = -256;
|
||
|
this.lI = true;
|
||
|
this.lK = ImageCacheType.MEMORY;
|
||
|
this.lL = new ArrayList();
|
||
|
this.lM = new Rect();
|
||
|
this.lN = false;
|
||
|
b(context);
|
||
|
setImageCacheType(this.lK);
|
||
|
}
|
||
|
|
||
|
public ImgReviewEditCntrl(Context context, AttributeSet attributeSet) {
|
||
|
super(context, attributeSet);
|
||
|
this.kV = 0;
|
||
|
this.kX = new Point();
|
||
|
this.kY = new Point();
|
||
|
this.le = false;
|
||
|
this.lf = true;
|
||
|
this.lg = -1;
|
||
|
this.state = 0;
|
||
|
this.lh = false;
|
||
|
this.li = false;
|
||
|
this.lo = 1.0f;
|
||
|
this.lu = BitmapDescriptorFactory.HUE_RED;
|
||
|
this.lv = 1.0f;
|
||
|
this.lx = new Point();
|
||
|
this.ly = new Point();
|
||
|
this.lA = new Point(0, 0);
|
||
|
this.lC = -16776961;
|
||
|
this.lD = -16776961;
|
||
|
this.lE = -256;
|
||
|
this.lI = true;
|
||
|
this.lK = ImageCacheType.MEMORY;
|
||
|
this.lL = new ArrayList();
|
||
|
this.lM = new Rect();
|
||
|
this.lN = false;
|
||
|
b(context);
|
||
|
a(context, attributeSet);
|
||
|
setImageCacheType(this.lK);
|
||
|
}
|
||
|
|
||
|
public ImgReviewEditCntrl(Context context, AttributeSet attributeSet, int i) {
|
||
|
super(context, attributeSet, i);
|
||
|
this.kV = 0;
|
||
|
this.kX = new Point();
|
||
|
this.kY = new Point();
|
||
|
this.le = false;
|
||
|
this.lf = true;
|
||
|
this.lg = -1;
|
||
|
this.state = 0;
|
||
|
this.lh = false;
|
||
|
this.li = false;
|
||
|
this.lo = 1.0f;
|
||
|
this.lu = BitmapDescriptorFactory.HUE_RED;
|
||
|
this.lv = 1.0f;
|
||
|
this.lx = new Point();
|
||
|
this.ly = new Point();
|
||
|
this.lA = new Point(0, 0);
|
||
|
this.lC = -16776961;
|
||
|
this.lD = -16776961;
|
||
|
this.lE = -256;
|
||
|
this.lI = true;
|
||
|
this.lK = ImageCacheType.MEMORY;
|
||
|
this.lL = new ArrayList();
|
||
|
this.lM = new Rect();
|
||
|
this.lN = false;
|
||
|
b(context);
|
||
|
a(context, attributeSet);
|
||
|
setImageCacheType(this.lK);
|
||
|
}
|
||
|
|
||
|
private void a(Context context, AttributeSet attributeSet) {
|
||
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.img_review_edit_cntrl);
|
||
|
Boolean valueOf = Boolean.valueOf(obtainStyledAttributes.getBoolean(R.styleable.img_review_edit_cntrl_retain_image, true));
|
||
|
if (valueOf != null) {
|
||
|
setRetainImage(valueOf.booleanValue());
|
||
|
}
|
||
|
obtainStyledAttributes.recycle();
|
||
|
}
|
||
|
|
||
|
private void b(Context context) {
|
||
|
setOnTouchListener(this);
|
||
|
this.scaleGestureDetector = new ScaleGestureDetector(context, new a(this, null));
|
||
|
this.lc = new Paint();
|
||
|
this.ls = new Point();
|
||
|
this.lr = new Point();
|
||
|
this.lq = new Point();
|
||
|
this.lp = new Point();
|
||
|
this.ly.x = 0;
|
||
|
this.ly.y = 0;
|
||
|
setLayerType(1, null);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View.OnTouchListener
|
||
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||
|
if (this.lw == null) {
|
||
|
return false;
|
||
|
}
|
||
|
this.lh = true;
|
||
|
this.scaleGestureDetector.onTouchEvent(motionEvent);
|
||
|
int action = motionEvent.getAction();
|
||
|
this.kV = motionEvent.getPointerCount();
|
||
|
String str = TAG;
|
||
|
StringBuilder sb = new StringBuilder("PINCH COUNT(start) = ");
|
||
|
sb.append(motionEvent.getPointerCount());
|
||
|
k.c(str, sb.toString());
|
||
|
if (this.kV > 1) {
|
||
|
this.le = true;
|
||
|
this.li = false;
|
||
|
}
|
||
|
int x = (int) motionEvent.getX();
|
||
|
int y = (int) motionEvent.getY();
|
||
|
if (action == 0) {
|
||
|
if (getParent() != null) {
|
||
|
getParent().requestDisallowInterceptTouchEvent(true);
|
||
|
}
|
||
|
this.la = new Point(x, y);
|
||
|
Point point = new Point(x, y);
|
||
|
this.kZ = point;
|
||
|
Point b = b(point);
|
||
|
this.state = 0;
|
||
|
if (e(b, this.ls)) {
|
||
|
this.state = 1;
|
||
|
this.lb = 1;
|
||
|
} else if (e(b, this.lr)) {
|
||
|
this.state = 1;
|
||
|
this.lb = 2;
|
||
|
} else if (e(b, this.lq)) {
|
||
|
this.state = 1;
|
||
|
this.lb = 3;
|
||
|
} else if (e(b, this.lp)) {
|
||
|
this.state = 1;
|
||
|
this.lb = 4;
|
||
|
} else {
|
||
|
int c = c(x, y);
|
||
|
this.kW = c;
|
||
|
if (c != 0) {
|
||
|
this.state = 2;
|
||
|
}
|
||
|
if (this.state == 0 && this.le && this.lu > 1.0f) {
|
||
|
this.state = 3;
|
||
|
if (this.lA.x == 0) {
|
||
|
this.lA.x = 0;
|
||
|
this.lA.y = 0;
|
||
|
}
|
||
|
this.lx.x = this.kZ.x - this.lA.x;
|
||
|
this.lx.y = this.kZ.y - this.lA.y;
|
||
|
}
|
||
|
}
|
||
|
} else if (action != 1) {
|
||
|
if (action == 2) {
|
||
|
if (this.le && !this.lf) {
|
||
|
return true;
|
||
|
}
|
||
|
this.kZ = new Point(x, y);
|
||
|
Point b2 = b(new Point(this.kZ.x, this.kZ.y));
|
||
|
int i = this.state;
|
||
|
if (i != 3 && !this.lt) {
|
||
|
return true;
|
||
|
}
|
||
|
if (i == 1) {
|
||
|
int i2 = this.lb;
|
||
|
if (i2 == 1) {
|
||
|
Point point2 = this.ls;
|
||
|
this.ls = b2;
|
||
|
if (!a(this.lq, b2, this.lr, i2)) {
|
||
|
this.ls = point2;
|
||
|
}
|
||
|
if (this.ls.x > this.lj || this.ls.y > this.lk || this.ls.x < 0 || this.ls.y < 0) {
|
||
|
this.ls = point2;
|
||
|
}
|
||
|
if (this.ls.y > this.lq.y) {
|
||
|
this.ls = point2;
|
||
|
}
|
||
|
if (this.ls.x > this.lr.x) {
|
||
|
this.ls = point2;
|
||
|
}
|
||
|
} else if (i2 == 2) {
|
||
|
Point point3 = this.lr;
|
||
|
this.lr = b2;
|
||
|
if (!a(this.lp, b2, this.ls, i2)) {
|
||
|
this.lr = point3;
|
||
|
}
|
||
|
if (this.lr.x > this.lj || this.lr.y > this.lk || this.lr.x < 0 || this.lr.y < 0) {
|
||
|
this.lr = point3;
|
||
|
}
|
||
|
if (this.lr.y > this.lp.y) {
|
||
|
this.lr = point3;
|
||
|
}
|
||
|
if (this.ls.x > this.lr.x) {
|
||
|
this.lr = point3;
|
||
|
}
|
||
|
} else if (i2 == 3) {
|
||
|
Point point4 = this.lq;
|
||
|
this.lq = b2;
|
||
|
if (!a(this.ls, b2, this.lp, i2)) {
|
||
|
this.lq = point4;
|
||
|
}
|
||
|
if (this.lq.x > this.lj || this.lq.y > this.lk || this.lq.x < 0 || this.lq.y < 0) {
|
||
|
this.lq = point4;
|
||
|
}
|
||
|
if (this.lq.y < this.ls.y) {
|
||
|
this.lq = point4;
|
||
|
}
|
||
|
if (this.lp.x < this.lq.x) {
|
||
|
this.lq = point4;
|
||
|
}
|
||
|
} else if (i2 == 4) {
|
||
|
Point point5 = this.lp;
|
||
|
this.lp = b2;
|
||
|
if (!a(this.lr, b2, this.lq, i2)) {
|
||
|
this.lp = point5;
|
||
|
}
|
||
|
if (this.lp.x > this.lj || this.lp.y > this.lk || this.lp.x < 0 || this.lp.y < 0) {
|
||
|
this.lp = point5;
|
||
|
}
|
||
|
if (this.lp.y < this.lr.y) {
|
||
|
this.lp = point5;
|
||
|
}
|
||
|
if (this.lp.x < this.lq.x) {
|
||
|
this.lp = point5;
|
||
|
}
|
||
|
}
|
||
|
} else if (i == 2) {
|
||
|
Point point6 = new Point(x, y);
|
||
|
this.kZ = point6;
|
||
|
a(this.kW, point6);
|
||
|
} else if (i == 3) {
|
||
|
this.ly.x = this.kZ.x - this.lx.x;
|
||
|
this.ly.y = this.kZ.y - this.lx.y;
|
||
|
StringBuilder sb2 = new StringBuilder("PanOffset ");
|
||
|
sb2.append(this.ly.x);
|
||
|
sb2.append(" ");
|
||
|
sb2.append(this.ly.y);
|
||
|
sb2.append(" ");
|
||
|
sb2.append(this.kZ.x);
|
||
|
sb2.append(" ");
|
||
|
sb2.append(this.kZ.y);
|
||
|
sb2.append(" PanOrn ");
|
||
|
sb2.append(this.lx.x);
|
||
|
sb2.append(" ");
|
||
|
sb2.append(this.lx.y);
|
||
|
k.c("PanOrigin", sb2.toString());
|
||
|
}
|
||
|
}
|
||
|
} else if (this.le) {
|
||
|
this.lf = true;
|
||
|
StringBuilder sb3 = new StringBuilder("firstPinchThisGesture ");
|
||
|
sb3.append(this.lf);
|
||
|
k.c("State", sb3.toString());
|
||
|
aw();
|
||
|
}
|
||
|
invalidate();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
private void aw() {
|
||
|
this.state = 0;
|
||
|
StringBuilder sb = new StringBuilder("panoffset = ");
|
||
|
sb.append(this.ly.x);
|
||
|
sb.append(" ");
|
||
|
sb.append(this.ly.y);
|
||
|
k.c("PanOffset", sb.toString());
|
||
|
Point a2 = a(new Point(0, 0));
|
||
|
if (a2.x > getWidth() / 2) {
|
||
|
float width = (a2.x - (getWidth() / 2)) + 1;
|
||
|
this.ly.x = (int) (r3.x - width);
|
||
|
}
|
||
|
if (a2.y > getHeight() / 2) {
|
||
|
float height = (a2.y - (getHeight() / 2)) + 1;
|
||
|
this.ly.y = (int) (r2.y - height);
|
||
|
}
|
||
|
Point a3 = a(new Point((int) this.lj, (int) this.lk));
|
||
|
if (a3.x < getWidth() / 2) {
|
||
|
Point point = this.ly;
|
||
|
point.x = (int) (point.x - ((a3.x - (getWidth() / 2)) - 1));
|
||
|
}
|
||
|
if (a3.y < getHeight() / 2) {
|
||
|
Point point2 = this.ly;
|
||
|
point2.y = (int) (point2.y - ((a3.y - (getHeight() / 2)) - 1));
|
||
|
}
|
||
|
this.lA.x = this.ly.x;
|
||
|
this.lA.y = this.ly.y;
|
||
|
if (this.lu == 1.0d) {
|
||
|
this.ly.x = 0;
|
||
|
this.ly.y = 0;
|
||
|
this.lA.x = 0;
|
||
|
this.lA.y = 0;
|
||
|
}
|
||
|
invalidate();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class a extends ScaleGestureDetector.SimpleOnScaleGestureListener {
|
||
|
private final int lR;
|
||
|
private final int lS;
|
||
|
final ImgReviewEditCntrl lT;
|
||
|
|
||
|
private a(ImgReviewEditCntrl imgReviewEditCntrl) {
|
||
|
this.lT = imgReviewEditCntrl;
|
||
|
this.lR = 1;
|
||
|
this.lS = 15;
|
||
|
}
|
||
|
|
||
|
/* synthetic */ a(ImgReviewEditCntrl imgReviewEditCntrl, AnonymousClass1 anonymousClass1) {
|
||
|
this(imgReviewEditCntrl);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ScaleGestureDetector.SimpleOnScaleGestureListener, android.view.ScaleGestureDetector.OnScaleGestureListener
|
||
|
public boolean onScale(ScaleGestureDetector scaleGestureDetector) {
|
||
|
this.lT.lv *= this.lT.scaleGestureDetector.getScaleFactor();
|
||
|
StringBuilder sb = new StringBuilder("focus.x= ");
|
||
|
sb.append(scaleGestureDetector.getFocusX());
|
||
|
sb.append(" focus.y = ");
|
||
|
sb.append(scaleGestureDetector.getFocusY());
|
||
|
k.c("Zoom", sb.toString());
|
||
|
Point point = new Point((int) scaleGestureDetector.getFocusX(), (int) scaleGestureDetector.getFocusY());
|
||
|
if (this.lT.lg != this.lT.kV) {
|
||
|
this.lT.lf = true;
|
||
|
}
|
||
|
if (this.lT.lf) {
|
||
|
this.lT.lf = false;
|
||
|
ImgReviewEditCntrl imgReviewEditCntrl = this.lT;
|
||
|
imgReviewEditCntrl.lB = imgReviewEditCntrl.b(point);
|
||
|
}
|
||
|
if (this.lT.lv < 1.0f) {
|
||
|
this.lT.lv = 1.0f;
|
||
|
}
|
||
|
if (this.lT.lv > 15.0f) {
|
||
|
this.lT.lv = 15.0f;
|
||
|
}
|
||
|
if (this.lT.lv == 1.0f) {
|
||
|
this.lT.ly.x = 0;
|
||
|
this.lT.ly.y = 0;
|
||
|
this.lT.state = 0;
|
||
|
StringBuilder sb2 = new StringBuilder("state = ");
|
||
|
sb2.append(this.lT.state);
|
||
|
k.c("State", sb2.toString());
|
||
|
this.lT.le = false;
|
||
|
}
|
||
|
ImgReviewEditCntrl imgReviewEditCntrl2 = this.lT;
|
||
|
imgReviewEditCntrl2.lu = imgReviewEditCntrl2.lv;
|
||
|
ImgReviewEditCntrl imgReviewEditCntrl3 = this.lT;
|
||
|
Point a = imgReviewEditCntrl3.a(imgReviewEditCntrl3.lB);
|
||
|
Point point2 = new Point(point.x - a.x, point.y - a.y);
|
||
|
this.lT.ly.x += point2.x;
|
||
|
this.lT.ly.y += point2.y;
|
||
|
ImgReviewEditCntrl imgReviewEditCntrl4 = this.lT;
|
||
|
imgReviewEditCntrl4.lg = imgReviewEditCntrl4.kV;
|
||
|
StringBuilder sb3 = new StringBuilder("prevNumTouches = ");
|
||
|
sb3.append(this.lT.lg);
|
||
|
sb3.append(" numtouches = ");
|
||
|
sb3.append(this.lT.kV);
|
||
|
k.c("State", sb3.toString());
|
||
|
this.lT.invalidate();
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
protected void onDraw(Canvas canvas) {
|
||
|
super.onDraw(canvas);
|
||
|
if (isInEditMode()) {
|
||
|
return;
|
||
|
}
|
||
|
canvas.getClipBounds(new Rect());
|
||
|
int i = (int) (this.lj * 0.075d);
|
||
|
if (!this.lh && this.lt && !this.lN) {
|
||
|
this.ls.set(i, i);
|
||
|
this.lr.set(((int) this.lj) - i, i);
|
||
|
this.lq.set(i, ((int) this.lk) - i);
|
||
|
this.lp.set(((int) this.lj) - i, ((int) this.lk) - i);
|
||
|
}
|
||
|
Bitmap bitmap = this.lw;
|
||
|
if (bitmap == null || bitmap.isRecycled()) {
|
||
|
return;
|
||
|
}
|
||
|
canvas.save();
|
||
|
canvas.scale(1.0f, 1.0f);
|
||
|
Paint paint = new Paint(2);
|
||
|
Point a2 = a(new Point(0, 0));
|
||
|
Rect rect = new Rect(0, 0, (int) this.lj, (int) this.lk);
|
||
|
if (this.lu == BitmapDescriptorFactory.HUE_RED) {
|
||
|
this.lu = 1.0f;
|
||
|
}
|
||
|
String str = TAG;
|
||
|
StringBuilder sb = new StringBuilder("origin = ");
|
||
|
sb.append(a2.x);
|
||
|
sb.append(" ");
|
||
|
sb.append(a2.y);
|
||
|
k.c(str, sb.toString());
|
||
|
canvas.drawBitmap(this.lw, rect, new Rect(a2.x, a2.y, ((int) (this.lz.width() * this.lu)) + a2.x, ((int) (this.lz.height() * this.lu)) + a2.y), paint);
|
||
|
canvas.restore();
|
||
|
if (this.lt) {
|
||
|
a(canvas);
|
||
|
}
|
||
|
a(a2, canvas);
|
||
|
}
|
||
|
|
||
|
private void a(Point point, Canvas canvas) {
|
||
|
ax();
|
||
|
Iterator<BoundingRect> it = this.lL.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
a(point, canvas, it.next());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void ax() {
|
||
|
if (this.ld == null) {
|
||
|
Paint paint = new Paint();
|
||
|
this.ld = paint;
|
||
|
paint.setStyle(Paint.Style.FILL);
|
||
|
}
|
||
|
ay();
|
||
|
}
|
||
|
|
||
|
private void ay() {
|
||
|
int parseLong = (int) Long.parseLong(Integer.toString(this.lE, 16), 16);
|
||
|
this.ld.setColor(Color.argb(100, (parseLong >> 16) & 255, (parseLong >> 8) & 255, parseLong & 255));
|
||
|
}
|
||
|
|
||
|
private void a(Point point, Canvas canvas, BoundingRect boundingRect) {
|
||
|
if (b(boundingRect)) {
|
||
|
setHighlightRectangle(boundingRect);
|
||
|
b(this.lu, this.lo);
|
||
|
this.lM.offset(point.x, point.y);
|
||
|
canvas.drawRect(this.lM, this.ld);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private boolean b(BoundingRect boundingRect) {
|
||
|
return boundingRect != null && boundingRect.getRectTop() > 0;
|
||
|
}
|
||
|
|
||
|
private void setHighlightRectangle(BoundingRect boundingRect) {
|
||
|
this.lM.set(boundingRect.getRectLeft(), boundingRect.getRectTop(), boundingRect.getRectRight(), boundingRect.getRectBottom());
|
||
|
}
|
||
|
|
||
|
private void b(float f, float f2) {
|
||
|
this.lM.set(Math.round(r0.left * f * f2), Math.round(this.lM.top * f * f2), Math.round(this.lM.right * f * f2), Math.round(this.lM.bottom * f * f2));
|
||
|
}
|
||
|
|
||
|
private float getDisplayToBitmapScalingFactor() {
|
||
|
float f = 1.0f;
|
||
|
if (this.image != null) {
|
||
|
try {
|
||
|
int width = ((WindowManager) getContext().getSystemService("window")).getDefaultDisplay().getWidth() - this.lz.width();
|
||
|
if (this.image.getImageRepresentation() == Image.ImageRep.IMAGE_REP_BITMAP && this.image.getImageBitmap() != null && !this.image.getImageBitmap().isRecycled()) {
|
||
|
f = Utility.getDisplayToBitmapScalingFactor(getContext(), this.image.getImageBitmap().getWidth(), width);
|
||
|
} else if (this.image.getImageFileWidth() != null) {
|
||
|
f = Utility.getDisplayToBitmapScalingFactor(getContext(), this.image.getImageFileWidth().intValue(), width);
|
||
|
}
|
||
|
} catch (IOException unused) {
|
||
|
}
|
||
|
}
|
||
|
return f;
|
||
|
}
|
||
|
|
||
|
private Rect a(float f, float f2, float f3, float f4) {
|
||
|
float f5;
|
||
|
float f6;
|
||
|
Rect rect = new Rect();
|
||
|
if (f2 > this.lj) {
|
||
|
f6 = (int) ((f4 / f2) * f);
|
||
|
if (f6 > f3) {
|
||
|
f5 = (int) ((f2 / f) * f3);
|
||
|
f6 = f3;
|
||
|
}
|
||
|
f5 = f4;
|
||
|
} else {
|
||
|
float f7 = (int) ((f2 / f) * f3);
|
||
|
if (f7 > f4) {
|
||
|
f6 = (int) ((f4 / f2) * f);
|
||
|
f5 = f4;
|
||
|
} else {
|
||
|
f5 = f7;
|
||
|
f6 = f3;
|
||
|
}
|
||
|
}
|
||
|
rect.left = (int) ((f3 - f6) / 2.0f);
|
||
|
rect.right = (int) (f6 + rect.left);
|
||
|
rect.top = ((int) (f4 - f5)) / 2;
|
||
|
rect.bottom = (int) (f5 + rect.top);
|
||
|
return rect;
|
||
|
}
|
||
|
|
||
|
Point d(Point point, Point point2) {
|
||
|
Point point3 = new Point();
|
||
|
if (point2.y > point2.x) {
|
||
|
point3.y = point.y;
|
||
|
point3.x = (int) ((point.y / point2.y) * point2.x);
|
||
|
if (point3.x > point.x) {
|
||
|
point3.x = point.x;
|
||
|
point3.y = (int) ((point2.y / point2.x) * point.x);
|
||
|
}
|
||
|
} else {
|
||
|
point3.x = point.x;
|
||
|
point3.y = (int) ((point2.y / point2.x) * point.x);
|
||
|
if (point3.y > point.y) {
|
||
|
point3.y = point.y;
|
||
|
point3.x = (int) ((point.y / point2.y) * point2.x);
|
||
|
}
|
||
|
}
|
||
|
return point3;
|
||
|
}
|
||
|
|
||
|
private void a(Canvas canvas) {
|
||
|
Line_Style_Solid line_Style_Solid = this.lF;
|
||
|
if (line_Style_Solid != null) {
|
||
|
if (line_Style_Solid.equals(Line_Style_Solid.LINE_STYLE_DOTTED)) {
|
||
|
this.lc.setPathEffect(new DashPathEffect(new float[]{10.0f, 10.0f}, 10.0f));
|
||
|
} else {
|
||
|
this.lc.setPathEffect(new DashPathEffect(new float[]{BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED}, BitmapDescriptorFactory.HUE_RED));
|
||
|
}
|
||
|
}
|
||
|
this.lc.setStrokeWidth(5.0f);
|
||
|
this.lc.setColor(this.lC);
|
||
|
this.lc.setStyle(Paint.Style.STROKE);
|
||
|
this.lc.setAntiAlias(true);
|
||
|
Point a2 = a(this.ls);
|
||
|
Point a3 = a(this.lr);
|
||
|
Point a4 = a(this.lq);
|
||
|
Point a5 = a(this.lp);
|
||
|
Path path = new Path();
|
||
|
path.moveTo(a2.x, a2.y);
|
||
|
path.lineTo(a3.x, a3.y);
|
||
|
path.moveTo(a3.x, a3.y);
|
||
|
path.lineTo(a5.x, a5.y);
|
||
|
path.moveTo(a5.x, a5.y);
|
||
|
path.lineTo(a4.x, a4.y);
|
||
|
path.moveTo(a4.x, a4.y);
|
||
|
path.lineTo(a2.x, a2.y);
|
||
|
path.close();
|
||
|
canvas.drawPath(path, this.lc);
|
||
|
this.lc.setStyle(Paint.Style.FILL);
|
||
|
this.lc.setColor(this.lD);
|
||
|
canvas.drawCircle(a2.x, a2.y, kT, this.lc);
|
||
|
canvas.drawCircle(a3.x, a3.y, kT, this.lc);
|
||
|
canvas.drawCircle(a4.x, a4.y, kT, this.lc);
|
||
|
canvas.drawCircle(a5.x, a5.y, kT, this.lc);
|
||
|
}
|
||
|
|
||
|
private boolean e(Point point, Point point2) {
|
||
|
float f = this.ln * 35.0f;
|
||
|
if (point.x >= point2.x - f && point.x <= point2.x + f && point.y >= point2.y - f && point.y <= point2.y + f) {
|
||
|
this.li = false;
|
||
|
return true;
|
||
|
}
|
||
|
if (this.lu > 1.0f) {
|
||
|
this.li = true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
private boolean a(Point point, Point point2, Point point3, int i) {
|
||
|
double abs = Math.abs((Math.atan2(point2.y - point3.y, point2.x - point3.x) * 180.0d) / 3.141592653589793d) + Math.abs((Math.atan2(point2.y - point.y, point2.x - point.x) * 180.0d) / 3.141592653589793d);
|
||
|
return (i == 2 || i == 4) ? abs < 175.0d : abs > 175.0d || abs < 2.0d;
|
||
|
}
|
||
|
|
||
|
private void a(int i, Point point) {
|
||
|
Point b = b(point);
|
||
|
Point b2 = b(this.la);
|
||
|
float f = b.x - b2.x;
|
||
|
float f2 = b.y - b2.y;
|
||
|
if (i == 1) {
|
||
|
if (this.kX.y + f2 >= this.lq.y || this.kX.y + f2 >= this.lp.y || this.kX.y + f2 < BitmapDescriptorFactory.HUE_RED || this.kY.y + f2 < BitmapDescriptorFactory.HUE_RED) {
|
||
|
return;
|
||
|
}
|
||
|
this.ls.y = (int) (this.kX.y + f2);
|
||
|
this.lr.y = (int) (this.kY.y + f2);
|
||
|
return;
|
||
|
}
|
||
|
if (i == 2) {
|
||
|
if (this.kX.x + f >= this.lp.x || this.kY.x + f >= this.lr.x || this.kX.x + f < BitmapDescriptorFactory.HUE_RED || this.kY.x + f < BitmapDescriptorFactory.HUE_RED) {
|
||
|
return;
|
||
|
}
|
||
|
this.ls.x = (int) (this.kX.x + f);
|
||
|
StringBuilder sb = new StringBuilder("[pointmove]pointImage.x = ");
|
||
|
sb.append(this.ls.x);
|
||
|
k.c("Zoom", sb.toString());
|
||
|
this.lq.x = (int) (this.kY.x + f);
|
||
|
return;
|
||
|
}
|
||
|
if (i == 3) {
|
||
|
if (this.kX.x + f <= this.ls.x || this.kY.x + f <= this.lq.x || this.kX.x + f > this.lj || this.kY.x + f > this.lj) {
|
||
|
return;
|
||
|
}
|
||
|
this.lr.x = (int) (this.kX.x + f);
|
||
|
this.lp.x = (int) (this.kY.x + f);
|
||
|
return;
|
||
|
}
|
||
|
if (i == 4) {
|
||
|
int i2 = (int) f2;
|
||
|
if (this.kX.y + i2 <= this.ls.y || this.kY.y + i2 <= this.lr.y || this.kX.y + i2 > this.lk || this.kY.y + i2 >= this.lk) {
|
||
|
return;
|
||
|
}
|
||
|
this.lq.y = (int) (this.kX.y + f2);
|
||
|
this.lp.y = (int) (this.kY.y + f2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private int c(int i, int i2) {
|
||
|
Point b = b(new Point(i, i2));
|
||
|
Point point = this.ls;
|
||
|
Point point2 = this.lr;
|
||
|
if (a(b, false, point, point2)) {
|
||
|
this.kX.x = point.x;
|
||
|
this.kX.y = point.y;
|
||
|
this.kY.x = point2.x;
|
||
|
this.kY.y = point2.y;
|
||
|
this.li = false;
|
||
|
return 1;
|
||
|
}
|
||
|
Point point3 = this.lr;
|
||
|
Point point4 = this.lp;
|
||
|
if (a(b, true, point3, point4)) {
|
||
|
this.kX.x = point3.x;
|
||
|
this.kX.y = point3.y;
|
||
|
this.kY.x = point4.x;
|
||
|
this.kY.y = point4.y;
|
||
|
this.li = false;
|
||
|
return 3;
|
||
|
}
|
||
|
Point point5 = this.ls;
|
||
|
Point point6 = this.lq;
|
||
|
if (a(b, true, point5, point6)) {
|
||
|
this.kX.x = point5.x;
|
||
|
this.kX.y = point5.y;
|
||
|
this.kY.x = point6.x;
|
||
|
this.kY.y = point6.y;
|
||
|
this.li = false;
|
||
|
return 2;
|
||
|
}
|
||
|
Point point7 = this.lq;
|
||
|
Point point8 = this.lp;
|
||
|
if (!a(b, false, point7, point8)) {
|
||
|
this.li = true;
|
||
|
return 0;
|
||
|
}
|
||
|
this.kX.x = point7.x;
|
||
|
this.kX.y = point7.y;
|
||
|
this.kY.x = point8.x;
|
||
|
this.kY.y = point8.y;
|
||
|
this.li = false;
|
||
|
return 4;
|
||
|
}
|
||
|
|
||
|
private boolean a(Point point, boolean z, Point point2, Point point3) {
|
||
|
float f = this.ln;
|
||
|
float f2 = kT * f;
|
||
|
float f3 = f * 35.0f;
|
||
|
float f4 = point3.x - point2.x;
|
||
|
if (f4 == BitmapDescriptorFactory.HUE_RED) {
|
||
|
return ((float) point.x) >= ((float) point3.x) - f2 && ((float) point.x) <= ((float) point3.x) + f2;
|
||
|
}
|
||
|
float f5 = (point3.y - point2.y) / f4;
|
||
|
float f6 = point2.y - (point2.x * f5);
|
||
|
if (z) {
|
||
|
float f7 = (point.y - f6) / f5;
|
||
|
return ((float) point.x) >= f7 - f3 && ((float) point.x) <= f7 + f3 && ((float) point.y) >= ((float) point2.y) + f3 && ((float) point.y) <= ((float) point3.y) - f3;
|
||
|
}
|
||
|
float f8 = (point.x * f5) + f6;
|
||
|
if (point.y < f8 - f3 || point.y > f8 + f3) {
|
||
|
return false;
|
||
|
}
|
||
|
k.c(TAG, "isonline true: horizontal");
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public Point a(Point point) {
|
||
|
Point point2 = new Point();
|
||
|
if (this.lu != BitmapDescriptorFactory.HUE_RED) {
|
||
|
point2.x = (int) ((point.x * this.lu * (this.lz.width() / this.lj)) + this.ll + this.lz.left + this.ly.x);
|
||
|
point2.y = (int) ((point.y * this.lu * (this.lz.height() / this.lk)) + this.lm + this.lz.top + this.ly.y);
|
||
|
} else {
|
||
|
point2.x = (int) ((point.x * (this.lz.width() / this.lj)) + this.ll + this.lz.left + this.ly.x);
|
||
|
point2.y = (int) ((point.y * (this.lz.height() / this.lk)) + this.lm + this.lz.top + this.ly.y);
|
||
|
}
|
||
|
return point2;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public Point b(Point point) {
|
||
|
Point point2 = new Point();
|
||
|
if (this.lu != BitmapDescriptorFactory.HUE_RED) {
|
||
|
float f = point.x;
|
||
|
float f2 = this.ll;
|
||
|
point2.x = (int) ((((f - f2) - this.lz.left) - this.ly.x) / (this.lu * (this.lz.width() / this.lj)));
|
||
|
float f3 = point.y;
|
||
|
float f4 = this.lm;
|
||
|
point2.y = (int) ((((f3 - f4) - this.lz.top) - this.ly.y) / (this.lu * (this.lz.height() / this.lk)));
|
||
|
} else {
|
||
|
float f5 = point.x;
|
||
|
float f6 = this.ll;
|
||
|
point2.x = (int) ((((f5 - f6) - this.lz.left) - this.ly.x) / (this.lz.width() / this.lj));
|
||
|
float f7 = point.y;
|
||
|
float f8 = this.lm;
|
||
|
point2.y = (int) ((((f7 - f8) - this.lz.top) - this.ly.y) / (this.lz.height() / this.lk));
|
||
|
}
|
||
|
return point2;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public Parcelable onSaveInstanceState() {
|
||
|
Bundle bundle = new Bundle();
|
||
|
bundle.putParcelable("instanceState", super.onSaveInstanceState());
|
||
|
bundle.putBoolean("retainImage", this.lI);
|
||
|
if (this.lI) {
|
||
|
aA();
|
||
|
String str = this.lH;
|
||
|
if (str != null) {
|
||
|
bundle.putString("bitmapKey", str);
|
||
|
}
|
||
|
}
|
||
|
bundle.putSerializable("cacheType", this.lK);
|
||
|
bundle.putParcelable("displayrect", this.lz);
|
||
|
bundle.putFloat("currentScale", this.lu);
|
||
|
bundle.putFloat("imgHt", this.lk);
|
||
|
bundle.putFloat("imgWd", this.lj);
|
||
|
bundle.putIntArray("p1", new int[]{this.ls.x, this.ls.y});
|
||
|
bundle.putIntArray("p2", new int[]{this.lr.x, this.lr.y});
|
||
|
bundle.putIntArray("p3", new int[]{this.lq.x, this.lq.y});
|
||
|
bundle.putIntArray("p4", new int[]{this.lp.x, this.lp.y});
|
||
|
bundle.putInt("linecolor", this.lC);
|
||
|
bundle.putInt("cornercolor", this.lD);
|
||
|
bundle.putSerializable("boundingTetragon", this.lG);
|
||
|
BoundingTetragon boundingTetragon = this.lG;
|
||
|
if (boundingTetragon != null) {
|
||
|
bundle.putSerializable("boundingTetragon", boundingTetragon);
|
||
|
}
|
||
|
bundle.putBoolean("isVisibleRectangle", this.lt);
|
||
|
bundle.putBoolean("isMoving", this.lh);
|
||
|
bundle.putBoolean("isCropTetragonSetbyUser", this.lN);
|
||
|
return bundle;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public void onRestoreInstanceState(Parcelable parcelable) {
|
||
|
if (parcelable instanceof Bundle) {
|
||
|
Bundle bundle = (Bundle) parcelable;
|
||
|
Bitmap bitmap = this.lw;
|
||
|
if (bitmap != null) {
|
||
|
bitmap.recycle();
|
||
|
this.lw = null;
|
||
|
}
|
||
|
ImageCacheType imageCacheType = (ImageCacheType) bundle.getSerializable("cacheType");
|
||
|
this.lK = imageCacheType;
|
||
|
setImageCacheType(imageCacheType);
|
||
|
this.lI = bundle.getBoolean("retainImage");
|
||
|
this.lH = bundle.getString("bitmapKey");
|
||
|
if (this.lI) {
|
||
|
aB();
|
||
|
} else {
|
||
|
aC();
|
||
|
}
|
||
|
this.lu = bundle.getFloat("currentScale", this.lu);
|
||
|
this.lC = bundle.getInt("linecolor");
|
||
|
this.lD = bundle.getInt("cornercolor");
|
||
|
this.lt = bundle.getBoolean("isVisibleRectangle");
|
||
|
this.lh = bundle.getBoolean("isMoving");
|
||
|
this.lN = bundle.getBoolean("isCropTetragonSetbyUser");
|
||
|
this.ls = new Point(bundle.getIntArray("p1")[0], bundle.getIntArray("p1")[1]);
|
||
|
this.lr = new Point(bundle.getIntArray("p2")[0], bundle.getIntArray("p2")[1]);
|
||
|
this.lq = new Point(bundle.getIntArray("p3")[0], bundle.getIntArray("p3")[1]);
|
||
|
this.lp = new Point(bundle.getIntArray("p4")[0], bundle.getIntArray("p4")[1]);
|
||
|
this.le = false;
|
||
|
this.li = false;
|
||
|
this.state = 0;
|
||
|
this.lG = (BoundingTetragon) bundle.getSerializable("boundingTetragon");
|
||
|
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
|
||
|
return;
|
||
|
}
|
||
|
super.onRestoreInstanceState(parcelable);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
protected void onSizeChanged(int i, int i2, int i3, int i4) {
|
||
|
super.onSizeChanged(i, i2, i3, i4);
|
||
|
if (this.lw != null) {
|
||
|
this.rotation = ((WindowManager) getContext().getSystemService("window")).getDefaultDisplay().getRotation();
|
||
|
av();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void az() {
|
||
|
if (!Licensing.isSdkLicensed(Licensing.LicenseType.IMAGE_CAPTURE)) {
|
||
|
throw new KmcRuntimeException(ErrorInfo.KMC_UT_LICENSE_IMAGE_CAPTURE);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void clearImage() {
|
||
|
Bitmap bitmap = this.lw;
|
||
|
if (bitmap != null) {
|
||
|
bitmap.recycle();
|
||
|
}
|
||
|
this.image = null;
|
||
|
clearHighlights();
|
||
|
invalidate();
|
||
|
aC();
|
||
|
}
|
||
|
|
||
|
private void aA() {
|
||
|
Bitmap bitmap = this.lw;
|
||
|
if (bitmap == null || bitmap.isRecycled() || m(this.lH)) {
|
||
|
return;
|
||
|
}
|
||
|
aC();
|
||
|
String obj = UUID.randomUUID().toString();
|
||
|
if (this.lJ.a(obj, this.lw)) {
|
||
|
this.lH = obj;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private boolean m(String str) {
|
||
|
c cVar = this.lJ;
|
||
|
return (cVar == null || str == null || cVar.getBitmap(str) == null) ? false : true;
|
||
|
}
|
||
|
|
||
|
private void aB() {
|
||
|
String str = this.lH;
|
||
|
if (str != null) {
|
||
|
this.lw = this.lJ.w(str);
|
||
|
this.lH = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void aC() {
|
||
|
String str = this.lH;
|
||
|
if (str != null) {
|
||
|
Bitmap w = this.lJ.w(str);
|
||
|
if (w != null && !w.isRecycled()) {
|
||
|
w.recycle();
|
||
|
}
|
||
|
this.lH = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setRetainImage(boolean z) {
|
||
|
this.lI = z;
|
||
|
}
|
||
|
|
||
|
public boolean getRetainImage() {
|
||
|
return this.lI;
|
||
|
}
|
||
|
|
||
|
public Image getImage() {
|
||
|
return this.image;
|
||
|
}
|
||
|
|
||
|
public int getCropLineColor() {
|
||
|
return this.lC;
|
||
|
}
|
||
|
|
||
|
public int getCropCornerColor() {
|
||
|
int i = this.lD;
|
||
|
if (i == -1) {
|
||
|
return -16776961;
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
}
|