Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8168ce3c authored by Luca Stefani's avatar Luca Stefani Committed by Mohammed Althaf T
Browse files

fix browser not opening for qr code links

parent d326ab90
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
/*
 * 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
+3 −2
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import net.sourceforge.opencamera.MyDebug
import net.sourceforge.opencamera.R
import net.sourceforge.opencamera.ext.getThemeColor
import net.sourceforge.opencamera.ext.px
import net.sourceforge.opencamera.ext.sendWithBalAllowed
import zxingcpp.BarcodeReader
import kotlin.reflect.cast

@@ -189,7 +190,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,
@@ -207,7 +208,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,