From 7f7e4b10a41f74dce12a08f6ebc3dce1a45b4b4a Mon Sep 17 00:00:00 2001 From: kosyak Date: Sun, 17 Dec 2023 23:46:06 +0100 Subject: [PATCH] info about pm on muc details screen --- .../ui/ConferenceDetailsActivity.java | 36 ++++++++++- .../conversations/ui/util/ShareUtil.java | 6 ++ src/main/res/drawable/content_copy_12dp.xml | 11 ++++ .../res/drawable/content_copy_12dp_white.xml | 11 ++++ src/main/res/layout/activity_muc_details.xml | 64 +++++++++++++++++++ src/main/res/values/attrs.xml | 1 + src/main/res/values/strings.xml | 1 + src/main/res/values/themes.xml | 2 + 8 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 src/main/res/drawable/content_copy_12dp.xml create mode 100644 src/main/res/drawable/content_copy_12dp_white.xml diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index aaf5c9b8a..8967bfc43 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -52,6 +52,7 @@ import eu.siacs.conversations.ui.util.MenuDoubleTabUtil; import eu.siacs.conversations.ui.util.MucConfiguration; import eu.siacs.conversations.ui.util.MucDetailsContextMenuHelper; import eu.siacs.conversations.ui.util.MyLinkify; +import eu.siacs.conversations.ui.util.ShareUtil; import eu.siacs.conversations.ui.util.SoftKeyboardUtils; import eu.siacs.conversations.utils.AccountUtils; import eu.siacs.conversations.utils.Compatibility; @@ -110,6 +111,13 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } intent.putExtra("uuid", uuid); + + Jid counterpart = conversation.getNextCounterpart(); + + if (counterpart != null) { + intent.putExtra("counterpart", counterpart.toEscapedString()); + } + activity.startActivity(intent); } @@ -510,6 +518,27 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers if (mConversation == null) { return; } + + String counterpart = getIntent().getStringExtra("counterpart"); + if (counterpart != null) { + binding.mucPmInfo.setVisibility(View.VISIBLE); + + Jid counterpartJid = Jid.of(counterpart); + + binding.mucPmCounterpartName.setText(getResources().getString(R.string.muc_private_conversation_title, counterpartJid.getResource(), mConversation.getName())); + binding.mucPmCounterpartJid.setText(counterpart); + binding.mucPmCounterpartJid.setOnClickListener(v -> ShareUtil.copyJidToClipboard(ConferenceDetailsActivity.this, counterpartJid)); + + Conversation conversation = xmppConnectionService.find(mConversation.getAccount(), mConversation.getJid(), counterpartJid); + + if (conversation != null) { + binding.mucPmCounterpartAvatar.setVisibility(View.VISIBLE); + AvatarWorkerTask.loadAvatar(conversation, binding.mucPmCounterpartAvatar, R.dimen.avatar_on_details_screen_size); + } else { + binding.mucPmCounterpartAvatar.setVisibility(View.GONE); + } + } + final MucOptions mucOptions = mConversation.getMucOptions(); final User self = mucOptions.getSelf(); String account; @@ -524,8 +553,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.binding.detailsAccount.setText(getString(R.string.using_account, account)); if (mConversation.isPrivateAndNonAnonymous()) { this.binding.jid.setText(getString(R.string.hosted_on, mConversation.getJid().getDomain())); - } else { - this.binding.jid.setText(mConversation.getJid().asBareJid().toEscapedString()); } AvatarWorkerTask.loadAvatar(mConversation, binding.yourPhoto, R.dimen.avatar_on_details_screen_size); String roomName = mucOptions.getName(); @@ -543,6 +570,11 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers hasTitle = false; this.binding.mucTitle.setVisibility(View.GONE); } + + this.binding.mucJid.setText(mConversation.getJid().asBareJid().toEscapedString()); + binding.mucJid.setOnClickListener(v -> ShareUtil.copyJidToClipboard(ConferenceDetailsActivity.this, mConversation.getJid().asBareJid())); + + if (printableValue(subject)) { SpannableStringBuilder spannable = new SpannableStringBuilder(subject); StylingHelper.format(spannable, this.binding.mucSubject.getCurrentTextColor()); diff --git a/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java b/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java index 2d0eed59b..05198bf6e 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java +++ b/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java @@ -256,4 +256,10 @@ public class ShareUtil { } return null; } + + public static void copyJidToClipboard(final XmppActivity activity, Jid jid) { + if (copyTextToClipboard(activity, jid.toEscapedString(), R.string.account_settings_jabber_id)) { + Toast.makeText(activity, R.string.jabber_id_copied_to_clipboard, Toast.LENGTH_SHORT).show(); + } + } } diff --git a/src/main/res/drawable/content_copy_12dp.xml b/src/main/res/drawable/content_copy_12dp.xml new file mode 100644 index 000000000..22e6ff2df --- /dev/null +++ b/src/main/res/drawable/content_copy_12dp.xml @@ -0,0 +1,11 @@ + + + diff --git a/src/main/res/drawable/content_copy_12dp_white.xml b/src/main/res/drawable/content_copy_12dp_white.xml new file mode 100644 index 000000000..a19a2be04 --- /dev/null +++ b/src/main/res/drawable/content_copy_12dp_white.xml @@ -0,0 +1,11 @@ + + + diff --git a/src/main/res/layout/activity_muc_details.xml b/src/main/res/layout/activity_muc_details.xml index 774df9b93..7f2e0bfd2 100644 --- a/src/main/res/layout/activity_muc_details.xml +++ b/src/main/res/layout/activity_muc_details.xml @@ -23,6 +23,61 @@ android:layout_height="wrap_content" android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 7ef16baa7..bbb19220c 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1065,6 +1065,7 @@ filter could_not_create_file %1$s (%2$s) + Private conversation with: %1$d selected General %1$s (%2$d) diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 9d9291aa7..1bdcf3fd9 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -142,6 +142,7 @@ @drawable/ic_gps_fixed_black_24dp @drawable/ic_directions_black_24dp @drawable/ic_content_copy_white_24dp + @drawable/content_copy_12dp @drawable/ic_notifications_black_24dp @@ -309,6 +310,7 @@ @drawable/ic_gps_fixed_white_24dp @drawable/ic_directions_white_24dp @drawable/ic_content_copy_white_24dp + @drawable/content_copy_12dp_white @drawable/ic_notifications_white_24dp