107 lines
3.2 KiB
Java
107 lines
3.2 KiB
Java
|
package com.kofax.mobile.sdk.t;
|
||
|
|
||
|
import android.graphics.Bitmap;
|
||
|
import android.os.Environment;
|
||
|
import java.io.ByteArrayOutputStream;
|
||
|
import java.io.File;
|
||
|
import java.io.FileFilter;
|
||
|
import java.io.IOException;
|
||
|
import java.nio.charset.Charset;
|
||
|
import java.text.SimpleDateFormat;
|
||
|
import java.util.Date;
|
||
|
import java.util.Locale;
|
||
|
import o.C15173gjA;
|
||
|
import o.C15188gji;
|
||
|
import o.C15191gjl;
|
||
|
import o.gjJ;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
class d {
|
||
|
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||
|
private final File NH;
|
||
|
private String NI;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public d(String str) {
|
||
|
this(new File(Environment.getExternalStorageDirectory(), "com.kofax.mobile.sdk/ode/".concat(String.valueOf(str))));
|
||
|
}
|
||
|
|
||
|
private d(File file) {
|
||
|
this.NI = null;
|
||
|
this.NH = file;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void B(String str, String str2) {
|
||
|
e(str, str2, "txt");
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void e(String str, String str2, String str3) {
|
||
|
a(str.getBytes(UTF_8), str2, str3);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void a(Bitmap bitmap, String str) {
|
||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||
|
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
|
||
|
a(byteArrayOutputStream.toByteArray(), str, "png");
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void b(File file, String str) {
|
||
|
try {
|
||
|
C15191gjl.b(file, C(str, C15188gji.e(file.getName())));
|
||
|
} catch (IOException e) {
|
||
|
throw new RuntimeException(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void a(byte[] bArr, String str, String str2) {
|
||
|
try {
|
||
|
C15191gjl.d(C(str, str2), bArr);
|
||
|
} catch (IOException e) {
|
||
|
throw new RuntimeException(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private File C(String str, String str2) {
|
||
|
File file;
|
||
|
File file2 = this.NH;
|
||
|
if (!gjJ.b((CharSequence) this.NI)) {
|
||
|
file2 = new File(this.NH, this.NI);
|
||
|
}
|
||
|
if (!file2.exists() && !file2.mkdirs()) {
|
||
|
throw new RuntimeException(new IOException("Unable to createdirectory: ".concat(String.valueOf(file2))));
|
||
|
}
|
||
|
do {
|
||
|
file = new File(file2, String.format("%s_%s.%s", e(file2), str, str2));
|
||
|
try {
|
||
|
} catch (IOException e) {
|
||
|
throw new RuntimeException(e);
|
||
|
}
|
||
|
} while (!file.createNewFile());
|
||
|
return file;
|
||
|
}
|
||
|
|
||
|
private static String e(File file) {
|
||
|
String format = new SimpleDateFormat("yyMMdd_HHmmss", Locale.US).format(new Date());
|
||
|
int i = 1;
|
||
|
while (true) {
|
||
|
String format2 = String.format(Locale.US, "%s_%03d", format, Integer.valueOf(i));
|
||
|
if (c(file, format2).length == 0) {
|
||
|
return format2;
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static File[] c(File file, String str) {
|
||
|
return file.listFiles((FileFilter) new C15173gjA(str));
|
||
|
}
|
||
|
|
||
|
public void az(String str) {
|
||
|
this.NI = str;
|
||
|
}
|
||
|
}
|