diff --git a/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt b/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt index 13f58e35b..498b917ee 100644 --- a/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt +++ b/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt @@ -408,6 +408,11 @@ class V8Plugin { } } } + fun executeString(js: String) : String? = busy { + catchScriptErrors("Plugin[${config.name}]") { + executeTyped(js).value + } + } fun executeTyped(js: String) : T { warnIfMainThread("V8Plugin.executeTyped"); if(isStopped) diff --git a/app/src/main/java/com/futo/platformplayer/states/StatePlugins.kt b/app/src/main/java/com/futo/platformplayer/states/StatePlugins.kt index b7c2be7a7..4d213d651 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StatePlugins.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StatePlugins.kt @@ -57,8 +57,13 @@ class StatePlugins { return iconsDir.getIconBinary(id); return null; } - + suspend fun getDynamicIcon(id: String): String? = withContext(Dispatchers.IO) { + val client = StatePlatform.instance.getClientOrNull(id) as? JSClient ?: return@withContext null; + return@withContext client.getUnderlyingPlugin().executeString("source.getIcon()") + } fun reloadPluginFile(){ + + _plugins = FragmentedStorage.storeJson("plugins") .load(); } diff --git a/app/src/main/java/com/futo/platformplayer/views/sources/SourceHeaderView.kt b/app/src/main/java/com/futo/platformplayer/views/sources/SourceHeaderView.kt index 614f7d069..be0961002 100644 --- a/app/src/main/java/com/futo/platformplayer/views/sources/SourceHeaderView.kt +++ b/app/src/main/java/com/futo/platformplayer/views/sources/SourceHeaderView.kt @@ -77,12 +77,20 @@ class SourceHeaderView : LinearLayout { val loadedIcon = StatePlugins.instance.getPluginIconOrNull(config.id); if(loadedIcon != null) loadedIcon.setImageView(_sourceImage); - else - Glide.with(_sourceImage) - .load(config.absoluteIconUrl) - .into(_sourceImage); + else { + StateApp.instance.scope.launch { + val dynamicIcon = StatePlugins.instance.getDynamicIcon(config.id) + val iconToLoad = dynamicIcon ?: config.absoluteIconUrl + withContext(Dispatchers.Main) { + Glide.with(_sourceImage) + .load(iconToLoad) + .into(_sourceImage); + } + } + } _sourceTitle.text = config.name; + _sourceBy.text = config.author _sourceDescription.text = config.description; _sourceVersion.text = config.version.toString();