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,
attachments.toArray(new SaveAttachmentTask.Attachment[attachments.size()]));
actionMode.finish();
// Sending a Data extraction notification
sendMediaSavedNotificationIfNeeded();
// Sending a Data extraction notification (for incoming attachments only)
boolean containsIncoming = mediaRecords.parallelStream().anyMatch(m -> !m.isOutgoing());
if (containsIncoming) {
sendMediaSavedNotificationIfNeeded();
}
}
}.execute();
})

View File

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

View File

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