正在查看: Oolka v2.4.42 应用的 HVDocsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Oolka v2.4.42 应用的 HVDocsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package co.hyperverge.hypersnapsdk.activities;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.graphics.RectF;
import android.hardware.Camera;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Looper;
import android.text.Spanned;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.ScaleAnimation;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.b;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.res.ResourcesCompat;
import co.hyperverge.hvcamera.HVCamHost;
import co.hyperverge.hvcamera.HVMagicView;
import co.hyperverge.hvcamera.magicfilter.camera.CameraEngine;
import co.hyperverge.hvcamera.magicfilter.utils.Exif;
import co.hyperverge.hyperdocdetect.carddetectorservice.HVTfliteHelper;
import co.hyperverge.hyperdocdetect.carddetectorservice.models.HVCardDetectionResult;
import co.hyperverge.hyperdocdetect.carddetectorservice.models.HVCardDetectorInput;
import co.hyperverge.hypersnapsdk.HyperSnapSDK;
import co.hyperverge.hypersnapsdk.R;
import co.hyperverge.hypersnapsdk.activities.HVDocsActivity;
import co.hyperverge.hypersnapsdk.data.models.FeatureConfig;
import co.hyperverge.hypersnapsdk.helpers.CustomTextStringConst;
import co.hyperverge.hypersnapsdk.helpers.DocOCRHelper;
import co.hyperverge.hypersnapsdk.helpers.ExifHelper;
import co.hyperverge.hypersnapsdk.helpers.FileHelper;
import co.hyperverge.hypersnapsdk.helpers.HVCameraHelper;
import co.hyperverge.hypersnapsdk.helpers.HVLottieHelper;
import co.hyperverge.hypersnapsdk.helpers.ImageToPDFConverter;
import co.hyperverge.hypersnapsdk.helpers.SDKInternalConfig;
import co.hyperverge.hypersnapsdk.helpers.SPHelper;
import co.hyperverge.hypersnapsdk.helpers.TimingUtils;
import co.hyperverge.hypersnapsdk.listeners.DocCaptureCompletionHandler;
import co.hyperverge.hypersnapsdk.listeners.LocationProviderCallback;
import co.hyperverge.hypersnapsdk.listeners.PermDialogCallback;
import co.hyperverge.hypersnapsdk.model.HVJSONObject;
import co.hyperverge.hypersnapsdk.objects.HVBaseConfig;
import co.hyperverge.hypersnapsdk.objects.HVBaseResponse;
import co.hyperverge.hypersnapsdk.objects.HVDocConfig;
import co.hyperverge.hypersnapsdk.objects.HVError;
import co.hyperverge.hypersnapsdk.objects.HVResponse;
import co.hyperverge.hypersnapsdk.objects.HyperSnapParams;
import co.hyperverge.hypersnapsdk.objects.HyperSnapSDKConfig;
import co.hyperverge.hypersnapsdk.objects.IPAddress;
import co.hyperverge.hypersnapsdk.service.iptogeo.IPToGeoService;
import co.hyperverge.hypersnapsdk.service.iptogeo.IPToGeoServiceImpl;
import co.hyperverge.hypersnapsdk.service.location.LocationServiceImpl;
import co.hyperverge.hypersnapsdk.service.qr.HVBarcodeDetector;
import co.hyperverge.hypersnapsdk.utils.AppConstants;
import co.hyperverge.hypersnapsdk.utils.HVLogUtils;
import co.hyperverge.hypersnapsdk.utils.HyperSnapUIConfigUtil;
import co.hyperverge.hypersnapsdk.utils.InternalToolUtils;
import co.hyperverge.hypersnapsdk.utils.PDFUtils;
import co.hyperverge.hypersnapsdk.utils.PermissionManager;
import co.hyperverge.hypersnapsdk.utils.StringUtils;
import co.hyperverge.hypersnapsdk.utils.TextConfigUtils;
import co.hyperverge.hypersnapsdk.utils.UIUtils;
import co.hyperverge.hypersnapsdk.utils.Utils;
import co.hyperverge.hypersnapsdk.views.CrossHairView;
import co.hyperverge.hypersnapsdk.views.RectPortHoleView;
import co.hyperverge.hypersnapsdk.views.ScanningIndicator;
import com.airbnb.lottie.LottieAnimationView;
import com.cashfree.pg.core.hidden.nfc.parser.EmvParser;
import com.google.android.material.imageview.ShapeableImageView;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;
@SuppressLint({"ClickableViewAccessibility", "LogNotTimber"})
public class HVDocsActivity extends HVBaseActivity implements View.OnClickListener {
private static final int LOCATION_SETTINGS_REQUEST_CODE = 1001;
public static String LOG_TAG = "DocumentActivity";
private static final int RC_PICK_DOC = 1000;
private static final String TAG = "co.hyperverge.hypersnapsdk.activities.HVDocsActivity";
private static DocCaptureCompletionHandler documentImageListener;
private final float BOX_PORTHOLE_PADDING_PERCENT;
private final int CAMERA_CHECK_DELAY;
final float[][] accels;
private CountDownTimer autoCaptureTimer;
private int autoCaptureTimerNumber;
final float[] azimuth;
View blackOverlay;
ImageView btCapture;
private final HVCamHost camHost;
private int camViewHeight;
private final String camViewTag = "docCaptureCameraPreview";
private int camViewWidth;
FrameLayout cameraContainer;
private AtomicBoolean cameraFree;
HVMagicView cameraView;
private final TimingUtils captureClickTimingUtils;
private String capturedHighResolutionFullImagePath;
private String capturedHighResolutionQRCroppedImagePath;
private String capturedImagePath;
File compressedFile;
private ImageView cross;
CrossHairView crossHairView;
private final Handler delayHandler;
private float density;
TextView descText;
private String detectedBarcode;
private HVDocConfig docConfig;
private ConstraintLayout docInstructionsLayout;
private ConstraintLayout docLoaderLayout;
private final TimingUtils docPickerCaptureButtonClickTimingUtils;
private final TimingUtils docPickerScreenLoadSuccessTimingUtils;
private final TimingUtils docPickerUploadButtonClickTimingUtils;
private HVDocConfig.Document document;
RectPortHoleView documentCaptureView;
private float dpHeight;
private float dpWidth;
private final Animation.AnimationListener flashAnimationListener;
File folder;
private File fullHRImageFile;
final float[][] gravity;
private boolean hasDelayFinished;
TextView hintText;
private final HVBarcodeDetector hvBarcodeDetector;
private HVCardUIState hvCardUIState;
private ImageView hvGreenTickImageView;
private HVError hvImageCaptureError;
private final HVResponse hvResponse;
private final ArrayList<HVBaseResponse> hvResponses;
private final TimingUtils imageCaptureTimingUtils;
private ScanningIndicator indicator;
private TextView instructionsInsideCameraPreviewBox;
private TextView instructionsOutsideCameraPreviewBox;
private Button instructionsUploadButton;
private IPAddress ipAddress;
private boolean isAutoCaptureTimerRunning;
private boolean isAutoCapturing;
private boolean isBarcodeDetected;
private boolean isCardDetectedInAutoCapturedImage;
private boolean isCardDetectionInProgress;
private boolean isCheckingCamera;
private boolean isDocCaptureFlow;
boolean isPhoneTilted;
private boolean isReadBarcodeTimerRunning;
private boolean isStillAutoCaptureInitialState;
private boolean isViewsInitialised;
ImageView ivFlash;
private float lastTouchX;
private float lastTouchY;
private LottieAnimationView lav;
private Location mLocation;
final float[][] magnetic;
final float[][] mags;
private final float maximumDocFrameXPercentage;
private final float maximumDocFrameYPercentage;
private final float minimumDocXFramePercentage;
private final float minimumDocYFramePercentage;
SensorEventListener mySensorEventListener;
private int numberOfRechecks;
private ShapeableImageView overlayImageView;
double padding;
String pdfPath;
PermissionManager permissionManager;
private final TimingUtils permissionTimingUtils;
final float[] pitch;
private TextView progressDialogTextView;
private View progressDialogView;
private ImageView progressSpinnerImageView;
private String qrCodeValue;
private File qrCroppedFile;
private CountDownTimer readBarcodeTimer;
String retakeMessage;
String retryAction;
final float[] roll;
private boolean safeToTakePicture;
private final TimingUtils screenLoadSuccessTimingUtils;
SensorManager sensorManager;
private boolean shouldAllowActivityClose;
private boolean showInstructionPage;
TextView tvTitle;
private final boolean useFrontFacingCam;
View vFlash;
final float[] values;
public static class AnonymousClass13 {
static final int[] $SwitchMap$co$hyperverge$hypersnapsdk$activities$HVDocsActivity$HVCardUIState;
static {
int[] iArr = new int[HVCardUIState.values().length];
$SwitchMap$co$hyperverge$hypersnapsdk$activities$HVDocsActivity$HVCardUIState = iArr;
try {
iArr[HVCardUIState.CARD_DETECTED.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$co$hyperverge$hypersnapsdk$activities$HVDocsActivity$HVCardUIState[HVCardUIState.CARD_NOT_DETECTED.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$co$hyperverge$hypersnapsdk$activities$HVDocsActivity$HVCardUIState[HVCardUIState.MOVE_CLOSER.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$co$hyperverge$hypersnapsdk$activities$HVDocsActivity$HVCardUIState[HVCardUIState.MOVE_AWAY_FROM_CAMERA.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$co$hyperverge$hypersnapsdk$activities$HVDocsActivity$HVCardUIState[HVCardUIState.MOVE_AWAY_FROM_EDGE.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
}
}
public class AnonymousClass2 extends HVCamHost {
public AnonymousClass2() {
}
public void lambda$onNewPreviewFrame$1() {
HVDocsActivity.this.showBarcodeScannedSuccessfulOverlay(false);
}
public void lambda$onNewPreviewFrame$2() {
HVDocsActivity.this.showBarcodeScannedSuccessfulOverlay(false);
}
public void lambda$onNewPreviewFrame$3() {
HVDocsActivity.this.enableCaptureButton();
}
public void lambda$onPictureReady$0(final ExifHelper exifHelper, final String str, Bitmap bitmap) {
onPictureSaved(new File(str));
HVDocsActivity.this.cameraFree.set(true);
if (bitmap == null || !new File(str).exists()) {
HVDocsActivity.this.stopCamera();
HVDocsActivity.this.finishView(new HVError(2, "Error while capturing the document"), new HVResponse(null, null, null, HVDocsActivity.this.retryAction));
return;
}
if (HVDocsActivity.this.docConfig.isShouldAutoCapture()) {
try {
HVCardDetectionResult detectCard = HVTfliteHelper.getInstance().detectCard(new HVCardDetectorInput(bitmap));
boolean z = false;
if (detectCard != null && detectCard.getNormalisedTopLeftX() >= 0.0f && detectCard.getNormalisedTopLeftX() <= 1.0f && detectCard.getNormalisedTopLeftY() >= 0.0f && detectCard.getNormalisedTopLeftY() <= 1.0f && detectCard.getNormalisedBottomRightX() >= 0.0f && detectCard.getNormalisedBottomRightX() <= 1.0f && detectCard.getNormalisedBottomRightY() >= 0.0f && detectCard.getNormalisedBottomRightY() <= 1.0f) {
float normalisedBottomRightY = detectCard.getNormalisedBottomRightY() - detectCard.getNormalisedTopLeftY();
float normalisedBottomRightX = detectCard.getNormalisedBottomRightX() - detectCard.getNormalisedTopLeftX();
z = ((normalisedBottomRightY > 0.5f ? 1 : (normalisedBottomRightY == 0.5f ? 0 : -1)) > 0 && (normalisedBottomRightX > 0.55f ? 1 : (normalisedBottomRightX == 0.55f ? 0 : -1)) > 0) && ((normalisedBottomRightY > 0.9f ? 1 : (normalisedBottomRightY == 0.9f ? 0 : -1)) < 0 && (normalisedBottomRightX > 1.0f ? 1 : (normalisedBottomRightX == 1.0f ? 0 : -1)) < 0);
}
setIsCardDetectedInAutoCapturedImage(z);
} catch (Exception e) {
String unused = HVDocsActivity.TAG;
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
} catch (NoClassDefFoundError e2) {
String unused2 = HVDocsActivity.TAG;
Utils.getErrorMessage(e2);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e2);
}
HVDocsActivity.callCompletionHandler(new HVError(36, HVDocsActivity.this.getStringFromResources(R.string.hyper_doc_detect_error)), null);
HVDocsActivity.this.finish();
}
}
final JSONObject jSONObject = new JSONObject();
try {
if (HVDocsActivity.this.docConfig.isShouldExportPDF()) {
HVDocsActivity.this.pdfPath = ImageToPDFConverter.convertImageToPDF(bitmap, HVDocsActivity.this.folder.getPath() + "/hv_" + System.currentTimeMillis() + ".pdf");
jSONObject.put("pdfUri", HVDocsActivity.this.pdfPath);
}
final String transactionID = (HVDocsActivity.this.docConfig.getOcrHeaders() == null || !HVDocsActivity.this.docConfig.getOcrHeaders().has("transactionId")) ? SPHelper.getTransactionID() : HVDocsActivity.this.docConfig.getOcrHeaders().getString("transactionId");
if (SDKInternalConfig.getInstance().getRemoteConfig().isUseIpToGeo()) {
new IPToGeoServiceImpl().performIp2GeoAddress(new IPToGeoService.IPToGeoCallback() {
@Override
public void onError() {
AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
anonymousClass2.moveOnFromHVDocView(str, HVDocsActivity.this.capturedHighResolutionQRCroppedImagePath, transactionID, null, exifHelper, jSONObject);
}
@Override
public void onSuccess(IPAddress iPAddress) {
HVDocsActivity.this.ipAddress = iPAddress;
AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
anonymousClass2.moveOnFromHVDocView(str, HVDocsActivity.this.capturedHighResolutionQRCroppedImagePath, transactionID, iPAddress, exifHelper, jSONObject);
}
});
} else {
moveOnFromHVDocView(str, HVDocsActivity.this.capturedHighResolutionQRCroppedImagePath, transactionID, null, exifHelper, jSONObject);
}
} catch (Exception e3) {
String unused3 = HVDocsActivity.TAG;
Utils.getErrorMessage(e3);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e3);
}
}
}
public void moveOnFromHVDocView(String str, String str2, String str3, IPAddress iPAddress, ExifHelper exifHelper, JSONObject jSONObject) {
String unused = HVDocsActivity.TAG;
StringBuilder sb = new StringBuilder();
sb.append("moveOnFromHVDocView() called with: filePath = [");
sb.append(str);
sb.append("], capturedHighResolutionQRCroppedImagePath = [");
sb.append(str2);
sb.append("], transactionID = [");
sb.append(str3);
sb.append("], ipAddress = [");
sb.append(iPAddress);
sb.append("], helper = [");
sb.append(exifHelper);
sb.append("], result = [");
sb.append(jSONObject);
sb.append("]");
if (HVDocsActivity.this.docConfig.isShouldReadNIDQR()) {
Bitmap decodeFile = BitmapFactory.decodeFile(str);
try {
HVDocsActivity hVDocsActivity = HVDocsActivity.this;
hVDocsActivity.qrCodeValue = hVDocsActivity.hvBarcodeDetector.detect(decodeFile);
} catch (NoClassDefFoundError unused2) {
String unused3 = HVDocsActivity.TAG;
}
JSONObject ocrParams = HVDocsActivity.this.docConfig.getOcrParams();
try {
ocrParams.put(AppConstants.DOCUMENT_QR_CODE, HVDocsActivity.this.qrCodeValue);
HVDocsActivity.this.docConfig.ocrParams = ocrParams.toString();
} catch (Exception e) {
String unused4 = HVDocsActivity.TAG;
StringBuilder sb2 = new StringBuilder();
sb2.append("onPictureReady:- JSON Exception :");
sb2.append(Utils.getErrorMessage(e));
}
decodeFile.recycle();
}
if (HVDocsActivity.this.docConfig.isShouldReadBarcode()) {
JSONObject ocrParams2 = HVDocsActivity.this.docConfig.getOcrParams();
try {
ocrParams2.put(AppConstants.DOCUMENT_BAR_CODE, HVDocsActivity.this.detectedBarcode);
HVDocsActivity.this.docConfig.ocrParams = ocrParams2.toString();
} catch (Exception e2) {
String unused5 = HVDocsActivity.TAG;
StringBuilder sb3 = new StringBuilder();
sb3.append("onPictureReady:- JSON Exception :");
sb3.append(Utils.getErrorMessage(e2));
}
}
exifHelper.writeExifData(str, str3, iPAddress);
HVDocsActivity.this.cross.setEnabled(true);
HVDocsActivity.this.showProgressDialog(false, null);
if (HVDocsActivity.this.docConfig.isShouldReadBarcode()) {
HVDocsActivity.this.resetReadBarcodeVariables();
}
HVDocsActivity.this.resetAutoCaptureVariables();
HVDocsActivity.this.safeToTakePicture = true;
if (HVDocsActivity.this.docConfig.isShouldAutoCapture() && !HVDocsActivity.this.isCardDetectedInAutoCapturedImage) {
HVDocsActivity.this.enableCaptureButton();
HVDocsActivity hVDocsActivity2 = HVDocsActivity.this;
hVDocsActivity2.startRetakeScreen(str, TextConfigUtils.getText(hVDocsActivity2.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_AUTO_CAPTURE_ERROR, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_AUTO_CAPTURE_ERROR, HVDocsActivity.this.getStringFromResources(R.string.docCaptureAutoCaptureError)).toString());
} else if (HVDocsActivity.this.docConfig.shouldShowReviewScreen()) {
HVDocsActivity.this.enableCaptureButton();
HVDocsActivity.this.startReviewScreen(str, str2);
} else {
if (HVDocsActivity.this.docConfig.isShouldDoOCR()) {
HVDocsActivity.this.makeOCRAPICall(str, str2);
return;
}
HVDocsActivity.this.enableCaptureButton();
HVDocsActivity.this.stopCamera();
HVDocsActivity.this.finishView(null, new HVResponse(jSONObject, new JSONObject(), str, HVDocsActivity.this.retryAction));
}
}
private void setIsCardDetectedInAutoCapturedImage(boolean z) {
HVDocsActivity.this.isCardDetectedInAutoCapturedImage = z;
}
private void showDocBoxView(RectF rectF, boolean z) {
}
@Override
public void flashScreen() {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
HVDocsActivity.this.flashScreen();
}
});
}
@Override
public int getAspectRatio() {
return 1;
}
@Override
public void getCurrentVideoLength(long j) {
}
@Override
public File getPhotoDirectory() {
return new File(HVDocsActivity.this.capturedImagePath).getParentFile();
}
@Override
public String getPhotoFilename() {
return "IS_" + System.currentTimeMillis() + ".jpg";
}
@Override
public float getPictureMegapixels() {
return 2.0f;
}
@Override
public float getPreviewMegapixels() {
return 2.0f;
}
@Override
public String getVideoFilename() {
return null;
}
@Override
public boolean isShouldCaptureHighResolutionImage() {
return HVDocsActivity.this.docConfig.isShouldReadNIDQR();
}
@Override
public void onCameraFlipCallback() {
}
@Override
public void onCamerasFound(int i) {
}
@Override
public void onFaceDetection(Camera.Face[] faceArr) {
}
@Override
public void onFilterMode(int i, String str) {
}
@Override
public void onFlashAuto() {
HVDocsActivity.this.docConfig.isShouldShowFlashIcon();
}
@Override
public void onFlashNull() {
}
@Override
public void onFlashOff() {
try {
if (HVDocsActivity.this.docConfig.isShouldShowFlashIcon()) {
HVDocsActivity.this.ivFlash.setImageResource(R.drawable.ic_baseline_flash_off_18);
}
} catch (Exception e) {
String unused = HVDocsActivity.TAG;
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
@Override
public void onFlashOn() {
HVMagicView hVMagicView;
try {
if (HVDocsActivity.this.docConfig.isShouldShowFlashIcon()) {
HVDocsActivity.this.ivFlash.setImageResource(R.drawable.ic_baseline_flash_on_18);
if (CameraEngine.isCamera2(HVDocsActivity.this) || (hVMagicView = HVDocsActivity.this.cameraView) == null) {
return;
}
hVMagicView.nextFlashMode();
}
} catch (Exception e) {
String unused = HVDocsActivity.TAG;
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
@Override
public void onFlashTorchOn() {
}
@Override
public void onLayoutChange() {
HVDocsActivity.this.adjustView(true);
}
@Override
public void onNewPreviewFrame(byte[] bArr, int i, int i2, int i3, int i4, byte[] bArr2) {
Bitmap documentImageBitmap;
if (HVDocsActivity.this.safeToTakePicture) {
if (HVDocsActivity.this.docConfig.isShouldReadBarcode()) {
String detect = HVDocsActivity.this.hvBarcodeDetector.detect(bArr, i, i2);
if (!detect.isEmpty()) {
HVDocsActivity.this.detectedBarcode = detect;
if (!HVDocsActivity.this.isBarcodeDetected) {
HVDocsActivity.this.isBarcodeDetected = true;
if (HVDocsActivity.this.docConfig.isBarcodeSkipDisabled()) {
HVDocsActivity.this.showBarcodeScannedSuccessfulOverlay(true);
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
HVDocsActivity.AnonymousClass2.this.lambda$onNewPreviewFrame$1();
}
}, 1000L);
}
if (!HVDocsActivity.this.docConfig.isBarcodeSkipDisabled() && HVDocsActivity.this.isReadBarcodeTimerRunning) {
HVDocsActivity.this.readBarcodeTimer.cancel();
HVDocsActivity.this.isReadBarcodeTimerRunning = false;
HVDocsActivity.this.showBarcodeScannedSuccessfulOverlay(true);
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
HVDocsActivity.AnonymousClass2.this.lambda$onNewPreviewFrame$2();
}
}, 1000L);
}
}
if (!HVDocsActivity.this.docConfig.isShouldAutoCapture() && (!HVDocsActivity.this.btCapture.isEnabled() || !HVDocsActivity.this.btCapture.isClickable())) {
HVDocsActivity.this.runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.AnonymousClass2.this.lambda$onNewPreviewFrame$3();
}
});
}
}
}
if (!HVDocsActivity.this.docConfig.isShouldAutoCapture() || HVDocsActivity.this.isCardDetectionInProgress) {
return;
}
HVDocsActivity.this.isCardDetectionInProgress = true;
Bitmap decodeByteArray = BitmapFactory.decodeByteArray(bArr2, 0, bArr2.length);
if (InternalToolUtils.isTestMode(HVDocsActivity.this) && (documentImageBitmap = InternalToolUtils.getDocumentImageBitmap(HVDocsActivity.this.docConfig.getDocumentSide())) != null) {
decodeByteArray = documentImageBitmap;
}
float width = decodeByteArray.getWidth();
float height = decodeByteArray.getHeight();
float width2 = HVDocsActivity.this.cameraContainer.getWidth();
float height2 = HVDocsActivity.this.cameraContainer.getHeight();
try {
try {
HVCardDetectionResult detectCard = HVTfliteHelper.getInstance().detectCard(new HVCardDetectorInput(decodeByteArray));
if (detectCard != null) {
RectF boxRect = HVDocsActivity.this.getBoxRect();
RectF rectF = new RectF(((int) boxRect.left) + ((int) (boxRect.width() * 0.02f)), ((int) boxRect.top) + ((int) (boxRect.height() * 0.02f)), ((int) boxRect.right) - ((int) (boxRect.width() * 0.02f)), ((int) boxRect.bottom) - ((int) (((int) boxRect.height()) * 0.02f)));
float f = rectF.bottom - rectF.top;
float f2 = rectF.right - rectF.left;
int i5 = (int) ((0.0f * f2) / 200.0f);
int i6 = (int) ((10.0f * f) / 200.0f);
RectF rectF2 = new RectF(((int) rectF.left) + i5, ((int) rectF.top) + i6, ((int) rectF.right) - i5, ((int) rectF.bottom) - i6);
int i7 = (int) ((45.0f * f2) / 200.0f);
int i8 = (int) ((f * 50.0f) / 200.0f);
RectF rectF3 = new RectF(((int) rectF.left) + i7, ((int) rectF.top) + i8, ((int) rectF.right) - i7, ((int) rectF.bottom) - i8);
float tfliteInputShapeHeight = detectCard.getTfliteInputShapeHeight() * ((height / width) - 1.0f);
float normalisedTopLeftX = detectCard.getNormalisedTopLeftX() * width2;
float normalisedTopLeftY = (detectCard.getNormalisedTopLeftY() * height2) + tfliteInputShapeHeight;
float normalisedBottomRightX = detectCard.getNormalisedBottomRightX() * width2;
float normalisedBottomRightY = (detectCard.getNormalisedBottomRightY() * height2) + tfliteInputShapeHeight;
detectCard.getNormalisedWidth();
detectCard.getNormalisedHeight();
RectF rectF4 = new RectF(normalisedTopLeftX, normalisedTopLeftY, normalisedBottomRightX, normalisedBottomRightY);
float f3 = rectF4.bottom - rectF4.top;
float f4 = rectF4.right - rectF4.left;
float min = Math.min(f2, f);
boolean z = f3 < (f * 90.0f) / 100.0f && f4 < (f2 * 100.0f) / 100.0f;
boolean z2 = f3 > (min * 50.0f) / 100.0f && f4 > (min * 55.0f) / 100.0f;
try {
if (rectF3.contains(rectF4)) {
HVDocsActivity.this.cancelAutoCaptureTimer();
HVDocsActivity.this.setHVCardUIState(HVCardUIState.MOVE_CLOSER);
} else if (rectF2.contains(rectF4)) {
if (z2) {
HVCardUIState hVCardUIState = HVDocsActivity.this.hvCardUIState;
HVCardUIState hVCardUIState2 = HVCardUIState.CARD_DETECTED;
if (hVCardUIState != hVCardUIState2) {
HVDocsActivity.this.setHVCardUIState(hVCardUIState2);
}
if (!HVDocsActivity.this.isAutoCapturing) {
HVDocsActivity.this.isAutoCapturing = true;
if (HVDocsActivity.this.autoCaptureTimer == null || HVDocsActivity.this.isAutoCaptureTimerRunning) {
String unused = HVDocsActivity.TAG;
} else {
HVDocsActivity.this.autoCaptureTimer.start();
HVDocsActivity.this.isAutoCaptureTimerRunning = true;
}
}
} else {
HVDocsActivity.this.cancelAutoCaptureTimer();
HVDocsActivity.this.setHVCardUIState(HVCardUIState.MOVE_CLOSER);
}
} else if (!rectF.contains(rectF4)) {
HVDocsActivity.this.cancelAutoCaptureTimer();
HVDocsActivity.this.setHVCardUIState(HVCardUIState.CARD_NOT_DETECTED);
} else if (!z2) {
HVDocsActivity.this.cancelAutoCaptureTimer();
HVDocsActivity.this.setHVCardUIState(HVCardUIState.MOVE_CLOSER);
} else if (z) {
HVDocsActivity.this.cancelAutoCaptureTimer();
HVDocsActivity.this.setHVCardUIState(HVCardUIState.MOVE_AWAY_FROM_EDGE);
} else {
HVDocsActivity.this.cancelAutoCaptureTimer();
HVDocsActivity.this.setHVCardUIState(HVCardUIState.MOVE_AWAY_FROM_CAMERA);
}
} catch (Exception e) {
String unused2 = HVDocsActivity.TAG;
StringBuilder sb = new StringBuilder();
sb.append("onNewPreviewFrame: Exception : ");
sb.append(e.getMessage());
HVDocsActivity.this.cancelAutoCaptureTimer();
}
} else {
HVDocsActivity.this.cancelAutoCaptureTimer();
HVDocsActivity.this.setHVCardUIState(HVCardUIState.CARD_NOT_DETECTED);
}
} catch (Exception e2) {
String unused3 = HVDocsActivity.TAG;
Utils.getErrorMessage(e2);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e2);
}
}
} catch (NoClassDefFoundError e3) {
String unused4 = HVDocsActivity.TAG;
Utils.getErrorMessage(e3);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e3);
}
HVDocsActivity.callCompletionHandler(new HVError(36, HVDocsActivity.this.getStringFromResources(R.string.hyper_doc_detect_error)), null);
HVDocsActivity.this.finish();
}
HVDocsActivity.this.isCardDetectionInProgress = false;
}
}
@Override
public void onPictureFailed() {
String unused = HVDocsActivity.TAG;
HVDocsActivity.this.cameraFree.set(true);
HVDocsActivity.this.hvImageCaptureError = new HVError(2, "failure logged in document onPictureFailed()");
long longValue = HVDocsActivity.this.imageCaptureTimingUtils.getTimeDifferenceLong().longValue();
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureFailed(HVDocsActivity.this.hvImageCaptureError, HVDocsActivity.this.docConfig, longValue);
}
@Override
public void onPictureReady(byte[] bArr) {
Bitmap documentImageBitmap;
if (InternalToolUtils.isTestMode(HVDocsActivity.this) && (documentImageBitmap = InternalToolUtils.getDocumentImageBitmap(HVDocsActivity.this.docConfig.getDocumentSide())) != null) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
documentImageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
bArr = byteArrayOutputStream.toByteArray();
}
onPictureTaken();
HVMagicView hVMagicView = HVDocsActivity.this.cameraView;
if (hVMagicView != null) {
hVMagicView.onPause();
}
final ExifHelper exifHelper = new ExifHelper();
exifHelper.readExif(bArr, HVDocsActivity.this.capturedImagePath, HVDocsActivity.this.mLocation);
try {
HVDocsActivity.this.showProgressDialog(true, "");
?? r2 = HVDocsActivity.this;
new SaveBitmapTask(bArr, r2, new ImageSaveListener() {
@Override
public final void onImageSave(String str, Bitmap bitmap) {
HVDocsActivity.AnonymousClass2.this.lambda$onPictureReady$0(exifHelper, str, bitmap);
}
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
} catch (Exception e) {
String unused = HVDocsActivity.TAG;
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
@Override
public void onPictureSaved(File file) {
String unused = HVDocsActivity.TAG;
StringBuilder sb = new StringBuilder();
sb.append("onPictureSaved() called with: file = [");
sb.append(file);
sb.append("]");
long longValue = HVDocsActivity.this.imageCaptureTimingUtils.getTimeDifferenceLong().longValue();
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureSaved(HVDocsActivity.this.docConfig, file.getAbsolutePath(), longValue);
}
@Override
public void onPictureSizeSet(int i, int i2) {
HVDocsActivity.this.enableCaptureButton();
}
@Override
public void onPictureTaken() {
String unused = HVDocsActivity.TAG;
long longValue = HVDocsActivity.this.imageCaptureTimingUtils.getTimeDifferenceLong().longValue();
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureSuccessful(HVDocsActivity.this.docConfig, longValue);
}
@Override
public void onReady() {
}
@Override
public void onVideoSaved(File file) {
}
@Override
public void onViewDimensionChange(int i, int i2) {
HVDocsActivity.this.camViewHeight = i2;
HVDocsActivity.this.camViewWidth = i;
HVDocsActivity.this.adjustCrossHairView();
HVDocsActivity.this.adjustDocumentCaptureView();
HVDocsActivity.this.adjustHintText();
HVDocsActivity.this.adjustTitleText();
HVDocsActivity.this.adjustScanningIndicator();
HVDocsActivity.this.adjustOverlayImageView();
HVDocsActivity.this.adjustBlackOverlayView();
HVDocsActivity.this.adjustProgressDialogView();
HVDocsActivity.this.adjustStatusText();
}
@Override
public void setScreenFlashOff() {
}
@Override
public void setScreenFlashOn() {
}
@Override
public void showCrossHair(final float f, final float f2, final boolean z) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
float f3 = f;
if (f3 > 0.0f || f2 > 0.0f) {
HVDocsActivity.this.crossHairView.showCrosshair(f3 * r1.camViewWidth, f2 * HVDocsActivity.this.camViewHeight, z);
} else {
HVDocsActivity.this.crossHairView.showCrosshair(r0.camViewWidth / 2, HVDocsActivity.this.camViewHeight / 2, z);
}
}
});
}
@Override
public void zoomMaxLevel(int i) {
}
}
public class AnonymousClass7 extends CountDownTimer {
public AnonymousClass7(long j, long j2) {
super(j, j2);
}
public void lambda$onFinish$0() {
HVDocsActivity.this.safeTakePicture();
}
@Override
public void onFinish() {
if (HVDocsActivity.this.isAutoCaptureTimerRunning) {
HVDocsActivity.this.isAutoCaptureTimerRunning = false;
HVDocsActivity.this.runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.AnonymousClass7.this.lambda$onFinish$0();
}
});
}
}
@Override
public void onTick(long j) {
if (HVDocsActivity.this.isAutoCaptureTimerRunning) {
HVDocsActivity.this.instructionsInsideCameraPreviewBox.setText(((Object) TextConfigUtils.getText(HVDocsActivity.this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_AUTO_CAPTURE_WAIT, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_AUTO_CAPTURE_WAIT, HVDocsActivity.this.getStringFromResources(R.string.docCaptureAutoCaptureWait))) + " " + HVDocsActivity.access$4310(HVDocsActivity.this));
}
}
}
public enum HVCardUIState {
CARD_DETECTED,
CARD_NOT_DETECTED,
MOVE_CLOSER,
MOVE_AWAY_FROM_CAMERA,
MOVE_AWAY_FROM_EDGE
}
public interface ImageSaveListener {
void onImageSave(String str, Bitmap bitmap);
}
public class SaveBitmapTask extends AsyncTask<Void, Void, Void> {
private final byte[] data;
ImageSaveListener listener;
private Bitmap mBitmap;
Context mContext;
public SaveBitmapTask(byte[] bArr, Context context, ImageSaveListener imageSaveListener) {
this.data = bArr;
this.mContext = context;
this.listener = imageSaveListener;
}
public Bitmap cropBitmap(Bitmap bitmap) {
try {
double width = HVDocsActivity.this.docConfig.padding * bitmap.getWidth() * HVDocsActivity.this.document.getAspectRatio();
HVDocsActivity.this.getBottomYOfBox();
HVDocsActivity.this.getTopYOfBox();
if (!HVDocsActivity.this.docConfig.isShouldSetPadding() || HVDocsActivity.this.document.getAspectRatio() > 1.0f) {
width = 0.0d;
}
HVDocsActivity.this.padding = width;
int width2 = (int) (bitmap.getWidth() * (HVDocsActivity.this.getBoxRect().left / HVDocsActivity.this.camViewWidth));
int height = (int) (((int) (bitmap.getHeight() * (HVDocsActivity.this.getTopYOfBox() / HVDocsActivity.this.camViewHeight))) - width);
if (height < 0) {
height = 0;
}
int height2 = (int) ((((int) (bitmap.getHeight() * (HVDocsActivity.this.getBottomYOfBox() / HVDocsActivity.this.camViewHeight))) - height) + width);
int width3 = ((int) (bitmap.getWidth() * (HVDocsActivity.this.getBoxRect().right / HVDocsActivity.this.camViewWidth))) - width2;
if (height2 > bitmap.getHeight()) {
height2 = bitmap.getHeight();
}
if (height + height2 > bitmap.getHeight()) {
height = (int) (bitmap.getHeight() * (HVDocsActivity.this.getTopYOfBox() / HVDocsActivity.this.camViewHeight));
height2 = ((int) (bitmap.getHeight() * (HVDocsActivity.this.getBottomYOfBox() / HVDocsActivity.this.camViewHeight))) - height;
HVDocsActivity.this.docConfig.setShouldAddPadding(false);
}
return Bitmap.createBitmap(bitmap, width2, height, width3, height2);
} catch (Exception | OutOfMemoryError e) {
String unused = HVDocsActivity.TAG;
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() == null) {
return null;
}
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
return null;
}
}
@Override
public Void doInBackground(Void... voidArr) {
Bitmap rotateBitmap;
FileOutputStream fileOutputStream;
int orientation = Exif.getOrientation(this.data);
try {
byte[] bArr = this.data;
rotateBitmap = FileHelper.rotateBitmap(BitmapFactory.decodeByteArray(bArr, 0, bArr.length), Utils.checkForOrientationCorrection(orientation));
} catch (Exception | OutOfMemoryError e) {
String unused = HVDocsActivity.TAG;
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
if (rotateBitmap == null) {
return null;
}
Bitmap cropBitmap = cropBitmap(rotateBitmap);
HVDocsActivity.this.fullHRImageFile = new File(HVDocsActivity.this.capturedHighResolutionFullImagePath);
FileOutputStream fileOutputStream2 = new FileOutputStream(HVDocsActivity.this.fullHRImageFile);
cropBitmap.compress(Bitmap.CompressFormat.JPEG, Utils.JPEG_COMPRESSION_QUALITY, fileOutputStream2);
fileOutputStream2.close();
if (HVDocsActivity.this.docConfig.isShouldReadNIDQR()) {
Bitmap cropQR = Utils.cropQR(cropBitmap);
HVDocsActivity.this.qrCroppedFile = new File(HVDocsActivity.this.capturedHighResolutionQRCroppedImagePath);
try {
if (cropQR == null) {
return null;
}
try {
fileOutputStream = new FileOutputStream(HVDocsActivity.this.qrCroppedFile);
} catch (Exception e2) {
String unused2 = HVDocsActivity.TAG;
Utils.getErrorMessage(e2);
}
try {
cropQR.compress(Bitmap.CompressFormat.JPEG, Utils.JPEG_COMPRESSION_QUALITY, fileOutputStream);
fileOutputStream.close();
} catch (Throwable th) {
try {
fileOutputStream.close();
} catch (Throwable th2) {
th.addSuppressed(th2);
}
throw th;
}
} finally {
cropQR.recycle();
}
}
this.mBitmap = Utils.resizeBitmap(cropBitmap);
cropBitmap.recycle();
if (this.mBitmap == null) {
return null;
}
HVDocsActivity.this.compressedFile = new File(HVDocsActivity.this.capturedImagePath);
FileOutputStream fileOutputStream3 = new FileOutputStream(HVDocsActivity.this.compressedFile);
this.mBitmap.compress(Bitmap.CompressFormat.JPEG, Utils.JPEG_COMPRESSION_QUALITY, fileOutputStream3);
fileOutputStream3.close();
return null;
}
@Override
public void onPostExecute(Void r4) {
this.listener.onImageSave(HVDocsActivity.this.capturedImagePath, this.mBitmap);
super.onPostExecute((SaveBitmapTask) r4);
}
}
public HVDocsActivity() {
Class cls = Float.TYPE;
this.gravity = (float[][]) Array.newInstance((Class<?>) cls, 1, 1);
this.magnetic = (float[][]) Array.newInstance((Class<?>) cls, 1, 1);
this.accels = new float[][]{new float[3]};
this.mags = new float[][]{new float[3]};
this.values = new float[3];
this.azimuth = new float[1];
this.pitch = new float[1];
this.roll = new float[1];
this.docPickerScreenLoadSuccessTimingUtils = new TimingUtils();
this.docPickerUploadButtonClickTimingUtils = new TimingUtils();
this.docPickerCaptureButtonClickTimingUtils = new TimingUtils();
this.screenLoadSuccessTimingUtils = new TimingUtils();
this.imageCaptureTimingUtils = new TimingUtils();
this.permissionTimingUtils = new TimingUtils();
this.captureClickTimingUtils = new TimingUtils();
this.hvBarcodeDetector = new HVBarcodeDetector();
this.delayHandler = new Handler();
this.BOX_PORTHOLE_PADDING_PERCENT = 0.03f;
this.useFrontFacingCam = false;
this.shouldAllowActivityClose = true;
this.hvResponse = new HVResponse();
this.hvResponses = new ArrayList<>();
this.minimumDocXFramePercentage = 55.0f;
this.minimumDocYFramePercentage = 50.0f;
this.maximumDocFrameXPercentage = 100.0f;
this.maximumDocFrameYPercentage = 90.0f;
this.flashAnimationListener = new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
HVDocsActivity.this.vFlash.setVisibility(8);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
HVDocsActivity.this.vFlash.setVisibility(0);
}
};
this.isPhoneTilted = false;
this.hasDelayFinished = false;
this.qrCodeValue = "";
this.detectedBarcode = "";
this.isBarcodeDetected = false;
this.safeToTakePicture = true;
this.isAutoCapturing = false;
this.isCardDetectionInProgress = false;
this.isAutoCaptureTimerRunning = false;
this.isCardDetectedInAutoCapturedImage = true;
this.hvCardUIState = HVCardUIState.CARD_NOT_DETECTED;
this.autoCaptureTimerNumber = 3;
this.isStillAutoCaptureInitialState = true;
this.numberOfRechecks = 0;
this.isViewsInitialised = false;
this.isCheckingCamera = false;
this.CAMERA_CHECK_DELAY = 20;
this.camHost = new AnonymousClass2();
}
public static int access$4310(HVDocsActivity hVDocsActivity) {
int i = hVDocsActivity.autoCaptureTimerNumber;
hVDocsActivity.autoCaptureTimerNumber = i - 1;
return i;
}
private void addCrossHairView(FrameLayout frameLayout) {
CrossHairView crossHairView = new CrossHairView(this);
this.crossHairView = crossHairView;
frameLayout.removeView(crossHairView);
frameLayout.addView(this.crossHairView, -1);
frameLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public final boolean onTouch(View view, MotionEvent motionEvent) {
boolean lambda$addCrossHairView$11;
lambda$addCrossHairView$11 = HVDocsActivity.this.lambda$addCrossHairView$11(view, motionEvent);
return lambda$addCrossHairView$11;
}
});
}
private void addDocumentCaptureView(FrameLayout frameLayout) {
RectPortHoleView rectPortHoleView = new RectPortHoleView(this);
this.documentCaptureView = rectPortHoleView;
frameLayout.removeView(rectPortHoleView);
frameLayout.addView(this.documentCaptureView, -1);
}
public void adjustCrossHairView() {
if (this.crossHairView.getParent() != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.crossHairView.getLayoutParams();
layoutParams.height = this.camViewHeight;
layoutParams.width = this.camViewWidth;
HVMagicView hVMagicView = this.cameraView;
if (hVMagicView != null) {
this.crossHairView.setX(hVMagicView.getX());
this.crossHairView.setY(this.cameraView.getY());
}
if (!this.crossHairView.isInLayout()) {
this.crossHairView.requestLayout();
}
}
if (this.cameraContainer.isInLayout()) {
return;
}
this.cameraContainer.requestLayout();
}
public void adjustDocumentCaptureView() {
if (this.documentCaptureView.getParent() != null) {
RectF boxRect = getBoxRect();
int width = (int) boxRect.width();
int height = (int) boxRect.height();
int topYOfBox = getTopYOfBox();
this.documentCaptureView.setX(0);
this.documentCaptureView.setY(topYOfBox);
RectPortHoleView rectPortHoleView = this.documentCaptureView;
float f = boxRect.left;
rectPortHoleView.setBoxRect(new RectF((int) f, 0.0f, width + ((int) f), height), 0.02f);
if (this.docConfig.isShouldAutoCapture()) {
this.documentCaptureView.setStrokeWidth(10);
this.documentCaptureView.setBorderColor(getResources().getColor(R.color.doc_capture_circle_failure));
}
if (!this.documentCaptureView.isInLayout()) {
this.documentCaptureView.requestLayout();
}
}
if (this.cameraContainer.isInLayout()) {
return;
}
this.cameraContainer.requestLayout();
}
private void adjustTopBar() {
}
public void adjustView(boolean z) {
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.overlay1);
FrameLayout frameLayout2 = (FrameLayout) findViewById(R.id.overlay2);
int topYOfBox = getTopYOfBox();
getBottomYOfBox();
if (frameLayout != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams.height = topYOfBox;
frameLayout.setLayoutParams(layoutParams);
}
if (frameLayout2 != null) {
frameLayout2.setVisibility(0);
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) frameLayout2.getLayoutParams();
layoutParams2.setMargins(0, getBottomYOfBox(), 0, 0);
frameLayout2.setLayoutParams(layoutParams2);
}
if (z) {
relayoutChildren(findViewById(R.id.mainLayout));
}
}
public static void callCompletionHandler(HVError hVError, HVResponse hVResponse) {
StringBuilder sb = new StringBuilder();
sb.append("callCompletionHandler() called with: documentImageListener = [");
sb.append(documentImageListener);
sb.append("] hvError = [");
sb.append(hVError);
sb.append("], hvResponse = [");
sb.append(hVResponse);
sb.append("], ");
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSensorBiometrics() && SDKInternalConfig.getInstance().getHvSensorBiometrics() != null) {
SDKInternalConfig.getInstance().getHvSensorBiometrics().stopSensorBiometrics();
}
DocCaptureCompletionHandler docCaptureCompletionHandler = documentImageListener;
if (docCaptureCompletionHandler != null) {
docCaptureCompletionHandler.onResult(hVError, hVResponse);
}
}
public void cancelAutoCaptureTimer() {
this.autoCaptureTimerNumber = 3;
this.isAutoCapturing = false;
CountDownTimer countDownTimer = this.autoCaptureTimer;
if (countDownTimer != null) {
countDownTimer.cancel();
}
this.isAutoCaptureTimerRunning = false;
}
public void lambda$checkCameraAndHandleCompletion$5(final HVError hVError, final HVResponse hVResponse) {
String str = TAG;
HVLogUtils.d(str, "checkCameraAndHandleCompletion() called with: error = [" + hVError + "], hvResponse = [" + hVResponse + "]");
if (this.isCheckingCamera) {
HVLogUtils.d("checkCameraAndHandleCompletion", "already checking");
return;
}
if (!CameraEngine.isCameraReleased()) {
HVLogUtils.d(str, "checkCameraAndHandleCompletion: camera is not released");
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$checkCameraAndHandleCompletion$5(hVError, hVResponse);
}
}, 20L);
return;
}
HVLogUtils.d(str, "checkCameraAndHandleCompletion: camera is released");
this.isCheckingCamera = true;
callCompletionHandler(hVError, hVResponse);
DocOCRHelper.destroy();
LocationServiceImpl.destroy();
this.mLocation = null;
HVMagicView hVMagicView = this.cameraView;
if (hVMagicView != null) {
hVMagicView.clearHandlers();
this.cameraView = null;
}
finish();
}
private void decideWhatToShow(boolean z) {
boolean z2 = true;
if (z) {
this.showInstructionPage = !this.isDocCaptureFlow;
} else {
if ((!this.docConfig.isShouldShowInstructionPage() || this.isDocCaptureFlow) && (!this.docConfig.isDocumentUploadEnabled() || this.isDocCaptureFlow)) {
z2 = false;
}
this.showInstructionPage = z2;
}
if (this.showInstructionPage) {
showDocInstructions();
} else {
startDocCapture();
}
}
private void displayProgressView(final String str) {
StringBuilder sb = new StringBuilder();
sb.append("displayProgressView() called with: progressLoaderText = [");
sb.append(str);
sb.append("]");
runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$displayProgressView$12(str);
}
});
}
public void enableCaptureButton() {
if (this.docConfig.isShouldReadBarcode()) {
setCaptureButtonState(true, true);
} else if (!this.docConfig.isShouldReadNIDQR() || this.hasDelayFinished) {
setCaptureButtonState(true, true);
} else {
this.delayHandler.postDelayed(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$enableCaptureButton$10();
}
}, 2000L);
}
}
public void flashScreen() {
AlphaAnimation alphaAnimation = new AlphaAnimation(0.6f, 0.0f);
alphaAnimation.setDuration(300L);
alphaAnimation.setInterpolator(new DecelerateInterpolator(2.0f));
alphaAnimation.setFillAfter(true);
alphaAnimation.setAnimationListener(this.flashAnimationListener);
this.vFlash.startAnimation(alphaAnimation);
}
public int getBottomYOfBox() {
return (int) getBoxRect().bottom;
}
@NonNull
public RectF getBoxRect() {
int i;
int i2;
float aspectRatio = this.document.getAspectRatio();
int width = this.cameraContainer.getWidth();
int min = Math.min(this.camViewHeight, this.cameraContainer.getHeight());
if (aspectRatio <= 1.0f) {
i2 = (int) (aspectRatio * width);
i = width;
} else {
i = (int) (min / aspectRatio);
i2 = min;
}
return new RectF((width - i) / 2, (min - i2) / 2, (width + i) / 2, (min + i2) / 2);
}
private void getLocation(final Context context) {
if (!LocationServiceImpl.getInstance(this).isGPSSwitchedOn()) {
showLocationSettingsDialog();
} else {
LocationServiceImpl.getInstance(context).startLocationUpdates();
LocationServiceImpl.getInstance(context).addLocationCallback(new LocationProviderCallback() {
@Override
public void onResult(Location location) {
if (location != null) {
HVDocsActivity.this.mLocation = location;
HVDocsActivity.this.enableCaptureButton();
} else {
HVDocsActivity.this.mLocation = LocationServiceImpl.getInstance(context).getLastKnownLocation();
if (HVDocsActivity.this.mLocation != null) {
HVDocsActivity.this.enableCaptureButton();
}
}
String unused = HVDocsActivity.TAG;
StringBuilder sb = new StringBuilder();
sb.append("onResult: mLocation: ");
sb.append(location);
}
});
}
}
public String getStringFromResources(int i) {
return getResources().getString(i);
}
public int getTopYOfBox() {
return (int) getBoxRect().top;
}
private String getTransactionId() throws JSONException {
return (this.docConfig.getOcrHeaders() == null || !this.docConfig.getOcrHeaders().has("transactionId")) ? SPHelper.getTransactionID() : this.docConfig.getOcrHeaders().getString("transactionId");
}
private String[] getUploadMimeTypes() {
ArrayList arrayList = new ArrayList();
HashMap hashMap = new HashMap();
hashMap.put("jpg", "image/jpg");
hashMap.put("jpeg", "image/jpeg");
hashMap.put("png", "image/png");
hashMap.put("pdf", "application/pdf");
List<String> uploadFileTypes = this.docConfig.getUploadFileTypes();
if (uploadFileTypes == null || uploadFileTypes.isEmpty()) {
uploadFileTypes = Arrays.asList("jpg", "jpeg", "png");
}
for (String str : hashMap.keySet()) {
if (uploadFileTypes.contains(str)) {
arrayList.add((String) hashMap.get(str));
}
}
String[] strArr = new String[arrayList.size()];
arrayList.toArray(strArr);
return strArr;
}
private boolean initDocumentDetector(Context context) {
try {
return HVTfliteHelper.getInstance().initialiseDetector(context);
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
return false;
} catch (NoClassDefFoundError e2) {
Utils.getErrorMessage(e2);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e2);
}
callCompletionHandler(new HVError(36, getStringFromResources(R.string.hyper_doc_detect_error)), null);
finish();
return false;
}
}
private void initializeHVBarcodeDetector() {
try {
this.hvBarcodeDetector.initialiseHVBarcodeDetector(getApplicationContext(), 6416);
} catch (NoClassDefFoundError unused) {
}
}
private void initializeTiltSensor() {
try {
this.sensorManager = (SensorManager) getSystemService("sensor");
this.mySensorEventListener = new SensorEventListener() {
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
try {
int type = sensorEvent.sensor.getType();
if (type == 1) {
HVDocsActivity.this.accels[0] = (float[]) sensorEvent.values.clone();
} else if (type == 2) {
HVDocsActivity.this.mags[0] = (float[]) sensorEvent.values.clone();
}
HVDocsActivity hVDocsActivity = HVDocsActivity.this;
float[][] fArr = hVDocsActivity.mags;
if (fArr[0] != null) {
float[][] fArr2 = hVDocsActivity.accels;
if (fArr2[0] != null) {
float[][] fArr3 = hVDocsActivity.gravity;
fArr3[0] = new float[9];
float[] fArr4 = new float[9];
hVDocsActivity.magnetic[0] = fArr4;
SensorManager.getRotationMatrix(fArr3[0], fArr4, fArr2[0], fArr[0]);
HVDocsActivity hVDocsActivity2 = HVDocsActivity.this;
SensorManager.getOrientation(hVDocsActivity2.gravity[0], hVDocsActivity2.values);
HVDocsActivity hVDocsActivity3 = HVDocsActivity.this;
float[] fArr5 = hVDocsActivity3.azimuth;
float[] fArr6 = hVDocsActivity3.values;
fArr5[0] = fArr6[0] * 57.29578f;
float[] fArr7 = hVDocsActivity3.pitch;
fArr7[0] = fArr6[1] * 57.29578f;
hVDocsActivity3.roll[0] = fArr6[2] * 57.29578f;
hVDocsActivity3.mags[0] = null;
hVDocsActivity3.accels[0] = null;
if (fArr7[0] < hVDocsActivity3.docConfig.getAllowedTiltPitch()) {
if (HVDocsActivity.this.pitch[0] > r9.docConfig.getAllowedTiltPitch() * (-1)) {
if (HVDocsActivity.this.roll[0] < r9.docConfig.getAllowedTiltRoll()) {
if (HVDocsActivity.this.roll[0] > r9.docConfig.getAllowedTiltRoll() * (-1)) {
HVDocsActivity.this.enableCaptureButton();
HVDocsActivity.this.isPhoneTilted = false;
HVDocsActivity.this.setDescText();
}
}
}
}
HVDocsActivity.this.setCaptureButtonState(true, false);
HVDocsActivity.this.isPhoneTilted = true;
HVDocsActivity.this.setDescText();
}
}
} catch (Exception e) {
String unused = HVDocsActivity.TAG;
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
};
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
private boolean is4By3Device() {
return ((double) this.dpHeight) <= (((double) this.dpWidth) * 4.0d) / 3.0d;
}
private boolean isSelectedFileExtentionInAllowedList(String str) {
for (String str2 : getUploadMimeTypes()) {
if (str2.contains(str)) {
return true;
}
}
return false;
}
public boolean lambda$addCrossHairView$11(View view, MotionEvent motionEvent) {
int actionMasked = motionEvent.getActionMasked();
if (actionMasked == 0) {
this.lastTouchX = motionEvent.getX();
this.lastTouchY = motionEvent.getY();
} else if (actionMasked == 1 && Math.abs(motionEvent.getX() - this.lastTouchX) < 20.0f && Math.abs(motionEvent.getY() - this.lastTouchY) < 20.0f) {
this.crossHairView.showCrosshair(motionEvent.getX(), motionEvent.getY(), false);
HVMagicView hVMagicView = this.cameraView;
if (hVMagicView != null) {
hVMagicView.onTouchToFocus(motionEvent.getX() / this.camViewWidth, motionEvent.getY() / this.camViewHeight, null);
}
}
return true;
}
public void lambda$displayProgressView$12(String str) {
View view = this.blackOverlay;
if (view != null) {
view.setVisibility(0);
}
if (str != null) {
this.progressDialogTextView.setText(str);
}
ImageView imageView = this.progressSpinnerImageView;
if (imageView != null) {
imageView.setAnimation(UIUtils.getInfiniteRotationAnimation());
}
View view2 = this.progressDialogView;
if (view2 != null) {
view2.setVisibility(0);
}
showOverlayImageView(false);
TextView textView = this.instructionsInsideCameraPreviewBox;
if (textView != null) {
textView.setVisibility(4);
}
TextView textView2 = this.hintText;
if (textView2 != null) {
textView2.setVisibility(4);
}
}
public void lambda$enableCaptureButton$10() {
this.hasDelayFinished = true;
setCaptureButtonState(true, true);
}
public void lambda$makeOCRAPICall$15() {
TextView textView = this.instructionsOutsideCameraPreviewBox;
if (textView != null) {
textView.setVisibility(0);
this.instructionsOutsideCameraPreviewBox.setText(TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_LOADER_TITLE, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_LOADER_TITLE, getStringFromResources(R.string.hv_doc_loader_title)));
}
}
public void lambda$makeOCRAPICall$16() {
this.docLoaderLayout.setVisibility(8);
this.docInstructionsLayout.setVisibility(8);
HVLottieHelper.reset(this.lav);
}
public void lambda$makeOCRAPICall$17(String str, String str2, boolean z, JSONObject jSONObject, String str3, JSONObject jSONObject2, HVError hVError) {
showProgressDialog(false, null);
this.shouldAllowActivityClose = true;
this.retryAction = str;
this.retakeMessage = str2;
if (z) {
if (this.hvResponse.getRetakeAttemptResponses() == null) {
this.hvResponse.setRetakeAttemptResponses(this.hvResponses);
}
HVBaseResponse hVBaseResponse = new HVBaseResponse();
hVBaseResponse.setAction(this.retryAction);
hVBaseResponse.setApiHeaders(jSONObject);
hVBaseResponse.setImageURI(str3);
hVBaseResponse.setApiResult(addResultImageUri(jSONObject2, str3));
hVBaseResponse.setRetakeMessage(this.retakeMessage);
HVDocConfig hVDocConfig = this.docConfig;
hVBaseResponse.setAttemptsCount(SPHelper.getAttemptsCountForImage(hVDocConfig.ocrEndpoint, hVDocConfig.getSuffixForDocument()));
this.hvResponses.add(hVBaseResponse);
startRetakeScreen(str3, str2);
this.uiThread.post(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$makeOCRAPICall$16();
}
});
return;
}
stopCamera();
if (jSONObject2 == null) {
jSONObject2 = new JSONObject();
}
JSONObject addResultImageUri = addResultImageUri(jSONObject2, str3);
this.hvResponse.setAction(this.retryAction);
this.hvResponse.setApiHeaders(jSONObject);
this.hvResponse.setImageURI(str3);
this.hvResponse.setApiResult(addResultImageUri);
this.hvResponse.setRetakeMessage(this.retakeMessage);
HVResponse hVResponse = this.hvResponse;
HVDocConfig hVDocConfig2 = this.docConfig;
hVResponse.setAttemptsCount(SPHelper.getAttemptsCountForImage(hVDocConfig2.ocrEndpoint, hVDocConfig2.getSuffixForDocument()));
this.hvResponse.setRetakeAttemptResponses(this.hvResponses);
finishView(hVError, this.hvResponse);
}
public void lambda$makeOCRAPICall$18(final String str, final boolean z, final String str2, final String str3, final JSONObject jSONObject, final JSONObject jSONObject2, final HVError hVError) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$makeOCRAPICall$17(str3, str2, z, jSONObject2, str, jSONObject, hVError);
}
});
}
public void lambda$removeProgressView$13() {
TextView textView;
View view = this.blackOverlay;
if (view != null) {
view.setVisibility(8);
}
ImageView imageView = this.progressSpinnerImageView;
if (imageView != null) {
imageView.clearAnimation();
}
if (this.docConfig.isShouldAutoCapture() && (textView = this.instructionsOutsideCameraPreviewBox) != null) {
textView.setText(TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_DOC_NOT_FOUND, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_DOC_NOT_FOUND, getStringFromResources(R.string.docCaptureDocNotFound)));
}
View view2 = this.progressDialogView;
if (view2 != null) {
view2.setVisibility(8);
}
showOverlayImageView(true);
TextView textView2 = this.hintText;
if (textView2 != null) {
textView2.setVisibility(0);
}
}
public void lambda$setAutoCaptureUI$6() {
TextView textView = this.instructionsOutsideCameraPreviewBox;
if (textView != null) {
textView.setVisibility(4);
}
}
public void lambda$setAutoCaptureUI$7() {
showOverlayImageView(false);
}
public void lambda$setAutoCaptureUI$8() {
TextView textView = this.instructionsInsideCameraPreviewBox;
if (textView != null) {
textView.setVisibility(0);
}
}
public void lambda$setAutoCaptureUI$9() {
TextView textView = this.hintText;
if (textView != null) {
textView.setVisibility(0);
}
}
public void lambda$showBarcodeScannedSuccessfulOverlay$14(boolean z) {
if (z) {
if (this.indicator != null) {
removeScanningIndicator();
}
View view = this.blackOverlay;
if (view != null) {
view.setVisibility(0);
}
ImageView imageView = this.hvGreenTickImageView;
if (imageView != null) {
imageView.setVisibility(0);
}
TextView textView = this.instructionsOutsideCameraPreviewBox;
if (textView != null) {
textView.setText(TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_BARCODE_SCANNED, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_BARCODE_SCANNED, getStringFromResources(R.string.docCaptureBarcodeScanned)));
}
showOverlayImageView(false);
TextView textView2 = this.instructionsInsideCameraPreviewBox;
if (textView2 != null) {
textView2.setVisibility(4);
}
TextView textView3 = this.hintText;
if (textView3 != null) {
textView3.setVisibility(4);
return;
}
return;
}
if (this.indicator != null) {
removeScanningIndicator();
}
View view2 = this.blackOverlay;
if (view2 != null) {
view2.setVisibility(4);
}
ImageView imageView2 = this.hvGreenTickImageView;
if (imageView2 != null) {
imageView2.setVisibility(4);
}
TextView textView4 = this.instructionsOutsideCameraPreviewBox;
if (textView4 != null) {
textView4.setText(TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_TITLE, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_TITLE, getStringFromResources(R.string.docCaptureTitle)));
}
if (this.overlayImageView != null) {
if (this.docConfig.getDocumentCaptureOverlay() != null) {
this.overlayImageView.setImageBitmap(this.docConfig.getDocumentCaptureOverlay());
} else {
this.overlayImageView.setImageResource(R.drawable.hv_front_overlay);
}
}
showOverlayImageView(true);
runOverlayTimer();
TextView textView5 = this.instructionsInsideCameraPreviewBox;
if (textView5 != null) {
textView5.setVisibility(4);
}
TextView textView6 = this.hintText;
if (textView6 != null) {
textView6.setVisibility(0);
}
}
public void lambda$showDocInstructions$2(View view) {
view.setEnabled(false);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(getApplicationContext()).logDocumentPickerScreenCloseClicked();
}
onBackPressed();
}
public void lambda$showDocInstructions$3(View view) {
view.setEnabled(false);
long longValue = this.docPickerUploadButtonClickTimingUtils.getTimeDifferenceLong().longValue();
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(getApplicationContext()).logDocumentPickerScreenDocumentUploadButtonClicked(longValue);
}
startDocUpload();
}
public void lambda$showDocInstructions$4(View view) {
view.setEnabled(false);
long longValue = this.docPickerCaptureButtonClickTimingUtils.getTimeDifferenceLong().longValue();
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(getApplicationContext()).logDocumentPickerScreenDocumentCaptureButtonClicked(longValue);
}
startDocCapture();
}
public void lambda$showLocationSettingsDialog$0(DialogInterface dialogInterface, int i) {
startActivityForResult(new Intent("android.settings.LOCATION_SOURCE_SETTINGS"), LOCATION_SETTINGS_REQUEST_CODE);
}
public void lambda$showLocationSettingsDialog$1(Spanned spanned, DialogInterface dialogInterface, int i) {
String string = getString(R.string.hv_gps_access_denied_by_user);
if (spanned != null) {
string = spanned.toString();
}
callCompletionHandler(new HVError(33, string), null);
finish();
}
private void loadAnimation() {
HVLottieHelper.load((LottieAnimationView) this.docInstructionsLayout.findViewById(R.id.lavDocInstructions), this.docConfig.getDocumentSide().equals(HVDocConfig.DocumentSide.FRONT) ? "doc_instruction_front.lottie" : this.docConfig.getDocumentSide().equals(HVDocConfig.DocumentSide.BACK) ? HVLottieHelper.DOC_INSTRUCTION_BACK : "", HVLottieHelper.State.START, null);
}
public void popin() {
ImageView imageView = this.btCapture;
imageView.clearAnimation();
imageView.clearAnimation();
ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.8f, 1.0f, 0.8f, 1, 0.5f, 1, 0.5f);
scaleAnimation.setDuration(150L);
scaleAnimation.setInterpolator(new AccelerateInterpolator());
scaleAnimation.setFillAfter(true);
imageView.startAnimation(scaleAnimation);
this.btCapture.startAnimation(scaleAnimation);
}
public void popout() {
ImageView imageView = this.btCapture;
imageView.clearAnimation();
this.btCapture.clearAnimation();
ScaleAnimation scaleAnimation = new ScaleAnimation(0.8f, 1.0f, 0.8f, 1.0f, 1, 0.5f, 1, 0.5f);
scaleAnimation.setDuration(150L);
scaleAnimation.setInterpolator(new AccelerateInterpolator());
scaleAnimation.setFillAfter(true);
scaleAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
}
});
this.btCapture.startAnimation(scaleAnimation);
imageView.startAnimation(scaleAnimation);
}
private void reInitCaptureButton() {
setCaptureButtonState(true, false);
this.hasDelayFinished = false;
}
private void reInitTimingUtils() {
try {
this.docPickerScreenLoadSuccessTimingUtils.init();
this.docPickerCaptureButtonClickTimingUtils.init();
this.docPickerUploadButtonClickTimingUtils.init();
this.screenLoadSuccessTimingUtils.init();
this.imageCaptureTimingUtils.init();
this.permissionTimingUtils.init();
this.captureClickTimingUtils.init();
} catch (Exception e) {
Utils.getErrorMessage(e);
}
}
private void readyToStartDocCapture() {
lambda$checkAndWaitForRemoteConfig$0();
}
private static void relayoutChildren(View view) {
view.measure(View.MeasureSpec.makeMeasureSpec(view.getMeasuredWidth(), 1073741824), View.MeasureSpec.makeMeasureSpec(view.getMeasuredHeight(), 1073741824));
view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
}
private void removeProgressView() {
runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$removeProgressView$13();
}
});
}
public void resetAutoCaptureVariables() {
this.autoCaptureTimerNumber = 3;
this.isAutoCapturing = false;
this.isCardDetectionInProgress = false;
this.isStillAutoCaptureInitialState = true;
if (this.docConfig.isShouldAutoCapture() && this.isDocCaptureFlow) {
setAutoCaptureInitialState();
}
CountDownTimer countDownTimer = this.autoCaptureTimer;
if (countDownTimer == null || !this.isAutoCaptureTimerRunning) {
return;
}
countDownTimer.cancel();
}
public void resetReadBarcodeVariables() {
this.isBarcodeDetected = false;
if (this.docConfig.isShouldReadBarcode() && this.isDocCaptureFlow) {
setReadBarcodeInitialState();
}
}
private void runOverlayTimer() {
if (this.docConfig.getDocumentCaptureOverlayDuration() != Integer.MAX_VALUE) {
new CountDownTimer(this.docConfig.getDocumentCaptureOverlayDuration(), 1000L) {
@Override
public void onFinish() {
if (HVDocsActivity.this.overlayImageView != null) {
HVDocsActivity.this.overlayImageView.setVisibility(4);
}
}
@Override
public void onTick(long j) {
}
}.start();
}
}
public void safeTakePicture() {
if (this.cameraFree.get()) {
this.safeToTakePicture = false;
this.cameraFree.set(false);
try {
this.imageCaptureTimingUtils.init();
if (this.cameraView != null) {
showProgressDialog(true, "");
this.cameraView.takePicture(null);
} else {
this.hvImageCaptureError = new HVError(2, "cameraView is null");
long longValue = this.imageCaptureTimingUtils.getTimeDifferenceLong().longValue();
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureFailed(this.hvImageCaptureError, this.docConfig, longValue);
}
}
} catch (Exception e) {
Utils.getErrorMessage(e);
this.hvImageCaptureError = new HVError(2, Utils.getErrorMessage(e));
long longValue2 = this.imageCaptureTimingUtils.getTimeDifferenceLong().longValue();
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureFailed(this.hvImageCaptureError, this.docConfig, longValue2);
}
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
}
private void setAutoCaptureInitialState() {
try {
TextView textView = this.instructionsOutsideCameraPreviewBox;
if (textView != null) {
textView.setVisibility(0);
}
showOverlayImageView(true);
TextView textView2 = this.instructionsInsideCameraPreviewBox;
if (textView2 != null) {
textView2.setVisibility(4);
}
TextView textView3 = this.hintText;
if (textView3 != null) {
textView3.setVisibility(4);
}
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
private void setAutoCaptureUI(boolean z, Spanned spanned) {
if (z) {
this.documentCaptureView.setBorderColor(getResources().getColor(R.color.doc_capture_circle_success));
} else {
this.documentCaptureView.setBorderColor(getResources().getColor(R.color.doc_capture_circle_failure));
}
TextView textView = this.instructionsInsideCameraPreviewBox;
if (textView != null) {
textView.setText(spanned);
}
try {
TextView textView2 = this.instructionsOutsideCameraPreviewBox;
if (textView2 != null) {
textView2.setVisibility(4);
}
} catch (Exception unused) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$setAutoCaptureUI$6();
}
});
}
try {
showOverlayImageView(false);
} catch (Exception unused2) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$setAutoCaptureUI$7();
}
});
}
try {
TextView textView3 = this.instructionsInsideCameraPreviewBox;
if (textView3 != null) {
textView3.setVisibility(0);
}
} catch (Exception unused3) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$setAutoCaptureUI$8();
}
});
}
try {
TextView textView4 = this.hintText;
if (textView4 != null) {
textView4.setVisibility(0);
}
} catch (Exception unused4) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$setAutoCaptureUI$9();
}
});
}
}
public void setCaptureButtonState(boolean z, boolean z2) {
ImageView imageView = this.btCapture;
if (imageView == null) {
return;
}
if (z) {
imageView.setVisibility(0);
} else {
imageView.setVisibility(4);
}
if (z2) {
HyperSnapUIConfigUtil.getInstance().customiseCaptureButton(this.btCapture);
this.btCapture.setImageResource(R.drawable.ic_camera_button_svg);
this.btCapture.setClickable(true);
this.btCapture.setEnabled(true);
return;
}
this.btCapture.setImageResource(R.drawable.hv_camera_button_disabled);
androidx.core.widget.i.c(this.btCapture, (ColorStateList) null);
this.btCapture.setClickable(false);
this.btCapture.setEnabled(false);
}
public void setHVCardUIState(HVCardUIState hVCardUIState) {
this.hvCardUIState = hVCardUIState;
int i = AnonymousClass13.$SwitchMap$co$hyperverge$hypersnapsdk$activities$HVDocsActivity$HVCardUIState[hVCardUIState.ordinal()];
if (i == 1) {
this.isStillAutoCaptureInitialState = false;
setAutoCaptureUI(true, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_DOC_FOUND, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_DOC_FOUND, getStringFromResources(R.string.docCaptureDocFound)));
return;
}
if (i == 2) {
if (this.isStillAutoCaptureInitialState) {
return;
}
setAutoCaptureUI(false, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_DOC_NOT_FOUND, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_DOC_NOT_FOUND, getStringFromResources(R.string.docCaptureDocNotFound)));
} else {
if (i == 3) {
this.isStillAutoCaptureInitialState = false;
setAutoCaptureUI(false, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_MOVE_CLOSER, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_MOVE_CLOSER, getStringFromResources(R.string.docCaptureMoveCloser)));
return;
}
if (i == 4) {
this.isStillAutoCaptureInitialState = false;
setAutoCaptureUI(false, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_MOVE_AWAY_FROM_CAMERA, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_MOVE_AWAY_FROM_CAMERA, getStringFromResources(R.string.docCaptureMoveAwayFromCamera)));
} else if (i != 5) {
return;
}
this.isStillAutoCaptureInitialState = false;
setAutoCaptureUI(false, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_MOVE_AWAY_FROM_EDGE, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_MOVE_AWAY_FROM_EDGE, getStringFromResources(R.string.docCaptureMoveAwayFromEdge)));
}
}
private void setReadBarcodeInitialState() {
try {
TextView textView = this.instructionsOutsideCameraPreviewBox;
if (textView != null) {
textView.setVisibility(0);
}
if (this.overlayImageView != null) {
if (this.docConfig.getReadBarcodeOverlay() != null) {
this.overlayImageView.setImageBitmap(this.docConfig.getReadBarcodeOverlay());
} else {
this.overlayImageView.setImageResource(R.drawable.hv_read_barcode_overlay);
}
}
showOverlayImageView(true);
TextView textView2 = this.instructionsInsideCameraPreviewBox;
if (textView2 != null) {
textView2.setVisibility(4);
}
TextView textView3 = this.hintText;
if (textView3 != null) {
textView3.setVisibility(0);
}
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
private void setupOverlayImageView() {
ShapeableImageView shapeableImageView;
TextView textView = this.instructionsInsideCameraPreviewBox;
if (textView != null) {
textView.setVisibility(4);
}
if (!this.docConfig.isShouldReadBarcode() && this.docConfig.getDocumentCaptureOverlay() != null && (shapeableImageView = this.overlayImageView) != null) {
shapeableImageView.setImageBitmap(this.docConfig.getDocumentCaptureOverlay());
adjustOverlayImageView();
}
if (this.docConfig.isShouldAutoCapture() || this.docConfig.isShouldReadBarcode()) {
return;
}
showOverlayImageView(true);
runOverlayTimer();
}
public void showBarcodeScannedSuccessfulOverlay(final boolean z) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$showBarcodeScannedSuccessfulOverlay$14(z);
}
});
}
private void showDocInstructions() {
this.docPickerScreenLoadSuccessTimingUtils.init();
this.docInstructionsLayout.setVisibility(0);
HVJSONObject customUIStrings = this.docConfig.getCustomUIStrings();
Spanned text = TextConfigUtils.getText(customUIStrings, CustomTextStringConst.DocCaptureTextConfigs.DOC_INSTRUCTIONS_TITLE, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_INSTRUCTIONS_TITLE);
if (text != null) {
((TextView) this.docInstructionsLayout.findViewById(R.id.tvTitle)).setText(text);
}
Spanned text2 = TextConfigUtils.getText(customUIStrings, CustomTextStringConst.DocCaptureTextConfigs.DOC_INSTRUCTIONS_SUBTITLE, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_INSTRUCTIONS_SUBTITLE);
if (text2 != null) {
((TextView) this.docInstructionsLayout.findViewById(R.id.tvSubtitle)).setText(text2);
}
Spanned text3 = TextConfigUtils.getText(customUIStrings, CustomTextStringConst.DocCaptureTextConfigs.DOC_INSTRUCTIONS_BUTTON, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_INSTRUCTIONS_BUTTON);
if (text3 != null) {
((Button) this.docInstructionsLayout.findViewById(R.id.btnCaptureDoc)).setText(text3);
}
Spanned text4 = TextConfigUtils.getText(customUIStrings, CustomTextStringConst.DocCaptureTextConfigs.DOC_INSTRUCTIONS_UPLOAD_BUTTON, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_INSTRUCTIONS_UPLOAD_BUTTON);
if (text4 != null) {
((Button) this.docInstructionsLayout.findViewById(R.id.btnUploadDoc)).setText(text4);
}
setupBranding(this.docInstructionsLayout);
TextView textView = (TextView) this.docInstructionsLayout.findViewById(R.id.tvTitle);
TextView textView2 = (TextView) this.docInstructionsLayout.findViewById(R.id.tvSubtitle);
Button button = (Button) this.docInstructionsLayout.findViewById(R.id.btnCaptureDoc);
button.setEnabled(true);
Button button2 = (Button) this.docInstructionsLayout.findViewById(R.id.btnUploadDoc);
this.instructionsUploadButton = button2;
button2.setEnabled(true);
HyperSnapUIConfigUtil.getInstance().customiseTitleTextView(textView);
HyperSnapUIConfigUtil.getInstance().customiseDescriptionTextView(textView2);
HyperSnapUIConfigUtil.getInstance().customisePrimaryButton(button);
HyperSnapUIConfigUtil.getInstance().customiseSecondaryButton(this.instructionsUploadButton);
HyperSnapUIConfigUtil.getInstance().customiseClientLogo((ImageView) this.docInstructionsLayout.findViewById(R.id.clientLogo));
this.docInstructionsLayout.findViewById(R.id.ivBack).setEnabled(true);
this.docInstructionsLayout.findViewById(R.id.ivBack).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
HVDocsActivity.this.lambda$showDocInstructions$2(view);
}
});
this.instructionsUploadButton.setVisibility(this.docConfig.isDocumentUploadEnabled() ? 0 : 8);
this.instructionsUploadButton.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
HVDocsActivity.this.lambda$showDocInstructions$3(view);
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
HVDocsActivity.this.lambda$showDocInstructions$4(view);
}
});
long longValue = this.docPickerScreenLoadSuccessTimingUtils.getTimeDifferenceLong().longValue();
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(getApplicationContext()).logDocumentPickerScreenLoadSuccess(longValue);
SDKInternalConfig.getInstance().getAnalyticsTrackerService(getApplicationContext()).logDocumentPickerScreenLaunched();
}
this.docPickerUploadButtonClickTimingUtils.init();
this.docPickerCaptureButtonClickTimingUtils.init();
loadAnimation();
}
private void showLocationSettingsDialog() {
HVJSONObject customUIStrings = this.docConfig.getCustomUIStrings();
Spanned text = TextConfigUtils.getText(customUIStrings, "", CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_LOCATION_PERMISSION_TITLE, getString(R.string.hv_gps_switched_off));
Spanned text2 = TextConfigUtils.getText(customUIStrings, "", CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_LOCATION_PERMISSION_DESC, getString(R.string.hv_please_enable_gps_to_continue));
Spanned text3 = TextConfigUtils.getText(customUIStrings, "", CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_LOCATION_PERMISSION_SETTINGS_BUTTON, getString(R.string.hv_open_settings));
Spanned text4 = TextConfigUtils.getText(customUIStrings, "", CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_LOCATION_PERMISSION_CANCEL_BUTTON, getString(R.string.hv_cancel));
final Spanned text5 = TextConfigUtils.getText(customUIStrings, "", CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_LOCATION_PERMISSION_ERROR, getString(R.string.hv_gps_access_denied_by_user));
b.a aVar = new b.a(this);
aVar.setTitle(text);
aVar.f(text2);
aVar.b(false);
aVar.j(text3, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
HVDocsActivity.this.lambda$showLocationSettingsDialog$0(dialogInterface, i);
}
});
aVar.g(text4, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
HVDocsActivity.this.lambda$showLocationSettingsDialog$1(text5, dialogInterface, i);
}
});
aVar.m();
}
private void showOverlayImageView(boolean z) {
if (z) {
if (this.overlayImageView == null || !this.docConfig.isOverlayEnabled()) {
return;
}
this.overlayImageView.setVisibility(0);
return;
}
ShapeableImageView shapeableImageView = this.overlayImageView;
if (shapeableImageView != null) {
shapeableImageView.setVisibility(4);
}
}
public void showProgressDialog(boolean z, String str) {
StringBuilder sb = new StringBuilder();
sb.append("showProgressDialog() called with: show = [");
sb.append(z);
sb.append("], progressLoaderText = [");
sb.append(str);
sb.append("]");
if (this.blackOverlay != null) {
if (z) {
displayProgressView(str);
} else {
removeProgressView();
}
}
}
public static void start(@NonNull Context context, @NonNull HVDocConfig hVDocConfig, @NonNull DocCaptureCompletionHandler docCaptureCompletionHandler) {
StringBuilder sb = new StringBuilder();
sb.append("start() called with: context = [");
sb.append(context);
sb.append("], hvDocConfig = [");
sb.append(hVDocConfig);
sb.append("], listener = [");
sb.append(docCaptureCompletionHandler);
sb.append("]");
if (docCaptureCompletionHandler == null) {
return;
}
documentImageListener = docCaptureCompletionHandler;
StringBuilder sb2 = new StringBuilder();
sb2.append("start: documentImageListener: ");
sb2.append(documentImageListener);
if (context == null) {
callCompletionHandler(new HVError(6, "Context object is null"), null);
return;
}
HyperSnapSDK hyperSnapSDK = HyperSnapSDK.getInstance();
HyperSnapSDKConfig hyperSnapSDKConfig = hyperSnapSDK.getHyperSnapSDKConfig();
if (!hyperSnapSDK.isHyperSnapSDKInitialised() || ((hyperSnapSDKConfig.getAppId() != null && hyperSnapSDKConfig.getAppId().isEmpty()) || (hyperSnapSDKConfig.getAppKey() != null && hyperSnapSDKConfig.getAppKey().isEmpty()))) {
HVError hVError = new HVError(11, context.getResources().getString(R.string.initialised_error));
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logHyperSnapSDKInitError(hVError.getErrorMessage());
}
callCompletionHandler(hVError, null);
return;
}
if (hyperSnapSDKConfig.getHyperSnapRegion() == HyperSnapParams.Region.ASIA_PACIFIC && !HyperSnapSDK.isUserSessionActive()) {
callCompletionHandler(new HVError(11, context.getResources().getString(R.string.user_session_not_created_error)), null);
return;
}
if (hVDocConfig == null) {
callCompletionHandler(new HVError(6, context.getResources().getString(R.string.document_config_error)), null);
return;
}
Intent intent = new Intent(context, (Class<?>) HVDocsActivity.class);
if (hVDocConfig.isShouldReadNIDQR() && SDKInternalConfig.getInstance().getFeatureConfigMap().get(AppConstants.READ_DOC_QR_FEATURE) != null) {
hVDocConfig.setShouldReadNIDQR(SDKInternalConfig.getInstance().getFeatureConfigMap().get(AppConstants.READ_DOC_QR_FEATURE).isShouldEnable());
}
if (hVDocConfig.isShouldAutoCapture()) {
if (Build.VERSION.SDK_INT >= 26) {
Map<String, FeatureConfig> featureConfigMap = SDKInternalConfig.getInstance().getFeatureConfigMap();
if (featureConfigMap != null && featureConfigMap.containsKey(AppConstants.DOC_AUTO_CAPTURE)) {
hVDocConfig.setShouldAutoCapture(featureConfigMap.get(AppConstants.DOC_AUTO_CAPTURE).isShouldEnable());
}
} else {
hVDocConfig.setShouldAutoCapture(false);
}
}
intent.putExtra(HVDocConfig.KEY, hVDocConfig);
context.startActivity(intent);
}
private void startDocCapture() {
this.isDocCaptureFlow = true;
this.docInstructionsLayout.setVisibility(8);
try {
this.permissionManager = new PermissionManager();
if (SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentDocFlowStarted(this.docConfig);
}
checkForPermissions();
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
sendResponse(new HVError(2, getStringFromResources(R.string.internal_error)));
}
}
private void startDocUpload() {
this.isDocCaptureFlow = false;
if (InternalToolUtils.isTestMode(this)) {
onActivityResult(RC_PICK_DOC, -1, new Intent().setData(Uri.fromFile(InternalToolUtils.getDocumentImageFile(this.docConfig.getDocumentSide()))));
} else {
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.setType("*/*");
intent.putExtra("android.intent.extra.MIME_TYPES", getUploadMimeTypes());
startActivityForResult(intent, RC_PICK_DOC);
}
}
private void startDocumentCapture() {
try {
if (!this.isViewsInitialised || this.showInstructionPage) {
initializeViewsById();
}
if (this.docConfig.isShouldAutoCapture()) {
TextView textView = this.instructionsInsideCameraPreviewBox;
if (textView != null) {
textView.setVisibility(0);
}
TextView textView2 = this.instructionsOutsideCameraPreviewBox;
if (textView2 != null) {
textView2.setVisibility(0);
}
TextView textView3 = this.tvTitle;
if (textView3 != null) {
textView3.setVisibility(4);
}
TextView textView4 = this.descText;
if (textView4 != null) {
textView4.setVisibility(4);
}
resetAutoCaptureVariables();
} else if (this.docConfig.isShouldReadBarcode()) {
TextView textView5 = this.instructionsInsideCameraPreviewBox;
if (textView5 != null) {
textView5.setVisibility(4);
}
TextView textView6 = this.instructionsOutsideCameraPreviewBox;
if (textView6 != null) {
textView6.setVisibility(0);
this.instructionsOutsideCameraPreviewBox.setText(TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_SCANNING_BARCODE, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_SCANNING_BARCODE, getStringFromResources(R.string.docCaptureScanningBarcode)));
}
TextView textView7 = this.tvTitle;
if (textView7 != null) {
textView7.setVisibility(4);
}
TextView textView8 = this.descText;
if (textView8 != null) {
textView8.setVisibility(4);
}
resetReadBarcodeVariables();
} else {
TextView textView9 = this.instructionsInsideCameraPreviewBox;
if (textView9 != null) {
textView9.setVisibility(4);
}
TextView textView10 = this.instructionsOutsideCameraPreviewBox;
if (textView10 != null) {
textView10.setVisibility(4);
}
TextView textView11 = this.tvTitle;
if (textView11 != null) {
textView11.setVisibility(0);
}
TextView textView12 = this.descText;
if (textView12 != null) {
textView12.setVisibility(0);
}
}
setupOverlayImageView();
setupBranding(null);
this.cameraFree = new AtomicBoolean(true);
try {
if (!this.docConfig.isShouldAllowPhoneTilt()) {
initializeTiltSensor();
SensorManager sensorManager = this.sensorManager;
sensorManager.registerListener(this.mySensorEventListener, sensorManager.getDefaultSensor(1), 3);
SensorManager sensorManager2 = this.sensorManager;
sensorManager2.registerListener(this.mySensorEventListener, sensorManager2.getDefaultSensor(2), 3);
}
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureScreenLoadFailure(new HVError(2, Utils.getErrorMessage(e)));
}
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
long longValue = this.screenLoadSuccessTimingUtils.getTimeDifferenceLong().longValue();
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureScreenOpened(this.docConfig);
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureScreenLoadSuccess(longValue);
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureScreenLaunched();
this.captureClickTimingUtils.init();
} catch (Exception e2) {
Utils.getErrorMessage(e2);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureScreenLoadFailure(new HVError(2, Utils.getErrorMessage(e2)));
}
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e2);
}
sendResponse(new HVError(2, getStringFromResources(R.string.internal_error)));
}
}
private void userCancelledOperation() {
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logIdScreenClosedByUser(this.docConfig);
}
stopCamera();
finishView(new HVError(3, getString(R.string.operation_cancelled)), new HVResponse(new JSONObject(), null, null, this.retryAction));
}
public JSONObject addResultImageUri(JSONObject jSONObject, String str) {
String str2;
try {
if (this.docConfig.isShouldExportPDF() && (str2 = this.pdfPath) != null) {
jSONObject.put("pdfUri", str2);
}
} catch (JSONException e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
return jSONObject;
}
public void adjustBlackOverlayView() {
View view = this.blackOverlay;
if (view != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
layoutParams.setMargins(0, 0, 0, 0);
if (!this.blackOverlay.isInLayout()) {
this.blackOverlay.setLayoutParams(layoutParams);
}
if (this.cameraContainer.isInLayout()) {
return;
}
this.cameraContainer.requestLayout();
}
}
public void adjustHintText() {
TextView textView = this.hintText;
if (textView != null) {
textView.setY(getBottomYOfBox() - (this.hintText.getHeight() * 1.75f));
if (!this.hintText.isInLayout()) {
this.hintText.requestLayout();
}
if (this.cameraContainer.isInLayout()) {
return;
}
this.cameraContainer.requestLayout();
}
}
public void adjustOverlayImageView() {
ShapeableImageView shapeableImageView = this.overlayImageView;
if (shapeableImageView != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) shapeableImageView.getLayoutParams();
layoutParams.setMargins(((int) getBoxRect().left) + UIUtils.dpToPx(this, 32.0f), UIUtils.dpToPx(this, 32.0f), ((int) getBoxRect().left) + UIUtils.dpToPx(this, 32.0f), UIUtils.dpToPx(this, 32.0f));
if (!this.overlayImageView.isInLayout()) {
this.overlayImageView.setLayoutParams(layoutParams);
}
if (this.cameraContainer.isInLayout()) {
return;
}
this.cameraContainer.requestLayout();
}
}
public void adjustProgressDialogView() {
View view = this.progressDialogView;
if (view != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
layoutParams.setMargins(((int) getBoxRect().left) + UIUtils.dpToPx(this, 32.0f), 0, ((int) getBoxRect().left) + UIUtils.dpToPx(this, 32.0f), 0);
if (!this.progressDialogView.isInLayout()) {
this.progressDialogView.setLayoutParams(layoutParams);
}
if (this.cameraContainer.isInLayout()) {
return;
}
this.cameraContainer.requestLayout();
}
}
public void adjustScanningIndicator() {
if (!this.docConfig.isShouldReadBarcode() || this.indicator == null) {
return;
}
int bottomYOfBox = getBottomYOfBox() - getTopYOfBox();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.indicator.getLayoutParams();
layoutParams.setMargins(0, (int) (this.camViewWidth * 0.15d), 0, 0);
this.indicator.setLayoutParams(layoutParams);
this.indicator.setmHeight(bottomYOfBox);
if (!this.cameraContainer.isInLayout()) {
this.cameraContainer.requestLayout();
}
this.indicator.startAnimation();
}
public void adjustStatusText() {
TextView textView = this.instructionsInsideCameraPreviewBox;
if (textView != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textView.getLayoutParams();
layoutParams.setMarginStart(UIUtils.dpToPx(this, 32.0f));
layoutParams.setMarginEnd(UIUtils.dpToPx(this, 32.0f));
if (!this.instructionsInsideCameraPreviewBox.isInLayout()) {
this.instructionsInsideCameraPreviewBox.setLayoutParams(layoutParams);
}
if (this.cameraContainer.isInLayout()) {
return;
}
this.cameraContainer.requestLayout();
}
}
public void adjustTitleText() {
}
public void adjustTopText() {
TextView textView = this.descText;
if (textView != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textView.getLayoutParams();
if (this.document.getAspectRatio() < 1.0f) {
layoutParams.setMargins(UIUtils.dpToPx(this, 30.0f), UIUtils.dpToPx(this, 60.0f), UIUtils.dpToPx(this, 30.0f), 0);
}
if (this.descText.isInLayout()) {
return;
}
this.descText.requestLayout();
}
}
@Override
public void lambda$checkAndWaitForRemoteConfig$0() {
super.lambda$checkAndWaitForRemoteConfig$0();
}
public void checkForPermissions() {
this.permissionTimingUtils.init();
ArrayList arrayList = new ArrayList(Arrays.asList("android.permission.CAMERA"));
this.permissionManager.checkAndRequestPermissions(this, arrayList);
if (this.permissionManager.getStatus(this, arrayList).denied.isEmpty()) {
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logCameraPermissionsGranted(this.permissionTimingUtils.getTimeDifferenceLong().longValue());
}
readyToStartDocCapture();
}
}
public void finishView(HVError hVError, HVResponse hVResponse) {
StringBuilder sb = new StringBuilder();
sb.append("finishView() called with: documentImageListener: ");
sb.append(documentImageListener);
sb.append("error = [");
sb.append(hVError);
sb.append("], hvResponse = [");
sb.append(hVResponse);
sb.append("]");
if (hVResponse != null) {
try {
if (this.docConfig.isShouldReadBarcode()) {
hVResponse.setRawBarcode(this.detectedBarcode);
}
Location location = this.mLocation;
if (location != null) {
hVResponse.setLatitude(Double.valueOf(location.getLatitude()));
hVResponse.setLongitude(Double.valueOf(this.mLocation.getLongitude()));
}
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
return;
}
return;
}
}
stopCamera();
lambda$checkCameraAndHandleCompletion$5(hVError, hVResponse);
}
@Override
public HVBaseConfig getBaseConfig() {
return this.docConfig;
}
@Override
public void handleCloseAction() {
super.handleCloseAction();
}
public void initializeViewsById() {
this.hvGreenTickImageView = (ImageView) findViewById(R.id.docGreenTickImageView);
this.overlayImageView = findViewById(R.id.docOverlayImageView);
this.instructionsInsideCameraPreviewBox = (TextView) findViewById(R.id.tvStatus);
this.instructionsOutsideCameraPreviewBox = (TextView) findViewById(R.id.initialStatusTV);
ImageView imageView = (ImageView) findViewById(R.id.camera_icon);
this.btCapture = imageView;
androidx.core.widget.i.c(imageView, (ColorStateList) null);
this.btCapture.setImageResource(R.drawable.hv_camera_button_disabled);
setCaptureButtonState(true, false);
this.progressDialogView = findViewById(R.id.docProgressDialogView);
this.progressSpinnerImageView = (ImageView) findViewById(R.id.hv_loading_icon);
this.progressDialogTextView = (TextView) findViewById(R.id.hv_loading_text);
if (this.docConfig.isShouldAutoCapture()) {
ImageView imageView2 = this.btCapture;
if (imageView2 != null) {
imageView2.setVisibility(4);
}
this.autoCaptureTimer = new AnonymousClass7(this.docConfig.getAutoCaptureDuration(), this.docConfig.getAutoCaptureDuration() / 2);
}
if (this.docConfig.isShouldReadBarcode() && !this.docConfig.isBarcodeSkipDisabled()) {
CountDownTimer countDownTimer = new CountDownTimer(this.docConfig.getReadBarcodeTimeout(), 1000L) {
@Override
public void onFinish() {
HVDocsActivity.this.isReadBarcodeTimerRunning = false;
HVDocsActivity.this.showBarcodeScannedSuccessfulOverlay(false);
HVDocsActivity.this.enableCaptureButton();
}
@Override
public void onTick(long j) {
}
};
this.readBarcodeTimer = countDownTimer;
countDownTimer.start();
this.isReadBarcodeTimerRunning = true;
}
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseLocation() && this.mLocation != null) {
enableCaptureButton();
}
ImageView imageView3 = (ImageView) findViewById(R.id.ivFlashFlip);
this.ivFlash = imageView3;
imageView3.setImageResource(R.drawable.ic_baseline_flash_off_18);
this.ivFlash.setEnabled(true);
this.blackOverlay = findViewById(R.id.blackOverlayView);
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
if (SDKInternalConfig.getInstance().isRemoteConfigFetchDone()) {
HVDocsActivity.this.setupBranding(null);
}
}
}, 100L);
View view = this.vFlash;
if (view != null) {
view.setVisibility(8);
}
this.cameraContainer = (FrameLayout) findViewById(R.id.cameraContainer);
CameraEngine.setPreviewCallback(this.docConfig.isShouldReadBarcode() || this.docConfig.isShouldAutoCapture());
HVCameraHelper.enableCameraParameters(this, true);
CameraEngine.setShouldRandomize(false);
CameraEngine.setShouldUseDefaultZoom(false);
try {
HVMagicView hVMagicView = this.cameraView;
if (hVMagicView != null) {
this.cameraContainer.removeView(hVMagicView);
}
HVMagicView hVMagicView2 = HVMagicView.getInstance(this, this.camHost, false);
this.cameraView = hVMagicView2;
hVMagicView2.disableRotation();
this.cameraView.setContentDescription("docCaptureCameraPreview");
this.cameraContainer.addView(this.cameraView, 0);
HVMagicView hVMagicView3 = this.cameraView;
if (hVMagicView3 != null) {
this.cameraView.setSensorCallback(new HVMagicView.SensorCallback() {
@Override
public void onSensorCallback() {
StringBuilder sb = new StringBuilder();
sb.append(HVDocsActivity.this.cameraContainer.getWidth());
sb.append(" ");
sb.append(HVDocsActivity.this.cameraContainer.getHeight());
HVDocsActivity.this.crossHairView.showCrosshair(r0.camViewWidth / 2, HVDocsActivity.this.camViewHeight / 2, false);
}
});
}
addCrossHairView(this.cameraContainer);
if (this.docConfig.isShouldReadBarcode()) {
removeScanningIndicator();
this.indicator = new ScanningIndicator(this, getBottomYOfBox() - getTopYOfBox());
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(UIUtils.getScreenWidth(), UIUtils.dpToPx(this, 15.0f));
layoutParams.gravity = 1;
this.indicator.setLayoutParams(layoutParams);
this.indicator.setImageResource(R.drawable.hv_ic_camera_qr_status);
this.cameraContainer.addView(this.indicator);
}
addDocumentCaptureView(this.cameraContainer);
ImageView imageView4 = (ImageView) findViewById(R.id.ivBack);
this.cross = imageView4;
imageView4.setEnabled(true);
this.cross.setOnClickListener(this);
this.tvTitle = (TextView) findViewById(R.id.title_text);
this.hintText = (TextView) findViewById(R.id.tvHint);
try {
HVJSONObject customUIStrings = this.docConfig.getCustomUIStrings();
if (this.docConfig.getHintTypeface() > 0) {
this.hintText.setTypeface(ResourcesCompat.h(getApplicationContext(), this.docConfig.getHintTypeface()));
}
String docCaptureSubText = this.docConfig.getDocCaptureSubText();
if (TextUtils.isEmpty(docCaptureSubText)) {
Spanned text = TextConfigUtils.getText(customUIStrings, CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_SUB_TEXT, this.docConfig.getDocumentSide() == HVDocConfig.DocumentSide.FRONT ? CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_FRONT_SUB_TEXT : CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_BACK_SUB_TEXT);
if (text != null) {
this.hintText.setText(text);
}
} else {
this.hintText.setText(docCaptureSubText);
}
this.descText = (TextView) findViewById(R.id.desc_text);
if (this.docConfig.getDescTypeface() > 0) {
this.descText.setTypeface(ResourcesCompat.h(getApplicationContext(), this.docConfig.getDescTypeface()));
}
if (this.docConfig.getDocCaptureDescription() == null || this.docConfig.getDocCaptureDescription().isEmpty()) {
Spanned text2 = TextConfigUtils.getText(customUIStrings, CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_DESC, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_DESC);
if (text2 != null) {
this.descText.setText(text2);
}
} else {
this.descText.setText(this.docConfig.getDocCaptureDescription());
}
String capturePageTitleText = this.docConfig.getCapturePageTitleText();
if (TextUtils.isEmpty(capturePageTitleText)) {
Spanned text3 = TextConfigUtils.getText(customUIStrings, CustomTextStringConst.DocCaptureTextConfigs.DOC_CAPTURE_TITLE, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAPTURE_TITLE);
if (text3 != null) {
this.tvTitle.setText(text3);
}
} else {
this.tvTitle.setText(capturePageTitleText);
}
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureScreenLoadFailure(new HVError(2, Utils.getErrorMessage(e)));
}
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
CameraEngine.setCaptureMode(true);
Display defaultDisplay = getWindowManager().getDefaultDisplay();
Point point = new Point();
defaultDisplay.getSize(point);
defaultDisplay.getMetrics(new DisplayMetrics());
CameraEngine.setScreenSize(point);
float f = getResources().getDisplayMetrics().density;
this.density = f;
this.dpHeight = r5.heightPixels / f;
this.dpWidth = r5.widthPixels / f;
adjustView(false);
adjustCrossHairView();
adjustHintText();
adjustTitleText();
adjustDocumentCaptureView();
adjustScanningIndicator();
adjustOverlayImageView();
adjustBlackOverlayView();
adjustProgressDialogView();
adjustStatusText();
if (this.docConfig.getTitleTypeface() > 0) {
this.tvTitle.setTypeface(ResourcesCompat.h(getApplicationContext(), this.docConfig.getTitleTypeface()));
}
HyperSnapUIConfigUtil.getInstance().customiseTitleTextView(this.tvTitle);
HyperSnapUIConfigUtil.getInstance().customiseDescriptionTextView(this.descText);
HyperSnapUIConfigUtil.getInstance().customiseStatusTextView(this.instructionsOutsideCameraPreviewBox);
HyperSnapUIConfigUtil.getInstance().customiseDocumentSideTextView(this.hintText);
HyperSnapUIConfigUtil.getInstance().customiseClientLogo((ImageView) findViewById(R.id.clientLogo));
this.btCapture.setOnClickListener(this);
this.ivFlash.setOnClickListener(this);
this.btCapture.setOnTouchListener(new View.OnTouchListener() {
boolean inAnimate;
@Override
public boolean onTouch(View view2, MotionEvent motionEvent) {
if (!HVDocsActivity.this.docConfig.isShouldAllowPhoneTilt() && HVDocsActivity.this.isPhoneTilted) {
return false;
}
int action = motionEvent.getAction();
if (action == 0) {
this.inAnimate = HVDocsActivity.this.cameraFree.get();
if (HVDocsActivity.this.cameraFree.get()) {
HVDocsActivity.this.popin();
}
} else if (action == 1 && this.inAnimate) {
HVDocsActivity.this.popout();
}
return false;
}
});
if (this.cameraView != null) {
this.cameraView.onResume();
} else if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureScreenLoadFailure(new HVError(2, "CameraView is null"));
}
this.isViewsInitialised = true;
} catch (Exception e2) {
Utils.getErrorMessage(e2);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e2);
}
HVError hVError = new HVError(5, getStringFromResources(R.string.camera_error));
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureScreenLoadFailure(hVError);
}
sendResponse(hVError);
}
}
public void makeOCRAPICall(final String str, String str2) {
StringBuilder sb = new StringBuilder();
sb.append("makeOCRAPICall() called with: filePath = [");
sb.append(str);
sb.append("], capturedHighResolutionQRCroppedImagePath = [");
sb.append(str2);
sb.append("]");
JSONObject ocrHeaders = this.docConfig.getOcrHeaders();
try {
ocrHeaders.put(AppConstants.IS_DOCUMENT_UPLOADED, !this.isDocCaptureFlow);
ocrHeaders.put("sdk-mode", InternalToolUtils.getSdkMode(this));
this.docConfig.ocrHeaders = ocrHeaders.toString();
} catch (Exception e) {
StringBuilder sb2 = new StringBuilder();
sb2.append("makeOCRAPICall() ocrHeaders:");
sb2.append(Utils.getErrorMessage(e));
}
if (this.docConfig.isShouldAutoCapture()) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
HVDocsActivity.this.lambda$makeOCRAPICall$15();
}
});
}
Spanned text = TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_LOADER_DESC, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_LOADER_DESC, getStringFromResources(R.string.hv_doc_loader_subtitle));
showProgressDialog(true, text != null ? text.toString() : null);
this.shouldAllowActivityClose = false;
DocOCRHelper.get().makeOcrAPICall(this, str, str2, this.docConfig, new DocOCRHelper.DocOCRListener() {
@Override
public final void onResult(boolean z, String str3, String str4, JSONObject jSONObject, JSONObject jSONObject2, HVError hVError) {
HVDocsActivity.this.lambda$makeOCRAPICall$18(str, z, str3, str4, jSONObject, jSONObject2, hVError);
}
});
}
public void onActivityResult(int i, int i2, Intent intent) {
super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i, i2, intent);
StringBuilder sb = new StringBuilder();
sb.append("onActivityResult() called with: requestCode = [");
sb.append(i);
sb.append("], resultCode = [");
sb.append(i2);
sb.append("], data = [");
sb.append(intent);
sb.append("]");
this.safeToTakePicture = true;
if (this.docConfig.isShouldReadBarcode()) {
resetReadBarcodeVariables();
}
resetAutoCaptureVariables();
reInitCaptureButton();
setupOverlayImageView();
reInitTimingUtils();
ImageView imageView = this.cross;
if (imageView != null) {
imageView.setEnabled(true);
}
showProgressDialog(false, null);
if (i == LOCATION_SETTINGS_REQUEST_CODE) {
try {
getLocation(this);
} catch (NoClassDefFoundError unused) {
HVLogUtils.e(TAG, "gms excluded");
}
}
if (i == RC_PICK_DOC) {
if (i2 != -1 || intent == null || intent.getData() == null) {
this.instructionsUploadButton.setEnabled(true);
} else {
Uri data = intent.getData();
String fileMimeType = Utils.getFileMimeType(getContentResolver(), data);
String str = TAG;
HVLogUtils.d(str, "onActivityResult: uri - " + data);
HVLogUtils.d(str, "onActivityResult: fileMimeType - " + fileMimeType);
if (fileMimeType == null) {
startRetakeScreen(null, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_UPLOAD_READ_FILE_ERROR, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_UPLOAD_READ_FILE_ERROR, getStringFromResources(R.string.docUploadReadFileError)).toString());
} else if (isSelectedFileExtentionInAllowedList(fileMimeType)) {
File saveDocToFilesDir = Utils.saveDocToFilesDir(getContentResolver(), data, new File(getFilesDir(), "hv"));
if (saveDocToFilesDir == null || !saveDocToFilesDir.exists()) {
startRetakeScreen(null, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_UPLOAD_READ_FILE_ERROR, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_UPLOAD_READ_FILE_ERROR, getStringFromResources(R.string.docUploadReadFileError)).toString());
} else {
String path = saveDocToFilesDir.getPath();
JSONObject jSONObject = new JSONObject();
if (Utils.getFileExtension(getContentResolver(), data).equals("pdf")) {
try {
PDFUtils.checkIfPDFIsReadable(data, getContentResolver());
} catch (Exception e) {
Utils.getErrorMessage(e);
if (e instanceof SecurityException) {
startRetakeScreen(path, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_UPLOAD_PASSWORD_PROTECTED_ERROR, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_UPLOAD_PASSWORD_PROTECTED_ERROR, getStringFromResources(R.string.docUploadPasswordProtectedError)).toString());
return;
} else {
startRetakeScreen(path, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_UPLOAD_READ_FILE_ERROR, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_UPLOAD_READ_FILE_ERROR, getStringFromResources(R.string.docUploadReadFileError)).toString());
return;
}
}
} else {
try {
ExifHelper exifHelper = new ExifHelper();
exifHelper.readExifFromFile(saveDocToFilesDir, this.mLocation);
if (this.docConfig.isShouldExportPDF()) {
String convertImageToPDF = ImageToPDFConverter.convertImageToPDF(BitmapFactory.decodeFile(path), this.folder.getPath() + "/hv_" + System.currentTimeMillis() + ".pdf");
this.pdfPath = convertImageToPDF;
jSONObject.put("pdfUri", convertImageToPDF);
}
exifHelper.writeExifData(path, getTransactionId(), this.ipAddress);
} catch (Exception e2) {
Utils.getErrorMessage(e2);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e2);
}
}
}
startReviewScreen(path, null);
}
} else {
startRetakeScreen(null, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_UPLOAD_ALLOWED_FILE_TYPE_ERROR, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_UPLOAD_ALLOWED_FILE_TYPE_ERROR, getStringFromResources(R.string.docUploadAllowedFileTypeError)).toString());
}
}
}
if (i2 == 6) {
this.numberOfRechecks++;
decideWhatToShow(false);
if (intent != null) {
long longExtra = intent.getLongExtra("timeTakenToClickRetakeButton", 0L);
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentReviewScreenRetakeButtonClicked(this.docConfig, longExtra);
return;
}
return;
}
if (i2 == 7) {
long longExtra2 = intent.getLongExtra("timeTakenToClickConfirmButton", 0L);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentReviewScreenConfirmButtonClicked(this.docConfig, this.numberOfRechecks, longExtra2);
}
stopCamera();
finishView((HVError) intent.getSerializableExtra("hvError"), (HVResponse) intent.getSerializableExtra("hvResponse"));
return;
}
if (i2 == 8 || i2 == 18) {
stopCamera();
finishView((HVError) intent.getSerializableExtra("hvError"), null);
return;
}
if (i2 != 21) {
return;
}
this.numberOfRechecks++;
decideWhatToShow(true);
if (intent != null) {
long longExtra3 = intent.getLongExtra("timeTakenToClickRetakeButton", 0L);
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentRetakeScreenRetakeButtonClicked(this.docConfig, longExtra3);
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.ivBack) {
view.setEnabled(false);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCloseClicked();
}
onBackPressed();
return;
}
if (id != R.id.camera_icon) {
if (id == R.id.ivFlashFlip) {
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureFlashButtonClicked();
}
HVMagicView hVMagicView = this.cameraView;
if (hVMagicView != null) {
hVMagicView.nextFlashMode();
return;
}
return;
}
return;
}
StringBuilder sb = new StringBuilder();
sb.append("onClick() called with: view = [");
sb.append(view);
sb.append("]");
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentCaptureButtonClicked(this.docConfig, this.captureClickTimingUtils.getTimeDifferenceLong().longValue());
}
if (this.docConfig.isShouldAllowPhoneTilt() || !this.isPhoneTilted) {
setCaptureButtonState(true, false);
this.cross.setEnabled(false);
safeTakePicture();
}
}
@Override
public void onCloseActivity() {
if ((this.docConfig.isShouldShowInstructionPage() || this.docConfig.isDocumentUploadEnabled()) && this.docInstructionsLayout.getVisibility() != 0) {
stopCamera();
showProgressDialog(false, null);
this.safeToTakePicture = true;
this.showInstructionPage = true;
showDocInstructions();
} else {
userCancelledOperation();
}
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService(getApplicationContext()).logDocumentCaptureScreenBackPressed();
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
setContentView(R.layout.hv_activity_doc_capture);
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
sendResponse(new HVError(2, getStringFromResources(R.string.internal_error)));
}
if (bundle != null) {
finish();
return;
}
getWindow().getDecorView().getRootView().setTag("docCaptureCameraPreview");
this.docConfig = (HVDocConfig) getIntent().getSerializableExtra(HVDocConfig.KEY);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentDocFlowStarted(this.docConfig);
}
if (this.docConfig == null) {
sendResponse(new HVError(6, getStringFromResources(R.string.document_config_error)));
}
if (this.docConfig.isShouldReadBarcode() || this.docConfig.isShouldReadNIDQR()) {
initializeHVBarcodeDetector();
}
if (this.docConfig.isShouldAutoCapture()) {
this.docConfig.setShouldAutoCapture(initDocumentDetector(this));
}
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseLocation()) {
try {
getLocation(this);
} catch (NoClassDefFoundError unused) {
}
}
this.document = this.docConfig.getDocument();
View findViewById = findViewById(R.id.v_flash);
this.vFlash = findViewById;
if (findViewById != null) {
findViewById.setVisibility(0);
}
File file = new File(getFilesDir(), "hv");
this.folder = file;
if (!file.exists()) {
this.folder.mkdirs();
}
long currentTimeMillis = System.currentTimeMillis();
this.capturedImagePath = this.folder.getPath() + EmvParser.CARD_HOLDER_NAME_SEPARATOR + currentTimeMillis + ".jpg";
this.capturedHighResolutionQRCroppedImagePath = this.folder.getPath() + "/HIGH_RES_CROPPED_" + currentTimeMillis + ".jpg";
this.capturedHighResolutionFullImagePath = this.folder.getPath() + "/HIGH_RES_FULL_" + currentTimeMillis + ".jpg";
this.docInstructionsLayout = findViewById(R.id.layoutDocInstructions);
ConstraintLayout findViewById2 = findViewById(R.id.layoutDocLoader);
this.docLoaderLayout = findViewById2;
this.lav = (LottieAnimationView) findViewById2.findViewById(R.id.lavDocLoader);
StringBuilder sb = new StringBuilder();
sb.append("onCreate: documentImageListener: ");
sb.append(documentImageListener);
}
@Override
public void onDestroy() {
try {
if (!this.docConfig.isShouldAllowPhoneTilt()) {
this.sensorManager.unregisterListener(this.mySensorEventListener);
DocOCRHelper.destroy();
}
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
super.onDestroy();
LocationServiceImpl.destroy();
}
@Override
public void onPause() {
super.onPause();
HVMagicView hVMagicView = this.cameraView;
if (hVMagicView != null) {
hVMagicView.onPause();
}
}
@Override
public void onRemoteConfigFetchDone() {
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSensorBiometrics()) {
String sensorDataZipFileName = Utils.getSensorDataZipFileName("doc");
if (SDKInternalConfig.getInstance().getHvSensorBiometrics() != null) {
SDKInternalConfig.getInstance().getHvSensorBiometrics().registerSensorBiometrics(sensorDataZipFileName);
}
JSONObject ocrHeaders = this.docConfig.getOcrHeaders();
try {
ocrHeaders.put(AppConstants.SENSOR_DATA_ZIP_FILE_NAME, sensorDataZipFileName);
this.docConfig.ocrHeaders = ocrHeaders.toString();
} catch (Exception e) {
StringBuilder sb = new StringBuilder();
sb.append("start() ocrHeaders :- JSON Exception :");
sb.append(Utils.getErrorMessage(e));
}
}
startDocumentCapture();
}
public void onRequestPermissionsResult(int i, @NonNull String[] strArr, @NonNull int[] iArr) {
final PermissionManager.StatusArray status = this.permissionManager.getStatus(this, new ArrayList(Arrays.asList("android.permission.CAMERA")));
if (!status.denied.isEmpty()) {
showCameraPermissionBS(TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), "", CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAMERA_PERMISSION_TITLE), TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), "", CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAMERA_PERMISSION_DESC), TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), "", CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_CAMERA_PERMISSION_BUTTON), new PermDialogCallback() {
@Override
public void onActionClick() {
if (androidx.core.app.b.z(HVDocsActivity.this, "android.permission.CAMERA")) {
HVDocsActivity.this.checkForPermissions();
return;
}
HVDocsActivity.this.startActivity(new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", Uri.parse("package:" + HVDocsActivity.this.getApplicationContext().getPackageName())));
}
@Override
public void onCancel() {
HVError hVError = new HVError(4, "Following Permissions not granted by user: " + TextUtils.join(",", status.denied));
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logCameraPermissionsRejected(hVError, HVDocsActivity.this.permissionTimingUtils.getTimeDifferenceLong().longValue());
}
HVDocsActivity.callCompletionHandler(hVError, null);
HVDocsActivity.this.finish();
}
});
return;
}
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logCameraPermissionsGranted(this.permissionTimingUtils.getTimeDifferenceLong().longValue());
}
readyToStartDocCapture();
super/*androidx.fragment.app.FragmentActivity*/.onRequestPermissionsResult(i, strArr, iArr);
}
@Override
public void onResume() {
super.onResume();
HVMagicView hVMagicView = this.cameraView;
if (hVMagicView != null) {
hVMagicView.onResume();
}
}
public void onSaveInstanceState(Bundle bundle) {
super/*androidx.activity.ComponentActivity*/.onSaveInstanceState(bundle);
}
public void onStart() {
super.onStart();
StringBuilder sb = new StringBuilder();
sb.append("onStart: docConfig.isShouldShowInstructionPage(): ");
sb.append(this.docConfig.isShouldShowInstructionPage());
sb.append("\ndocConfig.isDocumentUploadEnabled(): ");
sb.append(this.docConfig.isDocumentUploadEnabled());
sb.append("\nisDocCaptureFlow: ");
sb.append(this.isDocCaptureFlow);
sb.append("\nisFromRetake: ");
sb.append(false);
decideWhatToShow(false);
}
@Override
public boolean onSupportNavigateUp() {
return super.onSupportNavigateUp();
}
public void removeScanningIndicator() {
AppCompatImageView appCompatImageView = this.indicator;
if (appCompatImageView != null) {
this.cameraContainer.removeView(appCompatImageView);
if (this.cameraContainer.isInLayout()) {
return;
}
this.cameraContainer.requestLayout();
}
}
public void sendResponse(HVError hVError) {
StringBuilder sb = new StringBuilder();
sb.append("sendResponse() called with: documentImageListener: ");
sb.append(documentImageListener);
sb.append("error = [");
sb.append(hVError);
sb.append("]");
callCompletionHandler(hVError, null);
DocOCRHelper.destroy();
finish();
}
public void setCameraButtonTint() {
if (!this.docConfig.isShouldAllowPhoneTilt() || this.isPhoneTilted) {
return;
}
if (this.mLocation == null && HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseLocation()) {
return;
}
HyperSnapUIConfigUtil.getInstance().customiseCaptureButton(this.btCapture);
}
public void setDescText() {
if (this.isPhoneTilted) {
this.descText.setText(getStringFromResources(R.string.docCaptureTilt));
this.descText.setTextColor(getResources().getColor(R.color.text_red));
return;
}
this.descText.setTextColor(getResources().getColor(R.color.content_text_color));
if (this.docConfig.getDocCaptureDescription() == null || this.docConfig.getDocCaptureDescription().isEmpty()) {
this.descText.setText(getStringFromResources(R.string.docCaptureDescription));
} else {
this.descText.setText(this.docConfig.getDocCaptureDescription());
}
}
@Override
public boolean shouldAllowActivityClose() {
return this.shouldAllowActivityClose;
}
@Override
public boolean shouldShowCloseAlert() {
return this.docConfig.isDocumentUploadEnabled() ? this.docConfig.shouldShowCloseAlert() && this.docInstructionsLayout.getVisibility() == 0 : this.docConfig.shouldShowCloseAlert();
}
@Override
public void showCameraPermissionBS(Spanned spanned, Spanned spanned2, Spanned spanned3, PermDialogCallback permDialogCallback) {
super.showCameraPermissionBS(spanned, spanned2, spanned3, permDialogCallback);
}
public void startRetakeScreen(String str, String str2) {
StringBuilder sb = new StringBuilder();
sb.append("startErrorReviewScreen() called with: filePath = [");
sb.append(str);
sb.append("], message = [");
sb.append(str2);
sb.append("]");
try {
Intent intent = new Intent((Context) this, (Class<?>) HVRetakeActivity.class);
intent.putExtra(HVRetakeActivity.IMAGE_URI_TAG, str);
intent.putExtra(HVRetakeActivity.ASPECT_RATIO_TAG, this.document.getAspectRatio());
intent.putExtra("config", this.docConfig);
intent.putExtra(HVRetakeActivity.SET_PADDING_TAG, this.docConfig.isShouldSetPadding());
intent.putExtra(HVRetakeActivity.RETRY_MESSAGE_TAG, str2);
intent.putExtra(HVRetakeActivity.EXTRA_PADDING_TAG, this.padding);
intent.putExtra(HVRetakeActivity.CALLING_ACTIVITY_TAG, HVRetakeActivity.DOC_CALLING_ACTIVITY_VALUE);
RectPortHoleView rectPortHoleView = this.documentCaptureView;
if (rectPortHoleView != null) {
intent.putExtra("viewWidth", rectPortHoleView.getWidth());
intent.putExtra("viewHeight", this.documentCaptureView.getHeight());
}
startActivityForResult(intent, 1);
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
public void startReviewScreen(String str, String str2) {
StringBuilder sb = new StringBuilder();
sb.append("startReviewScreen() called with: filePath = [");
sb.append(str);
sb.append("]");
try {
Intent intent = new Intent((Context) this, (Class<?>) HVDocReviewActivity.class);
intent.putExtra(HVRetakeActivity.IMAGE_URI_TAG, str);
if (this.docConfig.isShouldReadNIDQR() && !StringUtils.isEmptyOrNull(str2) && new File(str2).exists()) {
intent.putExtra("qrCodeCroppedImageUri", str2);
}
intent.putExtra(HVRetakeActivity.ASPECT_RATIO_TAG, this.document.getAspectRatio());
intent.putExtra(HVDocConfig.KEY, this.docConfig);
intent.putExtra(HVRetakeActivity.EXTRA_PADDING_TAG, this.padding);
RectPortHoleView rectPortHoleView = this.documentCaptureView;
if (rectPortHoleView != null) {
intent.putExtra("viewWidth", rectPortHoleView.getWidth());
intent.putExtra("viewHeight", this.documentCaptureView.getHeight());
}
intent.putExtra(CustomTextStringConst.DocCaptureTextConfigs.DOC_LOADER_DESC, TextConfigUtils.getText(this.docConfig.getCustomUIStrings(), CustomTextStringConst.DocCaptureTextConfigs.DOC_LOADER_DESC, CustomTextStringConst.DocCaptureTextConfigs.TEXT_CONFIG_DOC_LOADER_DESC, getStringFromResources(R.string.hv_doc_loader_subtitle)));
intent.putExtra("isDocCaptureFlow", this.isDocCaptureFlow);
startActivityForResult(intent, 1);
} catch (Exception e) {
Utils.getErrorMessage(e);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() && SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logDocumentReviewScreenLoadFailure(new HVError(2, Utils.getErrorMessage(e)));
}
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
public void stopCamera() {
HVMagicView hVMagicView = this.cameraView;
if (hVMagicView != null) {
hVMagicView.setSensorCallback(null);
this.cameraView.onDestroy();
this.cameraView.onPause();
}
}
@Override
public Context updateBaseContextLocale(Context context) {
return super.updateBaseContextLocale(context);
}
}