Skip to content

Commit

Permalink
feat: mls epic (#1953)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Żerko <iot.zerko@gmail.com>
Co-authored-by: Vitor Hugo Schwaab <vitor@schwaab.dev>
  • Loading branch information
3 people committed Oct 15, 2023
1 parent 04c06e3 commit 43b3f91
Show file tree
Hide file tree
Showing 32 changed files with 558 additions and 141 deletions.
5 changes: 5 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Expand Up @@ -219,6 +219,11 @@ class UseCaseModule {
fun provideUpdateApiVersionsUseCase(@KaliumCoreLogic coreLogic: CoreLogic) =
coreLogic.getGlobalScope().updateApiVersions

@ViewModelScoped
@Provides
fun provideDisableEventProcessing(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).debug.disableEventProcessing

@ViewModelScoped
@Provides
fun provideCurrentSessionFlowUseCase(@KaliumCoreLogic coreLogic: CoreLogic) =
Expand Down
Expand Up @@ -60,6 +60,7 @@ class SystemMessageContentMapper @Inject constructor(
is MessageContent.NewConversationReceiptMode -> mapNewConversationReceiptMode(content)
is MessageContent.ConversationReceiptModeChanged -> mapConversationReceiptModeChanged(message.senderUserId, content, members)
is MessageContent.HistoryLost -> mapConversationHistoryLost()
is MessageContent.HistoryLostProtocolChanged -> mapConversationHistoryListProtocolChanged()
is MessageContent.ConversationMessageTimerChanged -> mapConversationTimerChanged(message.senderUserId, content, members)
is MessageContent.ConversationCreated -> mapConversationCreated(message.senderUserId, message.date, members)
is MessageContent.MLSWrongEpochWarning -> mapMLSWrongEpochWarning()
Expand All @@ -68,6 +69,7 @@ class SystemMessageContentMapper @Inject constructor(
is MessageContent.ConversationVerifiedMLS -> mapConversationVerified(Conversation.Protocol.MLS)
is MessageContent.ConversationVerifiedProteus -> mapConversationVerified(Conversation.Protocol.PROTEUS)
is MessageContent.FederationStopped -> mapFederationMessage(content)
is MessageContent.ConversationProtocolChanged -> mapConversationProtocolChanged(content)
}

private fun mapConversationCreated(senderUserId: UserId, date: String, userList: List<User>): UIMessageContent.SystemMessage {
Expand Down Expand Up @@ -108,6 +110,12 @@ class SystemMessageContentMapper @Inject constructor(
}
}

private fun mapConversationProtocolChanged(
content: MessageContent.ConversationProtocolChanged
): UIMessageContent.SystemMessage {
return UIMessageContent.SystemMessage.ConversationProtocolChanged(content.protocol)
}

private fun mapResetSession(
senderUserId: UserId,
userList: List<User>
Expand Down Expand Up @@ -236,11 +244,14 @@ class SystemMessageContentMapper @Inject constructor(
is MessageContent.FederationStopped.Removed -> UIMessageContent.SystemMessage.FederationStopped(listOf(content.domain))
}

private fun mapConversationHistoryLost(): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.HistoryLost()
private fun mapMLSWrongEpochWarning(): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.MLSWrongEpochWarning()
private fun mapConversationHistoryLost(): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.HistoryLost
private fun mapMLSWrongEpochWarning(): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.MLSWrongEpochWarning()
private fun mapConversationHistoryListProtocolChanged(): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.HistoryLostProtocolChanged
private fun mapConversationDegraded(protocol: Conversation.Protocol): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.ConversationDegraded(protocol)

private fun mapConversationVerified(protocol: Conversation.Protocol): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.ConversationVerified(protocol)

Expand Down
Expand Up @@ -57,6 +57,7 @@ class UIParticipantMapper @Inject constructor(
botService = (user as? OtherUser)?.botService,
isDefederated = (user is OtherUser && user.defederated),
isProteusVerified = (user is OtherUser && user.isProteusVerified),
supportedProtocolList = supportedProtocols.orEmpty().toList()
)
}

Expand All @@ -71,7 +72,8 @@ class UIParticipantMapper @Inject constructor(
isDeleted = userSummary.isUserDeleted,
isSelf = isSelfUser,
isDefederated = false,
isProteusVerified = false
isProteusVerified = false,
supportedProtocolList = listOf()
)
}

Expand All @@ -87,7 +89,8 @@ class UIParticipantMapper @Inject constructor(
isSelf = false,
readReceiptDate = date,
isDefederated = false,
isProteusVerified = false
isProteusVerified = false,
supportedProtocolList = listOf()
)
}

Expand Down
Expand Up @@ -39,6 +39,7 @@ import com.wire.kalium.logic.data.user.ConnectionState
import com.wire.kalium.logic.data.user.OtherUser
import com.wire.kalium.logic.data.user.SelfUser
import com.wire.kalium.logic.data.user.SsoId
import com.wire.kalium.logic.data.user.SupportedProtocol
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.data.user.type.UserType
Expand Down Expand Up @@ -203,7 +204,8 @@ class MigrationMapper @Inject constructor() {
connectionStatus = ConnectionState.ACCEPTED,
previewPicture = scalaUserData.pictureAssetId?.let { toQualifiedId(it, scalaUserData.domain, selfuser) },
completePicture = scalaUserData.pictureAssetId?.let { toQualifiedId(it, scalaUserData.domain, selfuser) },
availabilityStatus = mapUserAvailabilityStatus(scalaUserData.availability)
availabilityStatus = mapUserAvailabilityStatus(scalaUserData.availability),
supportedProtocols = setOf(SupportedProtocol.PROTEUS)
)
} else {
val botService =
Expand Down Expand Up @@ -232,7 +234,8 @@ class MigrationMapper @Inject constructor() {
botService = botService,
deleted = scalaUserData.deleted,
defederated = false,
isProteusVerified = false
isProteusVerified = false,
supportedProtocols = setOf(SupportedProtocol.PROTEUS)
)
}
}
Expand Up @@ -32,11 +32,12 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wire.android.R
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.util.ui.PreviewMultipleThemes

