Пример #1
0
  private void invite() {
    List<Conversation> conversations = xmppConnectionService.getConversations();
    Conversation conversation = null;
    for (Conversation tmpConversation : conversations) {
      if (tmpConversation.getUuid().equals(getIntent().getStringExtra("uuid"))) {
        conversation = tmpConversation;
        break;
      }
      // else if (!tmpConversation.getUuid().equals(
      // getIntent().getStringExtra("uuid"))
      // && ConversationActivity.INVITE_STRING
      // .equalsIgnoreCase("invite")) {
      // conversation = tmpConversation;
      // }

    }
    if (conversation != null) {
      xmppConnectionService.inviteToConference(conversation, selectedContacts);
    }
    finish();
  }
Пример #2
0
        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
          switch (item.getItemId()) {
            case R.id.action_start_conversation:
              if (selectedContacts.size() == 1) {
                startConversation(selectedContacts.get(0));
              } else {
                // startConference();
              }
              break;
            case R.id.action_contact_details:
              Intent intent = new Intent(getApplicationContext(), ContactDetailsActivity.class);
              intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
              intent.putExtra("account", selectedContacts.get(0).getAccount().getJid());
              intent.putExtra("contact", selectedContacts.get(0).getJid());
              startActivity(intent);
              finish();
              break;
            case R.id.action_invite:
              invite();
              break;
            case R.id.action_invite_to_existing:
              final List<Conversation> mucs = new ArrayList<Conversation>();
              for (Conversation conv : xmppConnectionService.getConversations()) {
                if (conv.getMode() == Conversation.MODE_MULTI) {
                  mucs.add(conv);
                }
              }
              AlertDialog.Builder builder = new AlertDialog.Builder(activity);
              builder.setTitle(getString(R.string.invite_contacts_to_existing));
              if (mucs.size() >= 1) {
                String[] options = new String[mucs.size()];
                for (int i = 0; i < options.length; ++i) {
                  options[i] = mucs.get(i).getName(useSubject);
                }
                builder.setItems(
                    options,
                    new OnClickListener() {

                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        Conversation conversation = mucs.get(which);
                        if (isOnline(conversation.getAccount())) {
                          xmppConnectionService.inviteToConference(conversation, selectedContacts);
                          Toast.makeText(
                                  activity, getString(R.string.invitation_sent), Toast.LENGTH_SHORT)
                              .show();
                          actionMode.finish();
                        }
                      }
                    });
              } else {
                builder.setMessage(getString(R.string.no_open_mucs));
              }
              builder.setNegativeButton(getString(R.string.cancel), null);
              builder.create().show();
              break;
            default:
              break;
          }
          return false;
        }