diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ComposeView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ComposeView.kt index b3c5b73353..90da13cef4 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ComposeView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ComposeView.kt @@ -203,12 +203,23 @@ fun ComposeView( val bitmap = ImageDecoder.decodeBitmap(source) if (drawable is AnimatedImageDrawable) { // It's a gif or webp - chosenAnimImage.value = uri + val fileSize = getFileSize(context, uri) + if (fileSize != null && fileSize <= MAX_FILE_SIZE) { + chosenAnimImage.value = uri + } else { + AlertManager.shared.showAlertMsg( + generalGetString(R.string.large_file), + String.format(generalGetString(R.string.maximum_supported_file_size), formatBytes(MAX_FILE_SIZE)) + ) + } } else { chosenImage.value = bitmap } - val imagePreview = resizeImageToStrSize(bitmap, maxDataSize = 14000) - composeState.value = composeState.value.copy(preview = ComposePreview.ImagePreview(imagePreview)) + + if (chosenImage.value != null || chosenAnimImage.value != null) { + val imagePreview = resizeImageToStrSize(bitmap, maxDataSize = 14000) + composeState.value = composeState.value.copy(preview = ComposePreview.ImagePreview(imagePreview)) + } } } val galleryLauncher = rememberLauncherForActivityResult(contract = PickFromGallery(), processPickedImage) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/item/CIImageView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/item/CIImageView.kt index 4e5da7a85f..5a63805049 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/item/CIImageView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/item/CIImageView.kt @@ -7,6 +7,8 @@ import androidx.compose.material.CircularProgressIndicator import androidx.compose.material.Icon import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Check +import androidx.compose.material.icons.filled.Download +import androidx.compose.material.icons.outlined.ArrowDownward import androidx.compose.material.icons.outlined.MoreHoriz import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState @@ -76,6 +78,13 @@ fun CIImageView( color = Color.White, strokeWidth = 2.dp ) + CIFileStatus.RcvInvitation -> + Icon( + Icons.Outlined.ArrowDownward, + stringResource(R.string.icon_descr_asked_to_receive), + Modifier.fillMaxSize(), + tint = Color.White + ) else -> {} } } @@ -116,6 +125,13 @@ fun CIImageView( ) } + fun fileSizeValid(): Boolean { + if (file != null) { + return file.fileSize <= MAX_FILE_SIZE + } + return false + } + Box(contentAlignment = Alignment.TopEnd) { val context = LocalContext.current val imageBitmap: Bitmap? = getLoadedImage(context, file) @@ -146,7 +162,14 @@ fun CIImageView( if (file != null) { when (file.fileStatus) { CIFileStatus.RcvInvitation -> - receiveFile(file.fileId) + if (fileSizeValid()) { + receiveFile(file.fileId) + } else { + AlertManager.shared.showAlertMsg( + generalGetString(R.string.large_file), + String.format(generalGetString(R.string.contact_sent_large_file), formatBytes(MAX_FILE_SIZE)) + ) + } CIFileStatus.RcvAccepted -> AlertManager.shared.showAlertMsg( generalGetString(R.string.waiting_for_image), diff --git a/apps/android/app/src/main/res/values-ru/strings.xml b/apps/android/app/src/main/res/values-ru/strings.xml index 5c7a0da863..a32d0848d4 100644 --- a/apps/android/app/src/main/res/values-ru/strings.xml +++ b/apps/android/app/src/main/res/values-ru/strings.xml @@ -162,6 +162,7 @@ Изображение Ожидается прием изображения + Предложено получить изображение Изображение отправлено Ожидается прием изображения Изображение будет принято, когда ваш контакт будет в сети, подождите или проверьте позже! diff --git a/apps/android/app/src/main/res/values/strings.xml b/apps/android/app/src/main/res/values/strings.xml index 32e78d127b..4db37e95d9 100644 --- a/apps/android/app/src/main/res/values/strings.xml +++ b/apps/android/app/src/main/res/values/strings.xml @@ -162,6 +162,7 @@ Image Waiting for image + Asked to receive the image Image sent Waiting for image Image will be received when your contact is online, please wait or check later!