mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Handle SecurityException for other upload methods
This commit is contained in:
parent
9e2ec95f99
commit
db2e7e79c4
1 changed files with 4 additions and 2 deletions
|
|
@ -297,8 +297,7 @@ object FilePicker : Constants {
|
||||||
*/
|
*/
|
||||||
private fun takePersistableUriPermissions(context: Context, result: ActivityResult) {
|
private fun takePersistableUriPermissions(context: Context, result: ActivityResult) {
|
||||||
result.data?.let { intentData ->
|
result.data?.let { intentData ->
|
||||||
val takeFlags: Int = (Intent.FLAG_GRANT_READ_URI_PERMISSION
|
val takeFlags: Int = (Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
|
||||||
// Persist the URI permission for all URIs in the clip data
|
// Persist the URI permission for all URIs in the clip data
|
||||||
// if multiple images are selected,
|
// if multiple images are selected,
|
||||||
// or for the single URI if only one image is selected
|
// or for the single URI if only one image is selected
|
||||||
|
|
@ -324,6 +323,7 @@ object FilePicker : Constants {
|
||||||
callbacks: Callbacks
|
callbacks: Callbacks
|
||||||
) {
|
) {
|
||||||
if (result.resultCode == Activity.RESULT_OK) {
|
if (result.resultCode == Activity.RESULT_OK) {
|
||||||
|
takePersistableUriPermissions(activity, result)
|
||||||
try {
|
try {
|
||||||
val files = getFilesFromCustomSelector(result.data, activity)
|
val files = getFilesFromCustomSelector(result.data, activity)
|
||||||
callbacks.onImagesPicked(files, ImageSource.CUSTOM_SELECTOR, restoreType(activity))
|
callbacks.onImagesPicked(files, ImageSource.CUSTOM_SELECTOR, restoreType(activity))
|
||||||
|
|
@ -368,6 +368,7 @@ object FilePicker : Constants {
|
||||||
callbacks: Callbacks
|
callbacks: Callbacks
|
||||||
) {
|
) {
|
||||||
if (result.resultCode == Activity.RESULT_OK && !isPhoto(result.data)) {
|
if (result.resultCode == Activity.RESULT_OK && !isPhoto(result.data)) {
|
||||||
|
takePersistableUriPermissions(activity, result)
|
||||||
try {
|
try {
|
||||||
val files = getFilesFromGalleryPictures(result.data, activity)
|
val files = getFilesFromGalleryPictures(result.data, activity)
|
||||||
callbacks.onImagesPicked(files, ImageSource.GALLERY, restoreType(activity))
|
callbacks.onImagesPicked(files, ImageSource.GALLERY, restoreType(activity))
|
||||||
|
|
@ -414,6 +415,7 @@ object FilePicker : Constants {
|
||||||
callbacks: Callbacks
|
callbacks: Callbacks
|
||||||
) {
|
) {
|
||||||
if (activityResult.resultCode == Activity.RESULT_OK) {
|
if (activityResult.resultCode == Activity.RESULT_OK) {
|
||||||
|
takePersistableUriPermissions(activity, activityResult)
|
||||||
try {
|
try {
|
||||||
val lastImageUri = PreferenceManager.getDefaultSharedPreferences(activity)
|
val lastImageUri = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
.getString(KEY_PHOTO_URI, null)
|
.getString(KEY_PHOTO_URI, null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue