Hanime1:Add subtitle preference setting.
This commit is contained in:
parent
430ec3f5ad
commit
952e90f592
1 changed files with 41 additions and 15 deletions
|
@ -24,6 +24,7 @@ import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
import okhttp3.Cookie
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
@ -287,25 +288,50 @@ class Hanime1 : AnimeHttpSource(), ConfigurableAnimeSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
screen.addPreference(
|
screen.apply {
|
||||||
ListPreference(screen.context).apply {
|
addPreference(
|
||||||
key = PREF_KEY_VIDEO_QUALITY
|
ListPreference(context).apply {
|
||||||
title = "設置首選畫質"
|
key = PREF_KEY_VIDEO_QUALITY
|
||||||
entries = arrayOf("1080P", "720P", "480P")
|
title = "設置首選畫質"
|
||||||
entryValues = entries
|
entries = arrayOf("1080P", "720P", "480P")
|
||||||
setDefaultValue(DEFAULT_QUALITY)
|
entryValues = entries
|
||||||
summary =
|
setDefaultValue(DEFAULT_QUALITY)
|
||||||
"當前選擇:${preferences.getString(PREF_KEY_VIDEO_QUALITY, DEFAULT_QUALITY)}"
|
summary =
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
"當前選擇:${preferences.getString(PREF_KEY_VIDEO_QUALITY, DEFAULT_QUALITY)}"
|
||||||
summary = "當前選擇:${newValue as String}"
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
true
|
summary = "當前選擇:${newValue as String}"
|
||||||
}
|
true
|
||||||
},
|
}
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
addPreference(
|
||||||
|
ListPreference(context).apply {
|
||||||
|
key = PREF_KEY_LANG
|
||||||
|
title = "設置首選語言"
|
||||||
|
summary = "該設置僅影響影片字幕"
|
||||||
|
entries = arrayOf("繁體中文", "簡體中文")
|
||||||
|
entryValues = arrayOf("zh-CHT", "zh-CHS")
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
val baseHttpUrl = baseUrl.toHttpUrl()
|
||||||
|
client.cookieJar.saveFromResponse(
|
||||||
|
baseHttpUrl,
|
||||||
|
listOf(
|
||||||
|
Cookie.parse(
|
||||||
|
baseHttpUrl,
|
||||||
|
"user_lang=${newValue as String}",
|
||||||
|
)!!,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val PREF_KEY_VIDEO_QUALITY = "PREF_KEY_VIDEO_QUALITY"
|
const val PREF_KEY_VIDEO_QUALITY = "PREF_KEY_VIDEO_QUALITY"
|
||||||
|
const val PREF_KEY_LANG = "PREF_KEY_LANG"
|
||||||
|
|
||||||
const val PREF_KEY_GENRE_LIST = "PREF_KEY_GENRE_LIST"
|
const val PREF_KEY_GENRE_LIST = "PREF_KEY_GENRE_LIST"
|
||||||
const val PREF_KEY_SORT_LIST = "PREF_KEY_SORT_LIST"
|
const val PREF_KEY_SORT_LIST = "PREF_KEY_SORT_LIST"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue