當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageNotifier.updateNotification方法代碼示例

本文整理匯總了Java中org.thoughtcrime.securesms.notifications.MessageNotifier.updateNotification方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageNotifier.updateNotification方法的具體用法?Java MessageNotifier.updateNotification怎麽用?Java MessageNotifier.updateNotification使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.thoughtcrime.securesms.notifications.MessageNotifier的用法示例。


在下文中一共展示了MessageNotifier.updateNotification方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: notifyNewUsers

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private static void notifyNewUsers(@NonNull  Context context,
                                   @Nullable MasterSecret masterSecret,
                                   @NonNull  List<String> newUsers)
{
  if (!TextSecurePreferences.isNewContactsNotificationEnabled(context)) return;

  for (String newUser : newUsers) {
    if (!SessionUtil.hasSession(context, masterSecret, newUser) && !Util.isOwnNumber(context, newUser)) {
      IncomingJoinedMessage  message      = new IncomingJoinedMessage(newUser);
      Optional<InsertResult> insertResult = DatabaseFactory.getSmsDatabase(context).insertMessageInbox(message);

      if (insertResult.isPresent()) {
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        if (hour >= 9 && hour < 23) {
          MessageNotifier.updateNotification(context, masterSecret, false, insertResult.get().getThreadId(), true);
        } else {
          MessageNotifier.updateNotification(context, masterSecret, false, insertResult.get().getThreadId(), false);
        }
      }
    }
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:23,代碼來源:DirectoryHelper.java

示例2: handleNoSessionMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private void handleNoSessionMessage(@NonNull MasterSecretUnion masterSecret,
                                    @NonNull SignalServiceEnvelope envelope,
                                    @NonNull Optional<Long> smsMessageId)
{
  EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);

  if (!smsMessageId.isPresent()) {
    Optional<InsertResult> insertResult = insertPlaceholder(envelope);

    if (insertResult.isPresent()) {
      smsDatabase.markAsNoSession(insertResult.get().getMessageId());
      MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
    }
  } else {
    smsDatabase.markAsNoSession(smsMessageId.get());
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:18,代碼來源:PushDecryptJob.java

示例3: handleInvalidVersionMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private void handleInvalidVersionMessage(@NonNull MasterSecretUnion masterSecret,
                                         @NonNull SignalServiceEnvelope envelope,
                                         @NonNull Optional<Long> smsMessageId)
{
  EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);

  if (!smsMessageId.isPresent()) {
    Optional<InsertResult> insertResult = insertPlaceholder(envelope);

    if (insertResult.isPresent()) {
      smsDatabase.markAsInvalidVersionKeyExchange(insertResult.get().getMessageId());
      MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
    }
  } else {
    smsDatabase.markAsInvalidVersionKeyExchange(smsMessageId.get());
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:18,代碼來源:PushDecryptJob.java

示例4: notifyNewUsers

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private static void notifyNewUsers(@NonNull  Context context,
                                   @Nullable MasterSecret masterSecret,
                                   @NonNull  List<String> newUsers)
{
  if (!TextSecurePreferences.isNewContactsNotificationEnabled(context)) return;

  for (String newUser : newUsers) {
    if (!SessionUtil.hasSession(context, masterSecret, newUser) && !Util.isOwnNumber(context, newUser)) {
      IncomingJoinedMessage  message      = new IncomingJoinedMessage(newUser);
      Optional<InsertResult> insertResult = DatabaseFactory.getSmsDatabase(context).insertMessageInbox(message);

      if (insertResult.isPresent()) {
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        if (hour >= 9 && hour < 23) {
          MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId(), true);
        } else {
          MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId(), false);
        }
      }
    }
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:23,代碼來源:DirectoryHelper.java

示例5: onRun

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
@Override
public void onRun(MasterSecret masterSecret) throws IOException {
  final AttachmentId attachmentId = new AttachmentId(partRowId, partUniqueId);
  final Attachment   attachment   = DatabaseFactory.getAttachmentDatabase(context).getAttachment(attachmentId);

  if (attachment == null) {
    Log.w(TAG, "attachment no longer exists.");
    return;
  }

  if (!attachment.isInProgress()) {
    Log.w(TAG, "Attachment was already downloaded.");
    return;
  }

  Log.w(TAG, "Downloading push part " + attachmentId);

  retrieveAttachment(masterSecret, messageId, attachmentId, attachment);
  MessageNotifier.updateNotification(context, masterSecret);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:21,代碼來源:AttachmentDownloadJob.java

示例6: handleLegacyMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private void handleLegacyMessage(@NonNull MasterSecretUnion masterSecret,
                                 @NonNull SignalServiceEnvelope envelope,
                                 @NonNull Optional<Long> smsMessageId)
{
  EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);

  if (!smsMessageId.isPresent()) {
    Optional<InsertResult> insertResult = insertPlaceholder(envelope);

    if (insertResult.isPresent()) {
      smsDatabase.markAsLegacyVersion(insertResult.get().getMessageId());
      MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
    }
  } else {
    smsDatabase.markAsLegacyVersion(smsMessageId.get());
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:18,代碼來源:PushDecryptJob.java

示例7: handleCorruptMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private void handleCorruptMessage(@NonNull MasterSecretUnion masterSecret,
                                  @NonNull SignalServiceEnvelope envelope,
                                  @NonNull Optional<Long> smsMessageId)
{
  EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);

  if (!smsMessageId.isPresent()) {
    Optional<InsertResult> insertResult = insertPlaceholder(envelope);

    if (insertResult.isPresent()) {
      smsDatabase.markAsDecryptFailed(insertResult.get().getMessageId());
      MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
    }
  } else {
    smsDatabase.markAsDecryptFailed(smsMessageId.get());
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:18,代碼來源:PushDecryptJob.java

示例8: storeMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private static void storeMessage(Context context, MasterSecret masterSecret,
                                 TextSecureEnvelope envelope, TextSecureGroup group,
                                 GroupContext storage)
{
  if (group.getAvatar().isPresent()) {
    ApplicationContext.getInstance(context).getJobManager()
                      .add(new AvatarDownloadJob(context, group.getGroupId()));
  }

  EncryptingSmsDatabase smsDatabase  = DatabaseFactory.getEncryptingSmsDatabase(context);
  String                body         = Base64.encodeBytes(storage.toByteArray());
  IncomingTextMessage   incoming     = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(), envelope.getTimestamp(), body, Optional.of(group));
  IncomingGroupMessage  groupMessage = new IncomingGroupMessage(incoming, storage, body);

  Pair<Long, Long> messageAndThreadId = smsDatabase.insertMessageInbox(masterSecret, groupMessage);
  MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:18,代碼來源:GroupMessageProcessor.java

示例9: onCreate

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
@Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    this.masterSecret = getIntent().getParcelableExtra("master_secret");

    if (needsUpgradeTask()) {
      Log.w("DatabaseUpgradeActivity", "Upgrading...");
      setContentView(R.layout.database_upgrade_activity);

      ProgressBar indeterminateProgress = (ProgressBar)findViewById(R.id.indeterminate_progress);
      ProgressBar determinateProgress   = (ProgressBar)findViewById(R.id.determinate_progress);

      new DatabaseUpgradeTask(indeterminateProgress, determinateProgress)
          .execute(VersionTracker.getLastSeenVersion(this));
    } else {
      VersionTracker.updateLastSeenVersion(this);
      ApplicationContext.getInstance(this)
                        .getJobManager()
                        .setEncryptionKeys(new EncryptionKeys(ParcelUtil.serialize(masterSecret)));
//      DecryptingQueue.schedulePendingDecrypts(DatabaseUpgradeActivity.this, masterSecret);
      MessageNotifier.updateNotification(DatabaseUpgradeActivity.this, masterSecret);
      startActivity((Intent)getIntent().getParcelableExtra("next_intent"));
      finish();
    }
  }
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:26,代碼來源:DatabaseUpgradeActivity.java

示例10: handleEndSessionMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private void handleEndSessionMessage(MasterSecret masterSecret, long recipientId,
                                     TextSecureEnvelope envelope, TextSecureMessage message)
{
  IncomingTextMessage incomingTextMessage = new IncomingTextMessage(envelope.getSource(),
                                                                    envelope.getSourceDevice(),
                                                                    message.getTimestamp(),
                                                                    "", Optional.<TextSecureGroup>absent());

  IncomingEndSessionMessage incomingEndSessionMessage = new IncomingEndSessionMessage(incomingTextMessage);
  EncryptingSmsDatabase     database                  = DatabaseFactory.getEncryptingSmsDatabase(context);
  Pair<Long, Long>          messageAndThreadId        = database.insertMessageInbox(masterSecret, incomingEndSessionMessage);

  SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
  sessionStore.deleteAllSessions(recipientId);

  SecurityEvent.broadcastSecurityUpdateEvent(context, messageAndThreadId.second);
  MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:19,代碼來源:PushDecryptJob.java

示例11: handleMediaMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private void handleMediaMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, TextSecureMessage message)
    throws MmsException
{
  String               localNumber  = TextSecurePreferences.getLocalNumber(context);
  MmsDatabase          database     = DatabaseFactory.getMmsDatabase(context);
  IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
                                                               localNumber, message.getTimestamp(),
                                                               Optional.fromNullable(envelope.getRelay()),
                                                               message.getBody(),
                                                               message.getGroupInfo(),
                                                               message.getAttachments());

  Pair<Long, Long> messageAndThreadId;

  if (message.isSecure()) {
    messageAndThreadId = database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);
  } else {
    messageAndThreadId = database.insertMessageInbox(masterSecret, mediaMessage, null, -1);
  }

  ApplicationContext.getInstance(context)
                    .getJobManager()
                    .add(new AttachmentDownloadJob(context, messageAndThreadId.first));

  MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:27,代碼來源:PushDecryptJob.java

示例12: storeMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private Pair<Long, Long> storeMessage(IncomingTextMessage message) {
  EncryptingSmsDatabase database     = DatabaseFactory.getEncryptingSmsDatabase(context);
  MasterSecret          masterSecret = KeyCachingService.getMasterSecret(context);

  Pair<Long, Long> messageAndThreadId;

  if (message.isSecureMessage()) {
    messageAndThreadId = database.insertMessageInbox((MasterSecret)null, message);
  } else if (masterSecret == null) {
    messageAndThreadId = database.insertMessageInbox(MasterSecretUtil.getAsymmetricMasterSecret(context, null), message);
  } else {
    messageAndThreadId = database.insertMessageInbox(masterSecret, message);
  }

  if (masterSecret == null || message.isSecureMessage() || message.isKeyExchange()) {
    ApplicationContext.getInstance(context)
                      .getJobManager()
                      .add(new SmsDecryptJob(context, messageAndThreadId.first));
  } else {
    MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
  }

  return messageAndThreadId;
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:25,代碼來源:SmsReceiveJob.java

示例13: handleEndSessionMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private void handleEndSessionMessage(@NonNull MasterSecretUnion        masterSecret,
                                     @NonNull SignalServiceEnvelope    envelope,
                                     @NonNull SignalServiceDataMessage message,
                                     @NonNull Optional<Long>           smsMessageId)
{
  EncryptingSmsDatabase smsDatabase         = DatabaseFactory.getEncryptingSmsDatabase(context);
  IncomingTextMessage   incomingTextMessage = new IncomingTextMessage(envelope.getSource(),
                                                                      envelope.getSourceDevice(),
                                                                      message.getTimestamp(),
                                                                      "", Optional.<SignalServiceGroup>absent(), 0);

  Long threadId;

  if (!smsMessageId.isPresent()) {
    IncomingEndSessionMessage incomingEndSessionMessage = new IncomingEndSessionMessage(incomingTextMessage);
    Optional<InsertResult>    insertResult              = smsDatabase.insertMessageInbox(masterSecret, incomingEndSessionMessage);

    if (insertResult.isPresent()) threadId = insertResult.get().getThreadId();
    else                          threadId = null;
  } else {
    smsDatabase.markAsEndSession(smsMessageId.get());
    threadId = smsDatabase.getThreadIdForMessage(smsMessageId.get());
  }

  if (threadId != null) {
    SessionStore sessionStore = new TextSecureSessionStore(context);
    sessionStore.deleteAllSessions(envelope.getSource());

    SecurityEvent.broadcastSecurityUpdateEvent(context);
    MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), threadId);
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:33,代碼來源:PushDecryptJob.java

示例14: handleMediaMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private void handleMediaMessage(@NonNull MasterSecretUnion masterSecret,
                                @NonNull SignalServiceEnvelope envelope,
                                @NonNull SignalServiceDataMessage message,
                                @NonNull Optional<Long> smsMessageId)
    throws MmsException
{
  MmsDatabase          database     = DatabaseFactory.getMmsDatabase(context);
  String               localNumber  = TextSecurePreferences.getLocalNumber(context);
  Recipients           recipients   = getMessageDestination(envelope, message);
  IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
                                                               localNumber, message.getTimestamp(), -1,
                                                               message.getExpiresInSeconds() * 1000, false,
                                                               Optional.fromNullable(envelope.getRelay()),
                                                               message.getBody(),
                                                               message.getGroupInfo(),
                                                               message.getAttachments());

  if (message.getExpiresInSeconds() != recipients.getExpireMessages()) {
    handleExpirationUpdate(masterSecret, envelope, message, Optional.<Long>absent());
  }

  Optional<InsertResult> insertResult = database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);

  if (insertResult.isPresent()) {
    List<DatabaseAttachment> attachments = DatabaseFactory.getAttachmentDatabase(context).getAttachmentsForMessage(insertResult.get().getMessageId());

    for (DatabaseAttachment attachment : attachments) {
      ApplicationContext.getInstance(context)
                        .getJobManager()
                        .add(new AttachmentDownloadJob(context, insertResult.get().getMessageId(),
                                                       attachment.getAttachmentId()));
    }

    if (smsMessageId.isPresent()) {
      DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
    }

    MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:41,代碼來源:PushDecryptJob.java

示例15: handleUntrustedIdentityMessage

import org.thoughtcrime.securesms.notifications.MessageNotifier; //導入方法依賴的package包/類
private void handleUntrustedIdentityMessage(@NonNull MasterSecretUnion masterSecret,
                                            @NonNull SignalServiceEnvelope envelope,
                                            @NonNull Optional<Long> smsMessageId)
{
  try {
    EncryptingSmsDatabase database       = DatabaseFactory.getEncryptingSmsDatabase(context);
    Recipients            recipients     = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
    long                  recipientId    = recipients.getPrimaryRecipient().getRecipientId();
    byte[]                serialized     = envelope.hasLegacyMessage() ? envelope.getLegacyMessage() : envelope.getContent();
    PreKeySignalMessage   whisperMessage = new PreKeySignalMessage(serialized);
    IdentityKey           identityKey    = whisperMessage.getIdentityKey();
    String                encoded        = Base64.encodeBytes(serialized);

    IncomingTextMessage   textMessage    = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(),
                                                                   envelope.getTimestamp(), encoded,
                                                                   Optional.<SignalServiceGroup>absent(), 0);

    if (!smsMessageId.isPresent()) {
      IncomingPreKeyBundleMessage bundleMessage = new IncomingPreKeyBundleMessage(textMessage, encoded, envelope.hasLegacyMessage());
      Optional<InsertResult>      insertResult  = database.insertMessageInbox(masterSecret, bundleMessage);

      if (insertResult.isPresent()) {
        database.setMismatchedIdentity(insertResult.get().getMessageId(), recipientId, identityKey);
        MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
      }
    } else {
      database.updateMessageBody(masterSecret, smsMessageId.get(), encoded);
      database.markAsPreKeyBundle(smsMessageId.get());
      database.setMismatchedIdentity(smsMessageId.get(), recipientId, identityKey);
    }
  } catch (InvalidMessageException | InvalidVersionException e) {
    throw new AssertionError(e);
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:35,代碼來源:PushDecryptJob.java


注:本文中的org.thoughtcrime.securesms.notifications.MessageNotifier.updateNotification方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。