Commit ebff07a2 authored by Alex Catarineu's avatar Alex Catarineu Committed by Matthew Finkel
Browse files

Bug 40007: Port external helper app prompting

Together with the corresponding fenix patch, this allows all `startActivity`
that may open external apps to be replaced by `TorUtils.startActivityPrompt`.
parent 777a6c1d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ dependencies {

    implementation Dependencies.kotlin_stdlib
    implementation Dependencies.kotlin_coroutines
    implementation project(path: ':support-utils')

    testImplementation project(':support-test')

+2 −1
Original line number Diff line number Diff line
@@ -67,7 +67,8 @@ class AppLinksFeature(
                    loadUrlUseCase?.invoke(url, session, EngineSession.LoadUrlFlags.none())
                }

                if (!session.private || fragmentManager == null) {
                // useCases.openAppLink will now prompt: calling it directly to avoid prompting twice
                if (true || !session.private || fragmentManager == null) {
                    doOpenApp()
                    return
                }
+2 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.ktx.android.content.pm.isPackageInstalled
import mozilla.components.support.ktx.android.net.isHttpOrHttps
import java.net.URISyntaxException
import mozilla.components.support.utils.TorUtils

private const val EXTRA_BROWSER_FALLBACK_URL = "browser_fallback_url"
private const val MARKET_INTENT_URI_PACKAGE_PREFIX = "market://details?id="
@@ -200,7 +201,7 @@ class AppLinksUseCases(
                    if (launchInNewTask) {
                        it.flags = it.flags or Intent.FLAG_ACTIVITY_NEW_TASK
                    }
                    context.startActivity(it)
                    TorUtils.startActivityPrompt(context, it)
                } catch (e: ActivityNotFoundException) {
                    failedToLaunchAction()
                    Logger.error("failed to start third party app activity", e)
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import mozilla.components.support.ktx.android.content.addContact
import mozilla.components.support.ktx.android.content.share
import mozilla.components.support.ktx.kotlin.stripMailToProtocol
import mozilla.components.support.ktx.kotlin.takeOrReplace
import mozilla.components.support.utils.TorUtils

/**
 * A candidate for an item to be displayed in the context menu.
@@ -326,7 +327,7 @@ data class ContextMenuCandidate(
                    context.getString(R.string.mozac_feature_contextmenu_share_link)
                ).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

                context.startActivity(shareIntent)
                TorUtils.startActivityPrompt(context, shareIntent)
            }
        )

+2 −1
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.ktx.kotlin.sanitizeURL
import mozilla.components.support.ktx.kotlinx.coroutines.throttleLatest
import mozilla.components.support.utils.DownloadUtils
import mozilla.components.support.utils.TorUtils
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
@@ -870,7 +871,7 @@ abstract class AbstractFetchDownloadService : Service() {
            }

            return try {
                context.startActivity(newIntent)
                TorUtils.startActivityPrompt(context, newIntent)
                true
            } catch (error: ActivityNotFoundException) {
                false
Loading