From 7464ec4d610fd4a67732c565bc4f90ec541a61f7 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Mon, 14 Aug 2023 17:44:52 +0200 Subject: [PATCH 1/2] fix: change connectivity status label --- .../ui/common/topappbar/CommonTopAppBar.kt | 21 +++++------- .../topappbar/CommonTopAppBarViewModel.kt | 34 +++++++++---------- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 26 insertions(+), 31 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 2c7deb0298c..3a4b07699df 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 @@ -22,6 +22,7 @@ package com.wire.android.ui.common.topappbar +import androidx.annotation.StringRes import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.animateContentSize import androidx.compose.animation.expandIn @@ -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 f2af7d26f4c..cee7bb262ff 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 @@ -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 = 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 { @@ -127,23 +144,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 8b8e1e24be9..f98f2f6663d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -750,7 +750,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 From 014a520da7ac84e6981125f10831a72589b1927a Mon Sep 17 00:00:00 2001 From: Oussama Date: Tue, 15 Aug 2023 15:05:26 +0200 Subject: [PATCH 2/2] chore: cleanup --- .../com/wire/android/ui/common/topappbar/CommonTopAppBar.kt | 6 +++--- .../android/ui/common/topappbar/CommonTopAppBarViewModel.kt | 1 - 2 files changed, 3 insertions(+), 4 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 3a4b07699df..00ee63b2e93 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 @@ -22,7 +22,6 @@ package com.wire.android.ui.common.topappbar -import androidx.annotation.StringRes import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.animateContentSize import androidx.compose.animation.expandIn @@ -35,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 @@ -106,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 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 cee7bb262ff..12b5149f14c 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 @@ -144,7 +144,6 @@ class CommonTopAppBarViewModel @Inject constructor( } } - private companion object { const val WAITING_TIME_TO_SHOW_ONGOING_CALL_BANNER = 600L }