Ejemplo n.º 1
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    switch (position) {
      case 0:
        startActivity(new Intent(this, InitiateSingleChat.class));
        break;

      case 1:
        startActivity(new Intent(this, SingleChatList.class));
        break;

      case 2:
        /* Check if Group chat initialization is allowed */
        ChatService chatService = ConnectionManager.getInstance().getChatApi();
        try {
          if (chatService.isAllowedToInitiateGroupChat()) {
            startActivity(new Intent(this, InitiateGroupChat.class));
          } else {
            Utils.showMessage(this, getString(R.string.label_NotAllowedToInitiateGroupChat));
          }
        } catch (RcsServiceException e) {
          if (LogUtils.isActive) {
            Log.d(LOGTAG, "Cannot check if Group chat initialization is allowed", e);
          }
          Utils.showMessage(this, getString(R.string.label_api_failed));
        }
        break;

      case 3:
        startActivity(new Intent(this, GroupChatList.class));
        break;

      case 4:
        startActivity(new Intent(this, ChatServiceConfigActivity.class));
        break;

      case 5:
        Set<ContactId> contacts = new HashSet<ContactId>();
        Cursor cursor = null;
        try {
          cursor =
              getContentResolver().query(CapabilitiesLog.CONTENT_URI, PROJECTION, null, null, null);
          while (cursor.moveToNext()) {
            String contact = cursor.getString(cursor.getColumnIndex(CapabilitiesLog.CONTACT));
            contacts.add(ContactUtil.formatContact(contact));
          }
          DisplayGeoloc.showContactsOnMap(this, contacts);
        } catch (Exception e) {
          // Skip intentionally
        } finally {
          if (cursor != null) {
            cursor.close();
          }
        }
        break;
    }
  }
Ejemplo n.º 2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    try {
      switch (item.getItemId()) {
        case R.id.menu_insert_smiley:
          AlertDialog alert =
              Smileys.showSmileyDialog(
                  this, mComposeText, getResources(), getString(R.string.menu_insert_smiley));
          registerDialog(alert);
          break;

        case R.id.menu_participants:
          alert =
              Utils.showList(
                  this,
                  getString(R.string.menu_participants),
                  getSetOfParticipants(mGroupChat.getParticipants()));
          registerDialog(alert);
          break;

        case R.id.menu_add_participant:
          addParticipants();
          break;

        case R.id.menu_quicktext:
          addQuickText();
          break;

        case R.id.menu_send_file:
          SendGroupFile.startActivity(this, mChatId);
          break;

        case R.id.menu_send_geoloc:
          getGeoLoc();
          break;

        case R.id.menu_showus_map:
          DisplayGeoloc.showContactsOnMap(this, mGroupChat.getParticipants().keySet());
          break;

        case R.id.menu_close_session:
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
          builder.setTitle(R.string.title_chat_exit);
          builder.setPositiveButton(
              R.string.label_ok,
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  if (mGroupChat != null) {
                    try {
                      mGroupChat.leave();
                    } catch (RcsServiceException e) {
                      showExceptionThenExit(e);
                    }
                  }
                  GroupChatView.this.finish();
                }
              });
          builder.setNegativeButton(R.string.label_cancel, null);
          builder.setCancelable(true);
          registerDialog(builder.show());
          break;
      }

    } catch (RcsServiceException e) {
      showException(e);
    }
    return true;
  }