Skip to content

Commit

Permalink
Merge branch 'release/candidate' into fix/get_e2ei_certificate_button…
Browse files Browse the repository at this point in the history
…_when_no_certificate-cherry-pick
  • Loading branch information
borichellow committed May 20, 2024
2 parents e8b8e12 + 74e655c commit cd7a9d2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fun ConversationProtocolDetails(
if (protocolInfo is Conversation.ProtocolInfo.MLS) {
ProtocolDetails(
label = UIText.StringResource(R.string.cipher_suite),
text = UIText.DynamicString(protocolInfo.cipherSuite.name)
text = UIText.DynamicString(protocolInfo.cipherSuite.toString())
)

if (BuildConfig.PRIVATE_BUILD) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.wire.android.ui.home.conversations.usecase.HandleUriAssetUseCase
import com.wire.android.ui.home.messagecomposer.model.ComposableMessageBundle
import com.wire.android.ui.home.messagecomposer.model.MessageBundle
import com.wire.android.ui.home.messagecomposer.model.Ping
import com.wire.android.util.AUDIO_MIME_TYPE
import com.wire.android.util.ImageUtil
import com.wire.android.util.dispatchers.DispatcherProvider
import com.wire.android.util.getAudioLengthInMs
Expand Down Expand Up @@ -67,8 +68,6 @@ import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okio.Path
import okio.Path.Companion.toPath
import javax.inject.Inject

@Suppress("LongParameterList", "TooManyFunctions")
Expand Down Expand Up @@ -165,8 +164,8 @@ class SendMessageViewModel @Inject constructor(
is ComposableMessageBundle.AudioMessageBundle -> {
handleAssetMessageBundle(
attachmentUri = messageBundle.attachmentUri,
audioPath = messageBundle.attachmentUri.uri.path?.toPath(),
conversationId = messageBundle.conversationId
conversationId = messageBundle.conversationId,
specifiedMimeType = AUDIO_MIME_TYPE,
)
}

Expand Down Expand Up @@ -208,12 +207,12 @@ class SendMessageViewModel @Inject constructor(
private suspend fun handleAssetMessageBundle(
conversationId: ConversationId,
attachmentUri: UriAsset,
audioPath: Path? = null
specifiedMimeType: String? = null, // specify a particular mimetype, otherwise it will be taken from the uri / file extension
) {
when (val result = handleUriAsset.invoke(
uri = attachmentUri.uri,
saveToDeviceIfInvalid = attachmentUri.saveToDeviceIfInvalid,
audioPath = audioPath
specifiedMimeType = specifiedMimeType
)) {
is HandleUriAssetUseCase.Result.Failure.AssetTooLarge -> {
assetTooLargeDialogState = AssetTooLargeDialogState.Visible(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.wire.kalium.logic.data.asset.AttachmentType
import com.wire.kalium.logic.data.asset.KaliumFileSystem
import com.wire.kalium.logic.feature.asset.GetAssetSizeLimitUseCase
import kotlinx.coroutines.withContext
import okio.Path
import java.util.UUID
import javax.inject.Inject

class HandleUriAssetUseCase @Inject constructor(
Expand All @@ -38,14 +38,13 @@ class HandleUriAssetUseCase @Inject constructor(
suspend fun invoke(
uri: Uri,
saveToDeviceIfInvalid: Boolean = false,
audioPath: Path? = null,
specifiedMimeType: String? = null, // specify a particular mimetype, otherwise it will be taken from the uri / file extension
): Result = withContext(dispatchers.io()) {

val tempCachePath = kaliumFileSystem.rootCachePath
val tempAssetPath = kaliumFileSystem.tempFilePath(UUID.randomUUID().toString())
val assetBundle = fileManager.getAssetBundleFromUri(
attachmentUri = uri,
tempCachePath = tempCachePath,
audioPath = audioPath
assetDestinationPath = tempAssetPath,
specifiedMimeType = specifiedMimeType,
)
if (assetBundle != null) {
// The max limit for sending assets changes between user and asset types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class ImportMediaAuthenticatedViewModel @Inject constructor(
}

private suspend fun handleImportedAsset(uri: Uri): ImportedMediaAsset? = withContext(dispatchers.io()) {
when (val result = handleUriAsset.invoke(uri, saveToDeviceIfInvalid = false, audioPath = null)) {
when (val result = handleUriAsset.invoke(uri, saveToDeviceIfInvalid = false)) {
is HandleUriAssetUseCase.Result.Failure.AssetTooLarge -> mapToImportedAsset(result.assetBundle, result.maxLimitInMB)

HandleUriAssetUseCase.Result.Failure.Unknown -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import com.wire.android.util.CustomTabsHelper
import com.wire.android.util.capitalizeFirstLetter
import com.wire.android.util.ui.LinkText
import com.wire.android.util.ui.LinkTextData
import com.wire.kalium.logic.feature.e2ei.CertificateStatus

@Composable
fun OtherUserDevicesScreen(
Expand Down Expand Up @@ -125,7 +124,7 @@ private fun OtherUserDevicesContent(
onClickAction = onDeviceClick,
icon = Icons.Filled.ChevronRight.Icon(),
shouldShowVerifyLabel = true,
shouldShowE2EIInfo = item.e2eiCertificateStatus == CertificateStatus.VALID
shouldShowE2EIInfo = item.e2eiCertificateStatus != null
)
if (index < otherUserDevices.lastIndex) WireDivider()
}
Expand Down
14 changes: 6 additions & 8 deletions app/src/main/kotlin/com/wire/android/util/FileManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,26 @@ class FileManager @Inject constructor(@ApplicationContext private val context: C
@Suppress("TooGenericExceptionCaught")
suspend fun getAssetBundleFromUri(
attachmentUri: Uri,
tempCachePath: Path,
audioPath: Path? = null,
assetDestinationPath: Path,
specifiedMimeType: String? = null, // specify a particular mimetype, otherwise it will be taken from the uri / file extension
dispatcher: DispatcherProvider = DefaultDispatcherProvider(),
): AssetBundle? = withContext(dispatcher.io()) {
try {
val assetKey = UUID.randomUUID().toString()
val assetFileName = context.getFileName(attachmentUri)
?: throw IOException("The selected asset has an invalid name")
val fullTempAssetPath = "$tempCachePath/${UUID.randomUUID()}".toPath()
val assetPath = audioPath ?: fullTempAssetPath
val mimeType = if (audioPath != null) AUDIO_MIME_TYPE else attachmentUri
val mimeType = specifiedMimeType ?: attachmentUri
.getMimeType(context)
.orDefault(DEFAULT_FILE_MIME_TYPE)
val attachmentType = AttachmentType.fromMimeTypeString(mimeType)
val assetSize = if (attachmentType == AttachmentType.IMAGE) {
attachmentUri.resampleImageAndCopyToTempPath(context, fullTempAssetPath)
attachmentUri.resampleImageAndCopyToTempPath(context, assetDestinationPath)
} else {
// TODO: We should add also a video resampling logic soon, that way we could drastically reduce as well the number
// of video assets hitting the max limit.
copyToPath(attachmentUri, fullTempAssetPath)
copyToPath(attachmentUri, assetDestinationPath)
}
AssetBundle(assetKey, mimeType, assetPath, assetSize, assetFileName, attachmentType)
AssetBundle(assetKey, mimeType, assetDestinationPath, assetSize, assetFileName, attachmentType)
} catch (e: IOException) {
appLogger.e("There was an error while obtaining the file from disk", e)
null
Expand Down
2 changes: 1 addition & 1 deletion kalium
Submodule kalium updated 56 files
+19 βˆ’0 .github/workflows/jira-lint-and-link.yml
+12 βˆ’4 cryptography/src/androidInstrumentedTest/kotlin/com/wire/kalium/cryptography/BaseMLSClientTest.kt
+1 βˆ’1 cryptography/src/androidInstrumentedTest/kotlin/com/wire/kalium/cryptography/BaseProteusClientTest.kt
+12 βˆ’4 cryptography/src/androidUnitTest/kotlin/com/wire/kalium/cryptography/BaseMLSClientTest.kt
+1 βˆ’1 cryptography/src/androidUnitTest/kotlin/com/wire/kalium/cryptography/BaseProteusClientTest.kt
+6 βˆ’1 cryptography/src/appleMain/kotlin/com/wire/kalium/cryptography/CoreCryptoCentralImpl.kt
+12 βˆ’4 cryptography/src/appleTest/kotlin/com/wire/kalium/cryptography/BaseMLSClientTest.kt
+1 βˆ’1 cryptography/src/appleTest/kotlin/com/wire/kalium/cryptography/BaseProteusClientTest.kt
+25 βˆ’9 cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/CoreCryptoCentral.kt
+12 βˆ’11 cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/MLSClientImpl.kt
+11 βˆ’2 cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/CoreCryptoCentral.kt
+10 βˆ’2 cryptography/src/commonTest/kotlin/com/wire/kalium/cryptography/BaseMLSClientTest.kt
+6 βˆ’4 cryptography/src/commonTest/kotlin/com/wire/kalium/cryptography/E2EIClientTest.kt
+3 βˆ’1 cryptography/src/commonTest/kotlin/com/wire/kalium/cryptography/MLSClientTest.kt
+1 βˆ’1 cryptography/src/commonTest/kotlin/com/wire/kalium/cryptography/ProteusClientTest.kt
+6 βˆ’1 cryptography/src/jsMain/kotlin/com/wire/kalium/cryptography/CoreCryptoCentralImpl.kt
+10 βˆ’2 cryptography/src/jsTest/kotlin/com/wire/kalium/cryptography/BaseMLSClientTest.kt
+12 βˆ’4 cryptography/src/jvmTest/kotlin/com/wire/kalium/cryptography/BaseMLSClientTest.kt
+1 βˆ’1 cryptography/src/jvmTest/kotlin/com/wire/kalium/cryptography/BaseProteusClientTest.kt
+2 βˆ’2 gradle/libs.versions.toml
+1 βˆ’0 logic/src/androidMain/kotlin/com/wire/kalium/logic/data/asset/KaliumFileSystemImpl.kt
+24 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/UserConfigRepository.kt
+5 βˆ’5 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/client/E2EIClientProvider.kt
+12 βˆ’4 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/client/MLSClientProvider.kt
+3 βˆ’1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/client/ProteusClientProvider.kt
+3 βˆ’19 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/Conversation.kt
+10 βˆ’2 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt
+3 βˆ’2 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ProtocolInfoMapper.kt
+13 βˆ’6 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigMapper.kt
+2 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigModel.kt
+98 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/mls/CipherSuite.kt
+2 βˆ’1 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt
+1 βˆ’1 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/SyncFeatureConfigsUseCase.kt
+5 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/MLSConfigHandler.kt
+18 βˆ’11 logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/MemberJoinEventHandler.kt
+2 βˆ’1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/CallRepositoryTest.kt
+42 βˆ’1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepositoryTest.kt
+3 βˆ’2 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/ProtocolInfoMapperTest.kt
+1 βˆ’1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/event/FeatureConfigMapperTest.kt
+6 βˆ’5 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigRepositoryTest.kt
+6 βˆ’1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigTest.kt
+2 βˆ’3 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/client/RegisterMLSClientUseCaseTest.kt
+6 βˆ’5 .../src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/JoinExistingMLSConversationUseCaseTest.kt
+3 βˆ’2 ...src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/JoinExistingMLSConversationsUseCaseTest.kt
+3 βˆ’2 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/RecoverMLSConversationsUseCaseTests.kt
+54 βˆ’16 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/MLSConfigHandlerTest.kt
+2 βˆ’1 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/MessageSenderTest.kt
+3 βˆ’2 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/mlsmigration/MLSMigratorTest.kt
+3 βˆ’2 logic/src/commonTest/kotlin/com/wire/kalium/logic/framework/TestConversation.kt
+75 βˆ’99 logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/conversation/MemberJoinEventHandlerTest.kt
+42 βˆ’0 logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/eventHandler/LegalHoldHandlerArrangement.kt
+5 βˆ’0 ...rc/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/ConversationRepositoryArrangement.kt
+5 βˆ’1 .../src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/UserConfigRepositoryArrangement.kt
+2 βˆ’1 logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/scenario/OnCloseCallTest.kt
+11 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/unread/UserConfigDAO.kt
+29 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/model/SupportedCipherSuiteEntity.kt

0 comments on commit cd7a9d2

Please sign in to comment.