For #3544 - Set SearchSuggestions preference value from settings
parent
ab6101b0f4
commit
b1102c2e76
|
@ -128,7 +128,7 @@ class AwesomeBarUIView(
|
||||||
components.core.icons
|
components.core.icons
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Settings.getInstance(container.context).showSearchSuggestions()) {
|
if (Settings.getInstance(container.context).showSearchSuggestions) {
|
||||||
val searchDrawable = getDrawable(R.drawable.ic_search)
|
val searchDrawable = getDrawable(R.drawable.ic_search)
|
||||||
searchDrawable?.setColorFilter(
|
searchDrawable?.setColorFilter(
|
||||||
ContextCompat.getColor(
|
ContextCompat.getColor(
|
||||||
|
@ -171,7 +171,7 @@ class AwesomeBarUIView(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showSuggestionProviders() {
|
private fun showSuggestionProviders() {
|
||||||
if (Settings.getInstance(container.context).showSearchSuggestions()) {
|
if (Settings.getInstance(container.context).showSearchSuggestions) {
|
||||||
view.addProviders(searchSuggestionProvider!!)
|
view.addProviders(searchSuggestionProvider!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ class AwesomeBarUIView(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showSearchSuggestionProvider() {
|
private fun showSearchSuggestionProvider() {
|
||||||
if (Settings.getInstance(container.context).showSearchSuggestions()) {
|
if (Settings.getInstance(container.context).showSearchSuggestions) {
|
||||||
view.addProviders(searchSuggestionProvider!!)
|
view.addProviders(searchSuggestionProvider!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ package org.mozilla.fenix.settings
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.preference.Preference
|
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
|
import androidx.preference.SwitchPreference
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
|
|
||||||
|
@ -23,7 +23,10 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
|
||||||
(activity as AppCompatActivity).supportActionBar?.show()
|
(activity as AppCompatActivity).supportActionBar?.show()
|
||||||
|
|
||||||
val searchSuggestionsPreference =
|
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 ->
|
searchSuggestionsPreference?.setOnPreferenceChangeListener { preference, newValue ->
|
||||||
Settings.getInstance(preference.context).preferences.edit().putBoolean(preference.key, newValue as Boolean)
|
Settings.getInstance(preference.context).preferences.edit().putBoolean(preference.key, newValue as Boolean)
|
||||||
.apply()
|
.apply()
|
||||||
|
@ -31,7 +34,10 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val showVisitedSitesBookmarks =
|
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 ->
|
showVisitedSitesBookmarks?.setOnPreferenceChangeListener { preference, newValue ->
|
||||||
Settings.getInstance(preference.context).preferences.edit().putBoolean(preference.key, newValue as Boolean)
|
Settings.getInstance(preference.context).preferences.edit().putBoolean(preference.key, newValue as Boolean)
|
||||||
.apply()
|
.apply()
|
||||||
|
|
|
@ -168,10 +168,10 @@ class Settings private constructor(context: Context) {
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showSearchSuggestions(): Boolean = preferences.getBoolean(
|
val showSearchSuggestions: Boolean
|
||||||
appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions),
|
get() = preferences.getBoolean(
|
||||||
true
|
appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions), true
|
||||||
)
|
)
|
||||||
|
|
||||||
fun setSitePermissionsPhoneFeatureCameraAction(action: SitePermissionsRules.Action) {
|
fun setSitePermissionsPhoneFeatureCameraAction(action: SitePermissionsRules.Action) {
|
||||||
preferences.edit()
|
preferences.edit()
|
||||||
|
|
Loading…
Reference in New Issue