From 9df3836665a06562ebd8e66169569305dce0d0e2 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Thu, 2 Nov 2017 21:18:39 +0100 Subject: [PATCH] prevent a crash in ComposeActivity when ContentResolver raises a SecurityException --- .../java/com/keylesspalace/tusky/ComposeActivity.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 6f991fc7..bbf01542 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -37,7 +37,6 @@ import android.os.Bundle; import android.os.Environment; import android.os.Parcel; import android.os.Parcelable; -import android.preference.PreferenceManager; import android.provider.MediaStore; import android.support.annotation.AttrRes; import android.support.annotation.LayoutRes; @@ -968,9 +967,14 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption status.setUid(savedTootUid); tootDao.delete(status); for (QueuedMedia item : mediaQueued) { - if (getContentResolver().delete(item.uri, null, null) == 0) { - Log.e(TAG, String.format("Did not delete file %s.", item.uri.toString())); + try { + if (getContentResolver().delete(item.uri, null, null) == 0) { + Log.e(TAG, String.format("Did not delete file %s.", item.uri.toString())); + } + } catch (SecurityException e) { + Log.e(TAG, String.format("Did not delete file %s.", item.uri.toString()), e); } + } } Snackbar bar = Snackbar.make(findViewById(R.id.activity_compose),