diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r-- | src/main/java/de/pixart/messenger/parser/PresenceParser.java | 3 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java index 15fb36372..1da8553dc 100644 --- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java +++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java @@ -283,6 +283,9 @@ public class PresenceParser extends AbstractParser implements } else { contact.removePresence(from.getResource()); } + if (contact.getShownStatus() == Presence.Status.OFFLINE) { + contact.flagInactive(); + } mXmppConnectionService.onContactStatusChanged.onContactStatusChanged(contact, false); } else if (type.equals("subscribe")) { if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) { diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 4aba18387..988f247f0 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -163,6 +163,7 @@ public class XmppConnectionService extends Service { public static final String ACTION_FCM_TOKEN_REFRESH = "fcm_token_refresh"; public static final String ACTION_FCM_MESSAGE_RECEIVED = "fcm_message_received"; private static final String ACTION_MERGE_PHONE_CONTACTS = "merge_phone_contacts"; + private static final String SETTING_LAST_ACTIVITY_TS = "last_activity_timestamp"; static { URL.setURLStreamHandlerFactory(new CustomURLStreamHandlerFactory()); @@ -1079,6 +1080,9 @@ public class XmppConnectionService extends Service { return bitmap.getByteCount() / 1024; } }; + if (mLastActivity == 0) { + mLastActivity = getPreferences().getLong(SETTING_LAST_ACTIVITY_TS, System.currentTimeMillis()); + } Log.d(Config.LOGTAG, "initializing database..."); this.databaseBackend = DatabaseBackend.getInstance(getApplicationContext()); @@ -2116,7 +2120,6 @@ public class XmppConnectionService extends Service { public void setOnConversationListChangedListener(OnConversationUpdate listener) { synchronized (this) { - this.mLastActivity = System.currentTimeMillis(); if (checkListeners()) { switchToForeground(); } @@ -2299,6 +2302,12 @@ public class XmppConnectionService extends Service { private void switchToBackground() { final boolean broadcastLastActivity = broadcastLastActivity(); + if (broadcastLastActivity) { + mLastActivity = System.currentTimeMillis(); + final SharedPreferences.Editor editor = getPreferences().edit(); + editor.putLong(SETTING_LAST_ACTIVITY_TS, mLastActivity); + editor.apply(); + } for (Account account : getAccounts()) { if (account.getStatus() == Account.State.ONLINE) { XmppConnection connection = account.getXmppConnection(); |