Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F13766933
D244.1787139440.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D244.1787139440.diff
View Options
diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/BarcodeFragment.kt b/app/src/main/java/it/reyboz/bustorino/fragments/BarcodeFragment.kt
--- a/app/src/main/java/it/reyboz/bustorino/fragments/BarcodeFragment.kt
+++ b/app/src/main/java/it/reyboz/bustorino/fragments/BarcodeFragment.kt
@@ -41,12 +41,13 @@
abstract fun onQrScanSuccess(busIDToSearch: String)
protected fun launchBarcodeScan() {
+ val context = getContext() ?: return
val scanOptions = BarcodeScanOptions()
val intent = scanOptions.createScanIntent()
- if (!BarcodeScanUtils.checkTargetPackageExists(getContext(), intent)) {
- BarcodeScanUtils.showDownloadDialog(null, this)
+ if (!BarcodeScanUtils.checkTargetPackageExists(context, intent)) {
+ BarcodeScanUtils.showDownloadDialog(context)
} else {
barcodeLauncher.launch(scanOptions)
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanOptions.java b/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanOptions.java
--- a/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanOptions.java
+++ b/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanOptions.java
@@ -19,6 +19,7 @@
public class BarcodeScanOptions {
public static final String BS_PACKAGE = "com.google.zxing.client.android";
+ public static final String BINARY_EYE_PACKAGE = "de.markufisch.android.binaryeye";
// supported barcode formats
diff --git a/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanUtils.java b/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanUtils.java
--- a/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanUtils.java
+++ b/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanUtils.java
@@ -25,31 +25,20 @@
public static boolean checkTargetPackageExists(Context context,Intent intent) {
PackageManager pm = context.getPackageManager();
List<ResolveInfo> availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
- if (availableApps != null) {
- return !availableApps.isEmpty();
- }
- return false;
+ return !availableApps.isEmpty();
}
- public static AlertDialog showDownloadDialog(@Nullable Activity activity,@Nullable final Fragment fragment) {
- if (activity == null){
- if (fragment==null) throw new IllegalArgumentException("Cannot put both activity and fragment null");
- activity = fragment.getActivity();
- }
- AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity);
+ public static AlertDialog showDownloadDialog(@NonNull Context context) {
+
+ AlertDialog.Builder downloadDialog = new AlertDialog.Builder(context);
downloadDialog.setTitle(R.string.title_barcode_scanner_install);
downloadDialog.setMessage(R.string.message_install_barcode_scanner);
- final Activity finalActivity = activity;
downloadDialog.setPositiveButton(R.string.yes, (dialogInterface, i) -> {
- final String packageName = BarcodeScanOptions.BS_PACKAGE;
+ final String packageName = BarcodeScanOptions.BINARY_EYE_PACKAGE;
Uri uri = Uri.parse("market://details?id=" + packageName);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
try {
- if (fragment == null) {
- finalActivity.startActivity(intent);
- } else {
- fragment.startActivity(intent);
- }
+ context.startActivity(intent);
} catch (ActivityNotFoundException anfe) {
// Hmm, market is not installed
Log.w("BusTO-BarcodeScanUtils", "Google Play is not installed; cannot install " + packageName);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -14,9 +14,9 @@
<string name="next">Next</string>
<string name="previous">Previous</string>
- <string name="title_barcode_scanner_install">Install Barcode Scanner?</string>
- <string name="message_install_barcode_scanner">This application requires an app to scan the QR codes. Would you like
- to install Barcode Scanner now?
+ <string name="title_barcode_scanner_install">Install barcode scanner app?</string>
+ <string name="message_install_barcode_scanner">This application requires an app to scan the QR codes. We suggest using Binary Eye, which
+ is open source software, would you like to install it now?
</string>
<string name="insert_bus_stop_number">Bus stop number</string>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 13:37 (22 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2072397
Default Alt Text
D244.1787139440.diff (4 KB)
Attached To
Mode
D244: Change barcode scanner app
Attached
Detach File
Event Timeline