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;
}
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);
});
}
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;
}
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);
});
}
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;
}
Aggregations