commit 73a326b1dcee27c2b64f081aff795ffef650052f Author: Fabio Mazza Date: Sun May 31 11:36:13 2026 +0200 Change barcode scanner app Summary: The old Barcode Scanner app is dead, switch the app to install on the device to Binary Eye (github.com/markusfisch/BinaryEye), which like this one is present on both F-Droid and Play Store. (Fix T1447) If the device has no store app, open the link to the F-Droid page. Also, change messages so they are nicer Test Plan: If there is NOT a system app for scanning QR which is impossible to remove: - Remove all QR scanner apps on device - Open app and tap on "Scan QR code" - Say yes to the dialog - Check that you land on Binary Eye app either on F-Droid or Play Store Reviewers: #libre_busto_hackers, valerio.bozzolan Reviewed By: #libre_busto_hackers, valerio.bozzolan Subscribers: valerio.bozzolan Project Tags: #libre_busto Maniphest Tasks: T1447 Differential Revision: https://gitpull.it/D244 diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/BarcodeFragment.kt b/app/src/main/java/it/reyboz/bustorino/fragments/BarcodeFragment.kt index 199a9e2..6f21ecb 100644 --- a/app/src/main/java/it/reyboz/bustorino/fragments/BarcodeFragment.kt +++ b/app/src/main/java/it/reyboz/bustorino/fragments/BarcodeFragment.kt @@ -41,10 +41,11 @@ abstract class BarcodeFragment : ScreenBaseFragment(){ 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) } 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..ceaacce 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.markusfisch.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..d5d12e3 100644 --- a/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanUtils.java +++ b/app/src/main/java/it/reyboz/bustorino/middleware/BarcodeScanUtils.java @@ -13,6 +13,7 @@ import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.Barrier; import androidx.fragment.app.Fragment; import java.util.List; @@ -25,34 +26,27 @@ 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); + //Open the browser on the F-Droid web page + intent = new Intent(Intent.ACTION_VIEW, + Uri.parse("https://f-droid.org/en/packages/"+BarcodeScanOptions.BINARY_EYE_PACKAGE+"/")); + context.startActivity(intent); } }); downloadDialog.setNegativeButton(R.string.no, null); diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index f7df649..ae15f99 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -8,8 +8,8 @@ No Prossimo Precedente - Installare Barcode Scanner? - Questa azione richiede un\'altra app per scansionare i codici QR. Vuoi installare Barcode Scanner? + Necessaria app per leggere i codici QR + Questa azione richiede un\'altra app per scansionare i codici QR, ma non è stata trovata sul dispositivo. Vuoi installare Binary Eye? Numero fermata Nome fermata Inserisci il numero della fermata @@ -37,7 +37,7 @@ Scegli la fermata… Matricola %1$s Nessun passaggio - Nessun QR code trovato, prova ad usare un\'altra app + Nessun QR code trovato, riprova Preferiti Aiuto Informazioni diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2965fd1..dc6428d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,9 +14,10 @@ Next Previous - Install Barcode Scanner? - This application requires an app to scan the QR codes. Would you like - to install Barcode Scanner now? + Barcode scanner app is needed + + This functionality requires another app to scan the QR codes, which has not been found on the device. We suggest using Binary Eye, which + is open source software, would you like to install it now? Bus stop number @@ -50,7 +51,7 @@ Stop %1$s Vehicle %1$s No timetable found - No QR code found, try using another app to scan + No QR code found, retry Scan QR code at the bus stop Unexpected internal error, cannot extract data from GTT/5T website Help