From 7cb1a7130d062749b1a3087ed06a720461630a22 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Thu, 29 Dec 2022 22:45:14 -0500 Subject: [PATCH] Set up correct tab in more cases --- .../siacs/conversations/ui/ConversationFragment.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index d66c6e4b57e95417e6d7ad9c2ebc49d9dd2938db..cd0d3c8553d876834cdfaabdba719aee9898a25d 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -936,6 +936,7 @@ public class ConversationFragment extends XmppFragment if (conversation.getCorrectingMessage() != null) { this.binding.textInputHint.setVisibility(View.GONE); this.binding.textinput.setHint(R.string.send_corrected_message); + binding.conversationViewPager.setCurrentItem(0); } else if (multi && conversation.getNextCounterpart() != null) { this.binding.textinput.setHint(R.string.send_message); this.binding.textInputHint.setVisibility(View.VISIBLE); @@ -943,6 +944,7 @@ public class ConversationFragment extends XmppFragment getString( R.string.send_private_message_to, conversation.getNextCounterpart().getResource())); + binding.conversationViewPager.setCurrentItem(0); } else if (multi && !conversation.getMucOptions().participating()) { this.binding.textInputHint.setVisibility(View.GONE); this.binding.textinput.setHint(R.string.you_are_not_participating); @@ -2466,6 +2468,7 @@ public class ConversationFragment extends XmppFragment if (conversation == null) { return false; } + final Conversation originalConversation = this.conversation; this.conversation = conversation; // once we set the conversation all is good and it will automatically do the right thing in // onStart() @@ -2535,6 +2538,11 @@ public class ConversationFragment extends XmppFragment .getNotificationService() .setOpenConversation(this.conversation); + if (commandAdapter != null && conversation != originalConversation) { + originalConversation.setupViewPager(null, null); + conversation.setupViewPager(binding.conversationViewPager, binding.tabLayout); + refreshCommands(); + } if (commandAdapter == null && conversation != null) { conversation.setupViewPager(binding.conversationViewPager, binding.tabLayout); commandAdapter = new CommandAdapter((XmppActivity) getActivity()); @@ -2977,6 +2985,10 @@ public class ConversationFragment extends XmppFragment this.binding.textSendButton.setImageResource( SendButtonTool.getSendButtonImageResource(activity, action, status)); } + + if (hasAttachments || binding.textinput.getText().length() > 0) { + binding.conversationViewPager.setCurrentItem(0); + } } protected void updateStatusMessages() {