aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu')
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java2
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java2
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java2
-rw-r--r--src/eu/siacs/conversations/utils/UIHelper.java50
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java1
5 files changed, 40 insertions, 17 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 5fa0c850..6d1ce784 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -173,7 +173,7 @@ public class XmppConnectionService extends Service {
convChangedListener.onConversationListChanged();
} else {
UIHelper.updateNotification(getApplicationContext(),
- getConversations(), notify);
+ getConversations(), message.getConversation(), notify);
}
}
};
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 86ba49b9..ad6e6c38 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -233,7 +233,7 @@ public class ConversationActivity extends XmppActivity {
invalidateOptionsMenu();
if (!getSelectedConversation().isRead()) {
getSelectedConversation().markRead();
- UIHelper.updateNotification(getApplicationContext(), getConversationList(), false);
+ UIHelper.updateNotification(getApplicationContext(), getConversationList(), null, false);
updateConversationList();
}
}
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 3373479a..6fb4a6f8 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -419,7 +419,7 @@ public class ConversationFragment extends Fragment {
if (!activity.shouldPaneBeOpen()) {
conversation.markRead();
//TODO update notifications
- UIHelper.updateNotification(getActivity(), activity.getConversationList(), false);
+ UIHelper.updateNotification(getActivity(), activity.getConversationList(), null, false);
activity.updateConversationList();
}
}
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index 5d9f2420..8880cde3 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -125,22 +125,41 @@ public class UIHelper {
}
public static void updateNotification(Context context,
- List<Conversation> conversations, boolean notify) {
+ List<Conversation> conversations, Conversation currentCon, boolean notify) {
+
+ Log.d("xmppService","called to update notifications");
+
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
-
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ boolean showNofifications = preferences.getBoolean("show_notification",true);
+ boolean vibrate = preferences.getBoolean("vibrate_on_notification", true);
+ boolean alwaysNotify = preferences.getBoolean("notify_in_conversation_when_highlighted", false);
+
+ if (!showNofifications) {
+ Log.d("xmppService","notification disabled in settings. not showing");
+ return;
+ }
+
String targetUuid = "";
+
+ if ((currentCon != null) &&(currentCon.getMode() == Conversation.MODE_MULTI)&&(!alwaysNotify)) {
+ String nick = currentCon.getMucOptions().getNick();
+ notify = currentCon.getLatestMessage().getBody().contains(nick);
+ if (!notify) {
+ return;
+ }
+ }
+
List<Conversation> unread = new ArrayList<Conversation>();
for (Conversation conversation : conversations) {
if (!conversation.isRead()) {
unread.add(conversation);
}
}
-
- SharedPreferences sharedPref = PreferenceManager
- .getDefaultSharedPreferences(context);
- String ringtone = sharedPref.getString("notification_ringtone", null);
+ String ringtone = preferences.getString("notification_ringtone", null);
Resources res = context.getResources();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
@@ -184,7 +203,7 @@ public class UIHelper {
style.setBigContentTitle(unread.size() + " unread Conversations");
StringBuilder names = new StringBuilder();
for (int i = 0; i < unread.size(); ++i) {
- targetUuid = conversations.get(0).getUuid();
+ targetUuid = unread.get(i).getUuid();
if (i < unread.size() - 1) {
names.append(unread.get(i).getName() + ", ");
} else {
@@ -200,9 +219,11 @@ public class UIHelper {
if (unread.size() != 0) {
mBuilder.setSmallIcon(R.drawable.notification);
if (notify) {
- int dat = 110;
- long[] pattern = {0,3*dat,dat,dat,dat,3*dat,dat,dat};
- mBuilder.setVibrate(pattern);
+ if (vibrate) {
+ int dat = 110;
+ long[] pattern = {0,3*dat,dat,dat,dat,3*dat,dat,dat};
+ mBuilder.setVibrate(pattern);
+ }
mBuilder.setLights(0xffffffff, 2000, 4000);
if (ringtone != null) {
mBuilder.setSound(Uri.parse(ringtone));
@@ -219,17 +240,18 @@ public class UIHelper {
targetUuid);
viewConversationIntent
.setType(ConversationActivity.VIEW_CONVERSATION);
-
+
stackBuilder.addNextIntent(viewConversationIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(
0, PendingIntent.FLAG_UPDATE_CURRENT);
-
+
mBuilder.setContentIntent(resultPendingIntent);
- mNotificationManager.notify(2342, mBuilder.build());
+ Notification notification = mBuilder.build();
+ mNotificationManager.notify(2342, notification);
}
}
-
+
public static void prepareContactBadge(final Activity activity,
QuickContactBadge badge, final Contact contact) {
if (contact.getSystemAccount() != null) {
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index be06a3a3..00a37b76 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -225,6 +225,7 @@ public class XmppConnection implements Runnable {
}
//Log.d(LOGTAG,"server ack"+ack.toString()+" ("+this.stanzasSent+")");
} else if (nextTag.isStart("failed")) {
+ tagReader.readElement(nextTag);
Log.d(LOGTAG,account.getJid()+": resumption failed");
streamId = null;
if (account.getStatus() != Account.STATUS_ONLINE) {