diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt index 8480c94d..f674cafe 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt @@ -16,7 +16,6 @@ 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.MainActivity.Companion.afterRepositoryLoadedEvent import com.lagradost.cloudstream3.R @@ -25,7 +24,6 @@ import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.plugins.RepositoryManager import com.lagradost.cloudstream3.ui.result.setText import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings -import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar import com.lagradost.cloudstream3.utils.AppUtils.downloadAllPluginsDialog import com.lagradost.cloudstream3.utils.Coroutines.ioSafe @@ -34,7 +32,6 @@ import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe import com.lagradost.cloudstream3.widget.LinearRecycleViewLayoutManager import kotlinx.android.synthetic.main.add_repo_input.* 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/" @@ -128,20 +125,20 @@ class ExtensionsFragment : Fragment() { } } - list_repositories?.setOnClickListener { - // Open webview on tv if browser fails - val isTv = isTvSettings() - openBrowser(PUBLIC_REPOSITORIES_LIST, isTv, this) - - // Set clipboard on TV because the browser might not exist or work properly - if (isTv) { - val serviceClipboard = - (activity?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager?) - ?: return@setOnClickListener - val clip = ClipData.newPlainText("Repository url", PUBLIC_REPOSITORIES_LIST) - serviceClipboard.setPrimaryClip(clip) - } - } +// list_repositories?.setOnClickListener { +// // Open webview on tv if browser fails +// val isTv = isTvSettings() +// openBrowser(PUBLIC_REPOSITORIES_LIST, isTv, this) +// +// // Set clipboard on TV because the browser might not exist or work properly +// if (isTv) { +// val serviceClipboard = +// (activity?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager?) +// ?: return@setOnClickListener +// val clip = ClipData.newPlainText("Repository url", PUBLIC_REPOSITORIES_LIST) +// serviceClipboard.setPrimaryClip(clip) +// } +// } observe(extensionViewModel.pluginStats) { when (it) { @@ -200,11 +197,11 @@ class ExtensionsFragment : Fragment() { } } - dialog.list_repositories?.setOnClickListener { - // Open webview on tv if browser fails - openBrowser(PUBLIC_REPOSITORIES_LIST, isTvSettings(), this) - dialog.dismissSafe() - } +// dialog.list_repositories?.setOnClickListener { +// // Open webview on tv if browser fails +// openBrowser(PUBLIC_REPOSITORIES_LIST, isTvSettings(), this) +// dialog.dismissSafe() +// } // dialog.text2?.text = provider.name dialog.apply_btt?.setOnClickListener secondListener@{ diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsViewModel.kt index 6d94f91e..b0e253be 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsViewModel.kt @@ -12,7 +12,6 @@ import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.apmap import com.lagradost.cloudstream3.mvvm.launchSafe -import com.lagradost.cloudstream3.plugins.PluginData import com.lagradost.cloudstream3.plugins.PluginManager import com.lagradost.cloudstream3.plugins.PluginManager.getPluginPath import com.lagradost.cloudstream3.plugins.RepositoryManager @@ -21,8 +20,8 @@ import com.lagradost.cloudstream3.ui.result.txt import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread -import kotlinx.coroutines.launch import me.xdrop.fuzzywuzzy.FuzzySearch +import java.io.File typealias Plugin = Pair /** @@ -47,7 +46,11 @@ class PluginsViewModel : ViewModel() { private val repositoryCache: MutableMap> = mutableMapOf() const val TAG = "PLG" - private fun isDownloaded(context: Context, pluginName: String, repositoryUrl: String): Boolean { + private fun isDownloaded( + context: Context, + pluginName: String, + repositoryUrl: String + ): Boolean { return getPluginPath(context, pluginName, repositoryUrl).exists() } @@ -73,7 +76,13 @@ class PluginsViewModel : ViewModel() { if (activity == null) return@ioSafe val plugins = getPlugins(repositoryUrl) - plugins.filter { plugin -> !isDownloaded(activity, plugin.second.internalName, repositoryUrl) }.also { list -> + plugins.filter { plugin -> + !isDownloaded( + activity, + plugin.second.internalName, + repositoryUrl + ) + }.also { list -> main { showToast( activity, @@ -133,9 +142,13 @@ class PluginsViewModel : ViewModel() { if (activity == null) return@ioSafe val (repo, metadata) = plugin - val file = getPluginPath(activity, plugin.second.internalName, plugin.first) + val file = if (isLocal) File(plugin.second.url) else getPluginPath( + activity, + plugin.second.internalName, + plugin.first + ) - val (success, message) = if (file.exists() || isLocal) { + val (success, message) = if (file.exists()) { PluginManager.deletePlugin(file) to R.string.plugin_deleted } else { PluginManager.downloadAndLoadPlugin( @@ -167,7 +180,9 @@ class PluginsViewModel : ViewModel() { } this.plugins = list - _filteredPlugins.postValue(false to list.filterTvTypes().filterLang().sortByQuery(currentQuery)) + _filteredPlugins.postValue( + false to list.filterTvTypes().filterLang().sortByQuery(currentQuery) + ) } // Perhaps can be optimized? @@ -175,7 +190,8 @@ class PluginsViewModel : ViewModel() { if (tvTypes.isEmpty()) return this return this.filter { (it.plugin.second.tvTypes?.any { type -> tvTypes.contains(type) } == true) || - (tvTypes.contains("Others") && (it.plugin.second.tvTypes ?: emptyList()).isEmpty()) + (tvTypes.contains("Others") && (it.plugin.second.tvTypes + ?: emptyList()).isEmpty()) } } @@ -199,7 +215,9 @@ class PluginsViewModel : ViewModel() { } fun updateFilteredPlugins() { - _filteredPlugins.postValue(false to plugins.filterTvTypes().filterLang().sortByQuery(currentQuery)) + _filteredPlugins.postValue( + false to plugins.filterTvTypes().filterLang().sortByQuery(currentQuery) + ) } fun updatePluginList(context: Context?, repositoryUrl: String) = viewModelScope.launchSafe { @@ -210,7 +228,9 @@ class PluginsViewModel : ViewModel() { fun search(query: String?) { currentQuery = query - _filteredPlugins.postValue(true to (filteredPlugins.value?.second?.sortByQuery(query) ?: emptyList())) + _filteredPlugins.postValue( + true to (filteredPlugins.value?.second?.sortByQuery(query) ?: emptyList()) + ) } /** @@ -226,6 +246,8 @@ class PluginsViewModel : ViewModel() { } plugins = downloadedPlugins - _filteredPlugins.postValue(false to downloadedPlugins.filterTvTypes().filterLang().sortByQuery(currentQuery)) + _filteredPlugins.postValue( + false to downloadedPlugins.filterTvTypes().filterLang().sortByQuery(currentQuery) + ) } } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentExtensions.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentExtensions.kt index 43037038..7b7e5458 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentExtensions.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentExtensions.kt @@ -7,21 +7,16 @@ 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.SettingsFragment.Companion.isTvSettings -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.Coroutines.main import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar import kotlinx.android.synthetic.main.fragment_extensions.blank_repo_screen -import kotlinx.android.synthetic.main.fragment_extensions.list_repositories import kotlinx.android.synthetic.main.fragment_extensions.repo_recycler_view -import kotlinx.android.synthetic.main.fragment_setup_extensions.* import kotlinx.android.synthetic.main.fragment_setup_media.next_btt import kotlinx.android.synthetic.main.fragment_setup_media.prev_btt import kotlinx.android.synthetic.main.fragment_setup_media.setup_root @@ -64,18 +59,19 @@ class SetupFragmentExtensions : Fragment() { val hasRepos = repositories.isNotEmpty() repo_recycler_view?.isVisible = hasRepos blank_repo_screen?.isVisible = !hasRepos - view_public_repositories_button?.isVisible = hasRepos +// view_public_repositories_button?.isVisible = hasRepos if (hasRepos) { repo_recycler_view?.adapter = RepoAdapter(true, {}, { PluginsViewModel.downloadAll(activity, it.url, null) }).apply { updateList(repositories) } - } else { - list_repositories?.setOnClickListener { - // Open webview on tv if browser fails - openBrowser(PUBLIC_REPOSITORIES_LIST, isTvSettings(), this) - } } +// else { +// list_repositories?.setOnClickListener { +// // Open webview on tv if browser fails +// openBrowser(PUBLIC_REPOSITORIES_LIST, isTvSettings(), this) +// } +// } } } @@ -84,9 +80,9 @@ class SetupFragmentExtensions : Fragment() { context?.fixPaddingStatusbar(setup_root) val isSetup = arguments?.getBoolean(SETUP_EXTENSION_BUNDLE_IS_SETUP) ?: false - view_public_repositories_button?.setOnClickListener { - openBrowser(PUBLIC_REPOSITORIES_LIST, isTvSettings(), this) - } +// view_public_repositories_button?.setOnClickListener { +// openBrowser(PUBLIC_REPOSITORIES_LIST, isTvSettings(), this) +// } with(context) { if (this == null) return diff --git a/app/src/main/res/layout/add_repo_input.xml b/app/src/main/res/layout/add_repo_input.xml index 445e71ec..6f6b4d5b 100644 --- a/app/src/main/res/layout/add_repo_input.xml +++ b/app/src/main/res/layout/add_repo_input.xml @@ -28,15 +28,15 @@ android:textSize="20sp" android:textStyle="bold" /> - + + + + + + + + + - + + + + + + - + + + + + - + + + + + + Disabled: %d Not downloaded: %d Updated %d plugins - Add a repository to install site extensions + CloudStream has no sites installed by default. You need to install the sites from repositories.\n\nBecause of a brainless DMCA takedown by Sky Uk Limited 🤮 we cannot link the repository sites in app.\n\nJoin our discord for links or search online. View community repositories Public list Uppercase all subtitles