2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

For #3544 - Set SearchSuggestions preference value from settings

This commit is contained in:
Emily Kager 2019-06-18 15:00:30 -07:00 committed by Jeff Boek
parent ab6101b0f4
commit b1102c2e76
3 changed files with 16 additions and 10 deletions

View File

@ -128,7 +128,7 @@ class AwesomeBarUIView(
components.core.icons
)
if (Settings.getInstance(container.context).showSearchSuggestions()) {
if (Settings.getInstance(container.context).showSearchSuggestions) {
val searchDrawable = getDrawable(R.drawable.ic_search)
searchDrawable?.setColorFilter(
ContextCompat.getColor(
@ -171,7 +171,7 @@ class AwesomeBarUIView(
}
private fun showSuggestionProviders() {
if (Settings.getInstance(container.context).showSearchSuggestions()) {
if (Settings.getInstance(container.context).showSearchSuggestions) {
view.addProviders(searchSuggestionProvider!!)
}
@ -187,7 +187,7 @@ class AwesomeBarUIView(
}
private fun showSearchSuggestionProvider() {
if (Settings.getInstance(container.context).showSearchSuggestions()) {
if (Settings.getInstance(container.context).showSearchSuggestions) {
view.addProviders(searchSuggestionProvider!!)
}
}

View File

@ -6,8 +6,8 @@ package org.mozilla.fenix.settings
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import org.mozilla.fenix.R
import org.mozilla.fenix.utils.Settings
@ -23,7 +23,10 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
(activity as AppCompatActivity).supportActionBar?.show()
val searchSuggestionsPreference =
findPreference<Preference>(getString(R.string.pref_key_show_search_suggestions))
findPreference<SwitchPreference>(getString(R.string.pref_key_show_search_suggestions))?.apply {
isChecked = Settings.getInstance(context).showSearchSuggestions
}
searchSuggestionsPreference?.setOnPreferenceChangeListener { preference, newValue ->
Settings.getInstance(preference.context).preferences.edit().putBoolean(preference.key, newValue as Boolean)
.apply()
@ -31,7 +34,10 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
}
val showVisitedSitesBookmarks =
findPreference<Preference>(getString(R.string.pref_key_show_visited_sites_bookmarks))
findPreference<SwitchPreference>(getString(R.string.pref_key_show_visited_sites_bookmarks))?.apply {
isChecked = Settings.getInstance(context).shouldShowVisitedSitesBookmarks
}
showVisitedSitesBookmarks?.setOnPreferenceChangeListener { preference, newValue ->
Settings.getInstance(preference.context).preferences.edit().putBoolean(preference.key, newValue as Boolean)
.apply()

View File

@ -168,10 +168,10 @@ class Settings private constructor(context: Context) {
.apply()
}
fun showSearchSuggestions(): Boolean = preferences.getBoolean(
appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions),
true
)
val showSearchSuggestions: Boolean
get() = preferences.getBoolean(
appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions), true
)
fun setSitePermissionsPhoneFeatureCameraAction(action: SitePermissionsRules.Action) {
preferences.edit()