forked from recloudstream/cloudstream
add error toast?
This commit is contained in:
parent
f9d6ade4f5
commit
505d5e1950
2 changed files with 15 additions and 15 deletions
|
@ -6,13 +6,17 @@ import com.google.gson.Gson
|
||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
|
import android.widget.Toast
|
||||||
|
import android.app.Activity
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
||||||
import com.lagradost.cloudstream3.plugins.RepositoryManager.ONLINE_PLUGINS_FOLDER
|
import com.lagradost.cloudstream3.plugins.RepositoryManager.ONLINE_PLUGINS_FOLDER
|
||||||
import com.lagradost.cloudstream3.plugins.RepositoryManager.downloadPluginToFile
|
import com.lagradost.cloudstream3.plugins.RepositoryManager.downloadPluginToFile
|
||||||
|
import com.lagradost.cloudstream3.CommonActivity.showToast
|
||||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||||
|
import com.lagradost.cloudstream3.R
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -89,13 +93,6 @@ object PluginManager {
|
||||||
val name = file.name
|
val name = file.name
|
||||||
if (file.extension == "zip" || file.extension == "cs3") {
|
if (file.extension == "zip" || file.extension == "cs3") {
|
||||||
loadPlugin(context, file, PluginData(name, null, false, file.absolutePath))
|
loadPlugin(context, file, PluginData(name, null, false, file.absolutePath))
|
||||||
} else if (name != "oat") { // Some roms create this
|
|
||||||
if (file.isDirectory) {
|
|
||||||
// Utils.showToast(String.format("Found directory %s in your plugins folder. DO NOT EXTRACT PLUGIN ZIPS!", name), true);
|
|
||||||
} else if (name == "classes.dex" || name.endsWith(".json")) {
|
|
||||||
// Utils.showToast(String.format("Found extracted plugin file %s in your plugins folder. DO NOT EXTRACT PLUGIN ZIPS!", name), true);
|
|
||||||
}
|
|
||||||
// rmrf(f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,8 +123,6 @@ object PluginManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadedLocalPlugins = true
|
loadedLocalPlugins = true
|
||||||
//if (!PluginManager.failedToLoad.isEmpty())
|
|
||||||
//Utils.showToast("Some plugins failed to load.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,10 +155,10 @@ object PluginManager {
|
||||||
loader.loadClass(manifest.pluginClassName) as Class<out Plugin?>
|
loader.loadClass(manifest.pluginClassName) as Class<out Plugin?>
|
||||||
val pluginInstance: Plugin =
|
val pluginInstance: Plugin =
|
||||||
pluginClass.newInstance() as Plugin
|
pluginClass.newInstance() as Plugin
|
||||||
// if (plugins.containsKey(name)) {
|
if (plugins.containsKey(name)) {
|
||||||
//logger.error("Plugin with name " + name + " already exists", null);
|
println("Plugin with name $name already exists")
|
||||||
// return false
|
return false
|
||||||
// }
|
}
|
||||||
pluginInstance.__filename = fileName
|
pluginInstance.__filename = fileName
|
||||||
if (pluginInstance.needsResources) {
|
if (pluginInstance.needsResources) {
|
||||||
// based on https://stackoverflow.com/questions/7483568/dynamic-resource-loading-from-other-apk
|
// based on https://stackoverflow.com/questions/7483568/dynamic-resource-loading-from-other-apk
|
||||||
|
@ -184,7 +179,11 @@ object PluginManager {
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
failedToLoad[file] = e
|
failedToLoad[file] = e
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
//logger.error("Failed to load plugin " + fileName + ":\n", e);
|
showToast(
|
||||||
|
context as Activity,
|
||||||
|
context.getString(R.string.plugin_load_fail).format(fileName),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,8 @@ object UIHelper {
|
||||||
this,
|
this,
|
||||||
arrayOf(
|
arrayOf(
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
|
Manifest.permission.MANAGE_EXTERNAL_STORAGE
|
||||||
),
|
),
|
||||||
1337
|
1337
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue