From 6b9c17ef41943179bbecabacc0e778320edadf5e Mon Sep 17 00:00:00 2001 From: Oussama Hassine Date: Tue, 15 Aug 2023 15:50:35 +0200 Subject: [PATCH] fix: change the connectivity message (RC) (#2102) Co-authored-by: Mateusz --- .../ui/common/topappbar/CommonTopAppBar.kt | 25 ++++++------- .../topappbar/CommonTopAppBarViewModel.kt | 35 +++++++++---------- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/common/topappbar/CommonTopAppBar.kt b/app/src/main/kotlin/com/wire/android/ui/common/topappbar/CommonTopAppBar.kt index 68edb90f96e..fcdc56d7699 100644 --- a/app/src/main/kotlin/com/wire/android/ui/common/topappbar/CommonTopAppBar.kt +++ b/app/src/main/kotlin/com/wire/android/ui/common/topappbar/CommonTopAppBar.kt @@ -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 @@ -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(connectivityInfo) }) } else this @@ -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 { diff --git a/app/src/main/kotlin/com/wire/android/ui/common/topappbar/CommonTopAppBarViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/common/topappbar/CommonTopAppBarViewModel.kt index 57b5a225dbd..0409800a404 100644 --- a/app/src/main/kotlin/com/wire/android/ui/common/topappbar/CommonTopAppBarViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/common/topappbar/CommonTopAppBarViewModel.kt @@ -58,6 +58,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 = 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 = coreLogic.sessionScope(userId) { + calls.establishedCall().distinctUntilChanged().map { calls -> + calls.firstOrNull() + } + } + init { viewModelScope.launch { coreLogic.globalScope { @@ -118,24 +135,6 @@ class CommonTopAppBarViewModel @Inject constructor( } } - private fun connectivityFlow(userId: UserId): Flow = 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 = 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 } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cfb3610baf5..a0228284c04 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -756,7 +756,7 @@ The option to initiate a conference call is only available in the paid version of Wire. Return to call - Connecting + Decrypting messages Waiting for network Connect