Skip to content

Commit

Permalink
Merge branch 'develop' into feat/inform_user_about_degraded_conversat…
Browse files Browse the repository at this point in the history
…ion_verification_status
  • Loading branch information
borichellow committed Jul 24, 2023
2 parents 47a1feb + 398b709 commit 63fcc8c
Show file tree
Hide file tree
Showing 21 changed files with 260 additions and 30 deletions.
5 changes: 5 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1221,4 +1221,9 @@ class UseCaseModule {
@KaliumCoreLogic coreLogic: CoreLogic,
@CurrentAccount currentAccount: UserId
): ObserveScreenshotCensoringConfigUseCase = coreLogic.getSessionScope(currentAccount).observeScreenshotCensoringConfig

@ViewModelScoped
@Provides
fun provideGetConversationVerificationStatusUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).getConversationVerificationStatus
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ data class Device(
val isVerified: Boolean = false
) {
constructor(client: Client) : this(
client.displayName(),
client.id,
client.registrationTime?.toIsoDateTimeString(),
client.lastActiveInWholeWeeks(),
client.isVerified
name = client.displayName(),
clientId = client.id,
registrationTime = client.registrationTime?.toIsoDateTimeString(),
lastActiveInWholeWeeks = client.lastActiveInWholeWeeks(),
isValid = client.isVerified,
isVerified = client.isVerified
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@

package com.wire.android.ui.home.conversations

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
Expand Down Expand Up @@ -62,8 +64,10 @@ import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.debug.LocalFeatureVisibilityFlags
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.data.conversation.ConversationVerificationStatus
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
import com.wire.kalium.logic.feature.conversation.ConversationProtocol

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -97,6 +101,20 @@ fun ConversationScreenTopAppBar(
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(weight = 1f, fill = false)
)
if (conversationInfoViewState.verificationStatus?.status == ConversationVerificationStatus.VERIFIED) {
val (iconId, contentDescriptionId) = when (conversationInfoViewState.verificationStatus.protocol) {
ConversationProtocol.MLS ->
R.drawable.ic_certificate_valid_mls to R.string.content_description_mls_certificate_valid

ConversationProtocol.PROTEUS ->
R.drawable.ic_certificate_valid_proteus to R.string.content_description_proteus_certificate_valid
}
Image(
modifier = Modifier.padding(start = dimensions().spacing4x),
painter = painterResource(id = iconId),
contentDescription = stringResource(contentDescriptionId)
)
}
if (isDropDownEnabled && isInteractionEnabled) {
Icon(
painter = painterResource(id = R.drawable.ic_dropdown_icon),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.id.QualifiedIdMapper
import com.wire.kalium.logic.data.user.ConnectionState
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.conversation.ConversationVerificationStatusResult
import com.wire.kalium.logic.feature.conversation.GetConversationVerificationStatusUseCase
import com.wire.kalium.logic.feature.conversation.ObserveConversationDetailsUseCase
import com.wire.kalium.logic.feature.user.GetSelfUserUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
Expand All @@ -62,7 +64,8 @@ class ConversationInfoViewModel @Inject constructor(
private val observeConversationDetails: ObserveConversationDetailsUseCase,
private val observerSelfUser: GetSelfUserUseCase,
private val wireSessionImageLoader: WireSessionImageLoader,
private val dispatchers: DispatcherProvider
private val dispatchers: DispatcherProvider,
private val getConversationVerificationStatus: GetConversationVerificationStatusUseCase
) : SavedStateViewModel(savedStateHandle) {

var conversationInfoViewState by mutableStateOf(ConversationInfoViewState())
Expand All @@ -81,6 +84,12 @@ class ConversationInfoViewModel @Inject constructor(
viewModelScope.launch {
selfUserId = observerSelfUser().first().id
}
viewModelScope.launch {
val result = getConversationVerificationStatus(conversationId)
if (result is ConversationVerificationStatusResult.Success) {
conversationInfoViewState = conversationInfoViewState.copy(verificationStatus = result)
}
}
}

/*
Expand Down Expand Up @@ -118,6 +127,7 @@ class ConversationInfoViewModel @Inject constructor(
navigateToHome()
}
}

is StorageFailure.Generic -> appLogger.e("An error occurred when fetching details of the conversation", failure.rootCause)
}
}
Expand All @@ -126,6 +136,7 @@ class ConversationInfoViewModel @Inject constructor(
val (isConversationUnavailable, _) = when (conversationDetails) {
is ConversationDetails.OneOne -> conversationDetails.otherUser
.run { isUnavailableUser to (connectionStatus == ConnectionState.BLOCKED) }

else -> false to false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.user.ConnectionState
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.conversation.ConversationVerificationStatusResult

data class ConversationInfoViewState(
val conversationName: UIText = UIText.DynamicString(""),
val conversationDetailsData: ConversationDetailsData = ConversationDetailsData.None,
val conversationAvatar: ConversationAvatar = ConversationAvatar.None,
val hasUserPermissionToEdit: Boolean = false,
val conversationType: Conversation.Type = Conversation.Type.ONE_ON_ONE,
val verificationStatus: ConversationVerificationStatusResult.Success? = null,
)

sealed class ConversationDetailsData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fun AdditionalOptionsMenu(
selectedOption: AdditionalOptionSelectItem,
isFileSharingEnabled: Boolean,
isSelfDeletingSettingEnabled: Boolean,
isSelfDeletingActive: Boolean,
isEditing: Boolean,
isMentionActive: Boolean,
onOnSelfDeletingOptionClicked: (() -> Unit)? = null,
Expand All @@ -82,8 +83,9 @@ fun AdditionalOptionsMenu(
isFileSharingEnabled = isFileSharingEnabled,
isEditing = isEditing,
isSelfDeletingSettingEnabled = isSelfDeletingSettingEnabled,
isSelfDeletingActive = isSelfDeletingActive,
isMentionActive = isMentionActive,
onMentionButtonClicked = onMentionButtonClicked ?: {},
onMentionButtonClicked = onMentionButtonClicked,
onAdditionalOptionsMenuClicked = onAdditionalOptionsMenuClicked,
onGifButtonClicked = onGifOptionClicked ?: {},
onSelfDeletionOptionButtonClicked = onOnSelfDeletingOptionClicked ?: {},
Expand Down Expand Up @@ -156,6 +158,7 @@ fun AttachmentAndAdditionalOptionsMenuItems(
onPingClicked: () -> Unit = {},
onSelfDeletionOptionButtonClicked: () -> Unit,
isSelfDeletingSettingEnabled: Boolean,
isSelfDeletingActive: Boolean,
onGifButtonClicked: () -> Unit = {},
onRichEditingButtonClicked: () -> Unit = {},
modifier: Modifier = Modifier
Expand All @@ -172,6 +175,7 @@ fun AttachmentAndAdditionalOptionsMenuItems(
onPingButtonClicked = onPingClicked,
onSelfDeletionOptionButtonClicked = onSelfDeletionOptionButtonClicked,
isSelfDeletingSettingEnabled = isSelfDeletingSettingEnabled,
isSelfDeletingActive = isSelfDeletingActive,
onGifButtonClicked = onGifButtonClicked,
onRichEditingButtonClicked = onRichEditingButtonClicked
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fun MessageComposeActions(
isFileSharingEnabled: Boolean = true,
isMentionActive: Boolean = true,
isSelfDeletingSettingEnabled: Boolean = true,
isSelfDeletingActive: Boolean = false,
onMentionButtonClicked: () -> Unit,
onAdditionalOptionButtonClicked: () -> Unit,
onPingButtonClicked: () -> Unit,
Expand All @@ -70,6 +71,7 @@ fun MessageComposeActions(
onRichEditingButtonClicked,
onGifButtonClicked,
isSelfDeletingSettingEnabled,
isSelfDeletingActive,
onSelfDeletionOptionButtonClicked,
onPingButtonClicked,
onMentionButtonClicked
Expand All @@ -86,6 +88,7 @@ private fun ComposingActions(
onRichEditingButtonClicked: () -> Unit,
onGifButtonClicked: () -> Unit,
isSelfDeletingSettingEnabled: Boolean,
isSelfDeletingActive: Boolean,
onSelfDeletionOptionButtonClicked: () -> Unit,
onPingButtonClicked: () -> Unit,
onMentionButtonClicked: () -> Unit
Expand All @@ -112,7 +115,7 @@ private fun ComposingActions(
if (EmojiIcon) AddEmojiAction({})
if (GifIcon) AddGifAction(onGifButtonClicked)
if (isSelfDeletingSettingEnabled) SelfDeletingMessageAction(
isSelected = false,
isSelected = isSelfDeletingActive,
onButtonClicked = onSelfDeletionOptionButtonClicked
)
if (PingIcon) PingAction(onPingButtonClicked)
Expand All @@ -131,8 +134,6 @@ fun EditingActions(
onRichEditingButtonClicked: () -> Unit,
onMentionButtonClicked: () -> Unit
) {
val localFeatureVisibilityFlags = LocalFeatureVisibilityFlags.current

Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceEvenly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import com.wire.android.util.ui.KeyboardHeight
import com.wire.kalium.logic.feature.conversation.InteractionAvailability
import com.wire.kalium.logic.feature.conversation.SecurityClassificationType
import com.wire.kalium.logic.feature.selfDeletingMessages.SelfDeletionTimer
import com.wire.kalium.logic.util.isPositiveNotNull
import kotlin.time.Duration

@Composable
Expand Down Expand Up @@ -350,7 +351,7 @@ private fun ActiveMessageComposer(
messageComposition = messageComposition.value,
inputSize = messageCompositionInputStateHolder.inputSize,
inputType = messageCompositionInputStateHolder.inputType,
inputVisiblity = messageCompositionInputStateHolder.inputVisibility,
inputVisibility = messageCompositionInputStateHolder.inputVisibility,
inputFocused = messageCompositionInputStateHolder.inputFocused,
onInputFocusedChanged = ::onInputFocusedChanged,
onToggleInputSize = messageCompositionInputStateHolder::toggleInputSize,
Expand Down Expand Up @@ -399,6 +400,7 @@ private fun ActiveMessageComposer(
isEditing = messageCompositionInputStateHolder.inputType is MessageCompositionType.Editing,
isFileSharingEnabled = messageComposerViewState.value.isFileSharingEnabled,
isSelfDeletingSettingEnabled = isSelfDeletingSettingEnabled,
isSelfDeletingActive = messageComposerViewState.value.selfDeletionTimer.duration.isPositiveNotNull(),
isMentionActive = messageComposerViewState.value.mentionSearchResult.isNotEmpty(),
onMentionButtonClicked = {
messageCompositionHolder.startMention(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fun InactiveMessageComposerInput(
focusColor = Color.Transparent,
placeholderColor = colorsScheme().secondaryText
),
placeHolderText = stringResource(id = R.string.label_type_a_message),
messageText = messageText,
onMessageTextChanged = {
// non functional
Expand All @@ -105,7 +106,7 @@ fun ActiveMessageComposerInput(
messageComposition: MessageComposition,
inputSize: MessageCompositionInputSize,
inputType: MessageCompositionType,
inputVisiblity: Boolean,
inputVisibility: Boolean,
inputFocused: Boolean,
onMessageTextChanged: (TextFieldValue) -> Unit,
onSendButtonClicked: () -> Unit,
Expand All @@ -119,7 +120,7 @@ fun ActiveMessageComposerInput(
onLineBottomYCoordinateChanged: (Float) -> Unit,
modifier: Modifier = Modifier
) {
if (inputVisiblity) {
if (inputVisibility) {
Column(
modifier = modifier
.wrapContentSize()
Expand Down Expand Up @@ -158,6 +159,7 @@ fun ActiveMessageComposerInput(
inputFocused = inputFocused,
colors = inputType.inputTextColor(),
messageText = messageComposition.messageTextFieldValue,
placeHolderText = inputType.labelText(),
onMessageTextChanged = onMessageTextChanged,
singleLine = false,
onFocusChanged = onInputFocusedChanged,
Expand Down Expand Up @@ -209,6 +211,7 @@ private fun MessageComposerTextInput(
colors: WireTextFieldColors,
singleLine: Boolean,
messageText: TextFieldValue,
placeHolderText: String,
onMessageTextChanged: (TextFieldValue) -> Unit,
onFocusChanged: (Boolean) -> Unit = {},
onSelectedLineIndexChanged: (Int) -> Unit = { },
Expand All @@ -233,7 +236,7 @@ private fun MessageComposerTextInput(
maxLines = Int.MAX_VALUE,
textStyle = MaterialTheme.wireTypography.body01,
// Add an extra space so that the cursor is placed one space before "Type a message"
placeholderText = " " + stringResource(R.string.label_type_a_message),
placeholderText = " $placeHolderText",
modifier = modifier.then(
Modifier
.onFocusChanged { focusState ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class AudioMediaRecorder @Inject constructor(

private companion object {
fun getRecordingAudioFileName(): String =
"wire-audio-${DateTimeUtil.currentInstant().audioFileDateTime()}.mp3"
"wire-audio-${DateTimeUtil.currentInstant().audioFileDateTime()}.m4a"
const val SIZE_OF_1MB = 1024 * 1024
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fun rememberMessageComposerStateHolder(
messageComposerViewState.value.selfDeletionTimer
}
}

val messageCompositionInputStateHolder = rememberSaveable(
saver = MessageCompositionInputStateHolder.saver(
messageComposition = messageCompositionHolder.messageComposition,
Expand Down Expand Up @@ -95,7 +96,6 @@ class MessageComposerStateHolder(
val modalBottomSheetState: WireModalSheetState
) {
val messageComposition = messageCompositionHolder.messageComposition

val isTransitionToKeyboardOnGoing
@Composable get() = additionalOptionStateHolder.additionalOptionsSubMenuState == AdditionalOptionSubMenuState.Hidden &&
!KeyboardHelper.isKeyboardVisible() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class MessageCompositionHolder(
}

val messageComposition: MutableState<MessageComposition> = mutableStateOf(MessageComposition.DEFAULT)

fun setReply(message: UIMessage.Regular) {
val senderId = message.header.userId ?: return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import com.wire.android.R
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.textfield.WireTextFieldColors
import com.wire.android.ui.common.textfield.wireTextFieldColors
Expand Down Expand Up @@ -159,6 +161,9 @@ sealed class MessageCompositionType {
@Composable
open fun backgroundColor(): Color = colorsScheme().messageComposerBackgroundColor

@Composable
open fun labelText(): String = stringResource(R.string.label_type_a_message)

class Composing(messageCompositionState: MutableState<MessageComposition>, val messageType: State<MessageType>) :
MessageCompositionType() {

Expand All @@ -177,6 +182,13 @@ sealed class MessageCompositionType {
} else {
super.inputTextColor()
}

@Composable
override fun labelText(): String = if (messageType.value is MessageType.SelfDeleting) {
stringResource(id = R.string.self_deleting_message_label)
} else {
super.labelText()
}
}

class Editing(
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/res/drawable/ic_certificate_valid_mls.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
~ Wire
~ Copyright (C) 2023 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/.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:fillColor="#1D7833"
android:fillType="evenOdd"
android:pathData="M15,8V1.872L8,0L1,2V8C1,12 4.007,15.098 8,16C12.034,15.098 15,12 15,8ZM13,5.346L6.852,12L3,7.846L4.231,6.5L6.852,9.309L11.769,4L13,5.346Z" />
</vector>
Loading

0 comments on commit 63fcc8c

Please sign in to comment.