mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Add reference to public list
This commit is contained in:
parent
b2ee957833
commit
bbf9f247a9
10 changed files with 135 additions and 31 deletions
|
@ -83,9 +83,9 @@ import kotlin.concurrent.thread
|
|||
import kotlin.reflect.KClass
|
||||
import com.lagradost.cloudstream3.plugins.PluginManager
|
||||
import com.lagradost.cloudstream3.plugins.RepositoryManager
|
||||
import com.lagradost.cloudstream3.plugins.RepositoryManager.PREBUILT_REPOSITORIES
|
||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appStringRepo
|
||||
import com.lagradost.cloudstream3.ui.settings.extensions.RepositoryData
|
||||
import com.lagradost.cloudstream3.ui.setup.SetupFragmentExtensions
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.main
|
||||
import com.lagradost.cloudstream3.utils.Event
|
||||
|
||||
|
@ -133,6 +133,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
companion object {
|
||||
const val TAG = "MAINACT"
|
||||
val afterPluginsLoadedEvent = Event<Boolean>()
|
||||
val afterRepositoryLoadedEvent = Event<Boolean>()
|
||||
}
|
||||
|
||||
override fun onColorSelected(dialogId: Int, color: Int) {
|
||||
|
@ -347,6 +348,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
Toast.LENGTH_LONG
|
||||
)
|
||||
}
|
||||
afterRepositoryLoadedEvent.invoke(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -695,9 +697,9 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
// If no plugins bring up extensions screen
|
||||
} else if (PluginManager.getPluginsOnline().isEmpty()
|
||||
&& PluginManager.getPluginsLocal().isEmpty()
|
||||
&& PREBUILT_REPOSITORIES.isNotEmpty()
|
||||
// && PREBUILT_REPOSITORIES.isNotEmpty()
|
||||
) {
|
||||
navController.navigate(R.id.navigation_setup_extensions)
|
||||
navController.navigate(R.id.navigation_setup_extensions, SetupFragmentExtensions.newInstance(false))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
|
|
|
@ -123,11 +123,15 @@ object RepositoryManager {
|
|||
}
|
||||
}
|
||||
|
||||
fun getRepositories(): Array<RepositoryData> {
|
||||
return getKey(REPOSITORIES_KEY) ?: emptyArray()
|
||||
}
|
||||
|
||||
// Don't want to read before we write in another thread
|
||||
private val repoLock = Mutex()
|
||||
suspend fun addRepository(repository: RepositoryData) {
|
||||
repoLock.withLock {
|
||||
val currentRepos = getKey<Array<RepositoryData>>(REPOSITORIES_KEY) ?: emptyArray()
|
||||
val currentRepos = getRepositories()
|
||||
// No duplicates
|
||||
setKey(REPOSITORIES_KEY, (currentRepos + repository).distinctBy { it.url })
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ import com.lagradost.cloudstream3.utils.DataStoreHelper.deleteAllResumeStateIds
|
|||
import com.lagradost.cloudstream3.utils.DataStoreHelper.removeLastWatched
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.setResultWatchState
|
||||
import com.lagradost.cloudstream3.utils.Event
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.HOMEPAGE_API
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showOptionSelectStringRes
|
||||
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso
|
||||
|
|
|
@ -14,6 +14,7 @@ import androidx.core.view.isVisible
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
|
||||
import com.lagradost.cloudstream3.CommonActivity.showToast
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.mvvm.Some
|
||||
|
@ -25,9 +26,10 @@ import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
|||
import com.lagradost.cloudstream3.utils.Coroutines.main
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import kotlinx.android.synthetic.main.add_repo_input.*
|
||||
import kotlinx.android.synthetic.main.add_repo_input.apply_btt
|
||||
import kotlinx.android.synthetic.main.add_repo_input.cancel_btt
|
||||
import kotlinx.android.synthetic.main.fragment_extensions.*
|
||||
import kotlinx.android.synthetic.main.fragment_extensions.list_repositories
|
||||
|
||||
const val PUBLIC_REPOSITORIES_LIST = "https://recloudstream.github.io/repos/"
|
||||
|
||||
class ExtensionsFragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
|
@ -98,6 +100,10 @@ class ExtensionsFragment : Fragment() {
|
|||
(repo_recycler_view?.adapter as? RepoAdapter)?.updateList(it)
|
||||
}
|
||||
|
||||
list_repositories?.setOnClickListener {
|
||||
openBrowser(PUBLIC_REPOSITORIES_LIST)
|
||||
}
|
||||
|
||||
observe(extensionViewModel.pluginStats) {
|
||||
when (it) {
|
||||
is Some.Success -> {
|
||||
|
@ -154,6 +160,9 @@ class ExtensionsFragment : Fragment() {
|
|||
dialog.repo_url_input?.setText(fixedUrl)
|
||||
}
|
||||
}
|
||||
dialog.list_repositories?.setOnClickListener {
|
||||
openBrowser(PUBLIC_REPOSITORIES_LIST)
|
||||
}
|
||||
|
||||
// dialog.text2?.text = provider.name
|
||||
dialog.apply_btt?.setOnClickListener secondListener@{
|
||||
|
|
|
@ -7,8 +7,12 @@ import android.view.ViewGroup
|
|||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
|
||||
import com.lagradost.cloudstream3.MainActivity.Companion.afterRepositoryLoadedEvent
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.plugins.RepositoryManager
|
||||
import com.lagradost.cloudstream3.plugins.RepositoryManager.PREBUILT_REPOSITORIES
|
||||
import com.lagradost.cloudstream3.ui.settings.extensions.PUBLIC_REPOSITORIES_LIST
|
||||
import com.lagradost.cloudstream3.ui.settings.extensions.PluginsViewModel
|
||||
import com.lagradost.cloudstream3.ui.settings.extensions.RepoAdapter
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
||||
|
@ -19,6 +23,10 @@ import kotlinx.android.synthetic.main.fragment_setup_media.*
|
|||
class SetupFragmentExtensions : Fragment() {
|
||||
companion object {
|
||||
const val SETUP_EXTENSION_BUNDLE_IS_SETUP = "isSetup"
|
||||
|
||||
/**
|
||||
* If false then this is treated a singular screen with a done button
|
||||
* */
|
||||
fun newInstance(isSetup: Boolean): Bundle {
|
||||
return Bundle().apply {
|
||||
putBoolean(SETUP_EXTENSION_BUNDLE_IS_SETUP, isSetup)
|
||||
|
@ -33,6 +41,33 @@ class SetupFragmentExtensions : Fragment() {
|
|||
return inflater.inflate(R.layout.fragment_setup_extensions, container, false)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
afterRepositoryLoadedEvent += ::setRepositories
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
afterRepositoryLoadedEvent -= ::setRepositories
|
||||
}
|
||||
|
||||
private fun setRepositories(success: Boolean = true) {
|
||||
val repositories = RepositoryManager.getRepositories() + PREBUILT_REPOSITORIES
|
||||
val hasRepos = repositories.isNotEmpty()
|
||||
repo_recycler_view?.isVisible = hasRepos
|
||||
blank_repo_screen?.isVisible = !hasRepos
|
||||
|
||||
if (hasRepos) {
|
||||
repo_recycler_view?.adapter = RepoAdapter(true, {}, {
|
||||
PluginsViewModel.downloadAll(activity, it.url, null)
|
||||
}).apply { updateList(repositories) }
|
||||
} else {
|
||||
list_repositories?.setOnClickListener {
|
||||
openBrowser(PUBLIC_REPOSITORIES_LIST)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
context?.fixPaddingStatusbar(setup_root)
|
||||
|
@ -40,10 +75,7 @@ class SetupFragmentExtensions : Fragment() {
|
|||
|
||||
with(context) {
|
||||
if (this == null) return
|
||||
|
||||
repo_recycler_view?.adapter = RepoAdapter(true, {}, {
|
||||
PluginsViewModel.downloadAll(activity, it.url, null)
|
||||
}).apply { updateList(PREBUILT_REPOSITORIES) }
|
||||
setRepositories()
|
||||
|
||||
if (!isSetup) {
|
||||
next_btt.setText(R.string.setup_done)
|
||||
|
|
|
@ -80,8 +80,10 @@ class SetupFragmentLanguage : Fragment() {
|
|||
|
||||
next_btt?.setOnClickListener {
|
||||
// If no plugins go to plugins page
|
||||
val nextDestination = if (PluginManager.getPluginsOnline()
|
||||
.isEmpty() && PREBUILT_REPOSITORIES.isNotEmpty()
|
||||
val nextDestination = if (
|
||||
PluginManager.getPluginsOnline().isEmpty()
|
||||
&& PluginManager.getPluginsLocal().isEmpty()
|
||||
//&& PREBUILT_REPOSITORIES.isNotEmpty()
|
||||
) R.id.action_navigation_global_to_navigation_setup_extensions
|
||||
else R.id.action_navigation_setup_language_to_navigation_setup_provider_languages
|
||||
|
||||
|
|
|
@ -6,16 +6,21 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_rowWeight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:text="@string/add_repository"
|
||||
|
@ -23,6 +28,14 @@
|
|||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/list_repositories"
|
||||
style="@style/WhiteButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/view_public_repositories_button_short" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -19,10 +19,11 @@
|
|||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
app:layout_constraintBottom_toTopOf="@id/download_storage_appbar"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:listitem="@layout/repository_item" />
|
||||
tools:listitem="@layout/repository_item"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
tools:visibility="gone"
|
||||
android:id="@+id/blank_repo_screen"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -31,17 +32,24 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_margin="10dp"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_margin="10dp"
|
||||
android:src="@drawable/ic_baseline_extension_24" />
|
||||
|
||||
<TextView
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/blank_repo_message"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/list_repositories"
|
||||
style="@style/WhiteButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/view_public_repositories_button" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/setup_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -21,12 +21,43 @@
|
|||
android:gravity="center"
|
||||
android:text="@string/setup_extensions_subtext" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/repo_recycler_view"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
<LinearLayout
|
||||
android:id="@+id/blank_repo_screen"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:listitem="@layout/repository_item" />
|
||||
android:layout_margin="20dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
tools:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_margin="10dp"
|
||||
android:src="@drawable/ic_baseline_extension_24" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/blank_repo_message"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/list_repositories"
|
||||
style="@style/WhiteButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/view_public_repositories_button" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/repo_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/repository_item"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/apply_btt_holder"
|
||||
|
|
|
@ -596,4 +596,6 @@
|
|||
<string name="plugins_disabled" formatted="true">Disabled: %d</string>
|
||||
<string name="plugins_not_downloaded" formatted="true">Not downloaded: %d</string>
|
||||
<string name="blank_repo_message">Add a repository to install site extensions</string>
|
||||
<string name="view_public_repositories_button">View public repositories</string>
|
||||
<string name="view_public_repositories_button_short">Public list</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue