mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
[fenix] Fixes https://github.com/mozilla-mobile/fenix/issues/9056 - Start Fenix activity on search in external app (https://github.com/mozilla-mobile/fenix/pull/10932)
This commit is contained in:
parent
5b0863076e
commit
d7b772a13f
@ -32,10 +32,13 @@ import mozilla.components.browser.search.SearchEngine
|
|||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.browser.state.state.WebExtensionState
|
import mozilla.components.browser.state.state.WebExtensionState
|
||||||
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
import mozilla.components.browser.tabstray.BrowserTabsTray
|
import mozilla.components.browser.tabstray.BrowserTabsTray
|
||||||
import mozilla.components.concept.engine.EngineView
|
import mozilla.components.concept.engine.EngineView
|
||||||
import mozilla.components.concept.tabstray.TabsTray
|
import mozilla.components.concept.tabstray.TabsTray
|
||||||
import mozilla.components.feature.contextmenu.ext.DefaultSelectionActionDelegate
|
import mozilla.components.feature.contextmenu.DefaultSelectionActionDelegate
|
||||||
|
import mozilla.components.feature.search.BrowserStoreSearchAdapter
|
||||||
|
import mozilla.components.feature.search.SearchAdapter
|
||||||
import mozilla.components.service.fxa.sync.SyncReason
|
import mozilla.components.service.fxa.sync.SyncReason
|
||||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||||
import mozilla.components.support.ktx.android.arch.lifecycle.addObservers
|
import mozilla.components.support.ktx.android.arch.lifecycle.addObservers
|
||||||
@ -63,6 +66,7 @@ import org.mozilla.fenix.home.HomeFragmentDirections
|
|||||||
import org.mozilla.fenix.home.intent.CrashReporterIntentProcessor
|
import org.mozilla.fenix.home.intent.CrashReporterIntentProcessor
|
||||||
import org.mozilla.fenix.home.intent.DeepLinkIntentProcessor
|
import org.mozilla.fenix.home.intent.DeepLinkIntentProcessor
|
||||||
import org.mozilla.fenix.home.intent.OpenBrowserIntentProcessor
|
import org.mozilla.fenix.home.intent.OpenBrowserIntentProcessor
|
||||||
|
import org.mozilla.fenix.home.intent.OpenSpecificTabIntentProcessor
|
||||||
import org.mozilla.fenix.home.intent.SpeechProcessingIntentProcessor
|
import org.mozilla.fenix.home.intent.SpeechProcessingIntentProcessor
|
||||||
import org.mozilla.fenix.home.intent.StartSearchIntentProcessor
|
import org.mozilla.fenix.home.intent.StartSearchIntentProcessor
|
||||||
import org.mozilla.fenix.library.bookmarks.BookmarkFragmentDirections
|
import org.mozilla.fenix.library.bookmarks.BookmarkFragmentDirections
|
||||||
@ -83,7 +87,6 @@ import org.mozilla.fenix.theme.DefaultThemeManager
|
|||||||
import org.mozilla.fenix.theme.ThemeManager
|
import org.mozilla.fenix.theme.ThemeManager
|
||||||
import org.mozilla.fenix.utils.BrowsersCache
|
import org.mozilla.fenix.utils.BrowsersCache
|
||||||
import org.mozilla.fenix.utils.RunWhenReadyQueue
|
import org.mozilla.fenix.utils.RunWhenReadyQueue
|
||||||
import org.mozilla.fenix.home.intent.OpenSpecificTabIntentProcessor
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main activity of the application. The application is primarily a single Activity (this one)
|
* The main activity of the application. The application is primarily a single Activity (this one)
|
||||||
@ -226,8 +229,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
|
|||||||
): View? = when (name) {
|
): View? = when (name) {
|
||||||
EngineView::class.java.name -> components.core.engine.createView(context, attrs).apply {
|
EngineView::class.java.name -> components.core.engine.createView(context, attrs).apply {
|
||||||
selectionActionDelegate = DefaultSelectionActionDelegate(
|
selectionActionDelegate = DefaultSelectionActionDelegate(
|
||||||
store = components.core.store,
|
getSearchAdapter(components.core.store),
|
||||||
context = context,
|
resources = context.resources,
|
||||||
appName = getString(R.string.app_name)
|
appName = getString(R.string.app_name)
|
||||||
) {
|
) {
|
||||||
share(it)
|
share(it)
|
||||||
@ -269,6 +272,9 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
|
|||||||
super.onUserLeaveHint()
|
super.onUserLeaveHint()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun getSearchAdapter(store: BrowserStore): SearchAdapter =
|
||||||
|
BrowserStoreSearchAdapter(store)
|
||||||
|
|
||||||
protected open fun getBreadcrumbMessage(destination: NavDestination): String {
|
protected open fun getBreadcrumbMessage(destination: NavDestination): String {
|
||||||
val fragmentName = resources.getResourceEntryName(destination.id)
|
val fragmentName = resources.getResourceEntryName(destination.id)
|
||||||
return "Changing to fragment $fragmentName, isCustomTab: false"
|
return "Changing to fragment $fragmentName, isCustomTab: false"
|
||||||
|
@ -4,15 +4,19 @@
|
|||||||
|
|
||||||
package org.mozilla.fenix.customtabs
|
package org.mozilla.fenix.customtabs
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import androidx.navigation.NavDestination
|
import androidx.navigation.NavDestination
|
||||||
import androidx.navigation.NavDirections
|
import androidx.navigation.NavDirections
|
||||||
import mozilla.components.browser.session.runWithSession
|
import mozilla.components.browser.session.runWithSession
|
||||||
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
import mozilla.components.concept.engine.manifest.WebAppManifestParser
|
import mozilla.components.concept.engine.manifest.WebAppManifestParser
|
||||||
import mozilla.components.feature.intent.ext.getSessionId
|
import mozilla.components.feature.intent.ext.getSessionId
|
||||||
import mozilla.components.feature.pwa.ext.getWebAppManifest
|
import mozilla.components.feature.pwa.ext.getWebAppManifest
|
||||||
|
import mozilla.components.feature.search.SearchAdapter
|
||||||
import mozilla.components.support.utils.SafeIntent
|
import mozilla.components.support.utils.SafeIntent
|
||||||
import org.mozilla.fenix.BrowserDirection
|
import org.mozilla.fenix.BrowserDirection
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
|
import org.mozilla.fenix.IntentReceiverActivity
|
||||||
import org.mozilla.fenix.NavGraphDirections
|
import org.mozilla.fenix.NavGraphDirections
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
@ -24,6 +28,12 @@ import java.security.InvalidParameterException
|
|||||||
*/
|
*/
|
||||||
open class ExternalAppBrowserActivity : HomeActivity() {
|
open class ExternalAppBrowserActivity : HomeActivity() {
|
||||||
|
|
||||||
|
private val openInFenixIntent by lazy {
|
||||||
|
Intent(this, IntentReceiverActivity::class.java).apply {
|
||||||
|
action = Intent.ACTION_VIEW
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final override fun getBreadcrumbMessage(destination: NavDestination): String {
|
final override fun getBreadcrumbMessage(destination: NavDestination): String {
|
||||||
val fragmentName = resources.getResourceEntryName(destination.id)
|
val fragmentName = resources.getResourceEntryName(destination.id)
|
||||||
return "Changing to fragment $fragmentName, isCustomTab: true"
|
return "Changing to fragment $fragmentName, isCustomTab: true"
|
||||||
@ -57,6 +67,19 @@ open class ExternalAppBrowserActivity : HomeActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getSearchAdapter(store: BrowserStore): SearchAdapter {
|
||||||
|
val baseAdapter = super.getSearchAdapter(store)
|
||||||
|
return object : SearchAdapter {
|
||||||
|
|
||||||
|
override fun sendSearch(isPrivate: Boolean, text: String) {
|
||||||
|
baseAdapter.sendSearch(isPrivate, text)
|
||||||
|
startActivity(openInFenixIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isPrivateSession() = baseAdapter.isPrivateSession()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user