From d5227e5c253658eb9d6bc1f7bf85397f072125d4 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Tue, 7 Oct 2014 13:37:50 +0200 Subject: refactored grace period --- src/eu/siacs/conversations/parser/MessageParser.java | 15 ++++----------- src/eu/siacs/conversations/parser/PresenceParser.java | 2 ++ 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src/eu/siacs/conversations/parser') diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java index 18752659..8d5ca898 100644 --- a/src/eu/siacs/conversations/parser/MessageParser.java +++ b/src/eu/siacs/conversations/parser/MessageParser.java @@ -1,10 +1,7 @@ package eu.siacs.conversations.parser; -import android.os.SystemClock; -import android.util.Log; import net.java.otr4j.session.Session; import net.java.otr4j.session.SessionStatus; -import eu.siacs.conversations.Config; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; @@ -19,9 +16,6 @@ import eu.siacs.conversations.xmpp.stanzas.MessagePacket; public class MessageParser extends AbstractParser implements OnMessagePacketReceived { - - private long lastCarbonMessageReceived = -(Config.CARBON_GRACE_PERIOD * 1000); - public MessageParser(XmppConnectionService service) { super(service); } @@ -404,8 +398,6 @@ public class MessageParser extends AbstractParser implements Message message = null; boolean notify = mXmppConnectionService.getPreferences().getBoolean( "show_notification", true); - notify = notify - && (SystemClock.elapsedRealtime() - lastCarbonMessageReceived) > (Config.CARBON_GRACE_PERIOD * 1000); boolean alwaysNotifyInConference = notify && mXmppConnectionService.getPreferences().getBoolean( "always_notify_in_conference", false); @@ -431,8 +423,8 @@ public class MessageParser extends AbstractParser implements message = this.parseCarbonMessage(packet, account); if (message != null) { if (message.getStatus() == Message.STATUS_SEND) { - lastCarbonMessageReceived = SystemClock - .elapsedRealtime(); + mXmppConnectionService.getNotificationService() + .activateGracePeriod(); notify = false; mXmppConnectionService.markRead( message.getConversation(), false); @@ -454,7 +446,8 @@ public class MessageParser extends AbstractParser implements } else { mXmppConnectionService.markRead(message.getConversation(), false); - lastCarbonMessageReceived = SystemClock.elapsedRealtime(); + mXmppConnectionService.getNotificationService() + .activateGracePeriod(); notify = false; } } diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java index 507ebbd2..2c3a7dbc 100644 --- a/src/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/eu/siacs/conversations/parser/PresenceParser.java @@ -58,6 +58,8 @@ public class PresenceParser extends AbstractParser implements Presences.parseShow(packet.findChild("show"))); } else if (type.equals("unavailable")) { account.removePresence(fromParts[1]); + mXmppConnectionService.getNotificationService() + .deactivateGracePeriod(); } } } else { -- cgit v1.2.3