Skip to content

Commit

Permalink
Merge branch 'develop' into feat/message-draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed Mar 21, 2024
2 parents a913cad + 01a0da9 commit 647db97
Show file tree
Hide file tree
Showing 41 changed files with 519 additions and 289 deletions.
10 changes: 0 additions & 10 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,6 @@ class UseCaseModule {
fun provideGetServerConfigUserCase(@KaliumCoreLogic coreLogic: CoreLogic) =
coreLogic.getGlobalScope().fetchServerConfigFromDeepLink

@ViewModelScoped
@Provides
fun provideFetchApiVersionUserCase(@KaliumCoreLogic coreLogic: CoreLogic) =
coreLogic.getGlobalScope().fetchApiVersion

@ViewModelScoped
@Provides
fun provideObserveServerConfigUseCase(@KaliumCoreLogic coreLogic: CoreLogic) =
coreLogic.getGlobalScope().observeServerConfig

@ViewModelScoped
@Provides
fun provideUpdateApiVersionsUseCase(@KaliumCoreLogic coreLogic: CoreLogic) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ class MigrationMapper @Inject constructor() {
previewPicture = scalaUserData.pictureAssetId?.let { toQualifiedId(it, scalaUserData.domain, selfuser) },
completePicture = scalaUserData.pictureAssetId?.let { toQualifiedId(it, scalaUserData.domain, selfuser) },
availabilityStatus = mapUserAvailabilityStatus(scalaUserData.availability),
supportedProtocols = setOf(SupportedProtocol.PROTEUS)
supportedProtocols = setOf(SupportedProtocol.PROTEUS),
userType = UserType.INTERNAL,
)
} else {
val botService =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ class MigrateActiveAccountsUseCase @Inject constructor(
private suspend fun handleMissingData(
serverConfig: ServerConfig,
refreshToken: String,
): Either<CoreFailure, AccountTokens> = coreLogic.authenticationScope(serverConfig) {
): Either<CoreFailure, AccountTokens> = coreLogic.authenticationScope(
serverConfig,
// scala did not support proxy mode so we can pass null
proxyCredentials = null
) {
ssoLoginScope.getLoginSession(refreshToken)
}.let {
when (it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.wire.kalium.logic.StorageFailure
import com.wire.kalium.logic.configuration.server.CommonApiVersionType
import com.wire.kalium.logic.configuration.server.ServerConfig
import com.wire.kalium.logic.failure.ServerConfigFailure
import com.wire.kalium.logic.feature.server.FetchApiVersionResult
import com.wire.kalium.logic.feature.auth.autoVersioningAuth.AutoVersionAuthScopeUseCase
import com.wire.kalium.logic.feature.server.GetServerConfigResult
import com.wire.kalium.logic.feature.server.StoreServerConfigResult
import com.wire.kalium.logic.functional.Either
Expand Down Expand Up @@ -66,13 +66,13 @@ class MigrateServerConfigUseCase @Inject constructor(
}

private suspend fun ServerConfig.Links.fetchApiVersionAndStore(): Either<CoreFailure, ServerConfig> =
coreLogic.getGlobalScope().fetchApiVersion(this).let { // it also already stores the fetched config
// scala did not support proxy mode so we can pass null here
coreLogic.versionedAuthenticationScope(this)(null).let { // it also already stores the fetched config
when (it) {
is FetchApiVersionResult.Success -> Either.Right(it.serverConfig)
FetchApiVersionResult.Failure.TooNewVersion -> Either.Left(ServerConfigFailure.NewServerVersion)
FetchApiVersionResult.Failure.UnknownServerVersion -> Either.Left(ServerConfigFailure.UnknownServerVersion)
is FetchApiVersionResult.Failure.Generic -> Either.Left(it.genericFailure)
is AutoVersionAuthScopeUseCase.Result.Failure.Generic -> Either.Left(it.genericFailure)
AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion -> Either.Left(ServerConfigFailure.NewServerVersion)
AutoVersionAuthScopeUseCase.Result.Failure.UnknownServerVersion -> Either.Left(ServerConfigFailure.UnknownServerVersion)
is AutoVersionAuthScopeUseCase.Result.Success -> Either.Right(it.authenticationScope.currentServerConfig())
}
}

}
25 changes: 25 additions & 0 deletions app/src/main/kotlin/com/wire/android/model/ItemActionType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.model

enum class ItemActionType {
CHECK, CLICK, CHECK_AND_CLICK;

val checkable: Boolean get() = this == CHECK || this == CHECK_AND_CLICK
val clickable: Boolean get() = this == CLICK || this == CHECK_AND_CLICK
}
11 changes: 6 additions & 5 deletions app/src/main/kotlin/com/wire/android/ui/WireActivityState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

package com.wire.android.ui

sealed class WireActivityState {
sealed class
WireActivityState {

data class NavigationGraph(val startNavigationRoute: String, val navigationArguments: List<Any>): WireActivityState()
data class ClientUpdateRequired(val clientUpdateUrl: String): WireActivityState()
object ServerVersionNotSupported: WireActivityState()
object Loading: WireActivityState()
data class NavigationGraph(val startNavigationRoute: String, val navigationArguments: List<Any>) : WireActivityState()
data class ClientUpdateRequired(val clientUpdateUrl: String) : WireActivityState()
object ServerVersionNotSupported : WireActivityState()
object Loading : WireActivityState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class WireActivityViewModel @Inject constructor(
}

private fun observeUpdateAppState() {
viewModelScope.launch(dispatchers.io()) {
viewModelScope.launch {
observeIfAppUpdateRequired(BuildConfig.VERSION_CODE)
.distinctUntilChanged()
.collect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,32 @@ private fun ServerEnrollmentDialogContent(
onDismiss: () -> Unit,
onClick: () -> Unit,
) {
WireDialog(
title = stringResource(id = R.string.server_details_dialog_title),
text = LocalContext.current.resources.stringWithStyledArgs(
val text = if (serverLinks.apiProxy == null) {
LocalContext.current.resources.stringWithStyledArgs(
R.string.server_details_dialog_body,
MaterialTheme.wireTypography.body02,
MaterialTheme.wireTypography.body02,
normalColor = colorsScheme().secondaryText,
argsColor = colorsScheme().onBackground,
serverLinks.title,
serverLinks.api
),
)
} else {
LocalContext.current.resources.stringWithStyledArgs(
R.string.server_details_dialog_body_with_proxy,
MaterialTheme.wireTypography.body02,
MaterialTheme.wireTypography.body02,
normalColor = colorsScheme().secondaryText,
argsColor = colorsScheme().onBackground,
serverLinks.title,
serverLinks.api,
serverLinks.apiProxy!!.host,
serverLinks.apiProxy!!.needsAuthentication.toString()
)
}
WireDialog(
title = stringResource(id = R.string.server_details_dialog_title),
text = text,
onDismiss = onDismiss,
optionButton1Properties = WireDialogButtonProperties(
stringResource(id = R.string.label_ok),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class CreateAccountCodeViewModel @Inject constructor(
fun resendCode() {
codeState = codeState.copy(loading = true)
viewModelScope.launch {
val authScope = coreLogic.versionedAuthenticationScope(serverConfig)().let {
// create account does not support proxy yet
val authScope = coreLogic.versionedAuthenticationScope(serverConfig)(null).let {
when (it) {
is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope

Expand Down Expand Up @@ -130,7 +131,8 @@ class CreateAccountCodeViewModel @Inject constructor(
private fun onCodeContinue(onSuccess: () -> Unit) {
codeState = codeState.copy(loading = true)
viewModelScope.launch {
val authScope = coreLogic.versionedAuthenticationScope(serverConfig)().let {
// create account does not support proxy yet
val authScope = coreLogic.versionedAuthenticationScope(serverConfig)(null).let {
when (it) {
is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import com.wire.kalium.logic.configuration.server.ServerConfig
import com.wire.kalium.logic.feature.auth.ValidateEmailUseCase
import com.wire.kalium.logic.feature.auth.autoVersioningAuth.AutoVersionAuthScopeUseCase
import com.wire.kalium.logic.feature.register.RequestActivationCodeResult
import com.wire.kalium.logic.feature.server.FetchApiVersionResult
import com.wire.kalium.logic.feature.server.FetchApiVersionUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand All @@ -44,7 +42,6 @@ import javax.inject.Inject
class CreateAccountEmailViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
private val authServerConfigProvider: AuthServerConfigProvider,
private val fetchApiVersion: FetchApiVersionUseCase,
private val validateEmail: ValidateEmailUseCase,
@KaliumCoreLogic private val coreLogic: CoreLogic,
) : ViewModel() {
Expand All @@ -69,25 +66,6 @@ class CreateAccountEmailViewModel @Inject constructor(
fun onEmailContinue(onSuccess: () -> Unit) {
emailState = emailState.copy(loading = true, continueEnabled = false)
viewModelScope.launch {
fetchApiVersion(authServerConfigProvider.authServer.value).let {
when (it) {
is FetchApiVersionResult.Success -> {}
is FetchApiVersionResult.Failure.UnknownServerVersion -> {
emailState = emailState.copy(showServerVersionNotSupportedDialog = true)
return@launch
}

is FetchApiVersionResult.Failure.TooNewVersion -> {
emailState = emailState.copy(showClientUpdateDialog = true)
return@launch
}

is FetchApiVersionResult.Failure.Generic -> {
return@launch
}
}
}

val emailError =
if (validateEmail(emailState.email.text.trim().lowercase())) CreateAccountEmailViewState.EmailError.None
else CreateAccountEmailViewState.EmailError.TextFieldError.InvalidEmailError
Expand All @@ -106,7 +84,7 @@ class CreateAccountEmailViewModel @Inject constructor(
fun onTermsAccept(onSuccess: () -> Unit) {
emailState = emailState.copy(loading = true, continueEnabled = false, termsDialogVisible = false, termsAccepted = true)
viewModelScope.launch {
val authScope = coreLogic.versionedAuthenticationScope(serverConfig)().let {
val authScope = coreLogic.versionedAuthenticationScope(serverConfig)(null).let {
when (it) {
is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.wire.android.ui.authentication.login

import androidx.compose.ui.text.input.TextFieldValue
import com.wire.android.ui.common.dialogs.CustomServerDialogState
import com.wire.kalium.logic.data.auth.login.ProxyCredentials

data class LoginState(
val userIdentifier: TextFieldValue = TextFieldValue(""),
Expand All @@ -36,7 +37,14 @@ data class LoginState(
val loginError: LoginError = LoginError.None,
val isProxyEnabled: Boolean = false,
val customServerDialogState: CustomServerDialogState? = null,
)
) {
fun getProxyCredentials(): ProxyCredentials? =
if (proxyIdentifier.text.isNotBlank() && proxyPassword.text.isNotBlank()) {
ProxyCredentials(proxyIdentifier.text, proxyPassword.text)
} else {
null
}
}

fun LoginState.updateEmailLoginEnabled() =
copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.auth.AddAuthenticatedUserUseCase
import com.wire.kalium.logic.feature.auth.AuthenticationResult
import com.wire.kalium.logic.feature.auth.DomainLookupUseCase
import com.wire.kalium.logic.feature.auth.autoVersioningAuth.AutoVersionAuthScopeUseCase
import com.wire.kalium.logic.feature.client.RegisterClientResult
import com.wire.kalium.logic.feature.client.RegisterClientUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -68,8 +67,6 @@ open class LoginViewModel @Inject constructor(
}
}

protected suspend fun authScope(): AutoVersionAuthScopeUseCase.Result = coreLogic.versionedAuthenticationScope(serverConfig)()

private val loginNavArgs: LoginNavArgs = savedStateHandle.navArgs()
private val preFilledUserIdentifier: PreFilledUserIdentifierType = loginNavArgs.userHandle.let {
if (it.isNullOrEmpty()) PreFilledUserIdentifierType.None else PreFilledUserIdentifierType.PreFilled(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import com.wire.android.ui.authentication.verificationcode.VerificationCodeState
import com.wire.android.ui.common.textfield.CodeFieldValue
import com.wire.android.util.dispatchers.DispatcherProvider
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.data.auth.login.ProxyCredentials
import com.wire.kalium.logic.data.auth.verification.VerifiableAction
import com.wire.kalium.logic.feature.auth.AddAuthenticatedUserUseCase
import com.wire.kalium.logic.feature.auth.AuthenticationResult
Expand Down Expand Up @@ -137,29 +136,27 @@ class LoginEmailViewModel @Inject constructor(

private suspend fun resolveCurrentAuthScope(): AuthenticationScope? =
coreLogic.versionedAuthenticationScope(serverConfig).invoke(
AutoVersionAuthScopeUseCase.ProxyAuthentication.UsernameAndPassword(
ProxyCredentials(loginState.proxyIdentifier.text, loginState.proxyPassword.text)
)
).let {
when (it) {
is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope

is AutoVersionAuthScopeUseCase.Result.Failure.UnknownServerVersion -> {
updateEmailLoginError(LoginError.DialogError.ServerVersionNotSupported)
return null
}
loginState.getProxyCredentials()
).let {
when (it) {
is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope

is AutoVersionAuthScopeUseCase.Result.Failure.UnknownServerVersion -> {
updateEmailLoginError(LoginError.DialogError.ServerVersionNotSupported)
return null
}

is AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion -> {
updateEmailLoginError(LoginError.DialogError.ClientUpdateRequired)
return null
}
is AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion -> {
updateEmailLoginError(LoginError.DialogError.ClientUpdateRequired)
return null
}

is AutoVersionAuthScopeUseCase.Result.Failure.Generic -> {
updateEmailLoginError(LoginError.DialogError.GenericError(it.genericFailure))
return null
is AutoVersionAuthScopeUseCase.Result.Failure.Generic -> {
updateEmailLoginError(LoginError.DialogError.GenericError(it.genericFailure))
return null
}
}
}
}

private suspend fun handleAuthenticationFailure(it: AuthenticationResult.Failure, authScope: AuthenticationScope) {
when (it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ class LoginSSOViewModel @Inject constructor(
if (loginState.customServerDialogState != null) {
authServerConfigProvider.updateAuthServer(loginState.customServerDialogState!!.serverLinks)

val authScope = coreLogic.versionedAuthenticationScope(loginState.customServerDialogState!!.serverLinks)().let {
// sso does not support proxy
// TODO: add proxy support
val authScope = coreLogic.versionedAuthenticationScope(loginState.customServerDialogState!!.serverLinks)(null).let {
when (it) {
is AutoVersionAuthScopeUseCase.Result.Failure.Generic,
AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion,
Expand Down Expand Up @@ -134,7 +136,9 @@ class LoginSSOViewModel @Inject constructor(
val defaultAuthScope: AuthenticationScope =
coreLogic.versionedAuthenticationScope(
authServerConfigProvider.defaultServerLinks()
)().let {
// domain lockup does not support proxy
// TODO: add proxy support
)(null).let {
when (it) {
is AutoVersionAuthScopeUseCase.Result.Failure.Generic,
AutoVersionAuthScopeUseCase.Result.Failure.TooNewVersion,
Expand Down Expand Up @@ -168,7 +172,8 @@ class LoginSSOViewModel @Inject constructor(
private fun ssoLoginWithCodeFlow() {
viewModelScope.launch {
val authScope =
authScope().let {
// sso does not support proxy
coreLogic.versionedAuthenticationScope(serverConfig)(null).let {
when (it) {
is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope

Expand Down Expand Up @@ -207,7 +212,7 @@ class LoginSSOViewModel @Inject constructor(
loginState = loginState.copy(ssoLoginLoading = true, loginError = LoginError.None).updateSSOLoginEnabled()
viewModelScope.launch {
val authScope =
authScope().let {
coreLogic.versionedAuthenticationScope(serverConfig)(null).let {
when (it) {
is AutoVersionAuthScopeUseCase.Result.Success -> it.authenticationScope

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,14 @@ private fun OngoingCallContent(
hideDoubleTapToast()
FullScreenTile(
selectedParticipant = selectedParticipantForFullScreen,
height = this@BoxWithConstraints.maxHeight - dimensions().spacing4x
) {
shouldOpenFullScreen = !shouldOpenFullScreen
}
height = this@BoxWithConstraints.maxHeight - dimensions().spacing4x,
closeFullScreen = {
shouldOpenFullScreen = !shouldOpenFullScreen
},
onBackButtonClicked = {
shouldOpenFullScreen = !shouldOpenFullScreen
}
)
} else {
VerticalCallingPager(
participants = participants,
Expand Down
Loading

0 comments on commit 647db97

Please sign in to comment.