2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 13:17:43 +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) { if (device.isPaired) {
requirePairingBinding().pairingButtons.visibility = View.GONE requirePairingBinding().pairingButtons.visibility = View.GONE
if (device.isReachable) { 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 requireErrorBinding().errorMessageContainer.visibility = View.GONE
requireDeviceBinding().deviceView.visibility = View.VISIBLE requireDeviceBinding().deviceView.visibility = View.VISIBLE
requireDeviceBinding().deviceViewCompose.apply { requireDeviceBinding().deviceViewCompose.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent { KdeTheme(context) { PluginList(device) } } setContent { KdeTheme(context) { PluginList(pluginsWithButtons, pluginsNeedPermissions, pluginsNeedOptionalPermissions) } }
} }
displayBatteryInfoIfPossible() displayBatteryInfoIfPossible()
} else { } else {
@ -448,14 +452,11 @@ class DeviceFragment : Fragment() {
} }
@Composable @Composable
fun PluginList(device : Device) { fun PluginList(
pluginsWithButtons: Iterator<Plugin>,
val context = requireContext() pluginsNeedPermissions: List<Plugin>,
pluginsNeedOptionalPermissions: List<Plugin>
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) }
Surface { Surface {
Column(modifier = Modifier.padding(top = 16.dp)) { Column(modifier = Modifier.padding(top = 16.dp)) {