Added adult marker support and status int to SitePlugin

This commit is contained in:
Blatzar 2022-08-07 13:48:01 +02:00
parent 2af440ee30
commit 8f3176d2cf
4 changed files with 34 additions and 11 deletions

View file

@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
import com.lagradost.cloudstream3.PROVIDER_STATUS_OK
import com.lagradost.cloudstream3.apmap
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall
@ -27,17 +28,26 @@ data class Repository(
@JsonProperty("pluginLists") val pluginLists: List<String>
)
/**
* Status int as the following:
* 0: Down
* 1: Ok
* 2: Slow
* 3: Beta only
* */
data class SitePlugin(
@JsonProperty("url") val url: String,
@JsonProperty("tvTypes") val tvTypes: List<String>?,
@JsonProperty("status") val status: Int,
@JsonProperty("version") val version: Int,
@JsonProperty("apiVersion") val apiVersion: Int,
@JsonProperty("name") val name: String,
@JsonProperty("authors") val authors: List<String>,
@JsonProperty("description") val description: String?,
@JsonProperty("repositoryUrl") val repositoryUrl: String?,
@JsonProperty("tvTypes") val tvTypes: List<String>?,
@JsonProperty("language") val language: String?,
@JsonProperty("iconUrl") val iconUrl: String?
@JsonProperty("iconUrl") val iconUrl: String?,
@JsonProperty("isAdult") val isAdult: Boolean?,
)
@ -63,7 +73,7 @@ object RepositoryManager {
val repo = parseRepository(repositoryUrl) ?: return null
return repo.pluginLists.apmap {
parsePlugins(it)
}.filterNotNull().flatten()
}.flatten()
}
suspend fun downloadPluginToFile(context: Context, pluginUrl: String, name: String): File? {

View file

@ -3,6 +3,7 @@ package com.lagradost.cloudstream3.ui.settings.extensions
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.plugins.PluginData
@ -51,7 +52,8 @@ class PluginAdapter(
R.drawable.ic_baseline_delete_outline_24
else R.drawable.netflix_download
itemView.action_button.setImageResource(drawableInt)
itemView.nsfw_marker?.isVisible = plugin.isAdult == true
itemView.action_button?.setImageResource(drawableInt)
itemView.action_button?.setOnClickListener {
iconClickCallback.invoke(this@PluginAdapter, plugin, isDownloaded)

View file

@ -7,9 +7,9 @@
android:padding="20dp">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
@ -28,13 +28,23 @@
tools:text="https://github.com/..." />
</LinearLayout>
<ImageView
android:id="@+id/action_button"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
tools:src="@drawable/ic_baseline_add_24"
android:layout_height="wrap_content">
<TextView
android:visibility="gone"
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/nsfw_marker"
style="@style/SearchBox"
android:background="@drawable/sub_bg_color"
android:text="@string/is_adult" />
<ImageView
android:layout_marginStart="10dp"
android:id="@+id/action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
tools:src="@drawable/ic_baseline_add_24">
</ImageView>

View file

@ -576,4 +576,5 @@
<string name="plugin_loaded">Plugin Loaded</string>
<string name="plugin_deleted">Plugin Deleted</string>
<string name="plugin_load_fail" formatted="true">Failed to load %s</string>
<string name="is_adult">18+</string>
</resources>