Search in sources :

Example 1 with StickerSlide

use of org.thoughtcrime.securesms.mms.StickerSlide in project Signal-Android by WhisperSystems.

the class ThreadDatabase method getExtrasFor.

@Nullable
private Extra getExtrasFor(@NonNull MessageRecord record) {
    Recipient threadRecipient = record.isOutgoing() ? record.getRecipient() : getRecipientForThreadId(record.getThreadId());
    boolean messageRequestAccepted = RecipientUtil.isMessageRequestAccepted(context, record.getThreadId(), threadRecipient);
    RecipientId individualRecipientId = record.getIndividualRecipient().getId();
    // noinspection ConstantConditions
    if (!messageRequestAccepted && threadRecipient != null) {
        if (threadRecipient.isPushGroup()) {
            if (threadRecipient.isPushV2Group()) {
                MessageRecord.InviteAddState inviteAddState = record.getGv2AddInviteState();
                if (inviteAddState != null) {
                    RecipientId from = RecipientId.from(ACI.from(inviteAddState.getAddedOrInvitedBy()), null);
                    if (inviteAddState.isInvited()) {
                        Log.i(TAG, "GV2 invite message request from " + from);
                        return Extra.forGroupV2invite(from, individualRecipientId);
                    } else {
                        Log.i(TAG, "GV2 message request from " + from);
                        return Extra.forGroupMessageRequest(from, individualRecipientId);
                    }
                }
                Log.w(TAG, "Falling back to unknown message request state for GV2 message");
                return Extra.forMessageRequest(individualRecipientId);
            } else {
                RecipientId recipientId = SignalDatabase.mmsSms().getGroupAddedBy(record.getThreadId());
                if (recipientId != null) {
                    return Extra.forGroupMessageRequest(recipientId, individualRecipientId);
                }
            }
        }
        return Extra.forMessageRequest(individualRecipientId);
    }
    if (record.isRemoteDelete()) {
        return Extra.forRemoteDelete(individualRecipientId);
    } else if (record.isViewOnce()) {
        return Extra.forViewOnce(individualRecipientId);
    } else if (record.isMms() && ((MmsMessageRecord) record).getSlideDeck().getStickerSlide() != null) {
        StickerSlide slide = Objects.requireNonNull(((MmsMessageRecord) record).getSlideDeck().getStickerSlide());
        return Extra.forSticker(slide.getEmoji(), individualRecipientId);
    } else if (record.isMms() && ((MmsMessageRecord) record).getSlideDeck().getSlides().size() > 1) {
        return Extra.forAlbum(individualRecipientId);
    }
    if (threadRecipient != null && threadRecipient.isGroup()) {
        return Extra.forDefault(individualRecipientId);
    }
    return null;
}
Also used : RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Recipient(org.thoughtcrime.securesms.recipients.Recipient) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Nullable(androidx.annotation.Nullable)

Example 2 with StickerSlide

use of org.thoughtcrime.securesms.mms.StickerSlide in project Signal-Android by WhisperSystems.

the class ConversationParentFragment method sendSticker.

private void sendSticker(@NonNull StickerLocator stickerLocator, @NonNull String contentType, @NonNull Uri uri, long size, boolean clearCompose) {
    if (sendButton.getSelectedTransport().isSms()) {
        Media media = new Media(uri, contentType, System.currentTimeMillis(), StickerSlide.WIDTH, StickerSlide.HEIGHT, size, 0, false, false, Optional.absent(), Optional.absent(), Optional.absent());
        Intent intent = MediaSelectionActivity.editor(requireContext(), sendButton.getSelectedTransport(), Collections.singletonList(media), recipient.getId(), composeText.getTextTrimmed());
        startActivityForResult(intent, MEDIA_SENDER);
        return;
    }
    long expiresIn = TimeUnit.SECONDS.toMillis(recipient.get().getExpiresInSeconds());
    int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
    boolean initiating = threadId == -1;
    TransportOption transport = sendButton.getSelectedTransport();
    SlideDeck slideDeck = new SlideDeck();
    Slide stickerSlide = new StickerSlide(requireContext(), uri, size, stickerLocator, contentType);
    slideDeck.addSlide(stickerSlide);
    sendMediaMessage(recipient.getId(), transport.isSms(), "", slideDeck, null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), expiresIn, false, subscriptionId, initiating, clearCompose, null);
}
Also used : TransportOption(org.thoughtcrime.securesms.TransportOption) LocationSlide(org.thoughtcrime.securesms.mms.LocationSlide) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) Slide(org.thoughtcrime.securesms.mms.Slide) GifSlide(org.thoughtcrime.securesms.mms.GifSlide) ImageSlide(org.thoughtcrime.securesms.mms.ImageSlide) AudioSlide(org.thoughtcrime.securesms.mms.AudioSlide) VideoSlide(org.thoughtcrime.securesms.mms.VideoSlide) Media(org.thoughtcrime.securesms.mediasend.Media) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) SuppressLint(android.annotation.SuppressLint)

Example 3 with StickerSlide

use of org.thoughtcrime.securesms.mms.StickerSlide in project Signal-Android by signalapp.

the class ThreadDatabase method getExtrasFor.

