use of android.content.ContentValues in project Signal-Android by WhisperSystems.
the class SmsDatabase method insertMessageOutbox.
protected long insertMessageOutbox(long threadId, OutgoingTextMessage message, long type, boolean forceSms, long date) {
if (message.isKeyExchange())
type |= Types.KEY_EXCHANGE_BIT;
else if (message.isSecureMessage())
type |= (Types.SECURE_MESSAGE_BIT | Types.PUSH_MESSAGE_BIT);
else if (message.isEndSession())
type |= Types.END_SESSION_BIT;
if (forceSms)
type |= Types.MESSAGE_FORCE_SMS_BIT;
String address = message.getRecipients().getPrimaryRecipient().getNumber();
ContentValues contentValues = new ContentValues(6);
contentValues.put(ADDRESS, PhoneNumberUtils.formatNumber(address));
contentValues.put(THREAD_ID, threadId);
contentValues.put(BODY, message.getMessageBody());
contentValues.put(DATE_RECEIVED, System.currentTimeMillis());
contentValues.put(DATE_SENT, date);
contentValues.put(READ, 1);
contentValues.put(TYPE, type);
contentValues.put(SUBSCRIPTION_ID, message.getSubscriptionId());
contentValues.put(EXPIRES_IN, message.getExpiresIn());
try {
contentValues.put(RECEIPT_COUNT, earlyReceiptCache.remove(date, canonicalizeNumber(context, address)));
} catch (InvalidNumberException e) {
Log.w(TAG, e);
}
SQLiteDatabase db = databaseHelper.getWritableDatabase();
long messageId = db.insert(TABLE_NAME, ADDRESS, contentValues);
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
notifyConversationListeners(threadId);
jobManager.add(new TrimThreadJob(context, threadId));
return messageId;
}
use of android.content.ContentValues in project Signal-Android by WhisperSystems.
the class IdentityDatabase method saveIdentity.
public void saveIdentity(long recipientId, IdentityKey identityKey) {
SQLiteDatabase database = databaseHelper.getWritableDatabase();
String identityKeyString = Base64.encodeBytes(identityKey.serialize());
ContentValues contentValues = new ContentValues();
contentValues.put(RECIPIENT, recipientId);
contentValues.put(IDENTITY_KEY, identityKeyString);
database.replace(TABLE_NAME, null, contentValues);
context.getContentResolver().notifyChange(CHANGE_URI, null);
}
use of android.content.ContentValues in project Signal-Android by WhisperSystems.
the class MmsAddressDatabase method insertAddress.
private void insertAddress(long messageId, int type, @NonNull String value) {
SQLiteDatabase database = databaseHelper.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(MMS_ID, messageId);
contentValues.put(TYPE, type);
contentValues.put(ADDRESS, value);
contentValues.put(ADDRESS_CHARSET, "UTF-8");
database.insert(TABLE_NAME, null, contentValues);
}
use of android.content.ContentValues in project Signal-Android by WhisperSystems.
the class RecipientPreferenceDatabase method setRingtone.
public void setRingtone(Recipients recipients, @Nullable Uri notification) {
ContentValues values = new ContentValues();
values.put(NOTIFICATION, notification == null ? null : notification.toString());
updateOrInsert(recipients, values);
}
use of android.content.ContentValues in project Signal-Android by WhisperSystems.
the class RecipientPreferenceDatabase method setExpireMessages.
public void setExpireMessages(Recipients recipients, int expiration) {
recipients.setExpireMessages(expiration);
ContentValues values = new ContentValues(1);
values.put(EXPIRE_MESSAGES, expiration);
updateOrInsert(recipients, values);
}
Aggregations