diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-06-02 20:39:59 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-06-02 20:39:59 +0200 |
commit | b082f919d73291c0bd832154af9b7b68f7d9f8e0 (patch) | |
tree | aea71ca6d12519135b5cff04fcbff004e9c567b5 /src/main/java/eu/siacs/conversations/parser/MessageParser.java | |
parent | 41d3b019d1618a00f4fe40371b0f339d8cc193d6 (diff) | |
parent | 25211f13b37ecef64d6fa9a382a2c30d212452ae (diff) |
Merge remote-tracking branch 'refs/remotes/siacs/master'
Diffstat (limited to 'src/main/java/eu/siacs/conversations/parser/MessageParser.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/parser/MessageParser.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 7ae89c7ef..887b9124a 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -7,8 +7,10 @@ import android.util.Pair; import net.java.otr4j.session.Session; import net.java.otr4j.session.SessionStatus; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Set; import java.util.UUID; @@ -53,7 +55,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece conversation.setOutgoingChatState(state); if (state == ChatState.ACTIVE || state == ChatState.COMPOSING) { mXmppConnectionService.markRead(conversation); - account.activateGracePeriod(); + activateGracePeriod(account); } return false; } else { @@ -500,7 +502,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece if (status == Message.STATUS_SEND || status == Message.STATUS_SEND_RECEIVED) { mXmppConnectionService.markRead(conversation); if (query == null) { - account.activateGracePeriod(); + activateGracePeriod(account); } } else { message.markUnread(); @@ -641,4 +643,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece mXmppConnectionService.sendMessagePacket(account, receipt); } } + + private static SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss"); + + private void activateGracePeriod(Account account) { + long duration = mXmppConnectionService.getPreferences().getLong("race_period_length", 144) * 1000; + Log.d(Config.LOGTAG,account.getJid().toBareJid()+": activating grace period till "+TIME_FORMAT.format(new Date(System.currentTimeMillis() + duration))); + account.activateGracePeriod(duration); + } } |