@Nullable
private Extra getExtrasFor(@NonNull MessageRecord record) {
    Recipient threadRecipient = record.isOutgoing() ? record.getRecipient() : getRecipientForThreadId(record.getThreadId());
    boolean messageRequestAccepted = RecipientUtil.isMessageRequestAccepted(context, record.getThreadId(), threadRecipient);
    RecipientId individualRecipientId = record.getIndividualRecipient().getId();
    // noinspection ConstantConditions
    if (!messageRequestAccepted && threadRecipient != null) {
        if (threadRecipient.isPushGroup()) {
            if (threadRecipient.isPushV2Group()) {
                MessageRecord.InviteAddState inviteAddState = record.getGv2AddInviteState();
                if (inviteAddState != null) {
                    RecipientId from = RecipientId.from(ACI.from(inviteAddState.getAddedOrInvitedBy()), null);
                    if (inviteAddState.isInvited()) {
                        Log.i(TAG, "GV2 invite message request from " + from);
                        return Extra.forGroupV2invite(from, individualRecipientId);
                    } else {
                        Log.i(TAG, "GV2 message request from " + from);
                        return Extra.forGroupMessageRequest(from, individualRecipientId);
                    }
                }
                Log.w(TAG, "Falling back to unknown message request state for GV2 message");
                return Extra.forMessageRequest(individualRecipientId);
            } else {
                RecipientId recipientId = SignalDatabase.mmsSms().getGroupAddedBy(record.getThreadId());
                if (recipientId != null) {
                    return Extra.forGroupMessageRequest(recipientId, individualRecipientId);
                }
            }
        }
        return Extra.forMessageRequest(individualRecipientId);
    }
    if (record.isRemoteDelete()) {
        return Extra.forRemoteDelete(individualRecipientId);
    } else if (record.isViewOnce()) {
        return Extra.forViewOnce(individualRecipientId);
    } else if (record.isMms() && ((MmsMessageRecord) record).getSlideDeck().getStickerSlide() != null) {
        StickerSlide slide = Objects.requireNonNull(((MmsMessageRecord) record).getSlideDeck().getStickerSlide());
        return Extra.forSticker(slide.getEmoji(), individualRecipientId);
    } else if (record.isMms() && ((MmsMessageRecord) record).getSlideDeck().getSlides().size() > 1) {
        return Extra.forAlbum(individualRecipientId);
    }
    if (threadRecipient != null && threadRecipient.isGroup()) {
        return Extra.forDefault(individualRecipientId);
    }
    return null;
}
Also used : RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Recipient(org.thoughtcrime.securesms.recipients.Recipient) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Nullable(androidx.annotation.Nullable)

Example 4 with StickerSlide

use of org.thoughtcrime.securesms.mms.StickerSlide in project Signal-Android by signalapp.

the class ConversationParentFragment method sendSticker.

private void sendSticker(@NonNull StickerLocator stickerLocator, @NonNull String contentType, @NonNull Uri uri, long size, boolean clearCompose) {
    if (sendButton.getSelectedTransport().isSms()) {
        Media media = new Media(uri, contentType, System.currentTimeMillis(), StickerSlide.WIDTH, StickerSlide.HEIGHT, size, 0, false, false, Optional.absent(), Optional.absent(), Optional.absent());
        Intent intent = MediaSelectionActivity.editor(requireContext(), sendButton.getSelectedTransport(), Collections.singletonList(media), recipient.getId(), composeText.getTextTrimmed());
        startActivityForResult(intent, MEDIA_SENDER);
        return;
    }
    long expiresIn = TimeUnit.SECONDS.toMillis(recipient.get().getExpiresInSeconds());
    int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
    boolean initiating = threadId == -1;
    TransportOption transport = sendButton.getSelectedTransport();
    SlideDeck slideDeck = new SlideDeck();
    Slide stickerSlide = new StickerSlide(requireContext(), uri, size, stickerLocator, contentType);
    slideDeck.addSlide(stickerSlide);
    sendMediaMessage(recipient.getId(), transport.isSms(), "", slideDeck, null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), expiresIn, false, subscriptionId, initiating, clearCompose, null);
}
Also used : TransportOption(org.thoughtcrime.securesms.TransportOption) LocationSlide(org.thoughtcrime.securesms.mms.LocationSlide) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) Slide(org.thoughtcrime.securesms.mms.Slide) GifSlide(org.thoughtcrime.securesms.mms.GifSlide) ImageSlide(org.thoughtcrime.securesms.mms.ImageSlide) AudioSlide(org.thoughtcrime.securesms.mms.AudioSlide) VideoSlide(org.thoughtcrime.securesms.mms.VideoSlide) Media(org.thoughtcrime.securesms.mediasend.Media) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) SuppressLint(android.annotation.SuppressLint)

Aggregations

StickerSlide (org.thoughtcrime.securesms.mms.StickerSlide)4 SuppressLint (android.annotation.SuppressLint)2 PendingIntent (android.app.PendingIntent)2 Intent (android.content.Intent)2 Nullable (androidx.annotation.Nullable)2 TransportOption (org.thoughtcrime.securesms.TransportOption)2 MediaMmsMessageRecord (org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord)2 MessageRecord (org.thoughtcrime.securesms.database.model.MessageRecord)2 MmsMessageRecord (org.thoughtcrime.securesms.database.model.MmsMessageRecord)2 Media (org.thoughtcrime.securesms.mediasend.Media)2 AudioSlide (org.thoughtcrime.securesms.mms.AudioSlide)2 GifSlide (org.thoughtcrime.securesms.mms.GifSlide)2 ImageSlide (org.thoughtcrime.securesms.mms.ImageSlide)2 LocationSlide (org.thoughtcrime.securesms.mms.LocationSlide)2 Slide (org.thoughtcrime.securesms.mms.Slide)2 SlideDeck (org.thoughtcrime.securesms.mms.SlideDeck)2 VideoSlide (org.thoughtcrime.securesms.mms.VideoSlide)2 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)2