No need for a RecipientFactory any longer

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-08-21 18:32:38 -07:00
parent 6af836735b
commit 6924f0519e
44 changed files with 105 additions and 179 deletions

View File

@ -21,7 +21,6 @@ import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.loaders.BlockedContactsLoader; import org.thoughtcrime.securesms.database.loaders.BlockedContactsLoader;
import org.thoughtcrime.securesms.preferences.BlockedContactListItem; import org.thoughtcrime.securesms.preferences.BlockedContactListItem;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme; import org.thoughtcrime.securesms.util.DynamicTheme;
@ -126,7 +125,7 @@ public class BlockedContactsActivity extends PassphraseRequiredActionBarActivity
@Override @Override
public void bindView(View view, Context context, Cursor cursor) { public void bindView(View view, Context context, Cursor cursor) {
String address = cursor.getString(1); String address = cursor.getString(1);
Recipient recipient = RecipientFactory.getRecipientFor(context, Address.fromSerialized(address), true); Recipient recipient = Recipient.from(context, Address.fromSerialized(address), true);
((BlockedContactListItem) view).set(recipient); ((BlockedContactListItem) view).set(recipient);
} }

View File

@ -22,7 +22,6 @@ import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
import org.thoughtcrime.securesms.database.model.MessageRecord; import org.thoughtcrime.securesms.database.model.MessageRecord;
import org.thoughtcrime.securesms.jobs.PushDecryptJob; import org.thoughtcrime.securesms.jobs.PushDecryptJob;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.util.Base64; import org.thoughtcrime.securesms.util.Base64;
import org.thoughtcrime.securesms.util.VerifySpan; import org.thoughtcrime.securesms.util.VerifySpan;
@ -47,7 +46,7 @@ public class ConfirmIdentityDialog extends AlertDialog {
{ {
super(context); super(context);
Recipient recipient = RecipientFactory.getRecipientFor(context, mismatch.getAddress(), false); Recipient recipient = Recipient.from(context, mismatch.getAddress(), false);
String name = recipient.toShortString(); String name = recipient.toShortString();
String introduction = String.format(context.getString(R.string.ConfirmIdentityDialog_your_safety_number_with_s_has_changed), name, name); String introduction = String.format(context.getString(R.string.ConfirmIdentityDialog_your_safety_number_with_s_has_changed), name, name);
SpannableString spannableString = new SpannableString(introduction + " " + SpannableString spannableString = new SpannableString(introduction + " " +

View File

@ -130,7 +130,6 @@ import org.thoughtcrime.securesms.notifications.MarkReadReceiver;
import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.providers.PersistentBlobProvider; import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientFormattingException; import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.scribbles.ScribbleActivity; import org.thoughtcrime.securesms.scribbles.ScribbleActivity;
@ -408,7 +407,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
addAttachmentContactInfo(data.getData()); addAttachmentContactInfo(data.getData());
break; break;
case GROUP_EDIT: case GROUP_EDIT:
recipient = RecipientFactory.getRecipientFor(this, (Address)data.getParcelableExtra(GroupCreateActivity.GROUP_ADDRESS_EXTRA), true); recipient = Recipient.from(this, (Address)data.getParcelableExtra(GroupCreateActivity.GROUP_ADDRESS_EXTRA), true);
recipient.addListener(this); recipient.addListener(this);
titleView.setTitle(recipient); titleView.setTitle(recipient);
setBlockedUserState(recipient, isSecureText, isDefaultSms); setBlockedUserState(recipient, isSecureText, isDefaultSms);
@ -420,7 +419,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
break; break;
case ADD_CONTACT: case ADD_CONTACT:
recipient = RecipientFactory.getRecipientFor(this, recipient.getAddress(), true); recipient = Recipient.from(this, recipient.getAddress(), true);
recipient.addListener(this); recipient.addListener(this);
fragment.reloadList(); fragment.reloadList();
break; break;
@ -1251,7 +1250,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private void initializeResources() { private void initializeResources() {
if (recipient != null) recipient.removeListener(this); if (recipient != null) recipient.removeListener(this);
recipient = RecipientFactory.getRecipientFor(this, (Address)getIntent().getParcelableExtra(ADDRESS_EXTRA), true); recipient = Recipient.from(this, (Address)getIntent().getParcelableExtra(ADDRESS_EXTRA), true);
threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1); threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1);
archived = getIntent().getBooleanExtra(IS_ARCHIVED_EXTRA, false); archived = getIntent().getBooleanExtra(IS_ARCHIVED_EXTRA, false);
distributionType = getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT); distributionType = getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
@ -1318,7 +1317,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
Log.w(TAG, "Group update received..."); Log.w(TAG, "Group update received...");
if (recipient != null) { if (recipient != null) {
Log.w(TAG, "Looking up new recipients..."); Log.w(TAG, "Looking up new recipients...");
recipient = RecipientFactory.getRecipientFor(context, recipient.getAddress(), true); recipient = Recipient.from(context, recipient.getAddress(), true);
recipient.addListener(ConversationActivity.this); recipient.addListener(ConversationActivity.this);
onModified(recipient); onModified(recipient);
fragment.reloadList(); fragment.reloadList();
@ -1328,7 +1327,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
IntentFilter staleFilter = new IntentFilter(); IntentFilter staleFilter = new IntentFilter();
staleFilter.addAction(GroupDatabase.DATABASE_UPDATE_ACTION); staleFilter.addAction(GroupDatabase.DATABASE_UPDATE_ACTION);
staleFilter.addAction(RecipientFactory.RECIPIENT_CLEAR_ACTION); staleFilter.addAction(Recipient.RECIPIENT_CLEAR_ACTION);
registerReceiver(securityUpdateReceiver, registerReceiver(securityUpdateReceiver,
new IntentFilter(SecurityEvent.SECURITY_UPDATE_EVENT), new IntentFilter(SecurityEvent.SECURITY_UPDATE_EVENT),
@ -2053,7 +2052,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
String[] unverifiedNames = new String[unverifiedIdentities.size()]; String[] unverifiedNames = new String[unverifiedIdentities.size()];
for (int i=0;i<unverifiedIdentities.size();i++) { for (int i=0;i<unverifiedIdentities.size();i++) {
unverifiedNames[i] = RecipientFactory.getRecipientFor(ConversationActivity.this, unverifiedIdentities.get(i).getAddress(), false).toShortString(); unverifiedNames[i] = Recipient.from(ConversationActivity.this, unverifiedIdentities.get(i).getAddress(), false).toShortString();
} }
AlertDialog.Builder builder = new AlertDialog.Builder(ConversationActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(ConversationActivity.this);

View File

@ -63,7 +63,6 @@ import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
import org.thoughtcrime.securesms.mms.Slide; import org.thoughtcrime.securesms.mms.Slide;
import org.thoughtcrime.securesms.profiles.UnknownSenderView; import org.thoughtcrime.securesms.profiles.UnknownSenderView;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage; import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.util.SaveAttachmentTask; import org.thoughtcrime.securesms.util.SaveAttachmentTask;
@ -184,7 +183,7 @@ public class ConversationFragment extends Fragment
} }
private void initializeResources() { private void initializeResources() {
this.recipient = RecipientFactory.getRecipientFor(getActivity(), (Address) getActivity().getIntent().getParcelableExtra(ConversationActivity.ADDRESS_EXTRA), true); this.recipient = Recipient.from(getActivity(), (Address) getActivity().getIntent().getParcelableExtra(ConversationActivity.ADDRESS_EXTRA), true);
this.threadId = this.getActivity().getIntent().getLongExtra(ConversationActivity.THREAD_ID_EXTRA, -1); this.threadId = this.getActivity().getIntent().getLongExtra(ConversationActivity.THREAD_ID_EXTRA, -1);
this.lastSeen = this.getActivity().getIntent().getLongExtra(ConversationActivity.LAST_SEEN_EXTRA, -1); this.lastSeen = this.getActivity().getIntent().getLongExtra(ConversationActivity.LAST_SEEN_EXTRA, -1);
this.firstLoad = true; this.firstLoad = true;

View File

@ -38,7 +38,6 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme; import org.thoughtcrime.securesms.util.DynamicTheme;
@ -230,7 +229,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
public void onChange(boolean selfChange) { public void onChange(boolean selfChange) {
super.onChange(selfChange); super.onChange(selfChange);
Log.w(TAG, "Detected android contact data changed, refreshing cache"); Log.w(TAG, "Detected android contact data changed, refreshing cache");
RecipientFactory.clearCache(ConversationListActivity.this); Recipient.clearCache(ConversationListActivity.this);
ConversationListActivity.this.runOnUiThread(new Runnable() { ConversationListActivity.this.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -60,7 +60,6 @@ import org.thoughtcrime.securesms.groups.GroupManager;
import org.thoughtcrime.securesms.groups.GroupManager.GroupActionResult; import org.thoughtcrime.securesms.groups.GroupManager.GroupActionResult;
import org.thoughtcrime.securesms.mms.RoundedCorners; import org.thoughtcrime.securesms.mms.RoundedCorners;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme; import org.thoughtcrime.securesms.util.DynamicTheme;
@ -298,7 +297,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
for (String contact : selected) { for (String contact : selected) {
Address address = Address.fromExternal(this, contact); Address address = Address.fromExternal(this, contact);
Recipient recipient = RecipientFactory.getRecipientFor(this, address, false); Recipient recipient = Recipient.from(this, address, false);
addSelectedContacts(recipient); addSelectedContacts(recipient);
} }
@ -351,7 +350,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
} }
String groupId = DatabaseFactory.getGroupDatabase(activity).getOrCreateGroupForMembers(memberAddresses, true); String groupId = DatabaseFactory.getGroupDatabase(activity).getOrCreateGroupForMembers(memberAddresses, true);
Recipient groupRecipient = RecipientFactory.getRecipientFor(activity, Address.fromSerialized(groupId), true); Recipient groupRecipient = Recipient.from(activity, Address.fromSerialized(groupId), true);
long threadId = DatabaseFactory.getThreadDatabase(activity).getThreadIdFor(groupRecipient, ThreadDatabase.DistributionTypes.DEFAULT); long threadId = DatabaseFactory.getThreadDatabase(activity).getThreadIdFor(groupRecipient, ThreadDatabase.DistributionTypes.DEFAULT);
return new GroupActionResult(groupRecipient, threadId); return new GroupActionResult(groupRecipient, threadId);

View File

@ -31,7 +31,6 @@ import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage; import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.util.ViewUtil; import org.thoughtcrime.securesms.util.ViewUtil;
@ -231,7 +230,7 @@ public class InviteActivity extends PassphraseRequiredActionBarActivity implemen
if (context == null) return null; if (context == null) return null;
for (String number : numbers) { for (String number : numbers) {
Recipient recipient = RecipientFactory.getRecipientFor(context, Address.fromExternal(context, number), false); Recipient recipient = Recipient.from(context, Address.fromExternal(context, number), false);
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipient.getAddress()); Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipient.getAddress());
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1; int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;

View File

@ -43,7 +43,6 @@ import org.thoughtcrime.securesms.database.CursorRecyclerViewAdapter;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord; import org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.util.AbstractCursorLoader; import org.thoughtcrime.securesms.util.AbstractCursorLoader;
import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicLanguage;
@ -136,7 +135,7 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity i
Address address = getIntent().getParcelableExtra(ADDRESS_EXTRA); Address address = getIntent().getParcelableExtra(ADDRESS_EXTRA);
if (address != null) { if (address != null) {
recipient = RecipientFactory.getRecipientFor(this, address, true); recipient = Recipient.from(this, address, true);
} else if (threadId > -1) { } else if (threadId > -1) {
recipient = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadId); recipient = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadId);
} else { } else {

View File

@ -38,7 +38,6 @@ import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.mms.VideoSlide; import org.thoughtcrime.securesms.mms.VideoSlide;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.DateUtils; import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.SaveAttachmentTask; import org.thoughtcrime.securesms.util.SaveAttachmentTask;
@ -153,7 +152,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1); threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1);
if (address != null) { if (address != null) {
recipient = RecipientFactory.getRecipientFor(this, address, true); recipient = Recipient.from(this, address, true);
recipient.addListener(this); recipient.addListener(this);
} else { } else {
recipient = null; recipient = null;

View File

@ -46,7 +46,6 @@ import org.thoughtcrime.securesms.database.loaders.MessageDetailsLoader;
import org.thoughtcrime.securesms.database.model.MessageRecord; import org.thoughtcrime.securesms.database.model.MessageRecord;
import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.util.DateUtils; import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicLanguage;
@ -138,7 +137,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
private void initializeActionBar() { private void initializeActionBar() {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Recipient recipient = RecipientFactory.getRecipientFor(this, (Address)getIntent().getParcelableExtra(ADDRESS_EXTRA), true); Recipient recipient = Recipient.from(this, (Address)getIntent().getParcelableExtra(ADDRESS_EXTRA), true);
recipient.addListener(this); recipient.addListener(this);
setActionBarColor(recipient.getColor()); setActionBarColor(recipient.getColor());

View File

@ -29,7 +29,6 @@ import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.ThreadDatabase; import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
/** /**
* Activity container for starting a new conversation. * Activity container for starting a new conversation.
@ -50,7 +49,7 @@ public class NewConversationActivity extends ContactSelectionActivity {
@Override @Override
public void onContactSelected(String number) { public void onContactSelected(String number) {
Recipient recipient = RecipientFactory.getRecipientFor(this, Address.fromExternal(this, number), true); Recipient recipient = Recipient.from(this, Address.fromExternal(this, number), true);
Intent intent = new Intent(this, ConversationActivity.class); Intent intent = new Intent(this, ConversationActivity.class);
intent.putExtra(ConversationActivity.ADDRESS_EXTRA, recipient.getAddress()); intent.putExtra(ConversationActivity.ADDRESS_EXTRA, recipient.getAddress());

View File

@ -42,7 +42,6 @@ import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
import org.thoughtcrime.securesms.preferences.AdvancedRingtonePreference; import org.thoughtcrime.securesms.preferences.AdvancedRingtonePreference;
import org.thoughtcrime.securesms.preferences.ColorPreference; import org.thoughtcrime.securesms.preferences.ColorPreference;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.util.DirectoryHelper; import org.thoughtcrime.securesms.util.DirectoryHelper;
import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicLanguage;
@ -88,7 +87,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
setContentView(R.layout.recipient_preference_activity); setContentView(R.layout.recipient_preference_activity);
Address address = getIntent().getParcelableExtra(ADDRESS_EXTRA); Address address = getIntent().getParcelableExtra(ADDRESS_EXTRA);
Recipient recipient = RecipientFactory.getRecipientFor(this, address, true); Recipient recipient = Recipient.from(this, address, true);
initializeToolbar(); initializeToolbar();
initializeReceivers(); initializeReceivers();
@ -150,7 +149,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
this.staleReceiver = new BroadcastReceiver() { this.staleReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Recipient recipient = RecipientFactory.getRecipientFor(context, (Address)getIntent().getParcelableExtra(ADDRESS_EXTRA), true); Recipient recipient = Recipient.from(context, (Address)getIntent().getParcelableExtra(ADDRESS_EXTRA), true);
recipient.addListener(RecipientPreferenceActivity.this); recipient.addListener(RecipientPreferenceActivity.this);
onModified(recipient); onModified(recipient);
} }
@ -158,7 +157,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
IntentFilter staleFilter = new IntentFilter(); IntentFilter staleFilter = new IntentFilter();
staleFilter.addAction(GroupDatabase.DATABASE_UPDATE_ACTION); staleFilter.addAction(GroupDatabase.DATABASE_UPDATE_ACTION);
staleFilter.addAction(RecipientFactory.RECIPIENT_CLEAR_ACTION); staleFilter.addAction(Recipient.RECIPIENT_CLEAR_ACTION);
registerReceiver(staleReceiver, staleFilter); registerReceiver(staleReceiver, staleFilter);
} }
@ -235,7 +234,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
} }
private void initializeRecipients() { private void initializeRecipients() {
this.recipient = RecipientFactory.getRecipientFor(getActivity(), this.recipient = Recipient.from(getActivity(),
(Address)getArguments().getParcelable(ADDRESS_EXTRA), (Address)getArguments().getParcelable(ADDRESS_EXTRA),
true); true);
@ -245,14 +244,14 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
recipient.removeListener(RecipientPreferenceFragment.this); recipient.removeListener(RecipientPreferenceFragment.this);
recipient = RecipientFactory.getRecipientFor(getActivity(), (Address)getArguments().getParcelable(ADDRESS_EXTRA), true); recipient = Recipient.from(getActivity(), (Address)getArguments().getParcelable(ADDRESS_EXTRA), true);
onModified(recipient); onModified(recipient);
} }
}; };
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(GroupDatabase.DATABASE_UPDATE_ACTION); intentFilter.addAction(GroupDatabase.DATABASE_UPDATE_ACTION);
intentFilter.addAction(RecipientFactory.RECIPIENT_CLEAR_ACTION); intentFilter.addAction(Recipient.RECIPIENT_CLEAR_ACTION);
getActivity().registerReceiver(staleReceiver, intentFilter); getActivity().registerReceiver(staleReceiver, intentFilter);
} }

View File

@ -13,7 +13,6 @@ import android.widget.Toast;
import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.Rfc5724Uri; import org.thoughtcrime.securesms.util.Rfc5724Uri;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -47,7 +46,7 @@ public class SmsSendtoActivity extends Activity {
nextIntent.putExtra(ConversationActivity.TEXT_EXTRA, destination.getBody()); nextIntent.putExtra(ConversationActivity.TEXT_EXTRA, destination.getBody());
Toast.makeText(this, R.string.ConversationActivity_specify_recipient, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.ConversationActivity_specify_recipient, Toast.LENGTH_LONG).show();
} else { } else {
Recipient recipient = RecipientFactory.getRecipientFor(this, Address.fromExternal(this, destination.getDestination()), true); Recipient recipient = Recipient.from(this, Address.fromExternal(this, destination.getDestination()), true);
long threadId = DatabaseFactory.getThreadDatabase(this).getThreadIdIfExistsFor(recipient); long threadId = DatabaseFactory.getThreadDatabase(this).getThreadIdIfExistsFor(recipient);
nextIntent = new Intent(this, ConversationActivity.class); nextIntent = new Intent(this, ConversationActivity.class);

View File

@ -73,7 +73,6 @@ import org.thoughtcrime.securesms.qr.QrCode;
import org.thoughtcrime.securesms.qr.ScanListener; import org.thoughtcrime.securesms.qr.ScanListener;
import org.thoughtcrime.securesms.qr.ScanningThread; import org.thoughtcrime.securesms.qr.ScanningThread;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme; import org.thoughtcrime.securesms.util.DynamicTheme;
@ -122,7 +121,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.AndroidManifest__verify_safety_number); getSupportActionBar().setTitle(R.string.AndroidManifest__verify_safety_number);
Recipient recipient = RecipientFactory.getRecipientFor(this, (Address)getIntent().getParcelableExtra(ADDRESS_EXTRA), true); Recipient recipient = Recipient.from(this, (Address)getIntent().getParcelableExtra(ADDRESS_EXTRA), true);
recipient.addListener(this); recipient.addListener(this);
setActionBarNotificationBarColor(recipient.getColor()); setActionBarNotificationBarColor(recipient.getColor());
@ -271,7 +270,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity
this.localNumber = getArguments().getString(LOCAL_NUMBER); this.localNumber = getArguments().getString(LOCAL_NUMBER);
this.localIdentity = localIdentityParcelable.get(); this.localIdentity = localIdentityParcelable.get();
this.remoteNumber = getArguments().getString(REMOTE_NUMBER); this.remoteNumber = getArguments().getString(REMOTE_NUMBER);
this.recipient = RecipientFactory.getRecipientFor(getActivity(), address, true); this.recipient = Recipient.from(getActivity(), address, true);
this.remoteIdentity = remoteIdentityParcelable.get(); this.remoteIdentity = remoteIdentityParcelable.get();
this.recipient.addListener(this); this.recipient.addListener(this);

View File

@ -31,7 +31,6 @@ import org.thoughtcrime.securesms.contacts.RecipientsAdapter;
import org.thoughtcrime.securesms.contacts.RecipientsEditor; import org.thoughtcrime.securesms.contacts.RecipientsEditor;
import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import java.util.LinkedList; import java.util.LinkedList;
@ -128,8 +127,8 @@ public class PushRecipientsPanel extends RelativeLayout implements RecipientModi
String token = tokenizer.nextToken().trim(); String token = tokenizer.nextToken().trim();
if (!TextUtils.isEmpty(token)) { if (!TextUtils.isEmpty(token)) {
if (hasBracketedNumber(token)) recipients.add(RecipientFactory.getRecipientFor(context, Address.fromExternal(context, parseBracketedNumber(token)), asynchronous)); if (hasBracketedNumber(token)) recipients.add(Recipient.from(context, Address.fromExternal(context, parseBracketedNumber(token)), asynchronous));
else recipients.add(RecipientFactory.getRecipientFor(context, Address.fromExternal(context, token), asynchronous)); else recipients.add(Recipient.from(context, Address.fromExternal(context, token), asynchronous));
} }
} }

View File

@ -12,7 +12,6 @@ import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.AvatarImageView; import org.thoughtcrime.securesms.components.AvatarImageView;
import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.util.ViewUtil; import org.thoughtcrime.securesms.util.ViewUtil;
@ -54,10 +53,10 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
if (type == ContactsDatabase.NEW_TYPE) { if (type == ContactsDatabase.NEW_TYPE) {
this.recipient = null; this.recipient = null;
this.contactPhotoImage.setAvatar(RecipientFactory.getRecipientFor(getContext(), Address.UNKNOWN, true), false); this.contactPhotoImage.setAvatar(Recipient.from(getContext(), Address.UNKNOWN, true), false);
} else if (!TextUtils.isEmpty(number)) { } else if (!TextUtils.isEmpty(number)) {
Address address = Address.fromExternal(getContext(), number); Address address = Address.fromExternal(getContext(), number);
this.recipient = RecipientFactory.getRecipientFor(getContext(), address, true); this.recipient = Recipient.from(getContext(), address, true);
if (this.recipient.getName() != null) { if (this.recipient.getName() != null) {
name = this.recipient.getName(); name = this.recipient.getName();

View File

@ -30,7 +30,6 @@ import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.DirectoryHelper; import org.thoughtcrime.securesms.util.DirectoryHelper;
import org.thoughtcrime.securesms.util.NumberUtil; import org.thoughtcrime.securesms.util.NumberUtil;
@ -103,7 +102,7 @@ public class ContactsCursorLoader extends CursorLoader {
ContactsDatabase.CONTACT_TYPE_COLUMN}); ContactsDatabase.CONTACT_TYPE_COLUMN});
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
final String number = cursor.getString(cursor.getColumnIndexOrThrow(ContactsDatabase.NUMBER_COLUMN)); final String number = cursor.getString(cursor.getColumnIndexOrThrow(ContactsDatabase.NUMBER_COLUMN));
final Recipient recipient = RecipientFactory.getRecipientFor(getContext(), Address.fromExternal(getContext(), number), true); final Recipient recipient = Recipient.from(getContext(), Address.fromExternal(getContext(), number), true);
if (DirectoryHelper.getUserCapabilities(getContext(), recipient) != DirectoryHelper.Capability.SUPPORTED) { if (DirectoryHelper.getUserCapabilities(getContext(), recipient) != DirectoryHelper.Capability.SUPPORTED) {
matrix.addRow(new Object[]{cursor.getLong(cursor.getColumnIndexOrThrow(ContactsDatabase.ID_COLUMN)), matrix.addRow(new Object[]{cursor.getLong(cursor.getColumnIndexOrThrow(ContactsDatabase.ID_COLUMN)),

View File

@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.IdentityDatabase; import org.thoughtcrime.securesms.database.IdentityDatabase;
import org.thoughtcrime.securesms.database.IdentityDatabase.IdentityRecord; import org.thoughtcrime.securesms.database.IdentityDatabase.IdentityRecord;
import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus; import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus;
import org.thoughtcrime.securesms.recipients.RecipientFactory; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.IdentityUtil; import org.thoughtcrime.securesms.util.IdentityUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.libsignal.IdentityKey; import org.whispersystems.libsignal.IdentityKey;
@ -69,7 +69,7 @@ public class TextSecureIdentityKeyStore implements IdentityKeyStore {
} }
identityDatabase.saveIdentity(signalAddress, identityKey, verifiedStatus, false, System.currentTimeMillis(), nonBlockingApproval); identityDatabase.saveIdentity(signalAddress, identityKey, verifiedStatus, false, System.currentTimeMillis(), nonBlockingApproval);
IdentityUtil.markIdentityUpdate(context, RecipientFactory.getRecipientFor(context, signalAddress, true)); IdentityUtil.markIdentityUpdate(context, Recipient.from(context, signalAddress, true));
SessionUtil.archiveSiblingSessions(context, address); SessionUtil.archiveSiblingSessions(context, address);
return true; return true;
} }

View File

@ -11,12 +11,10 @@ import android.graphics.Bitmap;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.GroupUtil; import org.thoughtcrime.securesms.util.GroupUtil;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
@ -145,7 +143,7 @@ public class GroupDatabase extends Database {
if (!includeSelf && Util.isOwnNumber(context, member)) if (!includeSelf && Util.isOwnNumber(context, member))
continue; continue;
recipients.add(RecipientFactory.getRecipientFor(context, member, false)); recipients.add(Recipient.from(context, member, false));
} }
return recipients; return recipients;
@ -174,7 +172,7 @@ public class GroupDatabase extends Database {
contentValues.put(MMS, GroupUtil.isMmsGroup(groupId)); contentValues.put(MMS, GroupUtil.isMmsGroup(groupId));
databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, contentValues); databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, contentValues);
RecipientFactory.clearCache(context); Recipient.clearCache(context);
notifyConversationListListeners(); notifyConversationListListeners();
} }
@ -193,7 +191,7 @@ public class GroupDatabase extends Database {
GROUP_ID + " = ?", GROUP_ID + " = ?",
new String[] {groupId}); new String[] {groupId});
RecipientFactory.clearCache(context); Recipient.clearCache(context);
notifyDatabaseListeners(); notifyDatabaseListeners();
notifyConversationListListeners(); notifyConversationListListeners();
} }
@ -204,7 +202,7 @@ public class GroupDatabase extends Database {
databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues, GROUP_ID + " = ?", databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues, GROUP_ID + " = ?",
new String[] {groupId}); new String[] {groupId});
RecipientFactory.clearCache(context); Recipient.clearCache(context);
notifyDatabaseListeners(); notifyDatabaseListeners();
} }
@ -219,7 +217,7 @@ public class GroupDatabase extends Database {
databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues, GROUP_ID + " = ?", databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues, GROUP_ID + " = ?",
new String[] {groupId}); new String[] {groupId});
RecipientFactory.clearCache(context); Recipient.clearCache(context);
notifyDatabaseListeners(); notifyDatabaseListeners();
} }

View File

@ -57,7 +57,6 @@ import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage;
import org.thoughtcrime.securesms.mms.SlideDeck; import org.thoughtcrime.securesms.mms.SlideDeck;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientFormattingException; import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.util.JsonUtils; import org.thoughtcrime.securesms.util.JsonUtils;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
@ -250,10 +249,10 @@ public class MmsDatabase extends MessagingDatabase {
private long getThreadIdFor(IncomingMediaMessage retrieved) throws RecipientFormattingException, MmsException { private long getThreadIdFor(IncomingMediaMessage retrieved) throws RecipientFormattingException, MmsException {
if (retrieved.getGroupId() != null) { 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); return DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipients);
} else { } else {
Recipient sender = RecipientFactory.getRecipientFor(context, retrieved.getFrom(), true); Recipient sender = Recipient.from(context, retrieved.getFrom(), true);
return DatabaseFactory.getThreadDatabase(context).getThreadIdFor(sender); return DatabaseFactory.getThreadDatabase(context).getThreadIdFor(sender);
} }
} }
@ -262,7 +261,7 @@ public class MmsDatabase extends MessagingDatabase {
String fromString = notification.getFrom() != null && notification.getFrom().getTextString() != null String fromString = notification.getFrom() != null && notification.getFrom().getTextString() != null
? Util.toIsoString(notification.getFrom().getTextString()) ? 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); return DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient);
} }
@ -553,7 +552,7 @@ public class MmsDatabase extends MessagingDatabase {
long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(THREAD_ID)); long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(THREAD_ID));
int distributionType = DatabaseFactory.getThreadDatabase(context).getDistributionType(threadId); 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))) { if (body != null && (Types.isGroupQuit(outboxType) || Types.isGroupUpdate(outboxType))) {
return new OutgoingGroupMediaMessage(recipient, body, attachments, timestamp, 0); return new OutgoingGroupMediaMessage(recipient, body, attachments, timestamp, 0);
@ -1162,7 +1161,7 @@ public class MmsDatabase extends MessagingDatabase {
address = Address.fromSerialized(serialized); address = Address.fromSerialized(serialized);
} }
return RecipientFactory.getRecipientFor(context, address, true); return Recipient.from(context, address, true);
} }
private List<IdentityKeyMismatch> getMismatchedIdentities(String document) { private List<IdentityKeyMismatch> getMismatchedIdentities(String document) {

View File

@ -9,7 +9,6 @@ import android.util.Log;
import org.thoughtcrime.securesms.crypto.MasterCipher; import org.thoughtcrime.securesms.crypto.MasterCipher;
import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import java.io.File; import java.io.File;
@ -34,7 +33,7 @@ public class PlaintextBackupImporter {
XmlBackup.XmlBackupItem item; XmlBackup.XmlBackupItem item;
while ((item = backup.getNext()) != null) { 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); long threadId = threads.getThreadIdFor(recipient);
SQLiteStatement statement = db.createInsertStatement(transaction); SQLiteStatement statement = db.createInsertStatement(transaction);

View File

@ -15,7 +15,6 @@ import com.annimon.stream.Stream;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.thoughtcrime.securesms.color.MaterialColor; import org.thoughtcrime.securesms.color.MaterialColor;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.Base64; import org.thoughtcrime.securesms.util.Base64;
import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.libsignal.util.guava.Optional;
@ -355,7 +354,7 @@ public class RecipientPreferenceDatabase extends Database {
public void finish() { public void finish() {
database.setTransactionSuccessful(); database.setTransactionSuccessful();
database.endTransaction(); database.endTransaction();
RecipientFactory.clearCache(context); Recipient.clearCache(context);
context.getContentResolver().notifyChange(Uri.parse(RECIPIENT_PREFERENCES_URI), null); context.getContentResolver().notifyChange(Uri.parse(RECIPIENT_PREFERENCES_URI), null);
} }
} }
@ -475,7 +474,7 @@ public class RecipientPreferenceDatabase extends Database {
public @NonNull Recipient getCurrent() { public @NonNull Recipient getCurrent() {
String serialized = cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)); 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() { public @Nullable Recipient getNext() {

View File

@ -35,7 +35,6 @@ import org.thoughtcrime.securesms.database.model.MessageRecord;
import org.thoughtcrime.securesms.database.model.SmsMessageRecord; import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
import org.thoughtcrime.securesms.jobs.TrimThreadJob; import org.thoughtcrime.securesms.jobs.TrimThreadJob;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.IncomingGroupMessage; import org.thoughtcrime.securesms.sms.IncomingGroupMessage;
import org.thoughtcrime.securesms.sms.IncomingTextMessage; import org.thoughtcrime.securesms.sms.IncomingTextMessage;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage; 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) { 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); long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient);
ContentValues values = new ContentValues(6); ContentValues values = new ContentValues(6);
@ -506,14 +505,14 @@ public class SmsDatabase extends MessagingDatabase {
if (message.isIdentityVerified()) type |= Types.KEY_EXCHANGE_IDENTITY_VERIFIED_BIT; if (message.isIdentityVerified()) type |= Types.KEY_EXCHANGE_IDENTITY_VERIFIED_BIT;
else if (message.isIdentityDefault()) type |= Types.KEY_EXCHANGE_IDENTITY_DEFAULT_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; Recipient groupRecipient;
if (message.getGroupId() == null) { if (message.getGroupId() == null) {
groupRecipient = null; groupRecipient = null;
} else { } else {
groupRecipient = RecipientFactory.getRecipientFor(context, message.getGroupId(), true); groupRecipient = Recipient.from(context, message.getGroupId(), true);
} }
boolean unread = (org.thoughtcrime.securesms.util.Util.isDefaultSmsProvider(context) || 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)); long expireStarted = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.EXPIRE_STARTED));
List<IdentityKeyMismatch> mismatches = getMismatches(mismatchDocument); List<IdentityKeyMismatch> mismatches = getMismatches(mismatchDocument);
Recipient recipient = RecipientFactory.getRecipientFor(context, address, true); Recipient recipient = Recipient.from(context, address, true);
DisplayRecord.Body body = getBody(cursor); DisplayRecord.Body body = getBody(cursor);
return new SmsMessageRecord(context, messageId, body, recipient, return new SmsMessageRecord(context, messageId, body, recipient,

View File

@ -28,7 +28,6 @@ import android.util.Log;
import org.thoughtcrime.securesms.crypto.MasterCipher; import org.thoughtcrime.securesms.crypto.MasterCipher;
import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.TextSecurePreferences;
import java.util.HashSet; import java.util.HashSet;
@ -152,7 +151,7 @@ public class SmsMigrator {
String address = getTheirCanonicalAddress(context, theirRecipientId); String address = getTheirCanonicalAddress(context, theirRecipientId);
if (address != null) { 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()); long ourThreadId = threadDatabase.getThreadIdFor(ourRecipients.iterator().next());
migrateConversation(context, masterSecret, listener, progress, theirThreadId, ourThreadId); migrateConversation(context, masterSecret, listener, progress, theirThreadId, ourThreadId);
} else if (ourRecipients.size() > 1) { } 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<>(); List<Address> memberAddresses = new LinkedList<>();
@ -243,7 +242,7 @@ public class SmsMigrator {
} }
String ourGroupId = DatabaseFactory.getGroupDatabase(context).getOrCreateGroupForMembers(memberAddresses, true); 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); long ourThreadId = threadDatabase.getThreadIdFor(ourGroupRecipient, ThreadDatabase.DistributionTypes.CONVERSATION);
migrateConversation(context, masterSecret, listener, progress, theirThreadId, ourThreadId); migrateConversation(context, masterSecret, listener, progress, theirThreadId, ourThreadId);

View File

@ -22,7 +22,6 @@ import android.database.Cursor;
import android.database.MergeCursor; import android.database.MergeCursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Path;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.TextUtils; 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.Slide;
import org.thoughtcrime.securesms.mms.SlideDeck; import org.thoughtcrime.securesms.mms.SlideDeck;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.DelimiterUtil; import org.thoughtcrime.securesms.util.DelimiterUtil;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libsignal.InvalidMessageException; import org.whispersystems.libsignal.InvalidMessageException;
@ -511,7 +509,7 @@ public class ThreadDatabase extends Database {
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
Address address = Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS))); Address address = Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
return RecipientFactory.getRecipientFor(context, address, false); return Recipient.from(context, address, false);
} }
} finally { } finally {
if (cursor != null) if (cursor != null)
@ -633,7 +631,7 @@ public class ThreadDatabase extends Database {
groupRecord = Optional.absent(); 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); DisplayRecord.Body body = getPlaintextBody(cursor);
long date = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.DATE)); long date = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.DATE));
long count = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.MESSAGE_COUNT)); long count = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.MESSAGE_COUNT));

View File

@ -6,7 +6,6 @@ import android.content.Context;
import org.thoughtcrime.securesms.database.IdentityDatabase.IdentityRecord; import org.thoughtcrime.securesms.database.IdentityDatabase.IdentityRecord;
import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus; import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.libsignal.util.guava.Optional;
import java.util.LinkedList; import java.util.LinkedList;
@ -77,7 +76,7 @@ public class IdentityRecordList {
for (IdentityRecord identityRecord : identityRecords) { for (IdentityRecord identityRecord : identityRecords) {
if (isUntrusted(identityRecord)) { 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) { for (IdentityRecord identityRecord : identityRecords) {
if (identityRecord.getVerifiedStatus() == VerifiedStatus.UNVERIFIED) { if (identityRecord.getVerifiedStatus() == VerifiedStatus.UNVERIFIED) {
unverified.add(RecipientFactory.getRecipientFor(context, identityRecord.getAddress(), false)); unverified.add(Recipient.from(context, identityRecord.getAddress(), false));
} }
} }

View File

@ -19,13 +19,11 @@ import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
import org.thoughtcrime.securesms.providers.SingleUseBlobProvider; import org.thoughtcrime.securesms.providers.SingleUseBlobProvider;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.GroupUtil; import org.thoughtcrime.securesms.util.GroupUtil;
import org.thoughtcrime.securesms.util.MediaUtil; import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.util.InvalidNumberException; import org.whispersystems.signalservice.api.util.InvalidNumberException;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext; import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
@ -58,7 +56,7 @@ public class GroupManager {
DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileSharing(Address.fromSerialized(groupId), true); DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileSharing(Address.fromSerialized(groupId), true);
return sendGroupUpdate(context, masterSecret, groupId, memberAddresses, name, avatarBytes); return sendGroupUpdate(context, masterSecret, groupId, memberAddresses, name, avatarBytes);
} else { } else {
Recipient groupRecipient = RecipientFactory.getRecipientFor(context, Address.fromSerialized(groupId), true); Recipient groupRecipient = Recipient.from(context, Address.fromSerialized(groupId), true);
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipient, ThreadDatabase.DistributionTypes.CONVERSATION); long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipient, ThreadDatabase.DistributionTypes.CONVERSATION);
return new GroupActionResult(groupRecipient, threadId); return new GroupActionResult(groupRecipient, threadId);
} }
@ -84,7 +82,7 @@ public class GroupManager {
if (!GroupUtil.isMmsGroup(groupId)) { if (!GroupUtil.isMmsGroup(groupId)) {
return sendGroupUpdate(context, masterSecret, groupId, memberAddresses, name, avatarBytes); return sendGroupUpdate(context, masterSecret, groupId, memberAddresses, name, avatarBytes);
} else { } else {
Recipient groupRecipient = RecipientFactory.getRecipientFor(context, Address.fromSerialized(groupId), true); Recipient groupRecipient = Recipient.from(context, Address.fromSerialized(groupId), true);
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipient); long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipient);
return new GroupActionResult(groupRecipient, threadId); return new GroupActionResult(groupRecipient, threadId);
} }
@ -100,7 +98,7 @@ public class GroupManager {
try { try {
Attachment avatarAttachment = null; Attachment avatarAttachment = null;
Address groupAddress = Address.fromSerialized(groupId); Address groupAddress = Address.fromSerialized(groupId);
Recipient groupRecipient = RecipientFactory.getRecipientFor(context, groupAddress, false); Recipient groupRecipient = Recipient.from(context, groupAddress, false);
List<String> numbers = new LinkedList<>(); List<String> numbers = new LinkedList<>();

View File

@ -22,7 +22,6 @@ import org.thoughtcrime.securesms.mms.MmsException;
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.IncomingGroupMessage; import org.thoughtcrime.securesms.sms.IncomingGroupMessage;
import org.thoughtcrime.securesms.sms.IncomingTextMessage; import org.thoughtcrime.securesms.sms.IncomingTextMessage;
import org.thoughtcrime.securesms.util.Base64; import org.thoughtcrime.securesms.util.Base64;
@ -218,7 +217,7 @@ public class GroupMessageProcessor {
if (outgoing) { if (outgoing) {
MmsDatabase mmsDatabase = DatabaseFactory.getMmsDatabase(context); MmsDatabase mmsDatabase = DatabaseFactory.getMmsDatabase(context);
Address addres = Address.fromExternal(context, GroupUtil.getEncodedId(group.getGroupId(), false)); Address addres = Address.fromExternal(context, GroupUtil.getEncodedId(group.getGroupId(), false));
Recipient recipient = RecipientFactory.getRecipientFor(context, addres, false); Recipient recipient = Recipient.from(context, addres, false);
OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(recipient, storage, null, envelope.getTimestamp(), 0); OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(recipient, storage, null, envelope.getTimestamp(), 0);
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient); long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient);
long messageId = mmsDatabase.insertMessageOutbox(masterSecret, outgoingMessage, threadId, false, null); long messageId = mmsDatabase.insertMessageOutbox(masterSecret, outgoingMessage, threadId, false, null);

View File

@ -14,7 +14,6 @@ import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.MmsDatabase; import org.thoughtcrime.securesms.database.MmsDatabase;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.jobqueue.JobParameters; import org.whispersystems.jobqueue.JobParameters;
@ -86,7 +85,7 @@ public class MmsReceiveJob extends ContextJob {
private boolean isBlocked(GenericPdu pdu) { private boolean isBlocked(GenericPdu pdu) {
if (pdu.getFrom() != null && pdu.getFrom().getTextString() != null) { if (pdu.getFrom() != null && pdu.getFrom().getTextString() != null) {
Recipient recipients = RecipientFactory.getRecipientFor(context, Address.fromExternal(context, Util.toIsoString(pdu.getFrom().getTextString())), false); Recipient recipients = Recipient.from(context, Address.fromExternal(context, Util.toIsoString(pdu.getFrom().getTextString())), false);
return recipients.isBlocked(); return recipients.isBlocked();
} }

View File

@ -20,7 +20,6 @@ import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule.SignalMessageSenderFactory; import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule.SignalMessageSenderFactory;
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement; import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.jobqueue.JobParameters; import org.whispersystems.jobqueue.JobParameters;
import org.whispersystems.jobqueue.requirements.NetworkRequirement; import org.whispersystems.jobqueue.requirements.NetworkRequirement;
@ -94,7 +93,7 @@ public class MultiDeviceContactUpdateJob extends MasterSecretJob implements Inje
try { try {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactDataFile)); DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactDataFile));
Recipient recipient = RecipientFactory.getRecipientFor(context, address, false); Recipient recipient = Recipient.from(context, address, false);
Optional<IdentityDatabase.IdentityRecord> identityRecord = DatabaseFactory.getIdentityDatabase(context).getIdentity(address); Optional<IdentityDatabase.IdentityRecord> identityRecord = DatabaseFactory.getIdentityDatabase(context).getIdentity(address);
Optional<VerifiedMessage> verifiedMessage = getVerifiedMessage(recipient, identityRecord); Optional<VerifiedMessage> verifiedMessage = getVerifiedMessage(recipient, identityRecord);
@ -127,7 +126,7 @@ public class MultiDeviceContactUpdateJob extends MasterSecretJob implements Inje
for (ContactData contactData : contacts) { for (ContactData contactData : contacts) {
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactData.id)); Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactData.id));
Address address = Address.fromExternal(context, contactData.numbers.get(0).number); Address address = Address.fromExternal(context, contactData.numbers.get(0).number);
Recipient recipient = RecipientFactory.getRecipientFor(context, address, false); Recipient recipient = Recipient.from(context, address, false);
Optional<IdentityDatabase.IdentityRecord> identity = DatabaseFactory.getIdentityDatabase(context).getIdentity(address); Optional<IdentityDatabase.IdentityRecord> identity = DatabaseFactory.getIdentityDatabase(context).getIdentity(address);
Optional<VerifiedMessage> verified = getVerifiedMessage(recipient, identity); Optional<VerifiedMessage> verified = getVerifiedMessage(recipient, identity);
Optional<String> name = Optional.fromNullable(contactData.name); Optional<String> name = Optional.fromNullable(contactData.name);

View File

@ -37,7 +37,6 @@ import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage;
import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.service.WebRtcCallService; import org.thoughtcrime.securesms.service.WebRtcCallService;
import org.thoughtcrime.securesms.sms.IncomingEncryptedMessage; import org.thoughtcrime.securesms.sms.IncomingEncryptedMessage;
@ -84,7 +83,6 @@ import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage
import org.whispersystems.signalservice.api.push.SignalServiceAddress; import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -814,7 +812,7 @@ public class PushDecryptJob extends ContextJob {
{ {
database.setProfileKey(sourceAddress, message.getProfileKey().get()); database.setProfileKey(sourceAddress, message.getProfileKey().get());
Recipient recipient = RecipientFactory.getRecipientFor(context, sourceAddress, true); Recipient recipient = Recipient.from(context, sourceAddress, true);
ApplicationContext.getInstance(context).getJobManager().add(new RetrieveProfileJob(context, recipient)); ApplicationContext.getInstance(context).getJobManager().add(new RetrieveProfileJob(context, recipient));
} }
@ -833,17 +831,17 @@ public class PushDecryptJob extends ContextJob {
private Recipient getSyncMessageDestination(SentTranscriptMessage message) { private Recipient getSyncMessageDestination(SentTranscriptMessage message) {
if (message.getMessage().getGroupInfo().isPresent()) { if (message.getMessage().getGroupInfo().isPresent()) {
return RecipientFactory.getRecipientFor(context, Address.fromExternal(context, GroupUtil.getEncodedId(message.getMessage().getGroupInfo().get().getGroupId(), false)), false); return Recipient.from(context, Address.fromExternal(context, GroupUtil.getEncodedId(message.getMessage().getGroupInfo().get().getGroupId(), false)), false);
} else { } else {
return RecipientFactory.getRecipientFor(context, Address.fromExternal(context, message.getDestination().get()), false); return Recipient.from(context, Address.fromExternal(context, message.getDestination().get()), false);
} }
} }
private Recipient getMessageDestination(SignalServiceEnvelope envelope, SignalServiceDataMessage message) { private Recipient getMessageDestination(SignalServiceEnvelope envelope, SignalServiceDataMessage message) {
if (message.getGroupInfo().isPresent()) { if (message.getGroupInfo().isPresent()) {
return RecipientFactory.getRecipientFor(context, Address.fromExternal(context, GroupUtil.getEncodedId(message.getGroupInfo().get().getGroupId(), false)), false); return Recipient.from(context, Address.fromExternal(context, GroupUtil.getEncodedId(message.getGroupInfo().get().getGroupId(), false)), false);
} else { } else {
return RecipientFactory.getRecipientFor(context, Address.fromExternal(context, envelope.getSource()), false); return Recipient.from(context, Address.fromExternal(context, envelope.getSource()), false);
} }
} }
} }

View File

@ -9,7 +9,6 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId; import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.jobqueue.JobManager; import org.whispersystems.jobqueue.JobManager;
@ -32,7 +31,7 @@ public abstract class PushReceivedJob extends ContextJob {
if (!isActiveNumber(context, source)) { if (!isActiveNumber(context, source)) {
DatabaseFactory.getRecipientPreferenceDatabase(context).setRegistered(Util.asList(source), new LinkedList<>()); DatabaseFactory.getRecipientPreferenceDatabase(context).setRegistered(Util.asList(source), new LinkedList<>());
Recipient recipient = RecipientFactory.getRecipientFor(context, source, false); Recipient recipient = Recipient.from(context, source, false);
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, KeyCachingService.getMasterSecret(context), recipient)); ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, KeyCachingService.getMasterSecret(context), recipient));
} }
@ -46,7 +45,7 @@ public abstract class PushReceivedJob extends ContextJob {
} }
private void handleMessage(SignalServiceEnvelope envelope, Address source, boolean sendExplicitReceipt) { private void handleMessage(SignalServiceEnvelope envelope, Address source, boolean sendExplicitReceipt) {
Recipient recipients = RecipientFactory.getRecipientFor(context, source, false); Recipient recipients = Recipient.from(context, source, false);
JobManager jobManager = ApplicationContext.getInstance(context).getJobManager(); JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
if (!recipients.isBlocked()) { if (!recipients.isBlocked()) {

View File

@ -11,7 +11,6 @@ import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.Recipient
import org.thoughtcrime.securesms.dependencies.InjectableType; import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.profiles.AvatarHelper; import org.thoughtcrime.securesms.profiles.AvatarHelper;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.jobqueue.JobParameters; import org.whispersystems.jobqueue.JobParameters;
import org.whispersystems.jobqueue.requirements.NetworkRequirement; import org.whispersystems.jobqueue.requirements.NetworkRequirement;
@ -89,7 +88,7 @@ public class RetrieveProfileAvatarJob extends ContextJob implements InjectableTy
} }
database.setProfileAvatar(recipient.getAddress(), profileAvatar); database.setProfileAvatar(recipient.getAddress(), profileAvatar);
RecipientFactory.clearCache(context); Recipient.clearCache(context);
} }
@Override @Override

View File

@ -11,7 +11,6 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.dependencies.InjectableType; import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.service.MessageRetrievalService; import org.thoughtcrime.securesms.service.MessageRetrievalService;
import org.thoughtcrime.securesms.util.Base64; import org.thoughtcrime.securesms.util.Base64;
import org.thoughtcrime.securesms.util.IdentityUtil; import org.thoughtcrime.securesms.util.IdentityUtil;
@ -142,7 +141,7 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
if (!Util.equals(plaintextProfileName, recipientPreferences.get().getProfileName())) { if (!Util.equals(plaintextProfileName, recipientPreferences.get().getProfileName())) {
DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileName(recipient.getAddress(), plaintextProfileName); DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileName(recipient.getAddress(), plaintextProfileName);
RecipientFactory.clearCache(context); Recipient.clearCache(context);
} }
} catch (ProfileCipher.InvalidCiphertextException | IOException e) { } catch (ProfileCipher.InvalidCiphertextException | IOException e) {
Log.w(TAG, e); Log.w(TAG, e);

View File

@ -14,7 +14,6 @@ import org.thoughtcrime.securesms.database.EncryptingSmsDatabase;
import org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult; import org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult;
import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.sms.IncomingTextMessage; import org.thoughtcrime.securesms.sms.IncomingTextMessage;
import org.whispersystems.jobqueue.JobParameters; import org.whispersystems.jobqueue.JobParameters;
@ -85,7 +84,7 @@ public class SmsReceiveJob extends ContextJob {
private boolean isBlocked(IncomingTextMessage message) { private boolean isBlocked(IncomingTextMessage message) {
if (message.getSender() != null) { if (message.getSender() != null) {
Recipient recipient = RecipientFactory.getRecipientFor(context, message.getSender(), false); Recipient recipient = Recipient.from(context, message.getSender(), false);
return recipient.isBlocked(); return recipient.isBlocked();
} }

View File

@ -32,7 +32,6 @@ import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage; import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.whispersystems.libsignal.logging.Log; import org.whispersystems.libsignal.logging.Log;
@ -65,7 +64,7 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
final Address address = intent.getParcelableExtra(ADDRESS_EXTRA); final Address address = intent.getParcelableExtra(ADDRESS_EXTRA);
final long threadId = intent.getLongExtra(THREAD_ID_EXTRA, -1); final long threadId = intent.getLongExtra(THREAD_ID_EXTRA, -1);
final CharSequence responseText = getMessageText(intent); final CharSequence responseText = getMessageText(intent);
final Recipient recipient = RecipientFactory.getRecipientFor(context, address, false); final Recipient recipient = Recipient.from(context, address, false);
if (responseText != null) { if (responseText != null) {
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {

View File

@ -32,7 +32,6 @@ import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage; import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.libsignal.util.guava.Optional;
@ -71,7 +70,7 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(address); Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(address);
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1; int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0; long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;
Recipient recipient = RecipientFactory.getRecipientFor(context, address, false); Recipient recipient = Recipient.from(context, address, false);
if (recipient.isGroupRecipient()) { if (recipient.isGroupRecipient()) {
OutgoingMediaMessage reply = new OutgoingMediaMessage(recipient, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0); OutgoingMediaMessage reply = new OutgoingMediaMessage(recipient, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0);

View File

@ -16,6 +16,8 @@
*/ */
package org.thoughtcrime.securesms.recipients; package org.thoughtcrime.securesms.recipients;
import android.content.Context;
import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -27,6 +29,7 @@ import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto; import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory; import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.GroupDatabase;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.VibrateState; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.VibrateState;
import org.thoughtcrime.securesms.recipients.RecipientProvider.RecipientDetails; import org.thoughtcrime.securesms.recipients.RecipientProvider.RecipientDetails;
@ -45,7 +48,9 @@ import java.util.concurrent.ExecutionException;
public class Recipient implements RecipientModifiedListener { public class Recipient implements RecipientModifiedListener {
private final static String TAG = Recipient.class.getSimpleName(); public static final String RECIPIENT_CLEAR_ACTION = "org.thoughtcrime.securesms.database.RecipientFactory.CLEAR";
private static final String TAG = Recipient.class.getSimpleName();
private static final RecipientProvider provider = new RecipientProvider();
private final Set<RecipientModifiedListener> listeners = Collections.newSetFromMap(new WeakHashMap<RecipientModifiedListener, Boolean>()); private final Set<RecipientModifiedListener> listeners = Collections.newSetFromMap(new WeakHashMap<RecipientModifiedListener, Boolean>());
@ -68,6 +73,21 @@ public class Recipient implements RecipientModifiedListener {
@Nullable private MaterialColor color; @Nullable private MaterialColor color;
public static @NonNull Recipient from(@NonNull Context context, @NonNull Address address, boolean asynchronous) {
if (address == null) throw new AssertionError(address);
return provider.getRecipient(context, address, Optional.absent(), Optional.absent(), asynchronous);
}
public static @NonNull Recipient from(@NonNull Context context, @NonNull Address address, @NonNull Optional<RecipientsPreferences> preferences, @NonNull Optional<GroupDatabase.GroupRecord> groupRecord, boolean asynchronous) {
if (address == null) throw new AssertionError(address);
return provider.getRecipient(context, address, preferences, groupRecord, asynchronous);
}
public static void clearCache(Context context) {
provider.clearCache();
context.sendBroadcast(new Intent(RECIPIENT_CLEAR_ACTION));
}
Recipient(@NonNull Address address, Recipient(@NonNull Address address,
@Nullable Recipient stale, @Nullable Recipient stale,
@NonNull Optional<RecipientDetails> details, @NonNull Optional<RecipientDetails> details,

View File

@ -1,49 +0,0 @@
/**
* Copyright (C) 2011 Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms.recipients;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
import org.whispersystems.libsignal.util.guava.Optional;
public class RecipientFactory {
public static final String RECIPIENT_CLEAR_ACTION = "org.thoughtcrime.securesms.database.RecipientFactory.CLEAR";
private static final RecipientProvider provider = new RecipientProvider();
public static @NonNull Recipient getRecipientFor(@NonNull Context context, @NonNull Address address, boolean asynchronous) {
if (address == null) throw new AssertionError(address);
return provider.getRecipient(context, address, Optional.absent(), Optional.absent(), asynchronous);
}
public static @NonNull Recipient getRecipientFor(@NonNull Context context, @NonNull Address address, @NonNull Optional<RecipientsPreferences> preferences, @NonNull Optional<GroupRecord> groupRecord, boolean asynchronous) {
if (address == null) throw new AssertionError(address);
return provider.getRecipient(context, address, preferences, groupRecord, asynchronous);
}
public static void clearCache(Context context) {
provider.clearCache();
context.sendBroadcast(new Intent(RECIPIENT_CLEAR_ACTION));
}
}

View File

@ -21,7 +21,6 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.ThreadDatabase; import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.database.model.ThreadRecord; import org.thoughtcrime.securesms.database.model.ThreadRecord;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.BitmapUtil;
import java.util.LinkedList; import java.util.LinkedList;
@ -49,7 +48,7 @@ public class DirectShareService extends ChooserTargetService {
ThreadRecord record; ThreadRecord record;
while ((record = reader.getNext()) != null && results.size() < 10) { while ((record = reader.getNext()) != null && results.size() < 10) {
Recipient recipient = RecipientFactory.getRecipientFor(this, record.getRecipient().getAddress(), false); Recipient recipient = Recipient.from(this, record.getRecipient().getAddress(), false);
String name = recipient.toShortString(); String name = recipient.toShortString();
Drawable drawable = recipient.getContactPhoto().asDrawable(this, recipient.getColor().toConversationColor(this)); Drawable drawable = recipient.getContactPhoto().asDrawable(this, recipient.getColor().toConversationColor(this));
Bitmap avatar = BitmapUtil.createFromDrawable(drawable, 500, 500); Bitmap avatar = BitmapUtil.createFromDrawable(drawable, 500, 500);

View File

@ -13,7 +13,6 @@ import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage; import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.util.Rfc5724Uri; import org.thoughtcrime.securesms.util.Rfc5724Uri;
@ -53,7 +52,7 @@ public class QuickResponseService extends MasterSecretIntentService {
} }
Address address = Address.fromExternal(this, number); Address address = Address.fromExternal(this, number);
Recipient recipient = RecipientFactory.getRecipientFor(this, address, false); Recipient recipient = Recipient.from(this, address, false);
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(this).getRecipientsPreferences(recipient.getAddress()); Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(this).getRecipientsPreferences(recipient.getAddress());
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1; int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0; long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;

View File

@ -33,7 +33,6 @@ import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule.SignalM
import org.thoughtcrime.securesms.events.WebRtcViewModel; import org.thoughtcrime.securesms.events.WebRtcViewModel;
import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.FutureTaskListener; import org.thoughtcrime.securesms.util.FutureTaskListener;
import org.thoughtcrime.securesms.util.ListenableFutureTask; import org.thoughtcrime.securesms.util.ListenableFutureTask;
import org.thoughtcrime.securesms.util.ServiceUtil; import org.thoughtcrime.securesms.util.ServiceUtil;
@ -945,7 +944,7 @@ public class WebRtcCallService extends Service implements InjectableType, PeerCo
Address remoteAddress = intent.getParcelableExtra(EXTRA_REMOTE_ADDRESS); Address remoteAddress = intent.getParcelableExtra(EXTRA_REMOTE_ADDRESS);
if (remoteAddress == null) throw new AssertionError("No recipient in intent!"); if (remoteAddress == null) throw new AssertionError("No recipient in intent!");
return RecipientFactory.getRecipientFor(this, remoteAddress, true); return Recipient.from(this, remoteAddress, true);
} }
private long getCallId(Intent intent) { private long getCallId(Intent intent) {

View File

@ -8,7 +8,6 @@ import android.util.Log;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import java.io.IOException; import java.io.IOException;
@ -73,7 +72,7 @@ public class GroupUtil {
this.members = new LinkedList<>(); this.members = new LinkedList<>();
for (String member : groupContext.getMembersList()) { for (String member : groupContext.getMembersList()) {
this.members.add(RecipientFactory.getRecipientFor(context, Address.fromExternal(context, member), true)); this.members.add(Recipient.from(context, Address.fromExternal(context, member), true));
} }
} }
} }

View File

@ -21,7 +21,6 @@ import org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult;
import org.thoughtcrime.securesms.database.SmsDatabase; import org.thoughtcrime.securesms.database.SmsDatabase;
import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.sms.IncomingIdentityDefaultMessage; import org.thoughtcrime.securesms.sms.IncomingIdentityDefaultMessage;
import org.thoughtcrime.securesms.sms.IncomingIdentityUpdateMessage; import org.thoughtcrime.securesms.sms.IncomingIdentityUpdateMessage;
import org.thoughtcrime.securesms.sms.IncomingIdentityVerifiedMessage; import org.thoughtcrime.securesms.sms.IncomingIdentityVerifiedMessage;
@ -90,7 +89,7 @@ public class IdentityUtil {
smsDatabase.insertMessageInbox(incoming); smsDatabase.insertMessageInbox(incoming);
} else { } else {
Recipient groupRecipient = RecipientFactory.getRecipientFor(context, Address.fromSerialized(GroupUtil.getEncodedId(group.getGroupId(), false)), true); Recipient groupRecipient = Recipient.from(context, Address.fromSerialized(GroupUtil.getEncodedId(group.getGroupId(), false)), true);
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipient); long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipient);
OutgoingTextMessage outgoing ; OutgoingTextMessage outgoing ;
@ -170,7 +169,7 @@ public class IdentityUtil {
public static void processVerifiedMessage(Context context, MasterSecretUnion masterSecret, VerifiedMessage verifiedMessage) { public static void processVerifiedMessage(Context context, MasterSecretUnion masterSecret, VerifiedMessage verifiedMessage) {
synchronized (SESSION_LOCK) { synchronized (SESSION_LOCK) {
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context); IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
Recipient recipient = RecipientFactory.getRecipientFor(context, Address.fromExternal(context, verifiedMessage.getDestination()), true); Recipient recipient = Recipient.from(context, Address.fromExternal(context, verifiedMessage.getDestination()), true);
Optional<IdentityRecord> identityRecord = identityDatabase.getIdentity(recipient.getAddress()); Optional<IdentityRecord> identityRecord = identityDatabase.getIdentity(recipient.getAddress());
if (!identityRecord.isPresent() && verifiedMessage.getVerified() == VerifiedMessage.VerifiedState.DEFAULT) { if (!identityRecord.isPresent() && verifiedMessage.getVerified() == VerifiedMessage.VerifiedState.DEFAULT) {