|
|
@ -45,6 +45,8 @@ 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
|
|
|
|
|
|
|
|
import mozilla.components.support.ktx.android.content.call
|
|
|
|
|
|
|
|
import mozilla.components.support.ktx.android.content.email
|
|
|
|
import mozilla.components.support.ktx.android.content.share
|
|
|
|
import mozilla.components.support.ktx.android.content.share
|
|
|
|
import mozilla.components.support.ktx.kotlin.isUrl
|
|
|
|
import mozilla.components.support.ktx.kotlin.isUrl
|
|
|
|
import mozilla.components.support.ktx.kotlin.toNormalizedUrl
|
|
|
|
import mozilla.components.support.ktx.kotlin.toNormalizedUrl
|
|
|
@ -294,10 +296,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
|
|
|
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(
|
|
|
|
getSearchAdapter(components.core.store),
|
|
|
|
getSearchAdapter(components.core.store),
|
|
|
|
resources = context.resources
|
|
|
|
resources = context.resources,
|
|
|
|
) {
|
|
|
|
shareTextClicked = { share(it) },
|
|
|
|
share(it)
|
|
|
|
emailTextClicked = { email(it) },
|
|
|
|
}
|
|
|
|
callTextClicked = { call(it) },
|
|
|
|
|
|
|
|
actionSorter = ::actionSorter
|
|
|
|
|
|
|
|
)
|
|
|
|
}.asView()
|
|
|
|
}.asView()
|
|
|
|
TabsTray::class.java.name -> {
|
|
|
|
TabsTray::class.java.name -> {
|
|
|
|
val layout = LinearLayoutManager(context).apply {
|
|
|
|
val layout = LinearLayoutManager(context).apply {
|
|
|
@ -313,6 +317,20 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
|
|
|
else -> super.onCreateView(parent, name, context, attrs)
|
|
|
|
else -> super.onCreateView(parent, name, context, attrs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun actionSorter(actions: Array<String>) : Array<String> {
|
|
|
|
|
|
|
|
val order = hashMapOf<String, Int>()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
order["org.mozilla.geckoview.COPY"] = 0
|
|
|
|
|
|
|
|
order["CUSTOM_CONTEXT_MENU_SEARCH"] = 1
|
|
|
|
|
|
|
|
order["org.mozilla.geckoview.SELECT_ALL"] = 2
|
|
|
|
|
|
|
|
order["CUSTOM_CONTEXT_MENU_SHARE"] = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return actions.sortedBy { actionName ->
|
|
|
|
|
|
|
|
// Sort the actions in our preferred order, putting "other" actions unsorted at the end
|
|
|
|
|
|
|
|
order[actionName] ?: actions.size
|
|
|
|
|
|
|
|
}.toTypedArray()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final override fun onBackPressed() {
|
|
|
|
final override fun onBackPressed() {
|
|
|
|
supportFragmentManager.primaryNavigationFragment?.childFragmentManager?.fragments?.forEach {
|
|
|
|
supportFragmentManager.primaryNavigationFragment?.childFragmentManager?.fragments?.forEach {
|
|
|
|
if (it is UserInteractionHandler && it.onBackPressed()) {
|
|
|
|
if (it is UserInteractionHandler && it.onBackPressed()) {
|
|
|
|