Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Close #9960: Launch URI in Fenix if failed to launch in custom tab
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketsroger committed Apr 15, 2020
1 parent aef827e commit aabb775
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
8 changes: 8 additions & 0 deletions app/src/main/java/org/mozilla/fenix/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ enum class ReleaseChannel {

val isFenix: Boolean
get() = !isFennec

val deepLinkScheme: String
get() = when (this) {
FenixNightly -> "fenix-nightly"
FennecNightly -> "fenix-beta"
FenixDebug -> "fenix-dev"
else -> "fenix"
}
}

object Config {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.mozilla.fenix.customtabs

import android.content.Context
import android.content.Intent
import android.view.View
import androidx.navigation.fragment.navArgs
import kotlinx.android.synthetic.main.component_browser_top_toolbar.*
Expand All @@ -28,13 +29,13 @@ import mozilla.components.lib.state.ext.consumeFrom
import mozilla.components.support.base.feature.UserInteractionHandler
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import mozilla.components.support.ktx.android.arch.lifecycle.addObservers
import org.mozilla.fenix.Config
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.browser.BaseBrowserFragment
import org.mozilla.fenix.browser.CustomTabContextMenuCandidate
import org.mozilla.fenix.browser.FenixSnackbarDelegate
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents
Expand Down Expand Up @@ -85,15 +86,14 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), UserInteractionHandler
components.core.store,
customTabSessionId
) { uri ->
components.analytics.crashReporter.submitCaughtException(Exception("Unknown scheme error $uri"))
FenixSnackbar.make(
view = view.swipeRefresh,
duration = FenixSnackbar.LENGTH_LONG,
isDisplayedWithBrowserToolbar = true
).apply {
setText(resources.getString(R.string.unknown_scheme_error_message))
setAppropriateBackground(true)
}.show()
val intent = Intent.parseUri("${Config.channel.deepLinkScheme}://open?url=$uri", 0)
if (intent.action == Intent.ACTION_VIEW) {
intent.addCategory(Intent.CATEGORY_BROWSABLE)
intent.component = null
intent.selector = null
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
activity.startActivity(intent)
},
owner = this,
view = view
Expand Down

0 comments on commit aabb775

Please sign in to comment.