Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade gradle and cleanup #19

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
- name: Clean old builds
run: rm $GITHUB_WORKSPACE/builds/*.cs3

- name: Setup JDK 11
- name: Setup JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- name: Setup Android SDK
uses: android-actions/setup-android@v2
Expand Down
26 changes: 13 additions & 13 deletions ExampleProvider/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
dependencies {
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("com.google.android.material:material:1.4.0")
implementation("androidx.recyclerview:recyclerview:1.2.1")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.recyclerview:recyclerview:1.3.2")
}
// use an integer for version numbers
version = -1

// Use an integer for version numbers
version = 1

cloudstream {
// All of these properties are optional, you can safely remove them
// All of these properties are optional, you can safely remove any of them.

description = "Lorem ipsum"
authors = listOf("Cloudburst")
authors = listOf("Cloudburst", "Luna712")

/**
* Status int as the following:
* Status int as one of the following:
* 0: Down
* 1: Ok
* 2: Slow
* 3: Beta only
* */
status = 1
* 3: Beta-only
**/
status = 1 // Will be 3 if unspecified

tvTypes = listOf("Movie")

requiresResources = true
language = "en"

// random cc logo i found
// Random CC logo I found
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/2/2f/Korduene_Logo.png"
}

android {
buildFeatures {
buildConfig = true
viewBinding = true
}
}
}
2 changes: 1 addition & 1 deletion ExampleProvider/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example"/>
<manifest />
104 changes: 55 additions & 49 deletions ExampleProvider/src/main/kotlin/com/example/BlankFragment.kt
Original file line number Diff line number Diff line change
@@ -1,88 +1,94 @@
package com.example

import android.annotation.SuppressLint
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.lagradost.cloudstream3.R
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.core.content.res.ResourcesCompat
import androidx.core.widget.TextViewCompat
import androidx.fragment.app.Fragment
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [BlankFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class BlankFragment(val plugin: TestPlugin) : BottomSheetDialogFragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}
class BlankFragment(private val plugin: ExamplePlugin) : BottomSheetDialogFragment() {

// Helper function to get a drawable resource by name
@SuppressLint("DiscouragedApi")
@Suppress("SameParameterValue")
private fun getDrawable(name: String): Drawable? {
val id = plugin.resources!!.getIdentifier(name, "drawable", BuildConfig.LIBRARY_PACKAGE_NAME)
return ResourcesCompat.getDrawable(plugin.resources!!, id, null)
val id = plugin.resources?.getIdentifier(name, "drawable", BuildConfig.LIBRARY_PACKAGE_NAME)
return id?.let { ResourcesCompat.getDrawable(plugin.resources ?: return null, it, null) }
}

// Helper function to get a string resource by name
@SuppressLint("DiscouragedApi")
@Suppress("SameParameterValue")
private fun getString(name: String): String? {
val id = plugin.resources!!.getIdentifier(name, "string", BuildConfig.LIBRARY_PACKAGE_NAME)
return plugin.resources!!.getString(id)
val id = plugin.resources?.getIdentifier(name, "string", BuildConfig.LIBRARY_PACKAGE_NAME)
return id?.let { plugin.resources?.getString(it) }
}

private fun <T : View> View.findView(name: String): T {
val id = plugin.resources!!.getIdentifier(name, "id", BuildConfig.LIBRARY_PACKAGE_NAME)
return this.findViewById(id)
// Generic findView function to find views by name
@SuppressLint("DiscouragedApi")
private fun <T : View> View.findViewByName(name: String): T? {
val id = plugin.resources?.getIdentifier(name, "id", BuildConfig.LIBRARY_PACKAGE_NAME)
return findViewById(id ?: return null)
}

@SuppressLint("DiscouragedApi")
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val id = plugin.resources!!.getIdentifier("fragment_blank", "layout", BuildConfig.LIBRARY_PACKAGE_NAME)
val layout = plugin.resources!!.getLayout(id)
return inflater.inflate(layout, container, false)
val layoutId = plugin.resources?.getIdentifier("fragment_blank", "layout", BuildConfig.LIBRARY_PACKAGE_NAME)
return layoutId?.let {
inflater.inflate(plugin.resources?.getLayout(it), container, false)
}
}

@RequiresApi(Build.VERSION_CODES.M)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val imageView = view.findView<ImageView>("imageView")
val imageView2 = view.findView<ImageView>("imageView2")
val textView = view.findView<TextView>("textView")
val textView2 = view.findView<TextView>("textView2")
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?
) {
super.onViewCreated(view, savedInstanceState)

textView.text = getString("hello_fragment")
textView.setTextAppearance(view.context, R.style.ResultInfoText)
textView2.text = view.context.resources.getText(R.string.legal_notice_text)
// Initialize views
val imageView: ImageView? = view.findViewByName("imageView")
val imageView2: ImageView? = view.findViewByName("imageView2")
val textView: TextView? = view.findViewByName("textView")
val textView2: TextView? = view.findViewByName("textView2")

// Set text and styling if the views are found
textView?.apply {
text = getString("hello_fragment")
TextViewCompat.setTextAppearance(this, R.style.ResultInfoText)
}

imageView.setImageDrawable(
getDrawable("ic_android_24dp")
)
imageView.imageTintList = ColorStateList.valueOf(view.context.getColor(R.color.white))
textView2?.text = view.context.resources.getText(R.string.legal_notice_text)

imageView2.setImageDrawable(
getDrawable("ic_android_24dp")
)
imageView2.imageTintList = ColorStateList.valueOf(view.context.colorFromAttribute(R.attr.white))
// Set image resources and tint if the views are found
imageView?.apply {
setImageDrawable(getDrawable("ic_android_24dp"))
imageTintList = ColorStateList.valueOf(view.context.getColor(R.color.white))
}

imageView2?.apply {
setImageDrawable(getDrawable("ic_android_24dp"))
imageTintList = ColorStateList.valueOf(view.context.colorFromAttribute(R.attr.white))
}
}
}
}
21 changes: 11 additions & 10 deletions ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package com.example

