make read markers work
This commit is contained in:
parent
46feb7bf42
commit
5e28a8f8d5
|
@ -72,6 +72,7 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
|||
int[] FRAGMENT_ID_NOTIFICATION_ORDER = {R.id.secondary_fragment, R.id.main_fragment};
|
||||
private final PendingItem<Intent> pendingViewIntent = new PendingItem<>();
|
||||
private ActivityConversationsBinding binding;
|
||||
private boolean mActivityPaused = true;
|
||||
|
||||
private static boolean isViewIntent(Intent i) {
|
||||
return i != null && ACTION_VIEW_CONVERSATION.equals(i.getAction()) && i.hasExtra(EXTRA_CONVERSATION);
|
||||
|
@ -214,6 +215,22 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
this.mActivityPaused = true;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
final int theme = findTheme();
|
||||
if (this.mTheme != theme) {
|
||||
recreate();
|
||||
}
|
||||
this.mActivityPaused = false;
|
||||
}
|
||||
|
||||
private void initializeFragments() {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
|
||||
|
@ -287,7 +304,9 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
|||
|
||||
@Override
|
||||
public void onConversationRead(Conversation conversation) {
|
||||
Log.d(Config.LOGTAG, "read event for " + conversation.getName() + " received");
|
||||
if (!mActivityPaused && pendingViewIntent.peek() == null) {
|
||||
xmppConnectionService.sendReadMarker(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1579,17 +1579,17 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
}
|
||||
|
||||
public boolean reInit(Conversation conversation) {
|
||||
public void reInit(Conversation conversation) {
|
||||
Log.d(Config.LOGTAG, "reInit()");
|
||||
if (conversation == null) {
|
||||
Log.d(Config.LOGTAG, "conversation was null :(");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.activity == null) {
|
||||
Log.d(Config.LOGTAG, "activity was null");
|
||||
this.conversation = conversation;
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
setupIme();
|
||||
|
@ -1617,8 +1617,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
this.binding.textinput.setKeyboardListener(this);
|
||||
messageListAdapter.updatePreferences();
|
||||
this.binding.messagesView.setAdapter(messageListAdapter);
|
||||
refresh();
|
||||
refresh(false);
|
||||
this.conversation.messagesLoaded.set(true);
|
||||
final boolean isAtBottom;
|
||||
synchronized (this.messageList) {
|
||||
final Message first = conversation.getFirstUnreadMessage();
|
||||
final int bottom = Math.max(0, this.messageList.size() - 1);
|
||||
|
@ -1630,7 +1631,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
pos = i < 0 ? bottom : i;
|
||||
}
|
||||
this.binding.messagesView.setSelection(pos);
|
||||
return pos == bottom;
|
||||
isAtBottom = pos == bottom;
|
||||
}
|
||||
if (activity != null) {
|
||||
activity.onConversationRead(this.conversation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1727,6 +1731,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
|
||||
@Override
|
||||
public void refresh() {
|
||||
this.refresh(true);
|
||||
}
|
||||
|
||||
|
||||
private void refresh(boolean notifyConversationRead) {
|
||||
synchronized (this.messageList) {
|
||||
if (this.conversation != null) {
|
||||
conversation.populateWithMessages(this.messageList);
|
||||
|
@ -1734,7 +1743,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
updateStatusMessages();
|
||||
this.messageListAdapter.notifyDataSetChanged();
|
||||
updateChatMsgHint();
|
||||
if (activity != null) {
|
||||
if (notifyConversationRead && activity != null) {
|
||||
activity.onConversationRead(this.conversation);
|
||||
}
|
||||
updateSendButton();
|
||||
|
|
|
@ -645,10 +645,10 @@ public class ConversationLegacyActivity extends XmppActivity
|
|||
updateActionBarTitle(true);
|
||||
}
|
||||
}
|
||||
if (this.mConversationFragment.reInit(getSelectedConversation())) {
|
||||
/*if (this.mConversationFragment.reInit(getSelectedConversation())) {
|
||||
Log.d(Config.LOGTAG, "setting scroll position on fragment");
|
||||
this.mConversationFragment.setScrollPosition(mScrollPosition);
|
||||
}
|
||||
}*/
|
||||
mOpenConversation = null;
|
||||
} else if (intent != null && ACTION_VIEW_CONVERSATION.equals(intent.getAction())) {
|
||||
clearPending();
|
||||
|
|
|
@ -31,7 +31,6 @@ package eu.siacs.conversations.ui;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
|
Loading…
Reference in a new issue