mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-20 05:58:27 +00:00
Correctly display group members
This commit is contained in:
parent
8e3aa94a05
commit
a305bb80e6
@ -17,6 +17,7 @@
|
|||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -84,6 +85,7 @@ import org.thoughtcrime.securesms.util.CharacterCalculator;
|
|||||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
import org.thoughtcrime.securesms.util.EncryptedCharacterCalculator;
|
import org.thoughtcrime.securesms.util.EncryptedCharacterCalculator;
|
||||||
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.textsecure.crypto.InvalidMessageException;
|
import org.whispersystems.textsecure.crypto.InvalidMessageException;
|
||||||
@ -427,19 +429,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleDisplayGroupRecipients() {
|
private void handleDisplayGroupRecipients() {
|
||||||
List<String> recipientStrings = new LinkedList<String>();
|
new GroupMembersDialog(this, getRecipients()).display();
|
||||||
|
|
||||||
for (Recipient recipient : getRecipients().getRecipientsList()) {
|
|
||||||
recipientStrings.add(recipient.toShortString());
|
|
||||||
}
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
||||||
builder.setTitle(R.string.ConversationActivity_group_conversation_recipients);
|
|
||||||
builder.setIcon(R.drawable.ic_menu_groups_holo_dark);
|
|
||||||
builder.setCancelable(true);
|
|
||||||
builder.setItems(recipientStrings.toArray(new String[]{}), null);
|
|
||||||
builder.setPositiveButton(android.R.string.ok, null);
|
|
||||||
builder.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDeleteThread() {
|
private void handleDeleteThread() {
|
||||||
|
72
src/org/thoughtcrime/securesms/GroupMembersDialog.java
Normal file
72
src/org/thoughtcrime/securesms/GroupMembersDialog.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GroupMembersDialog extends AsyncTask<Void, Void, Recipients> {
|
||||||
|
|
||||||
|
private final Recipients recipients;
|
||||||
|
private final Context context;
|
||||||
|
|
||||||
|
private ProgressDialog progress = null;
|
||||||
|
|
||||||
|
public GroupMembersDialog(Context context, Recipients recipients) {
|
||||||
|
this.recipients = recipients;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPreExecute() {
|
||||||
|
progress = ProgressDialog.show(context, "Members...", "Members...", true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Recipients doInBackground(Void... params) {
|
||||||
|
try {
|
||||||
|
String groupId = recipients.getPrimaryRecipient().getNumber();
|
||||||
|
return DatabaseFactory.getGroupDatabase(context)
|
||||||
|
.getGroupMembers(GroupUtil.getDecodedId(groupId));
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w("ConverstionActivity", e);
|
||||||
|
return new Recipients(new LinkedList<Recipient>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPostExecute(Recipients members) {
|
||||||
|
if (progress != null) {
|
||||||
|
progress.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> recipientStrings = new LinkedList<String>();
|
||||||
|
|
||||||
|
for (Recipient recipient : members.getRecipientsList()) {
|
||||||
|
recipientStrings.add(recipient.toShortString());
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setTitle(R.string.ConversationActivity_group_conversation_recipients);
|
||||||
|
builder.setIcon(R.drawable.ic_menu_groups_holo_dark);
|
||||||
|
builder.setCancelable(true);
|
||||||
|
builder.setItems(recipientStrings.toArray(new String[]{}), null);
|
||||||
|
builder.setPositiveButton(android.R.string.ok, null);
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display() {
|
||||||
|
if (recipients.isGroupRecipient()) execute();
|
||||||
|
else onPostExecute(recipients);
|
||||||
|
}
|
||||||
|
}
|
@ -77,7 +77,7 @@ public class GroupDatabase extends Database {
|
|||||||
|
|
||||||
for (String member : members) {
|
for (String member : members) {
|
||||||
try {
|
try {
|
||||||
recipients.addAll(RecipientFactory.getRecipientsFromString(context, member, true)
|
recipients.addAll(RecipientFactory.getRecipientsFromString(context, member, false)
|
||||||
.getRecipientsList());
|
.getRecipientsList());
|
||||||
} catch (RecipientFormattingException e) {
|
} catch (RecipientFormattingException e) {
|
||||||
Log.w("GroupDatabase", e);
|
Log.w("GroupDatabase", e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user