diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-10-24 20:51:39 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-10-24 20:51:39 +0200 |
commit | a62b9226d312e95c6653e4487fc3b7bb3034ba94 (patch) | |
tree | 84d1c03468794acfc65fa51274a4d34a6652fc21 /src | |
parent | 7cc71094dae503863a3e75bc60da4418e81e193d (diff) |
ask for permission when committing attachments
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index f1df07e0b..7edc309c9 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -134,6 +134,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public static final int REQUEST_TRUST_KEYS_ATTACHMENTS = 0x0209; public static final int REQUEST_START_DOWNLOAD = 0x0210; public static final int REQUEST_ADD_EDITOR_CONTENT = 0x0211; + public static final int REQUEST_COMMIT_ATTACHMENTS = 0x0212; public static final int ATTACHMENT_CHOICE = 0x0300; public static final int ATTACHMENT_CHOICE_CHOOSE_IMAGE = 0x0301; public static final int ATTACHMENT_CHOICE_TAKE_PHOTO = 0x0302; @@ -1034,6 +1035,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } private void commitAttachments() { + if (!hasPermissions(REQUEST_COMMIT_ATTACHMENTS, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { + return; + } if (conversation.getNextEncryption() == Message.ENCRYPTION_AXOLOTL && trustKeysIfNeeded(REQUEST_TRUST_KEYS_ATTACHMENTS)) { return; } @@ -1647,16 +1651,23 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { if (grantResults.length > 0) { if (allGranted(grantResults)) { - if (requestCode == REQUEST_START_DOWNLOAD) { - if (this.mPendingDownloadableMessage != null) { - startDownloadable(this.mPendingDownloadableMessage); - } - } else if (requestCode == REQUEST_ADD_EDITOR_CONTENT) { - if (this.mPendingEditorContent != null) { - attachEditorContentToConversation(this.mPendingEditorContent); - } - } else { - attachFile(requestCode); + switch (requestCode) { + case REQUEST_START_DOWNLOAD: + if (this.mPendingDownloadableMessage != null) { + startDownloadable(this.mPendingDownloadableMessage); + } + break; + case REQUEST_ADD_EDITOR_CONTENT: + if (this.mPendingEditorContent != null) { + attachEditorContentToConversation(this.mPendingEditorContent); + } + break; + case REQUEST_COMMIT_ATTACHMENTS: + commitAttachments(); + break; + default: + attachFile(requestCode); + break; } } else { @StringRes int res; @@ -1678,6 +1689,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (activity != null && activity.xmppConnectionService != null) { activity.xmppConnectionService.restartFileObserver(); } + refresh(); } } |