commit 8688a5602fde55fe31790a2dff598d10477dcba4 parent 600f91cebb2b1dc940d7fdbc1ea9b1a70129323f Author: pstanciu <pstanciu@mozilla.com> Date: Mon, 24 Nov 2025 15:43:05 +0200 Revert "Bug 1979576 - If URL is updated then dismiss AppLinks redirect prompt. r=android-reviewers,tthibaud" on request from developer This reverts commit 8c2a1ee1f707dd80aeb1f6c12e56c84263f6b9bd. Diffstat:
4 files changed, 9 insertions(+), 44 deletions(-)
diff --git a/mobile/android/android-components/components/feature/app-links/src/main/java/mozilla/components/feature/app/links/AppLinksFeature.kt b/mobile/android/android-components/components/feature/app-links/src/main/java/mozilla/components/feature/app/links/AppLinksFeature.kt @@ -80,34 +80,19 @@ class AppLinksFeature( override fun start() { scope = store.flowScoped { flow -> flow.mapNotNull { state -> state.findTabOrCustomTabOrSelectedTab(sessionId) } - // monitor either appIntent OR url changes - .distinctUntilChangedBy { session -> - val content = session.content - content.appIntent to content.url + .distinctUntilChangedBy { + it.content.appIntent } .collect { sessionState -> - val content = sessionState.content - val intent = content.appIntent - val url = content.url - - if (intent != null) { + sessionState.content.appIntent?.let { handleAppIntent( sessionState = sessionState, - url = intent.url, - appIntent = intent.appIntent, - fallbackUrl = intent.fallbackUrl, - appName = intent.appName, + url = it.url, + appIntent = it.appIntent, + fallbackUrl = it.fallbackUrl, + appName = it.appName, ) - - // Clear the consumed app intent so we don't re-handle it store.dispatch(ContentAction.ConsumeAppIntentAction(sessionState.id)) - } else { - // No appIntent present, but url changed, remove the external application prompt - findPreviousDialogFragment()?.let { - if (it.triggerUrl != url) { - fragmentManager?.beginTransaction()?.remove(it)?.commit() - } - } } } } @@ -213,13 +198,7 @@ class AppLinksFeature( return } - getOrCreateDialog( - isPrivate = isPrivate, - isWallet = isWallet, - triggerUrl = sessionState.content.url, - url = url, - targetAppName = appName, - ).apply { + getOrCreateDialog(isPrivate, isWallet, url, appName).apply { onConfirmRedirect = { isCheckboxTicked -> if (isCheckboxTicked) { alwaysOpenCheckboxAction?.invoke() @@ -236,7 +215,6 @@ class AppLinksFeature( internal fun getOrCreateDialog( isPrivate: Boolean, isWallet: Boolean, - triggerUrl: String?, url: String, targetAppName: String?, ): RedirectDialogFragment { @@ -276,7 +254,6 @@ class AppLinksFeature( dialogMessageString = dialogMessage, showCheckbox = if (isPrivate || isWallet) false else alwaysOpenCheckboxAction != null, maxSuccessiveDialogMillisLimit = MAX_SUCCESSIVE_DIALOG_MILLIS_LIMIT, - triggerUrl = triggerUrl, ) } diff --git a/mobile/android/android-components/components/feature/app-links/src/main/java/mozilla/components/feature/app/links/RedirectDialogFragment.kt b/mobile/android/android-components/components/feature/app-links/src/main/java/mozilla/components/feature/app/links/RedirectDialogFragment.kt @@ -13,10 +13,6 @@ import androidx.fragment.app.DialogFragment * Be mindful to call [onConfirmRedirect] when you want to open the linked app. */ abstract class RedirectDialogFragment : DialogFragment() { - /** - * The URL that triggered the dialog. - */ - open val triggerUrl: String? = null /** * A callback to trigger a redirect action. Call it when you are ready to open the linked app. For instance, diff --git a/mobile/android/android-components/components/feature/app-links/src/main/java/mozilla/components/feature/app/links/SimpleRedirectDialogFragment.kt b/mobile/android/android-components/components/feature/app-links/src/main/java/mozilla/components/feature/app/links/SimpleRedirectDialogFragment.kt @@ -38,9 +38,6 @@ class SimpleRedirectDialogFragment( @VisibleForTesting internal var testingContext: Context? = null - override val triggerUrl: String? - get() = arguments?.getString(KEY_TRIGGER_URL) - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { fun getBuilder(themeID: Int): MaterialAlertDialogBuilder { val context = testingContext ?: requireContext() @@ -127,7 +124,6 @@ class SimpleRedirectDialogFragment( cancelable: Boolean = false, showCheckbox: Boolean = false, maxSuccessiveDialogMillisLimit: Int = TIME_SHOWN_OFFSET_MILLIS, - triggerUrl: String? = null, ): RedirectDialogFragment { val fragment = SimpleRedirectDialogFragment(maxSuccessiveDialogMillisLimit) val arguments = fragment.arguments ?: Bundle() @@ -150,8 +146,6 @@ class SimpleRedirectDialogFragment( putBoolean(KEY_CANCELABLE, cancelable) putBoolean(KEY_CHECKBOX, showCheckbox) - - putString(KEY_TRIGGER_URL, triggerUrl) } fragment.arguments = arguments @@ -176,8 +170,6 @@ class SimpleRedirectDialogFragment( private const val KEY_CHECKBOX = "KEY_CHECKBOX" - private const val KEY_TRIGGER_URL = "KEY_TRIGGER_URL" - private const val TIME_SHOWN_OFFSET_MILLIS = 1000 internal const val VIEW_ID = 111 diff --git a/mobile/android/android-components/components/feature/app-links/src/test/java/mozilla/components/feature/app/links/AppLinksFeatureTest.kt b/mobile/android/android-components/components/feature/app-links/src/test/java/mozilla/components/feature/app/links/AppLinksFeatureTest.kt @@ -380,7 +380,7 @@ class AppLinksFeatureTest { verify(mockDialog).showNow(eq(mockFragmentManager), anyString()) - doReturn(mockDialog).`when`(feature).getOrCreateDialog(false, false, webUrl, "", null) + doReturn(mockDialog).`when`(feature).getOrCreateDialog(false, false, "", null) doReturn(mockDialog).`when`(mockFragmentManager).findFragmentByTag(RedirectDialogFragment.FRAGMENT_TAG) feature.handleAppIntent(tab, intentUrl, mock(), null, null) verify(mockDialog, times(1)).showNow(mockFragmentManager, RedirectDialogFragment.FRAGMENT_TAG)