ask for permission when committing attachments. fixes #3248
This commit is contained in:
parent
185d36d270
commit
bb6ddae76b
|
@ -129,6 +129,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
public static final int REQUEST_TRUST_KEYS_ATTACHMENTS = 0x0209;
|
public static final int REQUEST_TRUST_KEYS_ATTACHMENTS = 0x0209;
|
||||||
public static final int REQUEST_START_DOWNLOAD = 0x0210;
|
public static final int REQUEST_START_DOWNLOAD = 0x0210;
|
||||||
public static final int REQUEST_ADD_EDITOR_CONTENT = 0x0211;
|
public static final int REQUEST_ADD_EDITOR_CONTENT = 0x0211;
|
||||||
|
public static final int REQUEST_COMMIT_ATTACHMENTS = 0x0212;
|
||||||
public static final int ATTACHMENT_CHOICE_CHOOSE_IMAGE = 0x0301;
|
public static final int ATTACHMENT_CHOICE_CHOOSE_IMAGE = 0x0301;
|
||||||
public static final int ATTACHMENT_CHOICE_TAKE_PHOTO = 0x0302;
|
public static final int ATTACHMENT_CHOICE_TAKE_PHOTO = 0x0302;
|
||||||
public static final int ATTACHMENT_CHOICE_CHOOSE_FILE = 0x0303;
|
public static final int ATTACHMENT_CHOICE_CHOOSE_FILE = 0x0303;
|
||||||
|
@ -861,6 +862,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commitAttachments() {
|
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)) {
|
if (conversation.getNextEncryption() == Message.ENCRYPTION_AXOLOTL && trustKeysIfNeeded(REQUEST_TRUST_KEYS_ATTACHMENTS)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1402,16 +1406,23 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||||
if (grantResults.length > 0) {
|
if (grantResults.length > 0) {
|
||||||
if (allGranted(grantResults)) {
|
if (allGranted(grantResults)) {
|
||||||
if (requestCode == REQUEST_START_DOWNLOAD) {
|
switch (requestCode) {
|
||||||
|
case REQUEST_START_DOWNLOAD:
|
||||||
if (this.mPendingDownloadableMessage != null) {
|
if (this.mPendingDownloadableMessage != null) {
|
||||||
startDownloadable(this.mPendingDownloadableMessage);
|
startDownloadable(this.mPendingDownloadableMessage);
|
||||||
}
|
}
|
||||||
} else if (requestCode == REQUEST_ADD_EDITOR_CONTENT) {
|
break;
|
||||||
|
case REQUEST_ADD_EDITOR_CONTENT:
|
||||||
if (this.mPendingEditorContent != null) {
|
if (this.mPendingEditorContent != null) {
|
||||||
attachEditorContentToConversation(this.mPendingEditorContent);
|
attachEditorContentToConversation(this.mPendingEditorContent);
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
|
case REQUEST_COMMIT_ATTACHMENTS:
|
||||||
|
commitAttachments();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
attachFile(requestCode);
|
attachFile(requestCode);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@StringRes int res;
|
@StringRes int res;
|
||||||
|
@ -1430,6 +1441,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
if (activity != null && activity.xmppConnectionService != null) {
|
if (activity != null && activity.xmppConnectionService != null) {
|
||||||
activity.xmppConnectionService.restartFileObserver();
|
activity.xmppConnectionService.restartFileObserver();
|
||||||
}
|
}
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue