コード例 #1
0
  /**
   * Forward file transfer invitation to UI
   *
   * @param invitation Intent invitation
   * @param ftDao the file transfer data object
   */
  private void forwardFileTransferInvitationToUi(Intent invitation, FileTransferDAO ftDao) {
    ContactId contact = ftDao.getContact();
    if (ftDao.getContact() == null) {
      if (LogUtils.isActive) {
        Log.e(LOGTAG, "forwardFileTransferInvitationToUi failed: cannot parse contact");
      }
      return;
    }
    Intent intent = ReceiveFileTransfer.forgeInvitationIntent(this, ftDao, invitation);
    /*
     * If the PendingIntent has the same operation, action, data, categories, components, and
     * flags it will be replaced. Invitation should be notified individually so we use a random
     * generator to provide a unique request code and reuse it for the notification.
     */
    int uniqueId = Utils.getUniqueIdForPendingIntent();
    PendingIntent pi =
        PendingIntent.getActivity(this, uniqueId, intent, PendingIntent.FLAG_ONE_SHOT);

    String displayName = RcsContactUtil.getInstance(this).getDisplayName(contact);
    String title = getString(R.string.title_recv_file_transfer);
    String message = getString(R.string.label_from_args, displayName);

    /* Send notification */
    NotificationManager notificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notif = buildNotification(pi, title, message);
    notificationManager.notify(uniqueId, notif);
    TalkList.notifyNewConversationEvent(this, FileTransferIntent.ACTION_NEW_INVITATION);
  }
コード例 #2
0
 private void forwardUndeliveredFileTransferToUi(Intent undeliveredIntent, ContactId contact) {
   Intent intent = OneToOneTalkView.forgeIntentOnStackEvent(this, contact, undeliveredIntent);
   ChatPendingIntentManager pendingIntentmanager =
       ChatPendingIntentManager.getChatPendingIntentManager(this);
   Integer uniqueId = pendingIntentmanager.tryContinueChatConversation(intent, contact.toString());
   if (uniqueId != null) {
     PendingIntent contentIntent =
         PendingIntent.getActivity(this, uniqueId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
     String displayName = RcsContactUtil.getInstance(this).getDisplayName(contact);
     String title = getString(R.string.title_undelivered_filetransfer);
     String msg = getString(R.string.label_undelivered_filetransfer, displayName);
     Notification notif = buildNotification(contentIntent, title, msg);
     pendingIntentmanager.postNotification(uniqueId, notif);
   }
 }