[fenix] Bug 1811532 - Add secret setting allowing to overwrite the `site` parameter for Pocket sponsored stories
parent
0bb9cbb876
commit
f072aa85cc
@ -0,0 +1,38 @@
|
||||
/* 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.EditTextPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.SwitchPreference
|
||||
import org.mozilla.fenix.Config
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
/**
|
||||
* Allows customizing sponsored stories fetch parameters.
|
||||
*/
|
||||
class SponsoredStoriesSettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.sponsored_stories_settings, rootKey)
|
||||
|
||||
requirePreference<SwitchPreference>(R.string.pref_key_custom_sponsored_stories_parameters_enabled).apply {
|
||||
isVisible = Config.channel.isNightlyOrDebug
|
||||
isChecked = context.settings().useCustomConfigurationForSponsoredStories
|
||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
}
|
||||
|
||||
requirePreference<EditTextPreference>(R.string.pref_key_custom_sponsored_stories_site_id).apply {
|
||||
isVisible = Config.channel.isNightlyOrDebug
|
||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
context.settings().pocketSponsoredStoriesSiteId = (newValue as String)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- 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/. -->
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/pref_key_custom_sponsored_stories_parameters_enabled"
|
||||
android:title="@string/preferences_debug_settings_custom_sponsored_stories_parameters_enabled"
|
||||
app:iconSpaceReserved="false" />
|
||||
<EditTextPreference
|
||||
android:dependency="@string/pref_key_custom_sponsored_stories_parameters_enabled"
|
||||
android:inputType="text"
|
||||
android:key="@string/pref_key_custom_sponsored_stories_site_id"
|
||||
android:title="@string/preferences_debug_settings_custom_sponsored_stories_parameters_site"
|
||||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue