From b2ba830a8045c441f87089965e0741407d1e3346 Mon Sep 17 00:00:00 2001 From: Kavish Devar Date: Tue, 5 May 2026 13:11:50 +0530 Subject: [PATCH] android: hide reconnect when app hasn't connected once --- .../screens/AirPodsSettingsScreen.kt | 27 ++++++++++--------- .../viewmodel/AirPodsViewModel.kt | 9 +++++-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/android/app/src/main/java/me/kavishdevar/librepods/presentation/screens/AirPodsSettingsScreen.kt b/android/app/src/main/java/me/kavishdevar/librepods/presentation/screens/AirPodsSettingsScreen.kt index a822e77..339c39d 100644 --- a/android/app/src/main/java/me/kavishdevar/librepods/presentation/screens/AirPodsSettingsScreen.kt +++ b/android/app/src/main/java/me/kavishdevar/librepods/presentation/screens/AirPodsSettingsScreen.kt @@ -552,19 +552,22 @@ fun AirPodsSettingsScreen(viewModel: AirPodsViewModel, navController: NavControl } Spacer(Modifier.height(16.dp)) } - StyledButton( - onClick = { - viewModel.reconnectFromSavedMac() - }, backdrop = backdrop, modifier = Modifier.fillMaxWidth(0.9f) - ) { - Text( - text = stringResource(R.string.reconnect_to_last_device), style = TextStyle( - fontSize = 16.sp, - fontWeight = FontWeight.Medium, - fontFamily = FontFamily(Font(R.font.sf_pro)), - color = if (isSystemInDarkTheme()) Color.White else Color.Black + if (state.connectionSuccessful) { + StyledButton( + onClick = { + viewModel.reconnectFromSavedMac() + }, backdrop = backdrop, modifier = Modifier.fillMaxWidth(0.9f) + ) { + Text( + text = stringResource(R.string.reconnect_to_last_device), + style = TextStyle( + fontSize = 16.sp, + fontWeight = FontWeight.Medium, + fontFamily = FontFamily(Font(R.font.sf_pro)), + color = if (isSystemInDarkTheme()) Color.White else Color.Black + ) ) - ) + } } } } diff --git a/android/app/src/main/java/me/kavishdevar/librepods/presentation/viewmodel/AirPodsViewModel.kt b/android/app/src/main/java/me/kavishdevar/librepods/presentation/viewmodel/AirPodsViewModel.kt index c8b22c2..2b18465 100644 --- a/android/app/src/main/java/me/kavishdevar/librepods/presentation/viewmodel/AirPodsViewModel.kt +++ b/android/app/src/main/java/me/kavishdevar/librepods/presentation/viewmodel/AirPodsViewModel.kt @@ -91,7 +91,9 @@ data class AirPodsUiState( val isPremium: Boolean = false, val vendorIdHook: Boolean = false, - val dynamicEndOfCharge: Boolean = false + val dynamicEndOfCharge: Boolean = false, + + val connectionSuccessful: Boolean = false ) class AirPodsViewModel( @@ -354,6 +356,8 @@ class AirPodsViewModel( val vendorIdHook = xposedRemotePref.getBoolean("vendor_id_hook", false) val dynamicEndOfCharge = sharedPreferences.getBoolean("dynamic_end_of_charge", false) + val connectionSuccessful = sharedPreferences.getBoolean("connection_successful", false) + _uiState.update { it.copy( offListeningMode = offListeningModeEnabled, @@ -363,7 +367,8 @@ class AirPodsViewModel( leftAction = leftAction, rightAction = rightAction, vendorIdHook = vendorIdHook, - dynamicEndOfCharge = dynamicEndOfCharge + dynamicEndOfCharge = dynamicEndOfCharge, + connectionSuccessful = connectionSuccessful ) } }