2019-03-06 20:39:38 +01:00
|
|
|
/* 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/. */
|
|
|
|
|
2019-09-14 06:29:11 +02:00
|
|
|
package org.mozilla.fenix.settings.search
|
2019-03-06 20:39:38 +01:00
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
import androidx.preference.PreferenceFragmentCompat
|
2019-06-19 00:00:30 +02:00
|
|
|
import androidx.preference.SwitchPreference
|
2019-03-06 20:39:38 +01:00
|
|
|
import org.mozilla.fenix.R
|
2019-08-21 17:38:14 +02:00
|
|
|
import org.mozilla.fenix.ext.getPreferenceKey
|
2019-09-10 19:11:58 +02:00
|
|
|
import org.mozilla.fenix.ext.settings
|
2019-09-14 06:29:11 +02:00
|
|
|
import org.mozilla.fenix.settings.SharedPreferenceUpdater
|
2019-03-06 20:39:38 +01:00
|
|
|
|
|
|
|
class SearchEngineFragment : PreferenceFragmentCompat() {
|
|
|
|
|
2019-05-19 01:35:45 +02:00
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
|
|
setPreferencesFromResource(R.xml.search_engine_preferences, rootKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onResume() {
|
|
|
|
super.onResume()
|
2019-09-18 20:26:44 +02:00
|
|
|
(activity as AppCompatActivity).title = getString(R.string.preferences_search)
|
2019-03-06 20:39:38 +01:00
|
|
|
(activity as AppCompatActivity).supportActionBar?.show()
|
|
|
|
|
2019-05-19 01:35:45 +02:00
|
|
|
val searchSuggestionsPreference =
|
2019-08-21 17:38:14 +02:00
|
|
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_search_suggestions))?.apply {
|
2019-09-24 19:33:46 +02:00
|
|
|
isChecked = context.settings().shouldShowSearchSuggestions
|
2019-06-19 00:00:30 +02:00
|
|
|
}
|
|
|
|
|
2019-08-21 17:38:14 +02:00
|
|
|
searchSuggestionsPreference?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
2019-05-19 01:35:45 +02:00
|
|
|
|
2019-09-05 23:45:44 +02:00
|
|
|
val showHistorySuggestions =
|
|
|
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_browsing_history))?.apply {
|
2019-09-24 19:33:46 +02:00
|
|
|
isChecked = context.settings().shouldShowHistorySuggestions
|
2019-06-19 00:00:30 +02:00
|
|
|
}
|
|
|
|
|
2019-09-05 23:45:44 +02:00
|
|
|
val showBookmarkSuggestions =
|
|
|
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_bookmarks))?.apply {
|
2019-09-24 19:33:46 +02:00
|
|
|
isChecked = context.settings().shouldShowBookmarkSuggestions
|
2019-09-05 23:45:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
val showClipboardSuggestions =
|
|
|
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_clipboard_suggestions))?.apply {
|
2019-09-24 19:33:46 +02:00
|
|
|
isChecked = context.settings().shouldShowClipboardSuggestions
|
2019-09-05 23:45:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
showHistorySuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
|
|
|
showBookmarkSuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
|
|
|
showClipboardSuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
2019-03-06 20:39:38 +01:00
|
|
|
}
|
|
|
|
}
|