Skip to content
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
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ concurrency:
cancel-in-progress: true

on:
push:
pull_request:
branches:
# choose your default branch
- master
Expand All @@ -33,9 +33,11 @@ jobs:
run: rm $GITHUB_WORKSPACE/builds/*.cs3

- name: Setup JDK 17
uses: actions/setup-java@v1
uses: actions/setup-java@v5
with:
java-version: 17
distribution: adopt
cache: gradle

- name: Setup Android SDK
uses: android-actions/setup-android@v2
Expand All @@ -45,6 +47,7 @@ jobs:
cd $GITHUB_WORKSPACE/src
chmod +x gradlew
./gradlew make makePluginsJson
ls -R .
cp **/build/*.cs3 $GITHUB_WORKSPACE/builds
cp build/plugins.json $GITHUB_WORKSPACE/builds

Expand Down
29 changes: 26 additions & 3 deletions ExampleProvider/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("com.google.android.material:material:1.13.0")
implementation("androidx.recyclerview:recyclerview:1.4.0")
}

// Use an integer for version numbers
Expand Down Expand Up @@ -35,4 +35,27 @@ android {
buildConfig = true
viewBinding = true
}
}
}

tasks.register<Copy>("includeViewBindingInDex") {
group = "build"
description = "Ensures ViewBinding-generated classes are included in dex."

dependsOn("compileDebugKotlin")

val viewBindingDir = layout.buildDirectory.dir("generated/data_binding_base_class_source_out/debug/out")
val dexInputDir = layout.buildDirectory.dir("../src/main/java")

from(viewBindingDir)
into(dexInputDir)

doLast {
println("Included ViewBinding classes from: ${viewBindingDir.get().asFile}, to: ${dexInputDir.get().asFile}")
}
}

tasks.named("compileDex") {
dependsOn("includeViewBindingInDex")
// val dexInputDir = layout.buildDirectory.dir("intermediates/classes.dex").get().asFile
// inputs.dir(dexInputDir)
}
79 changes: 22 additions & 57 deletions ExampleProvider/src/main/kotlin/com/example/BlankFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@ import android.annotation.SuppressLint
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
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.example.databinding.FragmentBlankBinding
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.ui.BaseBottomSheetDialogFragment
import com.lagradost.cloudstream3.ui.BaseFragment
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute

/**
* A simple [Fragment] subclass.
* A simple [BaseBottomSheetDialogFragment] subclass.
*/
class BlankFragment(private val plugin: ExamplePlugin) : BottomSheetDialogFragment() {
class BlankFragment(private val plugin: ExamplePlugin) : BaseBottomSheetDialogFragment<FragmentBlankBinding>(
BaseFragment.BindingCreator.Inflate(FragmentBlankBinding::inflate)
) {

// Helper function to get a drawable resource by name
@SuppressLint("DiscouragedApi")
Expand All @@ -34,61 +31,29 @@ class BlankFragment(private val plugin: ExamplePlugin) : BottomSheetDialogFragme
// Helper function to get a string resource by name
@SuppressLint("DiscouragedApi")
@Suppress("SameParameterValue")
private fun getString(name: String): String? {
private fun getStringRes(name: String): String? {
val id = plugin.resources?.getIdentifier(name, "string", BuildConfig.LIBRARY_PACKAGE_NAME)
return id?.let { plugin.resources?.getString(it) }
}

// 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?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val layoutId = plugin.resources?.getIdentifier("fragment_blank", "layout", BuildConfig.LIBRARY_PACKAGE_NAME)
return layoutId?.let {
inflater.inflate(plugin.resources?.getLayout(it), container, false)
}
override fun fixPadding(view: View) {
// Don't need any padding here
}

@RequiresApi(Build.VERSION_CODES.M)
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?
) {
super.onViewCreated(view, savedInstanceState)
override fun onBindingCreated(binding: FragmentBlankBinding) {
binding.apply {
// Set text
textView.text = getStringRes("hello_fragment")
TextViewCompat.setTextAppearance(textView, R.style.ResultInfoText)

// 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")
textView2.text = root.context.resources.getText(R.string.legal_notice_text)

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

textView2?.text = view.context.resources.getText(R.string.legal_notice_text)

// 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))
}
// Set images
imageView.setImageDrawable(getDrawable("ic_android_24dp"))
imageView.imageTintList = ColorStateList.valueOf(root.context.getColor(R.color.white))

imageView2?.apply {
setImageDrawable(getDrawable("ic_android_24dp"))
imageTintList = ColorStateList.valueOf(view.context.colorFromAttribute(R.attr.white))
imageView2.setImageDrawable(getDrawable("ic_android_24dp"))
imageView2.imageTintList = ColorStateList.valueOf(root.context.colorFromAttribute(R.attr.white))
}
}
}
}
16 changes: 8 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ buildscript {
}

dependencies {
classpath("com.android.tools.build:gradle:8.7.3")
classpath("com.android.tools.build:gradle:8.13.0")
// Cloudstream gradle plugin which makes everything work and builds plugins
classpath("com.github.recloudstream:gradle:-SNAPSHOT")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.21")
}
}

Expand Down Expand Up @@ -46,8 +46,8 @@ subprojects {

defaultConfig {
minSdk = 21
compileSdkVersion(35)
targetSdk = 35
compileSdkVersion(36)
targetSdk = 36
}

compileOptions {
Expand Down Expand Up @@ -78,14 +78,14 @@ subprojects {
// but you don't need to include any of them if you don't need them.
// https://github.com/recloudstream/cloudstream/blob/master/app/build.gradle.kts
implementation(kotlin("stdlib")) // Adds Standard Kotlin Features
implementation("com.github.Blatzar:NiceHttp:0.4.11") // HTTP Lib
implementation("org.jsoup:jsoup:1.18.3") // HTML Parser
implementation("com.github.Blatzar:NiceHttp:0.4.13") // HTTP Lib
implementation("org.jsoup:jsoup:1.21.2") // HTML Parser
// IMPORTANT: Do not bump Jackson above 2.13.1, as newer versions will
// break compatibility on older Android devices.
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.1") // JSON Parser
}
}

task<Delete>("clean") {
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStoreBase=GRADLE_USER_HOME
8 changes: 8 additions & 0 deletions repo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "TestPlugins Fork",
"description": "TestPlugins Fork",
"manifestVersion": 1,
"pluginLists": [
"https://raw.githubusercontent.com/Luna712/TestPlugins/builds/plugins.json"
]
}