From d0424a271f3defedaacc1110794b10e4eaff9ddc Mon Sep 17 00:00:00 2001 From: Sarang S Date: Thu, 18 Aug 2022 12:14:33 +0530 Subject: [PATCH] invoke on auto repo add --- .../cloudstream3/plugins/PluginManager.kt | 22 +-------------- .../lagradost/cloudstream3/utils/AppUtils.kt | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt b/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt index bfba56f2..2a3c013c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt @@ -373,7 +373,7 @@ object PluginManager { ) } - private suspend fun downloadAllPluginsFromRepository( + suspend fun downloadAllPluginsFromRepository( activity: Activity, repositoryUrl: String ) { @@ -387,26 +387,6 @@ object PluginManager { } } - fun Activity.downloadAllPluginsDialog(repositoryUrl: String) { - runOnUiThread { - val context = this - val builder: AlertDialog.Builder = AlertDialog.Builder(this) - builder.setTitle( - "Download all plugins from this repo?" - ) - builder.apply { - // TODO: R.string Yes No - setPositiveButton("Yes") { _, _ -> - showToast(context, R.string.download_started, Toast.LENGTH_LONG) - ioSafe { downloadAllPluginsFromRepository(context, repositoryUrl) } - } - - setNegativeButton("No") { _, _ -> } - } - builder.show() - } - } - /** * @param isFilePath will treat the pluginUrl as as the filepath instead of url * */ diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt index 7102d52a..b372fb62 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt @@ -25,6 +25,7 @@ import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.annotation.RequiresApi import androidx.annotation.WorkerThread +import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.core.text.HtmlCompat @@ -48,6 +49,7 @@ import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.MainActivity.Companion.afterRepositoryLoadedEvent import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.normalSafeApiCall +import com.lagradost.cloudstream3.plugins.PluginManager import com.lagradost.cloudstream3.plugins.RepositoryManager import com.lagradost.cloudstream3.ui.WebviewFragment import com.lagradost.cloudstream3.ui.result.ResultFragment @@ -257,6 +259,32 @@ object AppUtils { ) } afterRepositoryLoadedEvent.invoke(true) + downloadAllPluginsDialog(url) + } + } + + fun Activity.downloadAllPluginsDialog(repositoryUrl: String) { + runOnUiThread { + val context = this + val builder: AlertDialog.Builder = AlertDialog.Builder(this) + builder.setTitle( + "Download all plugins from this repo?" + ) + builder.apply { + // TODO: R.string Yes No + setPositiveButton("Yes") { _, _ -> + showToast(context, R.string.download_started, Toast.LENGTH_LONG) + ioSafe { + PluginManager.downloadAllPluginsFromRepository( + context, + repositoryUrl + ) + } + } + + setNegativeButton("No") { _, _ -> } + } + builder.show() } }