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

For #5312 - Send ETP Strict/Standard event

This commit is contained in:
ekager 2019-09-25 14:40:34 -07:00 committed by Emily Kager
parent 24b3ed4384
commit 44bb592b43
2 changed files with 15 additions and 15 deletions

View File

@ -97,6 +97,7 @@ open class RadioButtonPreference @JvmOverloads constructor(
radioButton?.isChecked = isChecked
context.settings().preferences.edit().putBoolean(key, isChecked)
.apply()
onPreferenceChangeListener.onPreferenceChange(this, isChecked)
}
private fun bindRadioButton(holder: PreferenceViewHolder) {

View File

@ -90,15 +90,17 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {
private fun bindStrict() {
val keyStrict = getString(R.string.pref_key_tracking_protection_strict)
radioStrict = requireNotNull(findPreference(keyStrict))
radioStrict.onPreferenceChangeListener = SharedPreferenceUpdater()
radioStrict.isVisible = FeatureFlags.etpCategories
radioStrict.onPreferenceChangeListener = object : SharedPreferenceUpdater() {
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
context?.metrics?.track(
Event.TrackingProtectionSettingChanged(
Event.TrackingProtectionSettingChanged.Setting.STRICT
if (newValue == true) {
updateTrackingProtectionPolicy()
context?.metrics?.track(
Event.TrackingProtectionSettingChanged(
Event.TrackingProtectionSettingChanged.Setting.STRICT
)
)
)
}
return super.onPreferenceChange(preference, newValue)
}
}
@ -109,9 +111,6 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {
.actionTrackingProtectionFragmentToTrackingProtectionBlockingFragment(true)
)
}
radioStrict.onClickListener {
updateTrackingProtectionPolicy()
}
}
private fun bindStandard() {
@ -120,11 +119,14 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {
radioStandard.isVisible = FeatureFlags.etpCategories
radioStandard.onPreferenceChangeListener = object : SharedPreferenceUpdater() {
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
context?.metrics?.track(
Event.TrackingProtectionSettingChanged(
Event.TrackingProtectionSettingChanged.Setting.STANDARD
if (newValue == true) {
updateTrackingProtectionPolicy()
context?.metrics?.track(
Event.TrackingProtectionSettingChanged(
Event.TrackingProtectionSettingChanged.Setting.STANDARD
)
)
)
}
return super.onPreferenceChange(preference, newValue)
}
}
@ -135,9 +137,6 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {
.actionTrackingProtectionFragmentToTrackingProtectionBlockingFragment(false)
)
}
radioStandard.onClickListener {
updateTrackingProtectionPolicy()
}
}
private fun updateTrackingProtectionPolicy() {