Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
26 changes: 25 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//new import for centralised constant
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,29 @@ 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

// startsm truncation logic (Issue #3101)
if (fileCount > MAX_EXTERNAL_UPLOAD_COUNT) {
//truncates the list to the maximum allowed limit (20)
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 +1062,4 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
}
}
}

4 changes: 4 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,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_title">Upload Limit Exceeded</string>
<string name="multiple_upload_limit_message">You have selected %1$d files. The current limit for simultaneous uploads is <b>%2$d</b> files. Please go back and select fewer files.</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>
</resources>