aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-03-31 22:52:09 +0200
committerChristian Schneppe <christian@pix-art.de>2018-03-31 22:52:09 +0200
commitd68e780a91633c1336c31da54c45ec8cdd7ee5cf (patch)
tree5d8a14ac0054129156aadb016cf5b893b27e0197 /src/main/java/de
parentb11f76bea6bbed42301433ca3ec55b66b08b8942 (diff)
jump to first unread message if was scrolled to bottom earlier
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java17
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);