2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

[fenix] Closes https://github.com/mozilla-mobile/fenix/issues/884 - Set and use default search engine

This commit is contained in:
Emily Kager 2019-03-12 10:17:15 -07:00 committed by Emily Kager
parent e274a0a4fe
commit f3933d34e6
3 changed files with 8 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import android.content.Context
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import mozilla.components.browser.search.SearchEngineManager import mozilla.components.browser.search.SearchEngineManager
import org.mozilla.fenix.utils.Settings
/** /**
* Component group for all search engine integration related functionality. * Component group for all search engine integration related functionality.
@ -23,6 +24,10 @@ class Search(private val context: Context) {
GlobalScope.launch { GlobalScope.launch {
load(context).await() load(context).await()
} }
defaultSearchEngine = getDefaultSearchEngine(
context,
Settings.getInstance(context).defaultSearchEngineName
)
} }
} }
} }

View File

@ -112,8 +112,7 @@ class HomeFragment : Fragment() {
}) })
val searchIcon = requireComponents.search.searchEngineManager.getDefaultSearchEngine( val searchIcon = requireComponents.search.searchEngineManager.getDefaultSearchEngine(
requireContext(), requireContext()
Settings.getInstance(requireContext()).defaultSearchEngineName
).let { ).let {
BitmapDrawable(resources, it.icon) BitmapDrawable(resources, it.icon)
} }

View File

@ -10,6 +10,7 @@ import android.widget.CompoundButton
import android.widget.RadioGroup import android.widget.RadioGroup
import androidx.preference.PreferenceViewHolder import androidx.preference.PreferenceViewHolder
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.utils.Settings
class RadioSearchEngineListPreference : SearchEngineListPreference, class RadioSearchEngineListPreference : SearchEngineListPreference,
@ -45,6 +46,7 @@ class RadioSearchEngineListPreference : SearchEngineListPreference,
} }
val newDefaultEngine = searchEngines[checkedId] val newDefaultEngine = searchEngines[checkedId]
context.components.search.searchEngineManager.defaultSearchEngine = newDefaultEngine
Settings.getInstance(group.context).setDefaultSearchEngineByName(newDefaultEngine.name) Settings.getInstance(group.context).setDefaultSearchEngineByName(newDefaultEngine.name)
} }
} }