diff --git a/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java b/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java index f19a1fc45e..b74638fec7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/MediaPreviewActivity.java @@ -47,7 +47,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; import androidx.core.util.Pair; import androidx.lifecycle.ViewModelProvider; import androidx.loader.app.LoaderManager; @@ -534,11 +533,15 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im viewModel.setCursor(this, data.first, leftIsRecent); - int item = restartItem >= 0 ? restartItem : data.second; - mediaPager.setCurrentItem(item); + if (restartItem >= 0 || data.second >= 0) { + int item = restartItem >= 0 ? restartItem : data.second; + mediaPager.setCurrentItem(item); - if (item == 0) { - viewPagerListener.onPageSelected(0); + if (item == 0) { + viewPagerListener.onPageSelected(0); + } + } else { + Log.w(TAG, "one of restartItem "+restartItem+" and data.second "+data.second+" would cause OOB exception"); } } } diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentDownloadJob.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentDownloadJob.kt index 451081fd1a..1697c088bb 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentDownloadJob.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentDownloadJob.kt @@ -100,9 +100,10 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long) handleFailure(Error.NoSender, null) return } - if (!threadRecipient.isGroupRecipient && (contact?.isTrusted == true || storage.getUserPublicKey() != sender)) { + if (!threadRecipient.isGroupRecipient || (contact?.isTrusted != true && storage.getUserPublicKey() != sender)) { // if we aren't receiving a group message, a message from ourselves (self-send) and the contact sending is not trusted: // do not continue, but do not fail + handleFailure(Error.NoSender, null) return }