commit 6e2292e71839713958057edc3a6d0210a0a93cc3 Author: Fabio Mazza Date: Wed May 20 19:51:54 2026 +0200 Change barcode scanner app Try to open market on good open source app diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java b/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java index 429830f..f45ad1a 100644 --- a/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java +++ b/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java @@ -491,7 +491,7 @@ public class MainScreenFragment extends ScreenBaseFragment implements FragmentL BarcodeScanOptions scanOptions = new BarcodeScanOptions(); Intent intent = scanOptions.createScanIntent(); if(!BarcodeScanUtils.checkTargetPackageExists(getContext(), intent)){ - BarcodeScanUtils.showDownloadDialog(null, this); + BarcodeScanUtils.showDownloadDialog(requireContext()); }else { barcodeLauncher.launch(scanOptions); } diff --git a/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanOptions.java b/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanOptions.java index f593f53..69d2eba 100644 --- 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 @@ import java.util.Map; 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 index 2b9974c..c24a028 100644 --- 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 class BarcodeScanUtils { public static boolean checkTargetPackageExists(Context context,Intent intent) { PackageManager pm = context.getPackageManager(); List 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 index 17942b4..e569a59 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,9 +14,9 @@ Next Previous - Install Barcode Scanner? - This application requires an app to scan the QR codes. Would you like - to install Barcode Scanner now? + Install barcode scanner app? + 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? Bus stop number