fix(overview): Warn when profile has no paired Bluetooth device

This commit is contained in:
darken
2026-04-11 17:56:21 +02:00
committed by Matthias Urhahn
parent 30163a3f69
commit 37e2593d8a
5 changed files with 54 additions and 0 deletions
@@ -131,6 +131,7 @@ fun OverviewScreenHost(vm: OverviewViewModel = hiltViewModel()) {
onToggleUnmatched = { vm.toggleUnmatchedDevices() },
onAncModeChange = { device, mode -> vm.setAncMode(device, mode) },
onDeviceSettings = { device -> vm.goToDeviceSettings(device) },
onEditProfile = { device -> vm.goToEditProfile(device) },
)
}
@@ -144,6 +145,7 @@ fun OverviewScreen(
onToggleUnmatched: () -> Unit,
onAncModeChange: (PodDevice, AapSetting.AncMode.Value) -> Unit = { _, _ -> },
onDeviceSettings: (PodDevice) -> Unit = {},
onEditProfile: (PodDevice) -> Unit = {},
) {
Scaffold(
topBar = {
@@ -236,6 +238,7 @@ fun OverviewScreen(
onAncModeChange = { mode -> onAncModeChange(device, mode) },
onUpgrade = onUpgrade,
onDeviceSettings = { onDeviceSettings(device) },
onEditProfile = { onEditProfile(device) },
)
}
@@ -298,6 +301,7 @@ private fun PodDeviceCard(
onAncModeChange: (AapSetting.AncMode.Value) -> Unit,
onUpgrade: () -> Unit,
onDeviceSettings: (() -> Unit)? = null,
onEditProfile: (() -> Unit)? = null,
) {
when {
device.hasDualPods -> DualPodsCard(
@@ -305,12 +309,14 @@ private fun PodDeviceCard(
onAncModeChange = onAncModeChange,
onUpgrade = onUpgrade,
onDeviceSettings = onDeviceSettings,
onEditProfile = onEditProfile,
)
device.model != PodModel.UNKNOWN -> SinglePodsCard(
device = device, isPro = isPro, showDebug = showDebug, now = now,
onAncModeChange = onAncModeChange,
onUpgrade = onUpgrade,
onDeviceSettings = onDeviceSettings,
onEditProfile = onEditProfile,
)
else -> UnknownPodDeviceCard(device = device, showDebug = showDebug)
}
@@ -158,6 +158,11 @@ class OverviewViewModel @Inject constructor(
navTo(Nav.Main.DeviceSettings(address))
}
fun goToEditProfile(device: PodDevice) {
val profileId = device.profileId ?: return
navTo(Nav.Main.DeviceProfileCreation(profileId = profileId))
}
fun onUpgrade() {
navTo(Nav.Main.Upgrade)
}
@@ -21,6 +21,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.twotone.BatteryChargingFull
import androidx.compose.material.icons.twotone.GridView
import androidx.compose.material.icons.twotone.Tune
import androidx.compose.material.icons.twotone.Warning
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ElevatedCard
@@ -65,6 +66,7 @@ fun DualPodsCard(
onAncModeChange: ((AapSetting.AncMode.Value) -> Unit)? = null,
onUpgrade: (() -> Unit)? = null,
onDeviceSettings: (() -> Unit)? = null,
onEditProfile: (() -> Unit)? = null,
) {
val context = LocalContext.current
@@ -147,6 +149,14 @@ fun DualPodsCard(
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
} else if (device.profileId != null && device.address == null && onEditProfile != null) {
IconButton(onClick = onEditProfile) {
Icon(
imageVector = Icons.TwoTone.Warning,
contentDescription = stringResource(R.string.overview_card_missing_paired_device_cd),
tint = MaterialTheme.colorScheme.error,
)
}
}
}
@@ -429,3 +439,14 @@ private fun DualPodsCardCachedPreview() = PreviewWrapper {
now = Instant.now(),
)
}
@Preview2
@Composable
private fun DualPodsCardMissingAddressPreview() = PreviewWrapper {
DualPodsCard(
device = MockPodDataProvider.dualPodMonitoredMixed(),
showDebug = false,
now = Instant.now(),
onEditProfile = {},
)
}
@@ -22,6 +22,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.twotone.BatteryChargingFull
import androidx.compose.material.icons.twotone.Hearing
import androidx.compose.material.icons.twotone.Tune
import androidx.compose.material.icons.twotone.Warning
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ElevatedCard
@@ -61,6 +62,7 @@ fun SinglePodsCard(
onAncModeChange: ((AapSetting.AncMode.Value) -> Unit)? = null,
onUpgrade: (() -> Unit)? = null,
onDeviceSettings: (() -> Unit)? = null,
onEditProfile: (() -> Unit)? = null,
) {
val context = LocalContext.current
@@ -146,6 +148,14 @@ fun SinglePodsCard(
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
} else if (device.profileId != null && device.address == null && onEditProfile != null) {
IconButton(onClick = onEditProfile) {
Icon(
imageVector = Icons.TwoTone.Warning,
contentDescription = stringResource(R.string.overview_card_missing_paired_device_cd),
tint = MaterialTheme.colorScheme.error,
)
}
}
}
@@ -299,3 +309,14 @@ private fun SinglePodsCardCachedPreview() = PreviewWrapper {
now = Instant.now(),
)
}
@Preview2
@Composable
private fun SinglePodsCardMissingAddressPreview() = PreviewWrapper {
SinglePodsCard(
device = MockPodDataProvider.singlePodMonitored(),
showDebug = false,
now = Instant.now(),
onEditProfile = {},
)
}
+1
View File
@@ -474,6 +474,7 @@
<string name="device_settings_end_call_mute_mic_option_b_title">Single press to mute microphone</string>
<string name="device_settings_end_call_mute_mic_option_b_subtitle">Double press to end call</string>
<string name="device_settings_open_cd">Open device settings</string>
<string name="overview_card_missing_paired_device_cd">Profile has no paired Bluetooth device — tap to edit profile</string>
<!-- New device settings -->
<string name="device_settings_category_general_label">General</string>