Skip to content

Commit

Permalink
Merge branch 'develop' into Wrong-URL-when-opening-team-management-af…
Browse files Browse the repository at this point in the history
…ter-migration
  • Loading branch information
MohamadJaara authored Dec 17, 2024
2 parents 4ea2d65 + 41b7ca7 commit cfcbe6b
Show file tree
Hide file tree
Showing 56 changed files with 1,347 additions and 417 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-prod-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
build-flavour: prod
build-variant: compatrelease
- name: Attach APK and version file to release
uses: softprops/action-gh-release@v2.1.0
uses: softprops/action-gh-release@v2.2.0
with:
files: |
app/build/outputs/apk/prodCompatrelease/*.apk
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
npx [email protected] -t "$PREVIOUS_TAG...$CURRENT_TAG"
- name: 'Attach changelog to tag'
uses: softprops/action-gh-release@v2.1.0
uses: softprops/action-gh-release@v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.ANDROID_BOB_GH_TOKEN }}
with:
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/kotlin/com/wire/android/WireApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import co.touchlab.kermit.platformLogWriter
import com.wire.android.analytics.ObserveCurrentSessionAnalyticsUseCase
import com.wire.android.datastore.GlobalDataStore
import com.wire.android.datastore.UserDataStoreProvider
import com.wire.android.debug.DatabaseProfilingManager
import com.wire.android.di.ApplicationScope
import com.wire.android.di.KaliumCoreLogic
import com.wire.android.feature.analytics.AnonymousAnalyticsManagerImpl
Expand Down Expand Up @@ -89,6 +90,9 @@ class WireApplication : BaseApp() {
@Inject
lateinit var currentScreenManager: CurrentScreenManager

@Inject
lateinit var databaseProfilingManager: DatabaseProfilingManager

override val workManagerConfiguration: Configuration
get() = Configuration.Builder()
.setWorkerFactory(wireWorkerFactory.get())
Expand Down Expand Up @@ -183,6 +187,10 @@ class WireApplication : BaseApp() {
logDeviceInformation()
// 5. Verify if we can initialize Anonymous Analytics
initializeAnonymousAnalytics()
// 6. Observe and update profiling when needed
globalAppScope.launch {
databaseProfilingManager.observeAndUpdateProfiling()
}
}

private fun initializeAnonymousAnalytics() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.debug

import com.wire.android.datastore.GlobalDataStore
import com.wire.android.di.KaliumCoreLogic
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.functional.mapToRightOr
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.scan
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class DatabaseProfilingManager @Inject constructor(
@KaliumCoreLogic private val coreLogic: CoreLogic,
private val globalDataStore: GlobalDataStore,
) {

suspend fun observeAndUpdateProfiling() {
globalDataStore.isLoggingEnabled()
.flatMapLatest { isLoggingEnabled ->
coreLogic.getGlobalScope().sessionRepository.allValidSessionsFlow()
.mapToRightOr(emptyList())
.map { it.map { it.userId } }
.scan(emptyList<UserId>()) { previousList, currentList -> currentList - previousList.toSet() }
.map { userIds -> isLoggingEnabled to userIds }
}
.filter { (_, userIds) -> userIds.isNotEmpty() }
.distinctUntilChanged()
.collect { (isLoggingEnabled, userIds) ->
userIds.forEach { userId ->
coreLogic.getSessionScope(userId).debug.changeProfiling(isLoggingEnabled)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,9 @@ class CallsModule {
@Provides
fun provideIsEligibleToStartCall(callsScope: CallsScope) =
callsScope.isEligibleToStartCall

@ViewModelScoped
@Provides
fun provideObserveConferenceCallingEnabledUseCase(callsScope: CallsScope) =
callsScope.observeConferenceCallingEnabled
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fun ConversationDetailsWithEvents.toConversationItem(
),
userId = conversationDetails.otherUser.id,
blockingState = conversationDetails.otherUser.BlockState,
isUserDeleted = conversationDetails.otherUser.deleted,
teamId = conversationDetails.otherUser.teamId,
isArchived = conversationDetails.conversation.archived,
mlsVerificationStatus = conversationDetails.conversation.mlsVerificationStatus,
Expand Down
78 changes: 4 additions & 74 deletions app/src/main/kotlin/com/wire/android/navigation/HomeDestination.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,14 @@
package com.wire.android.navigation

import androidx.annotation.DrawableRes
import androidx.navigation.NavBackStackEntry
import com.ramcosta.composedestinations.spec.Direction
import com.wire.android.R
import com.wire.android.ui.destinations.AllConversationsScreenDestination
import com.wire.android.ui.destinations.ArchiveScreenDestination
import com.wire.android.ui.destinations.FavoritesConversationsScreenDestination
import com.wire.android.ui.destinations.FolderConversationsScreenDestination
import com.wire.android.ui.destinations.GroupConversationsScreenDestination
import com.wire.android.ui.destinations.OneOnOneConversationsScreenDestination
import com.wire.android.ui.destinations.SettingsScreenDestination
import com.wire.android.ui.destinations.VaultScreenDestination
import com.wire.android.ui.destinations.WhatsNewScreenDestination
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.data.conversation.ConversationFilter
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf

@Suppress("LongParameterList")
sealed class HomeDestination(
Expand All @@ -45,10 +37,6 @@ sealed class HomeDestination(
val withUserAvatar: Boolean = true,
val direction: Direction
) {

internal fun NavBackStackEntry.baseRouteMatches(): Boolean = direction.route.getBaseRoute() == destination.route?.getBaseRoute()
open fun entryMatches(entry: NavBackStackEntry): Boolean = entry.baseRouteMatches()

data object Conversations : HomeDestination(
title = UIText.StringResource(R.string.conversations_screen_title),
icon = R.drawable.ic_conversation,
Expand All @@ -57,43 +45,6 @@ sealed class HomeDestination(
direction = AllConversationsScreenDestination
)

data object Favorites : HomeDestination(
title = UIText.StringResource(R.string.label_filter_favorites),
icon = R.drawable.ic_conversation,
isSearchable = true,
withNewConversationFab = true,
direction = FavoritesConversationsScreenDestination
)

data class Folder(
val folderNavArgs: FolderNavArgs
) : HomeDestination(
title = UIText.DynamicString(folderNavArgs.folderName),
icon = R.drawable.ic_conversation,
isSearchable = true,
withNewConversationFab = true,
direction = FolderConversationsScreenDestination(folderNavArgs)
) {
override fun entryMatches(entry: NavBackStackEntry): Boolean =
entry.baseRouteMatches() && FolderConversationsScreenDestination.argsFrom(entry).folderId == folderNavArgs.folderId
}

data object Group : HomeDestination(
title = UIText.StringResource(R.string.label_filter_group),
icon = R.drawable.ic_conversation,
isSearchable = true,
withNewConversationFab = true,
direction = GroupConversationsScreenDestination
)

data object OneOnOne : HomeDestination(
title = UIText.StringResource(R.string.label_filter_one_on_one),
icon = R.drawable.ic_conversation,
isSearchable = true,
withNewConversationFab = true,
direction = OneOnOneConversationsScreenDestination
)

data object Settings : HomeDestination(
title = UIText.StringResource(R.string.settings_screen_title),
icon = R.drawable.ic_settings,
Expand Down Expand Up @@ -130,32 +81,11 @@ sealed class HomeDestination(

companion object {
private const val ITEM_NAME_PREFIX = "HomeNavigationItem."
fun values(): PersistentList<HomeDestination> =
persistentListOf(Conversations, Favorites, Group, OneOnOne, Settings, Vault, Archive, Support, WhatsNew)
}
}

fun HomeDestination.currentFilter(): ConversationFilter {
return when (this) {
HomeDestination.Conversations -> ConversationFilter.All
HomeDestination.Favorites -> ConversationFilter.Favorites
HomeDestination.Group -> ConversationFilter.Groups
HomeDestination.OneOnOne -> ConversationFilter.OneOnOne
is HomeDestination.Folder -> ConversationFilter.Folder(folderName = folderNavArgs.folderName, folderId = folderNavArgs.folderId)
HomeDestination.Archive,
HomeDestination.Settings,
HomeDestination.Support,
HomeDestination.Vault,
HomeDestination.WhatsNew -> ConversationFilter.All
}
}
fun fromRoute(fullRoute: String): HomeDestination? =
values().find { it.direction.route.getBaseRoute() == fullRoute.getBaseRoute() }

fun ConversationFilter.toDestination(): HomeDestination {
return when (this) {
ConversationFilter.All -> HomeDestination.Conversations
ConversationFilter.Favorites -> HomeDestination.Favorites
ConversationFilter.Groups -> HomeDestination.Group
ConversationFilter.OneOnOne -> HomeDestination.OneOnOne
is ConversationFilter.Folder -> HomeDestination.Folder(FolderNavArgs(folderId, folderName))
fun values(): Array<HomeDestination> =
arrayOf(Conversations, Settings, Vault, Archive, Support, WhatsNew)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal fun NavController.navigateToItem(command: NavigationCommand) {

fun lastDestinationFromOtherGraph(graph: NavGraphSpec) = currentBackStack.value.lastOrNull { it.navGraph() != graph }

appLogger.d("[$TAG] -> command: ${command.destination.route.obfuscateId()}")
appLogger.d("[$TAG] -> command: ${command.destination.route.obfuscateId()} backStackMode:${command.backStackMode}")
navigate(command.destination) {
when (command.backStackMode) {
BackStackMode.CLEAR_WHOLE, BackStackMode.CLEAR_TILL_START -> {
Expand Down
18 changes: 8 additions & 10 deletions app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -517,16 +517,14 @@ class WireActivity : AppCompatActivity() {
)
CustomBackendDialog(
viewModel.globalAppState,
viewModel::dismissCustomBackendDialog
) {
viewModel.customBackendDialogProceedButtonClicked {
navigate(
NavigationCommand(
WelcomeScreenDestination
)
)
}
}
viewModel::dismissCustomBackendDialog,
onConfirm = {
viewModel.customBackendDialogProceedButtonClicked {
navigate(NavigationCommand(WelcomeScreenDestination))
}
},
onTryAgain = viewModel::onCustomServerConfig
)
MaxAccountDialog(
shouldShow = viewModel.globalAppState.maxAccountDialog,
onConfirm = {
Expand Down
13 changes: 8 additions & 5 deletions app/src/main/kotlin/com/wire/android/ui/WireActivityDialogs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ import com.wire.android.ui.common.button.WireButtonState
import com.wire.android.ui.common.button.WireSecondaryButton
import com.wire.android.ui.common.dialogs.CustomServerDetailsDialog
import com.wire.android.ui.common.dialogs.CustomServerDetailsDialogState
import com.wire.android.ui.common.dialogs.CustomServerInvalidJsonDialog
import com.wire.android.ui.common.dialogs.CustomServerInvalidJsonDialogState
import com.wire.android.ui.common.dialogs.CustomServerNoNetworkDialog
import com.wire.android.ui.common.dialogs.CustomServerNoNetworkDialogState
import com.wire.android.ui.common.dialogs.MaxAccountAllowedDialogContent
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.wireDialogPropertiesBuilder
Expand Down Expand Up @@ -244,7 +244,8 @@ fun JoinConversationDialog(
fun CustomBackendDialog(
globalAppState: GlobalAppState,
onDismiss: () -> Unit,
onConfirm: () -> Unit
onConfirm: () -> Unit,
onTryAgain: (String) -> Unit
) {
when (globalAppState.customBackendDialog) {
is CustomServerDetailsDialogState -> {
Expand All @@ -255,8 +256,9 @@ fun CustomBackendDialog(
)
}

is CustomServerInvalidJsonDialogState -> {
CustomServerInvalidJsonDialog(
is CustomServerNoNetworkDialogState -> {
CustomServerNoNetworkDialog(
onTryAgain = { onTryAgain(globalAppState.customBackendDialog.customServerUrl) },
onDismiss = onDismiss
)
}
Expand Down Expand Up @@ -581,6 +583,7 @@ fun PreviewCustomBackendDialog() {
)
),
{},
{},
{}
)
}
Expand Down
21 changes: 12 additions & 9 deletions app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import com.wire.android.services.ServicesManager
import com.wire.android.ui.authentication.devices.model.displayName
import com.wire.android.ui.common.dialogs.CustomServerDetailsDialogState
import com.wire.android.ui.common.dialogs.CustomServerDialogState
import com.wire.android.ui.common.dialogs.CustomServerInvalidJsonDialogState
import com.wire.android.ui.common.dialogs.CustomServerNoNetworkDialogState
import com.wire.android.ui.joinConversation.JoinConversationViaCodeState
import com.wire.android.ui.theme.ThemeOption
import com.wire.android.util.CurrentScreen
Expand Down Expand Up @@ -320,7 +320,7 @@ class WireActivityViewModel @Inject constructor(
when (val result = deepLinkProcessor.get().invoke(intent?.data, isSharingIntent)) {
DeepLinkResult.AuthorizationNeeded -> onAuthorizationNeeded()
is DeepLinkResult.SSOLogin -> onSSOLogin(result)
is DeepLinkResult.CustomServerConfig -> onCustomServerConfig(result)
is DeepLinkResult.CustomServerConfig -> onCustomServerConfig(result.url)
is DeepLinkResult.Failure.OngoingCall -> onCannotLoginDuringACall()
is DeepLinkResult.Failure.Unknown -> appLogger.e("unknown deeplink failure")
is DeepLinkResult.JoinConversation -> onConversationInviteDeepLink(
Expand Down Expand Up @@ -429,13 +429,16 @@ class WireActivityViewModel @Inject constructor(
}
}

private suspend fun onCustomServerConfig(result: DeepLinkResult.CustomServerConfig) {
val customBackendDialogData = loadServerConfig(result.url)?.let { serverLinks ->
CustomServerDetailsDialogState(serverLinks = serverLinks)
} ?: CustomServerInvalidJsonDialogState
globalAppState = globalAppState.copy(
customBackendDialog = customBackendDialogData
)
fun onCustomServerConfig(customServerUrl: String) {
viewModelScope.launch(dispatchers.io()) {
val customBackendDialogData = loadServerConfig(customServerUrl)
?.let { serverLinks -> CustomServerDetailsDialogState(serverLinks = serverLinks) }
?: CustomServerNoNetworkDialogState(customServerUrl)

globalAppState = globalAppState.copy(
customBackendDialog = customBackendDialogData
)
}
}

private suspend fun onConversationInviteDeepLink(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import com.wire.kalium.logic.feature.session.CurrentSessionUseCase
import com.wire.kalium.logic.feature.user.screenshotCensoring.ObserveScreenshotCensoringConfigResult
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -61,7 +60,7 @@ class CallActivityViewModel @Inject constructor(
}

fun switchAccountIfNeeded(userId: UserId, actions: SwitchAccountActions) {
viewModelScope.launch(Dispatchers.IO) {
viewModelScope.launch(dispatchers.io()) {
val shouldSwitchAccount = when (val result = currentSession()) {
is CurrentSessionResult.Failure.Generic -> true
CurrentSessionResult.Failure.SessionNotFound -> true
Expand Down
Loading

0 comments on commit cfcbe6b

Please sign in to comment.