From 98d9b5737900797b0711be65d1ef3194a3bdb5c4 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Thu, 18 Jun 2020 14:34:30 -0300 Subject: [PATCH] Add copy to bottom sheet for Note to Self. --- .../securesms/components/AvatarImageView.java | 2 +- .../RecipientBottomSheetDialogFragment.java | 12 +++++++++++ .../res/layout/recipient_bottom_sheet.xml | 20 ++++++++++++++++++- app/src/main/res/values/strings.xml | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/AvatarImageView.java b/app/src/main/java/org/thoughtcrime/securesms/components/AvatarImageView.java index 1748fe58f7..363b496555 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/AvatarImageView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/AvatarImageView.java @@ -178,7 +178,7 @@ public final class AvatarImageView extends AppCompatImageView { context.startActivity(ManageGroupActivity.newIntent(context, recipient.requireGroupId().requirePush()), ManageGroupActivity.createTransitionBundle(context, this)); } else { - if (context instanceof FragmentActivity && !recipient.isLocalNumber()) { + if (context instanceof FragmentActivity) { RecipientBottomSheetDialogFragment.create(recipient.getId(), null) .show(((FragmentActivity) context).getSupportFragmentManager(), "BOTTOM"); } else { diff --git a/app/src/main/java/org/thoughtcrime/securesms/recipients/ui/bottomsheet/RecipientBottomSheetDialogFragment.java b/app/src/main/java/org/thoughtcrime/securesms/recipients/ui/bottomsheet/RecipientBottomSheetDialogFragment.java index ad90c9d0ca..f922dd4d4b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/recipients/ui/bottomsheet/RecipientBottomSheetDialogFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/recipients/ui/bottomsheet/RecipientBottomSheetDialogFragment.java @@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.groups.GroupId; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.RecipientExporter; import org.thoughtcrime.securesms.recipients.RecipientId; +import org.thoughtcrime.securesms.util.CommunicationActions; import org.thoughtcrime.securesms.util.ServiceUtil; import org.thoughtcrime.securesms.util.ThemeUtil; import org.thoughtcrime.securesms.util.Util; @@ -63,6 +64,7 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF private Button removeAdminButton; private Button removeFromGroupButton; private ProgressBar adminActionBusy; + private View noteToSelfDescription; public static BottomSheetDialogFragment create(@NonNull RecipientId recipientId, @Nullable GroupId groupId) @@ -109,6 +111,7 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF removeAdminButton = view.findViewById(R.id.rbs_remove_group_admin_button); removeFromGroupButton = view.findViewById(R.id.rbs_remove_from_group_button); adminActionBusy = view.findViewById(R.id.rbs_admin_action_busy); + noteToSelfDescription = view.findViewById(R.id.rbs_note_to_self_description); return view; } @@ -133,6 +136,12 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF } }); avatar.setAvatar(recipient); + if (recipient.isLocalNumber()) { + avatar.setOnClickListener(v -> { + dismiss(); + viewModel.onMessageClicked(requireActivity()); + }); + } String name = recipient.isLocalNumber() ? requireContext().getString(R.string.note_to_self) : recipient.getDisplayName(requireContext()); @@ -151,10 +160,13 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF return true; }); + noteToSelfDescription.setVisibility(recipient.isLocalNumber() ? View.VISIBLE : View.GONE); + boolean blocked = recipient.isBlocked(); blockButton .setVisibility(recipient.isLocalNumber() || blocked ? View.GONE : View.VISIBLE); unblockButton.setVisibility(recipient.isLocalNumber() || !blocked ? View.GONE : View.VISIBLE); + messageButton.setVisibility(!recipient.isLocalNumber() ? View.VISIBLE : View.GONE); secureCallButton.setVisibility(recipient.isRegistered() && !recipient.isLocalNumber() ? View.VISIBLE : View.GONE); insecureCallButton.setVisibility(!recipient.isRegistered() && !recipient.isLocalNumber() ? View.VISIBLE : View.GONE); secureVideoCallButton.setVisibility(recipient.isRegistered() && !recipient.isLocalNumber() ? View.VISIBLE : View.GONE); diff --git a/app/src/main/res/layout/recipient_bottom_sheet.xml b/app/src/main/res/layout/recipient_bottom_sheet.xml index 53e35389bd..2541ceec81 100644 --- a/app/src/main/res/layout/recipient_bottom_sheet.xml +++ b/app/src/main/res/layout/recipient_bottom_sheet.xml @@ -53,6 +53,24 @@ app:layout_constraintTop_toBottomOf="@+id/rbs_full_name" tools:text="\@spidergwen +1 555-654-6657" /> + + + app:layout_constraintTop_toBottomOf="@+id/rbs_note_to_self_description"> You can swipe to the left on any message to quickly reply Outgoing view-once media files are automatically removed after they are sent You already viewed this message - You can add notes for yourself in this conversation. If your account has any linked devices, new notes will be synced. + You can add notes for yourself in this conversation.\nIf your account has any linked devices, new notes will be synced. There is no browser installed on your device.