Verified Commit 8e5d33f7 authored by Alex Catarineu's avatar Alex Catarineu Committed by ma1
Browse files

Bug 40007: [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`.
parent 5b8cc87b
Loading
Loading
Loading
Loading
+1 −0
Changes for mobile/android/android-components/components/feature/app-links/build.gradle: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ dependencies {
    implementation project(':ui-widgets')

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

    testImplementation project(':support-test')
    testImplementation project(':support-test-libstate')
+1 −1
Changes for mobile/android/android-components/components/feature/app-links/src/main/java/mozilla/components/feature/app/links/AppLinksFeature.kt: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ class AppLinksFeature(
        }

        @Suppress("ComplexCondition")
        if (isSameCallerAndApp(tab, appIntent) || (!tab.content.private && !shouldPrompt()) ||
        if (isSameCallerAndApp(tab, appIntent) || (true || !tab.content.private && !shouldPrompt()) ||
            fragmentManager == null
        ) {
            doOpenApp()
+2 −1
Changes for mobile/android/android-components/components/feature/app-links/src/main/java/mozilla/components/feature/app/links/AppLinksUseCases.kt: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import java.lang.Exception
import java.lang.NullPointerException
import java.lang.NumberFormatException
import java.net.URISyntaxException
import mozilla.components.support.utils.TorUtils

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal const val EXTRA_BROWSER_FALLBACK_URL = "browser_fallback_url"
@@ -232,7 +233,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
Changes for mobile/android/android-components/components/feature/contextmenu/src/main/java/mozilla/components/feature/contextmenu/ContextMenuCandidate.kt: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -26,6 +26,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.
@@ -491,7 +492,8 @@ data class ContextMenuCandidate(
                    flags = Intent.FLAG_ACTIVITY_NEW_TASK
                    putExtra(Intent.EXTRA_TEXT, hitResult.getLink())
                }
                context.startActivity(
                TorUtils.startActivityPrompt(
                    context,
                    intent.createChooserExcludingCurrentApp(
                        context,
                        context.getString(R.string.mozac_feature_contextmenu_share_link),
+2 −1
Changes for mobile/android/android-components/components/feature/downloads/src/main/java/mozilla/components/feature/downloads/AbstractFetchDownloadService.kt: 2 added lines, 1 removed line.
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
@@ -984,7 +985,7 @@ abstract class AbstractFetchDownloadService : Service() {
            val newIntent = createOpenFileIntent(applicationContext, download)

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