diff --git a/app/src/main/java/org/thoughtcrime/securesms/BindableConversationItem.java b/app/src/main/java/org/thoughtcrime/securesms/BindableConversationItem.java index 5a1067b144..95cef276dd 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/BindableConversationItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/BindableConversationItem.java @@ -9,7 +9,6 @@ import org.thoughtcrime.securesms.database.model.MmsMessageRecord; import org.thoughtcrime.securesms.mms.GlideRequests; import org.session.libsignal.libsignal.util.guava.Optional; -import org.session.libsession.messaging.sending_receiving.attachments.StickerLocator; import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview; import org.session.libsession.messaging.threads.Address; import org.session.libsession.messaging.threads.recipients.Recipient; diff --git a/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java b/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java index 8278ae08da..193ebb2fe5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java @@ -47,7 +47,6 @@ import org.thoughtcrime.securesms.mediasend.Media; import org.thoughtcrime.securesms.mms.PartAuthority; import org.thoughtcrime.securesms.providers.BlobProvider; import org.session.libsession.messaging.threads.recipients.Recipient; -import org.session.libsession.messaging.sending_receiving.attachments.StickerLocator; import org.thoughtcrime.securesms.util.MediaUtil; import org.session.libsession.utilities.ViewUtil; @@ -229,11 +228,9 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity final Intent intent = new Intent(this, target); final String textExtra = getIntent().getStringExtra(Intent.EXTRA_TEXT); final ArrayList mediaExtra = getIntent().getParcelableArrayListExtra(ConversationActivity.MEDIA_EXTRA); - final StickerLocator stickerExtra = getIntent().getParcelableExtra(ConversationActivity.STICKER_EXTRA); intent.putExtra(ConversationActivity.TEXT_EXTRA, textExtra); intent.putExtra(ConversationActivity.MEDIA_EXTRA, mediaExtra); - intent.putExtra(ConversationActivity.STICKER_EXTRA, stickerExtra); if (resolvedExtra != null) intent.setDataAndType(resolvedExtra, mimeType); diff --git a/app/src/main/java/org/thoughtcrime/securesms/attachments/MmsNotificationAttachment.java b/app/src/main/java/org/thoughtcrime/securesms/attachments/MmsNotificationAttachment.java index aa7e797214..a68cf58db9 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/attachments/MmsNotificationAttachment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/attachments/MmsNotificationAttachment.java @@ -11,7 +11,7 @@ import org.session.libsession.messaging.sending_receiving.attachments.Attachment public class MmsNotificationAttachment extends Attachment { public MmsNotificationAttachment(int status, long size) { - super("application/mms", getTransferStateFromStatus(status), size, null, null, null, null, null, null, false, 0, 0, false, null, null, ""); + super("application/mms", getTransferStateFromStatus(status), size, null, null, null, null, null, null, false, 0, 0, false, null, ""); } @Nullable diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java b/app/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java index 16d377470a..1119efaf29 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java @@ -234,7 +234,6 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener List documentSlides = Stream.of(attachments.getSlides()).filter(Slide::hasDocument).limit(1).toList(); List imageSlides = Stream.of(attachments.getSlides()).filter(Slide::hasImage).limit(1).toList(); List videoSlides = Stream.of(attachments.getSlides()).filter(Slide::hasVideo).limit(1).toList(); - List stickerSlides = Stream.of(attachments.getSlides()).filter(Slide::hasSticker).limit(1).toList(); // Given that most types have images, we specifically check images last if (!audioSlides.isEmpty()) { @@ -243,15 +242,13 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener mediaDescriptionText.setVisibility(GONE); } else if (!videoSlides.isEmpty()) { mediaDescriptionText.setText(R.string.QuoteView_video); - } else if (!stickerSlides.isEmpty()) { - mediaDescriptionText.setText(R.string.QuoteView_sticker); } else if (!imageSlides.isEmpty()) { mediaDescriptionText.setText(R.string.QuoteView_photo); } } private void setQuoteAttachment(@NonNull GlideRequests glideRequests, @NonNull SlideDeck slideDeck) { - List imageVideoSlides = Stream.of(slideDeck.getSlides()).filter(s -> s.hasImage() || s.hasVideo() || s.hasSticker()).limit(1).toList(); + List imageVideoSlides = Stream.of(slideDeck.getSlides()).filter(s -> s.hasImage() || s.hasVideo()).limit(1).toList(); List documentSlides = Stream.of(attachments.getSlides()).filter(Slide::hasDocument).limit(1).toList(); attachmentVideoOverlayView.setVisibility(GONE); diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java index be7e4b5672..7c8cd6672f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -159,7 +159,6 @@ import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage; import org.thoughtcrime.securesms.mms.QuoteId; import org.thoughtcrime.securesms.mms.Slide; import org.thoughtcrime.securesms.mms.SlideDeck; -import org.thoughtcrime.securesms.mms.StickerSlide; import org.thoughtcrime.securesms.mms.TextSlide; import org.thoughtcrime.securesms.mms.VideoSlide; import org.thoughtcrime.securesms.notifications.MarkReadReceiver; @@ -170,7 +169,6 @@ import org.session.libsession.messaging.threads.recipients.Recipient; import org.session.libsession.messaging.threads.recipients.RecipientFormattingException; import org.session.libsession.messaging.threads.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.search.model.MessageResult; -import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage; import org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage; @@ -185,7 +183,6 @@ import org.session.libsession.utilities.Util; import org.session.libsession.messaging.sending_receiving.sharecontacts.Contact; import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview; import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel; -import org.session.libsession.messaging.sending_receiving.attachments.StickerLocator; import org.session.libsession.messaging.threads.GroupRecord; import org.session.libsession.utilities.ExpirationUtil; import org.session.libsession.utilities.views.Stub; @@ -1157,12 +1154,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity final Uri draftMedia = getIntent().getData(); final MediaType draftMediaType = MediaType.from(getIntent().getType()); final List mediaList = getIntent().getParcelableArrayListExtra(MEDIA_EXTRA); - final StickerLocator stickerLocator = getIntent().getParcelableExtra(STICKER_EXTRA); - - if (stickerLocator != null && draftMedia != null) { - sendSticker(stickerLocator, draftMedia, 0, true); - return new SettableFuture<>(false); - } if (!Util.isEmpty(mediaList)) { Intent sendIntent = MediaSendActivity.buildEditorIntent(this, mediaList, recipient, draftText); @@ -2085,19 +2076,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity linkPreviewViewModel.onTextChanged(this, composeText.getTextTrimmed(), start, end); } - private void sendSticker(@NonNull StickerLocator stickerLocator, @NonNull Uri uri, long size, boolean clearCompose) { - long expiresIn = recipient.getExpireMessages() * 1000L; - int subscriptionId = -1; - boolean initiating = threadId == -1; - SlideDeck slideDeck = new SlideDeck(); - Slide stickerSlide = new StickerSlide(this, uri, size, stickerLocator); - - slideDeck.addSlide(stickerSlide); - - sendMediaMessage(false, "", slideDeck, null, Collections.emptyList(), Collections.emptyList(), expiresIn, subscriptionId, initiating, clearCompose); - - } - private void silentlySetComposeText(String text) { typingTextWatcher.setEnabled(false); composeText.setText(text); diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java index 597b0a7686..ba7f4bcac3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java @@ -339,10 +339,6 @@ public class ConversationAdapter if (slideDeck.getThumbnailSlide() != null && slideDeck.getThumbnailSlide().getFastPreflightId() != null) { return Long.valueOf(slideDeck.getThumbnailSlide().getFastPreflightId()); } - - if (slideDeck.getStickerSlide() != null && slideDeck.getStickerSlide().getFastPreflightId() != null) { - return Long.valueOf(slideDeck.getStickerSlide().getFastPreflightId()); - } } return record.getId(); 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 85103e38cd..fe559e7443 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java @@ -94,7 +94,6 @@ import org.session.libsignal.service.loki.api.opengroups.PublicChat; import org.session.libsignal.service.loki.api.opengroups.PublicChatAPI; import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview; -import org.session.libsession.messaging.sending_receiving.attachments.StickerLocator; import org.session.libsession.utilities.TextSecurePreferences; import org.session.libsession.utilities.Util; import org.session.libsession.utilities.ViewUtil; @@ -384,8 +383,7 @@ public class ConversationFragment extends Fragment menu.findItem(R.id.menu_context_save_attachment).setVisible(!actionMessage && messageRecord.isMms() && !messageRecord.isMmsNotification() && - ((MediaMmsMessageRecord)messageRecord).containsMediaSlide() && - ((MediaMmsMessageRecord)messageRecord).getSlideDeck().getStickerSlide() == null); + ((MediaMmsMessageRecord)messageRecord).containsMediaSlide()); menu.findItem(R.id.menu_context_reply).setVisible(!actionMessage && !messageRecord.isPending() && @@ -653,8 +651,7 @@ public class ConversationFragment extends Fragment boolean isAlbum = mediaMessage.containsMediaSlide() && mediaMessage.getSlideDeck().getSlides().size() > 1 && mediaMessage.getSlideDeck().getAudioSlide() == null && - mediaMessage.getSlideDeck().getDocumentSlide() == null && - mediaMessage.getSlideDeck().getStickerSlide() == null; + mediaMessage.getSlideDeck().getDocumentSlide() == null; if (isAlbum) { ArrayList mediaList = new ArrayList<>(mediaMessage.getSlideDeck().getSlides().size()); @@ -685,10 +682,6 @@ public class ConversationFragment extends Fragment Slide slide = mediaMessage.getSlideDeck().getSlides().get(0); composeIntent.putExtra(Intent.EXTRA_STREAM, slide.getUri()); composeIntent.setType(slide.getContentType()); - - if (slide.hasSticker()) { - composeIntent.putExtra(ConversationActivity.STICKER_EXTRA, slide.asAttachment().getSticker()); - } } if (mediaMessage.getSlideDeck().getTextSlide() != null && mediaMessage.getSlideDeck().getTextSlide().getUri() != null) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java index 10295aa2d0..964e7834d6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java @@ -398,15 +398,10 @@ public class ConversationItem extends LinearLayout return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide() != null; } - private boolean hasSticker(MessageRecord messageRecord) { - return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getStickerSlide() != null; - } - private boolean hasOnlyThumbnail(MessageRecord messageRecord) { return hasThumbnail(messageRecord) && !hasAudio(messageRecord) && - !hasDocument(messageRecord) && - !hasSticker(messageRecord); + !hasDocument(messageRecord); } private boolean hasOnlyDocument(MessageRecord messageRecord) { @@ -414,7 +409,6 @@ public class ConversationItem extends LinearLayout !hasThumbnail(messageRecord) && !hasAudio(messageRecord) && hasDocument(messageRecord) && - !hasSticker(messageRecord) && !hasQuote(messageRecord); } @@ -423,7 +417,6 @@ public class ConversationItem extends LinearLayout !hasThumbnail(messageRecord) && !hasAudio(messageRecord) && !hasDocument(messageRecord) && - !hasSticker(messageRecord) && !hasQuote(messageRecord); } @@ -596,26 +589,6 @@ public class ConversationItem extends LinearLayout ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewUtil.updateLayoutParams(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - footer.setVisibility(VISIBLE); - } else if (hasSticker(messageRecord) && isCaptionlessMms(messageRecord)) { - bodyBubble.setBackgroundColor(Color.TRANSPARENT); - - stickerStub.get().setVisibility(View.VISIBLE); - if (mediaThumbnailStub.resolved()) mediaThumbnailStub.get().setVisibility(View.GONE); - if (audioViewStub.resolved()) audioViewStub.get().setVisibility(View.GONE); - if (documentViewStub.resolved()) documentViewStub.get().setVisibility(View.GONE); - if (linkPreviewStub.resolved()) linkPreviewStub.get().setVisibility(GONE); - - //noinspection ConstantConditions - stickerStub.get().setSticker(glideRequests, ((MmsMessageRecord) messageRecord).getSlideDeck().getStickerSlide()); - stickerStub.get().setThumbnailClickListener(new StickerClickListener()); - stickerStub.get().setDownloadClickListener(downloadClickListener); - stickerStub.get().setOnLongClickListener(passthroughClickListener); - stickerStub.get().setOnClickListener(passthroughClickListener); - - ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - ViewUtil.updateLayoutParams(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - footer.setVisibility(VISIBLE); } else if (hasThumbnail(messageRecord)) { mediaThumbnailStub.get().setVisibility(View.VISIBLE); @@ -870,9 +843,7 @@ public class ConversationItem extends LinearLayout } private ConversationItemFooter getActiveFooter(@NonNull MessageRecord messageRecord) { - if (hasSticker(messageRecord)) { - return stickerFooter; - } else if (hasOnlyThumbnail(messageRecord) && TextUtils.isEmpty(messageRecord.getDisplayBody(getContext()))) { + if (hasOnlyThumbnail(messageRecord) && TextUtils.isEmpty(messageRecord.getDisplayBody(getContext()))) { return mediaThumbnailStub.get().getFooter(); } else { return footer; @@ -916,13 +887,8 @@ public class ConversationItem extends LinearLayout } private void setGroupAuthorColor(@NonNull MessageRecord messageRecord) { - if (hasSticker(messageRecord)) { - groupSender.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_sticker_author_color)); - groupSenderProfileName.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_sticker_author_color)); - } else { - groupSender.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_item_received_text_primary_color)); - groupSenderProfileName.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_item_received_text_primary_color)); - } + groupSender.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_item_received_text_primary_color)); + groupSenderProfileName.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_item_received_text_primary_color)); } private void setAuthor(@NonNull MessageRecord current, @NonNull Optional previous, @NonNull Optional next, boolean isGroupThread) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/AttachmentDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/AttachmentDatabase.java index 11a4a40466..7b67856c19 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/AttachmentDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/AttachmentDatabase.java @@ -51,7 +51,6 @@ import org.session.libsession.messaging.sending_receiving.attachments.Attachment import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId; import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment; import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachmentAudioExtras; -import org.session.libsession.messaging.sending_receiving.attachments.StickerLocator; import org.session.libsignal.utilities.JsonUtil; import org.session.libsession.utilities.Util; @@ -504,7 +503,6 @@ public class AttachmentDatabase extends Database { mediaStream.getHeight(), databaseAttachment.isQuote(), databaseAttachment.getCaption(), - databaseAttachment.getSticker(), databaseAttachment.getUrl()); } @@ -689,11 +687,7 @@ public class AttachmentDatabase extends Database { object.getInt(HEIGHT), object.getInt(QUOTE) == 1, object.getString(CAPTION), - object.getInt(STICKER_ID) >= 0 - ? new StickerLocator(object.getString(STICKER_PACK_ID), - object.getString(STICKER_PACK_KEY), - object.getInt(STICKER_ID)) - : null, "")); // TODO: Not sure if this will break something + "")); // TODO: Not sure if this will break something } } @@ -719,11 +713,6 @@ public class AttachmentDatabase extends Database { cursor.getInt(cursor.getColumnIndexOrThrow(HEIGHT)), cursor.getInt(cursor.getColumnIndexOrThrow(QUOTE)) == 1, cursor.getString(cursor.getColumnIndexOrThrow(CAPTION)), - cursor.getInt(cursor.getColumnIndexOrThrow(STICKER_ID)) >= 0 - ? new StickerLocator(cursor.getString(cursor.getColumnIndexOrThrow(STICKER_PACK_ID)), - cursor.getString(cursor.getColumnIndexOrThrow(STICKER_PACK_KEY)), - cursor.getInt(cursor.getColumnIndexOrThrow(STICKER_ID))) - : null, urlIndex > 0 ? cursor.getString(urlIndex) : "")); } } catch (JSONException e) { @@ -765,19 +754,12 @@ public class AttachmentDatabase extends Database { contentValues.put(CAPTION, attachment.getCaption()); contentValues.put(URL, attachment.getUrl()); - if (attachment.isSticker()) { - contentValues.put(STICKER_PACK_ID, attachment.getSticker().getPackId()); - contentValues.put(STICKER_PACK_KEY, attachment.getSticker().getPackKey()); - contentValues.put(STICKER_ID, attachment.getSticker().getStickerId()); - } - if (dataInfo != null) { contentValues.put(DATA, dataInfo.file.getAbsolutePath()); contentValues.put(SIZE, dataInfo.length); contentValues.put(DATA_RANDOM, dataInfo.random); } - boolean notifyPacks = attachment.isSticker() && !hasStickerAttachments(); long rowId = database.insert(TABLE_NAME, null, contentValues); AttachmentId attachmentId = new AttachmentId(rowId, uniqueId); Uri thumbnailUri = attachment.getThumbnailUri(); @@ -817,10 +799,6 @@ public class AttachmentDatabase extends Database { } } - if (notifyPacks) { - notifyStickerPackListeners(); - } - return attachmentId; } diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupManager.java b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupManager.java index 11e36ffec3..f33ffa29e9 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupManager.java +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupManager.java @@ -153,7 +153,7 @@ public class GroupManager { if (avatar != null) { Uri avatarUri = BlobProvider.getInstance().forData(avatar).createForSingleUseInMemory(); - avatarAttachment = new UriAttachment(avatarUri, MediaTypes.IMAGE_PNG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length, null, false, false, null, null); + avatarAttachment = new UriAttachment(avatarUri, MediaTypes.IMAGE_PNG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length, null, false, false, null); } OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(groupRecipient, groupContext, avatarAttachment, 0, null, Collections.emptyList(), Collections.emptyList()); diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java index e84182d16a..76dc26572b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java @@ -94,8 +94,8 @@ public class AttachmentUploadJob extends BaseJob implements InjectableType { MediaConstraints mediaConstraints = MediaConstraints.getPushMediaConstraints(); Attachment scaledAttachment = scaleAndStripExif(database, mediaConstraints, databaseAttachment); SignalServiceAttachment localAttachment = getAttachmentFor(scaledAttachment); - SignalServiceAttachmentPointer remoteAttachment = messageSender.uploadAttachment(localAttachment.asStream(), databaseAttachment.isSticker(), new SignalServiceAddress(destination.serialize())); - attachment = PointerAttachment.forPointer(Optional.of(remoteAttachment), null, databaseAttachment.getFastPreflightId()).get(); + SignalServiceAttachmentPointer remoteAttachment = messageSender.uploadAttachment(localAttachment.asStream(), false, new SignalServiceAddress(destination.serialize())); + attachment = PointerAttachment.forPointer(Optional.of(remoteAttachment), databaseAttachment.getFastPreflightId()).get(); } catch (Exception e) { // On any error make sure we mark the related DB record's transfer state as failed. database.updateAttachmentAfterUploadFailed(databaseAttachment.getAttachmentId()); diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 2d9866c257..2e966993a3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -375,10 +375,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { if (insertResult.isPresent()) { List allAttachments = DatabaseFactory.getAttachmentDatabase(context).getAttachmentsForMessage(insertResult.get().getMessageId()); - List stickerAttachments = Stream.of(allAttachments).filter(Attachment::isSticker).toList(); - List dbAttachments = Stream.of(allAttachments).filterNot(Attachment::isSticker).toList(); - - forceStickerDownloadIfNecessary(stickerAttachments); + List dbAttachments = Stream.of(allAttachments).toList(); for (DatabaseAttachment attachment : dbAttachments) { ApplicationContext.getInstance(context).getJobManager().add(new AttachmentDownloadJob(insertResult.get().getMessageId(), attachment.getAttachmentId(), false)); @@ -419,10 +416,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { if (insertResult.isPresent()) { List allAttachments = DatabaseFactory.getAttachmentDatabase(context).getAttachmentsForMessage(insertResult.get().getMessageId()); - List stickerAttachments = Stream.of(allAttachments).filter(Attachment::isSticker).toList(); - List attachments = Stream.of(allAttachments).filterNot(Attachment::isSticker).toList(); - - forceStickerDownloadIfNecessary(stickerAttachments); + List attachments = Stream.of(allAttachments).toList(); for (DatabaseAttachment attachment : attachments) { ApplicationContext.getInstance(context).getJobManager().add(new AttachmentDownloadJob(insertResult.get().getMessageId(), attachment.getAttachmentId(), false)); @@ -866,25 +860,6 @@ public class PushDecryptJob extends BaseJob implements InjectableType { } } - private void forceStickerDownloadIfNecessary(List stickerAttachments) { - if (stickerAttachments.isEmpty()) return; - - DatabaseAttachment stickerAttachment = stickerAttachments.get(0); - - if (stickerAttachment.getTransferState() != AttachmentDatabase.TRANSFER_PROGRESS_DONE) { - AttachmentDownloadJob downloadJob = new AttachmentDownloadJob(messageId, stickerAttachment.getAttachmentId(), true); - - try { - ApplicationContext.getInstance(context).injectDependencies(downloadJob); - downloadJob.setContext(context); - downloadJob.doWork(); - } catch (Exception e) { - Log.w(TAG, "Failed to download sticker inline. Scheduling."); - ApplicationContext.getInstance(context).getJobManager().add(downloadJob); - } - } - } - @SuppressWarnings("WeakerAccess") private static class StorageFailedException extends Exception { private final String sender; diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index c08069b7c9..848ff045eb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -238,7 +238,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { if (message.isGroup() && address.isClosedGroup()) { SignalServiceGroup.GroupType groupType = address.isOpenGroup() ? SignalServiceGroup.GroupType.PUBLIC_CHAT : SignalServiceGroup.GroupType.SIGNAL; String groupId = address.toGroupString(); - List attachments = Stream.of(message.getAttachments()).filterNot(Attachment::isSticker).toList(); + List attachments = Stream.of(message.getAttachments()).toList(); List attachmentPointers = getAttachmentPointersFor(attachments); // Loki - Only send GroupUpdate or GroupQuit messages to closed groups OutgoingGroupMediaMessage groupMessage = (OutgoingGroupMediaMessage) message; @@ -269,7 +269,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { Optional quote = getQuoteFor(message); List sharedContacts = getSharedContactsFor(message); List previews = getPreviewsFor(message); - List attachments = Stream.of(message.getAttachments()).filterNot(Attachment::isSticker).toList(); + List attachments = Stream.of(message.getAttachments()).toList(); List attachmentPointers = getAttachmentPointersFor(attachments); SignalServiceGroup group = new SignalServiceGroup(GroupUtil.getDecodedGroupIDAsData(groupId), groupType); diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java index 5ca9c78d4c..9fcc30cdb7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java @@ -225,7 +225,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType { String userPublicKey = TextSecurePreferences.getLocalNumber(context); SignalServiceAddress address = getPushAddress(recipient.getAddress()); SignalServiceAddress localAddress = new SignalServiceAddress(userPublicKey); - List attachments = Stream.of(message.getAttachments()).filterNot(Attachment::isSticker).toList(); + List attachments = Stream.of(message.getAttachments()).toList(); List serviceAttachments = getAttachmentPointersFor(attachments); Optional profileKey = getProfileKey(message.getRecipient()); Optional quote = getQuoteFor(message); diff --git a/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java b/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java index 9a8066e3c0..583a7d5465 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java +++ b/app/src/main/java/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java @@ -200,7 +200,6 @@ public class LinkPreviewRepository implements InjectableType { null, false, false, - null, null)); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/ApnUnavailableException.java b/app/src/main/java/org/thoughtcrime/securesms/mms/ApnUnavailableException.java deleted file mode 100644 index 7aea170fb8..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/ApnUnavailableException.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.thoughtcrime.securesms.mms; - -public class ApnUnavailableException extends Exception { - - public ApnUnavailableException() { - } - - public ApnUnavailableException(String detailMessage) { - super(detailMessage); - } - - public ApnUnavailableException(Throwable throwable) { - super(throwable); - } - - public ApnUnavailableException(String detailMessage, Throwable throwable) { - super(detailMessage, throwable); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/AudioSlide.java b/app/src/main/java/org/thoughtcrime/securesms/mms/AudioSlide.java index 1041b5c72e..877a68f76d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/AudioSlide.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mms/AudioSlide.java @@ -34,11 +34,11 @@ import org.thoughtcrime.securesms.util.ResUtil; public class AudioSlide extends Slide { public AudioSlide(Context context, Uri uri, long dataSize, boolean voiceNote) { - super(context, constructAttachmentFromUri(context, uri, MediaTypes.AUDIO_UNSPECIFIED, dataSize, 0, 0, false, null, null, null, voiceNote, false)); + super(context, constructAttachmentFromUri(context, uri, MediaTypes.AUDIO_UNSPECIFIED, dataSize, 0, 0, false, null, null, voiceNote, false)); } public AudioSlide(Context context, Uri uri, long dataSize, String contentType, boolean voiceNote) { - super(context, new UriAttachment(uri, null, contentType, AttachmentDatabase.TRANSFER_PROGRESS_STARTED, dataSize, 0, 0, null, null, voiceNote, false, null, null)); + super(context, new UriAttachment(uri, null, contentType, AttachmentDatabase.TRANSFER_PROGRESS_STARTED, dataSize, 0, 0, null, null, voiceNote, false, null)); } public AudioSlide(Context context, Attachment attachment) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/DocumentSlide.java b/app/src/main/java/org/thoughtcrime/securesms/mms/DocumentSlide.java index 414c5f8be0..4021fc8eda 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/DocumentSlide.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mms/DocumentSlide.java @@ -19,7 +19,7 @@ public class DocumentSlide extends Slide { @NonNull String contentType, long size, @Nullable String fileName) { - super(context, constructAttachmentFromUri(context, uri, contentType, size, 0, 0, true, ExternalStorageUtil.getCleanFileName(fileName), null, null, false, false)); + super(context, constructAttachmentFromUri(context, uri, contentType, size, 0, 0, true, ExternalStorageUtil.getCleanFileName(fileName), null, false, false)); } @Override diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/GifSlide.java b/app/src/main/java/org/thoughtcrime/securesms/mms/GifSlide.java index 7cfe7ddf69..5ec7a36353 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/GifSlide.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mms/GifSlide.java @@ -19,7 +19,7 @@ public class GifSlide extends ImageSlide { } public GifSlide(Context context, Uri uri, long size, int width, int height, @Nullable String caption) { - super(context, constructAttachmentFromUri(context, uri, MediaTypes.IMAGE_GIF, size, width, height, true, null, caption, null, false, false)); + super(context, constructAttachmentFromUri(context, uri, MediaTypes.IMAGE_GIF, size, width, height, true, null, caption, false, false)); } @Override diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/ImageSlide.java b/app/src/main/java/org/thoughtcrime/securesms/mms/ImageSlide.java index e60708845b..87d66743c0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/ImageSlide.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mms/ImageSlide.java @@ -41,7 +41,7 @@ public class ImageSlide extends Slide { } public ImageSlide(Context context, Uri uri, long size, int width, int height, @Nullable String caption) { - super(context, constructAttachmentFromUri(context, uri, MediaTypes.IMAGE_JPEG, size, width, height, true, null, caption, null, false, false)); + super(context, constructAttachmentFromUri(context, uri, MediaTypes.IMAGE_JPEG, size, width, height, true, null, caption, false, false)); } @Override diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/IncomingMediaMessage.java b/app/src/main/java/org/thoughtcrime/securesms/mms/IncomingMediaMessage.java index d6c1f73a92..7c1451056f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/IncomingMediaMessage.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mms/IncomingMediaMessage.java @@ -7,12 +7,10 @@ import org.session.libsession.messaging.sending_receiving.sharecontacts.Contact; import org.session.libsession.messaging.threads.Address; import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview; import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel; -import org.session.libsession.messaging.threads.recipients.Recipient; import org.session.libsession.utilities.GroupUtil; import org.session.libsignal.libsignal.util.guava.Optional; import org.session.libsignal.service.api.messages.SignalServiceAttachment; import org.session.libsignal.service.api.messages.SignalServiceGroup; -import org.thoughtcrime.securesms.ApplicationContext; import java.util.Collections; import java.util.LinkedList; diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/MediaConstraints.java b/app/src/main/java/org/thoughtcrime/securesms/mms/MediaConstraints.java index 7fb5d1163a..fe823042ed 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/MediaConstraints.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mms/MediaConstraints.java @@ -26,10 +26,6 @@ public abstract class MediaConstraints { return new PushMediaConstraints(); } - public static MediaConstraints getMmsMediaConstraints(int subscriptionId) { - return new MmsMediaConstraints(subscriptionId); - } - public abstract int getImageMaxWidth(Context context); public abstract int getImageMaxHeight(Context context); public abstract int getImageMaxSize(Context context); diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsConfigManager.java b/app/src/main/java/org/thoughtcrime/securesms/mms/MmsConfigManager.java deleted file mode 100644 index 6ca484ce85..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsConfigManager.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.thoughtcrime.securesms.mms; - - -import android.content.Context; -import android.content.res.Configuration; -import androidx.annotation.NonNull; -import androidx.annotation.WorkerThread; - -import com.android.mms.service_alt.MmsConfig; - -import org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat; -import org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat; -import org.session.libsignal.libsignal.util.guava.Optional; - -import java.util.HashMap; -import java.util.Map; - -final class MmsConfigManager { - - private static final Map mmsConfigMap = new HashMap<>(); - - @WorkerThread - synchronized static @NonNull MmsConfig getMmsConfig(Context context, int subscriptionId) { - MmsConfig mmsConfig = mmsConfigMap.get(subscriptionId); - if (mmsConfig != null) { - return mmsConfig; - } - - MmsConfig loadedConfig = loadMmsConfig(context, subscriptionId); - - mmsConfigMap.put(subscriptionId, loadedConfig); - - return loadedConfig; - } - - private static @NonNull MmsConfig loadMmsConfig(Context context, int subscriptionId) { - Optional subscriptionInfo = new SubscriptionManagerCompat(context).getActiveSubscriptionInfo(subscriptionId); - - if (subscriptionInfo.isPresent()) { - SubscriptionInfoCompat subscriptionInfoCompat = subscriptionInfo.get(); - Configuration configuration = context.getResources().getConfiguration(); - configuration.mcc = subscriptionInfoCompat.getMcc(); - configuration.mnc = subscriptionInfoCompat.getMnc(); - - Context subContext = context.createConfigurationContext(configuration); - return new MmsConfig(subContext, subscriptionId); - } - - return new MmsConfig(context, subscriptionId); - } - -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsMediaConstraints.java b/app/src/main/java/org/thoughtcrime/securesms/mms/MmsMediaConstraints.java deleted file mode 100644 index d7b6c9666c..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsMediaConstraints.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.thoughtcrime.securesms.mms; - -import android.content.Context; - -import com.android.mms.service_alt.MmsConfig; - -final class MmsMediaConstraints extends MediaConstraints { - - private final int subscriptionId; - - private static final int MIN_IMAGE_DIMEN = 1024; - - MmsMediaConstraints(int subscriptionId) { - this.subscriptionId = subscriptionId; - } - - @Override - public int getImageMaxWidth(Context context) { - return Math.max(MIN_IMAGE_DIMEN, getOverriddenMmsConfig(context).getMaxImageWidth()); - } - - @Override - public int getImageMaxHeight(Context context) { - return Math.max(MIN_IMAGE_DIMEN, getOverriddenMmsConfig(context).getMaxImageHeight()); - } - - @Override - public int getImageMaxSize(Context context) { - return getMaxMessageSize(context); - } - - @Override - public int getGifMaxSize(Context context) { - return getMaxMessageSize(context); - } - - @Override - public int getVideoMaxSize(Context context) { - return getMaxMessageSize(context); - } - - @Override - public int getAudioMaxSize(Context context) { - return getMaxMessageSize(context); - } - - @Override - public int getDocumentMaxSize(Context context) { - return getMaxMessageSize(context); - } - - private int getMaxMessageSize(Context context) { - return getOverriddenMmsConfig(context).getMaxMessageSize(); - } - - private MmsConfig.Overridden getOverriddenMmsConfig(Context context) { - MmsConfig mmsConfig = MmsConfigManager.getMmsConfig(context, subscriptionId); - - return new MmsConfig.Overridden(mmsConfig, null); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsRadio.java b/app/src/main/java/org/thoughtcrime/securesms/mms/MmsRadio.java deleted file mode 100644 index 4e7eb3ad16..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsRadio.java +++ /dev/null @@ -1,165 +0,0 @@ -package org.thoughtcrime.securesms.mms; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; -import android.os.PowerManager; -import org.session.libsignal.utilities.logging.Log; - -import org.session.libsession.utilities.Util; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public class MmsRadio { - - private static final String TAG = MmsRadio.class.getSimpleName(); - - private static MmsRadio instance; - - public static synchronized MmsRadio getInstance(Context context) { - if (instance == null) - instance = new MmsRadio(context.getApplicationContext()); - - return instance; - } - - /// - - private static final String FEATURE_ENABLE_MMS = "enableMMS"; - private static final int APN_ALREADY_ACTIVE = 0; - public static final int TYPE_MOBILE_MMS = 2; - - private final Context context; - - private ConnectivityManager connectivityManager; - private ConnectivityListener connectivityListener; - private PowerManager.WakeLock wakeLock; - private int connectedCounter = 0; - - private MmsRadio(Context context) { - PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); - this.context = context; - this.connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - this.wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "signal:mms"); - this.wakeLock.setReferenceCounted(true); - } - - public synchronized void disconnect() { - Log.i(TAG, "MMS Radio Disconnect Called..."); - wakeLock.release(); - connectedCounter--; - - Log.i(TAG, "Reference count: " + connectedCounter); - - if (connectedCounter == 0) { - Log.i(TAG, "Turning off MMS radio..."); - try { - final Method stopUsingNetworkFeatureMethod = connectivityManager.getClass().getMethod("stopUsingNetworkFeature", Integer.TYPE, String.class); - stopUsingNetworkFeatureMethod.invoke(connectivityManager, ConnectivityManager.TYPE_MOBILE, FEATURE_ENABLE_MMS); - } catch (NoSuchMethodException nsme) { - Log.w(TAG, nsme); - } catch (IllegalAccessException iae) { - Log.w(TAG, iae); - } catch (InvocationTargetException ite) { - Log.w(TAG, ite); - } - - if (connectivityListener != null) { - Log.i(TAG, "Unregistering receiver..."); - context.unregisterReceiver(connectivityListener); - connectivityListener = null; - } - } - } - - public synchronized void connect() throws MmsRadioException { - int status; - - try { - final Method startUsingNetworkFeatureMethod = connectivityManager.getClass().getMethod("startUsingNetworkFeature", Integer.TYPE, String.class); - status = (int)startUsingNetworkFeatureMethod.invoke(connectivityManager, ConnectivityManager.TYPE_MOBILE, FEATURE_ENABLE_MMS); - } catch (NoSuchMethodException nsme) { - throw new MmsRadioException(nsme); - } catch (IllegalAccessException iae) { - throw new MmsRadioException(iae); - } catch (InvocationTargetException ite) { - throw new MmsRadioException(ite); - } - - Log.i(TAG, "startUsingNetworkFeature status: " + status); - - if (status == APN_ALREADY_ACTIVE) { - wakeLock.acquire(); - connectedCounter++; - return; - } else { - wakeLock.acquire(); - connectedCounter++; - - if (connectivityListener == null) { - IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); - connectivityListener = new ConnectivityListener(); - context.registerReceiver(connectivityListener, filter); - } - - Util.wait(this, 30000); - - if (!isConnected()) { - Log.w(TAG, "Got back from connectivity wait, and not connected..."); - disconnect(); - throw new MmsRadioException("Unable to successfully enable MMS radio."); - } - } - } - - private boolean isConnected() { - NetworkInfo info = connectivityManager.getNetworkInfo(TYPE_MOBILE_MMS); - - Log.i(TAG, "Connected: " + info); - - if ((info == null) || (info.getType() != TYPE_MOBILE_MMS) || !info.isConnected()) - return false; - - return true; - } - - private boolean isConnectivityPossible() { - NetworkInfo networkInfo = connectivityManager.getNetworkInfo(TYPE_MOBILE_MMS); - - return networkInfo != null && networkInfo.isAvailable(); - } - - private boolean isConnectivityFailure() { - NetworkInfo networkInfo = connectivityManager.getNetworkInfo(TYPE_MOBILE_MMS); - - return networkInfo == null || networkInfo.getDetailedState() == NetworkInfo.DetailedState.FAILED; - } - - private synchronized void issueConnectivityChange() { - if (isConnected()) { - Log.i(TAG, "Notifying connected..."); - notifyAll(); - return; - } - - if (!isConnected() && (isConnectivityFailure() || !isConnectivityPossible())) { - Log.i(TAG, "Notifying not connected..."); - notifyAll(); - return; - } - } - - private class ConnectivityListener extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - Log.i(TAG, "Got connectivity change..."); - issueConnectivityChange(); - } - } - - -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsRadioException.java b/app/src/main/java/org/thoughtcrime/securesms/mms/MmsRadioException.java deleted file mode 100644 index dfac78deed..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsRadioException.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.thoughtcrime.securesms.mms; - -public class MmsRadioException extends Throwable { - public MmsRadioException(String s) { - super(s); - } - - public MmsRadioException(Exception e) { - super(e); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsSendResult.java b/app/src/main/java/org/thoughtcrime/securesms/mms/MmsSendResult.java deleted file mode 100644 index bd9ce36f1b..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/MmsSendResult.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.thoughtcrime.securesms.mms; - -public class MmsSendResult { - - private final byte[] messageId; - private final int responseStatus; - - public MmsSendResult(byte[] messageId, int responseStatus) { - this.messageId = messageId; - this.responseStatus = responseStatus; - } - - public int getResponseStatus() { - return responseStatus; - } - - public byte[] getMessageId() { - return messageId; - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/PartParser.java b/app/src/main/java/org/thoughtcrime/securesms/mms/PartParser.java deleted file mode 100644 index 2c49cc55f6..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/PartParser.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.thoughtcrime.securesms.mms; - -import com.google.android.mms.ContentType; -import com.google.android.mms.pdu_alt.CharacterSets; -import com.google.android.mms.pdu_alt.PduBody; -import com.google.android.mms.pdu_alt.PduPart; - -import org.session.libsignal.utilities.logging.Log; - -import org.session.libsession.utilities.Util; - -import java.io.UnsupportedEncodingException; - - -public class PartParser { - public static String getMessageText(PduBody body) { - String bodyText = null; - - for (int i=0;i forPointer(Optional pointer) { - return forPointer(pointer, null, null); + return forPointer(pointer, null); } - public static Optional forPointer(Optional pointer, @Nullable StickerLocator stickerLocator) { - return forPointer(pointer, stickerLocator, null); - } - - public static Optional forPointer(Optional pointer, @Nullable StickerLocator stickerLocator, @Nullable String fastPreflightId) { + public static Optional forPointer(Optional pointer, @Nullable String fastPreflightId) { if (!pointer.isPresent() || !pointer.get().isPointer()) return Optional.absent(); String encodedKey = null; @@ -115,7 +111,6 @@ public class PointerAttachment extends Attachment { pointer.get().asPointer().getWidth(), pointer.get().asPointer().getHeight(), pointer.get().asPointer().getCaption().orNull(), - stickerLocator, pointer.get().asPointer().getUrl())); } @@ -134,7 +129,6 @@ public class PointerAttachment extends Attachment { pointer.getWidth(), pointer.getHeight(), pointer.getCaption(), - null, pointer.getUrl())); } @@ -154,7 +148,6 @@ public class PointerAttachment extends Attachment { thumbnail != null ? thumbnail.getWidth() : 0, thumbnail != null ? thumbnail.getHeight() : 0, thumbnail != null ? thumbnail.getCaption() : null, - null, thumbnail != null ? thumbnail.getUrl() : "")); } @@ -174,7 +167,6 @@ public class PointerAttachment extends Attachment { thumbnail != null ? thumbnail.asPointer().getWidth() : 0, thumbnail != null ? thumbnail.asPointer().getHeight() : 0, thumbnail != null ? thumbnail.asPointer().getCaption().orNull() : null, - null, thumbnail != null ? thumbnail.asPointer().getUrl() : "")); } } diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/StickerLocator.java b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/StickerLocator.java deleted file mode 100644 index 92cb4bd4c8..0000000000 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/StickerLocator.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.session.libsession.messaging.sending_receiving.attachments; - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.NonNull; - -public class StickerLocator implements Parcelable { - - private final String packId; - private final String packKey; - private final int stickerId; - - public StickerLocator(@NonNull String packId, @NonNull String packKey, int stickerId) { - this.packId = packId; - this.packKey = packKey; - this.stickerId = stickerId; - } - - private StickerLocator(Parcel in) { - packId = in.readString(); - packKey = in.readString(); - stickerId = in.readInt(); - } - - public @NonNull String getPackId() { - return packId; - } - - public @NonNull String getPackKey() { - return packKey; - } - - public @NonNull int getStickerId() { - return stickerId; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(packId); - dest.writeString(packKey); - dest.writeInt(stickerId); - } - - public static final Creator CREATOR = new Creator() { - @Override - public StickerLocator createFromParcel(Parcel in) { - return new StickerLocator(in); - } - - @Override - public StickerLocator[] newArray(int size) { - return new StickerLocator[size]; - } - }; -} diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/UriAttachment.java b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/UriAttachment.java index 101bc82e34..b87210faad 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/UriAttachment.java +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/attachments/UriAttachment.java @@ -11,18 +11,17 @@ public class UriAttachment extends Attachment { private final @Nullable Uri thumbnailUri; public UriAttachment(@NonNull Uri uri, @NonNull String contentType, int transferState, long size, - @Nullable String fileName, boolean voiceNote, boolean quote, @Nullable String caption, - @Nullable StickerLocator stickerLocator) + @Nullable String fileName, boolean voiceNote, boolean quote, @Nullable String caption) { - this(uri, uri, contentType, transferState, size, 0, 0, fileName, null, voiceNote, quote, caption, stickerLocator); + this(uri, uri, contentType, transferState, size, 0, 0, fileName, null, voiceNote, quote, caption); } public UriAttachment(@NonNull Uri dataUri, @Nullable Uri thumbnailUri, @NonNull String contentType, int transferState, long size, int width, int height, @Nullable String fileName, @Nullable String fastPreflightId, - boolean voiceNote, boolean quote, @Nullable String caption, @Nullable StickerLocator stickerLocator) + boolean voiceNote, boolean quote, @Nullable String caption) { - super(contentType, transferState, size, fileName, null, null, null, null, fastPreflightId, voiceNote, width, height, quote, caption, stickerLocator, ""); + super(contentType, transferState, size, fileName, null, null, null, null, fastPreflightId, voiceNote, width, height, quote, caption, ""); this.dataUri = dataUri; this.thumbnailUri = thumbnailUri; } diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/sharecontacts/Contact.java b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/sharecontacts/Contact.java index 0945c5a666..9158a7f827 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/sharecontacts/Contact.java +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/sharecontacts/Contact.java @@ -643,7 +643,7 @@ public class Contact implements Parcelable { private static Attachment attachmentFromUri(@Nullable Uri uri) { if (uri == null) return null; - return new UriAttachment(uri, MediaTypes.IMAGE_JPEG, AttachmentTransferProgress.TRANSFER_PROGRESS_DONE, 0, null, false, false, null, null); + return new UriAttachment(uri, MediaTypes.IMAGE_JPEG, AttachmentTransferProgress.TRANSFER_PROGRESS_DONE, 0, null, false, false, null); } @Override