mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-30 06:18:19 +00:00
Switch MMS groups to use the group database infrastructure
Eliminate the concept of 'Recipients' (plural). There is now just a 'Recipient', which contains an Address that is either an individual or a group ID. MMS groups now exist as part of the group database, just like push groups. // FREEBIE
This commit is contained in:
@@ -7,48 +7,36 @@ import android.graphics.Rect;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupMembersDialog extends AsyncTask<Void, Void, Recipients> {
|
||||
public class GroupMembersDialog extends AsyncTask<Void, Void, List<Recipient>> {
|
||||
|
||||
private static final String TAG = GroupMembersDialog.class.getSimpleName();
|
||||
|
||||
private final Recipients recipients;
|
||||
private final Recipient recipient;
|
||||
private final Context context;
|
||||
|
||||
public GroupMembersDialog(Context context, Recipients recipients) {
|
||||
this.recipients = recipients;
|
||||
this.context = context;
|
||||
public GroupMembersDialog(Context context, Recipient recipient) {
|
||||
this.recipient = recipient;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreExecute() {}
|
||||
|
||||
@Override
|
||||
protected Recipients doInBackground(Void... params) {
|
||||
try {
|
||||
String groupId = recipients.getPrimaryRecipient().getAddress().toGroupString();
|
||||
return DatabaseFactory.getGroupDatabase(context)
|
||||
.getGroupMembers(GroupUtil.getDecodedId(groupId), true);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
return RecipientFactory.getRecipientsFor(context, new LinkedList<Recipient>(), true);
|
||||
}
|
||||
protected List<Recipient> doInBackground(Void... params) {
|
||||
return DatabaseFactory.getGroupDatabase(context).getGroupMembers(recipient.getAddress().toGroupString(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostExecute(Recipients members) {
|
||||
public void onPostExecute(List<Recipient> members) {
|
||||
GroupMembers groupMembers = new GroupMembers(members);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(R.string.ConversationActivity_group_members);
|
||||
@@ -60,8 +48,7 @@ public class GroupMembersDialog extends AsyncTask<Void, Void, Recipients> {
|
||||
}
|
||||
|
||||
public void display() {
|
||||
if (recipients.isGroupRecipient()) execute();
|
||||
else onPostExecute(recipients);
|
||||
execute();
|
||||
}
|
||||
|
||||
private static class GroupMembersOnClickListener implements DialogInterface.OnClickListener {
|
||||
@@ -107,8 +94,8 @@ public class GroupMembersDialog extends AsyncTask<Void, Void, Recipients> {
|
||||
|
||||
private final LinkedList<Recipient> members = new LinkedList<>();
|
||||
|
||||
public GroupMembers(Recipients recipients) {
|
||||
for (Recipient recipient : recipients.getRecipientsList()) {
|
||||
public GroupMembers(List<Recipient> recipients) {
|
||||
for (Recipient recipient : recipients) {
|
||||
if (isLocalNumber(recipient)) {
|
||||
members.push(recipient);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user