Initial commit
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.StyleSpan;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.AddressBookParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class AddressBookResultHandler extends ResultHandler {
|
||||
private static final DateFormat[] n = {new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH), new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH), new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH), new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)};
|
||||
private static final int[] o;
|
||||
private final boolean[] l;
|
||||
private int m;
|
||||
|
||||
static {
|
||||
for (DateFormat dateFormat : n) {
|
||||
dateFormat.setLenient(false);
|
||||
}
|
||||
o = new int[]{R$string.button_add_contact, R$string.button_show_map, R$string.button_dial, R$string.button_email};
|
||||
}
|
||||
|
||||
public AddressBookResultHandler(Activity activity, ParsedResult parsedResult) {
|
||||
super(activity, parsedResult);
|
||||
AddressBookParsedResult addressBookParsedResult = (AddressBookParsedResult) parsedResult;
|
||||
String[] d = addressBookParsedResult.d();
|
||||
String[] n2 = addressBookParsedResult.n();
|
||||
String[] g = addressBookParsedResult.g();
|
||||
this.l = new boolean[4];
|
||||
boolean[] zArr = this.l;
|
||||
zArr[0] = true;
|
||||
zArr[1] = (d == null || d.length <= 0 || d[0] == null || d[0].isEmpty()) ? false : true;
|
||||
this.l[2] = n2 != null && n2.length > 0;
|
||||
this.l[3] = g != null && g.length > 0;
|
||||
this.m = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (this.l[i]) {
|
||||
this.m++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int c(int i) {
|
||||
if (i < this.m) {
|
||||
int i2 = -1;
|
||||
for (int i3 = 0; i3 < 4; i3++) {
|
||||
if (this.l[i3]) {
|
||||
i2++;
|
||||
}
|
||||
if (i2 == i) {
|
||||
return i3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static long n(String str) {
|
||||
DateFormat[] dateFormatArr = n;
|
||||
for (int i = 0; i < dateFormatArr.length; i++) {
|
||||
try {
|
||||
return dateFormatArr[i].parse(str).getTime();
|
||||
} catch (ParseException unused) {
|
||||
}
|
||||
}
|
||||
return -1L;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return o[c(i)];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
AddressBookParsedResult addressBookParsedResult = (AddressBookParsedResult) g();
|
||||
String[] d = addressBookParsedResult.d();
|
||||
String str = (d == null || d.length < 1) ? null : d[0];
|
||||
String[] c = addressBookParsedResult.c();
|
||||
String str2 = (c == null || c.length < 1) ? null : c[0];
|
||||
int c2 = c(i);
|
||||
if (c2 == 0) {
|
||||
a(addressBookParsedResult.j(), addressBookParsedResult.k(), addressBookParsedResult.p(), addressBookParsedResult.n(), addressBookParsedResult.o(), addressBookParsedResult.g(), addressBookParsedResult.f(), addressBookParsedResult.l(), addressBookParsedResult.i(), str, str2, addressBookParsedResult.m(), addressBookParsedResult.q(), addressBookParsedResult.r(), addressBookParsedResult.e(), addressBookParsedResult.h());
|
||||
return;
|
||||
}
|
||||
if (c2 == 1) {
|
||||
i(str);
|
||||
} else if (c2 == 2) {
|
||||
a(addressBookParsedResult.n()[0]);
|
||||
} else {
|
||||
if (c2 != 3) {
|
||||
return;
|
||||
}
|
||||
a(addressBookParsedResult.g(), null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public CharSequence e() {
|
||||
AddressBookParsedResult addressBookParsedResult = (AddressBookParsedResult) g();
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
ParsedResult.a(addressBookParsedResult.j(), sb);
|
||||
int length = sb.length();
|
||||
String p = addressBookParsedResult.p();
|
||||
if (p != null && !p.isEmpty()) {
|
||||
sb.append("\n(");
|
||||
sb.append(p);
|
||||
sb.append(')');
|
||||
}
|
||||
ParsedResult.a(addressBookParsedResult.q(), sb);
|
||||
ParsedResult.a(addressBookParsedResult.m(), sb);
|
||||
ParsedResult.a(addressBookParsedResult.d(), sb);
|
||||
String[] n2 = addressBookParsedResult.n();
|
||||
if (n2 != null) {
|
||||
for (String str : n2) {
|
||||
if (str != null) {
|
||||
ParsedResult.a(ResultHandler.m(str), sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
ParsedResult.a(addressBookParsedResult.g(), sb);
|
||||
ParsedResult.a(addressBookParsedResult.r(), sb);
|
||||
String e = addressBookParsedResult.e();
|
||||
if (e != null && !e.isEmpty()) {
|
||||
long n3 = n(e);
|
||||
if (n3 >= 0) {
|
||||
ParsedResult.a(DateFormat.getDateInstance(2).format(Long.valueOf(n3)), sb);
|
||||
}
|
||||
}
|
||||
ParsedResult.a(addressBookParsedResult.l(), sb);
|
||||
if (length <= 0) {
|
||||
return sb.toString();
|
||||
}
|
||||
SpannableString spannableString = new SpannableString(sb.toString());
|
||||
spannableString.setSpan(new StyleSpan(1), 0, length, 0);
|
||||
return spannableString;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_address_book;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return this.m;
|
||||
}
|
||||
}
|
@@ -0,0 +1,118 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.CalendarParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import java.text.DateFormat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class CalendarResultHandler extends ResultHandler {
|
||||
private static final String l = "CalendarResultHandler";
|
||||
private static final int[] m = {R$string.button_add_calendar};
|
||||
|
||||
public CalendarResultHandler(Activity activity, ParsedResult parsedResult) {
|
||||
super(activity, parsedResult);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return m[i];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
String str;
|
||||
if (i == 0) {
|
||||
CalendarParsedResult calendarParsedResult = (CalendarParsedResult) g();
|
||||
String d = calendarParsedResult.d();
|
||||
String g = calendarParsedResult.g();
|
||||
if (g != null) {
|
||||
if (d == null) {
|
||||
str = g;
|
||||
a(calendarParsedResult.i(), calendarParsedResult.h(), calendarParsedResult.k(), calendarParsedResult.e(), calendarParsedResult.f(), str, calendarParsedResult.c());
|
||||
} else {
|
||||
d = d + '\n' + g;
|
||||
}
|
||||
}
|
||||
str = d;
|
||||
a(calendarParsedResult.i(), calendarParsedResult.h(), calendarParsedResult.k(), calendarParsedResult.e(), calendarParsedResult.f(), str, calendarParsedResult.c());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return m.length;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public CharSequence e() {
|
||||
CalendarParsedResult calendarParsedResult = (CalendarParsedResult) g();
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
ParsedResult.a(calendarParsedResult.i(), sb);
|
||||
long h = calendarParsedResult.h();
|
||||
ParsedResult.a(a(calendarParsedResult.k(), h), sb);
|
||||
long e = calendarParsedResult.e();
|
||||
if (e >= 0) {
|
||||
if (calendarParsedResult.j() && h != e) {
|
||||
e -= 86400000;
|
||||
}
|
||||
ParsedResult.a(a(calendarParsedResult.j(), e), sb);
|
||||
}
|
||||
ParsedResult.a(calendarParsedResult.f(), sb);
|
||||
ParsedResult.a(calendarParsedResult.g(), sb);
|
||||
ParsedResult.a(calendarParsedResult.c(), sb);
|
||||
ParsedResult.a(calendarParsedResult.d(), sb);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_calendar;
|
||||
}
|
||||
|
||||
private void a(String str, long j, boolean z, long j2, String str2, String str3, String[] strArr) {
|
||||
Intent intent = new Intent("android.intent.action.INSERT");
|
||||
intent.setType("vnd.android.cursor.item/event");
|
||||
intent.putExtra("beginTime", j);
|
||||
if (z) {
|
||||
intent.putExtra("allDay", true);
|
||||
}
|
||||
if (j2 >= 0) {
|
||||
j = j2;
|
||||
} else if (z) {
|
||||
j += 86400000;
|
||||
}
|
||||
intent.putExtra("endTime", j);
|
||||
intent.putExtra("title", str);
|
||||
intent.putExtra("eventLocation", str2);
|
||||
intent.putExtra(SocialConstants.PARAM_COMMENT, str3);
|
||||
if (strArr != null) {
|
||||
intent.putExtra("android.intent.extra.EMAIL", strArr);
|
||||
}
|
||||
try {
|
||||
b(intent);
|
||||
} catch (ActivityNotFoundException unused) {
|
||||
Log.w(l, "No calendar app available that responds to android.intent.action.INSERT");
|
||||
intent.setAction("android.intent.action.EDIT");
|
||||
a(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private static String a(boolean z, long j) {
|
||||
DateFormat dateTimeInstance;
|
||||
if (j < 0) {
|
||||
return null;
|
||||
}
|
||||
if (z) {
|
||||
dateTimeInstance = DateFormat.getDateInstance(2);
|
||||
} else {
|
||||
dateTimeInstance = DateFormat.getDateTimeInstance(2, 2);
|
||||
}
|
||||
return dateTimeInstance.format(Long.valueOf(j));
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.EmailAddressParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class EmailAddressResultHandler extends ResultHandler {
|
||||
private static final int[] l = {R$string.button_email, R$string.button_add_contact};
|
||||
|
||||
public EmailAddressResultHandler(Activity activity, ParsedResult parsedResult) {
|
||||
super(activity, parsedResult);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return l[i];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
EmailAddressParsedResult emailAddressParsedResult = (EmailAddressParsedResult) g();
|
||||
if (i == 0) {
|
||||
a(emailAddressParsedResult.g(), emailAddressParsedResult.e(), emailAddressParsedResult.c(), emailAddressParsedResult.f(), emailAddressParsedResult.d());
|
||||
} else {
|
||||
if (i != 1) {
|
||||
return;
|
||||
}
|
||||
a(emailAddressParsedResult.g(), (String[]) null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return l.length;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_email_address;
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.GeoParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class GeoResultHandler extends ResultHandler {
|
||||
private static final int[] l = {R$string.button_show_map, R$string.button_get_directions};
|
||||
|
||||
public GeoResultHandler(Activity activity, ParsedResult parsedResult) {
|
||||
super(activity, parsedResult);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return l[i];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
GeoParsedResult geoParsedResult = (GeoParsedResult) g();
|
||||
if (i == 0) {
|
||||
e(geoParsedResult.c());
|
||||
} else {
|
||||
if (i != 1) {
|
||||
return;
|
||||
}
|
||||
a(geoParsedResult.d(), geoParsedResult.e());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return l.length;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_geo;
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.ISBNParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ISBNResultHandler extends ResultHandler {
|
||||
private static final int[] l = {R$string.button_product_search, R$string.button_book_search, R$string.button_search_book_contents, R$string.button_custom_product_search};
|
||||
|
||||
public ISBNResultHandler(Activity activity, ParsedResult parsedResult, Result result) {
|
||||
super(activity, parsedResult, result);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return l[i];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
ISBNParsedResult iSBNParsedResult = (ISBNParsedResult) g();
|
||||
if (i == 0) {
|
||||
f(iSBNParsedResult.c());
|
||||
return;
|
||||
}
|
||||
if (i == 1) {
|
||||
d(iSBNParsedResult.c());
|
||||
} else if (i == 2) {
|
||||
h(iSBNParsedResult.c());
|
||||
} else {
|
||||
if (i != 3) {
|
||||
return;
|
||||
}
|
||||
g(c(iSBNParsedResult.c()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return i() ? l.length : l.length - 1;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_isbn;
|
||||
}
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.ExpandedProductParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.ProductParsedResult;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ProductResultHandler extends ResultHandler {
|
||||
private static final int[] l = {R$string.button_product_search, R$string.button_web_search, R$string.button_custom_product_search};
|
||||
|
||||
public ProductResultHandler(Activity activity, ParsedResult parsedResult, Result result) {
|
||||
super(activity, parsedResult, result);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return l[i];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
String a = a(g());
|
||||
if (i == 0) {
|
||||
f(a);
|
||||
} else if (i == 1) {
|
||||
l(a);
|
||||
} else {
|
||||
if (i != 2) {
|
||||
return;
|
||||
}
|
||||
g(c(a));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return i() ? l.length : l.length - 1;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_product;
|
||||
}
|
||||
|
||||
private static String a(ParsedResult parsedResult) {
|
||||
if (parsedResult instanceof ProductParsedResult) {
|
||||
return ((ProductParsedResult) parsedResult).c();
|
||||
}
|
||||
if (parsedResult instanceof ExpandedProductParsedResult) {
|
||||
return ((ExpandedProductParsedResult) parsedResult).c();
|
||||
}
|
||||
throw new IllegalArgumentException(parsedResult.getClass().toString());
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ResultButtonListener implements View.OnClickListener {
|
||||
private final ResultHandler a;
|
||||
private final int b;
|
||||
|
||||
public ResultButtonListener(ResultHandler resultHandler, int i) {
|
||||
this.a = resultHandler;
|
||||
this.b = i;
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
this.a.b(this.b);
|
||||
}
|
||||
}
|
@@ -0,0 +1,390 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ContentValues;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.ContactsContract;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import android.util.Log;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.client.android.Contents;
|
||||
import com.google.zxing.client.android.LocaleManager;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.android.book.SearchBookContentsActivity;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResultType;
|
||||
import com.google.zxing.client.result.ResultParser;
|
||||
import com.ubt.jimu.blockly.command.BlocklyCommandController;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ResultHandler {
|
||||
private static final String e = "ResultHandler";
|
||||
private static final String[] f = {"home", "work", "mobile"};
|
||||
private static final String[] g = {"home", "work", "mobile", "fax", "pager", "main"};
|
||||
private static final String[] h = {"home", "work"};
|
||||
private static final int[] i = {1, 2, 4};
|
||||
private static final int[] j = {1, 3, 2, 4, 6, 12};
|
||||
private static final int[] k = {1, 2};
|
||||
private final ParsedResult a;
|
||||
private final Activity b;
|
||||
private final Result c;
|
||||
private final String d;
|
||||
|
||||
ResultHandler(Activity activity, ParsedResult parsedResult) {
|
||||
this(activity, parsedResult, null);
|
||||
}
|
||||
|
||||
static String m(String str) {
|
||||
return PhoneNumberUtils.formatNumber(str);
|
||||
}
|
||||
|
||||
private static int n(String str) {
|
||||
return a(str, h, k);
|
||||
}
|
||||
|
||||
private static int o(String str) {
|
||||
return a(str, f, i);
|
||||
}
|
||||
|
||||
private static int p(String str) {
|
||||
return a(str, g, j);
|
||||
}
|
||||
|
||||
public abstract int a(int i2);
|
||||
|
||||
final void a(String[] strArr, String[] strArr2) {
|
||||
a(null, null, null, null, null, strArr, strArr2, null, null, null, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Activity b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public abstract void b(int i2);
|
||||
|
||||
public abstract int c();
|
||||
|
||||
final String c(String str) {
|
||||
if (this.d == null) {
|
||||
return str;
|
||||
}
|
||||
try {
|
||||
str = URLEncoder.encode(str, "UTF-8");
|
||||
} catch (UnsupportedEncodingException unused) {
|
||||
}
|
||||
String str2 = this.d;
|
||||
Result result = this.c;
|
||||
if (result != null) {
|
||||
str2 = str2.replaceFirst("%f(?![0-9a-f])", result.a().toString());
|
||||
if (str2.contains("%t")) {
|
||||
str2 = str2.replace("%t", ResultParser.c(this.c).b().toString());
|
||||
}
|
||||
}
|
||||
return str2.replace("%s", str);
|
||||
}
|
||||
|
||||
public Integer d() {
|
||||
return null;
|
||||
}
|
||||
|
||||
final void d(String str) {
|
||||
a(new Intent("android.intent.action.VIEW", Uri.parse("http://books.google." + LocaleManager.a(this.b) + "/books?vid=isbn" + str)));
|
||||
}
|
||||
|
||||
public CharSequence e() {
|
||||
return this.a.a().replace("\r", "");
|
||||
}
|
||||
|
||||
public abstract int f();
|
||||
|
||||
final void f(String str) {
|
||||
a(new Intent("android.intent.action.VIEW", Uri.parse("http://www.google." + LocaleManager.d(this.b) + "/m/products?q=" + str + "&source=zxing")));
|
||||
}
|
||||
|
||||
public final ParsedResult g() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public final ParsedResultType h() {
|
||||
return this.a.b();
|
||||
}
|
||||
|
||||
final boolean i() {
|
||||
return this.d != null;
|
||||
}
|
||||
|
||||
final void j(String str) {
|
||||
a(null, null, null, null, str);
|
||||
}
|
||||
|
||||
final void k(String str) {
|
||||
b("smsto:", str);
|
||||
}
|
||||
|
||||
final void l(String str) {
|
||||
Intent intent = new Intent("android.intent.action.WEB_SEARCH");
|
||||
intent.putExtra(BlocklyCommandController.QUERY, str);
|
||||
a(intent);
|
||||
}
|
||||
|
||||
ResultHandler(Activity activity, ParsedResult parsedResult, Result result) {
|
||||
this.a = parsedResult;
|
||||
this.b = activity;
|
||||
this.c = result;
|
||||
this.d = j();
|
||||
}
|
||||
|
||||
private String j() {
|
||||
String string = PreferenceManager.getDefaultSharedPreferences(this.b).getString("preferences_custom_product_search", null);
|
||||
if (string == null || !string.trim().isEmpty()) {
|
||||
return string;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
final void a(String[] strArr, String[] strArr2, String str, String[] strArr3, String[] strArr4, String[] strArr5, String[] strArr6, String str2, String str3, String str4, String str5, String str6, String str7, String[] strArr7, String str8, String[] strArr8) {
|
||||
int n;
|
||||
int o;
|
||||
int p;
|
||||
Intent intent = new Intent("android.intent.action.INSERT_OR_EDIT", ContactsContract.Contacts.CONTENT_URI);
|
||||
intent.setType("vnd.android.cursor.item/contact");
|
||||
a(intent, MediationMetaData.KEY_NAME, (strArr == null || strArr.length <= 0) ? null : strArr[0]);
|
||||
a(intent, "phonetic_name", str);
|
||||
if (strArr3 != null) {
|
||||
int min = Math.min(strArr3.length, Contents.a.length);
|
||||
for (int i2 = 0; i2 < min; i2++) {
|
||||
a(intent, Contents.a[i2], strArr3[i2]);
|
||||
if (strArr4 != null && i2 < strArr4.length && (p = p(strArr4[i2])) >= 0) {
|
||||
intent.putExtra(Contents.b[i2], p);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strArr5 != null) {
|
||||
int min2 = Math.min(strArr5.length, Contents.c.length);
|
||||
for (int i3 = 0; i3 < min2; i3++) {
|
||||
a(intent, Contents.c[i3], strArr5[i3]);
|
||||
if (strArr6 != null && i3 < strArr6.length && (o = o(strArr6[i3])) >= 0) {
|
||||
intent.putExtra(Contents.d[i3], o);
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
|
||||
if (strArr7 != null) {
|
||||
int length = strArr7.length;
|
||||
int i4 = 0;
|
||||
while (true) {
|
||||
if (i4 >= length) {
|
||||
break;
|
||||
}
|
||||
String str9 = strArr7[i4];
|
||||
if (str9 != null && !str9.isEmpty()) {
|
||||
ContentValues contentValues = new ContentValues(2);
|
||||
contentValues.put("mimetype", "vnd.android.cursor.item/website");
|
||||
contentValues.put("data1", str9);
|
||||
arrayList.add(contentValues);
|
||||
break;
|
||||
}
|
||||
i4++;
|
||||
}
|
||||
}
|
||||
if (str8 != null) {
|
||||
ContentValues contentValues2 = new ContentValues(3);
|
||||
contentValues2.put("mimetype", "vnd.android.cursor.item/contact_event");
|
||||
contentValues2.put("data2", (Integer) 3);
|
||||
contentValues2.put("data1", str8);
|
||||
arrayList.add(contentValues2);
|
||||
}
|
||||
if (strArr2 != null) {
|
||||
int length2 = strArr2.length;
|
||||
int i5 = 0;
|
||||
while (true) {
|
||||
if (i5 >= length2) {
|
||||
break;
|
||||
}
|
||||
String str10 = strArr2[i5];
|
||||
if (str10 != null && !str10.isEmpty()) {
|
||||
ContentValues contentValues3 = new ContentValues(3);
|
||||
contentValues3.put("mimetype", "vnd.android.cursor.item/nickname");
|
||||
contentValues3.put("data2", (Integer) 1);
|
||||
contentValues3.put("data1", str10);
|
||||
arrayList.add(contentValues3);
|
||||
break;
|
||||
}
|
||||
i5++;
|
||||
}
|
||||
}
|
||||
if (!arrayList.isEmpty()) {
|
||||
intent.putParcelableArrayListExtra("data", arrayList);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (str2 != null) {
|
||||
sb.append('\n');
|
||||
sb.append(str2);
|
||||
}
|
||||
if (strArr8 != null && strArr8.length >= 2) {
|
||||
sb.append('\n');
|
||||
sb.append(strArr8[0]);
|
||||
sb.append(',');
|
||||
sb.append(strArr8[1]);
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
a(intent, "notes", sb.substring(1));
|
||||
}
|
||||
if (str3 == null || !str3.startsWith("xmpp:")) {
|
||||
a(intent, "im_handle", str3);
|
||||
} else {
|
||||
intent.putExtra("im_protocol", 7);
|
||||
intent.putExtra("im_handle", str3.substring(5));
|
||||
}
|
||||
a(intent, "postal", str4);
|
||||
if (str5 != null && (n = n(str5)) >= 0) {
|
||||
intent.putExtra("postal_type", n);
|
||||
}
|
||||
a(intent, "company", str6);
|
||||
a(intent, "job_title", str7);
|
||||
a(intent);
|
||||
}
|
||||
|
||||
final void b(String[] strArr, String[] strArr2) {
|
||||
a(null, null, null, strArr, strArr2, null, null, null, null, null, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
final void g(String str) {
|
||||
if (str.startsWith("HTTP://")) {
|
||||
str = "http" + str.substring(4);
|
||||
} else if (str.startsWith("HTTPS://")) {
|
||||
str = "https" + str.substring(5);
|
||||
}
|
||||
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
|
||||
try {
|
||||
a(intent);
|
||||
} catch (ActivityNotFoundException unused) {
|
||||
Log.w(e, "Nothing available to handle " + intent);
|
||||
}
|
||||
}
|
||||
|
||||
final void h(String str) {
|
||||
Intent intent = new Intent("com.google.zxing.client.android.SEARCH_BOOK_CONTENTS");
|
||||
intent.setClassName(this.b, SearchBookContentsActivity.class.getName());
|
||||
a(intent, "ISBN", str);
|
||||
a(intent);
|
||||
}
|
||||
|
||||
final void i(String str) {
|
||||
a(new Intent("android.intent.action.VIEW", Uri.parse("geo:0,0?q=" + Uri.encode(str))));
|
||||
}
|
||||
|
||||
private void b(String str, String str2) {
|
||||
Intent intent = new Intent("android.intent.action.SENDTO", Uri.parse(str));
|
||||
a(intent, "sms_body", str2);
|
||||
intent.putExtra("compose_mode", true);
|
||||
a(intent);
|
||||
}
|
||||
|
||||
final void e(String str) {
|
||||
a(new Intent("android.intent.action.VIEW", Uri.parse(str)));
|
||||
}
|
||||
|
||||
private void b(String str, String str2, String str3) {
|
||||
Intent intent = new Intent("android.intent.action.SENDTO", Uri.parse(str));
|
||||
if (str2 != null && !str2.isEmpty()) {
|
||||
a(intent, "subject", str2);
|
||||
} else {
|
||||
a(intent, "subject", this.b.getString(R$string.msg_default_mms_subject));
|
||||
}
|
||||
a(intent, "sms_body", str3);
|
||||
intent.putExtra("compose_mode", true);
|
||||
a(intent);
|
||||
}
|
||||
|
||||
final void b(String str) {
|
||||
a(new Intent("android.intent.action.DIAL", Uri.parse(str)));
|
||||
}
|
||||
|
||||
final void b(Intent intent) {
|
||||
if (intent != null) {
|
||||
intent.addFlags(524288);
|
||||
this.b.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private static int a(String str, String[] strArr, int[] iArr) {
|
||||
if (str == null) {
|
||||
return -1;
|
||||
}
|
||||
for (int i2 = 0; i2 < strArr.length; i2++) {
|
||||
String str2 = strArr[i2];
|
||||
if (str.startsWith(str2) || str.startsWith(str2.toUpperCase(Locale.ENGLISH))) {
|
||||
return iArr[i2];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
final void a(String[] strArr, String[] strArr2, String[] strArr3, String str, String str2) {
|
||||
Intent intent = new Intent("android.intent.action.SEND", Uri.parse("mailto:"));
|
||||
if (strArr != null && strArr.length != 0) {
|
||||
intent.putExtra("android.intent.extra.EMAIL", strArr);
|
||||
}
|
||||
if (strArr2 != null && strArr2.length != 0) {
|
||||
intent.putExtra("android.intent.extra.CC", strArr2);
|
||||
}
|
||||
if (strArr3 != null && strArr3.length != 0) {
|
||||
intent.putExtra("android.intent.extra.BCC", strArr3);
|
||||
}
|
||||
a(intent, "android.intent.extra.SUBJECT", str);
|
||||
a(intent, "android.intent.extra.TEXT", str2);
|
||||
intent.setType("text/plain");
|
||||
a(intent);
|
||||
}
|
||||
|
||||
final void a(String str, String str2) {
|
||||
b("smsto:" + str, str2);
|
||||
}
|
||||
|
||||
final void a(String str, String str2, String str3) {
|
||||
b("mmsto:" + str, str2, str3);
|
||||
}
|
||||
|
||||
final void a(String str) {
|
||||
a(new Intent("android.intent.action.DIAL", Uri.parse("tel:" + str)));
|
||||
}
|
||||
|
||||
final void a(double d, double d2) {
|
||||
a(new Intent("android.intent.action.VIEW", Uri.parse("http://maps.google." + LocaleManager.c(this.b) + "/maps?f=d&daddr=" + d + ',' + d2)));
|
||||
}
|
||||
|
||||
final void a(Intent intent) {
|
||||
try {
|
||||
b(intent);
|
||||
} catch (ActivityNotFoundException unused) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this.b);
|
||||
builder.setTitle(R$string.scan_name);
|
||||
builder.setMessage(R$string.msg_intent_failed);
|
||||
builder.setPositiveButton(R$string.button_ok, (DialogInterface.OnClickListener) null);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
||||
private static void a(Intent intent, String str, String str2) {
|
||||
if (str2 == null || str2.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
intent.putExtra(str, str2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.client.android.ICaptureView;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResultType;
|
||||
import com.google.zxing.client.result.ResultParser;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ResultHandlerFactory {
|
||||
|
||||
/* renamed from: com.google.zxing.client.android.result.ResultHandlerFactory$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] a = new int[ParsedResultType.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
a[ParsedResultType.ADDRESSBOOK.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
a[ParsedResultType.EMAIL_ADDRESS.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
a[ParsedResultType.PRODUCT.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
a[ParsedResultType.URI.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
try {
|
||||
a[ParsedResultType.WIFI.ordinal()] = 5;
|
||||
} catch (NoSuchFieldError unused5) {
|
||||
}
|
||||
try {
|
||||
a[ParsedResultType.GEO.ordinal()] = 6;
|
||||
} catch (NoSuchFieldError unused6) {
|
||||
}
|
||||
try {
|
||||
a[ParsedResultType.TEL.ordinal()] = 7;
|
||||
} catch (NoSuchFieldError unused7) {
|
||||
}
|
||||
try {
|
||||
a[ParsedResultType.SMS.ordinal()] = 8;
|
||||
} catch (NoSuchFieldError unused8) {
|
||||
}
|
||||
try {
|
||||
a[ParsedResultType.CALENDAR.ordinal()] = 9;
|
||||
} catch (NoSuchFieldError unused9) {
|
||||
}
|
||||
try {
|
||||
a[ParsedResultType.ISBN.ordinal()] = 10;
|
||||
} catch (NoSuchFieldError unused10) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultHandler a(Activity activity, ICaptureView iCaptureView, Result result) {
|
||||
ParsedResult a = a(result);
|
||||
switch (AnonymousClass1.a[a.b().ordinal()]) {
|
||||
case 1:
|
||||
return new AddressBookResultHandler(activity, a);
|
||||
case 2:
|
||||
return new EmailAddressResultHandler(activity, a);
|
||||
case 3:
|
||||
return new ProductResultHandler(activity, a, result);
|
||||
case 4:
|
||||
return new URIResultHandler(activity, a);
|
||||
case 5:
|
||||
return new WifiResultHandler(activity, iCaptureView, a);
|
||||
case 6:
|
||||
return new GeoResultHandler(activity, a);
|
||||
case 7:
|
||||
return new TelResultHandler(activity, a);
|
||||
case 8:
|
||||
return new SMSResultHandler(activity, a);
|
||||
case 9:
|
||||
return new CalendarResultHandler(activity, a);
|
||||
case 10:
|
||||
return new ISBNResultHandler(activity, a, result);
|
||||
default:
|
||||
return new TextResultHandler(activity, a, result);
|
||||
}
|
||||
}
|
||||
|
||||
private static ParsedResult a(Result result) {
|
||||
return ResultParser.c(result);
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.SMSParsedResult;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class SMSResultHandler extends ResultHandler {
|
||||
private static final int[] l = {R$string.button_sms, R$string.button_mms};
|
||||
|
||||
public SMSResultHandler(Activity activity, ParsedResult parsedResult) {
|
||||
super(activity, parsedResult);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return l[i];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
SMSParsedResult sMSParsedResult = (SMSParsedResult) g();
|
||||
String str = sMSParsedResult.d()[0];
|
||||
if (i == 0) {
|
||||
a(str, sMSParsedResult.c());
|
||||
} else {
|
||||
if (i != 1) {
|
||||
return;
|
||||
}
|
||||
a(str, sMSParsedResult.e(), sMSParsedResult.c());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return l.length;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public CharSequence e() {
|
||||
SMSParsedResult sMSParsedResult = (SMSParsedResult) g();
|
||||
String[] d = sMSParsedResult.d();
|
||||
String[] strArr = new String[d.length];
|
||||
for (int i = 0; i < d.length; i++) {
|
||||
strArr[i] = ResultHandler.m(d[i]);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(50);
|
||||
ParsedResult.a(strArr, sb);
|
||||
ParsedResult.a(sMSParsedResult.e(), sb);
|
||||
ParsedResult.a(sMSParsedResult.c(), sb);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_sms;
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.TelParsedResult;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class TelResultHandler extends ResultHandler {
|
||||
private static final int[] l = {R$string.button_dial, R$string.button_add_contact};
|
||||
|
||||
public TelResultHandler(Activity activity, ParsedResult parsedResult) {
|
||||
super(activity, parsedResult);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return l[i];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
TelParsedResult telParsedResult = (TelParsedResult) g();
|
||||
if (i == 0) {
|
||||
b(telParsedResult.d());
|
||||
b().finish();
|
||||
} else {
|
||||
if (i != 1) {
|
||||
return;
|
||||
}
|
||||
b(new String[]{telParsedResult.c()}, (String[]) null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return l.length;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public CharSequence e() {
|
||||
return ResultHandler.m(g().a().replace("\r", ""));
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_tel;
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class TextResultHandler extends ResultHandler {
|
||||
private static final int[] l = {R$string.button_web_search, R$string.button_share_by_email, R$string.button_share_by_sms, R$string.button_custom_product_search};
|
||||
|
||||
public TextResultHandler(Activity activity, ParsedResult parsedResult, Result result) {
|
||||
super(activity, parsedResult, result);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return l[i];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
String a = g().a();
|
||||
if (i == 0) {
|
||||
l(a);
|
||||
return;
|
||||
}
|
||||
if (i == 1) {
|
||||
j(a);
|
||||
} else if (i == 2) {
|
||||
k(a);
|
||||
} else {
|
||||
if (i != 3) {
|
||||
return;
|
||||
}
|
||||
g(c(a));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return i() ? l.length : l.length - 1;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_text;
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.google.zxing.client.android.LocaleManager;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.URIParsedResult;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class URIResultHandler extends ResultHandler {
|
||||
private static final String[] l = {"otpauth:"};
|
||||
private static final int[] m = {R$string.button_open_browser, R$string.button_share_by_email, R$string.button_share_by_sms, R$string.button_search_book_contents};
|
||||
|
||||
public URIResultHandler(Activity activity, ParsedResult parsedResult) {
|
||||
super(activity, parsedResult);
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return m[i];
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
String c = ((URIParsedResult) g()).c();
|
||||
if (i == 0) {
|
||||
g(c);
|
||||
return;
|
||||
}
|
||||
if (i == 1) {
|
||||
j(c);
|
||||
} else if (i == 2) {
|
||||
k(c);
|
||||
} else {
|
||||
if (i != 3) {
|
||||
return;
|
||||
}
|
||||
h(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return LocaleManager.a(((URIParsedResult) g()).c()) ? m.length : m.length - 1;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public Integer d() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_uri;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public boolean a() {
|
||||
String lowerCase = ((URIParsedResult) g()).c().toLowerCase(Locale.ENGLISH);
|
||||
for (String str : l) {
|
||||
if (lowerCase.startsWith(str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
package com.google.zxing.client.android.result;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import com.google.zxing.client.android.ICaptureView;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.android.wifi.WifiConfigManager;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.WifiParsedResult;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class WifiResultHandler extends ResultHandler {
|
||||
private static final String m = "WifiResultHandler";
|
||||
private final ICaptureView l;
|
||||
|
||||
public WifiResultHandler(Activity activity, ICaptureView iCaptureView, ParsedResult parsedResult) {
|
||||
super(activity, parsedResult);
|
||||
this.l = iCaptureView;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int a(int i) {
|
||||
return R$string.button_wifi;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public void b(int i) {
|
||||
if (i == 0) {
|
||||
WifiParsedResult wifiParsedResult = (WifiParsedResult) g();
|
||||
WifiManager wifiManager = (WifiManager) b().getApplicationContext().getSystemService("wifi");
|
||||
if (wifiManager == null) {
|
||||
Log.w(m, "No WifiManager available from device");
|
||||
return;
|
||||
}
|
||||
final Activity b = b();
|
||||
b.runOnUiThread(new Runnable(this) { // from class: com.google.zxing.client.android.result.WifiResultHandler.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
Toast.makeText(b.getApplicationContext(), R$string.wifi_changing_network, 0).show();
|
||||
}
|
||||
});
|
||||
new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiParsedResult);
|
||||
this.l.a(0L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int c() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public CharSequence e() {
|
||||
WifiParsedResult wifiParsedResult = (WifiParsedResult) g();
|
||||
return wifiParsedResult.i() + " (" + wifiParsedResult.f() + ')';
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.ResultHandler
|
||||
public int f() {
|
||||
return R$string.result_wifi;
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package com.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import com.google.zxing.client.android.LocaleManager;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class BookResultInfoRetriever extends SupplementalInfoRetriever {
|
||||
private final String f;
|
||||
private final String g;
|
||||
private final Context h;
|
||||
|
||||
BookResultInfoRetriever(TextView textView, String str, HistoryManager historyManager, Context context) {
|
||||
super(textView, historyManager);
|
||||
this.f = str;
|
||||
this.g = context.getString(R$string.msg_google_books);
|
||||
this.h = context;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever
|
||||
void a() throws IOException {
|
||||
JSONObject jSONObject;
|
||||
ArrayList arrayList;
|
||||
CharSequence a = HttpHelper.a("https://www.googleapis.com/books/v1/volumes?q=isbn:" + this.f, HttpHelper.ContentType.JSON);
|
||||
if (a.length() == 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JSONArray optJSONArray = ((JSONObject) new JSONTokener(a.toString()).nextValue()).optJSONArray("items");
|
||||
if (optJSONArray != null) {
|
||||
if (optJSONArray.isNull(0) || (jSONObject = ((JSONObject) optJSONArray.get(0)).getJSONObject("volumeInfo")) == null) {
|
||||
return;
|
||||
}
|
||||
String optString = jSONObject.optString("title");
|
||||
String optString2 = jSONObject.optString("pageCount");
|
||||
JSONArray optJSONArray2 = jSONObject.optJSONArray("authors");
|
||||
String str = null;
|
||||
if (optJSONArray2 == null || optJSONArray2.isNull(0)) {
|
||||
arrayList = null;
|
||||
} else {
|
||||
arrayList = new ArrayList(optJSONArray2.length());
|
||||
for (int i = 0; i < optJSONArray2.length(); i++) {
|
||||
arrayList.add(optJSONArray2.getString(i));
|
||||
}
|
||||
}
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
SupplementalInfoRetriever.a(optString, arrayList2);
|
||||
SupplementalInfoRetriever.a(arrayList, arrayList2);
|
||||
if (optString2 != null && !optString2.isEmpty()) {
|
||||
str = optString2 + "pp.";
|
||||
}
|
||||
SupplementalInfoRetriever.a(str, arrayList2);
|
||||
String str2 = "http://www.google." + LocaleManager.a(this.h) + "/search?tbm=bks&source=zxing&q=";
|
||||
a(this.f, this.g, (String[]) arrayList2.toArray(SupplementalInfoRetriever.e), str2 + this.f);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import com.google.zxing.client.android.LocaleManager;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class ProductResultInfoRetriever extends SupplementalInfoRetriever {
|
||||
private static final Pattern[] i = {Pattern.compile(",event\\)\">([^<]+)</a></h3>.+<span class=psrp>([^<]+)</span>"), Pattern.compile("owb63p\">([^<]+).+zdi3pb\">([^<]+)")};
|
||||
private final String f;
|
||||
private final String g;
|
||||
private final Context h;
|
||||
|
||||
ProductResultInfoRetriever(TextView textView, String str, HistoryManager historyManager, Context context) {
|
||||
super(textView, historyManager);
|
||||
this.f = str;
|
||||
this.g = context.getString(R$string.msg_google_product);
|
||||
this.h = context;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever
|
||||
void a() throws IOException {
|
||||
String str = "https://www.google." + LocaleManager.d(this.h) + "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + URLEncoder.encode(this.f, "UTF-8");
|
||||
CharSequence a = HttpHelper.a(str, HttpHelper.ContentType.HTML);
|
||||
for (Pattern pattern : i) {
|
||||
Matcher matcher = pattern.matcher(a);
|
||||
if (matcher.find()) {
|
||||
a(this.f, this.g, new String[]{a(matcher.group(1)), a(matcher.group(2))}, str);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String a(String str) {
|
||||
return Html.fromHtml(str).toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,139 @@
|
||||
package com.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import com.google.zxing.client.result.ISBNParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.ProductParsedResult;
|
||||
import com.google.zxing.client.result.URIParsedResult;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class SupplementalInfoRetriever extends AsyncTask<Object, Object, Object> {
|
||||
static final String[] e = new String[0];
|
||||
private final WeakReference<TextView> a;
|
||||
private final WeakReference<HistoryManager> b;
|
||||
private final Collection<Spannable> c = new ArrayList();
|
||||
private final Collection<String[]> d = new ArrayList();
|
||||
|
||||
SupplementalInfoRetriever(TextView textView, HistoryManager historyManager) {
|
||||
this.a = new WeakReference<>(textView);
|
||||
this.b = new WeakReference<>(historyManager);
|
||||
}
|
||||
|
||||
public static void a(TextView textView, ParsedResult parsedResult, HistoryManager historyManager, Context context) {
|
||||
try {
|
||||
if (parsedResult instanceof URIParsedResult) {
|
||||
new URIResultInfoRetriever(textView, (URIParsedResult) parsedResult, historyManager, context).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Object[0]);
|
||||
new TitleRetriever(textView, (URIParsedResult) parsedResult, historyManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Object[0]);
|
||||
} else if (parsedResult instanceof ProductParsedResult) {
|
||||
new ProductResultInfoRetriever(textView, ((ProductParsedResult) parsedResult).d(), historyManager, context).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Object[0]);
|
||||
} else if (parsedResult instanceof ISBNParsedResult) {
|
||||
String c = ((ISBNParsedResult) parsedResult).c();
|
||||
new ProductResultInfoRetriever(textView, c, historyManager, context).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Object[0]);
|
||||
new BookResultInfoRetriever(textView, c, historyManager, context).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Object[0]);
|
||||
}
|
||||
} catch (RejectedExecutionException unused) {
|
||||
}
|
||||
}
|
||||
|
||||
abstract void a() throws IOException;
|
||||
|
||||
@Override // android.os.AsyncTask
|
||||
public final Object doInBackground(Object... objArr) {
|
||||
try {
|
||||
a();
|
||||
return null;
|
||||
} catch (IOException e2) {
|
||||
Log.w("SupplementalInfo", e2);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.os.AsyncTask
|
||||
protected final void onPostExecute(Object obj) {
|
||||
TextView textView = this.a.get();
|
||||
if (textView != null) {
|
||||
Iterator<Spannable> it = this.c.iterator();
|
||||
while (it.hasNext()) {
|
||||
textView.append(it.next());
|
||||
}
|
||||
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
HistoryManager historyManager = this.b.get();
|
||||
if (historyManager != null) {
|
||||
for (String[] strArr : this.d) {
|
||||
historyManager.a(strArr[0], strArr[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final void a(String str, String str2, String[] strArr, String str3) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (str2 != null) {
|
||||
sb.append(str2);
|
||||
sb.append(' ');
|
||||
}
|
||||
int length = sb.length();
|
||||
boolean z = true;
|
||||
for (String str4 : strArr) {
|
||||
if (z) {
|
||||
sb.append(str4);
|
||||
z = false;
|
||||
} else {
|
||||
sb.append(" [");
|
||||
sb.append(str4);
|
||||
sb.append(']');
|
||||
}
|
||||
}
|
||||
int length2 = sb.length();
|
||||
String sb2 = sb.toString();
|
||||
SpannableString spannableString = new SpannableString(sb2 + "\n\n");
|
||||
if (str3 != null) {
|
||||
if (str3.startsWith("HTTP://")) {
|
||||
str3 = "http" + str3.substring(4);
|
||||
} else if (str3.startsWith("HTTPS://")) {
|
||||
str3 = "https" + str3.substring(5);
|
||||
}
|
||||
spannableString.setSpan(new URLSpan(str3), length, length2, 33);
|
||||
}
|
||||
this.c.add(spannableString);
|
||||
this.d.add(new String[]{str, sb2});
|
||||
}
|
||||
|
||||
static void a(String str, Collection<String> collection) {
|
||||
if (str == null || str.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
collection.add(str);
|
||||
}
|
||||
|
||||
static void a(Collection<String> collection, Collection<String> collection2) {
|
||||
if (collection == null || collection.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
boolean z = true;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String str : collection) {
|
||||
if (z) {
|
||||
z = false;
|
||||
} else {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(str);
|
||||
}
|
||||
collection2.add(sb.toString());
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package com.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.text.Html;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import com.google.zxing.client.result.URIParsedResult;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class TitleRetriever extends SupplementalInfoRetriever {
|
||||
private static final Pattern g = Pattern.compile("<title>([^<]+)");
|
||||
private final String f;
|
||||
|
||||
TitleRetriever(TextView textView, URIParsedResult uRIParsedResult, HistoryManager historyManager) {
|
||||
super(textView, historyManager);
|
||||
this.f = uRIParsedResult.c();
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever
|
||||
void a() {
|
||||
String group;
|
||||
try {
|
||||
CharSequence a = HttpHelper.a(this.f, HttpHelper.ContentType.HTML, FileUtil.ZIP_BUFFER_SIZE);
|
||||
if (a == null || a.length() <= 0) {
|
||||
return;
|
||||
}
|
||||
Matcher matcher = g.matcher(a);
|
||||
if (!matcher.find() || (group = matcher.group(1)) == null || group.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String obj = Html.fromHtml(group).toString();
|
||||
if (obj.length() > 100) {
|
||||
obj = obj.substring(0, 100) + "...";
|
||||
}
|
||||
String str = this.f;
|
||||
a(str, (String) null, new String[]{obj}, str);
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package com.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import com.google.zxing.client.android.R$string;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import com.google.zxing.client.result.URIParsedResult;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class URIResultInfoRetriever extends SupplementalInfoRetriever {
|
||||
private final URIParsedResult f;
|
||||
private final String g;
|
||||
|
||||
URIResultInfoRetriever(TextView textView, URIParsedResult uRIParsedResult, HistoryManager historyManager, Context context) {
|
||||
super(textView, historyManager);
|
||||
this.g = context.getString(R$string.msg_redirect);
|
||||
this.f = uRIParsedResult;
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever
|
||||
void a() throws IOException {
|
||||
try {
|
||||
URI uri = new URI(this.f.c());
|
||||
URI a = HttpHelper.a(uri);
|
||||
URI uri2 = uri;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
int i2 = i + 1;
|
||||
if (i >= 5 || uri2.equals(a)) {
|
||||
return;
|
||||
}
|
||||
a(this.f.a(), (String) null, new String[]{this.g + " : " + a}, a.toString());
|
||||
uri2 = a;
|
||||
a = HttpHelper.a(a);
|
||||
i = i2;
|
||||
}
|
||||
} catch (URISyntaxException unused) {
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user