Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change the connectivity message (RC) #2102

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -105,7 +105,8 @@ private fun ConnectivityStatusBar(
.animateContentSize()
.fillMaxWidth()
.height(MaterialTheme.wireDimensions.ongoingCallLabelHeight)
.background(backgroundColor).run {
.background(backgroundColor)
.run {
if (connectivityInfo is ConnectivityUIState.Info.EstablishedCall) {
clickable(onClick = onReturnToCallClick)
} else this
Expand All @@ -121,24 +122,18 @@ private fun ConnectivityStatusBar(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
if (connectivityInfo is ConnectivityUIState.Info.EstablishedCall) {
OngoingCallContent(connectivityInfo.isMuted)
} else {
val isConnecting = connectivityInfo is ConnectivityUIState.Info.Connecting
ConnectivityIssueContent(isConnecting)
when (connectivityInfo) {
is ConnectivityUIState.Info.EstablishedCall -> OngoingCallContent(connectivityInfo.isMuted)
ConnectivityUIState.Info.Connecting -> StatusLabel(R.string.connectivity_status_bar_connecting)
ConnectivityUIState.Info.WaitingConnection ->
StatusLabel(R.string.connectivity_status_bar_waiting_for_network)

ConnectivityUIState.Info.None -> {}
}
}
}
}

@Composable
private fun ConnectivityIssueContent(isConnecting: Boolean) {
val stringResource = if (isConnecting) R.string.connectivity_status_bar_connecting
else R.string.connectivity_status_bar_waiting_for_network

StatusLabel(stringResource)
}

@Composable
private fun OngoingCallContent(isMuted: Boolean) {
Row {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ class CommonTopAppBarViewModel @Inject constructor(

var connectivityState by mutableStateOf(ConnectivityUIState(ConnectivityUIState.Info.None))

private suspend fun currentScreenFlow() = currentScreenManager.observeCurrentScreen(viewModelScope)

private fun connectivityFlow(userId: UserId): Flow<Connectivity> = coreLogic.sessionScope(userId) {
observeSyncState().map {
when (it) {
is SyncState.Failed, SyncState.Waiting -> Connectivity.WAITING_CONNECTION
SyncState.GatheringPendingEvents, SyncState.SlowSync -> Connectivity.CONNECTING
SyncState.Live -> Connectivity.CONNECTED
}
}
}
private suspend fun activeCallFlow(userId: UserId): Flow<Call?> = coreLogic.sessionScope(userId) {
calls.establishedCall().distinctUntilChanged().map { calls ->
calls.firstOrNull()
}
}

init {
viewModelScope.launch {
coreLogic.globalScope {
Expand Down Expand Up @@ -127,24 +144,6 @@ class CommonTopAppBarViewModel @Inject constructor(
}
}

private fun connectivityFlow(userId: UserId): Flow<Connectivity> = coreLogic.sessionScope(userId) {
observeSyncState().map {
when (it) {
is SyncState.Failed, SyncState.Waiting -> Connectivity.WAITING_CONNECTION
SyncState.GatheringPendingEvents, SyncState.SlowSync -> Connectivity.CONNECTING
SyncState.Live -> Connectivity.CONNECTED
}
}
}

private suspend fun activeCallFlow(userId: UserId): Flow<Call?> = coreLogic.sessionScope(userId) {
calls.establishedCall().distinctUntilChanged().map { calls ->
calls.firstOrNull()
}
}

private suspend fun currentScreenFlow() = currentScreenManager.observeCurrentScreen(viewModelScope)

private companion object {
const val WAITING_TIME_TO_SHOW_ONGOING_CALL_BANNER = 600L
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@
<string name="calling_feature_unavailable_message_alert">The option to initiate a conference call is only available in the paid version of Wire.</string>
<!-- Connectivity Status Bar -->
<string name="connectivity_status_bar_return_to_call">Return to call</string>
<string name="connectivity_status_bar_connecting">Connecting</string>
<string name="connectivity_status_bar_connecting">Decrypting messages</string>
<string name="connectivity_status_bar_waiting_for_network">Waiting for network</string>
<!-- Connections -->
<string name="connection_label_connect">Connect</string>
Expand Down
Loading