mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
make the setting work
This commit is contained in:
parent
e9343bafc2
commit
228626c27c
5 changed files with 18 additions and 12 deletions
|
@ -721,16 +721,16 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
changeStatusBarState(isEmulatorSettings())
|
||||
|
||||
// Automatically enable jsdelivr if cant connect to raw.githubusercontent.com
|
||||
if (!settingsManager.contains("jsdelivr_proxy_key") && isNetworkAvailable()) {
|
||||
if (this.getKey<Boolean>(getString(R.string.jsdelivr_proxy_key)) == null && isNetworkAvailable()) {
|
||||
main {
|
||||
if (checkGithubConnectivity()) {
|
||||
this.setKey("jsdelivr_proxy_key", false)
|
||||
this.setKey(getString(R.string.jsdelivr_proxy_key), false)
|
||||
} else {
|
||||
this.setKey("jsdelivr_proxy_key", true)
|
||||
this.setKey(getString(R.string.jsdelivr_proxy_key), true)
|
||||
val parentView: View = findViewById(android.R.id.content)
|
||||
Snackbar.make(parentView, R.string.jsdelivr_enabled, Snackbar.LENGTH_LONG).let { snackbar ->
|
||||
snackbar.setAction(R.string.revert) { v ->
|
||||
setKey("jsdelivr_proxy_key", false)
|
||||
snackbar.setAction(R.string.revert) {
|
||||
setKey(getString(R.string.jsdelivr_proxy_key), false)
|
||||
}
|
||||
snackbar.setBackgroundTint(colorFromAttribute(R.attr.primaryGrayBackground))
|
||||
snackbar.setTextColor(colorFromAttribute(R.attr.textColor))
|
||||
|
|
|
@ -2,8 +2,10 @@ package com.lagradost.cloudstream3.plugins
|
|||
|
||||
import android.content.Context
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.context
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.amap
|
||||
import com.lagradost.cloudstream3.app
|
||||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
|
@ -75,7 +77,7 @@ object RepositoryManager {
|
|||
|
||||
/* Convert raw.githubusercontent.com urls to cdn.jsdelivr.net if enabled in settings */
|
||||
fun convertRawGitUrl(url: String): String {
|
||||
if (!(getKey<Boolean>("jsdelivr_proxy_key") ?: false)) return url
|
||||
if (getKey<Boolean>(context!!.getString(R.string.jsdelivr_proxy_key)) != true) return url
|
||||
val match = GH_REGEX.find(url) ?: return url
|
||||
val (user, repo, rest) = match.destructured
|
||||
return "https://cdn.jsdelivr.net/gh/$user/$repo@$rest"
|
||||
|
|
|
@ -82,7 +82,7 @@ val appLanguages = arrayListOf(
|
|||
Triple("", "norsk bokmål", "no"),
|
||||
Triple("", "polski", "pl"),
|
||||
Triple("\uD83C\uDDF5\uD83C\uDDF9", "português", "pt"),
|
||||
Triple("🦍", "mmmm... monke", "qt"),
|
||||
Triple("\uD83E\uDD8D", "mmmm... monke", "qt"),
|
||||
Triple("", "română", "ro"),
|
||||
Triple("", "русский", "ru"),
|
||||
Triple("", "slovenčina", "sk"),
|
||||
|
@ -97,7 +97,7 @@ val appLanguages = arrayListOf(
|
|||
Triple("", "中文", "zh"),
|
||||
Triple("\uD83C\uDDF9\uD83C\uDDFC", "文言", "zh-rTW"),
|
||||
/* end language list */
|
||||
).sortedBy { it.second?.toLowerCase() } //ye, we go alphabetical, so ppl don't put their lang on top
|
||||
).sortedBy { it.second.lowercase() } //ye, we go alphabetical, so ppl don't put their lang on top
|
||||
|
||||
class SettingsGeneral : PreferenceFragmentCompat() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -157,9 +157,6 @@ class SettingsGeneral : PreferenceFragmentCompat() {
|
|||
|
||||
getPref(R.string.locale_key)?.setOnPreferenceClickListener { pref ->
|
||||
val tempLangs = appLanguages.toMutableList()
|
||||
//if (beneneCount > 100) {
|
||||
// tempLangs.add(Triple("\uD83E\uDD8D", "mmmm... monke", "mo"))
|
||||
//}
|
||||
val current = getCurrentLocale(pref.context)
|
||||
val languageCodes = tempLangs.map { (_, _, iso) -> iso }
|
||||
val languageNames = tempLangs.map { (emoji, name, iso) ->
|
||||
|
@ -316,6 +313,12 @@ class SettingsGeneral : PreferenceFragmentCompat() {
|
|||
} ?: emptyList()
|
||||
}
|
||||
|
||||
settingsManager.edit().putBoolean(getString(R.string.jsdelivr_proxy_key), getKey(getString(R.string.jsdelivr_proxy_key), false) ?: false).apply()
|
||||
getPref(R.string.jsdelivr_proxy_key)?.setOnPreferenceChangeListener { _, newValue ->
|
||||
setKey(getString(R.string.jsdelivr_proxy_key), newValue)
|
||||
return@setOnPreferenceChangeListener true
|
||||
}
|
||||
|
||||
getPref(R.string.download_path_key)?.setOnPreferenceClickListener {
|
||||
val dirs = getDownloadDirs()
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
<string name="random_button_key" translatable="false">random_button_key</string>
|
||||
<string name="provider_lang_key" translatable="false">provider_lang_key</string>
|
||||
<string name="dns_key" translatable="false">dns_key</string>
|
||||
<string name="jsdelivr_proxy_key" translatable="false">jsdelivr_proxy_key</string>
|
||||
<string name="download_path_key" translatable="false">download_path_key</string>
|
||||
<string name="app_name_download_path" translatable="false">Cloudstream</string>
|
||||
<string name="app_layout_key" translatable="false">app_layout_key</string>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_github_logo"
|
||||
android:key="jsdelivr_proxy_key"
|
||||
android:key="@string/jsdelivr_proxy_key"
|
||||
android:title="@string/jsdelivr_proxy"
|
||||
android:summary="@string/jsdelivr_proxy_summary" />
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue