diff options
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 30058dd1e..4ef1d95da 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1982,6 +1982,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return false; } Log.d(Config.LOGTAG, "reInit(hasExtras=" + Boolean.toString(hasExtras) + ")"); + + if (this.conversation.isRead() && hasExtras) { + Log.d(Config.LOGTAG, "trimming conversation"); + this.conversation.trim(); + } + setupIme(); this.binding.textSendButton.setContentDescription(activity.getString(R.string.send_message_to_x, conversation.getName())); @@ -1993,7 +1999,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke refresh(false); this.conversation.messagesLoaded.set(true); - if (hasExtras) { + final boolean scrolledToBottomAndNoPending = this.scrolledToBottom() && pendingScrollState.peek() == null; + + Log.d(Config.LOGTAG, "scrolledToBottomAndNoPending=" + Boolean.toString(scrolledToBottomAndNoPending)); + + if (hasExtras || scrolledToBottomAndNoPending) { synchronized (this.messageList) { Log.d(Config.LOGTAG, "jump to first unread message"); final Message first = conversation.getFirstUnreadMessage(); @@ -2022,6 +2032,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return true; } + private boolean scrolledToBottom() { + final ListView l = this.binding.messagesView; + return l.getLastVisiblePosition() == l.getAdapter().getCount() - 1 && l.getChildAt(l.getChildCount() - 1).getBottom() <= l.getHeight(); + } + private void processExtras(Bundle extras) { final String downloadUuid = extras.getString(ConversationActivity.EXTRA_DOWNLOAD_UUID); final String text = extras.getString(ConversationActivity.EXTRA_TEXT); |