From 1e4f06d04de38021a8cd62c386261103ebebccb6 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Wed, 22 Feb 2017 22:28:46 +0100 Subject: send 'online' presences also while typing a message --- .../pixart/messenger/services/XmppConnectionService.java | 2 +- .../java/de/pixart/messenger/ui/ConversationFragment.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index faecf0774..3fa4f9d4c 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -3558,7 +3558,7 @@ public class XmppConnectionService extends Service { sendPresence(account, checkListeners() && broadcastLastActivity()); } - private void sendPresence(final Account account, final boolean includeIdleTimestamp) { + public void sendPresence(final Account account, final boolean includeIdleTimestamp) { PresencePacket packet; if (manuallyChangePresence()) { packet = mPresenceGenerator.selfPresence(account, account.getPresenceStatus()); diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 74ee1324d..2212ad6b0 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -9,8 +9,10 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender.SendIntentException; +import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; +import android.preference.PreferenceManager; import android.support.v13.view.inputmethod.InputConnectionCompat; import android.support.v13.view.inputmethod.InputContentInfoCompat; import android.text.Editable; @@ -1485,14 +1487,27 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa @Override public void onTypingStarted() { + final boolean broadcastLastActivity = broadcastLastActivity(); Account.State status = conversation.getAccount().getStatus(); if (status == Account.State.ONLINE && conversation.setOutgoingChatState(ChatState.COMPOSING)) { activity.xmppConnectionService.sendChatState(conversation); } + if (broadcastLastActivity) { + activity.xmppConnectionService.sendPresence(conversation.getAccount(), false); //send new presence but don't include idle because we are not + } activity.hideConversationsOverview(); updateSendButton(); } + public boolean broadcastLastActivity() { + return getPreferences().getBoolean("last_activity", true); + } + + public SharedPreferences getPreferences() { + return PreferenceManager + .getDefaultSharedPreferences(getActivity().getApplicationContext()); + } + @Override public void onTypingStopped() { Account.State status = conversation.getAccount().getStatus(); -- cgit v1.2.3