forked from recloudstream/cloudstream
[Feature] Copy settings values from Preferences to providers APIs (#48)
* [Feature] Copy settings values from Preferences to providers APIs * Use companion object instead for singular object access across all providers * Fix build * Re-order code hierarchy. Prioritize loading settings from pref
This commit is contained in:
parent
2893cd8da3
commit
01c81fc421
4 changed files with 20 additions and 0 deletions
|
@ -315,6 +315,10 @@ data class ProvidersInfoJson(
|
|||
@JsonProperty("status") var status: Int,
|
||||
)
|
||||
|
||||
data class SettingsJson(
|
||||
@JsonProperty("enableAdult") var enableAdult: Boolean = false,
|
||||
)
|
||||
|
||||
|
||||
data class MainPageData(
|
||||
val name: String,
|
||||
|
@ -354,6 +358,7 @@ fun newHomePageResponse(list: List<HomePageList>, hasNext: Boolean? = null): Hom
|
|||
abstract class MainAPI {
|
||||
companion object {
|
||||
var overrideData: HashMap<String, ProvidersInfoJson>? = null
|
||||
var settingsForProvider: SettingsJson = SettingsJson()
|
||||
}
|
||||
|
||||
fun init() {
|
||||
|
|
|
@ -455,6 +455,11 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
app.initClient(this)
|
||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
|
||||
val settingsForProvider = SettingsJson()
|
||||
settingsForProvider.enableAdult = settingsManager.getBoolean(getString(R.string.enable_nsfw_on_providers_key), false)
|
||||
|
||||
MainAPI.settingsForProvider = settingsForProvider
|
||||
|
||||
loadThemes(this)
|
||||
updateLocale()
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<string name="redo_setup_key" translatable="false">redo_setup_key</string>
|
||||
<string name="filter_sub_lang_key" translatable="false">filter_sub_lang_key</string>
|
||||
<string name="pref_filter_search_quality_key" translatable="false">pref_filter_search_quality_key</string>
|
||||
<string name="enable_nsfw_on_providers_key" translatable="false">enable_nsfw_on_providers_key</string>
|
||||
|
||||
<!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG -->
|
||||
<string name="extra_info_format" formatted="true" translatable="false">%d %s | %s</string>
|
||||
|
@ -444,6 +445,7 @@
|
|||
<string name="provider_lang_settings">Provider languages</string>
|
||||
<string name="app_layout">App Layout</string>
|
||||
<string name="preferred_media_settings">Preferred media</string>
|
||||
<string name="enable_nsfw_on_providers">Enable NSFW on supported providers</string>
|
||||
<string name="subtitles_encoding">Subtitle encoding</string>
|
||||
<string name="category_preferred_media_and_lang">Language</string>
|
||||
<string name="category_ui">Layout</string>
|
||||
|
@ -607,4 +609,5 @@
|
|||
|
||||
<string name="download_all_plugins_from_repo">Download all plugins from this repository?</string>
|
||||
<string name="single_plugin_disabled" formatted="true">%s (Disabled)</string>
|
||||
<string name="apply_on_restart">Apply on Restart</string>
|
||||
</resources>
|
||||
|
|
|
@ -18,4 +18,11 @@
|
|||
android:key="@string/display_sub_key"
|
||||
android:title="@string/display_subbed_dubbed_settings"
|
||||
android:icon="@drawable/ic_outline_voice_over_off_24" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="@string/enable_nsfw_on_providers_key"
|
||||
android:title="@string/enable_nsfw_on_providers"
|
||||
android:icon="@drawable/ic_baseline_extension_24"
|
||||
android:summary="@string/apply_on_restart"
|
||||
app:defaultValue="false"/>
|
||||
</PreferenceScreen>
|
Loading…
Reference in a new issue