android: hide reconnect when app hasn't connected once

This commit is contained in:
Kavish Devar
2026-05-05 13:11:50 +05:30
parent f08769e62f
commit b2ba830a80
2 changed files with 22 additions and 14 deletions

View File

@@ -552,19 +552,22 @@ fun AirPodsSettingsScreen(viewModel: AirPodsViewModel, navController: NavControl
} }
Spacer(Modifier.height(16.dp)) Spacer(Modifier.height(16.dp))
} }
StyledButton( if (state.connectionSuccessful) {
onClick = { StyledButton(
viewModel.reconnectFromSavedMac() onClick = {
}, backdrop = backdrop, modifier = Modifier.fillMaxWidth(0.9f) viewModel.reconnectFromSavedMac()
) { }, backdrop = backdrop, modifier = Modifier.fillMaxWidth(0.9f)
Text( ) {
text = stringResource(R.string.reconnect_to_last_device), style = TextStyle( Text(
fontSize = 16.sp, text = stringResource(R.string.reconnect_to_last_device),
fontWeight = FontWeight.Medium, style = TextStyle(
fontFamily = FontFamily(Font(R.font.sf_pro)), fontSize = 16.sp,
color = if (isSystemInDarkTheme()) Color.White else Color.Black fontWeight = FontWeight.Medium,
fontFamily = FontFamily(Font(R.font.sf_pro)),
color = if (isSystemInDarkTheme()) Color.White else Color.Black
)
) )
) }
} }
} }
} }

View File

@@ -91,7 +91,9 @@ data class AirPodsUiState(
val isPremium: Boolean = false, val isPremium: Boolean = false,
val vendorIdHook: Boolean = false, val vendorIdHook: Boolean = false,
val dynamicEndOfCharge: Boolean = false val dynamicEndOfCharge: Boolean = false,
val connectionSuccessful: Boolean = false
) )
class AirPodsViewModel( class AirPodsViewModel(
@@ -354,6 +356,8 @@ class AirPodsViewModel(
val vendorIdHook = xposedRemotePref.getBoolean("vendor_id_hook", false) val vendorIdHook = xposedRemotePref.getBoolean("vendor_id_hook", false)
val dynamicEndOfCharge = sharedPreferences.getBoolean("dynamic_end_of_charge", false) val dynamicEndOfCharge = sharedPreferences.getBoolean("dynamic_end_of_charge", false)
val connectionSuccessful = sharedPreferences.getBoolean("connection_successful", false)
_uiState.update { _uiState.update {
it.copy( it.copy(
offListeningMode = offListeningModeEnabled, offListeningMode = offListeningModeEnabled,
@@ -363,7 +367,8 @@ class AirPodsViewModel(
leftAction = leftAction, leftAction = leftAction,
rightAction = rightAction, rightAction = rightAction,
vendorIdHook = vendorIdHook, vendorIdHook = vendorIdHook,
dynamicEndOfCharge = dynamicEndOfCharge dynamicEndOfCharge = dynamicEndOfCharge,
connectionSuccessful = connectionSuccessful
) )
} }
} }