From d3776ae0e637ccf5ca440a8cb4ae5cf8182d0150 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 1 Jun 2021 10:07:37 +1000 Subject: [PATCH] Enable data extraction notifications --- .../securesms/MediaOverviewActivity.java | 8 +------- .../securesms/MediaPreviewActivity.java | 18 +++++++----------- .../conversation/ConversationFragment.java | 10 ++-------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/MediaOverviewActivity.java b/app/src/main/java/org/thoughtcrime/securesms/MediaOverviewActivity.java index 7b25c4f1bb..53a909c5ac 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/MediaOverviewActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/MediaOverviewActivity.java @@ -353,11 +353,9 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity { saveTask.executeOnExecutor(THREAD_POOL_EXECUTOR, attachments.toArray(new SaveAttachmentTask.Attachment[attachments.size()])); actionMode.finish(); - // Sending a Data extraction notification (for incoming attachments only) boolean containsIncoming = mediaRecords.parallelStream().anyMatch(m -> !m.isOutgoing()); if (containsIncoming) { - //TODO uncomment line below when Data extraction will be activated - //sendMediaSavedNotificationIfNeeded(); + sendMediaSavedNotificationIfNeeded(); } } }.execute(); @@ -366,11 +364,7 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity { }, mediaRecords.size()); } - /** - * Send a MediaSaved notification to the recipient - */ private void sendMediaSavedNotificationIfNeeded() { - // we don't send media saved notification for groups if (recipient.isGroupRecipient()) return; DataExtractionNotification message = new DataExtractionNotification(new DataExtractionNotification.Kind.MediaSaved(System.currentTimeMillis())); MessageSender.send(message, recipient.getAddress()); diff --git a/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java b/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java index 431d0b4e3f..3f8f03fa51 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java @@ -39,8 +39,7 @@ import android.view.Window; import android.widget.FrameLayout; import android.widget.TextView; import android.widget.Toast; -import org.session.libsession.messaging.messages.control.DataExtractionNotification; -import org.session.libsession.messaging.sending_receiving.MessageSender; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; @@ -53,11 +52,14 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; + +import org.session.libsession.messaging.messages.control.DataExtractionNotification; +import org.session.libsession.messaging.sending_receiving.MessageSender; import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment; import org.session.libsession.utilities.Address; +import org.session.libsession.utilities.Util; import org.session.libsession.utilities.recipients.Recipient; import org.session.libsession.utilities.recipients.RecipientModifiedListener; -import org.session.libsession.utilities.Util; import org.session.libsignal.utilities.Log; import org.thoughtcrime.securesms.components.MediaView; import org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord; @@ -352,21 +354,15 @@ 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 (for incoming attachments only) - if(!mediaItem.outgoing) { - //TODO uncomment line below when Data extraction will be activated - //sendMediaSavedNotificationIfNeeded(); + if (!mediaItem.outgoing) { + sendMediaSavedNotificationIfNeeded(); } }) .execute(); }); } - /** - * Send a MediaSaved notification to the recipient - */ private void sendMediaSavedNotificationIfNeeded() { - // we don't send media saved notification for groups if (conversationRecipient.isGroupRecipient()) return; DataExtractionNotification message = new DataExtractionNotification(new DataExtractionNotification.Kind.MediaSaved(System.currentTimeMillis())); MessageSender.send(message, conversationRecipient.getAddress()); diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java index 425160b45d..f8162aae0a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java @@ -741,10 +741,8 @@ 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 (for incoming attachments only) - if(!message.isOutgoing()) { - //TODO uncomment line below when Data extraction will be activated - //sendMediaSavedNotificationIfNeeded(); + if (!message.isOutgoing()) { + sendMediaSavedNotificationIfNeeded(); } return; } @@ -758,11 +756,7 @@ public class ConversationFragment extends Fragment }); } - /** - * Send a MediaSaved notification to the recipient - */ private void sendMediaSavedNotificationIfNeeded() { - // we don't send media saved notification for groups if (recipient.isGroupRecipient()) return; DataExtractionNotification message = new DataExtractionNotification(new DataExtractionNotification.Kind.MediaSaved(System.currentTimeMillis())); MessageSender.send(message, recipient.getAddress());