From d6652c571d9167b6966543013297faf5640d03cf Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 8 Dec 2019 15:12:37 +0100 Subject: add direct answer button in private muc messages --- .../messenger/ui/adapter/MessageAdapter.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/main/java/de/pixart') diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 19bfb7463..9a5540236 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -29,6 +29,7 @@ import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; @@ -975,6 +976,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie viewHolder.contact_picture = view.findViewById(R.id.message_photo); viewHolder.audioPlayer = view.findViewById(R.id.audio_player); viewHolder.download_button = view.findViewById(R.id.download_button); + viewHolder.answer_button = view.findViewById(R.id.answer); viewHolder.indicator = view.findViewById(R.id.security_indicator); viewHolder.edit_indicator = view.findViewById(R.id.edit_indicator); viewHolder.image = view.findViewById(R.id.message_image); @@ -1146,6 +1148,26 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie } if (type == RECEIVED) { + if (message.isPrivateMessage()) { + viewHolder.answer_button.setVisibility(View.VISIBLE); + viewHolder.answer_button.setImageResource(R.drawable.ic_reply_circle_black_24dp); + viewHolder.answer_button.setOnClickListener(v -> { + try { + if (activity instanceof ConversationsActivity) { + ConversationFragment conversationFragment = ConversationFragment.get(activity); + if (conversationFragment != null) { + activity.invalidateOptionsMenu(); + conversationFragment.privateMessageWith(message.getCounterpart()); + } + } + } catch (Exception e) { + viewHolder.answer_button.setVisibility(View.GONE); + e.printStackTrace(); + } + }); + } else { + viewHolder.answer_button.setVisibility(View.GONE); + } if (isInValidSession) { setBubbleBackgroundColor(viewHolder.message_box, activity.getThemeColor(), type, message.isPrivateMessage(), isInValidSession); viewHolder.encryption.setVisibility(View.GONE); @@ -1299,6 +1321,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie protected LinearLayout message_box; protected Button download_button; protected Button resend_button; + protected ImageButton answer_button; protected ImageView image; protected GifImageView gifImage; protected RichLinkView richlinkview; -- cgit v1.2.3