Search in sources :

Example 1 with MediaMmsMessageRecord

use of org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord in project Signal-Android by WhisperSystems.

the class MessageNotifier method constructNotificationState.

private static NotificationState constructNotificationState(@NonNull Context context, @Nullable MasterSecret masterSecret, @NonNull Cursor cursor) {
    NotificationState notificationState = new NotificationState();
    MessageRecord record;
    MmsSmsDatabase.Reader reader;
    if (masterSecret == null)
        reader = DatabaseFactory.getMmsSmsDatabase(context).readerFor(cursor);
    else
        reader = DatabaseFactory.getMmsSmsDatabase(context).readerFor(cursor, masterSecret);
    while ((record = reader.getNext()) != null) {
        long id = record.getId();
        boolean mms = record.isMms() || record.isMmsNotification();
        Recipient recipient = record.getIndividualRecipient();
        Recipients recipients = record.getRecipients();
        long threadId = record.getThreadId();
        CharSequence body = record.getDisplayBody();
        Recipients threadRecipients = null;
        SlideDeck slideDeck = null;
        long timestamp = record.getTimestamp();
        if (threadId != -1) {
            threadRecipients = DatabaseFactory.getThreadDatabase(context).getRecipientsForThreadId(threadId);
        }
        if (SmsDatabase.Types.isDecryptInProgressType(record.getType()) || !record.getBody().isPlaintext()) {
            body = SpanUtil.italic(context.getString(R.string.MessageNotifier_locked_message));
        } else if (record.isMms() && TextUtils.isEmpty(body)) {
            body = SpanUtil.italic(context.getString(R.string.MessageNotifier_media_message));
            slideDeck = ((MediaMmsMessageRecord) record).getSlideDeck();
        } else if (record.isMms() && !record.isMmsNotification()) {
            String message = context.getString(R.string.MessageNotifier_media_message_with_text, body);
            int italicLength = message.length() - body.length();
            body = SpanUtil.italic(message, italicLength);
            slideDeck = ((MediaMmsMessageRecord) record).getSlideDeck();
        }
        if (threadRecipients == null || !threadRecipients.isMuted()) {
            notificationState.addNotification(new NotificationItem(id, mms, recipient, recipients, threadRecipients, threadId, body, timestamp, slideDeck));
        }
    }
    reader.close();
    return notificationState;
}
Also used : MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Recipients(org.thoughtcrime.securesms.recipients.Recipients) Recipient(org.thoughtcrime.securesms.recipients.Recipient) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) MmsSmsDatabase(org.thoughtcrime.securesms.database.MmsSmsDatabase) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord)

Example 2 with MediaMmsMessageRecord

use of org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord in project Signal-Android by WhisperSystems.

the class ConversationFragment method setCorrectMenuVisibility.

private void setCorrectMenuVisibility(Menu menu) {
    Set<MessageRecord> messageRecords = getListAdapter().getSelectedItems();
    boolean actionMessage = false;
    if (actionMode != null && messageRecords.size() == 0) {
        actionMode.finish();
        return;
    }
    for (MessageRecord messageRecord : messageRecords) {
        if (messageRecord.isGroupAction() || messageRecord.isCallLog() || messageRecord.isJoined() || messageRecord.isExpirationTimerUpdate() || messageRecord.isEndSession() || messageRecord.isIdentityUpdate()) {
            actionMessage = true;
            break;
        }
    }
    if (messageRecords.size() > 1) {
        menu.findItem(R.id.menu_context_forward).setVisible(false);
        menu.findItem(R.id.menu_context_details).setVisible(false);
        menu.findItem(R.id.menu_context_save_attachment).setVisible(false);
        menu.findItem(R.id.menu_context_resend).setVisible(false);
        menu.findItem(R.id.menu_context_copy).setVisible(!actionMessage);
    } else {
        MessageRecord messageRecord = messageRecords.iterator().next();
        menu.findItem(R.id.menu_context_resend).setVisible(messageRecord.isFailed());
        menu.findItem(R.id.menu_context_save_attachment).setVisible(!actionMessage && messageRecord.isMms() && !messageRecord.isMmsNotification() && ((MediaMmsMessageRecord) messageRecord).containsMediaSlide());
        menu.findItem(R.id.menu_context_forward).setVisible(!actionMessage);
        menu.findItem(R.id.menu_context_details).setVisible(!actionMessage);
        menu.findItem(R.id.menu_context_copy).setVisible(!actionMessage);
    }
}
Also used : MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord)

Example 3 with MediaMmsMessageRecord

use of org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord in project Signal-Android by signalapp.

the class ConversationFragment method handleForwardMessage.

