Bug 1800700 - Add default search suggest header
This commit is contained in:
parent
52b4a1ebfa
commit
775258db6b
|
@ -10,6 +10,7 @@ import androidx.core.graphics.BlendModeCompat.SRC_IN
|
|||
import androidx.core.graphics.drawable.toBitmap
|
||||
import mozilla.components.browser.state.search.SearchEngine
|
||||
import mozilla.components.browser.state.state.searchEngines
|
||||
import mozilla.components.browser.state.state.selectedOrDefaultSearchEngine
|
||||
import mozilla.components.concept.awesomebar.AwesomeBar
|
||||
import mozilla.components.concept.engine.EngineSession
|
||||
import mozilla.components.feature.awesomebar.provider.BookmarksStorageSuggestionProvider
|
||||
|
@ -176,6 +177,7 @@ class AwesomeBarView(
|
|||
BrowsingMode.Normal -> false
|
||||
BrowsingMode.Private -> true
|
||||
},
|
||||
suggestionsHeader = getSearchEngineSuggestionsHeader(),
|
||||
)
|
||||
|
||||
defaultSearchActionProvider =
|
||||
|
@ -184,6 +186,7 @@ class AwesomeBarView(
|
|||
searchUseCase = searchUseCase,
|
||||
icon = searchBitmap,
|
||||
showDescription = false,
|
||||
suggestionsHeader = getSearchEngineSuggestionsHeader(),
|
||||
)
|
||||
|
||||
shortcutsEnginePickerProvider =
|
||||
|
@ -207,6 +210,25 @@ class AwesomeBarView(
|
|||
searchSuggestionProviderMap = HashMap()
|
||||
}
|
||||
|
||||
private fun getSearchEngineSuggestionsHeader(): String? {
|
||||
val searchState = activity.components.core.store.state.search
|
||||
var searchEngine = searchState.selectedOrDefaultSearchEngine?.name
|
||||
|
||||
if (!searchEngine.isNullOrEmpty()) {
|
||||
searchEngine = when (searchEngine) {
|
||||
GOOGLE_SEARCH_ENGINE_NAME -> activity.getString(
|
||||
R.string.google_search_engine_suggestion_header,
|
||||
)
|
||||
else -> activity.getString(
|
||||
R.string.other_default_search_engine_suggestion_header,
|
||||
searchEngine,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return searchEngine
|
||||
}
|
||||
|
||||
fun update(state: SearchFragmentState) {
|
||||
// Do not make suggestions based on user's current URL unless it's a search shortcut
|
||||
if (state.query.isNotEmpty() && state.query == state.url && !state.showSearchShortcuts) {
|
||||
|
@ -355,6 +377,8 @@ class AwesomeBarView(
|
|||
companion object {
|
||||
// Maximum number of suggestions returned.
|
||||
const val METADATA_SUGGESTION_LIMIT = 3
|
||||
|
||||
const val GOOGLE_SEARCH_ENGINE_NAME = "Google"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1829,6 +1829,14 @@
|
|||
<!-- Text for the snackbar to confirm auto-close is enabled for inactive tabs -->
|
||||
<string name="inactive_tabs_auto_close_message_snackbar">Auto-close enabled</string>
|
||||
|
||||
<!-- Awesome bar suggestion's headers -->
|
||||
<!-- Search suggestions title for Firefox Suggest. -->
|
||||
<string name="firefox_suggest_header">Firefox Suggest</string>
|
||||
<!-- Title for search suggestions when Google is the default search suggestion engine. -->
|
||||
<string name="google_search_engine_suggestion_header">Google Search</string>
|
||||
<!-- Title for search suggestions when the default search suggestion engine is anything other than Google. The first parameter is default search engine name. -->
|
||||
<string name="other_default_search_engine_suggestion_header">%s search</string>
|
||||
|
||||
<!-- Default browser experiment -->
|
||||
<string name="default_browser_experiment_card_text">Set links from websites, emails, and messages to open automatically in Firefox.</string>
|
||||
|
||||
|
@ -1866,7 +1874,6 @@
|
|||
<string name="experiments_snackbar">Enable telemetry to send data.</string>
|
||||
<!-- Snackbar button text to navigate to telemetry settings.-->
|
||||
<string name="experiments_snackbar_button">Go to settings</string>
|
||||
<string name="firefox_suggest_header">Firefox Suggest</string>
|
||||
|
||||
<!-- Accessibility services actions labels. These will be appended to accessibility actions like "Double tap to.." but not by or applications but by services like Talkback. -->
|
||||
<!-- Action label for elements that can be collapsed if interacting with them. Talkback will append this to say "Double tap to collapse". -->
|
||||
|
|
Loading…
Reference in New Issue