public SmsMessageRecord getCurrent() {
      long messageId = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.ID));
      String address = cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.ADDRESS));
      int addressDeviceId =
          cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.ADDRESS_DEVICE_ID));
      long type = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.TYPE));
      long dateReceived =
          cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.NORMALIZED_DATE_RECEIVED));
      long dateSent =
          cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.NORMALIZED_DATE_SENT));
      long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.THREAD_ID));
      int status = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.STATUS));
      int receiptCount = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.RECEIPT_COUNT));
      String mismatchDocument =
          cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.MISMATCHED_IDENTITIES));

      List<IdentityKeyMismatch> mismatches = getMismatches(mismatchDocument);
      Recipients recipients = getRecipientsFor(address);
      DisplayRecord.Body body = getBody(cursor);

      return new SmsMessageRecord(
          context,
          messageId,
          body,
          recipients,
          recipients.getPrimaryRecipient(),
          addressDeviceId,
          dateSent,
          dateReceived,
          receiptCount,
          type,
          threadId,
          status,
          mismatches);
    }
 @Override
 protected Recipients doInBackground(Void... params) {
   try {
     String groupId = recipients.getPrimaryRecipient().getNumber();
     return DatabaseFactory.getGroupDatabase(context)
         .getGroupMembers(GroupUtil.getDecodedId(groupId), true);
   } catch (IOException e) {
     Log.w(TAG, e);
     return RecipientFactory.getRecipientsFor(context, new LinkedList<Recipient>(), true);
   }
 }
  public void setTitle(@Nullable Recipients recipients) {
    if (recipients == null) setComposeTitle();
    else if (recipients.isSingleRecipient()) setRecipientTitle(recipients.getPrimaryRecipient());
    else setRecipientsTitle(recipients);

    if (recipients != null && recipients.isBlocked()) {
      title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_block_white_18dp, 0, 0, 0);
    } else if (recipients != null && recipients.isMuted()) {
      title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_volume_off_white_18dp, 0, 0, 0);
    } else {
      title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    }
  }
Exemple #4
0
    private NotificationMmsMessageRecord getNotificationMmsMessageRecord(Cursor cursor) {
      long id = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.ID));
      long dateSent =
          cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.NORMALIZED_DATE_SENT));
      long dateReceived =
          cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.NORMALIZED_DATE_RECEIVED));
      long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.THREAD_ID));
      long mailbox = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX));
      String address = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS));
      int addressDeviceId =
          cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS_DEVICE_ID));
      Recipients recipients = getRecipientsFor(address);

      String contentLocation =
          cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.CONTENT_LOCATION));
      String transactionId =
          cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.TRANSACTION_ID));
      long messageSize = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_SIZE));
      long expiry = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.EXPIRY));
      int status = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.STATUS));
      int receiptCount = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.RECEIPT_COUNT));

      byte[] contentLocationBytes = null;
      byte[] transactionIdBytes = null;

      if (!TextUtils.isEmpty(contentLocation))
        contentLocationBytes = org.thoughtcrime.securesms.util.Util.toIsoBytes(contentLocation);

      if (!TextUtils.isEmpty(transactionId))
        transactionIdBytes = org.thoughtcrime.securesms.util.Util.toIsoBytes(transactionId);

      return new NotificationMmsMessageRecord(
          context,
          id,
          recipients,
          recipients.getPrimaryRecipient(),
          addressDeviceId,
          dateSent,
          dateReceived,
          receiptCount,
          threadId,
          contentLocationBytes,
          messageSize,
          expiry,
          status,
          transactionIdBytes,
          mailbox);
    }
Exemple #5
0
    private MediaMmsMessageRecord getMediaMmsMessageRecord(Cursor cursor) {
      long id = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.ID));
      long dateSent =
          cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.NORMALIZED_DATE_SENT));
      long dateReceived =
          cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.NORMALIZED_DATE_RECEIVED));
      long box = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX));
      long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.THREAD_ID));
      String address = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS));
      int addressDeviceId =
          cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS_DEVICE_ID));
      int receiptCount = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.RECEIPT_COUNT));
      DisplayRecord.Body body = getBody(cursor);
      int partCount = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.PART_COUNT));
      String mismatchDocument =
          cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.MISMATCHED_IDENTITIES));
      String networkDocument =
          cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.NETWORK_FAILURE));

      Recipients recipients = getRecipientsFor(address);
      List<IdentityKeyMismatch> mismatches = getMismatchedIdentities(mismatchDocument);
      List<NetworkFailure> networkFailures = getFailures(networkDocument);
      SlideDeck slideDeck = getSlideDeck(cursor);

      return new MediaMmsMessageRecord(
          context,
          id,
          recipients,
          recipients.getPrimaryRecipient(),
          addressDeviceId,
          dateSent,
          dateReceived,
          receiptCount,
          threadId,
          body,
          slideDeck,
          partCount,
          box,
          mismatches,
          networkFailures);
    }