Set selection limit to 5 images and add warning for exceeding limit

This commit is contained in:
Kota-Jagadeesh 2025-10-14 00:06:13 +05:30
parent c3bb460ae9
commit 6edcab654a

View file

@ -107,7 +107,7 @@ class CustomSelectorActivity :
/** /**
* Maximum number of images that can be selected. * Maximum number of images that can be selected.
*/ */
private var uploadLimit: Int = 20 private var uploadLimit: Int = 5 // Changed to 5 asper the issue #3101
/** /**
* Flag that is marked true when the amount * Flag that is marked true when the amount
@ -650,8 +650,12 @@ class CustomSelectorActivity :
finishPickImages(arrayListOf()) finishPickImages(arrayListOf())
return return
} }
if (selectedImages.size > uploadLimit) {
displayUploadLimitWarning() // shows the warning dialog if >5 images
return
}
scope.launch(ioDispatcher) { scope.launch(ioDispatcher) {
val uniqueImages = selectedImages.distinctBy { image -> val uniqueImages = selectedImages.take(uploadLimit).distinctBy { image -> //enforce limit
CustomSelectorUtils.getImageSHA1( CustomSelectorUtils.getImageSHA1(
image.uri, image.uri,
ioDispatcher, ioDispatcher,