mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Display 'me' for device's local number in group membership list.
// FREEBIE Fixes #1494 Closes #1505
This commit is contained in:
parent
de75a98093
commit
b57763f397
@ -169,6 +169,9 @@
|
|||||||
<string name="GroupCreateActivity_creating_group">Creating %1$s…</string>
|
<string name="GroupCreateActivity_creating_group">Creating %1$s…</string>
|
||||||
<string name="GroupCreateActivity_cannot_add_non_push_to_existing_group">Cannot add non-TextSecure contacts to an existing TextSecure group</string>
|
<string name="GroupCreateActivity_cannot_add_non_push_to_existing_group">Cannot add non-TextSecure contacts to an existing TextSecure group</string>
|
||||||
|
|
||||||
|
<!-- GroupMembersDialog -->
|
||||||
|
<string name="GroupMembersDialog_me">Me</string>
|
||||||
|
|
||||||
<!-- ImportExportActivity -->
|
<!-- ImportExportActivity -->
|
||||||
<string name="ImportExportActivity_import">Import</string>
|
<string name="ImportExportActivity_import">Import</string>
|
||||||
<string name="ImportExportActivity_export">Export</string>
|
<string name="ImportExportActivity_export">Export</string>
|
||||||
|
@ -10,6 +10,9 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -17,6 +20,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public class GroupMembersDialog extends AsyncTask<Void, Void, Recipients> {
|
public class GroupMembersDialog extends AsyncTask<Void, Void, Recipients> {
|
||||||
|
|
||||||
|
private static final String TAG = GroupMembersDialog.class.getSimpleName();
|
||||||
|
|
||||||
private final Recipients recipients;
|
private final Recipients recipients;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
@ -50,10 +55,13 @@ public class GroupMembersDialog extends AsyncTask<Void, Void, Recipients> {
|
|||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> recipientStrings = new LinkedList<String>();
|
List<String> recipientStrings = new LinkedList<>();
|
||||||
|
recipientStrings.add(context.getString(R.string.GroupMembersDialog_me));
|
||||||
|
|
||||||
for (Recipient recipient : members.getRecipientsList()) {
|
for (Recipient recipient : members.getRecipientsList()) {
|
||||||
recipientStrings.add(recipient.toShortString());
|
if (!isLocalNumber(recipient)) {
|
||||||
|
recipientStrings.add(recipient.toShortString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
@ -69,4 +77,16 @@ public class GroupMembersDialog extends AsyncTask<Void, Void, Recipients> {
|
|||||||
if (recipients.isGroupRecipient()) execute();
|
if (recipients.isGroupRecipient()) execute();
|
||||||
else onPostExecute(recipients);
|
else onPostExecute(recipients);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isLocalNumber(Recipient recipient) {
|
||||||
|
try {
|
||||||
|
String localNumber = TextSecurePreferences.getLocalNumber(context);
|
||||||
|
String e164Number = Util.canonicalizeNumber(context, recipient.getNumber());
|
||||||
|
|
||||||
|
return e164Number != null && e164Number.equals(localNumber);
|
||||||
|
} catch (InvalidNumberException e) {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user