mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 02:30:15 +00:00
Display a notification when unable retrieve messages for push
Fixes #6684 // FREEBIE
This commit is contained in:
@@ -84,6 +84,7 @@ public class MessageNotifier {
|
||||
public static final String EXTRA_REMOTE_REPLY = "extra_remote_reply";
|
||||
|
||||
private static final int SUMMARY_NOTIFICATION_ID = 1338;
|
||||
private static final int PENDING_MESSAGES_ID = 1111;
|
||||
private static final String NOTIFICATION_GROUP = "messages";
|
||||
private static final long MIN_AUDIBLE_PERIOD_MILLIS = TimeUnit.SECONDS.toMillis(2);
|
||||
private static final long DESKTOP_ACTIVITY_PERIOD = TimeUnit.MINUTES.toMillis(1);
|
||||
@@ -116,6 +117,15 @@ public class MessageNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
public static void notifyMessagesPending(Context context) {
|
||||
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PendingMessageNotificationBuilder builder = new PendingMessageNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context));
|
||||
ServiceUtil.getNotificationManager(context).notify(PENDING_MESSAGES_ID, builder.build());
|
||||
}
|
||||
|
||||
public static void cancelDelayedNotifications() {
|
||||
executor.cancel();
|
||||
}
|
||||
@@ -153,7 +163,8 @@ public class MessageNotifier {
|
||||
if (notification.getId() != SUMMARY_NOTIFICATION_ID &&
|
||||
notification.getId() != CallNotificationBuilder.WEBRTC_NOTIFICATION &&
|
||||
notification.getId() != KeyCachingService.SERVICE_RUNNING_ID &&
|
||||
notification.getId() != MessageRetrievalService.FOREGROUND_ID)
|
||||
notification.getId() != MessageRetrievalService.FOREGROUND_ID &&
|
||||
notification.getId() != PENDING_MESSAGES_ID)
|
||||
{
|
||||
for (NotificationItem item : notificationState.getNotifications()) {
|
||||
if (notification.getId() == (SUMMARY_NOTIFICATION_ID + item.getThreadId())) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.thoughtcrime.securesms.notifications;
|
||||
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase;
|
||||
import org.thoughtcrime.securesms.preferences.NotificationPrivacyPreference;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
public class PendingMessageNotificationBuilder extends AbstractNotificationBuilder {
|
||||
|
||||
public PendingMessageNotificationBuilder(Context context, NotificationPrivacyPreference privacy) {
|
||||
super(context, privacy);
|
||||
|
||||
Intent intent = new Intent(context, ConversationListActivity.class);
|
||||
|
||||
setSmallIcon(R.drawable.icon_notification);
|
||||
setColor(context.getResources().getColor(R.color.textsecure_primary));
|
||||
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
||||
setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
||||
|
||||
setContentTitle(context.getString(R.string.MessageNotifier_pending_signal_messages));
|
||||
setContentText(context.getString(R.string.MessageNotifier_you_have_pending_signal_messages));
|
||||
setTicker(context.getString(R.string.MessageNotifier_you_have_pending_signal_messages));
|
||||
|
||||
setContentIntent(PendingIntent.getActivity(context, 0, intent, 0));
|
||||
setAutoCancel(true);
|
||||
setAlarms(null, RecipientPreferenceDatabase.VibrateState.DEFAULT);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user