Skip to content
15 changes: 12 additions & 3 deletions app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,20 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
}

private fun checkStoragePermissions() {
// The share intent provides files via content uris with temporary read permissions,
// so we do not need to obtain storage permissions
val action = intent.action
if (Intent.ACTION_SEND == action || Intent.ACTION_SEND_MULTIPLE == action) {
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The UI visibility for binding.cvContainerTopCard is not set when handling share intents. In the normal flow (line 330), binding.cvContainerTopCard.visibility is set to View.VISIBLE after permissions are granted and receiveSharedItems() is called. The share intent path should also set this visibility to ensure consistent UI behavior. Consider adding binding.cvContainerTopCard.visibility = View.VISIBLE before calling receiveSharedItems().

Suggested change
if (Intent.ACTION_SEND == action || Intent.ACTION_SEND_MULTIPLE == action) {
if (Intent.ACTION_SEND == action || Intent.ACTION_SEND_MULTIPLE == action) {
binding.cvContainerTopCard.visibility = View.VISIBLE

Copilot uses AI. Check for mistakes.
// Get the external items first
receiveExternalSharedItems()
receiveSharedItems()
return
}

// Check if all required permissions are granted
val hasAllPermissions = hasPermission(this, PERMISSIONS_STORAGE)
val hasPartialAccess = hasPartialAccess(this)

if (hasAllPermissions || hasPartialAccess) {
// All required permissions are granted, so enable UI elements and perform actions
receiveSharedItems()
Expand Down Expand Up @@ -472,9 +483,7 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
private fun receiveSharedItems() {
val intent = intent
val action = intent.action
if (Intent.ACTION_SEND == action || Intent.ACTION_SEND_MULTIPLE == action) {
receiveExternalSharedItems()
} else if (ContributionController.ACTION_INTERNAL_UPLOADS == action) {
if (ContributionController.ACTION_INTERNAL_UPLOADS == action) {
receiveInternalSharedItems()
}

Expand Down