Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c3bb460
Enforce 5-image selection limit with warning dialog on click
Kota-Jagadeesh Oct 13, 2025
6edcab6
Set selection limit to 5 images and add warning for exceeding limit
Kota-Jagadeesh Oct 13, 2025
d918b84
Enforced 5-image limit for selection and upload, added close button, …
Kota-Jagadeesh Oct 13, 2025
82cb5db
Added 20-img limit
Kota-Jagadeesh Oct 14, 2025
04bc600
Merge branch 'main' into fix/upload-limit-#3101
nicolas-raoul Oct 16, 2025
e17a668
Merge branch 'main' into fix/upload-limit-#3101
nicolas-raoul Oct 19, 2025
38b1010
Fix:define the maximum number of images allowed for selection
Kota-Jagadeesh Oct 20, 2025
24e6ac7
Fix:initialize the adapter's limit from the constant
Kota-Jagadeesh Oct 20, 2025
e09b61a
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh Nov 7, 2025
6dde33b
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh Nov 10, 2025
9218460
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh Nov 12, 2025
004e04b
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh Nov 14, 2025
66c21ca
Merge branch 'main' into fix/upload-limit-#3101
nicolas-raoul Nov 15, 2025
f5fa479
Remove duplicate import statement for MAX_IMAGE_COUNT
nicolas-raoul Nov 15, 2025
efabeb9
Remove duplicate import of MAX_IMAGE_COUNT
nicolas-raoul Nov 15, 2025
6421d94
Set max upload limit to 20 on adapter initialization and improve sele…
Kota-Jagadeesh Nov 17, 2025
9df1f38
Improve thumbnail selection visual feedback and make cross button beh…
Kota-Jagadeesh Nov 17, 2025
03dac94
Fix:Ensure reliable 20-image limit toast in Custom Selector
Kota-Jagadeesh Nov 17, 2025
bb1a89e
Added string for toast in classic multi-upload
Kota-Jagadeesh Nov 17, 2025
fa982d6
Added selected more than 20 images toast and limit uploads to first 2…
Kota-Jagadeesh Nov 17, 2025
f8dd59a
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh Nov 18, 2025
897221d
Added back the xml declaration
Kota-Jagadeesh Nov 18, 2025
88e1f57
Removed unused code
Kota-Jagadeesh Nov 18, 2025
4984d73
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh Nov 20, 2025
3e01041
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh Nov 25, 2025
dac21ad
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh Nov 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,55 +188,38 @@ class ImageAdapter(
defaultDispatcher,
uploadingContributionList,
)
scope.launch {
val sharedPreferences: SharedPreferences =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this part not useful? Does the Show already handled pictures still work as intended?

context.getSharedPreferences(CUSTOM_SELECTOR_PREFERENCE_KEY, 0)
val showAlreadyActionedImages =
sharedPreferences.getBoolean(SHOW_ALREADY_ACTIONED_IMAGES_PREFERENCE_KEY, true)
if (!showAlreadyActionedImages) {
// If the position is not already visited, that means the position is new then
// finds the next actionable image position from all images
if (!alreadyAddedPositions.contains(position)) {
processThumbnailForActionedImage(
holder,
position,
uploadingContributionList
)
_isLoadingImages.value = false
// If the position is already visited, that means the image is already present
// inside map, so it will fetch the image from the map and load in the holder
holder.itemView.setOnClickListener {
if (!holder.isItemUploaded() && !holder.isItemNotForUpload()) {
if (selectedImages.size >= 20 && !isSelected) { //enforce the 20-image limit
Toast.makeText(context, "Cannot select more than 20 images", Toast.LENGTH_SHORT).show()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using MAX_IMAGE_COUNT in the toast?

return@setOnClickListener
}
if (isSelected) {
selectedImages.removeAt(selectedIndex)
holder.itemUnselected()
notifyItemChanged(position, ImageUnselected())
imageSelectListener.onSelectedImagesChanged(selectedImages, selectedImages.size)
} else {
val actionableImages: List<Image> = ArrayList(actionableImagesMap.values)
if (actionableImages.size > position) {
image = actionableImages[position]
Glide
.with(holder.image)
.load(image.uri)
.thumbnail(0.3f)
.into(holder.image)
}
selectedImages.add(image)
holder.itemSelected()
notifyItemChanged(position, ImageSelectedOrUpdated())
imageSelectListener.onSelectedImagesChanged(selectedImages, selectedImages.size)
}

// If switch is turned off, it just fetches the image from all images without any
// further operations
} else {
Glide
.with(holder.image)
.load(image.uri)
.thumbnail(0.3f)
.into(holder.image)
}
}

holder.itemView.setOnClickListener {
onThumbnailClicked(position, holder)
}

// launch media preview on long click.
holder.itemView.setOnLongClickListener {
imageSelectListener.onLongPress(images.indexOf(image), images, selectedImages)
imageSelectListener.onLongPress(position, images, ArrayList(selectedImages))
true
}
//handle close button click for deselection
holder.closeButton.setOnClickListener {
if (isSelected) {
selectedImages.removeAt(selectedIndex)
holder.itemUnselected()
notifyItemChanged(position, ImageUnselected())
imageSelectListener.onSelectedImagesChanged(selectedImages, selectedImages.size)
}
}
}
}

Expand Down Expand Up @@ -417,7 +400,7 @@ class ImageAdapter(
* Set new selected images
*/
fun setSelectedImages(newSelectedImages: ArrayList<Image>) {
selectedImages = ArrayList(newSelectedImages)
selectedImages = ArrayList(newSelectedImages.take(20)) // enforce 20-image limit
imageSelectListener.onSelectedImagesChanged(selectedImages, 0)
}

Expand All @@ -431,7 +414,7 @@ class ImageAdapter(
) {
numberOfSelectedImagesMarkedAsNotForUpload = 0
images.clear()
selectedImages = arrayListOf()
selectedImages = ArrayList(selectedImages.take(5)) // enforce the 5-image limit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using MAX_IMAGE_COUNT here?

init(newImages, fixedImages, TreeMap(), uploadingImages)
notifyDataSetChanged()
}
Expand Down Expand Up @@ -523,19 +506,22 @@ class ImageAdapter(
private val uploadingGroup: Group = itemView.findViewById(R.id.uploading_group)
private val notForUploadGroup: Group = itemView.findViewById(R.id.not_for_upload_group)
private val selectedGroup: Group = itemView.findViewById(R.id.selected_group)
val closeButton: ImageView = itemView.findViewById(R.id.close_button) // Added for close button

/**
* Item selected view.
*/
fun itemSelected() {
selectedGroup.visibility = View.VISIBLE
closeButton.visibility = View.VISIBLE // Show close button when selected
}

/**
* Item Unselected view.
*/
fun itemUnselected() {
selectedGroup.visibility = View.GONE
closeButton.visibility = View.GONE // Hide close button when unselected
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class CustomSelectorActivity :
/**
* Maximum number of images that can be selected.
*/
private var uploadLimit: Int = 20
private var uploadLimit: Int = 20 // changed to 20 asper the issue #3101

/**
* Flag that is marked true when the amount
Expand Down Expand Up @@ -650,8 +650,12 @@ class CustomSelectorActivity :
finishPickImages(arrayListOf())
return
}
if (selectedImages.size > uploadLimit) {
displayUploadLimitWarning() // shows the warning dialog if >20 images
return
}
scope.launch(ioDispatcher) {
val uniqueImages = selectedImages.distinctBy { image ->
val uniqueImages = selectedImages.take(uploadLimit).distinctBy { image -> //enforce limit
CustomSelectorUtils.getImageSHA1(
image.uri,
ioDispatcher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class ThumbnailsAdapter(private val callback: Callback) :
var onThumbnailDeletedListener: OnThumbnailDeletedListener? = null
var uploadableFiles: List<UploadableFile> = emptyList()
set(value) {
field = value
field = value.take(20) //enforce 20-image limit
notifyDataSetChanged()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,8 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
intent.getParcelableArrayListExtra<UploadableFile>(EXTRA_FILES)
}

// Convert to mutable list or return empty list if null
files?.toMutableList() ?: run {
// Convert to mutable list,takes up to 20 files, or return empty list if null
files?.toMutableList()?.take(20)?.toMutableList() ?: run { //enforce 20-image limit
Timber.w("Files array was null")
mutableListOf()
}
Expand All @@ -753,6 +753,9 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
Timber.d("File $index path: ${file.getFilePath()}")
}

//update thumbnails adapter with limited files
thumbnailsAdapter?.uploadableFiles = uploadableFiles

// Handle other extras with null safety
place = try {
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/res/layout/item_custom_selector_image.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
Expand Down Expand Up @@ -45,14 +44,24 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<ImageView
android:id="@+id/close_button"
android:layout_width="@dimen/dimen_20"
android:layout_height="@dimen/dimen_20"
app:layout_constraintDimensionRatio="H,1:1"
android:src="@drawable/ic_cancel_white"
android:layout_margin="@dimen/dimen_6"
android:background="@drawable/circle_shape"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"/>

<androidx.constraintlayout.widget.Group
android:id="@+id/selected_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="selected_overlay,selected_image"/>

app:constraint_referenced_ids="selected_overlay,selected_image,close_button"/>

<View
android:id="@+id/uploaded_overlay"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -887,4 +887,6 @@ Upload your first media by tapping on the add button.</string>
<string name="image_tag_line_created_and_uploaded_by">Created and uploaded by: %1$s</string>
<string name="image_tag_line_created_by_and_uploaded_by">Created by %1$s and uploaded by %2$s</string>
<string name="nominated_for_deletion_btn">Nominated for Deletion</string>

<string name="custom_selector_limit_warning_message">You can only select up to 20 images.</string>
</resources>