diff options
Diffstat (limited to 'src')
3 files changed, 39 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index 2103b63e5..c1aa6caaa 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -75,8 +75,8 @@ public class ConversationActivity extends XmppActivity implements OnConversation private static final @IdRes 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); @@ -219,6 +219,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); @@ -332,7 +348,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 diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 4e898b66d..42f0b431c 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1811,16 +1811,16 @@ 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(); @@ -1847,6 +1847,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke this.binding.textinput.setKeyboardListener(this); messageListAdapter.updatePreferences(); this.binding.messagesView.setAdapter(messageListAdapter); + refresh(false); + refresh(); + this.conversation.messagesLoaded.set(true); + final boolean isAtBottom; this.binding.messagesView.setOnTouchListener(new OnSwipeTouchListener(getContext()) { @Override public void onSwipeRight() { @@ -1854,8 +1858,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke activity.onBackPressed(); } }); - refresh(); - this.conversation.messagesLoaded.set(true); synchronized (this.messageList) { final Message first = conversation.getFirstUnreadMessage(); final int bottom = Math.max(0, this.messageList.size() - 1); @@ -1867,7 +1869,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); } } @@ -1999,6 +2004,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(ConversationFragment.this.messageList); @@ -2006,7 +2016,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(); diff --git a/src/main/java/de/pixart/messenger/ui/ConversationLegacyActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationLegacyActivity.java index 5c99ff001..9d7573dd2 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationLegacyActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationLegacyActivity.java @@ -778,10 +778,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(); |