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))
}
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
)
)
)
}
}
}
}

View File

@@ -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
)
}
}