mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 04:39:42 +00:00
Remove the Canonical Address Database
This was a holdover from Signal's origins as a pure SMS app. It causes problems, depends on undefined device specific behavior, and should no longer be necessary now that we have all the information we need to E164 all numbers. // FREEBIE
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
|
||||
package org.thoughtcrime.securesms.notifications;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
@@ -27,10 +26,9 @@ import android.support.v4.app.RemoteInput;
|
||||
|
||||
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.MessagingDatabase;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
@@ -48,11 +46,11 @@ import java.util.List;
|
||||
*/
|
||||
public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
public static final String TAG = AndroidAutoReplyReceiver.class.getSimpleName();
|
||||
public static final String REPLY_ACTION = "org.thoughtcrime.securesms.notifications.ANDROID_AUTO_REPLY";
|
||||
public static final String RECIPIENT_IDS_EXTRA = "car_recipient_ids";
|
||||
public static final String VOICE_REPLY_KEY = "car_voice_reply_key";
|
||||
public static final String THREAD_ID_EXTRA = "car_reply_thread_id";
|
||||
public static final String TAG = AndroidAutoReplyReceiver.class.getSimpleName();
|
||||
public static final String REPLY_ACTION = "org.thoughtcrime.securesms.notifications.ANDROID_AUTO_REPLY";
|
||||
public static final String ADDRESSES_EXTRA = "car_addresses";
|
||||
public static final String VOICE_REPLY_KEY = "car_voice_reply_key";
|
||||
public static final String THREAD_ID_EXTRA = "car_reply_thread_id";
|
||||
|
||||
@Override
|
||||
protected void onReceive(final Context context, Intent intent,
|
||||
@@ -64,10 +62,10 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
if (remoteInput == null) return;
|
||||
|
||||
final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA);
|
||||
final Address[] addresses = Address.fromParcelable(intent.getParcelableArrayExtra(ADDRESSES_EXTRA));
|
||||
final long threadId = intent.getLongExtra(THREAD_ID_EXTRA, -1);
|
||||
final CharSequence responseText = getMessageText(intent);
|
||||
final Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false);
|
||||
final Recipients recipients = RecipientFactory.getRecipientsFor(context, addresses, false);
|
||||
|
||||
if (responseText != null) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@@ -76,7 +74,7 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
long replyThreadId;
|
||||
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipientIds);
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(addresses);
|
||||
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class MessageNotifier {
|
||||
sendInThreadNotification(context, recipients);
|
||||
} else {
|
||||
Intent intent = new Intent(context, ConversationActivity.class);
|
||||
intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
|
||||
intent.putExtra(ConversationActivity.ADDRESSES_EXTRA, recipients.getAddresses());
|
||||
intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, threadId);
|
||||
intent.setData((Uri.parse("custom://" + System.currentTimeMillis())));
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class NotificationItem {
|
||||
public PendingIntent getPendingIntent(Context context) {
|
||||
Intent intent = new Intent(context, ConversationActivity.class);
|
||||
Recipients notifyRecipients = threadRecipients != null ? threadRecipients : recipients;
|
||||
if (notifyRecipients != null) intent.putExtra("recipients", notifyRecipients.getIds());
|
||||
if (notifyRecipients != null) intent.putExtra(ConversationActivity.ADDRESSES_EXTRA, notifyRecipients.getAddresses());
|
||||
|
||||
intent.putExtra("thread_id", threadId);
|
||||
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
||||
|
||||
@@ -121,7 +121,7 @@ public class NotificationState {
|
||||
Intent intent = new Intent(RemoteReplyReceiver.REPLY_ACTION);
|
||||
intent.setClass(context, RemoteReplyReceiver.class);
|
||||
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
||||
intent.putExtra(RemoteReplyReceiver.RECIPIENT_IDS_EXTRA, recipients.getIds());
|
||||
intent.putExtra(RemoteReplyReceiver.ADDRESSES_EXTRA, recipients.getAddresses());
|
||||
intent.setPackage(context.getPackageName());
|
||||
|
||||
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
@@ -134,7 +134,7 @@ public class NotificationState {
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
intent.setClass(context, AndroidAutoReplyReceiver.class);
|
||||
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
||||
intent.putExtra(AndroidAutoReplyReceiver.RECIPIENT_IDS_EXTRA, recipients.getIds());
|
||||
intent.putExtra(AndroidAutoReplyReceiver.ADDRESSES_EXTRA, recipients.getAddresses());
|
||||
intent.putExtra(AndroidAutoReplyReceiver.THREAD_ID_EXTRA, (long)threads.toArray()[0]);
|
||||
intent.setPackage(context.getPackageName());
|
||||
|
||||
@@ -164,7 +164,7 @@ public class NotificationState {
|
||||
if (threads.size() != 1) throw new AssertionError("We only support replies to single thread notifications! " + threads.size());
|
||||
|
||||
Intent intent = new Intent(context, ConversationPopupActivity.class);
|
||||
intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
|
||||
intent.putExtra(ConversationActivity.ADDRESSES_EXTRA, recipients.getAddresses());
|
||||
intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, (long)threads.toArray()[0]);
|
||||
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.support.v4.app.RemoteInput;
|
||||
|
||||
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.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
|
||||
@@ -44,9 +45,9 @@ import java.util.List;
|
||||
*/
|
||||
public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
public static final String TAG = RemoteReplyReceiver.class.getSimpleName();
|
||||
public static final String REPLY_ACTION = "org.thoughtcrime.securesms.notifications.WEAR_REPLY";
|
||||
public static final String RECIPIENT_IDS_EXTRA = "recipient_ids";
|
||||
public static final String TAG = RemoteReplyReceiver.class.getSimpleName();
|
||||
public static final String REPLY_ACTION = "org.thoughtcrime.securesms.notifications.WEAR_REPLY";
|
||||
public static final String ADDRESSES_EXTRA = "addresses";
|
||||
|
||||
@Override
|
||||
protected void onReceive(final Context context, Intent intent,
|
||||
@@ -58,7 +59,7 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
if (remoteInput == null) return;
|
||||
|
||||
final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA);
|
||||
final Address[] addresses = Address.fromParcelable(intent.getParcelableArrayExtra(ADDRESSES_EXTRA));
|
||||
final CharSequence responseText = remoteInput.getCharSequence(MessageNotifier.EXTRA_REMOTE_REPLY);
|
||||
|
||||
if (masterSecret != null && responseText != null) {
|
||||
@@ -67,11 +68,11 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
protected Void doInBackground(Void... params) {
|
||||
long threadId;
|
||||
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipientIds);
|
||||
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(addresses);
|
||||
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
|
||||
long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;
|
||||
|
||||
Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false);
|
||||
Recipients recipients = RecipientFactory.getRecipientsFor(context, addresses, false);
|
||||
if (recipients.isGroupRecipient()) {
|
||||
OutgoingMediaMessage reply = new OutgoingMediaMessage(recipients, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0);
|
||||
threadId = MessageSender.send(context, masterSecret, reply, -1, false, null);
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.notifications;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
@@ -19,6 +18,8 @@ import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
@@ -69,11 +70,8 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
.toConversationColor(context)));
|
||||
} else {
|
||||
setContentTitle(context.getString(R.string.SingleRecipientNotificationBuilder_signal));
|
||||
setLargeIcon(Recipient.getUnknownRecipient()
|
||||
.getContactPhoto()
|
||||
.asDrawable(context, Recipient.getUnknownRecipient()
|
||||
.getColor()
|
||||
.toConversationColor(context)));
|
||||
setLargeIcon(ContactPhotoFactory.getDefaultContactPhoto("Unknown")
|
||||
.asDrawable(context, ContactColors.UNKNOWN_COLOR.toConversationColor(context)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user