From 3ad6eefadba1d24a6004c99a2769accc84d58a96 Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Fri, 28 Jul 2023 12:29:07 +0000 Subject: [PATCH] fix: hide connectivity banner on authentications screens (#2020) Co-authored-by: Tommaso Piazza <196761+tmspzz@users.noreply.github.com> --- .../wire/android/ui/WireActivityViewModel.kt | 1 + .../topappbar/CommonTopAppBarViewModel.kt | 15 +++++++++++---- .../wire/android/util/CurrentScreenManager.kt | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt index 3c74b8abfd7..a5e6ab5be15 100644 --- a/app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt @@ -499,6 +499,7 @@ class WireActivityViewModel @Inject constructor( is CurrentScreen.IncomingCallScreen, is CurrentScreen.OngoingCallScreen, is CurrentScreen.OtherUserProfile, + CurrentScreen.AuthRelated, CurrentScreen.SomeOther -> true } } 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..267efe333c5 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 @@ -69,6 +69,7 @@ class CommonTopAppBarViewModel @Inject constructor( when (it) { is CurrentSessionResult.Failure.Generic, CurrentSessionResult.Failure.SessionNotFound -> flowOf(ConnectivityUIState.Info.None) + is CurrentSessionResult.Success -> { val userId = it.accountInfo.userId combine( @@ -104,14 +105,20 @@ class CommonTopAppBarViewModel @Inject constructor( ): ConnectivityUIState.Info { val canDisplayActiveCall = currentScreen !is CurrentScreen.OngoingCallScreen + val canDisplayConnectivityIssues = currentScreen !is CurrentScreen.AuthRelated + if (activeCall != null && canDisplayActiveCall) { return ConnectivityUIState.Info.EstablishedCall(activeCall.conversationId, activeCall.isMuted) } - return when (connectivity) { - Connectivity.WAITING_CONNECTION -> ConnectivityUIState.Info.WaitingConnection - Connectivity.CONNECTING -> ConnectivityUIState.Info.Connecting - Connectivity.CONNECTED -> ConnectivityUIState.Info.None + return if (canDisplayConnectivityIssues) { + when (connectivity) { + Connectivity.WAITING_CONNECTION -> ConnectivityUIState.Info.WaitingConnection + Connectivity.CONNECTING -> ConnectivityUIState.Info.Connecting + Connectivity.CONNECTED -> ConnectivityUIState.Info.None + } + } else { + ConnectivityUIState.Info.None } } diff --git a/app/src/main/kotlin/com/wire/android/util/CurrentScreenManager.kt b/app/src/main/kotlin/com/wire/android/util/CurrentScreenManager.kt index da6fdf10b43..8549bbd4073 100644 --- a/app/src/main/kotlin/com/wire/android/util/CurrentScreenManager.kt +++ b/app/src/main/kotlin/com/wire/android/util/CurrentScreenManager.kt @@ -145,9 +145,13 @@ sealed class CurrentScreen { // Import media screen is opened object ImportMedia : CurrentScreen() + // SelfDevices screen is opened object DeviceManager : CurrentScreen() + // Auth related screen is opened + object AuthRelated : CurrentScreen() + // Some other screen is opened, kinda "do nothing screen" object SomeOther : CurrentScreen() @@ -170,26 +174,39 @@ sealed class CurrentScreen { ?.let { Conversation(it) } ?: SomeOther } + NavigationItem.OtherUserProfile -> { arguments?.getString(EXTRA_CONVERSATION_ID) ?.toQualifiedID(qualifiedIdMapper) ?.let { OtherUserProfile(it) } ?: SomeOther } + NavigationItem.OngoingCall -> { arguments?.getString(EXTRA_CONVERSATION_ID) ?.toQualifiedID(qualifiedIdMapper) ?.let { OngoingCallScreen(it) } ?: SomeOther } + NavigationItem.IncomingCall -> { arguments?.getString(EXTRA_CONVERSATION_ID) ?.toQualifiedID(qualifiedIdMapper) ?.let { IncomingCallScreen(it) } ?: SomeOther } + NavigationItem.ImportMedia -> ImportMedia NavigationItem.SelfDevices -> DeviceManager + NavigationItem.Welcome, + NavigationItem.Login, + NavigationItem.CreatePersonalAccount, + NavigationItem.CreateTeam, + NavigationItem.CreateAccountSummary, + NavigationItem.Migration, + NavigationItem.InitialSync, + NavigationItem.RemoveDevices -> AuthRelated + else -> SomeOther } }