File tree Expand file tree Collapse file tree
watch/app/src/main/java/com/imsproject/watch Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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)
You can’t perform that action at this time.
0 commit comments