Skip to content

Commit 314d1ca

Browse files
committed
Made it so the ready button doesn't turn gray when the heart rate is unavailable
1 parent 4cf8efb commit 314d1ca

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

watch/app/src/main/java/com/imsproject/watch/view/MainActivity.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -516,11 +516,12 @@ class MainActivity : ComponentActivity() {
516516
)
517517
}
518518
Button(
519-
colors = if(hrSensorReady) ButtonDefaults.primaryButtonColors()
520-
else ButtonDefaults.buttonColors(
521-
backgroundColor = Color(0xFF707070).copy(alpha=0.5f),
522-
contentColor = Color.White
523-
),
519+
colors = if (!hrSensorReady && !viewModel.heartRateUnavailable.collectAsState().value)
520+
ButtonDefaults.buttonColors(
521+
backgroundColor = Color(0xFF707070).copy(alpha=0.5f),
522+
contentColor = Color.White
523+
)
524+
else ButtonDefaults.primaryButtonColors(),
524525
onClick = { onReady() },
525526
modifier = Modifier
526527
.fillMaxWidth(0.55f)

watch/app/src/main/java/com/imsproject/watch/viewmodel/MainViewModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class MainViewModel() : ViewModel() {
111111
private val _expId = MutableStateFlow<String?>(null)
112112
val expId : StateFlow<String?> = _expId
113113

114+
private val _heartRateUnavailable = MutableStateFlow(false)
115+
val heartRateUnavailable: StateFlow<Boolean> = _heartRateUnavailable
116+
114117
private var _skipFeedback = false
115118
private var _sessionId = -1
116119
var temporaryPlayerId = ""
@@ -128,6 +131,7 @@ class MainViewModel() : ViewModel() {
128131
viewModelScope.launch(Dispatchers.Main) {
129132
Toast.makeText(context, "Heart rate unavailable", Toast.LENGTH_LONG).show()
130133
}
134+
_heartRateUnavailable.value = true
131135
}
132136
}
133137
locationSensorsHandler.init(context)

0 commit comments

Comments
 (0)