aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-10-24 20:51:39 +0200
committerChristian Schneppe <christian@pix-art.de>2018-10-24 20:51:39 +0200
commita62b9226d312e95c6653e4487fc3b7bb3034ba94 (patch)
tree84d1c03468794acfc65fa51274a4d34a6652fc21 /src/main/java/de
parent7cc71094dae503863a3e75bc60da4418e81e193d (diff)
ask for permission when committing attachments
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java32
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();
}
}