diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-17 11:01:38 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-17 11:01:38 +0200 |
commit | 3372e50155ac16c9eabce9a484914c2acbf391c8 (patch) | |
tree | ad00d1e203d0adf56f27a44cd4a9e12301ac41dc /src/eu/siacs/conversations/services | |
parent | 5e3caf962696d3fe39e7ce70274530aa4f77d134 (diff) |
made grace period on a per account basis
Diffstat (limited to 'src/eu/siacs/conversations/services')
-rw-r--r-- | src/eu/siacs/conversations/services/NotificationService.java | 25 | ||||
-rw-r--r-- | src/eu/siacs/conversations/services/XmppConnectionService.java | 4 |
2 files changed, 6 insertions, 23 deletions
diff --git a/src/eu/siacs/conversations/services/NotificationService.java b/src/eu/siacs/conversations/services/NotificationService.java index e65085fb..1983e581 100644 --- a/src/eu/siacs/conversations/services/NotificationService.java +++ b/src/eu/siacs/conversations/services/NotificationService.java @@ -20,6 +20,7 @@ import android.text.Html; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; +import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.ui.ConversationActivity; @@ -34,9 +35,7 @@ public class NotificationService { public int NOTIFICATION_ID = 0x2342; private Conversation mOpenConversation; private boolean mIsInForeground; - - private long mEndGracePeriod = 0L; - + public NotificationService(XmppConnectionService service) { this.mXmppConnectionService = service; this.mNotificationManager = (NotificationManager) service @@ -62,8 +61,9 @@ public class NotificationService { notifications.put(conversationUuid, mList); } } + Account account = message.getConversation().getAccount(); updateNotification((!(this.mIsInForeground && this.mOpenConversation == null) || !isScreenOn) - && !inGracePeriod()); + && !account.inGracePeriod()); } public void clear() { @@ -170,9 +170,7 @@ public class NotificationService { } } mBuilder.setDeleteIntent(createDeleteIntent()); - if (!inGracePeriod()) { - mBuilder.setLights(0xffffffff, 2000, 4000); - } + mBuilder.setLights(0xffffffff, 2000, 4000); Notification notification = mBuilder.build(); mNotificationManager.notify(NOTIFICATION_ID, notification); } @@ -231,17 +229,4 @@ public class NotificationService { public void setIsInForeground(boolean foreground) { this.mIsInForeground = foreground; } - - public void activateGracePeriod() { - this.mEndGracePeriod = SystemClock.elapsedRealtime() - + (Config.CARBON_GRACE_PERIOD * 1000); - } - - public void deactivateGracePeriod() { - this.mEndGracePeriod = 0L; - } - - private boolean inGracePeriod() { - return SystemClock.elapsedRealtime() < this.mEndGracePeriod; - } } diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 8007191f..4a680228 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -529,6 +529,7 @@ public class XmppConnectionService extends Service { synchronized public void sendMessage(Message message) { Account account = message.getConversation().getAccount(); + account.deactivateGracePeriod(); Conversation conv = message.getConversation(); MessagePacket packet = null; boolean saveInDb = true; @@ -1019,7 +1020,6 @@ public class XmppConnectionService extends Service { return; } synchronized (this.convChangedListenerCount) { - this.mNotificationService.deactivateGracePeriod(); if (checkListeners()) { switchToForeground(); } @@ -1049,7 +1049,6 @@ public class XmppConnectionService extends Service { return; } synchronized (this.accountChangedListenerCount) { - this.mNotificationService.deactivateGracePeriod(); if (checkListeners()) { switchToForeground(); } @@ -1077,7 +1076,6 @@ public class XmppConnectionService extends Service { return; } synchronized (this.rosterChangedListenerCount) { - this.mNotificationService.deactivateGracePeriod(); if (checkListeners()) { switchToForeground(); } |