From 8b9f95381807f289694abd68d71347013fa1144d Mon Sep 17 00:00:00 2001 From: darken Date: Mon, 4 May 2026 12:50:28 +0200 Subject: [PATCH] feat(widget): Show profile name and nearby state when ANC widget is disconnected --- .../ui/widget/AncWidgetRenderStateMapper.kt | 22 +++++++++++++------ .../capod/main/ui/widget/WidgetDeviceKey.kt | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/darken/capod/main/ui/widget/AncWidgetRenderStateMapper.kt b/app/src/main/java/eu/darken/capod/main/ui/widget/AncWidgetRenderStateMapper.kt index 7acbc14d..195a7cfe 100644 --- a/app/src/main/java/eu/darken/capod/main/ui/widget/AncWidgetRenderStateMapper.kt +++ b/app/src/main/java/eu/darken/capod/main/ui/widget/AncWidgetRenderStateMapper.kt @@ -58,13 +58,21 @@ object AncWidgetRenderStateMapper { primaryText = context.getString(R.string.anc_widget_no_anc_support_label), ) - !device.isAapConnected -> AncWidgetRenderState.Message( - theme = theme, - resolvedBgColor = bgColor, - resolvedTextColor = textColor, - resolvedIconColor = iconColor, - primaryText = context.getString(R.string.anc_widget_aap_not_connected_label), - ) + !device.isAapConnected -> { + val secondaryRes = if (device.ble != null) { + R.string.anc_widget_aap_not_connected_nearby_description + } else { + R.string.anc_widget_aap_not_connected_not_nearby_description + } + AncWidgetRenderState.Message( + theme = theme, + resolvedBgColor = bgColor, + resolvedTextColor = textColor, + resolvedIconColor = iconColor, + primaryText = profileLabel ?: device.getLabel(context), + secondaryText = context.getString(secondaryRes), + ) + } !device.isAapReady -> AncWidgetRenderState.Message( theme = theme, diff --git a/app/src/main/java/eu/darken/capod/main/ui/widget/WidgetDeviceKey.kt b/app/src/main/java/eu/darken/capod/main/ui/widget/WidgetDeviceKey.kt index 04da1c4e..59d9f626 100644 --- a/app/src/main/java/eu/darken/capod/main/ui/widget/WidgetDeviceKey.kt +++ b/app/src/main/java/eu/darken/capod/main/ui/widget/WidgetDeviceKey.kt @@ -27,6 +27,7 @@ internal data class WidgetDeviceKey( val isBeingWorn: Boolean?, val isAapConnected: Boolean, val isAapReady: Boolean, + val hasBleAdvertisement: Boolean, val ancMode: AapSetting.AncMode.Value?, val pendingAncMode: AapSetting.AncMode.Value?, val visibleAncModes: List, @@ -49,6 +50,7 @@ internal fun PodDevice.toWidgetKey(): WidgetDeviceKey = WidgetDeviceKey( isBeingWorn = isBeingWorn, isAapConnected = isAapConnected, isAapReady = isAapReady, + hasBleAdvertisement = ble != null, ancMode = ancMode?.current, pendingAncMode = pendingAncMode, visibleAncModes = visibleAncModes, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 169769a9..62361ecc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -157,6 +157,8 @@ This widget requires a direct connection (AAP) to your device. Make sure your device is paired and connected in the app before using this widget. This device does not support noise control Not connected + Nearby but not connected + Not nearby Connecting… Noise Control Permission required