private void handleForwardMessage(MessageRecord message) {
    Intent composeIntent = new Intent(getActivity(), ShareActivity.class);
    composeIntent.putExtra(Intent.EXTRA_TEXT, message.getDisplayBody().toString());
    if (message.isMms()) {
        MediaMmsMessageRecord mediaMessage = (MediaMmsMessageRecord) message;
        if (mediaMessage.containsMediaSlide()) {
            Slide slide = mediaMessage.getSlideDeck().getSlides().get(0);
            composeIntent.putExtra(Intent.EXTRA_STREAM, slide.getUri());
            composeIntent.setType(slide.getContentType());
        }
    }
    startActivity(composeIntent);
}
Also used : MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Slide(org.thoughtcrime.securesms.mms.Slide) Intent(android.content.Intent)

Example 4 with MediaMmsMessageRecord

use of org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord in project Signal-Android by signalapp.

the class MessageNotifier method constructNotificationState.

private static NotificationState constructNotificationState(@NonNull Context context, @NonNull Cursor cursor) {
    NotificationState notificationState = new NotificationState();
    MmsSmsDatabase.Reader reader = DatabaseFactory.getMmsSmsDatabase(context).readerFor(cursor);
    MessageRecord record;
    while ((record = reader.getNext()) != null) {
        long id = record.getId();
        boolean mms = record.isMms() || record.isMmsNotification();
        Recipient recipient = record.getIndividualRecipient();
        Recipient conversationRecipient = record.getRecipient();
        long threadId = record.getThreadId();
        CharSequence body = record.getDisplayBody();
        Recipient threadRecipients = null;
        SlideDeck slideDeck = null;
        long timestamp = record.getTimestamp();
        if (threadId != -1) {
            threadRecipients = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId);
        }
        if (KeyCachingService.isLocked(context)) {
            body = SpanUtil.italic(context.getString(R.string.MessageNotifier_locked_message));
        } else if (record.isMms() && TextUtils.isEmpty(body)) {
            body = SpanUtil.italic(context.getString(R.string.MessageNotifier_media_message));
            slideDeck = ((MediaMmsMessageRecord) record).getSlideDeck();
        } else if (record.isMms() && !record.isMmsNotification()) {
            String message = context.getString(R.string.MessageNotifier_media_message_with_text, body);
            int italicLength = message.length() - body.length();
            body = SpanUtil.italic(message, italicLength);
            slideDeck = ((MediaMmsMessageRecord) record).getSlideDeck();
        }
        if (threadRecipients == null || !threadRecipients.isMuted()) {
            notificationState.addNotification(new NotificationItem(id, mms, recipient, conversationRecipient, threadRecipients, threadId, body, timestamp, slideDeck));
        }
    }
    reader.close();
    return notificationState;
}
Also used : MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Recipient(org.thoughtcrime.securesms.recipients.Recipient) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) SuppressLint(android.annotation.SuppressLint) MmsSmsDatabase(org.thoughtcrime.securesms.database.MmsSmsDatabase) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord)

Example 5 with MediaMmsMessageRecord

use of org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord in project Signal-Android by WhisperSystems.

the class ThreadDatabase method getAttachmentUriFor.

@Nullable
private Uri getAttachmentUriFor(MessageRecord record) {
    if (!record.isMms() || record.isMmsNotification() || record.isGroupAction())
        return null;
    SlideDeck slideDeck = ((MediaMmsMessageRecord) record).getSlideDeck();
    Slide thumbnail = Optional.fromNullable(slideDeck.getThumbnailSlide()).or(Optional.fromNullable(slideDeck.getStickerSlide())).orNull();
    if (thumbnail != null && !((MmsMessageRecord) record).isViewOnce()) {
        return thumbnail.getUri();
    }
    return null;
}
Also used : MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) StickerSlide(org.thoughtcrime.securesms.mms.StickerSlide) Slide(org.thoughtcrime.securesms.mms.Slide) SlideDeck(org.thoughtcrime.securesms.mms.SlideDeck) MmsMessageRecord(org.thoughtcrime.securesms.database.model.MmsMessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) Nullable(androidx.annotation.Nullable)

Aggregations

MediaMmsMessageRecord (org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord)14 MessageRecord (org.thoughtcrime.securesms.database.model.MessageRecord)8 Slide (org.thoughtcrime.securesms.mms.Slide)6 SuppressLint (android.annotation.SuppressLint)4 Intent (android.content.Intent)4 MmsMessageRecord (org.thoughtcrime.securesms.database.model.MmsMessageRecord)4 Nullable (androidx.annotation.Nullable)3 MultiselectPart (org.thoughtcrime.securesms.conversation.mutiselect.MultiselectPart)3 SlideDeck (org.thoughtcrime.securesms.mms.SlideDeck)3 Recipient (org.thoughtcrime.securesms.recipients.Recipient)3 ValueAnimator (android.animation.ValueAnimator)2 Context (android.content.Context)2 Color (android.graphics.Color)2 Rect (android.graphics.Rect)2 Uri (android.net.Uri)2 SpannableStringBuilder (android.text.SpannableStringBuilder)2 TextPaint (android.text.TextPaint)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 TextView (android.widget.TextView)2