Esempio n. 1
0
  public static void notifyMessageDeliveryFailed(
      Context context, Recipients recipients, long threadId) {
    if (visibleThread == threadId) {
      sendInThreadNotification(context, recipients);
    } else {
      Intent intent = new Intent(context, ConversationActivity.class);
      intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
      intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, threadId);
      intent.setData((Uri.parse("custom://" + System.currentTimeMillis())));

      FailedNotificationBuilder builder =
          new FailedNotificationBuilder(
              context, SMSSecurePreferences.getNotificationPrivacy(context), intent);
      ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE))
          .notify((int) threadId, builder.build());
    }
  }
Esempio n. 2
0
  public static void updateNotification(Context context, MasterSecret masterSecret, long threadId) {
    Recipients recipients =
        DatabaseFactory.getThreadDatabase(context).getRecipientsForThreadId(threadId);

    if (!SMSSecurePreferences.isNotificationsEnabled(context)
        || (recipients != null && recipients.isMuted())) {
      return;
    }

    if (visibleThread == threadId) {
      ThreadDatabase threads = DatabaseFactory.getThreadDatabase(context);
      threads.setRead(threadId);
      sendInThreadNotification(context, threads.getRecipientsForThreadId(threadId));
    } else {
      updateNotification(context, masterSecret, true, 0);
    }
  }