This commit is contained in:
C10udburst 2022-08-14 16:31:33 +02:00
commit 64fd8fdf45
3 changed files with 37 additions and 32 deletions

View file

@ -447,13 +447,15 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
changeStatusBarState(isEmulatorSettings()) changeStatusBarState(isEmulatorSettings())
if (settingsManager.getBoolean(getString(R.string.auto_update_plugins_key), true)) { ioSafe {
PluginManager.updateAllOnlinePluginsAndLoadThem(this) if (settingsManager.getBoolean(getString(R.string.auto_update_plugins_key), true)) {
} else { PluginManager.updateAllOnlinePluginsAndLoadThem(this@MainActivity)
PluginManager.loadAllOnlinePlugins(this) } else {
} PluginManager.loadAllOnlinePlugins(this@MainActivity)
}
PluginManager.loadAllLocalPlugins(this) PluginManager.loadAllLocalPlugins(this@MainActivity)
}
// ioSafe { // ioSafe {
// val plugins = // val plugins =
@ -466,8 +468,10 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
// } // }
// init accounts // init accounts
for (api in accountManagers) { ioSafe {
api.init() for (api in accountManagers) {
api.init()
}
} }
ioSafe { ioSafe {
@ -482,28 +486,29 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
SearchResultBuilder.updateCache(this) SearchResultBuilder.updateCache(this)
ioSafe {
initAll() initAll()
apis = allProviders
try {
getKey<Array<SettingsGeneral.CustomSite>>(USER_PROVIDER_API)?.let { list ->
list.forEach { custom ->
allProviders.firstOrNull { it.javaClass.simpleName == custom.parentJavaClass }
?.let {
allProviders.add(it.javaClass.newInstance().apply {
name = custom.name
lang = custom.lang
mainUrl = custom.url.trimEnd('/')
canBeOverridden = false
})
}
}
}
apis = allProviders apis = allProviders
APIHolder.apiMap = null
} catch (e: Exception) { try {
logError(e) getKey<Array<SettingsGeneral.CustomSite>>(USER_PROVIDER_API)?.let { list ->
list.forEach { custom ->
allProviders.firstOrNull { it.javaClass.simpleName == custom.parentJavaClass }
?.let {
allProviders.add(it.javaClass.newInstance().apply {
name = custom.name
lang = custom.lang
mainUrl = custom.url.trimEnd('/')
canBeOverridden = false
})
}
}
}
apis = allProviders
APIHolder.apiMap = null
} catch (e: Exception) {
logError(e)
}
} }
// val navView: BottomNavigationView = findViewById(R.id.nav_view) // val navView: BottomNavigationView = findViewById(R.id.nav_view)

View file

@ -234,7 +234,7 @@ object PluginManager {
val sortedPlugins = dir.listFiles() val sortedPlugins = dir.listFiles()
// Always sort plugins alphabetically for reproducible results // Always sort plugins alphabetically for reproducible results
Log.d(TAG, "Files in '${LOCAL_PLUGINS_PATH}' folder: ${sortedPlugins}") Log.d(TAG, "Files in '${LOCAL_PLUGINS_PATH}' folder: $sortedPlugins")
sortedPlugins?.sortedBy { it.name }?.apmap { file -> sortedPlugins?.sortedBy { it.name }?.apmap { file ->
maybeLoadPlugin(activity, file) maybeLoadPlugin(activity, file)
@ -375,7 +375,7 @@ object PluginManager {
* */ * */
suspend fun deletePlugin(pluginIdentifier: String, isFilePath: Boolean): Boolean { suspend fun deletePlugin(pluginIdentifier: String, isFilePath: Boolean): Boolean {
val data = val data =
(if (isFilePath) getPluginsLocal().firstOrNull { it.filePath == pluginIdentifier } (if (isFilePath) (getPluginsLocal() + getPluginsOnline()).firstOrNull { it.filePath == pluginIdentifier }
else getPluginsOnline().firstOrNull { it.url == pluginIdentifier }) ?: return false else getPluginsOnline().firstOrNull { it.url == pluginIdentifier }) ?: return false
return try { return try {

View file

@ -128,7 +128,7 @@ class PluginsViewModel : ViewModel() {
plugin: Plugin, plugin: Plugin,
isLocal: Boolean isLocal: Boolean
) = ioSafe { ) = ioSafe {
Log.i(TAG, "handlePluginAction = $repositoryUrl, $plugin") Log.i(TAG, "handlePluginAction = $repositoryUrl, $plugin, $isLocal")
if (activity == null) return@ioSafe if (activity == null) return@ioSafe
val (repo, metadata) = plugin val (repo, metadata) = plugin