mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 07:59:14 +00:00
Improve default SMS subscription id intelligence
Fixes #5266 // FREEBIE
This commit is contained in:
@@ -10,6 +10,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
@@ -140,6 +141,7 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(DEFAULT_SUBSCRIPTION_ID, defaultSubscriptionId);
|
||||
updateOrInsert(recipients, values);
|
||||
EventBus.getDefault().post(new RecipientPreferenceEvent(recipients));
|
||||
}
|
||||
|
||||
public void setBlocked(Recipients recipients, boolean blocked) {
|
||||
@@ -284,4 +286,17 @@ public class RecipientPreferenceDatabase extends Database {
|
||||
return getCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecipientPreferenceEvent {
|
||||
|
||||
private final Recipients recipients;
|
||||
|
||||
public RecipientPreferenceEvent(Recipients recipients) {
|
||||
this.recipients = recipients;
|
||||
}
|
||||
|
||||
public Recipients getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,6 +567,10 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
|
||||
}
|
||||
|
||||
if (message.getSubscriptionId() != -1) {
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setDefaultSubscriptionId(recipients, message.getSubscriptionId());
|
||||
}
|
||||
|
||||
notifyConversationListeners(threadId);
|
||||
jobManager.add(new TrimThreadJob(context, threadId));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user