Search in sources :

Example 1 with LiveGroup

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

the class GroupLinkBottomSheetDialogFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.group_link_share_bottom_sheet, container, false);
    View shareViaSignalButton = view.findViewById(R.id.group_link_bottom_sheet_share_via_signal_button);
    View copyButton = view.findViewById(R.id.group_link_bottom_sheet_copy_button);
    View viewQrButton = view.findViewById(R.id.group_link_bottom_sheet_qr_code_button);
    View shareBySystemButton = view.findViewById(R.id.group_link_bottom_sheet_share_via_system_button);
    TextView hint = view.findViewById(R.id.group_link_bottom_sheet_hint);
    GroupId.V2 groupId = GroupId.parseOrThrow(Objects.requireNonNull(requireArguments().getString(ARG_GROUP_ID))).requireV2();
    LiveGroup liveGroup = new LiveGroup(groupId);
    liveGroup.getGroupLink().observe(getViewLifecycleOwner(), groupLink -> {
        if (!groupLink.isEnabled()) {
            Toast.makeText(requireContext(), R.string.GroupLinkBottomSheet_the_link_is_not_currently_active, Toast.LENGTH_SHORT).show();
            dismiss();
            return;
        }
        hint.setText(groupLink.isRequiresApproval() ? R.string.GroupLinkBottomSheet_share_hint_requiring_approval : R.string.GroupLinkBottomSheet_share_hint_not_requiring_approval);
        hint.setVisibility(View.VISIBLE);
        shareViaSignalButton.setOnClickListener(v -> {
            Context context = requireContext();
            Intent intent = new Intent(context, ShareActivity.class);
            intent.putExtra(Intent.EXTRA_TEXT, groupLink.getUrl());
            context.startActivity(intent);
            dismiss();
        });
        copyButton.setOnClickListener(v -> {
            Context context = requireContext();
            Util.copyToClipboard(context, groupLink.getUrl());
            Toast.makeText(context, R.string.GroupLinkBottomSheet_copied_to_clipboard, Toast.LENGTH_SHORT).show();
            dismiss();
        });
        viewQrButton.setOnClickListener(v -> {
            GroupLinkShareQrDialogFragment.show(requireFragmentManager(), groupId);
            dismiss();
        });
        shareBySystemButton.setOnClickListener(v -> {
            ShareCompat.IntentBuilder.from(requireActivity()).setType("text/plain").setText(groupLink.getUrl()).startChooser();
            dismiss();
        });
    });
    return view;
}
Also used : LiveGroup(org.thoughtcrime.securesms.groups.LiveGroup) Context(android.content.Context) TextView(android.widget.TextView) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) GroupId(org.thoughtcrime.securesms.groups.GroupId)

Example 2 with LiveGroup

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

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 3 with LiveGroup

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

the class GroupDescriptionDialog method onCreateDialog.

@Override
@NonNull
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.group_description_dialog, null, false);
    String argumentTitle = requireArguments().getString(ARGUMENT_TITLE, null);
    String argumentDescription = requireArguments().getString(ARGUMENT_DESCRIPTION, null);
    GroupId argumentGroupId = ParcelableGroupId.get(requireArguments().getParcelable(ARGUMENT_GROUP_ID));
    boolean linkify = requireArguments().getBoolean(ARGUMENT_LINKIFY, false);
    LiveGroup liveGroup = argumentGroupId != null ? new LiveGroup(argumentGroupId) : null;
    descriptionText = dialogView.findViewById(R.id.group_description_dialog_text);
    descriptionText.setMovementMethod(LongClickMovementMethod.getInstance(requireContext()));
    MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext(), R.style.Signal_ThemeOverlay_Dialog_Rounded);
    Dialog dialog = builder.setTitle(TextUtils.isEmpty(argumentTitle) ? getString(R.string.GroupDescriptionDialog__group_description) : argumentTitle).setView(dialogView).setPositiveButton(android.R.string.ok, null).create();
    if (argumentDescription != null) {
        GroupDescriptionUtil.setText(requireContext(), descriptionText, argumentDescription, linkify, null);
    } else if (liveGroup != null) {
        liveGroup.getDescription().observe(this, d -> GroupDescriptionUtil.setText(requireContext(), descriptionText, d, linkify, null));
    }
    if (TextUtils.isEmpty(argumentTitle) && liveGroup != null) {
        liveGroup.getTitle().observe(this, dialog::setTitle);
    }
    return dialog;
}
Also used : LiveGroup(org.thoughtcrime.securesms.groups.LiveGroup) FragmentManager(androidx.fragment.app.FragmentManager) Bundle(android.os.Bundle) GroupDescriptionUtil(org.thoughtcrime.securesms.groups.v2.GroupDescriptionUtil) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ParcelableGroupId(org.thoughtcrime.securesms.groups.ParcelableGroupId) LongClickMovementMethod(org.thoughtcrime.securesms.util.LongClickMovementMethod) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) Dialog(android.app.Dialog) TextUtils(android.text.TextUtils) R(org.thoughtcrime.securesms.R) LiveGroup(org.thoughtcrime.securesms.groups.LiveGroup) Nullable(androidx.annotation.Nullable) GroupId(org.thoughtcrime.securesms.groups.GroupId) View(android.view.View) DialogFragment(androidx.fragment.app.DialogFragment) Dialog(android.app.Dialog) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) View(android.view.View) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ParcelableGroupId(org.thoughtcrime.securesms.groups.ParcelableGroupId) GroupId(org.thoughtcrime.securesms.groups.GroupId) NonNull(androidx.annotation.NonNull)

