1
0
Fork 0

For #6849 - Properly select a new default search engine when you delete the current one

Co-authored-by: Severin Rudie <Baron-Severin@users.noreply.github.com>
master
Jeff Boek 2019-12-04 15:00:14 -08:00
parent eb6e6b774f
commit 781b141bc7
1 changed files with 3 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import mozilla.components.browser.search.provider.SearchEngineProvider
import mozilla.components.browser.search.provider.filter.SearchEngineFilter
import mozilla.components.browser.search.provider.localization.LocaleSearchLocalizationProvider
import org.mozilla.fenix.ext.settings
import java.util.Locale
@SuppressWarnings("TooManyFunctions")
class FenixSearchEngineProvider(
@ -49,7 +50,7 @@ class FenixSearchEngineProvider(
val engines = installedSearchEngines(context)
val selectedName = context.settings().defaultSearchEngineName
return engines.list.find { it.name == selectedName } ?: engines.list.first()
return engines.list.find { it.name == selectedName } ?: engines.default ?: engines.list.first()
}
fun installedSearchEngines(context: Context): SearchEngineList = runBlocking {
@ -59,7 +60,7 @@ class FenixSearchEngineProvider(
engineList.copy(
list = engineList.list.filter {
installedIdentifiers.contains(it.identifier)
},
}.sortedBy { it.name.toLowerCase(Locale.getDefault()) },
default = engineList.default?.let {
if (installedIdentifiers.contains(it.identifier)) {
it