invoke on auto repo add

This commit is contained in:
Sarang S 2022-08-18 12:14:33 +05:30
parent 40141f2d27
commit d0424a271f
2 changed files with 29 additions and 21 deletions

View file

@ -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
* */

View file

@ -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()
}
}