Exemple #1
0
 /**
  * Display the visit card
  *
  * @param contact Contact
  */
 private void displayVisitCard(String contact) {
   try {
     Uri contactUri =
         Uri.withAppendedPath(
             ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(contact));
     Uri vcard = ContactUtil.getInstance(this).getVCard(contactUri);
     TextView vcardView = (TextView) findViewById(R.id.vcard);
     vcardView.setText(vcard.getPath());
   } catch (RcsGenericException e) {
     showExceptionThenExit(e);
   }
 }
Exemple #2
0
  @Override
  public boolean processIntent(Intent intent) {
    String action = intent.getAction();
    if (LogUtils.isActive) {
      Log.d(LOGTAG, "processIntent: " + action);
    }
    String oldChatId = mChatId;
    try {
      switch ((GroupChatMode) intent.getSerializableExtra(EXTRA_MODE)) {
        case OUTGOING:
          /* Initiate a Group Chat: Get subject */
          mSubject = intent.getStringExtra(GroupChatView.EXTRA_SUBJECT);
          updateGroupChatViewTitle(mSubject);
          /* Get the list of participants */
          ContactUtil contactUtil = ContactUtil.getInstance(this);
          List<String> contacts = intent.getStringArrayListExtra(GroupChatView.EXTRA_PARTICIPANTS);
          if (contacts == null || contacts.isEmpty()) {
            showMessageThenExit(R.string.label_invalid_contacts);
            return false;
          }
          for (String contact : contacts) {
            mParticipants.add(contactUtil.formatContact(contact));
          }
          if (mParticipants.isEmpty()) {
            showMessageThenExit(R.string.label_invalid_contacts);
            return false;
          }
          return initiateGroupChat(oldChatId == null);

        case OPEN:
          /* Open an existing session from the history log */
          mChatId = intent.getStringExtra(GroupChatIntent.EXTRA_CHAT_ID);
          mGroupChat = mChatService.getGroupChat(mChatId);
          if (mGroupChat == null) {
            if (LogUtils.isActive) {
              Log.e(LOGTAG, "Groupchat not found for Id=".concat(mChatId));
            }
            showMessageThenExit(R.string.label_session_not_found);
            return false;
          }
          setCursorLoader(oldChatId == null);
          sChatIdOnForeground = mChatId;
          mSubject = mGroupChat.getSubject();
          updateGroupChatViewTitle(mSubject);
          /* Set list of participants */
          mParticipants = mGroupChat.getParticipants().keySet();
          if (LogUtils.isActive) {
            Log.i(LOGTAG, "processIntent chatId=" + mChatId + " subject='" + mSubject + "'");
          }
          return true;

        case INCOMING:
          String rxChatId = intent.getStringExtra(GroupChatIntent.EXTRA_CHAT_ID);
          if (GroupChatIntent.ACTION_NEW_GROUP_CHAT_MESSAGE.equals(action)) {
            String rxMsgId = intent.getStringExtra(GroupChatIntent.EXTRA_MESSAGE_ID);
            mChatService.markMessageAsRead(rxMsgId);
          }
          mChatId = rxChatId;
          mGroupChat = mChatService.getGroupChat(mChatId);
          if (mGroupChat == null) {
            showMessageThenExit(R.string.label_session_not_found);
            return false;
          }
          setCursorLoader(oldChatId == null);
          sChatIdOnForeground = mChatId;
          ContactId contact = mGroupChat.getRemoteContact();
          mSubject = mGroupChat.getSubject();
          updateGroupChatViewTitle(mSubject);
          mParticipants = mGroupChat.getParticipants().keySet();
          /* Display accept/reject dialog */
          if (GroupChat.State.INVITED == mGroupChat.getState()) {
            displayAcceptRejectDialog(contact);
          }
          if (LogUtils.isActive) {
            Log.d(LOGTAG, "New group chat for chatId ".concat(mChatId));
          }
          return true;
      }

    } catch (RcsServiceException e) {
      showExceptionThenExit(e);
    }
    return false;
  }