Search in sources :

Example 36 with Recipients

use of org.thoughtcrime.securesms.recipients.Recipients in project Signal-Android by WhisperSystems.

the class MessageDetailsActivity method initializeActionBar.

private void initializeActionBar() {
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Recipients recipients = RecipientFactory.getRecipientsForIds(this, getIntent().getLongArrayExtra(RECIPIENTS_IDS_EXTRA), true);
    recipients.addListener(this);
    setActionBarColor(recipients.getColor());
}
Also used : Recipients(org.thoughtcrime.securesms.recipients.Recipients)

Example 37 with Recipients

use of org.thoughtcrime.securesms.recipients.Recipients in project Signal-Android by WhisperSystems.

the class NewConversationActivity method onContactSelected.

@Override
public void onContactSelected(String number) {
    Recipients recipients = RecipientFactory.getRecipientsFromString(this, number, true);
    Intent intent = new Intent(this, ConversationActivity.class);
    intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
    intent.putExtra(ConversationActivity.TEXT_EXTRA, getIntent().getStringExtra(ConversationActivity.TEXT_EXTRA));
    intent.setDataAndType(getIntent().getData(), getIntent().getType());
    long existingThread = DatabaseFactory.getThreadDatabase(this).getThreadIdIfExistsFor(recipients);
    intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, existingThread);
    intent.putExtra(ConversationActivity.DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
    startActivity(intent);
    finish();
}
Also used : Recipients(org.thoughtcrime.securesms.recipients.Recipients) Intent(android.content.Intent)

Example 38 with Recipients

use of org.thoughtcrime.securesms.recipients.Recipients in project Signal-Android by WhisperSystems.

the class PushRecipientsPanel method getRecipients.

public Recipients getRecipients() throws RecipientFormattingException {
    String rawText = recipientsText.getText().toString();
    Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(), rawText, true);
    if (recipients.isEmpty())
        throw new RecipientFormattingException("Recipient List Is Empty!");
    return recipients;
}
Also used : Recipients(org.thoughtcrime.securesms.recipients.Recipients) RecipientFormattingException(org.thoughtcrime.securesms.recipients.RecipientFormattingException)

Example 39 with Recipients

use of org.thoughtcrime.securesms.recipients.Recipients in project Signal-Android by WhisperSystems.

the class PushDecryptJob method handleTextMessage.

private void handleTextMessage(@NonNull MasterSecretUnion masterSecret, @NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceDataMessage message, @NonNull Optional<Long> smsMessageId) throws MmsException {
    EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
    String body = message.getBody().isPresent() ? message.getBody().get() : "";
    Recipients recipients = getMessageDestination(envelope, message);
    if (message.getExpiresInSeconds() != recipients.getExpireMessages()) {
        handleExpirationUpdate(masterSecret, envelope, message, Optional.<Long>absent());
    }
    Long threadId;
    if (smsMessageId.isPresent() && !message.getGroupInfo().isPresent()) {
        threadId = database.updateBundleMessageBody(masterSecret, smsMessageId.get(), body).second;
    } else {
        IncomingTextMessage textMessage = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(), message.getTimestamp(), body, message.getGroupInfo(), message.getExpiresInSeconds() * 1000);
        textMessage = new IncomingEncryptedMessage(textMessage, body);
        Optional<InsertResult> insertResult = database.insertMessageInbox(masterSecret, textMessage);
        if (insertResult.isPresent())
            threadId = insertResult.get().getThreadId();
        else
            threadId = null;
        if (smsMessageId.isPresent())
            database.deleteMessage(smsMessageId.get());
    }
    if (threadId != null) {
        MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), threadId);
    }
}
Also used : InsertResult(org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult) IncomingEncryptedMessage(org.thoughtcrime.securesms.sms.IncomingEncryptedMessage) Recipients(org.thoughtcrime.securesms.recipients.Recipients) EncryptingSmsDatabase(org.thoughtcrime.securesms.database.EncryptingSmsDatabase) IncomingTextMessage(org.thoughtcrime.securesms.sms.IncomingTextMessage)

Example 40 with Recipients

use of org.thoughtcrime.securesms.recipients.Recipients in project Signal-Android by WhisperSystems.

the class PushReceivedJob method handle.

public void handle(SignalServiceEnvelope envelope, boolean sendExplicitReceipt) {
    if (!isActiveNumber(context, envelope.getSource())) {
        TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
        ContactTokenDetails contactTokenDetails = new ContactTokenDetails();
        contactTokenDetails.setNumber(envelope.getSource());
        directory.setNumber(contactTokenDetails, true);
        Recipients recipients = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
        ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, KeyCachingService.getMasterSecret(context), recipients));
    }
    if (envelope.isReceipt()) {
        handleReceipt(envelope);
    } else if (envelope.isPreKeySignalMessage() || envelope.isSignalMessage()) {
        handleMessage(envelope, sendExplicitReceipt);
    } else {
        Log.w(TAG, "Received envelope of unknown type: " + envelope.getType());
    }
}
Also used : Recipients(org.thoughtcrime.securesms.recipients.Recipients) ContactTokenDetails(org.whispersystems.signalservice.api.push.ContactTokenDetails) TextSecureDirectory(org.thoughtcrime.securesms.database.TextSecureDirectory)

Aggregations

Recipients (org.thoughtcrime.securesms.recipients.Recipients)52 EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)7 MmsDatabase (org.thoughtcrime.securesms.database.MmsDatabase)7 OutgoingMediaMessage (org.thoughtcrime.securesms.mms.OutgoingMediaMessage)6 LinkedList (java.util.LinkedList)5 Recipient (org.thoughtcrime.securesms.recipients.Recipient)5 RecipientFormattingException (org.thoughtcrime.securesms.recipients.RecipientFormattingException)5 OutgoingTextMessage (org.thoughtcrime.securesms.sms.OutgoingTextMessage)5 Intent (android.content.Intent)4 Bundle (android.os.Bundle)4 ThreadDatabase (org.thoughtcrime.securesms.database.ThreadDatabase)4 IncomingTextMessage (org.thoughtcrime.securesms.sms.IncomingTextMessage)4 MmsException (ws.com.google.android.mms.MmsException)4 Cursor (android.database.Cursor)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)3 NonNull (android.support.annotation.NonNull)3 Attachment (org.thoughtcrime.securesms.attachments.Attachment)3 DatabaseAttachment (org.thoughtcrime.securesms.attachments.DatabaseAttachment)3 InsertResult (org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult)3 OutgoingGroupMediaMessage (org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage)3