Search in sources :

Example 6 with GroupMemberListView

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);
    });
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) LiveGroup(org.thoughtcrime.securesms.groups.LiveGroup) List(java.util.List) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView) GroupMemberEntry(org.thoughtcrime.securesms.groups.ui.GroupMemberEntry)

Example 7 with GroupMemberListView

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;
}
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 8 with GroupMemberListView

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));
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Arrays(java.util.Arrays) Bundle(android.os.Bundle) EditTextUtil(org.signal.core.util.EditTextUtil) NonNull(androidx.annotation.NonNull) AvatarPickerFragment(org.thoughtcrime.securesms.avatar.picker.AvatarPickerFragment) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ImageView(android.widget.ImageView) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) Drawable(android.graphics.drawable.Drawable) R(org.thoughtcrime.securesms.R) VectorDrawableCompat(androidx.vectordrawable.graphics.drawable.VectorDrawableCompat) SafeNavigation(org.thoughtcrime.securesms.util.navigation.SafeNavigation) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) Media(org.thoughtcrime.securesms.mediasend.Media) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Recipient(org.thoughtcrime.securesms.recipients.Recipient) DecryptableStreamUriLoader(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader) RecipientDisappearingMessagesActivity(org.thoughtcrime.securesms.recipients.ui.disappearingmessages.RecipientDisappearingMessagesActivity) ViewGroup(android.view.ViewGroup) Objects(java.util.Objects) StringRes(androidx.annotation.StringRes) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Toolbar(androidx.appcompat.widget.Toolbar) ExpireTimerSettingsFragment(org.thoughtcrime.securesms.components.settings.app.privacy.expire.ExpireTimerSettingsFragment) BitmapUtil(org.thoughtcrime.securesms.util.BitmapUtil) GlideApp(org.thoughtcrime.securesms.mms.GlideApp) Context(android.content.Context) Intent(android.content.Intent) ExpirationUtil(org.thoughtcrime.securesms.util.ExpirationUtil) AvatarSelectionActivity(org.thoughtcrime.securesms.mediasend.AvatarSelectionActivity) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) CircularProgressButton(com.dd.CircularProgressButton) CustomTarget(com.bumptech.glide.request.target.CustomTarget) InsetDrawable(android.graphics.drawable.InsetDrawable) AvatarHelper(org.thoughtcrime.securesms.profiles.AvatarHelper) LayoutInflater(android.view.LayoutInflater) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) NonGv2MemberDialog(org.thoughtcrime.securesms.groups.ui.creategroup.dialogs.NonGv2MemberDialog) Bitmap(android.graphics.Bitmap) Transition(com.bumptech.glide.request.transition.Transition) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) Navigation(androidx.navigation.Navigation) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) Activity(android.app.Activity) EditText(android.widget.EditText) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) TextView(android.widget.TextView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) InsetDrawable(android.graphics.drawable.InsetDrawable) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView)

Example 9 with GroupMemberListView

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);
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) SimpleProgressDialog(org.thoughtcrime.securesms.util.views.SimpleProgressDialog) IOException(java.io.IOException) R(org.thoughtcrime.securesms.R) FragmentActivity(androidx.fragment.app.FragmentActivity) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView) Log(org.signal.core.util.logging.Log) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) List(java.util.List) GroupChangeFailedException(org.thoughtcrime.securesms.groups.GroupChangeFailedException) MembershipNotSuitableForV2Exception(org.thoughtcrime.securesms.groups.MembershipNotSuitableForV2Exception) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) GroupNotAMemberException(org.thoughtcrime.securesms.groups.GroupNotAMemberException) Toast(android.widget.Toast) GroupId(org.thoughtcrime.securesms.groups.GroupId) GroupInsufficientRightsException(org.thoughtcrime.securesms.groups.GroupInsufficientRightsException) Recipient(org.thoughtcrime.securesms.recipients.Recipient) GroupChangeBusyException(org.thoughtcrime.securesms.groups.GroupChangeBusyException) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) DialogInterface(android.content.DialogInterface) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView)

Example 10 with GroupMemberListView

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));
}
Also used : GroupMemberListView(org.thoughtcrime.securesms.groups.ui.GroupMemberListView)

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