media saved notification is sent only when incoming media are saved

This commit is contained in:
Brice-W 2021-04-12 12:02:41 +10:00
parent 40015c2898
commit 2bce2738b3
3 changed files with 13 additions and 6 deletions

View File

@ -353,8 +353,11 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity {
saveTask.executeOnExecutor(THREAD_POOL_EXECUTOR, saveTask.executeOnExecutor(THREAD_POOL_EXECUTOR,
attachments.toArray(new SaveAttachmentTask.Attachment[attachments.size()])); attachments.toArray(new SaveAttachmentTask.Attachment[attachments.size()]));
actionMode.finish(); actionMode.finish();
// Sending a Data extraction notification // Sending a Data extraction notification (for incoming attachments only)
sendMediaSavedNotificationIfNeeded(); boolean containsIncoming = mediaRecords.parallelStream().anyMatch(m -> !m.isOutgoing());
if (containsIncoming) {
sendMediaSavedNotificationIfNeeded();
}
} }
}.execute(); }.execute();
}) })

View File

@ -357,8 +357,10 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
saveTask.executeOnExecutor( saveTask.executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, AsyncTask.THREAD_POOL_EXECUTOR,
new Attachment(mediaItem.uri, mediaItem.type, saveDate, null)); new Attachment(mediaItem.uri, mediaItem.type, saveDate, null));
// Sending a Data extraction notification // Sending a Data extraction notification (for incoming attachments only)
sendMediaSavedNotificationIfNeeded(); if(!mediaItem.outgoing) {
sendMediaSavedNotificationIfNeeded();
}
}) })
.execute(); .execute();
}); });

View File

@ -746,8 +746,10 @@ public class ConversationFragment extends Fragment
if (!Util.isEmpty(attachments)) { if (!Util.isEmpty(attachments)) {
SaveAttachmentTask saveTask = new SaveAttachmentTask(getActivity()); SaveAttachmentTask saveTask = new SaveAttachmentTask(getActivity());
saveTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, attachments.toArray(new SaveAttachmentTask.Attachment[0])); saveTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, attachments.toArray(new SaveAttachmentTask.Attachment[0]));
// Sending a Data extraction notification // Sending a Data extraction notification (for incoming attachments only)
sendMediaSavedNotificationIfNeeded(); if(!message.isOutgoing()) {
sendMediaSavedNotificationIfNeeded();
}
return; return;
} }