Skip to content

Commit b2ba830

Browse files
committed
android: hide reconnect when app hasn't connected once
1 parent f08769e commit b2ba830

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

android/app/src/main/java/me/kavishdevar/librepods/presentation/screens/AirPodsSettingsScreen.kt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -552,19 +552,22 @@ fun AirPodsSettingsScreen(viewModel: AirPodsViewModel, navController: NavControl
552552
}
553553
Spacer(Modifier.height(16.dp))
554554
}
555-
StyledButton(
556-
onClick = {
557-
viewModel.reconnectFromSavedMac()
558-
}, backdrop = backdrop, modifier = Modifier.fillMaxWidth(0.9f)
559-
) {
560-
Text(
561-
text = stringResource(R.string.reconnect_to_last_device), style = TextStyle(
562-
fontSize = 16.sp,
563-
fontWeight = FontWeight.Medium,
564-
fontFamily = FontFamily(Font(R.font.sf_pro)),
565-
color = if (isSystemInDarkTheme()) Color.White else Color.Black
555+
if (state.connectionSuccessful) {
556+
StyledButton(
557+
onClick = {
558+
viewModel.reconnectFromSavedMac()
559+
}, backdrop = backdrop, modifier = Modifier.fillMaxWidth(0.9f)
560+
) {
561+
Text(
562+
text = stringResource(R.string.reconnect_to_last_device),
563+
style = TextStyle(
564+
fontSize = 16.sp,
565+
fontWeight = FontWeight.Medium,
566+
fontFamily = FontFamily(Font(R.font.sf_pro)),
567+
color = if (isSystemInDarkTheme()) Color.White else Color.Black
568+
)
566569
)
567-
)
570+
}
568571
}
569572
}
570573
}

android/app/src/main/java/me/kavishdevar/librepods/presentation/viewmodel/AirPodsViewModel.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ data class AirPodsUiState(
9191
val isPremium: Boolean = false,
9292
val vendorIdHook: Boolean = false,
9393

94-
val dynamicEndOfCharge: Boolean = false
94+
val dynamicEndOfCharge: Boolean = false,
95+
96+
val connectionSuccessful: Boolean = false
9597
)
9698

9799
class AirPodsViewModel(
@@ -354,6 +356,8 @@ class AirPodsViewModel(
354356
val vendorIdHook = xposedRemotePref.getBoolean("vendor_id_hook", false)
355357
val dynamicEndOfCharge = sharedPreferences.getBoolean("dynamic_end_of_charge", false)
356358

359+
val connectionSuccessful = sharedPreferences.getBoolean("connection_successful", false)
360+
357361
_uiState.update {
358362
it.copy(
359363
offListeningMode = offListeningModeEnabled,
@@ -363,7 +367,8 @@ class AirPodsViewModel(
363367
leftAction = leftAction,
364368
rightAction = rightAction,
365369
vendorIdHook = vendorIdHook,
366-
dynamicEndOfCharge = dynamicEndOfCharge
370+
dynamicEndOfCharge = dynamicEndOfCharge,
371+
connectionSuccessful = connectionSuccessful
367372
)
368373
}
369374
}

0 commit comments

Comments
 (0)