/**
* Outlined box with a text inside.
Expand All @@ -46,17 +47,24 @@ import com.wire.android.ui.theme.wireColorScheme
@Composable
fun StatusBox(
statusText: String,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
textColor: Color = MaterialTheme.wireColorScheme.labelText,
badgeColor: Color = MaterialTheme.wireColorScheme.surface,
withBorder: Boolean = true,
) {
Box(
modifier = modifier
.wrapContentSize()
.clip(RoundedCornerShape(size = dimensions().spacing4x))
.background(colorsScheme().surface)
.background(badgeColor)
.border(
BorderStroke(
width = 1.dp,
color = MaterialTheme.wireColorScheme.divider
color = if (withBorder) {
MaterialTheme.wireColorScheme.divider
} else {
badgeColor
}
),
shape = RoundedCornerShape(size = dimensions().spacing4x),
)
Expand All @@ -68,7 +76,7 @@ fun StatusBox(
) {
Text(
text = statusText,
style = typography().label03.copy(color = MaterialTheme.wireColorScheme.labelText)
style = typography().label03.copy(color = textColor)
)
}
}
Expand All @@ -81,8 +89,28 @@ fun DeletedLabel(modifier: Modifier = Modifier) {
)
}

@Preview
@Composable
fun ProtocolLabel(
protocolName: String,
modifier: Modifier = Modifier
) {
StatusBox(
statusText = protocolName,
modifier = modifier,
textColor = MaterialTheme.wireColorScheme.onPrimary,
badgeColor = MaterialTheme.wireColorScheme.primary,
withBorder = false
)
}

@PreviewMultipleThemes
@Composable
fun PreviewDeletedLabel() {
DeletedLabel()
}

@PreviewMultipleThemes
@Composable
fun PreviewProtocolLabel() {
ProtocolLabel("MLS")
}

0 comments on commit 43b3f91

Please sign in to comment.