mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-26 05:20:16 +00:00
No need for a RecipientFactory any longer
// FREEBIE
This commit is contained in:
@@ -11,12 +11,10 @@ import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
@@ -145,7 +143,7 @@ public class GroupDatabase extends Database {
|
||||
if (!includeSelf && Util.isOwnNumber(context, member))
|
||||
continue;
|
||||
|
||||
recipients.add(RecipientFactory.getRecipientFor(context, member, false));
|
||||
recipients.add(Recipient.from(context, member, false));
|
||||
}
|
||||
|
||||
return recipients;
|
||||
@@ -174,7 +172,7 @@ public class GroupDatabase extends Database {
|
||||
contentValues.put(MMS, GroupUtil.isMmsGroup(groupId));
|
||||
|
||||
databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, contentValues);
|
||||
RecipientFactory.clearCache(context);
|
||||
Recipient.clearCache(context);
|
||||
notifyConversationListListeners();
|
||||
}
|
||||
|
||||
@@ -193,7 +191,7 @@ public class GroupDatabase extends Database {
|
||||
GROUP_ID + " = ?",
|
||||
new String[] {groupId});
|
||||
|
||||
RecipientFactory.clearCache(context);
|
||||
Recipient.clearCache(context);
|
||||
notifyDatabaseListeners();
|
||||
notifyConversationListListeners();
|
||||
}
|
||||
@@ -204,7 +202,7 @@ public class GroupDatabase extends Database {
|
||||
databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues, GROUP_ID + " = ?",
|
||||
new String[] {groupId});
|
||||
|
||||
RecipientFactory.clearCache(context);
|
||||
Recipient.clearCache(context);
|
||||
notifyDatabaseListeners();
|
||||
}
|
||||
|
||||
@@ -219,7 +217,7 @@ public class GroupDatabase extends Database {
|
||||
databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues, GROUP_ID + " = ?",
|
||||
new String[] {groupId});
|
||||
|
||||
RecipientFactory.clearCache(context);
|
||||
Recipient.clearCache(context);
|
||||
notifyDatabaseListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
@@ -250,10 +249,10 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
|
||||
private long getThreadIdFor(IncomingMediaMessage retrieved) throws RecipientFormattingException, MmsException {
|
||||
if (retrieved.getGroupId() != null) {
|
||||
Recipient groupRecipients = RecipientFactory.getRecipientFor(context, retrieved.getGroupId(), true);
|
||||
Recipient groupRecipients = Recipient.from(context, retrieved.getGroupId(), true);
|
||||
return DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipients);
|
||||
} else {
|
||||
Recipient sender = RecipientFactory.getRecipientFor(context, retrieved.getFrom(), true);
|
||||
Recipient sender = Recipient.from(context, retrieved.getFrom(), true);
|
||||
return DatabaseFactory.getThreadDatabase(context).getThreadIdFor(sender);
|
||||
}
|
||||
}
|
||||
@@ -262,7 +261,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
String fromString = notification.getFrom() != null && notification.getFrom().getTextString() != null
|
||||
? Util.toIsoString(notification.getFrom().getTextString())
|
||||
: "";
|
||||
Recipient recipient = RecipientFactory.getRecipientFor(context, Address.fromExternal(context, fromString), false);
|
||||
Recipient recipient = Recipient.from(context, Address.fromExternal(context, fromString), false);
|
||||
return DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient);
|
||||
}
|
||||
|
||||
@@ -553,7 +552,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(THREAD_ID));
|
||||
int distributionType = DatabaseFactory.getThreadDatabase(context).getDistributionType(threadId);
|
||||
|
||||
Recipient recipient = RecipientFactory.getRecipientFor(context, Address.fromSerialized(address), false);
|
||||
Recipient recipient = Recipient.from(context, Address.fromSerialized(address), false);
|
||||
|
||||
if (body != null && (Types.isGroupQuit(outboxType) || Types.isGroupUpdate(outboxType))) {
|
||||
return new OutgoingGroupMediaMessage(recipient, body, attachments, timestamp, 0);
|
||||
@@ -1162,7 +1161,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
address = Address.fromSerialized(serialized);
|
||||
|
||||
}
|
||||
return RecipientFactory.getRecipientFor(context, address, true);
|
||||
return Recipient.from(context, address, true);
|
||||
}
|
||||
|
||||
private List<IdentityKeyMismatch> getMismatchedIdentities(String document) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.util.Log;
|
||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
@@ -34,7 +33,7 @@ public class PlaintextBackupImporter {
|
||||
XmlBackup.XmlBackupItem item;
|
||||
|
||||
while ((item = backup.getNext()) != null) {
|
||||
Recipient recipient = RecipientFactory.getRecipientFor(context, Address.fromExternal(context, item.getAddress()), false);
|
||||
Recipient recipient = Recipient.from(context, Address.fromExternal(context, item.getAddress()), false);
|
||||
long threadId = threads.getThreadIdFor(recipient);
|
||||
SQLiteStatement statement = db.createInsertStatement(transaction);
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.annimon.stream.Stream;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
@@ -355,7 +354,7 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
public void finish() {
|
||||
database.setTransactionSuccessful();
|
||||
database.endTransaction();
|
||||
RecipientFactory.clearCache(context);
|
||||
Recipient.clearCache(context);
|
||||
context.getContentResolver().notifyChange(Uri.parse(RECIPIENT_PREFERENCES_URI), null);
|
||||
}
|
||||
}
|
||||
@@ -475,7 +474,7 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
|
||||
public @NonNull Recipient getCurrent() {
|
||||
String serialized = cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS));
|
||||
return RecipientFactory.getRecipientFor(context, Address.fromSerialized(serialized), false);
|
||||
return Recipient.from(context, Address.fromSerialized(serialized), false);
|
||||
}
|
||||
|
||||
public @Nullable Recipient getNext() {
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.jobs.TrimThreadJob;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.sms.IncomingGroupMessage;
|
||||
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||
@@ -457,7 +456,7 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
}
|
||||
|
||||
private @NonNull Pair<Long, Long> insertCallLog(@NonNull Address address, long type, boolean unread) {
|
||||
Recipient recipient = RecipientFactory.getRecipientFor(context, address, true);
|
||||
Recipient recipient = Recipient.from(context, address, true);
|
||||
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient);
|
||||
|
||||
ContentValues values = new ContentValues(6);
|
||||
@@ -506,14 +505,14 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
if (message.isIdentityVerified()) type |= Types.KEY_EXCHANGE_IDENTITY_VERIFIED_BIT;
|
||||
else if (message.isIdentityDefault()) type |= Types.KEY_EXCHANGE_IDENTITY_DEFAULT_BIT;
|
||||
|
||||
Recipient recipient = RecipientFactory.getRecipientFor(context, message.getSender(), true);
|
||||
Recipient recipient = Recipient.from(context, message.getSender(), true);
|
||||
|
||||
Recipient groupRecipient;
|
||||
|
||||
if (message.getGroupId() == null) {
|
||||
groupRecipient = null;
|
||||
} else {
|
||||
groupRecipient = RecipientFactory.getRecipientFor(context, message.getGroupId(), true);
|
||||
groupRecipient = Recipient.from(context, message.getGroupId(), true);
|
||||
}
|
||||
|
||||
boolean unread = (org.thoughtcrime.securesms.util.Util.isDefaultSmsProvider(context) ||
|
||||
@@ -830,7 +829,7 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
long expireStarted = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.EXPIRE_STARTED));
|
||||
|
||||
List<IdentityKeyMismatch> mismatches = getMismatches(mismatchDocument);
|
||||
Recipient recipient = RecipientFactory.getRecipientFor(context, address, true);
|
||||
Recipient recipient = Recipient.from(context, address, true);
|
||||
DisplayRecord.Body body = getBody(cursor);
|
||||
|
||||
return new SmsMessageRecord(context, messageId, body, recipient,
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.util.Log;
|
||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -152,7 +151,7 @@ public class SmsMigrator {
|
||||
String address = getTheirCanonicalAddress(context, theirRecipientId);
|
||||
|
||||
if (address != null) {
|
||||
recipientList.add(RecipientFactory.getRecipientFor(context, Address.fromExternal(context, address), true));
|
||||
recipientList.add(Recipient.from(context, Address.fromExternal(context, address), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +233,7 @@ public class SmsMigrator {
|
||||
long ourThreadId = threadDatabase.getThreadIdFor(ourRecipients.iterator().next());
|
||||
migrateConversation(context, masterSecret, listener, progress, theirThreadId, ourThreadId);
|
||||
} else if (ourRecipients.size() > 1) {
|
||||
ourRecipients.add(RecipientFactory.getRecipientFor(context, Address.fromSerialized(TextSecurePreferences.getLocalNumber(context)), true));
|
||||
ourRecipients.add(Recipient.from(context, Address.fromSerialized(TextSecurePreferences.getLocalNumber(context)), true));
|
||||
|
||||
List<Address> memberAddresses = new LinkedList<>();
|
||||
|
||||
@@ -243,7 +242,7 @@ public class SmsMigrator {
|
||||
}
|
||||
|
||||
String ourGroupId = DatabaseFactory.getGroupDatabase(context).getOrCreateGroupForMembers(memberAddresses, true);
|
||||
Recipient ourGroupRecipient = RecipientFactory.getRecipientFor(context, Address.fromSerialized(ourGroupId), true);
|
||||
Recipient ourGroupRecipient = Recipient.from(context, Address.fromSerialized(ourGroupId), true);
|
||||
long ourThreadId = threadDatabase.getThreadIdFor(ourGroupRecipient, ThreadDatabase.DistributionTypes.CONVERSATION);
|
||||
|
||||
migrateConversation(context, masterSecret, listener, progress, theirThreadId, ourThreadId);
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.database.Cursor;
|
||||
import android.database.MergeCursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.graphics.Path;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
@@ -42,7 +41,6 @@ import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.util.DelimiterUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.libsignal.InvalidMessageException;
|
||||
@@ -511,7 +509,7 @@ public class ThreadDatabase extends Database {
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
Address address = Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
|
||||
return RecipientFactory.getRecipientFor(context, address, false);
|
||||
return Recipient.from(context, address, false);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
@@ -633,7 +631,7 @@ public class ThreadDatabase extends Database {
|
||||
groupRecord = Optional.absent();
|
||||
}
|
||||
|
||||
Recipient recipient = RecipientFactory.getRecipientFor(context, address, preferences, groupRecord, true);
|
||||
Recipient recipient = Recipient.from(context, address, preferences, groupRecord, true);
|
||||
DisplayRecord.Body body = getPlaintextBody(cursor);
|
||||
long date = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.DATE));
|
||||
long count = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.MESSAGE_COUNT));
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.content.Context;
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase.IdentityRecord;
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.LinkedList;
|
||||
@@ -77,7 +76,7 @@ public class IdentityRecordList {
|
||||
|
||||
for (IdentityRecord identityRecord : identityRecords) {
|
||||
if (isUntrusted(identityRecord)) {
|
||||
untrusted.add(RecipientFactory.getRecipientFor(context, identityRecord.getAddress(), false));
|
||||
untrusted.add(Recipient.from(context, identityRecord.getAddress(), false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +100,7 @@ public class IdentityRecordList {
|
||||
|
||||
for (IdentityRecord identityRecord : identityRecords) {
|
||||
if (identityRecord.getVerifiedStatus() == VerifiedStatus.UNVERIFIED) {
|
||||
unverified.add(RecipientFactory.getRecipientFor(context, identityRecord.getAddress(), false));
|
||||
unverified.add(Recipient.from(context, identityRecord.getAddress(), false));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user