import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
import com.lagradost.cloudstream3.plugins.Plugin
import com.lagradost.cloudstream3.APIHolder
import android.content.Context
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
import com.lagradost.cloudstream3.plugins.Plugin

@CloudstreamPlugin
class TestPlugin: Plugin() {
var activity: AppCompatActivity? = null
class ExamplePlugin: Plugin() {
private var activity: AppCompatActivity? = null

override fun load(context: Context) {
activity = context as AppCompatActivity
activity = context as? AppCompatActivity

// All providers should be added in this manner
registerMainAPI(ExampleProvider(this))
registerMainAPI(ExampleProvider())

openSettings = { ctx ->
openSettings = {
val frag = BlankFragment(this)
frag.show(activity!!.supportFragmentManager, "Frag")
activity?.let {
frag.show(it.supportFragmentManager, "Frag")
}
}
}
}
11 changes: 5 additions & 6 deletions ExampleProvider/src/main/kotlin/com/example/ExampleProvider.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package com.example

import androidx.appcompat.app.AppCompatActivity
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.MainAPI
import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.TvType

class ExampleProvider(val plugin: TestPlugin) : MainAPI() { // all providers must be an intstance of MainAPI
class ExampleProvider : MainAPI() { // All providers must be an instance of MainAPI
override var mainUrl = "https://example.com/"
override var name = "Example provider"
override val supportedTypes = setOf(TvType.Movie)

override var lang = "en"

// enable this when your provider has a main page
// Enable this when your provider has a main page
override val hasMainPage = true

// this function gets called when you search for something
// This function gets called when you search for something
override suspend fun search(query: String): List<SearchResponse> {
return listOf<SearchResponse>()
return listOf()
}
}
2 changes: 1 addition & 1 deletion ExampleProvider/src/main/res/drawable/ic_android_24dp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M17.6,11.48 L19.44,8.3a0.63,0.63 0,0 0,-1.09 -0.63l-1.88,3.24a11.43,11.43 0,0 0,-8.94 0L5.65,7.67a0.63,0.63 0,0 0,-1.09 0.63L6.4,11.48A10.81,10.81 0,0 0,1 20L23,20A10.81,10.81 0,0 0,17.6 11.48ZM7,17.25A1.25,1.25 0,1 1,8.25 16,1.25 1.25,0 0,1 7,17.25ZM17,17.25A1.25,1.25 0,1 1,18.25 16,1.25 1.25,0 0,1 17,17.25Z"/>
</vector>
</vector>
9 changes: 5 additions & 4 deletions ExampleProvider/src/main/res/layout/fragment_blank.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainFragmentLayout"
android:layout_width="match_parent"
Expand All @@ -19,7 +18,7 @@
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="[loaded from app trans]" />
android:text="@string/loaded_from_app_trans" />

<LinearLayout
android:layout_width="wrap_content"
Expand All @@ -30,13 +29,15 @@
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/ic_android_24dp" />
tools:src="@drawable/ic_android_24dp"
tools:ignore="ContentDescription" />

<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/ic_android_24dp" />
tools:src="@drawable/ic_android_24dp"
tools:ignore="ContentDescription" />
</LinearLayout>

</LinearLayout>
1 change: 1 addition & 0 deletions ExampleProvider/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello_fragment">Witaj zabawny fragmencie!!</string>
<string name="loaded_from_app_trans">[Załadowane z aplikacji trans]</string>
</resources>
1 change: 1 addition & 0 deletions ExampleProvider/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello_fragment">Hello funny fragment!!</string>
<string name="loaded_from_app_trans">[loaded from app trans]</string>
</resources>
Loading