You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.3 KiB
Kotlin
54 lines
2.3 KiB
Kotlin
5 years ago
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||
|
|
||
5 years ago
|
package org.mozilla.fenix.settings.search
|
||
5 years ago
|
|
||
|
import android.os.Bundle
|
||
|
import androidx.appcompat.app.AppCompatActivity
|
||
|
import androidx.preference.PreferenceFragmentCompat
|
||
5 years ago
|
import androidx.preference.SwitchPreference
|
||
5 years ago
|
import org.mozilla.fenix.R
|
||
5 years ago
|
import org.mozilla.fenix.ext.getPreferenceKey
|
||
5 years ago
|
import org.mozilla.fenix.ext.settings
|
||
5 years ago
|
import org.mozilla.fenix.settings.SharedPreferenceUpdater
|
||
5 years ago
|
|
||
|
class SearchEngineFragment : PreferenceFragmentCompat() {
|
||
|
|
||
5 years ago
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||
|
setPreferencesFromResource(R.xml.search_engine_preferences, rootKey)
|
||
|
}
|
||
|
|
||
|
override fun onResume() {
|
||
|
super.onResume()
|
||
5 years ago
|
(activity as AppCompatActivity).title = getString(R.string.preferences_search)
|
||
5 years ago
|
(activity as AppCompatActivity).supportActionBar?.show()
|
||
|
|
||
5 years ago
|
val searchSuggestionsPreference =
|
||
5 years ago
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_search_suggestions))?.apply {
|
||
5 years ago
|
isChecked = context.settings.shouldShowSearchSuggestions
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
searchSuggestionsPreference?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||
5 years ago
|
|
||
5 years ago
|
val showHistorySuggestions =
|
||
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_browsing_history))?.apply {
|
||
5 years ago
|
isChecked = context.settings.shouldShowHistorySuggestions
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
val showBookmarkSuggestions =
|
||
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_bookmarks))?.apply {
|
||
5 years ago
|
isChecked = context.settings.shouldShowBookmarkSuggestions
|
||
5 years ago
|
}
|
||
|
|
||
|
val showClipboardSuggestions =
|
||
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_clipboard_suggestions))?.apply {
|
||
5 years ago
|
isChecked = context.settings.shouldShowClipboardSuggestions
|
||
5 years ago
|
}
|
||
|
|
||
|
showHistorySuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||
|
showBookmarkSuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||
|
showClipboardSuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||
5 years ago
|
}
|
||
|
}
|