Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/filepicker/Costants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package fr.free.nrw.commons.filepicker
interface Constants {
companion object {
const val DEFAULT_FOLDER_NAME = "CommonsContributions"
// this is used for truncation logic to cap the selection at 20 files.
const val MAX_EXTERNAL_UPLOAD_COUNT: Int = 20
}

/**
Expand Down
25 changes: 24 additions & 1 deletion app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import fr.free.nrw.commons.auth.LoginActivity
import fr.free.nrw.commons.auth.SessionManager
import fr.free.nrw.commons.contributions.ContributionController
import fr.free.nrw.commons.databinding.ActivityUploadBinding
import fr.free.nrw.commons.filepicker.Constants.Companion.MAX_EXTERNAL_UPLOAD_COUNT
import fr.free.nrw.commons.filepicker.Constants.RequestCodes
import fr.free.nrw.commons.filepicker.UploadableFile
import fr.free.nrw.commons.kvstore.BasicKvStore
Expand Down Expand Up @@ -723,7 +724,28 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
}

private fun receiveExternalSharedItems() {
uploadableFiles = contributionController!!.handleExternalImagesPicked(this, intent).toMutableList()
var filesToProcess = contributionController!!.handleExternalImagesPicked(this, intent).toMutableList()

if (intent.action == Intent.ACTION_SEND_MULTIPLE) {
val fileCount = filesToProcess.size

if (fileCount > MAX_EXTERNAL_UPLOAD_COUNT) {
//truncates the list to the maximum allowed limit (20) Issue #3101
filesToProcess = filesToProcess.subList(0, MAX_EXTERNAL_UPLOAD_COUNT)

// informs the the user that the list was truncated
showLongToast(
this,
getString(
R.string.multiple_upload_limit_truncated_message,
fileCount,
MAX_EXTERNAL_UPLOAD_COUNT
)
)
}
}

uploadableFiles = filesToProcess
}

private fun receiveInternalSharedItems() {
Expand Down Expand Up @@ -1039,3 +1061,4 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
}
}
}

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,6 +887,8 @@ 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="multiple_upload_limit_truncated_message">You selected %1$d files. Only the first %2$d files will be processed for upload.</string>
<string name="custom_selector_max_image_limit_reached">You can only select a maximum of %d images.</string>

</resources>