2020-02-08 01:59:59 +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/. */
|
|
|
|
|
|
|
|
package org.mozilla.fenix.settings
|
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
import androidx.preference.Preference
|
|
|
|
import androidx.preference.PreferenceFragmentCompat
|
2020-02-17 14:17:36 +01:00
|
|
|
import androidx.preference.SwitchPreference
|
2020-02-08 01:59:59 +01:00
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.components.PrivateShortcutCreateManager
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
import org.mozilla.fenix.ext.metrics
|
2020-04-03 11:19:39 +02:00
|
|
|
import org.mozilla.fenix.ext.settings
|
2020-02-08 01:59:59 +01:00
|
|
|
import org.mozilla.fenix.ext.showToolbar
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lets the user customize Private browsing options.
|
|
|
|
*/
|
|
|
|
class PrivateBrowsingFragment : PreferenceFragmentCompat() {
|
|
|
|
override fun onResume() {
|
|
|
|
super.onResume()
|
|
|
|
showToolbar(getString(R.string.preferences_private_browsing_options))
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
|
|
setPreferencesFromResource(R.xml.private_browsing_preferences, rootKey)
|
2020-02-17 14:17:36 +01:00
|
|
|
updatePreferences()
|
|
|
|
}
|
2020-02-08 01:59:59 +01:00
|
|
|
|
2020-02-17 14:17:36 +01:00
|
|
|
private fun updatePreferences() {
|
2020-06-15 20:24:14 +02:00
|
|
|
requirePreference<Preference>(R.string.pref_key_add_private_browsing_shortcut).apply {
|
2020-02-08 01:59:59 +01:00
|
|
|
setOnPreferenceClickListener {
|
|
|
|
requireContext().metrics.track(Event.PrivateBrowsingCreateShortcut)
|
|
|
|
PrivateShortcutCreateManager.createPrivateShortcut(requireContext())
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
2020-02-17 14:17:36 +01:00
|
|
|
|
2020-06-15 20:24:14 +02:00
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_open_links_in_a_private_tab).apply {
|
2020-02-23 18:56:05 +01:00
|
|
|
onPreferenceChangeListener = SharedPreferenceUpdater()
|
2020-04-22 23:29:43 +02:00
|
|
|
isChecked = context.settings().openLinksInAPrivateTab
|
2020-02-17 14:17:36 +01:00
|
|
|
}
|
2020-04-03 11:19:39 +02:00
|
|
|
|
2020-06-15 20:24:14 +02:00
|
|
|
requirePreference<SwitchPreference>(R.string.pref_key_allow_screenshots_in_private_mode).apply {
|
2020-06-23 02:38:58 +02:00
|
|
|
onPreferenceChangeListener = SharedPreferenceUpdater()
|
2020-04-03 11:19:39 +02:00
|
|
|
}
|
2020-02-08 01:59:59 +01:00
|
|
|
}
|
|
|
|
}
|