mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 19:52:15 -05:00
fixed notifications for images
This commit is contained in:
parent
6a43bda4d7
commit
2253814519
@ -401,12 +401,6 @@ public class MessageParser extends AbstractParser implements
|
|||||||
@Override
|
@Override
|
||||||
public void onMessagePacketReceived(Account account, MessagePacket packet) {
|
public void onMessagePacketReceived(Account account, MessagePacket packet) {
|
||||||
Message message = null;
|
Message message = null;
|
||||||
boolean notify = mXmppConnectionService.getPreferences().getBoolean(
|
|
||||||
"show_notification", true);
|
|
||||||
boolean alwaysNotifyInConference = notify
|
|
||||||
&& mXmppConnectionService.getPreferences().getBoolean(
|
|
||||||
"always_notify_in_conference", false);
|
|
||||||
|
|
||||||
this.parseNick(packet, account);
|
this.parseNick(packet, account);
|
||||||
|
|
||||||
if ((packet.getType() == MessagePacket.TYPE_CHAT || packet.getType() == MessagePacket.TYPE_NORMAL)) {
|
if ((packet.getType() == MessagePacket.TYPE_CHAT || packet.getType() == MessagePacket.TYPE_NORMAL)) {
|
||||||
@ -429,7 +423,6 @@ public class MessageParser extends AbstractParser implements
|
|||||||
if (message != null) {
|
if (message != null) {
|
||||||
if (message.getStatus() == Message.STATUS_SEND) {
|
if (message.getStatus() == Message.STATUS_SEND) {
|
||||||
account.activateGracePeriod();
|
account.activateGracePeriod();
|
||||||
notify = false;
|
|
||||||
mXmppConnectionService.markRead(
|
mXmppConnectionService.markRead(
|
||||||
message.getConversation(), false);
|
message.getConversation(), false);
|
||||||
} else {
|
} else {
|
||||||
@ -444,14 +437,10 @@ public class MessageParser extends AbstractParser implements
|
|||||||
if (message != null) {
|
if (message != null) {
|
||||||
if (message.getStatus() == Message.STATUS_RECEIVED) {
|
if (message.getStatus() == Message.STATUS_RECEIVED) {
|
||||||
message.markUnread();
|
message.markUnread();
|
||||||
notify = alwaysNotifyInConference
|
|
||||||
|| NotificationService
|
|
||||||
.wasHighlightedOrPrivate(message);
|
|
||||||
} else {
|
} else {
|
||||||
mXmppConnectionService.markRead(message.getConversation(),
|
mXmppConnectionService.markRead(message.getConversation(),
|
||||||
false);
|
false);
|
||||||
account.activateGracePeriod();
|
account.activateGracePeriod();
|
||||||
notify = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (packet.getType() == MessagePacket.TYPE_ERROR) {
|
} else if (packet.getType() == MessagePacket.TYPE_ERROR) {
|
||||||
@ -498,10 +487,7 @@ public class MessageParser extends AbstractParser implements
|
|||||||
if (message.trusted() && message.bodyContainsDownloadable()) {
|
if (message.trusted() && message.bodyContainsDownloadable()) {
|
||||||
this.mXmppConnectionService.getHttpConnectionManager()
|
this.mXmppConnectionService.getHttpConnectionManager()
|
||||||
.createNewConnection(message);
|
.createNewConnection(message);
|
||||||
notify = false;
|
} else {
|
||||||
}
|
|
||||||
notify = notify && !conversation.isMuted();
|
|
||||||
if (notify) {
|
|
||||||
mXmppConnectionService.getNotificationService().push(message);
|
mXmppConnectionService.getNotificationService().push(message);
|
||||||
}
|
}
|
||||||
mXmppConnectionService.updateConversationUi();
|
mXmppConnectionService.updateConversationUi();
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
package eu.siacs.conversations.services;
|
package eu.siacs.conversations.services;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
@ -23,6 +17,12 @@ import android.support.v4.app.TaskStackBuilder;
|
|||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
@ -46,7 +46,28 @@ public class NotificationService {
|
|||||||
this.mXmppConnectionService = service;
|
this.mXmppConnectionService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean notify(Message message) {
|
||||||
|
return (message.getStatus() == Message.STATUS_RECEIVED)
|
||||||
|
&& notificationsEnabled()
|
||||||
|
&& !message.getConversation().isMuted()
|
||||||
|
&& (message.getConversation().getMode() == Conversation.MODE_SINGLE
|
||||||
|
|| conferenceNotificationsEnabled()
|
||||||
|
|| wasHighlightedOrPrivate(message)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean notificationsEnabled() {
|
||||||
|
return mXmppConnectionService.getPreferences().getBoolean("show_notification", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean conferenceNotificationsEnabled() {
|
||||||
|
return mXmppConnectionService.getPreferences().getBoolean("always_notify_in_conference", false);
|
||||||
|
}
|
||||||
|
|
||||||
public void push(Message message) {
|
public void push(Message message) {
|
||||||
|
if (!notify(message)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
PowerManager pm = (PowerManager) mXmppConnectionService
|
PowerManager pm = (PowerManager) mXmppConnectionService
|
||||||
.getSystemService(Context.POWER_SERVICE);
|
.getSystemService(Context.POWER_SERVICE);
|
||||||
boolean isScreenOn = pm.isScreenOn();
|
boolean isScreenOn = pm.isScreenOn();
|
||||||
@ -287,7 +308,7 @@ public class NotificationService {
|
|||||||
return PendingIntent.getService(mXmppConnectionService, 0, intent, 0);
|
return PendingIntent.getService(mXmppConnectionService, 0, intent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean wasHighlightedOrPrivate(Message message) {
|
private boolean wasHighlightedOrPrivate(Message message) {
|
||||||
String nick = message.getConversation().getMucOptions().getActualNick();
|
String nick = message.getConversation().getMucOptions().getActualNick();
|
||||||
Pattern highlight = generateNickHighlightPattern(nick);
|
Pattern highlight = generateNickHighlightPattern(nick);
|
||||||
if (message.getBody() == null || nick == null) {
|
if (message.getBody() == null || nick == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user