|
|
|
@ -20,6 +20,7 @@ import mozilla.components.feature.awesomebar.provider.SearchSuggestionProvider
|
|
|
|
|
import mozilla.components.feature.awesomebar.provider.SessionSuggestionProvider
|
|
|
|
|
import mozilla.components.feature.search.SearchUseCases
|
|
|
|
|
import mozilla.components.feature.session.SessionUseCases
|
|
|
|
|
import mozilla.components.feature.syncedtabs.SyncedTabsStorageSuggestionProvider
|
|
|
|
|
import mozilla.components.feature.tabs.TabsUseCases
|
|
|
|
|
import mozilla.components.support.ktx.android.content.getColorFromAttr
|
|
|
|
|
import org.mozilla.fenix.HomeActivity
|
|
|
|
@ -32,6 +33,7 @@ import org.mozilla.fenix.search.SearchFragmentState
|
|
|
|
|
/**
|
|
|
|
|
* View that contains and configures the BrowserAwesomeBar
|
|
|
|
|
*/
|
|
|
|
|
@Suppress("LargeClass")
|
|
|
|
|
class AwesomeBarView(
|
|
|
|
|
private val activity: HomeActivity,
|
|
|
|
|
val interactor: AwesomeBarInteractor,
|
|
|
|
@ -41,6 +43,7 @@ class AwesomeBarView(
|
|
|
|
|
private val historyStorageProvider: HistoryStorageSuggestionProvider
|
|
|
|
|
private val shortcutsEnginePickerProvider: ShortcutsSuggestionProvider
|
|
|
|
|
private val bookmarksStorageSuggestionProvider: BookmarksStorageSuggestionProvider
|
|
|
|
|
private val syncedTabsStorageSuggestionProvider: SyncedTabsStorageSuggestionProvider
|
|
|
|
|
private val defaultSearchSuggestionProvider: SearchSuggestionProvider
|
|
|
|
|
private val defaultSearchActionProvider: SearchActionProvider
|
|
|
|
|
private val searchSuggestionProviderMap: MutableMap<SearchEngine, List<AwesomeBar.SuggestionProvider>>
|
|
|
|
@ -123,6 +126,13 @@ class AwesomeBarView(
|
|
|
|
|
engine = engineForSpeculativeConnects
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
syncedTabsStorageSuggestionProvider =
|
|
|
|
|
SyncedTabsStorageSuggestionProvider(
|
|
|
|
|
components.backgroundServices.syncedTabsStorage,
|
|
|
|
|
components.useCases.tabsUseCases.addTab,
|
|
|
|
|
components.core.icons
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val searchBitmap = getDrawable(activity, R.drawable.ic_search)!!.apply {
|
|
|
|
|
colorFilter = createBlendModeColorFilterCompat(primaryTextColor, SRC_IN)
|
|
|
|
|
}.toBitmap()
|
|
|
|
@ -204,6 +214,7 @@ class AwesomeBarView(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Suppress("ComplexMethod")
|
|
|
|
|
private fun getProvidersToAdd(state: SearchFragmentState): MutableSet<AwesomeBar.SuggestionProvider> {
|
|
|
|
|
val providersToAdd = mutableSetOf<AwesomeBar.SuggestionProvider>()
|
|
|
|
|
|
|
|
|
@ -219,6 +230,10 @@ class AwesomeBarView(
|
|
|
|
|
providersToAdd.addAll(getSelectedSearchSuggestionProvider(state))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (state.showSyncedTabsSuggestions) {
|
|
|
|
|
providersToAdd.add(syncedTabsStorageSuggestionProvider)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (activity.browsingModeManager.mode == BrowsingMode.Normal) {
|
|
|
|
|
providersToAdd.add(sessionProvider)
|
|
|
|
|
}
|
|
|
|
@ -243,6 +258,10 @@ class AwesomeBarView(
|
|
|
|
|
providersToRemove.addAll(getSelectedSearchSuggestionProvider(state))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!state.showSyncedTabsSuggestions) {
|
|
|
|
|
providersToRemove.add(syncedTabsStorageSuggestionProvider)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (activity.browsingModeManager.mode == BrowsingMode.Private) {
|
|
|
|
|
providersToRemove.add(sessionProvider)
|
|
|
|
|
}
|
|
|
|
|