2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 05:07:40 +00:00

Fix plugin list not recomposing

This commit is contained in:
Albert Vaca Cintora 2024-10-08 22:37:46 +02:00
parent ba98e21d40
commit c32e00bb47
No known key found for this signature in database

View File

@ -280,11 +280,15 @@ class DeviceFragment : Fragment() {
if (device.isPaired) {
requirePairingBinding().pairingButtons.visibility = View.GONE
if (device.isReachable) {
val context = requireContext()
val pluginsWithButtons = device.loadedPlugins.values.filter { it.displayAsButton(context) }.iterator()
val pluginsNeedPermissions = device.pluginsWithoutPermissions.values.filter { device.isPluginEnabled(it.pluginKey) }
val pluginsNeedOptionalPermissions = device.pluginsWithoutOptionalPermissions.values.filter { device.isPluginEnabled(it.pluginKey) }
requireErrorBinding().errorMessageContainer.visibility = View.GONE
requireDeviceBinding().deviceView.visibility = View.VISIBLE
requireDeviceBinding().deviceViewCompose.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent { KdeTheme(context) { PluginList(device) } }
setContent { KdeTheme(context) { PluginList(pluginsWithButtons, pluginsNeedPermissions, pluginsNeedOptionalPermissions) } }
}
displayBatteryInfoIfPossible()
} else {
@ -448,14 +452,11 @@ class DeviceFragment : Fragment() {
}
@Composable
fun PluginList(device : Device) {
val context = requireContext()
val pluginsWithButtons = device.loadedPlugins.values.filter { it.displayAsButton(context) }.iterator()
val pluginsNeedPermissions = device.pluginsWithoutPermissions.values.filter { device.isPluginEnabled(it.pluginKey) }
val pluginsNeedOptionalPermissions = device.pluginsWithoutOptionalPermissions.values.filter { device.isPluginEnabled(it.pluginKey) }
fun PluginList(
pluginsWithButtons: Iterator<Plugin>,
pluginsNeedPermissions: List<Plugin>,
pluginsNeedOptionalPermissions: List<Plugin>
) {
Surface {
Column(modifier = Modifier.padding(top = 16.dp)) {