158 lines
5.1 KiB
Java
158 lines
5.1 KiB
Java
package com.kofax.kmc.kui.uicontrols;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Rect;
|
|
import android.util.AttributeSet;
|
|
import android.util.Base64;
|
|
import com.kofax.kmc.kui.uicontrols.captureanimations.CaptureMessage;
|
|
import com.kofax.kmc.kui.uicontrols.captureanimations.ILicenseOverlayView;
|
|
import com.kofax.kmc.kut.utilities.Licensing;
|
|
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
|
|
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
|
|
import com.kofax.mobile.sdk._internal.dagger.Injector;
|
|
import com.kofax.mobile.sdk._internal.impl.event.PreviewImageReadyBusEvent;
|
|
import com.manateeworks.kfx.BarcodeScanner;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
import o.InterfaceC13006fNs;
|
|
import o.InterfaceC13391fZD;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class LicenseCaptureView extends ImageCaptureView {
|
|
private static final double lW = 10.0d;
|
|
private final List<LicenseFoundListener> lX;
|
|
|
|
@InterfaceC13391fZD
|
|
ILicenseOverlayView lY;
|
|
private boolean lZ;
|
|
|
|
@Override // com.kofax.kmc.kui.uicontrols.ImageCaptureView
|
|
protected void checkLicense() {
|
|
}
|
|
|
|
public LicenseCaptureView(Context context) {
|
|
this(context, null, 0);
|
|
}
|
|
|
|
public LicenseCaptureView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public LicenseCaptureView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.lX = new CopyOnWriteArrayList();
|
|
this.lZ = false;
|
|
if (isInEditMode()) {
|
|
return;
|
|
}
|
|
aD();
|
|
this.lY.init();
|
|
addView(this.lY.getView());
|
|
setViewfinderPaddingPercent(lW);
|
|
this._bus.register(this);
|
|
}
|
|
|
|
@Override // com.kofax.kmc.kui.uicontrols.ImageCaptureView
|
|
void ai() {
|
|
Injector.getInjector(getContext()).injectMembers(this);
|
|
}
|
|
|
|
public void addLicenseFoundEventListener(LicenseFoundListener licenseFoundListener) {
|
|
if (this.lX.contains(licenseFoundListener)) {
|
|
return;
|
|
}
|
|
this.lX.add(licenseFoundListener);
|
|
}
|
|
|
|
public void removeLicenseFoundEventListener(LicenseFoundListener licenseFoundListener) {
|
|
this.lX.remove(licenseFoundListener);
|
|
}
|
|
|
|
public double getViewfinderPaddingPercent() {
|
|
return this.lY.getPaddingPercent();
|
|
}
|
|
|
|
public void setViewfinderPaddingPercent(double d) {
|
|
if (d < 0.0d || d > 50.0d) {
|
|
throw new KmcRuntimeException(ErrorInfo.KMC_UI_INVALID_PADDING_PERCENTAGE_ARGUMENT);
|
|
}
|
|
this.lY.setPaddingPercent(d);
|
|
}
|
|
|
|
public int getOuterViewFinderColor() {
|
|
return this.lY.getOuterOverlayFrameColor();
|
|
}
|
|
|
|
public void setOuterViewFinderColor(int i) {
|
|
this.lY.setOuterOverlayFrameColor(i);
|
|
}
|
|
|
|
public CaptureMessage getUserInstructionMessage() {
|
|
return this.lY.getUserInstructionMessage();
|
|
}
|
|
|
|
public void setUserInstructionMessage(CaptureMessage captureMessage) {
|
|
this.lY.setUserInstructionMessage(captureMessage);
|
|
this.lY.showUserInstructionMessage();
|
|
}
|
|
|
|
private static void aD() {
|
|
BarcodeScanner.registerCode(1, "Kofax.Android.QR.UDL", "5C44241E3E38A6E3BFBA3FB5949112DA91544173A67BFA58B622123B0C5341BC");
|
|
ak();
|
|
al();
|
|
BarcodeScanner.setLevel(2);
|
|
}
|
|
|
|
private static void ak() {
|
|
BarcodeScanner.setScanningRect(1, new Rect(0, 0, 100, 100));
|
|
BarcodeScanner.setActiveCodes(1);
|
|
}
|
|
|
|
private static void al() {
|
|
BarcodeScanner.setDirection(3);
|
|
}
|
|
|
|
private static String a(byte[] bArr, int i, int i2) {
|
|
byte[] scanGrayscaleImage = BarcodeScanner.scanGrayscaleImage(bArr, i, i2);
|
|
if (scanGrayscaleImage == null || scanGrayscaleImage.length <= 3) {
|
|
return null;
|
|
}
|
|
if (a(scanGrayscaleImage)) {
|
|
return new String(scanGrayscaleImage);
|
|
}
|
|
return Base64.encodeToString(scanGrayscaleImage, 0);
|
|
}
|
|
|
|
private static boolean a(byte[] bArr) {
|
|
for (byte b : bArr) {
|
|
if (b < 32 || b >= Byte.MAX_VALUE) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@InterfaceC13006fNs
|
|
public void onPreviewFrame(PreviewImageReadyBusEvent previewImageReadyBusEvent) {
|
|
String a;
|
|
if (this.lZ && (a = a(previewImageReadyBusEvent.imageData, previewImageReadyBusEvent.width, previewImageReadyBusEvent.height)) != null && BarcodeScanner.getLastType() == 13) {
|
|
String replace = a.replace("\\", "");
|
|
ErrorInfo mobileSDKLicense = Licensing.setMobileSDKLicense(replace);
|
|
int daysRemaining = Licensing.getDaysRemaining();
|
|
if (mobileSDKLicense != ErrorInfo.KMC_SUCCESS) {
|
|
replace = null;
|
|
}
|
|
this.lZ = false;
|
|
Iterator<LicenseFoundListener> it = this.lX.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().licenseFound(new LicenseFoundEvent(this, mobileSDKLicense, daysRemaining, replace));
|
|
}
|
|
}
|
|
}
|
|
|
|
public void readLicense() {
|
|
this.lZ = true;
|
|
}
|
|
}
|