Initial commit
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package com.google.zxing.client.android.encode;
|
||||
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class ContactEncoder {
|
||||
ContactEncoder() {
|
||||
}
|
||||
|
||||
static void a(StringBuilder sb, StringBuilder sb2, String str, String str2, Formatter formatter, char c) {
|
||||
String b = b(str2);
|
||||
if (b != null) {
|
||||
sb.append(str);
|
||||
sb.append(formatter.a(b, 0));
|
||||
sb.append(c);
|
||||
sb2.append(b);
|
||||
sb2.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
static String b(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
String trim = str.trim();
|
||||
if (trim.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return trim;
|
||||
}
|
||||
|
||||
abstract String[] a(List<String> list, String str, List<String> list2, List<String> list3, List<String> list4, List<String> list5, List<String> list6, String str2);
|
||||
|
||||
static void a(StringBuilder sb, StringBuilder sb2, String str, List<String> list, int i, Formatter formatter, Formatter formatter2, char c) {
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
HashSet hashSet = new HashSet(2);
|
||||
int i2 = 0;
|
||||
for (int i3 = 0; i3 < list.size(); i3++) {
|
||||
String b = b(list.get(i3));
|
||||
if (b != null && !b.isEmpty() && !hashSet.contains(b)) {
|
||||
sb.append(str);
|
||||
sb.append(formatter2.a(b, i3));
|
||||
sb.append(c);
|
||||
sb2.append(formatter == null ? b : formatter.a(b, i3));
|
||||
sb2.append('\n');
|
||||
i2++;
|
||||
if (i2 == i) {
|
||||
return;
|
||||
} else {
|
||||
hashSet.add(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static String a(String str) {
|
||||
return PhoneNumberUtils.formatNumber(str);
|
||||
}
|
||||
}
|
@@ -0,0 +1,185 @@
|
||||
package com.google.zxing.client.android.encode;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.client.android.FinishListener;
|
||||
import com.google.zxing.client.android.R$id;
|
||||
import com.google.zxing.client.android.R$layout;
|
||||
import com.google.zxing.client.android.R$menu;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class EncodeActivity extends Activity {
|
||||
private static final String b = EncodeActivity.class.getSimpleName();
|
||||
private static final Pattern c = Pattern.compile("[^A-Za-z0-9]");
|
||||
private QRCodeEncoder a;
|
||||
|
||||
private void a() {
|
||||
QRCodeEncoder qRCodeEncoder = this.a;
|
||||
if (qRCodeEncoder == null) {
|
||||
Log.w(b, "No existing barcode to send?");
|
||||
return;
|
||||
}
|
||||
String b2 = qRCodeEncoder.b();
|
||||
if (b2 == null) {
|
||||
Log.w(b, "No existing barcode to send?");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Bitmap a = qRCodeEncoder.a();
|
||||
if (a == null) {
|
||||
return;
|
||||
}
|
||||
File file = new File(new File(Environment.getExternalStorageDirectory(), "BarcodeScanner"), "Barcodes");
|
||||
if (!file.exists() && !file.mkdirs()) {
|
||||
Log.w(b, "Couldn't make dir " + file);
|
||||
a(R$string.msg_unmount_usb);
|
||||
return;
|
||||
}
|
||||
File file2 = new File(file, ((Object) a(b2)) + ".png");
|
||||
if (!file2.delete()) {
|
||||
Log.w(b, "Could not delete " + file2);
|
||||
}
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file2);
|
||||
try {
|
||||
a.compress(Bitmap.CompressFormat.PNG, 0, fileOutputStream);
|
||||
fileOutputStream.close();
|
||||
Intent intent = new Intent("android.intent.action.SEND", Uri.parse("mailto:"));
|
||||
intent.putExtra("android.intent.extra.SUBJECT", getString(R$string.scan_name) + " - " + qRCodeEncoder.d());
|
||||
intent.putExtra("android.intent.extra.TEXT", b2);
|
||||
intent.putExtra("android.intent.extra.STREAM", Uri.parse("file://" + file2.getAbsolutePath()));
|
||||
intent.setType("image/png");
|
||||
intent.addFlags(524288);
|
||||
startActivity(Intent.createChooser(intent, null));
|
||||
} finally {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.w(b, "Couldn't access file " + file2 + " due to " + e);
|
||||
a(R$string.msg_unmount_usb);
|
||||
}
|
||||
} catch (WriterException e2) {
|
||||
Log.w(b, e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
String action = intent.getAction();
|
||||
if ("com.google.zxing.client.android.ENCODE".equals(action) || "android.intent.action.SEND".equals(action)) {
|
||||
setContentView(R$layout.encode);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R$menu.encode, menu);
|
||||
QRCodeEncoder qRCodeEncoder = this.a;
|
||||
int i = qRCodeEncoder != null && qRCodeEncoder.e() ? R$string.menu_encode_mecard : R$string.menu_encode_vcard;
|
||||
MenuItem findItem = menu.findItem(R$id.menu_encode);
|
||||
findItem.setTitle(i);
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
findItem.setVisible("CONTACT_TYPE".equals(intent.getStringExtra("ENCODE_TYPE")));
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||
Intent intent;
|
||||
int itemId = menuItem.getItemId();
|
||||
if (itemId == R$id.menu_share) {
|
||||
a();
|
||||
return true;
|
||||
}
|
||||
if (itemId != R$id.menu_encode || (intent = getIntent()) == null) {
|
||||
return false;
|
||||
}
|
||||
intent.putExtra("USE_VCARD", !this.a.e());
|
||||
intent.addFlags(67108864);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Display defaultDisplay = ((WindowManager) getSystemService("window")).getDefaultDisplay();
|
||||
Point point = new Point();
|
||||
defaultDisplay.getSize(point);
|
||||
int i = point.x;
|
||||
int i2 = point.y;
|
||||
if (i >= i2) {
|
||||
i = i2;
|
||||
}
|
||||
int i3 = (i * 7) / 8;
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.a = new QRCodeEncoder(this, intent, i3, intent.getBooleanExtra("USE_VCARD", false));
|
||||
Bitmap a = this.a.a();
|
||||
if (a == null) {
|
||||
Log.w(b, "Could not encode barcode");
|
||||
a(R$string.msg_encode_contents_failed);
|
||||
this.a = null;
|
||||
return;
|
||||
}
|
||||
((ImageView) findViewById(R$id.image_view)).setImageBitmap(a);
|
||||
TextView textView = (TextView) findViewById(R$id.contents_text_view);
|
||||
if (intent.getBooleanExtra("ENCODE_SHOW_CONTENTS", true)) {
|
||||
textView.setText(this.a.c());
|
||||
setTitle(this.a.d());
|
||||
} else {
|
||||
textView.setText("");
|
||||
setTitle("");
|
||||
}
|
||||
} catch (WriterException e) {
|
||||
Log.w(b, "Could not encode barcode", e);
|
||||
a(R$string.msg_encode_contents_failed);
|
||||
this.a = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static CharSequence a(CharSequence charSequence) {
|
||||
String replaceAll = c.matcher(charSequence).replaceAll("_");
|
||||
return replaceAll.length() > 24 ? replaceAll.substring(0, 24) : replaceAll;
|
||||
}
|
||||
|
||||
private void a(int i) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(i);
|
||||
builder.setPositiveButton(R$string.button_ok, new FinishListener(this));
|
||||
builder.setOnCancelListener(new FinishListener(this));
|
||||
builder.show();
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.google.zxing.client.android.encode;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface Formatter {
|
||||
CharSequence a(CharSequence charSequence, int i);
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
package com.google.zxing.client.android.encode;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class MECARDContactEncoder extends ContactEncoder {
|
||||
|
||||
private static final class MECARDFieldFormatter implements Formatter {
|
||||
private static final Pattern a = Pattern.compile("([\\\\:;])");
|
||||
private static final Pattern b = Pattern.compile("\\n");
|
||||
|
||||
private MECARDFieldFormatter() {
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.encode.Formatter
|
||||
public CharSequence a(CharSequence charSequence, int i) {
|
||||
return ':' + b.matcher(a.matcher(charSequence).replaceAll("\\\\$1")).replaceAll("");
|
||||
}
|
||||
}
|
||||
|
||||
private static final class MECARDNameDisplayFormatter implements Formatter {
|
||||
private static final Pattern a = Pattern.compile(",");
|
||||
|
||||
private MECARDNameDisplayFormatter() {
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.encode.Formatter
|
||||
public CharSequence a(CharSequence charSequence, int i) {
|
||||
return a.matcher(charSequence).replaceAll("");
|
||||
}
|
||||
}
|
||||
|
||||
private static final class MECARDTelDisplayFormatter implements Formatter {
|
||||
private static final Pattern a = Pattern.compile("[^0-9+]+");
|
||||
|
||||
private MECARDTelDisplayFormatter() {
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.encode.Formatter
|
||||
public CharSequence a(CharSequence charSequence, int i) {
|
||||
return a.matcher(ContactEncoder.a(charSequence.toString())).replaceAll("");
|
||||
}
|
||||
}
|
||||
|
||||
MECARDContactEncoder() {
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.encode.ContactEncoder
|
||||
public String[] a(List<String> list, String str, List<String> list2, List<String> list3, List<String> list4, List<String> list5, List<String> list6, String str2) {
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
sb.append("MECARD:");
|
||||
StringBuilder sb2 = new StringBuilder(100);
|
||||
MECARDFieldFormatter mECARDFieldFormatter = new MECARDFieldFormatter();
|
||||
ContactEncoder.a(sb, sb2, "N", list, 1, (Formatter) new MECARDNameDisplayFormatter(), (Formatter) mECARDFieldFormatter, ';');
|
||||
ContactEncoder.a(sb, sb2, "ORG", str, mECARDFieldFormatter, ';');
|
||||
ContactEncoder.a(sb, sb2, "ADR", list2, 1, (Formatter) null, (Formatter) mECARDFieldFormatter, ';');
|
||||
ContactEncoder.a(sb, sb2, "TEL", list3, Integer.MAX_VALUE, (Formatter) new MECARDTelDisplayFormatter(), (Formatter) mECARDFieldFormatter, ';');
|
||||
ContactEncoder.a(sb, sb2, "EMAIL", list5, Integer.MAX_VALUE, (Formatter) null, (Formatter) mECARDFieldFormatter, ';');
|
||||
ContactEncoder.a(sb, sb2, "URL", list6, Integer.MAX_VALUE, (Formatter) null, (Formatter) mECARDFieldFormatter, ';');
|
||||
ContactEncoder.a(sb, sb2, "NOTE", str2, mECARDFieldFormatter, ';');
|
||||
sb.append(';');
|
||||
return new String[]{sb.toString(), sb2.toString()};
|
||||
}
|
||||
}
|
@@ -0,0 +1,406 @@
|
||||
package com.google.zxing.client.android.encode;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.client.android.Contents;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.AddressBookParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.ResultParser;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class QRCodeEncoder {
|
||||
private static final String h = "QRCodeEncoder";
|
||||
private final Context a;
|
||||
private String b;
|
||||
private String c;
|
||||
private String d;
|
||||
private BarcodeFormat e;
|
||||
private final int f;
|
||||
private final boolean g;
|
||||
|
||||
QRCodeEncoder(Context context, Intent intent, int i, boolean z) throws WriterException {
|
||||
this.a = context;
|
||||
this.f = i;
|
||||
this.g = z;
|
||||
String action = intent.getAction();
|
||||
if ("com.google.zxing.client.android.ENCODE".equals(action)) {
|
||||
b(intent);
|
||||
} else if ("android.intent.action.SEND".equals(action)) {
|
||||
a(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(Intent intent) throws WriterException {
|
||||
if (intent.hasExtra("android.intent.extra.STREAM")) {
|
||||
c(intent);
|
||||
} else {
|
||||
d(intent);
|
||||
}
|
||||
}
|
||||
|
||||
String b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
String c() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
String d() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
boolean e() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
private void b(Intent intent) {
|
||||
String stringExtra = intent.getStringExtra("ENCODE_FORMAT");
|
||||
this.e = null;
|
||||
if (stringExtra != null) {
|
||||
try {
|
||||
this.e = BarcodeFormat.valueOf(stringExtra);
|
||||
} catch (IllegalArgumentException unused) {
|
||||
}
|
||||
}
|
||||
BarcodeFormat barcodeFormat = this.e;
|
||||
if (barcodeFormat == null || barcodeFormat == BarcodeFormat.QR_CODE) {
|
||||
String stringExtra2 = intent.getStringExtra("ENCODE_TYPE");
|
||||
if (stringExtra2 == null || stringExtra2.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
this.e = BarcodeFormat.QR_CODE;
|
||||
a(intent, stringExtra2);
|
||||
return;
|
||||
}
|
||||
String stringExtra3 = intent.getStringExtra("ENCODE_DATA");
|
||||
if (stringExtra3 == null || stringExtra3.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
this.b = stringExtra3;
|
||||
this.c = stringExtra3;
|
||||
this.d = this.a.getString(R$string.contents_text);
|
||||
}
|
||||
|
||||
private void c(Intent intent) throws WriterException {
|
||||
this.e = BarcodeFormat.QR_CODE;
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras == null) {
|
||||
throw new WriterException("No extras");
|
||||
}
|
||||
Uri uri = (Uri) extras.getParcelable("android.intent.extra.STREAM");
|
||||
if (uri == null) {
|
||||
throw new WriterException("No EXTRA_STREAM");
|
||||
}
|
||||
ByteArrayOutputStream byteArrayOutputStream = null;
|
||||
try {
|
||||
try {
|
||||
InputStream openInputStream = this.a.getContentResolver().openInputStream(uri);
|
||||
try {
|
||||
if (openInputStream == null) {
|
||||
throw new WriterException("Can't open stream for " + uri);
|
||||
}
|
||||
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
|
||||
try {
|
||||
byte[] bArr = new byte[2048];
|
||||
while (true) {
|
||||
int read = openInputStream.read(bArr);
|
||||
if (read <= 0) {
|
||||
break;
|
||||
} else {
|
||||
byteArrayOutputStream2.write(bArr, 0, read);
|
||||
}
|
||||
}
|
||||
byte[] byteArray = byteArrayOutputStream2.toByteArray();
|
||||
String str = new String(byteArray, 0, byteArray.length, StandardCharsets.UTF_8);
|
||||
if (openInputStream != null) {
|
||||
try {
|
||||
openInputStream.close();
|
||||
} catch (IOException e) {
|
||||
e = e;
|
||||
throw new WriterException(e);
|
||||
} catch (Throwable th) {
|
||||
byteArrayOutputStream = byteArrayOutputStream2;
|
||||
th = th;
|
||||
if (byteArrayOutputStream != null) {
|
||||
try {
|
||||
byteArrayOutputStream.close();
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
try {
|
||||
byteArrayOutputStream2.close();
|
||||
} catch (IOException e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
Log.d(h, "Encoding share intent content:");
|
||||
Log.d(h, str);
|
||||
ParsedResult c = ResultParser.c(new Result(str, byteArray, null, BarcodeFormat.QR_CODE));
|
||||
if (!(c instanceof AddressBookParsedResult)) {
|
||||
throw new WriterException("Result was not an address");
|
||||
}
|
||||
a((AddressBookParsedResult) c);
|
||||
String str2 = this.b;
|
||||
if (str2 == null || str2.isEmpty()) {
|
||||
throw new WriterException("No content to encode");
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
try {
|
||||
throw th;
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
} catch (Throwable th3) {
|
||||
th = th3;
|
||||
}
|
||||
} catch (IOException e4) {
|
||||
e = e4;
|
||||
}
|
||||
} catch (Throwable th4) {
|
||||
th = th4;
|
||||
}
|
||||
}
|
||||
|
||||
private void d(Intent intent) throws WriterException {
|
||||
String b = ContactEncoder.b(intent.getStringExtra("android.intent.extra.TEXT"));
|
||||
if (b == null && (b = ContactEncoder.b(intent.getStringExtra("android.intent.extra.HTML_TEXT"))) == null && (b = ContactEncoder.b(intent.getStringExtra("android.intent.extra.SUBJECT"))) == null) {
|
||||
String[] stringArrayExtra = intent.getStringArrayExtra("android.intent.extra.EMAIL");
|
||||
b = stringArrayExtra != null ? ContactEncoder.b(stringArrayExtra[0]) : "?";
|
||||
}
|
||||
if (b == null || b.isEmpty()) {
|
||||
throw new WriterException("Empty EXTRA_TEXT");
|
||||
}
|
||||
this.b = b;
|
||||
this.e = BarcodeFormat.QR_CODE;
|
||||
if (intent.hasExtra("android.intent.extra.SUBJECT")) {
|
||||
this.c = intent.getStringExtra("android.intent.extra.SUBJECT");
|
||||
} else if (intent.hasExtra("android.intent.extra.TITLE")) {
|
||||
this.c = intent.getStringExtra("android.intent.extra.TITLE");
|
||||
} else {
|
||||
this.c = this.b;
|
||||
}
|
||||
this.d = this.a.getString(R$string.contents_text);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
||||
private void a(Intent intent, String str) {
|
||||
char c;
|
||||
Bundle bundleExtra;
|
||||
switch (str.hashCode()) {
|
||||
case -1309271157:
|
||||
if (str.equals("PHONE_TYPE")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case -670199783:
|
||||
if (str.equals("CONTACT_TYPE")) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 709220992:
|
||||
if (str.equals("SMS_TYPE")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1349204356:
|
||||
if (str.equals("LOCATION_TYPE")) {
|
||||
c = 5;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1778595596:
|
||||
if (str.equals("TEXT_TYPE")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1833351709:
|
||||
if (str.equals("EMAIL_TYPE")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
default:
|
||||
c = 65535;
|
||||
break;
|
||||
}
|
||||
if (c == 0) {
|
||||
String stringExtra = intent.getStringExtra("ENCODE_DATA");
|
||||
if (stringExtra == null || stringExtra.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
this.b = stringExtra;
|
||||
this.c = stringExtra;
|
||||
this.d = this.a.getString(R$string.contents_text);
|
||||
return;
|
||||
}
|
||||
if (c == 1) {
|
||||
String b = ContactEncoder.b(intent.getStringExtra("ENCODE_DATA"));
|
||||
if (b != null) {
|
||||
this.b = "mailto:" + b;
|
||||
this.c = b;
|
||||
this.d = this.a.getString(R$string.contents_email);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (c == 2) {
|
||||
String b2 = ContactEncoder.b(intent.getStringExtra("ENCODE_DATA"));
|
||||
if (b2 != null) {
|
||||
this.b = "tel:" + b2;
|
||||
this.c = ContactEncoder.a(b2);
|
||||
this.d = this.a.getString(R$string.contents_phone);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (c == 3) {
|
||||
String b3 = ContactEncoder.b(intent.getStringExtra("ENCODE_DATA"));
|
||||
if (b3 != null) {
|
||||
this.b = "sms:" + b3;
|
||||
this.c = ContactEncoder.a(b3);
|
||||
this.d = this.a.getString(R$string.contents_sms);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (c == 4) {
|
||||
Bundle bundleExtra2 = intent.getBundleExtra("ENCODE_DATA");
|
||||
if (bundleExtra2 != null) {
|
||||
String string = bundleExtra2.getString(MediationMetaData.KEY_NAME);
|
||||
String string2 = bundleExtra2.getString("company");
|
||||
String string3 = bundleExtra2.getString("postal");
|
||||
List<String> a = a(bundleExtra2, Contents.a);
|
||||
List<String> a2 = a(bundleExtra2, Contents.b);
|
||||
List<String> a3 = a(bundleExtra2, Contents.c);
|
||||
String string4 = bundleExtra2.getString("URL_KEY");
|
||||
String[] a4 = (this.g ? new VCardContactEncoder() : new MECARDContactEncoder()).a(Collections.singletonList(string), string2, Collections.singletonList(string3), a, a2, a3, string4 == null ? null : Collections.singletonList(string4), bundleExtra2.getString("NOTE_KEY"));
|
||||
if (a4[1].isEmpty()) {
|
||||
return;
|
||||
}
|
||||
this.b = a4[0];
|
||||
this.c = a4[1];
|
||||
this.d = this.a.getString(R$string.contents_contact);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (c == 5 && (bundleExtra = intent.getBundleExtra("ENCODE_DATA")) != null) {
|
||||
float f = bundleExtra.getFloat("LAT", Float.MAX_VALUE);
|
||||
float f2 = bundleExtra.getFloat("LONG", Float.MAX_VALUE);
|
||||
if (f == Float.MAX_VALUE || f2 == Float.MAX_VALUE) {
|
||||
return;
|
||||
}
|
||||
this.b = "geo:" + f + ',' + f2;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(f);
|
||||
sb.append(",");
|
||||
sb.append(f2);
|
||||
this.c = sb.toString();
|
||||
this.d = this.a.getString(R$string.contents_location);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> a(Bundle bundle, String[] strArr) {
|
||||
ArrayList arrayList = new ArrayList(strArr.length);
|
||||
for (String str : strArr) {
|
||||
Object obj = bundle.get(str);
|
||||
arrayList.add(obj == null ? null : obj.toString());
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private void a(AddressBookParsedResult addressBookParsedResult) {
|
||||
String[] a = (this.g ? new VCardContactEncoder() : new MECARDContactEncoder()).a(a(addressBookParsedResult.j()), addressBookParsedResult.m(), a(addressBookParsedResult.d()), a(addressBookParsedResult.n()), (List<String>) null, a(addressBookParsedResult.g()), a(addressBookParsedResult.r()), (String) null);
|
||||
if (a[1].isEmpty()) {
|
||||
return;
|
||||
}
|
||||
this.b = a[0];
|
||||
this.c = a[1];
|
||||
this.d = this.a.getString(R$string.contents_contact);
|
||||
}
|
||||
|
||||
private static List<String> a(String[] strArr) {
|
||||
if (strArr == null) {
|
||||
return null;
|
||||
}
|
||||
return Arrays.asList(strArr);
|
||||
}
|
||||
|
||||
Bitmap a() throws WriterException {
|
||||
EnumMap enumMap;
|
||||
String str = this.b;
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
String a = a(str);
|
||||
if (a != null) {
|
||||
EnumMap enumMap2 = new EnumMap(EncodeHintType.class);
|
||||
enumMap2.put((EnumMap) EncodeHintType.CHARACTER_SET, (EncodeHintType) a);
|
||||
enumMap = enumMap2;
|
||||
} else {
|
||||
enumMap = null;
|
||||
}
|
||||
try {
|
||||
BitMatrix a2 = new MultiFormatWriter().a(str, this.e, this.f, this.f, enumMap);
|
||||
int k = a2.k();
|
||||
int i = a2.i();
|
||||
int[] iArr = new int[k * i];
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
int i3 = i2 * k;
|
||||
for (int i4 = 0; i4 < k; i4++) {
|
||||
iArr[i3 + i4] = a2.b(i4, i2) ? -16777216 : -1;
|
||||
}
|
||||
}
|
||||
Bitmap createBitmap = Bitmap.createBitmap(k, i, Bitmap.Config.ARGB_8888);
|
||||
createBitmap.setPixels(iArr, 0, k, 0, 0, k, i);
|
||||
return createBitmap;
|
||||
} catch (IllegalArgumentException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String a(CharSequence charSequence) {
|
||||
for (int i = 0; i < charSequence.length(); i++) {
|
||||
if (charSequence.charAt(i) > 255) {
|
||||
return "UTF-8";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
package com.google.zxing.client.android.encode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class VCardContactEncoder extends ContactEncoder {
|
||||
VCardContactEncoder() {
|
||||
}
|
||||
|
||||
private static String a(int i) {
|
||||
if (i == 10 || i == 17 || i == 18) {
|
||||
return "work";
|
||||
}
|
||||
switch (i) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 5:
|
||||
case 6:
|
||||
return "home";
|
||||
case 3:
|
||||
case 4:
|
||||
return "work";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String b(int i) {
|
||||
if (i == 4 || i == 5) {
|
||||
return "fax";
|
||||
}
|
||||
if (i == 6) {
|
||||
return "pager";
|
||||
}
|
||||
if (i == 13) {
|
||||
return "fax";
|
||||
}
|
||||
if (i == 16) {
|
||||
return "textphone";
|
||||
}
|
||||
if (i == 18) {
|
||||
return "pager";
|
||||
}
|
||||
if (i != 20) {
|
||||
return null;
|
||||
}
|
||||
return "text";
|
||||
}
|
||||
|
||||
private static Integer c(String str) {
|
||||
try {
|
||||
return Integer.valueOf(str);
|
||||
} catch (NumberFormatException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.encode.ContactEncoder
|
||||
public String[] a(List<String> list, String str, List<String> list2, List<String> list3, List<String> list4, List<String> list5, List<String> list6, String str2) {
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
sb.append("BEGIN:VCARD");
|
||||
sb.append('\n');
|
||||
sb.append("VERSION:3.0");
|
||||
sb.append('\n');
|
||||
StringBuilder sb2 = new StringBuilder(100);
|
||||
VCardFieldFormatter vCardFieldFormatter = new VCardFieldFormatter();
|
||||
ContactEncoder.a(sb, sb2, "N", list, 1, (Formatter) null, (Formatter) vCardFieldFormatter, '\n');
|
||||
ContactEncoder.a(sb, sb2, "ORG", str, vCardFieldFormatter, '\n');
|
||||
ContactEncoder.a(sb, sb2, "ADR", list2, 1, (Formatter) null, (Formatter) vCardFieldFormatter, '\n');
|
||||
List<Map<String, Set<String>>> a = a(list3, list4);
|
||||
ContactEncoder.a(sb, sb2, "TEL", list3, Integer.MAX_VALUE, (Formatter) new VCardTelDisplayFormatter(a), (Formatter) new VCardFieldFormatter(a), '\n');
|
||||
ContactEncoder.a(sb, sb2, "EMAIL", list5, Integer.MAX_VALUE, (Formatter) null, (Formatter) vCardFieldFormatter, '\n');
|
||||
ContactEncoder.a(sb, sb2, "URL", list6, Integer.MAX_VALUE, (Formatter) null, (Formatter) vCardFieldFormatter, '\n');
|
||||
ContactEncoder.a(sb, sb2, "NOTE", str2, vCardFieldFormatter, '\n');
|
||||
sb.append("END:VCARD");
|
||||
sb.append('\n');
|
||||
return new String[]{sb.toString(), sb2.toString()};
|
||||
}
|
||||
|
||||
private static List<Map<String, Set<String>>> a(Collection<String> collection, List<String> list) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (int i = 0; i < collection.size(); i++) {
|
||||
if (list.size() <= i) {
|
||||
arrayList.add(null);
|
||||
} else {
|
||||
HashMap hashMap = new HashMap();
|
||||
arrayList.add(hashMap);
|
||||
HashSet hashSet = new HashSet();
|
||||
hashMap.put("TYPE", hashSet);
|
||||
String str = list.get(i);
|
||||
Integer c = c(str);
|
||||
if (c == null) {
|
||||
hashSet.add(str);
|
||||
} else {
|
||||
String b = b(c.intValue());
|
||||
String a = a(c.intValue());
|
||||
if (b != null) {
|
||||
hashSet.add(b);
|
||||
}
|
||||
if (a != null) {
|
||||
hashSet.add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package com.google.zxing.client.android.encode;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class VCardFieldFormatter implements Formatter {
|
||||
private static final Pattern b = Pattern.compile("([\\\\,;])");
|
||||
private static final Pattern c = Pattern.compile("\\n");
|
||||
private final List<Map<String, Set<String>>> a;
|
||||
|
||||
VCardFieldFormatter() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.encode.Formatter
|
||||
public CharSequence a(CharSequence charSequence, int i) {
|
||||
String replaceAll = c.matcher(b.matcher(charSequence).replaceAll("\\\\$1")).replaceAll("");
|
||||
List<Map<String, Set<String>>> list = this.a;
|
||||
return a(replaceAll, (list == null || list.size() <= i) ? null : this.a.get(i));
|
||||
}
|
||||
|
||||
VCardFieldFormatter(List<Map<String, Set<String>>> list) {
|
||||
this.a = list;
|
||||
}
|
||||
|
||||
private static CharSequence a(CharSequence charSequence, Map<String, Set<String>> map) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (map != null) {
|
||||
for (Map.Entry<String, Set<String>> entry : map.entrySet()) {
|
||||
Set<String> value = entry.getValue();
|
||||
if (value != null && !value.isEmpty()) {
|
||||
sb.append(';');
|
||||
sb.append(entry.getKey());
|
||||
sb.append('=');
|
||||
if (value.size() > 1) {
|
||||
sb.append('\"');
|
||||
}
|
||||
Iterator<String> it = value.iterator();
|
||||
sb.append(it.next());
|
||||
while (it.hasNext()) {
|
||||
sb.append(',');
|
||||
sb.append(it.next());
|
||||
}
|
||||
if (value.size() > 1) {
|
||||
sb.append('\"');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append(':');
|
||||
sb.append(charSequence);
|
||||
return sb;
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package com.google.zxing.client.android.encode;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class VCardTelDisplayFormatter implements Formatter {
|
||||
private final List<Map<String, Set<String>>> a;
|
||||
|
||||
VCardTelDisplayFormatter(List<Map<String, Set<String>>> list) {
|
||||
this.a = list;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.encode.Formatter
|
||||
public CharSequence a(CharSequence charSequence, int i) {
|
||||
String a = ContactEncoder.a(charSequence.toString());
|
||||
List<Map<String, Set<String>>> list = this.a;
|
||||
return a(a, (list == null || list.size() <= i) ? null : this.a.get(i));
|
||||
}
|
||||
|
||||
private static CharSequence a(CharSequence charSequence, Map<String, Set<String>> map) {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return charSequence;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<Map.Entry<String, Set<String>>> it = map.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Set<String> value = it.next().getValue();
|
||||
if (value != null && !value.isEmpty()) {
|
||||
Iterator<String> it2 = value.iterator();
|
||||
sb.append(it2.next());
|
||||
while (it2.hasNext()) {
|
||||
sb.append(',');
|
||||
sb.append(it2.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append(charSequence);
|
||||
return sb;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user