Commit 9ed68736 authored by Alex Catarineu's avatar Alex Catarineu Committed by Pier Angelo Vendrame
Browse files

TB 34378: [android] 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`.

Originally, android-components#40007 and fenix#34378.
parent cb072ba0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ dependencies {
    implementation project(':ui-widgets')

    implementation libs.kotlin.coroutines
    implementation project(path: ':support-utils')

    testImplementation project(':support-test')
    testImplementation project(':support-test-libstate')
+1 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ class AppLinksFeature(
        isAuthenticationFlow: Boolean,
        fragmentManager: FragmentManager?,
    ): Boolean {
        val shouldShowPrompt = isPrivate || shouldPrompt()
        val shouldShowPrompt = true
        return fragmentManager == null || !shouldShowPrompt || isAuthenticationFlow
    }

+2 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import mozilla.components.support.utils.BrowsersCache
import mozilla.components.support.utils.ext.queryIntentActivitiesCompat
import mozilla.components.support.utils.ext.resolveActivityCompat
import java.net.URISyntaxException
import mozilla.components.support.utils.TorUtils

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal const val EXTRA_BROWSER_FALLBACK_URL = "browser_fallback_url"
@@ -258,7 +259,7 @@ class AppLinksUseCases(
                    if (launchInNewTask) {
                        it.flags = it.flags or Intent.FLAG_ACTIVITY_NEW_TASK
                    }
                    context.startActivity(it)
                    TorUtils.startActivityPrompt(context, it)
                } catch (e: Exception) {
                    when (e) {
                        is ActivityNotFoundException, is SecurityException, is NullPointerException -> {
+3 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import mozilla.components.support.ktx.kotlin.stripMailToProtocol
import mozilla.components.support.ktx.kotlin.takeOrReplace
import mozilla.components.ui.widgets.DefaultSnackbarDelegate
import mozilla.components.ui.widgets.SnackbarDelegate
import mozilla.components.support.utils.TorUtils

/**
 * A candidate for an item to be displayed in the context menu.
@@ -497,7 +498,8 @@ data class ContextMenuCandidate(
                }

                try {
                    context.startActivity(
                    TorUtils.startActivityPrompt(
                        context,
                        intent.createChooserExcludingCurrentApp(
                            context,
                            context.getString(R.string.mozac_feature_contextmenu_share_link),
+2 −1
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ import mozilla.components.support.ktx.kotlinx.coroutines.throttleLatest
import mozilla.components.support.utils.DownloadUtils
import mozilla.components.support.utils.ext.registerReceiverCompat
import mozilla.components.support.utils.ext.stopForegroundCompat
import mozilla.components.support.utils.TorUtils
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
@@ -1074,7 +1075,7 @@ abstract class AbstractFetchDownloadService : Service() {
            )

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