Example 4 with LiveGroup

use of org.thoughtcrime.securesms.groups.LiveGroup 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 5 with LiveGroup

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

the class GroupDescriptionDialog method onCreateDialog.

@Override
@NonNull
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.group_description_dialog, null, false);
    String argumentTitle = requireArguments().getString(ARGUMENT_TITLE, null);
    String argumentDescription = requireArguments().getString(ARGUMENT_DESCRIPTION, null);
    GroupId argumentGroupId = ParcelableGroupId.get(requireArguments().getParcelable(ARGUMENT_GROUP_ID));
    boolean linkify = requireArguments().getBoolean(ARGUMENT_LINKIFY, false);
    LiveGroup liveGroup = argumentGroupId != null ? new LiveGroup(argumentGroupId) : null;
    descriptionText = dialogView.findViewById(R.id.group_description_dialog_text);
    descriptionText.setMovementMethod(LongClickMovementMethod.getInstance(requireContext()));
    MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext(), R.style.Signal_ThemeOverlay_Dialog_Rounded);
    Dialog dialog = builder.setTitle(TextUtils.isEmpty(argumentTitle) ? getString(R.string.GroupDescriptionDialog__group_description) : argumentTitle).setView(dialogView).setPositiveButton(android.R.string.ok, null).create();
    if (argumentDescription != null) {
        GroupDescriptionUtil.setText(requireContext(), descriptionText, argumentDescription, linkify, null);
    } else if (liveGroup != null) {
        liveGroup.getDescription().observe(this, d -> GroupDescriptionUtil.setText(requireContext(), descriptionText, d, linkify, null));
    }
    if (TextUtils.isEmpty(argumentTitle) && liveGroup != null) {
        liveGroup.getTitle().observe(this, dialog::setTitle);
    }
    return dialog;
}
Also used : LiveGroup(org.thoughtcrime.securesms.groups.LiveGroup) FragmentManager(androidx.fragment.app.FragmentManager) Bundle(android.os.Bundle) GroupDescriptionUtil(org.thoughtcrime.securesms.groups.v2.GroupDescriptionUtil) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ParcelableGroupId(org.thoughtcrime.securesms.groups.ParcelableGroupId) LongClickMovementMethod(org.thoughtcrime.securesms.util.LongClickMovementMethod) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) Dialog(android.app.Dialog) TextUtils(android.text.TextUtils) R(org.thoughtcrime.securesms.R) LiveGroup(org.thoughtcrime.securesms.groups.LiveGroup) Nullable(androidx.annotation.Nullable) GroupId(org.thoughtcrime.securesms.groups.GroupId) View(android.view.View) DialogFragment(androidx.fragment.app.DialogFragment) Dialog(android.app.Dialog) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) View(android.view.View) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ParcelableGroupId(org.thoughtcrime.securesms.groups.ParcelableGroupId) GroupId(org.thoughtcrime.securesms.groups.GroupId) NonNull(androidx.annotation.NonNull)

Aggregations

LiveGroup (org.thoughtcrime.securesms.groups.LiveGroup)6 View (android.view.View)4 GroupId (org.thoughtcrime.securesms.groups.GroupId)4 Dialog (android.app.Dialog)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 TextUtils (android.text.TextUtils)2 LayoutInflater (android.view.LayoutInflater)2 TextView (android.widget.TextView)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 DialogFragment (androidx.fragment.app.DialogFragment)2 FragmentManager (androidx.fragment.app.FragmentManager)2 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)2 List (java.util.List)2 R (org.thoughtcrime.securesms.R)2 EmojiTextView (org.thoughtcrime.securesms.components.emoji.EmojiTextView)2 ParcelableGroupId (org.thoughtcrime.securesms.groups.ParcelableGroupId)2