From c7bdc343ecd3fd6d1dde3a3d2f318692a5d8c62c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 27 Jan 2018 21:34:32 +0100 Subject: [PATCH] show account details when clicking avatar picture in self chat --- .../ui/ConversationFragment.java | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index d7b6ea8a5..e70fa5690 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -562,54 +562,52 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa messagesView.setOnScrollListener(mOnScrollListener); messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL); messageListAdapter = new MessageAdapter((ConversationActivity) getActivity(), this.messageList); - messageListAdapter.setOnContactPictureClicked(new OnContactPictureClicked() { - - @Override - public void onContactPictureClicked(Message message) { - if (message.getStatus() <= Message.STATUS_RECEIVED) { - if (message.getConversation().getMode() == Conversation.MODE_MULTI) { - Jid user = message.getCounterpart(); - if (user != null && !user.isBareJid()) { - if (!message.getConversation().getMucOptions().isUserInRoom(user)) { - Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show(); - } - highlightInConference(user.getResourcepart()); - } - } else { - if (!message.getContact().isSelf()) { - String fingerprint; - if (message.getEncryption() == Message.ENCRYPTION_PGP - || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { - fingerprint = "pgp"; - } else { - fingerprint = message.getFingerprint(); - } - activity.switchToContactDetails(message.getContact(), fingerprint); + messageListAdapter.setOnContactPictureClicked(message -> { + final boolean received = message.getStatus() <= Message.STATUS_RECEIVED; + if (received) { + if (message.getConversation().getMode() == Conversation.MODE_MULTI) { + Jid user = message.getCounterpart(); + if (user != null && !user.isBareJid()) { + if (!message.getConversation().getMucOptions().isUserInRoom(user)) { + Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show(); } + highlightInConference(user.getResourcepart()); } + return; } else { - Account account = message.getConversation().getAccount(); - Intent intent; - if (activity.manuallyChangePresence()) { - intent = new Intent(activity, SetPresenceActivity.class); - intent.putExtra(SetPresenceActivity.EXTRA_ACCOUNT, account.getJid().toBareJid().toString()); - } else { - intent = new Intent(activity, EditAccountActivity.class); - intent.putExtra("jid", account.getJid().toBareJid().toString()); + if (!message.getContact().isSelf()) { String fingerprint; if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { fingerprint = "pgp"; - } else if (message.getEncryption() == Message.ENCRYPTION_OTR) { - fingerprint = "otr"; } else { fingerprint = message.getFingerprint(); } - intent.putExtra("fingerprint", fingerprint); + activity.switchToContactDetails(message.getContact(), fingerprint); + return; } - startActivity(intent); } } + Account account = message.getConversation().getAccount(); + Intent intent; + if (activity.manuallyChangePresence() && !received) { + intent = new Intent(activity, SetPresenceActivity.class); + intent.putExtra(SetPresenceActivity.EXTRA_ACCOUNT, account.getJid().toBareJid().toString()); + } else { + intent = new Intent(activity, EditAccountActivity.class); + intent.putExtra("jid", account.getJid().toBareJid().toString()); + String fingerprint; + if (message.getEncryption() == Message.ENCRYPTION_PGP + || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { + fingerprint = "pgp"; + } else if (message.getEncryption() == Message.ENCRYPTION_OTR) { + fingerprint = "otr"; + } else { + fingerprint = message.getFingerprint(); + } + intent.putExtra("fingerprint", fingerprint); + } + startActivity(intent); }); messageListAdapter.setOnContactPictureLongClicked(message -> { if (message.getStatus() <= Message.STATUS_RECEIVED) { @@ -632,7 +630,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa activity.showQrCode(); } }); - messageListAdapter.setOnQuoteListener(text -> quoteText(text)); + messageListAdapter.setOnQuoteListener(this::quoteText); messagesView.setAdapter(messageListAdapter); registerForContextMenu(messagesView);