From 0791413efcb5fb8a888cfd425cabd08158446d48 Mon Sep 17 00:00:00 2001 From: C10udburst <18114966+C10udburst@users.noreply.github.com> Date: Wed, 10 Aug 2022 12:30:14 +0200 Subject: [PATCH] add very cursed fragment (search for openFragment) --- ExampleProvider/build.gradle.kts | 13 ++++++ .../main/kotlin/com/example/BlankFragment.kt | 42 +++++++++++++++++++ .../main/kotlin/com/example/ExamplePlugin.kt | 7 +++- .../kotlin/com/example/ExampleProvider.kt | 10 ++++- .../src/main/res/layout/fragment_blank.xml | 22 ++++++++++ 5 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 ExampleProvider/src/main/kotlin/com/example/BlankFragment.kt create mode 100644 ExampleProvider/src/main/res/layout/fragment_blank.xml diff --git a/ExampleProvider/build.gradle.kts b/ExampleProvider/build.gradle.kts index 1728592..fa47e0c 100644 --- a/ExampleProvider/build.gradle.kts +++ b/ExampleProvider/build.gradle.kts @@ -1,3 +1,8 @@ +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") +} // use an integer for version numbers version = 1 @@ -19,4 +24,12 @@ cloudstream { // Set to true to get an 18+ symbol next to the plugin adult = true + + requiresResources = true } + +android { + buildFeatures { + viewBinding = true + } +} \ No newline at end of file diff --git a/ExampleProvider/src/main/kotlin/com/example/BlankFragment.kt b/ExampleProvider/src/main/kotlin/com/example/BlankFragment.kt new file mode 100644 index 0000000..1b8b8a6 --- /dev/null +++ b/ExampleProvider/src/main/kotlin/com/example/BlankFragment.kt @@ -0,0 +1,42 @@ +package com.example + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.google.android.material.bottomsheet.BottomSheetDialogFragment + +// 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) + } + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + // Inflate the layout for this fragment + val id = plugin.resources!!.getIdentifier("fragment_blank", "layout", "com.example") + val layout = plugin.resources!!.getLayout(id) + return inflater.inflate(layout, container, false) + } +} \ No newline at end of file diff --git a/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt b/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt index 0114ee4..8f04e22 100644 --- a/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt +++ b/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt @@ -4,11 +4,16 @@ 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 @CloudstreamPlugin class TestPlugin: Plugin() { + var activity: AppCompatActivity? = null + override fun load(context: Context) { + activity = context as AppCompatActivity // All providers should be added in this manner - registerMainAPI(ExampleProvider()) + registerMainAPI(ExampleProvider(this)) } } \ No newline at end of file diff --git a/ExampleProvider/src/main/kotlin/com/example/ExampleProvider.kt b/ExampleProvider/src/main/kotlin/com/example/ExampleProvider.kt index e66aaa9..27fdf93 100644 --- a/ExampleProvider/src/main/kotlin/com/example/ExampleProvider.kt +++ b/ExampleProvider/src/main/kotlin/com/example/ExampleProvider.kt @@ -1,12 +1,13 @@ package com.example +import androidx.appcompat.app.AppCompatActivity import com.lagradost.cloudstream3.TvType import com.lagradost.cloudstream3.MainAPI import com.lagradost.cloudstream3.SearchResponse -class ExampleProvider : MainAPI() { // all providers must be an intstance of MainAPI +class ExampleProvider(val plugin: TestPlugin) : MainAPI() { // all providers must be an intstance of MainAPI override var mainUrl = "https://example.com/" - override var name = "Example provider" + override var name = "Example sex provider" override val supportedTypes = setOf(TvType.Movie) override var lang = "en" @@ -16,6 +17,11 @@ class ExampleProvider : MainAPI() { // all providers must be an intstance of Mai // this function gets called when you search for something override suspend fun search(query: String): List { + if (query == "openFragment") { + val frag = BlankFragment(plugin) + frag.show(plugin.activity!!.supportFragmentManager, "sexFrag") + } + return listOf() } diff --git a/ExampleProvider/src/main/res/layout/fragment_blank.xml b/ExampleProvider/src/main/res/layout/fragment_blank.xml new file mode 100644 index 0000000..4fb7697 --- /dev/null +++ b/ExampleProvider/src/main/res/layout/fragment_blank.xml @@ -0,0 +1,22 @@ + + + + + + + + \ No newline at end of file