Search in sources :

Example 1 with QuoteId

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

the class ConversationParentFragment method getDraftsForCurrentState.

private Drafts getDraftsForCurrentState() {
    Drafts drafts = new Drafts();
    if (recipient.get().isGroup() && !recipient.get().isActiveGroup()) {
        return drafts;
    }
    if (!Util.isEmpty(composeText)) {
        drafts.add(new Draft(Draft.TEXT, composeText.getTextTrimmed().toString()));
        List<Mention> draftMentions = composeText.getMentions();
        if (!draftMentions.isEmpty()) {
            drafts.add(new Draft(Draft.MENTION, Base64.encodeBytes(MentionUtil.mentionsToBodyRangeList(draftMentions).toByteArray())));
        }
    }
    for (Slide slide : attachmentManager.buildSlideDeck().getSlides()) {
        if (slide.hasAudio() && slide.getUri() != null)
            drafts.add(new Draft(Draft.AUDIO, slide.getUri().toString()));
        else if (slide.hasVideo() && slide.getUri() != null)
            drafts.add(new Draft(Draft.VIDEO, slide.getUri().toString()));
        else if (slide.hasLocation())
            drafts.add(new Draft(Draft.LOCATION, ((LocationSlide) slide).getPlace().serialize()));
        else if (slide.hasImage() && slide.getUri() != null)
            drafts.add(new Draft(Draft.IMAGE, slide.getUri().toString()));
    }
    Optional<QuoteModel> quote = inputPanel.getQuote();
    if (quote.isPresent()) {
        drafts.add(new Draft(Draft.QUOTE, new QuoteId(quote.get().getId(), quote.get().getAuthor()).serialize()));
    }
    Draft voiceNoteDraft = draftViewModel.getVoiceNoteDraft();
    if (voiceNoteDraft != null) {
        drafts.add(voiceNoteDraft);
    }
    return drafts;
}
Also used : LocationSlide(org.thoughtcrime.securesms.mms.LocationSlide) VoiceNoteDraft(org.thoughtcrime.securesms.components.voice.VoiceNoteDraft) Draft(org.thoughtcrime.securesms.database.DraftDatabase.Draft) 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) QuoteId(org.thoughtcrime.securesms.mms.QuoteId) Mention(org.thoughtcrime.securesms.database.model.Mention) QuoteModel(org.thoughtcrime.securesms.mms.QuoteModel) Drafts(org.thoughtcrime.securesms.database.DraftDatabase.Drafts)

Example 2 with QuoteId

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

the class ConversationParentFragment method getDraftsForCurrentState.

private Drafts getDraftsForCurrentState() {
    Drafts drafts = new Drafts();
    if (recipient.get().isGroup() && !recipient.get().isActiveGroup()) {
        return drafts;
    }
    if (!Util.isEmpty(composeText)) {
        drafts.add(new Draft(Draft.TEXT, composeText.getTextTrimmed().toString()));
        List<Mention> draftMentions = composeText.getMentions();
        if (!draftMentions.isEmpty()) {
            drafts.add(new Draft(Draft.MENTION, Base64.encodeBytes(MentionUtil.mentionsToBodyRangeList(draftMentions).toByteArray())));
        }
    }
    for (Slide slide : attachmentManager.buildSlideDeck().getSlides()) {
        if (slide.hasAudio() && slide.getUri() != null)
            drafts.add(new Draft(Draft.AUDIO, slide.getUri().toString()));
        else if (slide.hasVideo() && slide.getUri() != null)
            drafts.add(new Draft(Draft.VIDEO, slide.getUri().toString()));
        else if (slide.hasLocation())
            drafts.add(new Draft(Draft.LOCATION, ((LocationSlide) slide).getPlace().serialize()));
        else if (slide.hasImage() && slide.getUri() != null)
            drafts.add(new Draft(Draft.IMAGE, slide.getUri().toString()));
    }
    Optional<QuoteModel> quote = inputPanel.getQuote();
    if (quote.isPresent()) {
        drafts.add(new Draft(Draft.QUOTE, new QuoteId(quote.get().getId(), quote.get().getAuthor()).serialize()));
    }
    Draft voiceNoteDraft = draftViewModel.getVoiceNoteDraft();
    if (voiceNoteDraft != null) {
        drafts.add(voiceNoteDraft);
    }
    return drafts;
}
Also used : LocationSlide(org.thoughtcrime.securesms.mms.LocationSlide) VoiceNoteDraft(org.thoughtcrime.securesms.components.voice.VoiceNoteDraft) Draft(org.thoughtcrime.securesms.database.DraftDatabase.Draft) 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) QuoteId(org.thoughtcrime.securesms.mms.QuoteId) Mention(org.thoughtcrime.securesms.database.model.Mention) QuoteModel(org.thoughtcrime.securesms.mms.QuoteModel) Drafts(org.thoughtcrime.securesms.database.DraftDatabase.Drafts)

Aggregations

VoiceNoteDraft (org.thoughtcrime.securesms.components.voice.VoiceNoteDraft)2 Draft (org.thoughtcrime.securesms.database.DraftDatabase.Draft)2 Drafts (org.thoughtcrime.securesms.database.DraftDatabase.Drafts)2 Mention (org.thoughtcrime.securesms.database.model.Mention)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 QuoteId (org.thoughtcrime.securesms.mms.QuoteId)2 QuoteModel (org.thoughtcrime.securesms.mms.QuoteModel)2 Slide (org.thoughtcrime.securesms.mms.Slide)2 StickerSlide (org.thoughtcrime.securesms.mms.StickerSlide)2 VideoSlide (org.thoughtcrime.securesms.mms.VideoSlide)2