mirror of
https://github.com/oxen-io/session-android.git
synced 2025-03-13 21:30:56 +00:00
Rename RecipientPreferences -> RecipientSettings
// FREEBIE
This commit is contained in:
parent
8e6ca53023
commit
d1790dfe17
@ -109,7 +109,7 @@ import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientPreferenceEvent;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.identity.IdentityRecordList;
|
||||
@ -574,7 +574,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(ConversationActivity.this)
|
||||
DatabaseFactory.getRecipientDatabase(ConversationActivity.this)
|
||||
.setExpireMessages(recipient, expirationTime);
|
||||
recipient.setExpireMessages(expirationTime);
|
||||
|
||||
@ -603,7 +603,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(ConversationActivity.this)
|
||||
DatabaseFactory.getRecipientDatabase(ConversationActivity.this)
|
||||
.setMuted(recipient, until);
|
||||
|
||||
return null;
|
||||
@ -623,7 +623,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(ConversationActivity.this)
|
||||
DatabaseFactory.getRecipientDatabase(ConversationActivity.this)
|
||||
.setMuted(recipient, 0);
|
||||
|
||||
return null;
|
||||
@ -644,7 +644,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(ConversationActivity.this)
|
||||
DatabaseFactory.getRecipientDatabase(ConversationActivity.this)
|
||||
.setBlocked(recipient, false);
|
||||
|
||||
ApplicationContext.getInstance(ConversationActivity.this)
|
||||
@ -1652,7 +1652,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
@Override
|
||||
protected Long doInBackground(OutgoingMediaMessage... messages) {
|
||||
if (initiating) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileSharing(recipient.getAddress(), true);
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getAddress(), true);
|
||||
}
|
||||
|
||||
return MessageSender.send(context, masterSecret, messages[0], threadId, forceSms, new SmsDatabase.InsertListener() {
|
||||
@ -1692,7 +1692,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
@Override
|
||||
protected Long doInBackground(OutgoingTextMessage... messages) {
|
||||
if (initiatingConversation) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileSharing(recipient.getAddress(), true);
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getAddress(), true);
|
||||
}
|
||||
|
||||
return MessageSender.send(context, masterSecret, messages[0], threadId, forceSms, new SmsDatabase.InsertListener() {
|
||||
@ -1724,7 +1724,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(ConversationActivity.this)
|
||||
DatabaseFactory.getRecipientDatabase(ConversationActivity.this)
|
||||
.setDefaultSubscriptionId(recipient, subscriptionId.or(-1));
|
||||
return null;
|
||||
}
|
||||
@ -1989,20 +1989,20 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
updateToggleButtonState();
|
||||
}
|
||||
|
||||
private class RecipientPreferencesTask extends AsyncTask<Recipient, Void, Pair<Recipient,RecipientsPreferences>> {
|
||||
private class RecipientPreferencesTask extends AsyncTask<Recipient, Void, Pair<Recipient,RecipientSettings>> {
|
||||
@Override
|
||||
protected Pair<Recipient, RecipientsPreferences> doInBackground(Recipient... recipient) {
|
||||
protected Pair<Recipient, RecipientSettings> doInBackground(Recipient... recipient) {
|
||||
if (recipient.length != 1 || recipient[0] == null) {
|
||||
throw new AssertionError("task needs exactly one Recipients object");
|
||||
}
|
||||
|
||||
Optional<RecipientsPreferences> prefs = DatabaseFactory.getRecipientPreferenceDatabase(ConversationActivity.this)
|
||||
.getRecipientsPreferences(recipient[0].getAddress());
|
||||
Optional<RecipientSettings> prefs = DatabaseFactory.getRecipientDatabase(ConversationActivity.this)
|
||||
.getRecipientSettings(recipient[0].getAddress());
|
||||
return new Pair<>(recipient[0], prefs.orNull());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(@NonNull Pair<Recipient, RecipientsPreferences> result) {
|
||||
protected void onPostExecute(@NonNull Pair<Recipient, RecipientSettings> result) {
|
||||
if (result.first == recipient) {
|
||||
updateInviteReminder(result.second != null && result.second.hasSeenInviteReminder());
|
||||
updateDefaultSubscriptionId(result.second != null ? result.second.getDefaultSubscriptionId() : Optional.<Integer>absent());
|
||||
|
@ -54,7 +54,7 @@ import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.groups.GroupManager;
|
||||
import org.thoughtcrime.securesms.groups.GroupManager.GroupActionResult;
|
||||
@ -168,7 +168,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private static boolean isActiveInDirectory(Context context, Recipient recipient) {
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipient.getAddress());
|
||||
Optional<RecipientSettings> preferences = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(recipient.getAddress());
|
||||
return preferences.isPresent() && preferences.get().isRegistered();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ import org.thoughtcrime.securesms.components.ContactFilterToolbar.OnFilterChange
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||
@ -230,14 +230,14 @@ public class InviteActivity extends PassphraseRequiredActionBarActivity implemen
|
||||
if (context == null) return null;
|
||||
|
||||
for (String number : numbers) {
|
||||
Recipient recipient = Recipient.from(context, Address.fromExternal(context, number), false);
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipient.getAddress());
|
||||
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
Recipient recipient = Recipient.from(context, Address.fromExternal(context, number), false);
|
||||
Optional<RecipientSettings> settings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(recipient.getAddress());
|
||||
int subscriptionId = settings.isPresent() ? settings.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
|
||||
MessageSender.send(context, masterSecret, new OutgoingTextMessage(recipient, message, subscriptionId), -1L, true, null);
|
||||
|
||||
if (recipient.getContactUri() != null) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setSeenInviteReminder(recipient, true);
|
||||
DatabaseFactory.getRecipientDatabase(context).setSeenInviteReminder(recipient, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
new AsyncTask<Uri, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Uri... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(getActivity())
|
||||
DatabaseFactory.getRecipientDatabase(getActivity())
|
||||
.setRingtone(recipient, params[0]);
|
||||
return null;
|
||||
}
|
||||
@ -376,7 +376,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(getActivity())
|
||||
DatabaseFactory.getRecipientDatabase(getActivity())
|
||||
.setVibrate(recipient, vibrateState);
|
||||
return null;
|
||||
}
|
||||
@ -403,7 +403,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
Context context = getActivity();
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context)
|
||||
DatabaseFactory.getRecipientDatabase(context)
|
||||
.setColor(recipient, selectedColor);
|
||||
|
||||
if (DirectoryHelper.getUserCapabilities(context, recipient) == DirectoryHelper.Capability.SUPPORTED) {
|
||||
@ -449,7 +449,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(getActivity())
|
||||
DatabaseFactory.getRecipientDatabase(getActivity())
|
||||
.setMuted(recipient, until);
|
||||
return null;
|
||||
}
|
||||
@ -523,7 +523,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
protected Void doInBackground(Void... params) {
|
||||
Context context = getActivity();
|
||||
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context)
|
||||
DatabaseFactory.getRecipientDatabase(context)
|
||||
.setBlocked(recipient, blocked);
|
||||
|
||||
ApplicationContext.getInstance(context)
|
||||
|
@ -23,7 +23,7 @@ public class InviteReminder extends Reminder {
|
||||
new AsyncTask<Void,Void,Void>() {
|
||||
|
||||
@Override protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setSeenInviteReminder(recipient, true);
|
||||
DatabaseFactory.getRecipientDatabase(context).setSeenInviteReminder(recipient, true);
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
|
@ -103,7 +103,7 @@ public class ContactAccessor {
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final String[] inProjection = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};
|
||||
|
||||
final List<Address> registeredAddresses = DatabaseFactory.getRecipientPreferenceDatabase(context).getRegistered();
|
||||
final List<Address> registeredAddresses = DatabaseFactory.getRecipientDatabase(context).getRegistered();
|
||||
final Collection<ContactData> lookupData = new ArrayList<>(registeredAddresses.size());
|
||||
|
||||
for (Address registeredAddress : registeredAddresses) {
|
||||
|
@ -182,7 +182,7 @@ public class DatabaseFactory {
|
||||
return getInstance(context).groupDatabase;
|
||||
}
|
||||
|
||||
public static RecipientDatabase getRecipientPreferenceDatabase(Context context) {
|
||||
public static RecipientDatabase getRecipientDatabase(Context context) {
|
||||
return getInstance(context).recipientDatabase;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class RecipientDatabase extends Database {
|
||||
}
|
||||
|
||||
|
||||
public Optional<RecipientsPreferences> getRecipientsPreferences(@NonNull Address address) {
|
||||
public Optional<RecipientSettings> getRecipientSettings(@NonNull Address address) {
|
||||
SQLiteDatabase database = databaseHelper.getReadableDatabase();
|
||||
Cursor cursor = null;
|
||||
|
||||
@ -129,7 +129,7 @@ public class RecipientDatabase extends Database {
|
||||
}
|
||||
}
|
||||
|
||||
Optional<RecipientsPreferences> getRecipientPreferences(@NonNull Cursor cursor) {
|
||||
Optional<RecipientSettings> getRecipientPreferences(@NonNull Cursor cursor) {
|
||||
boolean blocked = cursor.getInt(cursor.getColumnIndexOrThrow(BLOCK)) == 1;
|
||||
String notification = cursor.getString(cursor.getColumnIndexOrThrow(NOTIFICATION));
|
||||
int vibrateState = cursor.getInt(cursor.getColumnIndexOrThrow(VIBRATE));
|
||||
@ -165,12 +165,12 @@ public class RecipientDatabase extends Database {
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.of(new RecipientsPreferences(blocked, muteUntil,
|
||||
VibrateState.fromId(vibrateState),
|
||||
notificationUri, color, seenInviteReminder,
|
||||
defaultSubscriptionId, expireMessages, registered,
|
||||
profileKey, systemDisplayName, signalProfileName,
|
||||
signalProfileAvatar, profileSharing));
|
||||
return Optional.of(new RecipientSettings(blocked, muteUntil,
|
||||
VibrateState.fromId(vibrateState),
|
||||
notificationUri, color, seenInviteReminder,
|
||||
defaultSubscriptionId, expireMessages, registered,
|
||||
profileKey, systemDisplayName, signalProfileName,
|
||||
signalProfileAvatar, profileSharing));
|
||||
}
|
||||
|
||||
public BulkOperationsHandle resetAllDisplayNames() {
|
||||
@ -359,7 +359,7 @@ public class RecipientDatabase extends Database {
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecipientsPreferences {
|
||||
public static class RecipientSettings {
|
||||
private final boolean blocked;
|
||||
private final long muteUntil;
|
||||
private final VibrateState vibrateState;
|
||||
@ -375,19 +375,19 @@ public class RecipientDatabase extends Database {
|
||||
private final String signalProfileAvatar;
|
||||
private final boolean profileSharing;
|
||||
|
||||
RecipientsPreferences(boolean blocked, long muteUntil,
|
||||
@NonNull VibrateState vibrateState,
|
||||
@Nullable Uri notification,
|
||||
@Nullable MaterialColor color,
|
||||
boolean seenInviteReminder,
|
||||
int defaultSubscriptionId,
|
||||
int expireMessages,
|
||||
boolean registered,
|
||||
@Nullable byte[] profileKey,
|
||||
@Nullable String systemDisplayName,
|
||||
@Nullable String signalProfileName,
|
||||
@Nullable String signalProfileAvatar,
|
||||
boolean profileSharing)
|
||||
RecipientSettings(boolean blocked, long muteUntil,
|
||||
@NonNull VibrateState vibrateState,
|
||||
@Nullable Uri notification,
|
||||
@Nullable MaterialColor color,
|
||||
boolean seenInviteReminder,
|
||||
int defaultSubscriptionId,
|
||||
int expireMessages,
|
||||
boolean registered,
|
||||
@Nullable byte[] profileKey,
|
||||
@Nullable String systemDisplayName,
|
||||
@Nullable String signalProfileName,
|
||||
@Nullable String signalProfileAvatar,
|
||||
boolean profileSharing)
|
||||
{
|
||||
this.blocked = blocked;
|
||||
this.muteUntil = muteUntil;
|
||||
|
@ -559,7 +559,7 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
}
|
||||
|
||||
if (message.getSubscriptionId() != -1) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setDefaultSubscriptionId(recipient, message.getSubscriptionId());
|
||||
DatabaseFactory.getRecipientDatabase(context).setDefaultSubscriptionId(recipient, message.getSubscriptionId());
|
||||
}
|
||||
|
||||
notifyConversationListeners(threadId);
|
||||
|
@ -33,7 +33,7 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.database.model.DisplayRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
@ -620,18 +620,18 @@ public class ThreadDatabase extends Database {
|
||||
int distributionType = cursor.getInt(cursor.getColumnIndexOrThrow(ThreadDatabase.TYPE));
|
||||
Address address = Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ThreadDatabase.ADDRESS)));
|
||||
|
||||
Optional<RecipientsPreferences> preferences;
|
||||
Optional<GroupRecord> groupRecord;
|
||||
Optional<RecipientSettings> settings;
|
||||
Optional<GroupRecord> groupRecord;
|
||||
|
||||
if (distributionType != DistributionTypes.ARCHIVE) {
|
||||
preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientPreferences(cursor);
|
||||
settings = DatabaseFactory.getRecipientDatabase(context).getRecipientPreferences(cursor);
|
||||
groupRecord = DatabaseFactory.getGroupDatabase(context).getGroup(cursor);
|
||||
} else {
|
||||
preferences = Optional.absent();
|
||||
settings = Optional.absent();
|
||||
groupRecord = Optional.absent();
|
||||
}
|
||||
|
||||
Recipient recipient = Recipient.from(context, address, preferences, groupRecord, true);
|
||||
Recipient recipient = Recipient.from(context, address, settings, groupRecord, true);
|
||||
DisplayRecord.Body body = getPlaintextBody(cursor);
|
||||
long date = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.DATE));
|
||||
long count = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.MESSAGE_COUNT));
|
||||
|
@ -14,7 +14,7 @@ public class BlockedContactsLoader extends AbstractCursorLoader {
|
||||
|
||||
@Override
|
||||
public Cursor getCursor() {
|
||||
return DatabaseFactory.getRecipientPreferenceDatabase(getContext())
|
||||
return DatabaseFactory.getRecipientDatabase(getContext())
|
||||
.getBlocked();
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class GroupManager {
|
||||
|
||||
if (!mms) {
|
||||
groupDatabase.updateAvatar(groupId, avatarBytes);
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileSharing(Address.fromSerialized(groupId), true);
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(Address.fromSerialized(groupId), true);
|
||||
return sendGroupUpdate(context, masterSecret, groupId, memberAddresses, name, avatarBytes);
|
||||
} else {
|
||||
Recipient groupRecipient = Recipient.from(context, Address.fromSerialized(groupId), true);
|
||||
|
@ -45,7 +45,7 @@ public class MultiDeviceBlockedUpdateJob extends MasterSecretJob implements Inje
|
||||
public void onRun(MasterSecret masterSecret)
|
||||
throws IOException, UntrustedIdentityException
|
||||
{
|
||||
RecipientDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
|
||||
RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context);
|
||||
SignalServiceMessageSender messageSender = messageSenderFactory.create();
|
||||
BlockedReader reader = database.readerForBlocked(database.getBlocked());
|
||||
List<String> blocked = new LinkedList<>();
|
||||
|
@ -26,7 +26,7 @@ import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||
import org.thoughtcrime.securesms.database.PushDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.groups.GroupMessageProcessor;
|
||||
@ -391,7 +391,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
|
||||
database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);
|
||||
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setExpireMessages(recipient, message.getExpiresInSeconds());
|
||||
DatabaseFactory.getRecipientDatabase(context).setExpireMessages(recipient, message.getExpiresInSeconds());
|
||||
|
||||
if (smsMessageId.isPresent()) {
|
||||
DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
|
||||
@ -549,7 +549,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
|
||||
database.markAsSent(messageId, true);
|
||||
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setExpireMessages(recipient, message.getMessage().getExpiresInSeconds());
|
||||
DatabaseFactory.getRecipientDatabase(context).setExpireMessages(recipient, message.getMessage().getExpiresInSeconds());
|
||||
|
||||
if (smsMessageId.isPresent()) {
|
||||
DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
|
||||
@ -803,12 +803,12 @@ public class PushDecryptJob extends ContextJob {
|
||||
private void handleProfileKey(@NonNull SignalServiceEnvelope envelope,
|
||||
@NonNull SignalServiceDataMessage message)
|
||||
{
|
||||
RecipientDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
|
||||
Address sourceAddress = Address.fromExternal(context, envelope.getSource());
|
||||
Optional<RecipientsPreferences> preferences = database.getRecipientsPreferences(sourceAddress);
|
||||
RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context);
|
||||
Address sourceAddress = Address.fromExternal(context, envelope.getSource());
|
||||
Optional<RecipientSettings> settings = database.getRecipientSettings(sourceAddress);
|
||||
|
||||
if (!preferences.isPresent() || preferences.get().getProfileKey() == null ||
|
||||
!MessageDigest.isEqual(message.getProfileKey().get(), preferences.get().getProfileKey()))
|
||||
if (!settings.isPresent() || settings.get().getProfileKey() == null ||
|
||||
!MessageDigest.isEqual(message.getProfileKey().get(), settings.get().getProfileKey()))
|
||||
{
|
||||
database.setProfileKey(sourceAddress, message.getProfileKey().get());
|
||||
|
||||
|
@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
@ -30,7 +30,7 @@ public abstract class PushReceivedJob extends ContextJob {
|
||||
Address source = Address.fromExternal(context, envelope.getSource());
|
||||
|
||||
if (!isActiveNumber(context, source)) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setRegistered(Util.asList(source), new LinkedList<>());
|
||||
DatabaseFactory.getRecipientDatabase(context).setRegistered(Util.asList(source), new LinkedList<>());
|
||||
Recipient recipient = Recipient.from(context, source, false);
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, KeyCachingService.getMasterSecret(context), recipient));
|
||||
}
|
||||
@ -69,8 +69,8 @@ public abstract class PushReceivedJob extends ContextJob {
|
||||
}
|
||||
|
||||
private boolean isActiveNumber(Context context, Address address) {
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(address);
|
||||
return preferences.isPresent() && preferences.get().isRegistered();
|
||||
Optional<RecipientSettings> settings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(address);
|
||||
return settings.isPresent() && settings.get().isRegistered();
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
@ -66,8 +66,8 @@ public abstract class PushSendJob extends SendJob {
|
||||
|
||||
protected Optional<byte[]> getProfileKey(Address address) {
|
||||
try {
|
||||
Optional<RecipientsPreferences> recipientsPreferences = DatabaseFactory.getRecipientPreferenceDatabase(context)
|
||||
.getRecipientsPreferences(address);
|
||||
Optional<RecipientSettings> recipientsPreferences = DatabaseFactory.getRecipientDatabase(context)
|
||||
.getRecipientSettings(address);
|
||||
|
||||
if (!recipientsPreferences.isPresent()) return Optional.absent();
|
||||
|
||||
|
@ -7,7 +7,7 @@ import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@ -51,20 +51,20 @@ public class RetrieveProfileAvatarJob extends ContextJob implements InjectableTy
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException {
|
||||
RecipientDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
|
||||
Optional<RecipientsPreferences> recipientsPreferences = database.getRecipientsPreferences(recipient.getAddress());
|
||||
RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context);
|
||||
Optional<RecipientSettings> recipientSettings = database.getRecipientSettings(recipient.getAddress());
|
||||
|
||||
if (!recipientsPreferences.isPresent()) {
|
||||
if (!recipientSettings.isPresent()) {
|
||||
Log.w(TAG, "Recipient preference row is gone!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (recipientsPreferences.get().getProfileKey() == null) {
|
||||
if (recipientSettings.get().getProfileKey() == null) {
|
||||
Log.w(TAG, "Recipient profile key is gone!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Util.equals(profileAvatar, recipientsPreferences.get().getProfileAvatar())) {
|
||||
if (Util.equals(profileAvatar, recipientSettings.get().getProfileAvatar())) {
|
||||
Log.w(TAG, "Already retrieved profile avatar: " + profileAvatar);
|
||||
return;
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class RetrieveProfileAvatarJob extends ContextJob implements InjectableTy
|
||||
File downloadDestination = File.createTempFile("avatar", "jpg", context.getCacheDir());
|
||||
|
||||
try {
|
||||
InputStream avatarStream = receiver.retrieveProfileAvatar(profileAvatar, downloadDestination, recipientsPreferences.get().getProfileKey(), MAX_PROFILE_SIZE_BYTES);
|
||||
InputStream avatarStream = receiver.retrieveProfileAvatar(profileAvatar, downloadDestination, recipientSettings.get().getProfileKey(), MAX_PROFILE_SIZE_BYTES);
|
||||
File decryptDestination = File.createTempFile("avatar", "jpg", context.getCacheDir());
|
||||
|
||||
Util.copy(avatarStream, new FileOutputStream(decryptDestination));
|
||||
|
@ -8,7 +8,7 @@ import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.service.MessageRetrievalService;
|
||||
@ -71,13 +71,13 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
|
||||
private void handleIndividualRecipient(Recipient recipient)
|
||||
throws IOException, InvalidKeyException, InvalidNumberException
|
||||
{
|
||||
String number = recipient.getAddress().toPhoneString();
|
||||
SignalServiceProfile profile = retrieveProfile(number);
|
||||
Optional<RecipientsPreferences> recipientPreferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipient.getAddress());
|
||||
String number = recipient.getAddress().toPhoneString();
|
||||
SignalServiceProfile profile = retrieveProfile(number);
|
||||
Optional<RecipientSettings> recipientSettings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(recipient.getAddress());
|
||||
|
||||
setIdentityKey(recipient, profile.getIdentityKey());
|
||||
setProfileName(recipient, recipientPreferences, profile.getName());
|
||||
setProfileAvatar(recipient, recipientPreferences, profile.getAvatar());
|
||||
setProfileName(recipient, recipientSettings, profile.getName());
|
||||
setProfileAvatar(recipient, recipientSettings, profile.getAvatar());
|
||||
}
|
||||
|
||||
private void handleGroupRecipient(Recipient group)
|
||||
@ -127,7 +127,7 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
|
||||
}
|
||||
}
|
||||
|
||||
private void setProfileName(Recipient recipient, Optional<RecipientsPreferences> recipientPreferences, String profileName) {
|
||||
private void setProfileName(Recipient recipient, Optional<RecipientSettings> recipientPreferences, String profileName) {
|
||||
try {
|
||||
if (!recipientPreferences.isPresent()) return;
|
||||
if (recipientPreferences.get().getProfileKey() == null) return;
|
||||
@ -140,7 +140,7 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
|
||||
}
|
||||
|
||||
if (!Util.equals(plaintextProfileName, recipientPreferences.get().getProfileName())) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileName(recipient.getAddress(), plaintextProfileName);
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileName(recipient.getAddress(), plaintextProfileName);
|
||||
Recipient.clearCache(context);
|
||||
}
|
||||
} catch (ProfileCipher.InvalidCiphertextException | IOException e) {
|
||||
@ -148,7 +148,7 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
|
||||
}
|
||||
}
|
||||
|
||||
private void setProfileAvatar(Recipient recipient, Optional<RecipientsPreferences> recipientPreferences, String profileAvatar) {
|
||||
private void setProfileAvatar(Recipient recipient, Optional<RecipientSettings> recipientPreferences, String profileAvatar) {
|
||||
if (!recipientPreferences.isPresent()) return;
|
||||
if (recipientPreferences.get().getProfileKey() == null) return;
|
||||
|
||||
|
@ -29,7 +29,7 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
@ -73,9 +73,9 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
long replyThreadId;
|
||||
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(address);
|
||||
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;
|
||||
Optional<RecipientSettings> settings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(address);
|
||||
int subscriptionId = settings.isPresent() ? settings.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
long expiresIn = settings.isPresent() ? settings.get().getExpireMessages() * 1000 : 0;
|
||||
|
||||
if (recipient.isGroupRecipient()) {
|
||||
Log.w("AndroidAutoReplyReceiver", "GroupRecipient, Sending media message");
|
||||
|
@ -29,7 +29,7 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
@ -67,9 +67,9 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
protected Void doInBackground(Void... params) {
|
||||
long threadId;
|
||||
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(address);
|
||||
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;
|
||||
Optional<RecipientSettings> settings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(address);
|
||||
int subscriptionId = settings.isPresent() ? settings.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
long expiresIn = settings.isPresent() ? settings.get().getExpireMessages() * 1000 : 0;
|
||||
Recipient recipient = Recipient.from(context, address, false);
|
||||
|
||||
if (recipient.isGroupRecipient()) {
|
||||
|
@ -48,7 +48,7 @@ public class UnknownSenderView extends FrameLayout {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setBlocked(recipient, true);
|
||||
DatabaseFactory.getRecipientDatabase(context).setBlocked(recipient, true);
|
||||
if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true);
|
||||
return null;
|
||||
}
|
||||
@ -94,7 +94,7 @@ public class UnknownSenderView extends FrameLayout {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileSharing(recipient.getAddress(), true);
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getAddress(), true);
|
||||
if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true);
|
||||
return null;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientProvider.RecipientDetails;
|
||||
import org.thoughtcrime.securesms.util.FutureTaskListener;
|
||||
@ -77,9 +77,9 @@ public class Recipient implements RecipientModifiedListener {
|
||||
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) {
|
||||
public static @NonNull Recipient from(@NonNull Context context, @NonNull Address address, @NonNull Optional<RecipientSettings> settings, @NonNull Optional<GroupDatabase.GroupRecord> groupRecord, boolean asynchronous) {
|
||||
if (address == null) throw new AssertionError(address);
|
||||
return provider.getRecipient(context, address, preferences, groupRecord, asynchronous);
|
||||
return provider.getRecipient(context, address, settings, groupRecord, asynchronous);
|
||||
}
|
||||
|
||||
public static void clearCache(Context context) {
|
||||
|
@ -33,7 +33,7 @@ import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
||||
import org.thoughtcrime.securesms.util.LRUCache;
|
||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
||||
@ -68,18 +68,18 @@ class RecipientProvider {
|
||||
null, null));
|
||||
}};
|
||||
|
||||
@NonNull Recipient getRecipient(Context context, Address address, Optional<RecipientsPreferences> preferences, Optional<GroupRecord> groupRecord, boolean asynchronous) {
|
||||
@NonNull Recipient getRecipient(Context context, Address address, Optional<RecipientSettings> settings, Optional<GroupRecord> groupRecord, boolean asynchronous) {
|
||||
Recipient cachedRecipient = recipientCache.get(address);
|
||||
if (cachedRecipient != null && !cachedRecipient.isStale() && (asynchronous || !cachedRecipient.isResolving())) {
|
||||
return cachedRecipient;
|
||||
}
|
||||
|
||||
Optional<RecipientDetails> prefetchedRecipientDetails = createPrefetchedRecipientDetails(context, address, preferences, groupRecord);
|
||||
Optional<RecipientDetails> prefetchedRecipientDetails = createPrefetchedRecipientDetails(context, address, settings, groupRecord);
|
||||
|
||||
if (asynchronous) {
|
||||
cachedRecipient = new Recipient(address, cachedRecipient, prefetchedRecipientDetails, getRecipientDetailsAsync(context, address, preferences, groupRecord));
|
||||
cachedRecipient = new Recipient(address, cachedRecipient, prefetchedRecipientDetails, getRecipientDetailsAsync(context, address, settings, groupRecord));
|
||||
} else {
|
||||
cachedRecipient = new Recipient(address, getRecipientDetailsSync(context, address, preferences, groupRecord, false));
|
||||
cachedRecipient = new Recipient(address, getRecipientDetailsSync(context, address, settings, groupRecord, false));
|
||||
}
|
||||
|
||||
recipientCache.set(address, cachedRecipient);
|
||||
@ -91,24 +91,24 @@ class RecipientProvider {
|
||||
}
|
||||
|
||||
private @NonNull Optional<RecipientDetails> createPrefetchedRecipientDetails(@NonNull Context context, @NonNull Address address,
|
||||
@NonNull Optional<RecipientsPreferences> preferences,
|
||||
@NonNull Optional<RecipientSettings> settings,
|
||||
@NonNull Optional<GroupRecord> groupRecord)
|
||||
{
|
||||
if (address.isGroup() && preferences.isPresent() && groupRecord.isPresent()) {
|
||||
return Optional.of(getGroupRecipientDetails(context, address, groupRecord, preferences, true));
|
||||
} else if (!address.isGroup() && preferences.isPresent()) {
|
||||
return Optional.of(new RecipientDetails(null, null, null, ContactPhotoFactory.getLoadingPhoto(), preferences.get(), null));
|
||||
if (address.isGroup() && settings.isPresent() && groupRecord.isPresent()) {
|
||||
return Optional.of(getGroupRecipientDetails(context, address, groupRecord, settings, true));
|
||||
} else if (!address.isGroup() && settings.isPresent()) {
|
||||
return Optional.of(new RecipientDetails(null, null, null, ContactPhotoFactory.getLoadingPhoto(), settings.get(), null));
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
private @NonNull ListenableFutureTask<RecipientDetails> getRecipientDetailsAsync(final Context context, final @NonNull Address address, final @NonNull Optional<RecipientsPreferences> preferences, final @NonNull Optional<GroupRecord> groupRecord)
|
||||
private @NonNull ListenableFutureTask<RecipientDetails> getRecipientDetailsAsync(final Context context, final @NonNull Address address, final @NonNull Optional<RecipientSettings> settings, final @NonNull Optional<GroupRecord> groupRecord)
|
||||
{
|
||||
Callable<RecipientDetails> task = new Callable<RecipientDetails>() {
|
||||
@Override
|
||||
public RecipientDetails call() throws Exception {
|
||||
return getRecipientDetailsSync(context, address, preferences, groupRecord, true);
|
||||
return getRecipientDetailsSync(context, address, settings, groupRecord, true);
|
||||
}
|
||||
};
|
||||
|
||||
@ -117,14 +117,14 @@ class RecipientProvider {
|
||||
return future;
|
||||
}
|
||||
|
||||
private @NonNull RecipientDetails getRecipientDetailsSync(Context context, @NonNull Address address, Optional<RecipientsPreferences> preferences, Optional<GroupRecord> groupRecord, boolean nestedAsynchronous) {
|
||||
if (address.isGroup()) return getGroupRecipientDetails(context, address, groupRecord, preferences, nestedAsynchronous);
|
||||
else return getIndividualRecipientDetails(context, address, preferences);
|
||||
private @NonNull RecipientDetails getRecipientDetailsSync(Context context, @NonNull Address address, Optional<RecipientSettings> settings, Optional<GroupRecord> groupRecord, boolean nestedAsynchronous) {
|
||||
if (address.isGroup()) return getGroupRecipientDetails(context, address, groupRecord, settings, nestedAsynchronous);
|
||||
else return getIndividualRecipientDetails(context, address, settings);
|
||||
}
|
||||
|
||||
private @NonNull RecipientDetails getIndividualRecipientDetails(Context context, @NonNull Address address, Optional<RecipientsPreferences> preferences) {
|
||||
if (!preferences.isPresent()) {
|
||||
preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(address);
|
||||
private @NonNull RecipientDetails getIndividualRecipientDetails(Context context, @NonNull Address address, Optional<RecipientSettings> settings) {
|
||||
if (!settings.isPresent()) {
|
||||
settings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(address);
|
||||
}
|
||||
|
||||
if (address.isPhone() && !TextUtils.isEmpty(address.toPhoneString())) {
|
||||
@ -142,7 +142,7 @@ class RecipientProvider {
|
||||
address,
|
||||
name);
|
||||
|
||||
return new RecipientDetails(cursor.getString(0), cursor.getString(4), contactUri, contactPhoto, preferences.orNull(), null);
|
||||
return new RecipientDetails(cursor.getString(0), cursor.getString(4), contactUri, contactPhoto, settings.orNull(), null);
|
||||
} else {
|
||||
Log.w(TAG, "resultNumber is null");
|
||||
}
|
||||
@ -154,16 +154,16 @@ class RecipientProvider {
|
||||
}
|
||||
|
||||
if (STATIC_DETAILS.containsKey(address.serialize())) return STATIC_DETAILS.get(address.serialize());
|
||||
else return new RecipientDetails(null, null, null, ContactPhotoFactory.getSignalAvatarContactPhoto(context, address, null, context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size)), preferences.orNull(), null);
|
||||
else return new RecipientDetails(null, null, null, ContactPhotoFactory.getSignalAvatarContactPhoto(context, address, null, context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size)), settings.orNull(), null);
|
||||
}
|
||||
|
||||
private @NonNull RecipientDetails getGroupRecipientDetails(Context context, Address groupId, Optional<GroupRecord> groupRecord, Optional<RecipientsPreferences> preferences, boolean asynchronous) {
|
||||
private @NonNull RecipientDetails getGroupRecipientDetails(Context context, Address groupId, Optional<GroupRecord> groupRecord, Optional<RecipientSettings> settings, boolean asynchronous) {
|
||||
if (!groupRecord.isPresent()) {
|
||||
groupRecord = DatabaseFactory.getGroupDatabase(context).getGroup(groupId.toGroupString());
|
||||
}
|
||||
|
||||
if (!preferences.isPresent()) {
|
||||
preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(groupId);
|
||||
if (!settings.isPresent()) {
|
||||
settings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(groupId);
|
||||
}
|
||||
|
||||
if (groupRecord.isPresent()) {
|
||||
@ -180,10 +180,10 @@ class RecipientProvider {
|
||||
title = context.getString(R.string.RecipientProvider_unnamed_group);;
|
||||
}
|
||||
|
||||
return new RecipientDetails(title, null, null, contactPhoto, preferences.orNull(), members);
|
||||
return new RecipientDetails(title, null, null, contactPhoto, settings.orNull(), members);
|
||||
}
|
||||
|
||||
return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), null, null, ContactPhotoFactory.getDefaultGroupPhoto(), preferences.orNull(), null);
|
||||
return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), null, null, ContactPhotoFactory.getDefaultGroupPhoto(), settings.orNull(), null);
|
||||
}
|
||||
|
||||
static class RecipientDetails {
|
||||
@ -202,22 +202,22 @@ class RecipientProvider {
|
||||
|
||||
public RecipientDetails(@Nullable String name, @Nullable String customLabel,
|
||||
@Nullable Uri contactUri, @NonNull ContactPhoto avatar,
|
||||
@Nullable RecipientsPreferences preferences,
|
||||
@Nullable RecipientSettings settings,
|
||||
@Nullable List<Recipient> participants)
|
||||
{
|
||||
this.customLabel = customLabel;
|
||||
this.avatar = avatar;
|
||||
this.contactUri = contactUri;
|
||||
this.color = preferences != null ? preferences.getColor() : null;
|
||||
this.ringtone = preferences != null ? preferences.getRingtone() : null;
|
||||
this.mutedUntil = preferences != null ? preferences.getMuteUntil() : 0;
|
||||
this.vibrateState = preferences != null ? preferences.getVibrateState() : null;
|
||||
this.blocked = preferences != null && preferences.isBlocked();
|
||||
this.expireMessages = preferences != null ? preferences.getExpireMessages() : 0;
|
||||
this.color = settings != null ? settings.getColor() : null;
|
||||
this.ringtone = settings != null ? settings.getRingtone() : null;
|
||||
this.mutedUntil = settings != null ? settings.getMuteUntil() : 0;
|
||||
this.vibrateState = settings != null ? settings.getVibrateState() : null;
|
||||
this.blocked = settings != null && settings.isBlocked();
|
||||
this.expireMessages = settings != null ? settings.getExpireMessages() : 0;
|
||||
this.participants = participants == null ? new LinkedList<Recipient>() : participants;
|
||||
this.profileName = preferences != null ? preferences.getProfileName() : null;
|
||||
this.profileName = settings != null ? settings.getProfileName() : null;
|
||||
|
||||
if (name == null && preferences != null) this.name = preferences.getSystemDisplayName();
|
||||
if (name == null && settings != null) this.name = settings.getSystemDisplayName();
|
||||
else this.name = name;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||
@ -51,11 +51,11 @@ public class QuickResponseService extends MasterSecretIntentService {
|
||||
number = URLDecoder.decode(number);
|
||||
}
|
||||
|
||||
Address address = Address.fromExternal(this, number);
|
||||
Recipient recipient = Recipient.from(this, address, false);
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(this).getRecipientsPreferences(recipient.getAddress());
|
||||
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;
|
||||
Address address = Address.fromExternal(this, number);
|
||||
Recipient recipient = Recipient.from(this, address, false);
|
||||
Optional<RecipientSettings> settings = DatabaseFactory.getRecipientDatabase(this).getRecipientSettings(recipient.getAddress());
|
||||
int subscriptionId = settings.isPresent() ? settings.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
long expiresIn = settings.isPresent() ? settings.get().getExpireMessages() * 1000 : 0;
|
||||
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
MessageSender.send(this, masterSecret, new OutgoingTextMessage(recipient, content, expiresIn, subscriptionId), -1, false, null);
|
||||
|
@ -28,7 +28,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.EncryptingSmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
@ -265,8 +265,8 @@ public class MessageSender {
|
||||
}
|
||||
|
||||
private static boolean isPushDestination(Context context, Address destination) {
|
||||
RecipientDatabase recipientsDatabase = DatabaseFactory.getRecipientPreferenceDatabase(context);
|
||||
Optional<RecipientsPreferences> recipientPreferences = recipientsDatabase.getRecipientsPreferences(destination);
|
||||
RecipientDatabase recipientsDatabase = DatabaseFactory.getRecipientDatabase(context);
|
||||
Optional<RecipientSettings> recipientPreferences = recipientsDatabase.getRecipientSettings(destination);
|
||||
|
||||
if (recipientPreferences.isPresent()) {
|
||||
return recipientPreferences.get().isRegistered();
|
||||
|
@ -25,7 +25,7 @@ import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
import org.thoughtcrime.securesms.push.AccountManagerFactory;
|
||||
@ -75,7 +75,7 @@ public class DirectoryHelper {
|
||||
return new RefreshResult(new LinkedList<>(), false);
|
||||
}
|
||||
|
||||
RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientPreferenceDatabase(context);
|
||||
RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
|
||||
Set<Address> eligibleContactNumbers = recipientDatabase.getAllRecipients();
|
||||
eligibleContactNumbers.addAll(ContactAccessor.getInstance().getAllContactsWithNumbers(context));
|
||||
|
||||
@ -104,7 +104,7 @@ public class DirectoryHelper {
|
||||
@NonNull Recipient recipient)
|
||||
throws IOException
|
||||
{
|
||||
RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientPreferenceDatabase(context);
|
||||
RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
|
||||
SignalServiceAccountManager accountManager = AccountManagerFactory.createManager(context);
|
||||
String number = recipient.getAddress().serialize();
|
||||
Optional<ContactTokenDetails> details = accountManager.getContact(number);
|
||||
@ -146,12 +146,12 @@ public class DirectoryHelper {
|
||||
return Capability.SUPPORTED;
|
||||
}
|
||||
|
||||
final RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientPreferenceDatabase(context);
|
||||
final Optional<RecipientsPreferences> recipientPreferences = recipientDatabase.getRecipientsPreferences(recipient.getAddress());
|
||||
final RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
|
||||
final Optional<RecipientSettings> recipientSettings = recipientDatabase.getRecipientSettings(recipient.getAddress());
|
||||
|
||||
if (recipientPreferences.isPresent() && recipientPreferences.get().isRegistered()) return Capability.SUPPORTED;
|
||||
else if (recipientPreferences.isPresent()) return Capability.UNSUPPORTED;
|
||||
else return Capability.UNKNOWN;
|
||||
if (recipientSettings.isPresent() && recipientSettings.get().isRegistered()) return Capability.SUPPORTED;
|
||||
else if (recipientSettings.isPresent()) return Capability.UNSUPPORTED;
|
||||
else return Capability.UNKNOWN;
|
||||
}
|
||||
|
||||
private static @NonNull RefreshResult updateContactsDatabase(@NonNull Context context, @NonNull List<Address> activeAddresses, boolean removeMissing) {
|
||||
@ -163,7 +163,7 @@ public class DirectoryHelper {
|
||||
.setRegisteredUsers(account.get().getAccount(), activeAddresses, removeMissing);
|
||||
|
||||
Cursor cursor = ContactAccessor.getInstance().getAllSystemContacts(context);
|
||||
RecipientDatabase.BulkOperationsHandle handle = DatabaseFactory.getRecipientPreferenceDatabase(context).resetAllDisplayNames();
|
||||
RecipientDatabase.BulkOperationsHandle handle = DatabaseFactory.getRecipientDatabase(context).resetAllDisplayNames();
|
||||
|
||||
try {
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user