Update parsers

This commit is contained in:
Koitharu
2023-02-25 18:44:31 +02:00
parent d0b9412559
commit 4ec50f83d2
6 changed files with 28 additions and 11 deletions

View File

@@ -23,6 +23,7 @@ class SourceSettings(context: Context, source: MangaSource) : MangaSourceConfig
@Suppress("UNCHECKED_CAST")
override fun <T> get(key: ConfigKey<T>): T {
return when (key) {
is ConfigKey.UserAgent -> prefs.getString(key.key, key.defaultValue).ifNullOrEmpty { key.defaultValue }
is ConfigKey.Domain -> prefs.getString(key.key, key.defaultValue).ifNullOrEmpty { key.defaultValue }
is ConfigKey.ShowSuspiciousContent -> prefs.getBoolean(key.key, key.defaultValue)
} as T

View File

@@ -37,6 +37,21 @@ fun PreferenceFragmentCompat.addPreferencesFromRepository(repository: RemoteMang
}
}
is ConfigKey.UserAgent -> {
EditTextPreference(requireContext()).apply {
summaryProvider = EditTextDefaultSummaryProvider(key.defaultValue)
setOnBindEditTextListener(
EditTextBindListener(
inputType = EditorInfo.TYPE_CLASS_TEXT,
hint = key.defaultValue,
validator = null,
),
)
setTitle(R.string.user_agent)
setDialogTitle(R.string.user_agent)
}
}
is ConfigKey.ShowSuspiciousContent -> {
SwitchPreferenceCompat(requireContext()).apply {
setDefaultValue(key.defaultValue)

View File

@@ -424,4 +424,5 @@
<string name="allow_unstable_updates">Allow unstable updates</string>
<string name="allow_unstable_updates_summary">Propose updates to beta versions of the app</string>
<string name="download_started">Download started</string>
<string name="user_agent">UserAgent header</string>
</resources>