From 57a7d5372b6046463f804a86110dd70107c0b021 Mon Sep 17 00:00:00 2001 From: Luca Stefani Date: Wed, 25 Jun 2025 17:52:15 +0530 Subject: [PATCH] fix browser not opening for qr code links --- .../opencamera/ext/PendingIntent.kt | 21 +++++++++++++++++++ .../opencamera/qr/QrImageAnalyzer.kt | 5 +++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/net/sourceforge/opencamera/ext/PendingIntent.kt diff --git a/app/src/main/java/net/sourceforge/opencamera/ext/PendingIntent.kt b/app/src/main/java/net/sourceforge/opencamera/ext/PendingIntent.kt new file mode 100644 index 000000000..1f5a8f303 --- /dev/null +++ b/app/src/main/java/net/sourceforge/opencamera/ext/PendingIntent.kt @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2024 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +package net.sourceforge.opencamera.ext + +import android.app.ActivityOptions +import android.app.PendingIntent +import android.os.Build + +fun PendingIntent.sendWithBalAllowed() = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + send( + ActivityOptions.makeBasic().setPendingIntentBackgroundActivityStartMode( + ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED + ).toBundle() + ) + } else { + send() + } \ No newline at end of file diff --git a/app/src/main/java/net/sourceforge/opencamera/qr/QrImageAnalyzer.kt b/app/src/main/java/net/sourceforge/opencamera/qr/QrImageAnalyzer.kt index cdb610ab1..b273b0754 100644 --- a/app/src/main/java/net/sourceforge/opencamera/qr/QrImageAnalyzer.kt +++ b/app/src/main/java/net/sourceforge/opencamera/qr/QrImageAnalyzer.kt @@ -43,6 +43,7 @@ import kotlinx.coroutines.withContext import net.sourceforge.opencamera.MyDebug import net.sourceforge.opencamera.R import net.sourceforge.opencamera.ext.px +import net.sourceforge.opencamera.ext.sendWithBalAllowed import zxingcpp.BarcodeReader import kotlin.reflect.cast @@ -188,7 +189,7 @@ class QrImageAnalyzer(private val activity: Activity, private val scope: Corouti with(textClassification.actions[0]) { bottomSheetDialogCardView.setOnClickListener { try { - actionIntent.send() + actionIntent.sendWithBalAllowed() } catch (e: PendingIntent.CanceledException) { Toast.makeText( activity, @@ -206,7 +207,7 @@ class QrImageAnalyzer(private val activity: Activity, private val scope: Corouti bottomSheetDialogActionsLayout.addView(inflateButton().apply { setOnClickListener { try { - action.actionIntent.send() + action.actionIntent.sendWithBalAllowed() } catch (e: PendingIntent.CanceledException) { Toast.makeText( activity, -- GitLab