use of org.thoughtcrime.securesms.groups.ui.GroupMemberListView in project Signal-Android by signalapp.
the class GroupMembersDialog method display.
public void display() {
AlertDialog dialog = new AlertDialog.Builder(fragmentActivity).setTitle(R.string.ConversationActivity_group_members).setIcon(R.drawable.ic_group_24).setCancelable(true).setView(R.layout.dialog_group_members).setPositiveButton(android.R.string.ok, null).show();
GroupMemberListView memberListView = dialog.findViewById(R.id.list_members);
memberListView.initializeAdapter(fragmentActivity);
LiveGroup liveGroup = new LiveGroup(groupRecipient.requireGroupId());
LiveData<List<GroupMemberEntry.FullMember>> fullMembers = liveGroup.getFullMembers();
// noinspection ConstantConditions
fullMembers.observe(fragmentActivity, memberListView::setMembers);
dialog.setOnDismissListener(d -> fullMembers.removeObservers(fragmentActivity));
memberListView.setRecipientClickListener(recipient -> {
dialog.dismiss();
contactClick(recipient);
});
}
use of org.thoughtcrime.securesms.groups.ui.GroupMemberListView in project Signal-Android by signalapp.
the class GroupInviteSentDialog method showInvitesSent.
@Nullable
public static Dialog showInvitesSent(@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).setTitle(context.getResources().getQuantityString(R.plurals.GroupManagement_invitation_sent, size, size)).setPositiveButton(android.R.string.ok, null);
if (size == 1) {
builder.setMessage(context.getString(R.string.GroupManagement_invite_single_user, recipients.get(0).getDisplayName(context)));
} else {
builder.setMessage(R.string.GroupManagement_invite_multiple_users).setView(R.layout.dialog_multiple_group_invites_sent);
}
Dialog dialog = builder.show();
if (size > 1) {
GroupMemberListView invitees = dialog.findViewById(R.id.list_invitees);
invitees.initializeAdapter(lifecycleOwner);
List<GroupMemberEntry.PendingMember> pendingMembers = new ArrayList<>(recipients.size());
for (Recipient r : recipients) {
pendingMembers.add(new GroupMemberEntry.PendingMember(r));
}
// noinspection ConstantConditions
invitees.setMembers(pendingMembers);
}
return dialog;
}
use of org.thoughtcrime.securesms.groups.ui.GroupMemberListView in project Signal-Android by signalapp.
the class AddGroupDetailsFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
create = view.findViewById(R.id.create);
name = view.findViewById(R.id.name);
toolbar = view.findViewById(R.id.toolbar);
disappearingMessagesRow = view.findViewById(R.id.group_disappearing_messages_row);
setCreateEnabled(false, false);
GroupMemberListView members = view.findViewById(R.id.member_list);
ImageView avatar = view.findViewById(R.id.group_avatar);
View mmsWarning = view.findViewById(R.id.mms_warning);
LearnMoreTextView gv2Warning = view.findViewById(R.id.gv2_warning);
View addLater = view.findViewById(R.id.add_later);
TextView disappearingMessageValue = view.findViewById(R.id.group_disappearing_messages_value);
members.initializeAdapter(getViewLifecycleOwner());
avatarPlaceholder = VectorDrawableCompat.create(getResources(), R.drawable.ic_camera_outline_32_ultramarine, requireActivity().getTheme());
if (savedInstanceState == null) {
avatar.setImageDrawable(new InsetDrawable(avatarPlaceholder, ViewUtil.dpToPx(AVATAR_PLACEHOLDER_INSET_DP)));
}
initializeViewModel();
avatar.setOnClickListener(v -> showAvatarPicker());
members.setRecipientClickListener(this::handleRecipientClick);
EditTextUtil.addGraphemeClusterLimitFilter(name, FeatureFlags.getMaxGroupNameGraphemeLength());
name.addTextChangedListener(new AfterTextChanged(editable -> viewModel.setName(editable.toString())));
toolbar.setNavigationOnClickListener(unused -> callback.onNavigationButtonPressed());
create.setOnClickListener(v -> handleCreateClicked());
viewModel.getMembers().observe(getViewLifecycleOwner(), list -> {
addLater.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE);
members.setMembers(list);
});
viewModel.getCanSubmitForm().observe(getViewLifecycleOwner(), isFormValid -> setCreateEnabled(isFormValid, true));
viewModel.getIsMms().observe(getViewLifecycleOwner(), isMms -> {
disappearingMessagesRow.setVisibility(isMms ? View.GONE : View.VISIBLE);
mmsWarning.setVisibility(isMms ? View.VISIBLE : View.GONE);
name.setHint(isMms ? R.string.AddGroupDetailsFragment__group_name_optional : R.string.AddGroupDetailsFragment__group_name_required);
toolbar.setTitle(isMms ? R.string.AddGroupDetailsFragment__create_group : R.string.AddGroupDetailsFragment__name_this_group);
});
viewModel.getNonGv2CapableMembers().observe(getViewLifecycleOwner(), nonGv2CapableMembers -> {
gv2Warning.setVisibility(nonGv2CapableMembers.isEmpty() ? View.GONE : View.VISIBLE);
gv2Warning.setText(requireContext().getResources().getQuantityString(R.plurals.AddGroupDetailsFragment__d_members_do_not_support_new_groups_so_this_group_cannot_be_created, nonGv2CapableMembers.size(), nonGv2CapableMembers.size()));
gv2Warning.setLearnMoreVisible(true);
gv2Warning.setOnLinkClickListener(v -> NonGv2MemberDialog.showNonGv2Members(requireContext(), getViewLifecycleOwner(), nonGv2CapableMembers));
});
viewModel.getAvatar().observe(getViewLifecycleOwner(), avatarBytes -> {
if (avatarBytes == null) {
avatar.setImageDrawable(new InsetDrawable(avatarPlaceholder, ViewUtil.dpToPx(AVATAR_PLACEHOLDER_INSET_DP)));
} else {
GlideApp.with(this).load(avatarBytes).circleCrop().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(avatar);
}
});
viewModel.getDisappearingMessagesTimer().observe(getViewLifecycleOwner(), timer -> disappearingMessageValue.setText(ExpirationUtil.getExpirationDisplayValue(requireContext(), timer)));
disappearingMessagesRow.setOnClickListener(v -> {
startActivityForResult(RecipientDisappearingMessagesActivity.forCreateGroup(requireContext(), viewModel.getDisappearingMessagesTimer().getValue()), REQUEST_DISAPPEARING_TIMER);
});
name.requestFocus();
getParentFragmentManager().setFragmentResultListener(AvatarPickerFragment.REQUEST_KEY_SELECT_AVATAR, getViewLifecycleOwner(), (key, bundle) -> handleMediaResult(bundle));
}
use of org.thoughtcrime.securesms.groups.ui.GroupMemberListView in project Signal-Android by signalapp.
the class GroupsV1MigrationSuggestionsDialog method display.
private void display() {
AlertDialog dialog = new AlertDialog.Builder(fragmentActivity).setTitle(fragmentActivity.getResources().getQuantityString(R.plurals.GroupsV1MigrationSuggestionsDialog_add_members_question, suggestions.size())).setMessage(fragmentActivity.getResources().getQuantityString(R.plurals.GroupsV1MigrationSuggestionsDialog_these_members_couldnt_be_automatically_added, suggestions.size())).setView(R.layout.dialog_group_members).setPositiveButton(fragmentActivity.getResources().getQuantityString(R.plurals.GroupsV1MigrationSuggestionsDialog_add_members, suggestions.size()), (d, i) -> onAddClicked(d)).setNegativeButton(android.R.string.cancel, (d, i) -> d.dismiss()).show();
GroupMemberListView memberListView = dialog.findViewById(R.id.list_members);
memberListView.initializeAdapter(fragmentActivity);
SimpleTask.run(() -> Recipient.resolvedList(suggestions), memberListView::setDisplayOnlyMembers);
}
use of org.thoughtcrime.securesms.groups.ui.GroupMemberListView in project Signal-Android by WhisperSystems.
the class ShowAdminsBottomSheetDialog method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
disposables.bindTo(getViewLifecycleOwner().getLifecycle());
GroupMemberListView list = view.findViewById(R.id.show_admin_list);
list.initializeAdapter(getViewLifecycleOwner());
list.setDisplayOnlyMembers(Collections.emptyList());
list.setRecipientClickListener(recipient -> {
CommunicationActions.startConversation(requireContext(), recipient, null);
dismissAllowingStateLoss();
});
disposables.add(Single.fromCallable(() -> getAdmins(requireContext().getApplicationContext(), getGroupId())).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(list::setDisplayOnlyMembers));
}
Aggregations