Search in sources :

Example 11 with GroupMemberListView

use of org.thoughtcrime.securesms.groups.ui.GroupMemberListView in project Signal-Android by WhisperSystems.

the class NonGv2MemberDialog method showNonGv2Members.

@Nullable
public static Dialog showNonGv2Members(@NonNull Context context, @NonNull LifecycleOwner lifecycleOwner, @NonNull List<Recipient> recipients) {
    int size = recipients.size();
    if (size == 0) {
        return null;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context).setPositiveButton(android.R.string.ok, null);
    if (size == 1) {
        builder.setMessage(context.getString(R.string.NonGv2MemberDialog_single_users_are_non_gv2_capable_forced_migration, recipients.get(0).getDisplayName(context)));
    } else {
        builder.setMessage(context.getResources().getQuantityString(R.plurals.NonGv2MemberDialog_d_users_are_non_gv2_capable_forced_migration, size, size)).setView(R.layout.dialog_multiple_members_non_gv2_capable);
    }
    Dialog dialog = builder.show();
    if (size > 1) {
        GroupMemberListView nonGv2CapableMembers = dialog.findViewById(R.id.list_non_gv2_members);
        nonGv2CapableMembers.initializeAdapter(lifecycleOwner);
        List<GroupMemberEntry.NewGroupCandidate> pendingMembers = new ArrayList<>(recipients.size());
        for (Recipient r : recipients) {
            pendingMembers.add(new GroupMemberEntry.NewGroupCandidate(r));
        }
        // noinspection ConstantConditions
        nonGv2CapableMembers.setMembers(pendingMembers);
    }
    return dialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) AlertDialog(androidx.appcompat.app.AlertDialog) Dialog(android.app.Dialog) ArrayList(java.util.ArrayList) Recipient(org.thoughtcrime.securesms.recipients.Recipient) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView) GroupMemberEntry(org.thoughtcrime.securesms.groups.ui.GroupMemberEntry) Nullable(androidx.annotation.Nullable)

Example 12 with GroupMemberListView

use of org.thoughtcrime.securesms.groups.ui.GroupMemberListView in project Signal-Android by signalapp.

the class NonGv2MemberDialog method showNonGv2Members.

@Nullable
public static Dialog showNonGv2Members(@NonNull Context context, @NonNull LifecycleOwner lifecycleOwner, @NonNull List<Recipient> recipients) {
    int size = recipients.size();
    if (size == 0) {
        return null;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context).setPositiveButton(android.R.string.ok, null);
    if (size == 1) {
        builder.setMessage(context.getString(R.string.NonGv2MemberDialog_single_users_are_non_gv2_capable_forced_migration, recipients.get(0).getDisplayName(context)));
    } else {
        builder.setMessage(context.getResources().getQuantityString(R.plurals.NonGv2MemberDialog_d_users_are_non_gv2_capable_forced_migration, size, size)).setView(R.layout.dialog_multiple_members_non_gv2_capable);
    }
    Dialog dialog = builder.show();
    if (size > 1) {
        GroupMemberListView nonGv2CapableMembers = dialog.findViewById(R.id.list_non_gv2_members);
        nonGv2CapableMembers.initializeAdapter(lifecycleOwner);
        List<GroupMemberEntry.NewGroupCandidate> pendingMembers = new ArrayList<>(recipients.size());
        for (Recipient r : recipients) {
            pendingMembers.add(new GroupMemberEntry.NewGroupCandidate(r));
        }
        // noinspection ConstantConditions
        nonGv2CapableMembers.setMembers(pendingMembers);
    }
    return dialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) AlertDialog(androidx.appcompat.app.AlertDialog) Dialog(android.app.Dialog) ArrayList(java.util.ArrayList) Recipient(org.thoughtcrime.securesms.recipients.Recipient) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView) GroupMemberEntry(org.thoughtcrime.securesms.groups.ui.GroupMemberEntry) Nullable(androidx.annotation.Nullable)

Aggregations

GroupMemberListView (org.thoughtcrime.securesms.groups.ui.GroupMemberListView)12 AlertDialog (androidx.appcompat.app.AlertDialog)8 Recipient (org.thoughtcrime.securesms.recipients.Recipient)8 Nullable (androidx.annotation.Nullable)6 List (java.util.List)6 GroupMemberEntry (org.thoughtcrime.securesms.groups.ui.GroupMemberEntry)6 Dialog (android.app.Dialog)4 Toast (android.widget.Toast)4 NonNull (androidx.annotation.NonNull)4 ArrayList (java.util.ArrayList)4 R (org.thoughtcrime.securesms.R)4 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)4 Activity (android.app.Activity)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 Intent (android.content.Intent)2 Bitmap (android.graphics.Bitmap)2 Drawable (android.graphics.drawable.Drawable)2 InsetDrawable (android.graphics.drawable.InsetDrawable)2 Bundle (android.os.Bundle)2