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;
}
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);
}
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;
}
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);
}
Aggregations