aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-04-07 23:58:59 +0200
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-04-07 23:58:59 +0200
commit78bd6c423fa1a2b89322deb69a23b15ef3a72bcb (patch)
tree81a5f2e536cb541aa34b013f4b6cc558ba84a455
parent3f403fb8a976f6cc7d135cf1eb6dd6f0789c312a (diff)
fixed #52. thanks @strb
-rw-r--r--res/xml/preferences.xml5
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java12
2 files changed, 16 insertions, 1 deletions
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 7339565e..0e746a3e 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -41,6 +41,11 @@
android:key="notify_in_conversation_when_highlighted"
android:title="Conference notification"
android:summary="Always notify when a new conference message arrives instead of only when highlighted"/>
+ <CheckBoxPreference
+ android:key="notification_grace_period_after_carbon_received"
+ android:title="Notification grace period"
+ android:summary="Disable notifications for a short time after a carbon copy was received"
+ android:defaultValue="true"/>
</PreferenceCategory>
<PreferenceCategory
android:title="UI Options">
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 62e48773..46da0b67 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -84,6 +84,7 @@ public class XmppConnectionService extends Service {
private static final int PING_MIN_INTERVAL = 10;
private static final int PING_TIMEOUT = 5;
private static final int CONNECT_TIMEOUT = 60;
+ private static final long CARBON_GRACE_PERIOD = 60000L;
private List<Account> accounts;
private List<Conversation> conversations = null;
@@ -101,6 +102,8 @@ public class XmppConnectionService extends Service {
private Random mRandom = new Random(System.currentTimeMillis());
+ private long lastCarbonMessageReceived = -CARBON_GRACE_PERIOD;
+
private ContentObserver contactObserver = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
@@ -120,6 +123,12 @@ public class XmppConnectionService extends Service {
MessagePacket packet) {
Message message = null;
boolean notify = true;
+ if(PreferenceManager
+ .getDefaultSharedPreferences(getApplicationContext())
+ .getBoolean("notification_grace_period_after_carbon_received", true)){
+ notify=(SystemClock.elapsedRealtime() - lastCarbonMessageReceived) > CARBON_GRACE_PERIOD;
+ }
+
if ((packet.getType() == MessagePacket.TYPE_CHAT)) {
String pgpBody = MessageParser.getPgpBody(packet);
if (pgpBody != null) {
@@ -143,6 +152,7 @@ public class XmppConnectionService extends Service {
service);
if (message != null) {
if (message.getStatus() == Message.STATUS_SEND) {
+ lastCarbonMessageReceived = SystemClock.elapsedRealtime();
notify = false;
message.getConversation().markRead();
} else {
@@ -1351,4 +1361,4 @@ public class XmppConnectionService extends Service {
}
}
-} \ No newline at end of file
+}