Commit ec6b3ca6 authored by Tiago Cunha's avatar Tiago Cunha

Clean up read notifications

parent ec29bb97
...@@ -10,6 +10,7 @@ import chat.rocket.android.RocketChatCache; ...@@ -10,6 +10,7 @@ import chat.rocket.android.RocketChatCache;
import chat.rocket.android.model.ServerConfig; import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.model.ddp.RoomSubscription; import chat.rocket.android.model.ddp.RoomSubscription;
import chat.rocket.android.push.PushConstants; import chat.rocket.android.push.PushConstants;
import chat.rocket.android.push.PushNotificationHandler;
import chat.rocket.android.realm_helper.RealmListObserver; import chat.rocket.android.realm_helper.RealmListObserver;
import chat.rocket.android.realm_helper.RealmStore; import chat.rocket.android.realm_helper.RealmStore;
import chat.rocket.android.service.RocketChatService; import chat.rocket.android.service.RocketChatService;
...@@ -64,6 +65,11 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity { ...@@ -64,6 +65,11 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
editor.putString(RocketChatCache.KEY_SELECTED_ROOM_ID, editor.putString(RocketChatCache.KEY_SELECTED_ROOM_ID,
intent.getStringExtra(PushConstants.ROOM_ID)); intent.getStringExtra(PushConstants.ROOM_ID));
} }
if (intent.hasExtra(PushConstants.NOT_ID)) {
PushNotificationHandler
.cleanUpNotificationStack(intent.getIntExtra(PushConstants.NOT_ID, 0));
}
editor.apply(); editor.apply();
} }
} }
......
...@@ -42,7 +42,11 @@ public class PushNotificationHandler implements PushConstants { ...@@ -42,7 +42,11 @@ public class PushNotificationHandler implements PushConstants {
private Random random = new Random(); private Random random = new Random();
public void setNotification(int notId, String message) { public static synchronized void cleanUpNotificationStack(int notId) {
messageMap.remove(notId);
}
private synchronized void setNotification(int notId, String message) {
ArrayList<String> messageList = messageMap.get(notId); ArrayList<String> messageList = messageMap.get(notId);
if (messageList == null) { if (messageList == null) {
messageList = new ArrayList<>(); messageList = new ArrayList<>();
...@@ -56,6 +60,10 @@ public class PushNotificationHandler implements PushConstants { ...@@ -56,6 +60,10 @@ public class PushNotificationHandler implements PushConstants {
} }
} }
private synchronized ArrayList<String> getMessageList(int notId) {
return messageMap.get(notId);
}
public void showNotificationIfPossible(Context context, PushInteractor pushInteractor, public void showNotificationIfPossible(Context context, PushInteractor pushInteractor,
Bundle extras) { Bundle extras) {
...@@ -369,7 +377,7 @@ public class PushNotificationHandler implements PushConstants { ...@@ -369,7 +377,7 @@ public class PushNotificationHandler implements PushConstants {
mBuilder.setContentText(fromHtml(message)); mBuilder.setContentText(fromHtml(message));
ArrayList<String> messageList = messageMap.get(notId); ArrayList<String> messageList = getMessageList(notId);
Integer sizeList = messageList.size(); Integer sizeList = messageList.size();
if (sizeList > 1) { if (sizeList > 1) {
String sizeListMessage = sizeList.toString(); String sizeListMessage = sizeList.toString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment