Skip to content

Commit

Permalink
Merge pull request #8908 from toshanmugaraj/FileAtachmentCrash
Browse files Browse the repository at this point in the history
Fix file attachment crash
  • Loading branch information
bmarty authored Jan 13, 2025
2 parents e42075a + 4762b80 commit d97f69b
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.activity.result.ActivityResultLauncher
import im.vector.lib.core.utils.compat.getParcelableArrayListExtraCompat
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import im.vector.lib.core.utils.compat.queryIntentActivitiesCompat
import timber.log.Timber

/**
* Abstract class to provide all types of Pickers.
Expand Down Expand Up @@ -106,6 +107,14 @@ abstract class Picker<T> {
}
}
}
return selectedUriList.onEach { context.grantUriPermission(context.applicationContext.packageName, it, Intent.FLAG_GRANT_READ_URI_PERMISSION) }
selectedUriList.forEach { uri ->
try {
context.grantUriPermission(context.applicationContext.packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
} catch (e: SecurityException) {
// Handle the exception, e.g., log it or notify the user
Timber.w("Picker", "Failed to grant URI permission for $uri: ${e.message}")
}
}
return selectedUriList
}
}

0 comments on commit d97f69b

Please sign in to comment.