Upload: drop duplicate images and display warning in custom selector#6765
Upload: drop duplicate images and display warning in custom selector#6765Akul-Tyagi wants to merge 2 commits intocommons-app:mainfrom
Conversation
Updated CustomSelectorActivity to prevent silent dropping of duplicate images. Added a warning dialog with a 'Review selection' option to improve UX and maintain parity with the normal selector.
|
We should rather block duplicates from the normal selector as well. I don't think duplicate uploads are helpful. Just a warning that duplicate images would be dropped should suffice. |
|
✅ Generated APK variants! |
|
Updated this PR as discussed - custom selector now drops duplicates and shows a warning. Kept normal selector out of scope; tracking that separately in Issue #6771 . Ready for review! |
|
A quick one: when does the custom selector decide to drop the duplicates? Could you point me to that logic in the existing code base? |
|
The duplicate dropping happens inside the onDone() flow in CustomSelectorActivity.kt.
My change preserves the same SHA1-based deduplication logic but replaces the silent distinctBy with an explicit loop that tracks seen hashes, so we can also detect whether any duplicates were present. If they were, we show the warning dialog first before calling finishPickImages() with the deduplicated list. So the actual dedup key and mechanism is unchanged - only the user visibility of the drop is new. |
Fixes #6764
The Problem
In the custom selector flow, selecting duplicate content images (matching SHA1 hashes) silently reduced the number of images passed forward to the upload screen. This caused UX confusion because users would select N images but see fewer in the upload details. Additionally, if users realize they made a mistake, they needed an in place way to correct their selection without entirely leaving the selector flow.
The Solution & Justification
I updated the custom selector's completion flow to:
This approach is minimal and tightly scoped to the custom selector's done flow. It improves clarity, keeps the behavior explicit, and brings the custom selector's duplicate handling closer to parity with the normal selector.
Alternative Solutions Considered
I considered completely blocking the upload of duplicates directly from the selector. However, I discarded this because the normal selector currently permits duplicate selections, and blocking it here would create an inconsistent experience across the app. A non blocking warning dialog provides the safest, most informative UX.
Testing Performed
Compiled and ran the betaDebug variant successfully.
Passed targeted unit tests: :app:testBetaDebugUnitTest --tests "fr.free.nrw.commons.customselector.ui.selector.CustomSelectorActivityTest"
Passed broader adapter tests: :app:testBetaDebugUnitTest --tests "fr.free.nrw.commons.customselector.ui.selector." --tests "fr.free.nrw.commons.customselector.ui.adapter."
Manually verified that the duplicate warning is shown when identical images are selected.
Manually verified that tapping "Review selection" dismisses the dialog and retains the current selection state.
Manually verified that tapping "OK" proceeds to the upload details screen successfully.
Videos
Before :
Screen_Recording_20260318_082650_Commons.mp4
After :
Screen_Recording_20260321_163221_Commons.mp4