diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6dcd4e1b..b80154b2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -155,11 +155,11 @@ + android:exported="false" /> + android:name=".ui.ControllerActivity" /> = arrayListOf() - private var apiMap: Map? = null + var apiMap: Map? = null private fun initMap() { if (apiMap == null) @@ -357,6 +357,7 @@ abstract class MainAPI { } fun overrideWithNewData(data: ProvidersInfoJson) { + if (!canBeOverridden) return this.name = data.name if (data.url.isNotBlank() && data.url != "NONE") this.mainUrl = data.url @@ -366,10 +367,11 @@ abstract class MainAPI { open var name = "NONE" open var mainUrl = "NONE" open var storedCredentials: String? = null + open var canBeOverridden: Boolean = true //open val uniqueId : Int by lazy { this.name.hashCode() } // in case of duplicate providers you can have a shared id - open val lang = "en" // ISO_639_1 check SubtitleHelper + open var lang = "en" // ISO_639_1 check SubtitleHelper /**If link is stored in the "data" string, so links can be instantly loaded*/ open val instantLinkLoading = false @@ -908,7 +910,7 @@ interface LoadResponse { } fun LoadResponse.addTrailer(trailerUrls: List?) { - if(trailerUrls == null) return + if (trailerUrls == null) return if (this.trailers == null) { this.trailers = trailerUrls } else { diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index aadf00a7..3216b1f3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -47,6 +47,7 @@ import com.lagradost.cloudstream3.ui.result.ResultFragment import com.lagradost.cloudstream3.ui.search.SearchResultBuilder import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings +import com.lagradost.cloudstream3.ui.settings.SettingsGeneral import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable import com.lagradost.cloudstream3.utils.AppUtils.loadCache import com.lagradost.cloudstream3.utils.AppUtils.loadResult @@ -68,6 +69,7 @@ import com.lagradost.cloudstream3.utils.UIHelper.getResourceColor import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard import com.lagradost.cloudstream3.utils.UIHelper.navigate import com.lagradost.cloudstream3.utils.UIHelper.requestRW +import com.lagradost.cloudstream3.utils.USER_PROVIDER_API import com.lagradost.nicehttp.Requests import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.fragment_result_swipe.* @@ -515,6 +517,26 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { apis = allProviders } + try { + getKey>(USER_PROVIDER_API)?.let { list -> + list.forEach { custom -> + allProviders.firstOrNull { it.javaClass.simpleName == custom.parentJavaClass } + ?.let { + allProviders.add(it.javaClass.newInstance().apply { + name = custom.name + lang = custom.lang + mainUrl = custom.url.trimEnd('/') + canBeOverridden = false + }) + } + } + } + apis = allProviders + APIHolder.apiMap = null + } catch (e: Exception) { + logError(e) + } + loadThemes(this) updateLocale() app.initClient(this) diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeWorldProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeWorldProvider.kt index e41a63b5..4a965206 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeWorldProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeWorldProvider.kt @@ -16,7 +16,7 @@ import org.jsoup.nodes.Element class AnimeWorldProvider : MainAPI() { override var mainUrl = "https://www.animeworld.tv" override var name = "AnimeWorld" - override val lang = "it" + override var lang = "it" override val hasMainPage = true override val supportedTypes = setOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimefenixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimefenixProvider.kt index 11eb01c2..d00543d4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimefenixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimefenixProvider.kt @@ -13,7 +13,7 @@ class AnimefenixProvider:MainAPI() { override var mainUrl = "https://animefenix.com" override var name = "Animefenix" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvIOProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvIOProvider.kt index 481c2b25..aadfdcad 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvIOProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvIOProvider.kt @@ -11,7 +11,7 @@ import kotlin.collections.ArrayList class AnimeflvIOProvider:MainAPI() { override var mainUrl = "https://animeflv.io" //Also scrapes from animeid.to override var name = "Animeflv.io" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt index 7e88ce75..df40481b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt @@ -24,7 +24,7 @@ class AnimeflvnetProvider : MainAPI() { override var mainUrl = "https://www3.animeflv.net" override var name = "Animeflv.net" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DreamSubProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DreamSubProvider.kt index 725e1054..e3ca3e28 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DreamSubProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DreamSubProvider.kt @@ -11,7 +11,7 @@ import org.jsoup.nodes.Element class DreamSubProvider : MainAPI() { override var mainUrl = "https://dreamsub.me" override var name = "DreamSub" - override val lang = "it" + override var lang = "it" override val hasMainPage = true override val supportedTypes = setOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GomunimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GomunimeProvider.kt index 1287ae6f..f32d2ddd 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GomunimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GomunimeProvider.kt @@ -14,7 +14,7 @@ class GomunimeProvider : MainAPI() { override var name = "Gomunime" override val hasQuickSearch = false override val hasMainPage = true - override val lang = "id" + override var lang = "id" override val hasDownloadSupport = true override val supportedTypes = setOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/JKAnimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/JKAnimeProvider.kt index d6e215a9..c84c1fba 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/JKAnimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/JKAnimeProvider.kt @@ -22,7 +22,7 @@ class JKAnimeProvider : MainAPI() { override var mainUrl = "https://jkanime.net" override var name = "JKAnime" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuramanimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuramanimeProvider.kt index e41e9119..ce560949 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuramanimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuramanimeProvider.kt @@ -12,7 +12,7 @@ class KuramanimeProvider : MainAPI() { override var name = "Kuramanime" override val hasQuickSearch = false override val hasMainPage = true - override val lang = "id" + override var lang = "id" override val hasDownloadSupport = true override val supportedTypes = setOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuronimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuronimeProvider.kt index 14e841fc..d3203810 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuronimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuronimeProvider.kt @@ -13,7 +13,7 @@ class KuronimeProvider : MainAPI() { override var name = "Kuronime" override val hasQuickSearch = false override val hasMainPage = true - override val lang = "id" + override var lang = "id" override val hasDownloadSupport = true override val supportedTypes = setOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MonoschinosProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MonoschinosProvider.kt index 3681e6f0..e06d2e66 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MonoschinosProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MonoschinosProvider.kt @@ -24,7 +24,7 @@ class MonoschinosProvider : MainAPI() { override var mainUrl = "https://monoschinos2.com" override var name = "Monoschinos" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MundoDonghuaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MundoDonghuaProvider.kt index 19520ae6..54fdfe45 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MundoDonghuaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MundoDonghuaProvider.kt @@ -15,7 +15,7 @@ class MundoDonghuaProvider : MainAPI() { override var mainUrl = "https://www.mundodonghua.com" override var name = "MundoDonghua" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NeonimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NeonimeProvider.kt index d844e043..0d9574e5 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NeonimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NeonimeProvider.kt @@ -11,7 +11,7 @@ class NeonimeProvider : MainAPI() { override var name = "Neonime" override val hasQuickSearch = false override val hasMainPage = true - override val lang = "id" + override var lang = "id" override val hasDownloadSupport = true override val supportedTypes = setOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NontonAnimeIDProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NontonAnimeIDProvider.kt index d3cf7772..5998f2a7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NontonAnimeIDProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NontonAnimeIDProvider.kt @@ -15,7 +15,7 @@ class NontonAnimeIDProvider : MainAPI() { override var name = "NontonAnimeID" override val hasQuickSearch = false override val hasMainPage = true - override val lang = "id" + override var lang = "id" override val hasDownloadSupport = true override val supportedTypes = setOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OploverzProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OploverzProvider.kt index 906c20ff..9c01934d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OploverzProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OploverzProvider.kt @@ -13,7 +13,7 @@ class OploverzProvider : MainAPI() { override var name = "Oploverz" override val hasQuickSearch = false override val hasMainPage = true - override val lang = "id" + override var lang = "id" override val hasDownloadSupport = true override val supportedTypes = setOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/metaproviders/CrossTmdbProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/metaproviders/CrossTmdbProvider.kt index a9c6a463..b01d188c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/metaproviders/CrossTmdbProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/metaproviders/CrossTmdbProvider.kt @@ -12,7 +12,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink class CrossTmdbProvider : TmdbProvider() { override var name = "MultiMovie" override val apiName = "MultiMovie" - override val lang = "en" + override var lang = "en" override val useMetaLoadResponse = true override val usesWebView = true override val supportedTypes = setOf(TvType.Movie) diff --git a/app/src/main/java/com/lagradost/cloudstream3/metaproviders/MultiAnimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/metaproviders/MultiAnimeProvider.kt index 38c2abea..df765b7d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/metaproviders/MultiAnimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/metaproviders/MultiAnimeProvider.kt @@ -12,7 +12,7 @@ import com.lagradost.cloudstream3.utils.SyncUtil // wont be implemented class MultiAnimeProvider : MainAPI() { override var name = "MultiAnime" - override val lang = "en" + override var lang = "en" override val usesWebView = true override val supportedTypes = setOf(TvType.Anime) private val syncApi: SyncAPI = aniListApi diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AkwamProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AkwamProvider.kt index 3a8435a2..f370a274 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AkwamProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AkwamProvider.kt @@ -7,7 +7,7 @@ import com.lagradost.cloudstream3.utils.Qualities import org.jsoup.nodes.Element class AkwamProvider : MainAPI() { - override val lang = "ar" + override var lang = "ar" override var mainUrl = "https://akwam.to" override var name = "Akwam" override val usesWebView = false diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt index a0a7324b..b9fe05e9 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt @@ -7,7 +7,7 @@ import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.* class AltadefinizioneProvider : MainAPI() { - override val lang = "it" + override var lang = "it" override var mainUrl = "https://altadefinizione.hair" override var name = "Altadefinizione" override val hasMainPage = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt index 81d6c835..50bc4244 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt @@ -6,7 +6,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor class CineblogProvider : MainAPI() { - override val lang = "it" + override var lang = "it" override var mainUrl = "https://cb01.rip" override var name = "CineBlog" override val hasMainPage = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt index c650ba49..91fa8941 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt @@ -9,7 +9,7 @@ import com.lagradost.cloudstream3.utils.loadExtractor class CinecalidadProvider:MainAPI() { override var mainUrl = "https://cinecalidad.lol" override var name = "Cinecalidad" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CuevanaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CuevanaProvider.kt index 0703a124..771cdf3e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CuevanaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CuevanaProvider.kt @@ -10,7 +10,7 @@ import com.lagradost.cloudstream3.utils.loadExtractor class CuevanaProvider : MainAPI() { override var mainUrl = "https://cuevana3.me" override var name = "Cuevana" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt index ab907aba..b216ec6f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt @@ -23,7 +23,7 @@ class DoramasYTProvider : MainAPI() { override var mainUrl = "https://doramasyt.com" override var name = "DoramasYT" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaidProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaidProvider.kt index 5b601e28..77945fa7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaidProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaidProvider.kt @@ -15,7 +15,7 @@ class DramaidProvider : MainAPI() { override var name = "DramaId" override val hasQuickSearch = false override val hasMainPage = true - override val lang = "id" + override var lang = "id" override val hasDownloadSupport = true override val hasChromecastSupport = false override val supportedTypes = setOf(TvType.AsianDrama) diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EgyBestProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EgyBestProvider.kt index 7fa54ad6..aae321a9 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EgyBestProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EgyBestProvider.kt @@ -7,7 +7,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink import org.jsoup.nodes.Element class EgyBestProvider : MainAPI() { - override val lang = "ar" + override var lang = "ar" override var mainUrl = "https://www.egy.best" override var name = "EgyBest" override val usesWebView = false diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ElifilmsProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ElifilmsProvider.kt index 58167214..dd3e1d15 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ElifilmsProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ElifilmsProvider.kt @@ -1,19 +1,20 @@ package com.lagradost.cloudstream3.movieproviders import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.utils.* -import kotlin.collections.ArrayList +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.loadExtractor -class ElifilmsProvider:MainAPI() { +class ElifilmsProvider : MainAPI() { override var mainUrl: String = "https://elifilms.net" override var name: String = "Elifilms" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true override val supportedTypes = setOf( TvType.Movie, ) + override suspend fun getMainPage(): HomePageResponse { val items = ArrayList() val newest = app.get(mainUrl).document.selectFirst("a.fav_link.premiera")?.attr("href") @@ -42,6 +43,7 @@ class ElifilmsProvider:MainAPI() { if (items.size <= 0) throw ErrorLoadingException() return HomePageResponse(items) } + override suspend fun search(query: String): List { val url = "$mainUrl/?s=$query" val doc = app.get(url).document @@ -52,6 +54,7 @@ class ElifilmsProvider:MainAPI() { (MovieSearchResponse(name, href, this.name, TvType.Movie, poster, null)) } } + override suspend fun load(url: String): LoadResponse { val document = app.get(url, timeout = 120).document val title = document.selectFirst(".post_title h1")?.text() ?: "" @@ -73,6 +76,7 @@ class ElifilmsProvider:MainAPI() { tags ) } + override suspend fun loadLinks( data: String, isCasting: Boolean, diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt index 8ad342b8..68103f8c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt @@ -8,7 +8,7 @@ import com.lagradost.cloudstream3.utils.loadExtractor class EntrepeliculasyseriesProvider:MainAPI() { override var mainUrl = "https://entrepeliculasyseries.nu" override var name = "EntrePeliculasySeries" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EstrenosDoramasProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EstrenosDoramasProvider.kt index b02f88fa..bddd9de0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EstrenosDoramasProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EstrenosDoramasProvider.kt @@ -20,7 +20,7 @@ class EstrenosDoramasProvider : MainAPI() { override var mainUrl = "https://www23.estrenosdoramas.net" override var name = "EstrenosDoramas" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FaselHDProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FaselHDProvider.kt index fc2258e0..9a21a42c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FaselHDProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FaselHDProvider.kt @@ -5,7 +5,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink import org.jsoup.nodes.Element class FaselHDProvider : MainAPI() { - override val lang = "ar" + override var lang = "ar" override var mainUrl = "https://faselhd.io" override var name = "FaselHD" override val usesWebView = false diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt index 14fa5d6f..8cf5f753 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt @@ -11,7 +11,7 @@ import org.jsoup.select.Elements class FilmanProvider : MainAPI() { override var mainUrl = "https://filman.cc" override var name = "filman.cc" - override val lang = "pl" + override var lang = "pl" override val hasMainPage = true override val supportedTypes = setOf( TvType.Movie, diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FrenchStreamProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FrenchStreamProvider.kt index e3146a96..9923adca 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FrenchStreamProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FrenchStreamProvider.kt @@ -12,7 +12,7 @@ class FrenchStreamProvider : MainAPI() { override var name = "French Stream" override val hasQuickSearch = false override val hasMainPage = true - override val lang = "fr" + override var lang = "fr" override val supportedTypes = setOf(TvType.AnimeMovie, TvType.TvSeries, TvType.Movie) override suspend fun search(query: String): List { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt index 42ed9dc6..007cde6d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt @@ -10,7 +10,7 @@ import org.jsoup.Jsoup class HDMovie5 : MainAPI() { override var mainUrl = "https://hdmovie5.mba" override var name = "HDMovie" - override val lang = "hi" + override var lang = "hi" override val hasQuickSearch = true override val hasMainPage = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LayarKaca21Provider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LayarKaca21Provider.kt index e8f78b28..393bae12 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LayarKaca21Provider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LayarKaca21Provider.kt @@ -11,7 +11,7 @@ class LayarKacaProvider : MainAPI() { override var mainUrl = "https://149.56.24.226" override var name = "LayarKaca" override val hasMainPage = true - override val lang = "id" + override var lang = "id" override val hasDownloadSupport = true override val supportedTypes = setOf( TvType.Movie, diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MyCimaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MyCimaProvider.kt index bcc39647..b74a281c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MyCimaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MyCimaProvider.kt @@ -8,7 +8,7 @@ import org.jsoup.Jsoup import org.jsoup.nodes.Element class MyCimaProvider : MainAPI() { - override val lang = "ar" + override var lang = "ar" override var mainUrl = "https://mycima.tv" override var name = "MyCima" override val usesWebView = false diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt index d29c4b58..0976c8b8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt @@ -7,7 +7,7 @@ import com.lagradost.cloudstream3.utils.loadExtractor class PeliSmartProvider: MainAPI() { override var mainUrl = "https://pelismart.com" override var name = "PeliSmart" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisflixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisflixProvider.kt index f635573c..005cbb7f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisflixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisflixProvider.kt @@ -9,7 +9,7 @@ import com.lagradost.cloudstream3.utils.loadExtractor class PelisflixProvider : MainAPI() { override var mainUrl = "https://pelisflix.li" override var name = "Pelisflix" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusHDProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusHDProvider.kt index 3aef6b4f..ae8d2718 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusHDProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusHDProvider.kt @@ -8,7 +8,7 @@ import org.jsoup.nodes.Element class PelisplusHDProvider:MainAPI() { override var mainUrl = "https://pelisplushd.net" override var name = "PelisplusHD" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusProviderTemplate.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusProviderTemplate.kt index a9fd90a0..b198b4e4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusProviderTemplate.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusProviderTemplate.kt @@ -12,7 +12,7 @@ import org.jsoup.Jsoup */ open class PelisplusProviderTemplate : MainAPI() { - override val lang = "es" + override var lang = "es" open val homePageUrlList = listOf() // // mainUrl is good to have as a holder for the url to make future changes easier. diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt index 1a5500ef..1e6b71b6 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt @@ -9,7 +9,7 @@ import com.lagradost.cloudstream3.utils.loadExtractor class PinoyHDXyzProvider : MainAPI() { override var name = "Pinoy-HD" override var mainUrl = "https://www.pinoy-hd.xyz" - override val lang = "tl" + override var lang = "tl" override val supportedTypes = setOf(TvType.AsianDrama) override val hasDownloadSupport = true override val hasMainPage = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt index acc22786..7ed1be88 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt @@ -10,7 +10,7 @@ import com.lagradost.cloudstream3.utils.loadExtractor class PinoyMoviePediaProvider : MainAPI() { override var name = "Pinoy Moviepedia" override var mainUrl = "https://pinoymoviepedia.ru" - override val lang = "tl" + override var lang = "tl" override val supportedTypes = setOf(TvType.AsianDrama) override val hasDownloadSupport = true override val hasMainPage = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt index b975255b..cee6107f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt @@ -15,7 +15,7 @@ import org.jsoup.select.Elements class PinoyMoviesEsProvider : MainAPI() { override var name = "Pinoy Movies" override var mainUrl = "https://pinoymovies.es" - override val lang = "tl" + override var lang = "tl" override val supportedTypes = setOf(TvType.AsianDrama) override val hasDownloadSupport = false override val hasMainPage = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/RebahinProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/RebahinProvider.kt index 789d6684..3a004b6b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/RebahinProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/RebahinProvider.kt @@ -15,7 +15,7 @@ class RebahinProvider : MainAPI() { override var mainUrl = "http://167.88.14.149" override var name = "Rebahin" override val hasMainPage = true - override val lang = "id" + override var lang = "id" override val hasDownloadSupport = true override val supportedTypes = setOf( TvType.Movie, diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SeriesflixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SeriesflixProvider.kt index 94683604..7fca3179 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SeriesflixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SeriesflixProvider.kt @@ -9,7 +9,7 @@ import com.lagradost.cloudstream3.utils.loadExtractor class SeriesflixProvider : MainAPI() { override var mainUrl = "https://seriesflix.video" override var name = "Seriesflix" - override val lang = "es" + override var lang = "es" override val hasMainPage = true override val hasChromecastSupport = true override val hasDownloadSupport = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/StreamingcommunityProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/StreamingcommunityProvider.kt index 67be5257..80d2440a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/StreamingcommunityProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/StreamingcommunityProvider.kt @@ -127,7 +127,7 @@ data class TrailerElement( class StreamingcommunityProvider : MainAPI() { - override val lang = "it" + override var lang = "it" override var mainUrl = "https://streamingcommunity.press" override var name = "Streamingcommunity" override val hasMainPage = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt index a598d159..3aef5085 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt @@ -6,7 +6,7 @@ import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.* class TantifilmProvider : MainAPI() { - override val lang = "it" + override var lang = "it" override var mainUrl = "https://www.tantifilm.rodeo" override var name = "Tantifilm" override val hasMainPage = true diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VfFilmProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VfFilmProvider.kt index 51335f6b..a0b3420a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VfFilmProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VfFilmProvider.kt @@ -9,7 +9,7 @@ import org.jsoup.Jsoup class VfFilmProvider : MainAPI() { override var mainUrl = "https://vf-film.me" override var name = "vf-film.me" - override val lang = "fr" + override var lang = "fr" override val hasQuickSearch = false override val hasMainPage = false override val hasChromecastSupport = false diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VfSerieProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VfSerieProvider.kt index 654406d8..552b0be0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VfSerieProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VfSerieProvider.kt @@ -9,7 +9,7 @@ import org.jsoup.Jsoup class VfSerieProvider : MainAPI() { override var mainUrl = "https://vf-serie.org" override var name = "vf-serie.org" - override val lang = "fr" + override var lang = "fr" override val hasQuickSearch = false override val hasMainPage = false diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt index d1ba5f12..b2219d1c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt @@ -13,12 +13,12 @@ class APIRepository(val api: MainAPI) { val noneApi = object : MainAPI() { override var name = "None" override val supportedTypes = emptySet() - override val lang = "" + override var lang = "" } val randomApi = object : MainAPI() { override var name = "Random" override val supportedTypes = emptySet() - override val lang = "" + override var lang = "" } fun isInvalidData(data: String): Boolean { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt index 22ca83a3..781736a1 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt @@ -6,12 +6,18 @@ import android.os.Build import android.os.Bundle import android.os.Environment import android.view.View +import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AlertDialog import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceManager +import com.fasterxml.jackson.annotation.JsonProperty import com.hippo.unifile.UniFile +import com.lagradost.cloudstream3.APIHolder.allProviders import com.lagradost.cloudstream3.AcraApplication +import com.lagradost.cloudstream3.AcraApplication.Companion.getKey +import com.lagradost.cloudstream3.AcraApplication.Companion.setKey +import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.mvvm.logError @@ -20,9 +26,15 @@ import com.lagradost.cloudstream3.network.initClient import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog +import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog +import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog +import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard +import com.lagradost.cloudstream3.utils.USER_PROVIDER_API import com.lagradost.cloudstream3.utils.VideoDownloadManager import com.lagradost.cloudstream3.utils.VideoDownloadManager.getBasePath +import kotlinx.android.synthetic.main.add_remove_sites.* +import kotlinx.android.synthetic.main.add_site_input.* import java.io.File class SettingsGeneral : PreferenceFragmentCompat() { @@ -31,6 +43,17 @@ class SettingsGeneral : PreferenceFragmentCompat() { setUpToolbar(R.string.category_general) } + data class CustomSite( + @JsonProperty("parentJavaClass") // javaClass.simpleName + val parentJavaClass: String, + @JsonProperty("name") + val name: String, + @JsonProperty("url") + val url: String, + @JsonProperty("lang") + val lang: String, + ) + // Open file picker private val pathPicker = registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri -> @@ -64,6 +87,94 @@ class SettingsGeneral : PreferenceFragmentCompat() { setPreferencesFromResource(R.xml.settins_general, rootKey) val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext()) + fun getCurrent(): MutableList { + return getKey>(USER_PROVIDER_API)?.toMutableList() + ?: mutableListOf() + } + + fun showAdd() { + val providers = allProviders.distinctBy { it.javaClass }.sortedBy { it.name } + activity?.showDialog( + providers.map { "${it.name} (${it.mainUrl})" }, + -1, + context?.getString(R.string.add_site_pref) ?: return, + true, + {}) { selection -> + val provider = providers.getOrNull(selection) ?: return@showDialog + + val builder = + AlertDialog.Builder(context ?: return@showDialog, R.style.AlertDialogCustom) + .setView(R.layout.add_site_input) + + val dialog = builder.create() + dialog.show() + + dialog.text2?.text = provider.name + dialog.apply_btt?.setOnClickListener { + val name = dialog.site_name_input?.text?.toString() + val url = dialog.site_url_input?.text?.toString() + val lang = dialog.site_lang_input?.text?.toString() + val realLang = if (lang.isNullOrBlank()) provider.lang else lang + if (url.isNullOrBlank() || name.isNullOrBlank() || realLang.length != 2) { + showToast(activity, R.string.error_invalid_data, Toast.LENGTH_SHORT) + return@setOnClickListener + } + + val current = getCurrent() + val newSite = CustomSite(provider.javaClass.simpleName, name, url, realLang) + current.add(newSite) + setKey(USER_PROVIDER_API, current.toTypedArray()) + + dialog.dismissSafe(activity) + } + dialog.cancel_btt?.setOnClickListener { + dialog.dismissSafe(activity) + } + } + } + + fun showDelete() { + val current = getCurrent() + + activity?.showMultiDialog( + current.map { it.name }, + listOf(), + context?.getString(R.string.remove_site_pref) ?: return, + {}) { indexes -> + current.removeAll(indexes.map { current[it] }) + setKey(USER_PROVIDER_API, current.toTypedArray()) + } + } + + fun showAddOrDelete() { + val builder = + AlertDialog.Builder(context ?: return, R.style.AlertDialogCustom) + .setView(R.layout.add_remove_sites) + + val dialog = builder.create() + dialog.show() + + dialog.add_site?.setOnClickListener { + showAdd() + dialog.dismissSafe(activity) + } + dialog.remove_site?.setOnClickListener { + showDelete() + dialog.dismissSafe(activity) + } + } + + getPref(R.string.override_site_key)?.setOnPreferenceClickListener { _ -> + + if (getCurrent().isEmpty()) { + showAdd() + } else { + showAddOrDelete() + } + + return@setOnPreferenceClickListener true + } + getPref(R.string.legal_notice_key)?.setOnPreferenceClickListener { val builder: AlertDialog.Builder = AlertDialog.Builder(it.context, R.style.AlertDialogCustom) @@ -72,7 +183,7 @@ class SettingsGeneral : PreferenceFragmentCompat() { builder.show() return@setOnPreferenceClickListener true } - + getPref(R.string.dns_key)?.setOnPreferenceClickListener { val prefNames = resources.getStringArray(R.array.dns_pref) val prefValues = resources.getIntArray(R.array.dns_pref_values) @@ -177,6 +288,5 @@ class SettingsGeneral : PreferenceFragmentCompat() { } catch (e: Exception) { e.printStackTrace() } - } } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStore.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStore.kt index 3ad95730..ade1fc38 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStore.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStore.kt @@ -14,6 +14,7 @@ const val DOWNLOAD_HEADER_CACHE = "download_header_cache" const val DOWNLOAD_EPISODE_CACHE = "download_episode_cache" const val VIDEO_PLAYER_BRIGHTNESS = "video_player_alpha_key" const val HOMEPAGE_API = "home_api_used" +const val USER_PROVIDER_API = "user_custom_sites" const val PREFERENCES_NAME = "rebuild_preference" diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt index 0a069cec..814cf95b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt @@ -14,23 +14,33 @@ import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIconsAndNoStringRes import com.lagradost.cloudstream3.utils.UIHelper.setImage object SingleSelectionHelper { - fun Activity.showOptionSelectStringRes( + fun Activity?.showOptionSelectStringRes( view: View?, poster: String?, options: List, tvOptions: List = listOf(), callback: (Pair) -> Unit ) { - this.showOptionSelect(view, poster, options.map { this.getString(it) },tvOptions.map { this.getString(it) }, callback) + if(this == null) return + + this.showOptionSelect( + view, + poster, + options.map { this.getString(it) }, + tvOptions.map { this.getString(it) }, + callback + ) } - private fun Activity.showOptionSelect( + private fun Activity?.showOptionSelect( view: View?, poster: String?, options: List, tvOptions: List, callback: (Pair) -> Unit ) { + if(this == null) return + if (this.isTvSettings()) { val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom) @@ -41,12 +51,13 @@ object SingleSelectionHelper { dialog.findViewById(R.id.listview1)?.let { listView -> listView.choiceMode = AbsListView.CHOICE_MODE_SINGLE - listView.adapter = ArrayAdapter(this, R.layout.sort_bottom_single_choice_color).apply { - addAll(tvOptions) - } + listView.adapter = + ArrayAdapter(this, R.layout.sort_bottom_single_choice_color).apply { + addAll(tvOptions) + } listView.setOnItemClickListener { _, _, i, _ -> - callback.invoke(Pair(true,i)) + callback.invoke(Pair(true, i)) dialog.dismissSafe(this) } } @@ -62,12 +73,12 @@ object SingleSelectionHelper { s ) }) { - callback(Pair(false,this.itemId)) + callback(Pair(false, this.itemId)) } } } - fun Activity.showDialog( + fun Activity?.showDialog( dialog: Dialog, items: List, selectedIndex: List, @@ -77,6 +88,8 @@ object SingleSelectionHelper { callback: (List) -> Unit, dismissCallback: () -> Unit ) { + if(this == null) return + val realShowApply = showApply || isMultiSelect val listView = dialog.findViewById(R.id.listview1)!! val textView = dialog.findViewById(R.id.text1)!! @@ -145,8 +158,7 @@ object SingleSelectionHelper { } - - private fun Activity.showInputDialog( + private fun Activity?.showInputDialog( dialog: Dialog, value: String, name: String, @@ -154,6 +166,8 @@ object SingleSelectionHelper { callback: (String) -> Unit, dismissCallback: () -> Unit ) { + if(this == null) return + val inputView = dialog.findViewById(R.id.nginx_text_input)!! val textView = dialog.findViewById(R.id.text1)!! val applyButton = dialog.findViewById(R.id.apply_btt)!! @@ -184,13 +198,15 @@ object SingleSelectionHelper { } - fun Activity.showMultiDialog( + fun Activity?.showMultiDialog( items: List, selectedIndex: List, name: String, dismissCallback: () -> Unit, callback: (List) -> Unit, ) { + if(this == null) return + val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom) .setView(R.layout.bottom_selection_dialog) @@ -200,7 +216,7 @@ object SingleSelectionHelper { showDialog(dialog, items, selectedIndex, name, true, true, callback, dismissCallback) } - fun Activity.showDialog( + fun Activity?.showDialog( items: List, selectedIndex: Int, name: String, @@ -208,6 +224,8 @@ object SingleSelectionHelper { dismissCallback: () -> Unit, callback: (Int) -> Unit, ) { + if(this == null) return + val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom) .setView(R.layout.bottom_selection_dialog) @@ -227,14 +245,15 @@ object SingleSelectionHelper { } /** Only for a low amount of items */ - fun Activity.showBottomDialog( + fun Activity?.showBottomDialog( items: List, selectedIndex: Int, name: String, showApply: Boolean, - dismissCallback: () -> Unit, + dismissCallback: () -> Unit, callback: (Int) -> Unit, ) { + if (this == null) return val builder = BottomSheetDialog(this) builder.setContentView(R.layout.bottom_selection_dialog) @@ -252,12 +271,12 @@ object SingleSelectionHelper { ) } - fun Activity.showNginxTextInputDialog( - name: String, - value: String, - textInputType: Int?, - dismissCallback: () -> Unit, - callback: (String) -> Unit, + fun Activity.showNginxTextInputDialog( + name: String, + value: String, + textInputType: Int?, + dismissCallback: () -> Unit, + callback: (String) -> Unit, ) { val builder = BottomSheetDialog(this) // probably the stuff at the bottom builder.setContentView(R.layout.bottom_input_dialog) // input layout diff --git a/app/src/main/res/drawable/ic_baseline_add_24.xml b/app/src/main/res/drawable/ic_baseline_add_24.xml index 70046c48..9fdd2903 100644 --- a/app/src/main/res/drawable/ic_baseline_add_24.xml +++ b/app/src/main/res/drawable/ic_baseline_add_24.xml @@ -1,4 +1,4 @@ - diff --git a/app/src/main/res/layout/add_remove_sites.xml b/app/src/main/res/layout/add_remove_sites.xml new file mode 100644 index 00000000..9ef6ad6a --- /dev/null +++ b/app/src/main/res/layout/add_remove_sites.xml @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/add_site_input.xml b/app/src/main/res/layout/add_site_input.xml new file mode 100644 index 00000000..1c61f8b4 --- /dev/null +++ b/app/src/main/res/layout/add_site_input.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b1232736..b499e624 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -50,6 +50,7 @@ bottom_title_key poster_ui_key subtitles_encoding_key + override_site_key %d %s | %sMB @@ -382,6 +383,10 @@ DNS over HTTPS Useful for bypassing ISP blocks + Add site + Remove site + Add a clone of an existing site, with a different url + Download path Nginx server url @@ -440,6 +445,9 @@ MyCoolUsername hello@world.com 127.0.0.1 + MyCoolSite + example.com + Language code (en)