Updates im Chat-Server
This commit is contained in:
@@ -64,14 +64,6 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
@@ -80,6 +72,14 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
||||
@@ -96,7 +96,6 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
@@ -44,9 +46,12 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import Database.DatabaseHandler;
|
||||
import entities.ChatEntity;
|
||||
import entities.ChatMessage;
|
||||
import entities.NotificationLog;
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.JsonSoapPrimitiveRequest;
|
||||
import soapConnection.Packet;
|
||||
@@ -88,9 +93,6 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
|
||||
|
||||
@Override
|
||||
public void onNetworkConnectionChanged(boolean isConnected) {
|
||||
//TODO: Socket neustarten
|
||||
// Broken Pipe, weil die Internetverbindung abgerissen ist
|
||||
|
||||
Util.reconnectWithServer(isConnected, ChatActivity.this);
|
||||
}
|
||||
|
||||
@@ -125,8 +127,6 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
|
||||
teamMemberOids = zielkorb.getString("TeamMemberOids");
|
||||
teamMemberNames = zielkorb.getString("TeamMemberNames");
|
||||
|
||||
Log.i(LOGTAG, "onCreate aufgerufen");
|
||||
|
||||
ReloadChatView(recipientName, recipientPersonOid, bildArray, isTeam, teamMemberOids, teamMemberNames);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
|
||||
teamMemberNames = pTeamMemberNames;
|
||||
|
||||
ImageView status = (ImageView) mCustomView.findViewById(R.id.status);
|
||||
TextView titlename = (TextView) mCustomView.findViewById(R.id.PersonalName);
|
||||
TextView titlename = (TextView) mCustomView.findViewById(R.id.PersonalName);
|
||||
ImageView titlepic = (ImageView) mCustomView.findViewById(R.id.PersonalPic);
|
||||
|
||||
if(!isTeam) {
|
||||
@@ -294,6 +294,16 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
|
||||
|
||||
JsonSoapPrimitiveRequest request = new JsonSoapPrimitiveRequest(SoapCalls.GET_ALL_CHAT_MESSAGES, propertyInfos);
|
||||
spiceManager.execute(request, new JsonSoapPrimitiveRequestListener());
|
||||
|
||||
|
||||
NotificationManager mNotifyMgr = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
ChatEntity entity = new ChatEntity(recipientOid, isTeam);
|
||||
|
||||
if(SocketManager.notificationEntities.get(entity) != null) {
|
||||
mNotifyMgr.cancel(SocketManager.notificationEntities.get(entity).getNotificationId());
|
||||
Util.removeMessagesCount(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
@@ -31,7 +30,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import Database.DatabaseHandler;
|
||||
import entities.ChatMessage;
|
||||
import entities.ChatPerson;
|
||||
import soapConnection.JsonSoapPrimitiveRequest;
|
||||
import soapConnection.Packet;
|
||||
@@ -47,11 +45,11 @@ import util.Util;
|
||||
*/
|
||||
public class KontaktChatActivity extends ActionBarActivity implements ConnectivityReceiver.ConnectivityReceiverListener {
|
||||
|
||||
private static final String LOGTAG = "";
|
||||
|
||||
private SpiceManager spiceManager = new SpiceManager(UncachedSpiceService.class);
|
||||
private DatabaseHandler databaseHandler;
|
||||
|
||||
// private UIHandler kontaktChatUIHandler;
|
||||
|
||||
public static ListView listView;
|
||||
|
||||
ArrayList<ContactListItem> contactList = new ArrayList<>();
|
||||
@@ -110,6 +108,32 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
|
||||
|
||||
JsonSoapPrimitiveRequest request = new JsonSoapPrimitiveRequest(SoapCalls.GET_CONTACTS_FOR_PERSON, propertyInfos);
|
||||
spiceManager.execute(request, new JsonSoapPrimitiveRequestListener());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ArrayList<Integer> test = isTeam ? databaseHandler.getExistingTeamChatMessageIds() : databaseHandler.getExistingChatMessageIds();
|
||||
//
|
||||
// Log.i(LOGTAG, "Chat-Messages in der Datenbank: " + test.size());
|
||||
//
|
||||
// String pExceptions = "";
|
||||
// for(int i = 0; i < test.size(); i++) {
|
||||
// pExceptions += test.get(i);
|
||||
//
|
||||
// if(i < test.size() - 1) {
|
||||
// pExceptions += ";";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ArrayList<PropertyInfo> propertyInfos2 = new ArrayList<>();
|
||||
// propertyInfos.add(SoapConnectionManager.BuildProperty("pSenderPersonOid", SoapConnectionManager.User.getPersonOid(), Long.class));
|
||||
// propertyInfos.add(SoapConnectionManager.BuildProperty("pRecipientPersonOid", recipientPersonOid, Long.class));
|
||||
// propertyInfos.add(SoapConnectionManager.BuildProperty("pExceptions", pExceptions, String.class));
|
||||
// propertyInfos.add(SoapConnectionManager.BuildProperty("pIsForTeam", isTeam, Boolean.class));
|
||||
//
|
||||
// JsonSoapPrimitiveRequest request2 = new JsonSoapPrimitiveRequest(SoapCalls.GET_ALL_CHAT_MESSAGES, propertyInfos);
|
||||
// spiceManager.execute(request2, new JsonSoapPrimitiveRequestListenerForUnreadMessages());
|
||||
}
|
||||
|
||||
public UIHandler kontaktChatActivityUIHandler = new UIHandler() {
|
||||
@@ -163,7 +187,6 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
|
||||
});
|
||||
break;
|
||||
case STATUS_NOTIFICATION_LOGIN_BROADCAST:
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -254,11 +277,22 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
|
||||
spiceManager.start(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
SocketManager.logout();
|
||||
|
||||
Intent intent = new Intent(KontaktChatActivity.this, LoginActivity.class);
|
||||
KontaktChatActivity.this.startActivity(intent);
|
||||
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private final class JsonSoapPrimitiveRequestListener implements RequestListener<SoapPrimitive> {
|
||||
|
||||
@Override
|
||||
public void onRequestFailure(SpiceException spiceException) {
|
||||
Toast.makeText(KontaktChatActivity.this, "An error occured while loading the contact list", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(KontaktChatActivity.this, "Ein Fehler ist beim laden der Kontaktliste aufgetreten.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -313,4 +347,21 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
|
||||
((KontaktAdapter) listView.getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private final class JsonSoapPrimitiveRequestListenerForUnreadMessages implements RequestListener<SoapPrimitive> {
|
||||
@Override
|
||||
public void onRequestFailure(SpiceException spiceException) {
|
||||
Toast.makeText(KontaktChatActivity.this, "Ein Fehler ist beim laden der ungelesenen Nachrichten aufgetreten.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestSuccess(SoapPrimitive soapPrimitive) {
|
||||
//TODO: Nachrichten, die empfangen wurden als man offline war, laden und jeweils die neueste anzeigen.
|
||||
if(soapPrimitive == null) {
|
||||
Log.i("KONTAKT_CHAT_ACTIVITY", "soapPrimitive ist NULL!");
|
||||
}
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,26 @@ public class ChatEntity {
|
||||
public boolean isTeam() {
|
||||
return isTeam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if(other == null || !(other instanceof ChatEntity)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(other == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ChatEntity otherEntity = (ChatEntity) other;
|
||||
|
||||
return this.oid == otherEntity.getOid() && this.isTeam == otherEntity.isTeam();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (int) (oid ^ (oid >>> 32));
|
||||
result = 31 * result + (isTeam ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.TimerTask;
|
||||
|
||||
import Database.DatabaseHandler;
|
||||
import beyondsoft.bewomitarbeiterapp.BeWoChatApplication;
|
||||
import beyondsoft.bewomitarbeiterapp.R;
|
||||
import entities.ChatEntity;
|
||||
import entities.ChatMessage;
|
||||
import entities.NotificationLog;
|
||||
@@ -26,6 +25,8 @@ import entities.NotificationLog;
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.Packet;
|
||||
import soapConnection.SoapCalls;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
import util.Util;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 04.08.2016.
|
||||
@@ -188,10 +189,6 @@ public class SocketManager {
|
||||
|
||||
private volatile boolean isRunning = true;
|
||||
|
||||
public void terminate() {
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -213,6 +210,7 @@ public class SocketManager {
|
||||
|
||||
try {
|
||||
chatPacket = new Packet(new String(message, "UTF-8"));
|
||||
Log.i("SOCKET_LISTENER", "Erstelle Packet; " + (chatPacket.ChatMessage.isEmpty() ? "<<LEER>>" : chatPacket.ChatMessage) + "; Typ: " + chatPacket.ChatDataIdentifier + ": " + new String(message, "UTF-8"));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -251,6 +249,30 @@ public class SocketManager {
|
||||
SocketManager.onlinePersonOids.add(chatPacket.SenderPersonOid);
|
||||
}
|
||||
|
||||
//if(!SocketManager.onlineEntities.)
|
||||
|
||||
/*
|
||||
for(Map.Entry<ChatEntity, NotificationLog> entry : SocketManager.notificationEntities.entrySet()) {
|
||||
if(!(entry.getKey().equals(chatEntity) && entry.getValue().equals(notificationLog))) {
|
||||
mNotifyMgr.cancel(entry.getValue().getNotificationId());
|
||||
entities2remove.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
boolean isAlreadyLoggedIn = false;
|
||||
for(ChatEntity entity : SocketManager.onlineEntities)
|
||||
{
|
||||
if(entity.getOid() == chatPacket.SenderPersonOid) {
|
||||
isAlreadyLoggedIn = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isAlreadyLoggedIn) {
|
||||
SocketManager.onlineEntities.add(new ChatEntity(chatPacket.SenderPersonOid, false));
|
||||
}
|
||||
|
||||
break;
|
||||
case STATUS_NOTIFICATION_LOGOUT:
|
||||
|
||||
@@ -258,6 +280,10 @@ public class SocketManager {
|
||||
SocketManager.onlinePersonOids.remove(Integer.valueOf(chatPacket.SenderPersonOid));
|
||||
}
|
||||
|
||||
ChatEntity entity2delete = Util.getChatEntityFromOnlineEntitiesByOid(chatPacket.SenderPersonOid, chatPacket.ChatDataIdentifier == DataIdentifier.TEAM);
|
||||
|
||||
SocketManager.onlineEntities.remove(entity2delete);
|
||||
|
||||
break;
|
||||
|
||||
case STATUS_NOTIFICATION_LOGIN_BROADCAST:
|
||||
@@ -265,7 +291,12 @@ public class SocketManager {
|
||||
String[] onlinePersons = chatPacket.ChatMessage.split(",");
|
||||
|
||||
for (String onlinePerson : onlinePersons) {
|
||||
SocketManager.onlinePersonOids.add(Integer.parseInt(onlinePerson));
|
||||
|
||||
int personOid = Integer.parseInt(onlinePerson);
|
||||
|
||||
if(!SocketManager.onlinePersonOids.contains(personOid)) {
|
||||
SocketManager.onlinePersonOids.add(personOid);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -319,4 +350,4 @@ public class SocketManager {
|
||||
|
||||
return "02:00:00:00:00:00";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -20,6 +18,8 @@ import entities.ChatMessage;
|
||||
* Created by JettenM on 09.08.2016.
|
||||
*/
|
||||
public class ChatMessageDeserializer implements JsonDeserializer<ChatMessage> {
|
||||
private static final String LOGTAG = "MESSAGE_DESERIALIZER";
|
||||
|
||||
@Override
|
||||
public ChatMessage deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
||||
|
||||
@@ -31,6 +31,7 @@ public class ChatMessageDeserializer implements JsonDeserializer<ChatMessage> {
|
||||
int recipientPersonOid = Long.valueOf(json.get("EmpfängerPersonOid").getAsLong()).intValue();
|
||||
int serverseitigeOid = Long.valueOf(json.get("Oid").getAsLong()).intValue();
|
||||
String chatText = json.get("ChatText").getAsString();
|
||||
|
||||
boolean isDelivered = json.get("IsDelivered").getAsBoolean();
|
||||
|
||||
boolean isTeam = !json.get("TeamOid").isJsonNull();
|
||||
|
||||
@@ -3,8 +3,12 @@ package util;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import entities.ChatEntity;
|
||||
import tcpConnection.SocketManager;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 09.09.2016.
|
||||
*/
|
||||
@@ -17,10 +21,14 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
|
||||
{
|
||||
Log.i("NOTIFICATION_CANCELLED", "Benachrichtigung gelöscht");
|
||||
|
||||
// nicht?
|
||||
//Util.unreadMessagesCount--;
|
||||
Bundle extras = intent.getExtras();
|
||||
int recipientOid = extras.getInt("RecipientOid");
|
||||
boolean isTeam = extras.getBoolean("IsTeam");
|
||||
|
||||
//TODO: auf die Konversationen achten
|
||||
Util.removeMessagesCount(new ChatEntity(recipientOid, isTeam));
|
||||
|
||||
Util.conversationsCount = 0;
|
||||
SocketManager.notificationEntities.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ import android.os.Bundle;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -46,14 +46,20 @@ public class Util {
|
||||
|
||||
public static final String NOTIFICATION_CANCELLED = "notification_cancelled";
|
||||
|
||||
public static int unreadMessagesCount = 0;
|
||||
//public static int unreadMessagesCount = 0;
|
||||
public static int conversationsCount = 0;
|
||||
|
||||
public static HashMap<ChatEntity, Integer> entity2MessagesCountRel = new HashMap<>();
|
||||
|
||||
//TODO: Notifications zählen. Bei Nachrichten verschiedener Unterhaltungen nur noch eine kleine Notification anzeigen mit "Sie haben x Nachrichten in y Unterhaltungen
|
||||
public static void SetNotify(String username, String message, int recipientOid, boolean isTeam, String teamMemberOids, String teamMemberNames, Context packageContext) {
|
||||
unreadMessagesCount++;
|
||||
int unreadMessagesCount = entity2MessagesCountRel.size() + 1;
|
||||
//TODO: unterscheiden, ob es sich um eine einzelne Benachrichtigung handelt
|
||||
|
||||
if(SocketManager.notificationEntities.keySet().size() >= 1) {
|
||||
conversationsCount = SocketManager.notificationEntities.keySet().size();
|
||||
}
|
||||
|
||||
String mUsername = conversationsCount > 1 ? String.valueOf(conversationsCount) + " Konversationen" : username;
|
||||
String mMessage = unreadMessagesCount > 1 ? String.valueOf(unreadMessagesCount) + " Nachrichten" : message;
|
||||
|
||||
@@ -85,13 +91,20 @@ public class Util {
|
||||
|
||||
NotificationManager mNotifyMgr = (NotificationManager) packageContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
mBuilder.setDeleteIntent(getDeletedIntent(packageContext));
|
||||
mBuilder.setDeleteIntent(getDeletedIntent(packageContext, recipientOid, isTeam));
|
||||
|
||||
mBuilder.setContentIntent(resultPendingIntent);
|
||||
|
||||
Random random = new Random();
|
||||
int notificationId = 1;
|
||||
ChatEntity chatEntity = new ChatEntity(SoapConnectionManager.User.getPersonOid(), isTeam);
|
||||
ChatEntity chatEntity = new ChatEntity(recipientOid, isTeam);
|
||||
|
||||
|
||||
|
||||
// TODO: in entity2MessagesCountRels einfügen und Anzahl der Nachrichten aktualisieren
|
||||
updateMessagesCount(chatEntity, 1);
|
||||
|
||||
|
||||
NotificationLog notificationLog = new NotificationLog(notificationId, Calendar.getInstance().getTime());
|
||||
|
||||
while(SocketManager.notificationEntities.containsValue(notificationLog)) {
|
||||
@@ -101,11 +114,9 @@ public class Util {
|
||||
|
||||
SocketManager.notificationEntities.put(chatEntity, notificationLog);
|
||||
|
||||
//TODO: alte Notifications löschen ---------------------------------
|
||||
ArrayList<ChatEntity> entities2remove = new ArrayList<>();
|
||||
|
||||
if(conversationsCount > 1 || unreadMessagesCount > 1) {
|
||||
//TODO: differenzieren, welche Notifications gelöscht werden müssen. Alle bis auf die aktuelle Benachrichtigungen löschen.
|
||||
for(Map.Entry<ChatEntity, NotificationLog> entry : SocketManager.notificationEntities.entrySet()) {
|
||||
if(!(entry.getKey().equals(chatEntity) && entry.getValue().equals(notificationLog))) {
|
||||
mNotifyMgr.cancel(entry.getValue().getNotificationId());
|
||||
@@ -113,15 +124,23 @@ public class Util {
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO: ------------------------------------------------------------
|
||||
|
||||
for(ChatEntity entry : entities2remove) {
|
||||
SocketManager.notificationEntities.remove(entry);
|
||||
}
|
||||
|
||||
mNotifyMgr.notify(notificationId, mBuilder.build());
|
||||
}
|
||||
|
||||
protected static PendingIntent getDeletedIntent(Context context) {
|
||||
protected static PendingIntent getDeletedIntent(Context context, int recipientOid, boolean isTeam) {
|
||||
Intent intent = new Intent(context, NotificationBroadcastReceiver.class);
|
||||
intent.setAction(Util.NOTIFICATION_CANCELLED);
|
||||
|
||||
Bundle extras = new Bundle();
|
||||
extras.putInt("RecipientOid", recipientOid);
|
||||
extras.putBoolean("IsTeam", isTeam);
|
||||
intent.putExtras(extras);
|
||||
|
||||
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
}
|
||||
|
||||
@@ -200,4 +219,30 @@ public class Util {
|
||||
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public static ChatEntity getChatEntityFromOnlineEntitiesByOid(int personOid, boolean isTeam) {
|
||||
for(ChatEntity item : SocketManager.onlineEntities) {
|
||||
if(item.getOid() == personOid && item.isTeam() == isTeam) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void updateMessagesCount(ChatEntity entity, int value2add) {
|
||||
int newValue = value2add;
|
||||
|
||||
if(entity2MessagesCountRel.containsKey(entity)) {
|
||||
newValue = entity2MessagesCountRel.get(entity) + value2add;
|
||||
}
|
||||
|
||||
entity2MessagesCountRel.put(entity, newValue);
|
||||
}
|
||||
|
||||
public static void removeMessagesCount(ChatEntity entity) {
|
||||
if(entity2MessagesCountRel.containsKey(entity)) {
|
||||
entity2MessagesCountRel.remove(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user