Remove provider language (#141)

This commit is contained in:
LagradOst 2022-10-10 21:51:03 +02:00 committed by GitHub
parent 98ef6a3f16
commit a43e950a48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 13 deletions

View file

@ -17,8 +17,7 @@ import com.lagradost.cloudstream3.ui.player.SubtitleData
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.AppUtils.toJson
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.SubtitleHelper
import com.lagradost.cloudstream3.utils.loadExtractor
import okhttp3.Interceptor import okhttp3.Interceptor
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
@ -191,17 +190,26 @@ object APIHolder {
return list.filter { names.contains(it) }.map { DubStatus.valueOf(it) }.toHashSet() return list.filter { names.contains(it) }.map { DubStatus.valueOf(it) }.toHashSet()
} }
/**
* Gets all the activated provider languages
* Used to obey the preference provider_lang_key
* but it turned out too complicated and unnecessary with extensions.
**/
fun Context.getApiProviderLangSettings(): HashSet<String> { fun Context.getApiProviderLangSettings(): HashSet<String> {
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) val langs = apis.map { it.lang }.toSet()
val hashSet = HashSet<String>() .sortedBy { SubtitleHelper.fromTwoLettersToLanguage(it) }
hashSet.add("en") // def is only en return langs.toHashSet()
val list = settingsManager.getStringSet(
this.getString(R.string.provider_lang_key),
hashSet.toMutableSet()
)
if (list.isNullOrEmpty()) return hashSet // val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
return list.toHashSet() // val hashSet = HashSet<String>()
// hashSet.add("en") // def is only en
// val list = settingsManager.getStringSet(
// this.getString(R.string.provider_lang_key),
// hashSet.toMutableSet()
// )
//
// if (list.isNullOrEmpty()) return hashSet
// return list.toHashSet()
} }
fun Context.getApiTypeSettings(): HashSet<TvType> { fun Context.getApiTypeSettings(): HashSet<TvType> {

View file

@ -100,7 +100,7 @@ class SetupFragmentExtensions : Fragment() {
next_btt?.setOnClickListener { next_btt?.setOnClickListener {
// Continue setup // Continue setup
if (isSetup) if (isSetup)
findNavController().navigate(R.id.action_navigation_setup_extensions_to_navigation_setup_provider_languages) findNavController().navigate(R.id.action_navigation_setup_extensions_to_navigation_setup_media)
else else
findNavController().navigate(R.id.navigation_home) findNavController().navigate(R.id.navigation_home)
} }

View file

@ -85,7 +85,7 @@ class SetupFragmentLanguage : Fragment() {
&& PluginManager.getPluginsLocal().isEmpty() && PluginManager.getPluginsLocal().isEmpty()
//&& PREBUILT_REPOSITORIES.isNotEmpty() //&& PREBUILT_REPOSITORIES.isNotEmpty()
) R.id.action_navigation_global_to_navigation_setup_extensions ) R.id.action_navigation_global_to_navigation_setup_extensions
else R.id.action_navigation_setup_language_to_navigation_setup_provider_languages else R.id.action_navigation_setup_language_to_navigation_setup_media
findNavController().navigate( findNavController().navigate(
nextDestination, nextDestination,

View file

@ -522,6 +522,13 @@
app:exitAnim="@anim/exit_anim" app:exitAnim="@anim/exit_anim"
app:popEnterAnim="@anim/enter_anim" app:popEnterAnim="@anim/enter_anim"
app:popExitAnim="@anim/exit_anim" /> app:popExitAnim="@anim/exit_anim" />
<action
android:id="@+id/action_navigation_setup_language_to_navigation_setup_media"
app:destination="@id/navigation_setup_media"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
app:popEnterAnim="@anim/enter_anim"
app:popExitAnim="@anim/exit_anim" />
</fragment> </fragment>
<action <action
@ -553,6 +560,13 @@
app:exitAnim="@anim/exit_anim" app:exitAnim="@anim/exit_anim"
app:popEnterAnim="@anim/enter_anim" app:popEnterAnim="@anim/enter_anim"
app:popExitAnim="@anim/exit_anim" /> app:popExitAnim="@anim/exit_anim" />
<action
android:id="@+id/action_navigation_setup_extensions_to_navigation_setup_media"
app:destination="@id/navigation_setup_media"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
app:popEnterAnim="@anim/enter_anim"
app:popExitAnim="@anim/exit_anim" />
</fragment> </fragment>
<fragment <fragment

View file

@ -2,6 +2,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference <Preference
app:isPreferenceVisible="false"
android:icon="@drawable/ic_baseline_language_24" android:icon="@drawable/ic_baseline_language_24"
android:key="@string/provider_lang_key" android:key="@string/provider_lang_key"
android:title="@string/provider_lang_settings" /> android:title="@string/provider_lang_settings" />