-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix/upload limit #3101 #6500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Kota-Jagadeesh
wants to merge
15
commits into
commons-app:main
Choose a base branch
from
Kota-Jagadeesh:fix/upload-limit-#3101
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+57
−53
Open
Fix/upload limit #3101 #6500
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c3bb460
Enforce 5-image selection limit with warning dialog on click
Kota-Jagadeesh 6edcab6
Set selection limit to 5 images and add warning for exceeding limit
Kota-Jagadeesh d918b84
Enforced 5-image limit for selection and upload, added close button, …
Kota-Jagadeesh 82cb5db
Added 20-img limit
Kota-Jagadeesh 04bc600
Merge branch 'main' into fix/upload-limit-#3101
nicolas-raoul e17a668
Merge branch 'main' into fix/upload-limit-#3101
nicolas-raoul 38b1010
Fix:define the maximum number of images allowed for selection
Kota-Jagadeesh 24e6ac7
Fix:initialize the adapter's limit from the constant
Kota-Jagadeesh e09b61a
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh 6dde33b
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh 9218460
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh 004e04b
Merge branch 'main' into fix/upload-limit-#3101
Kota-Jagadeesh 66c21ca
Merge branch 'main' into fix/upload-limit-#3101
nicolas-raoul f5fa479
Remove duplicate import statement for MAX_IMAGE_COUNT
nicolas-raoul efabeb9
Remove duplicate import of MAX_IMAGE_COUNT
nicolas-raoul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,55 +202,38 @@ class ImageAdapter( | |
| defaultDispatcher, | ||
| uploadingContributionList, | ||
| ) | ||
| scope.launch { | ||
| val sharedPreferences: SharedPreferences = | ||
| 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 >= MAX_IMAGE_COUNT && !isSelected) { //enforce the 20-image limit | ||
| Toast.makeText(context, "Cannot select more than 20 images", Toast.LENGTH_SHORT).show() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -445,7 +428,7 @@ class ImageAdapter( | |
| * Set new selected images | ||
| */ | ||
| fun setSelectedImages(newSelectedImages: ArrayList<Image>) { | ||
| selectedImages = ArrayList(newSelectedImages) | ||
| selectedImages = ArrayList(newSelectedImages.take(MAX_IMAGE_COUNT)) // enforce 20-image limit | ||
| imageSelectListener.onSelectedImagesChanged(selectedImages, 0) | ||
| } | ||
|
|
||
|
|
@@ -459,7 +442,7 @@ class ImageAdapter( | |
| ) { | ||
| numberOfSelectedImagesMarkedAsNotForUpload = 0 | ||
| images.clear() | ||
| selectedImages = arrayListOf() | ||
| selectedImages = ArrayList(selectedImages.take(5)) // enforce the 5-image limit | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
| } | ||
|
|
@@ -551,19 +534,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 | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -664,4 +650,4 @@ class ImageAdapter( | |
| fun setSingleSelection(single: Boolean) { | ||
| singleSelection = single | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 picturesstill work as intended?