/** * Open chat with specified contact and enter text to be sent. * * @param baseEntity * @param text can be <code>null</code>. */ private void openChat(BaseEntity baseEntity, String text) { if (text == null) { startActivity( ChatViewer.createSendIntent(this, baseEntity.getAccount(), baseEntity.getUser(), null)); } else { startActivity( ChatViewer.createSendIntent(this, baseEntity.getAccount(), baseEntity.getUser(), text)); } finish(); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (drawerToggle.onOptionsItemSelected(item)) { return true; } switch (item.getItemId()) { case R.id.action_search: searchView.setIconified(false); return true; case R.id.action_change_status: startActivity(StatusEditor.createIntent(this)); return true; case R.id.action_add_contact: startActivity(ContactAdd.createIntent(this)); return true; case R.id.action_close_chats: closeAllChats(); return true; case R.id.action_join_conference: startActivity(ConferenceSelectActivity.createIntent(this)); return true; case R.id.action_chat_list: startActivity(ChatViewer.createRecentChatsIntent(this)); return true; default: return super.onOptionsItemSelected(item); } }
@Override public void onContactClick(AbstractContact abstractContact) { if (action == null) { startActivity( ChatViewer.createSpecificChatIntent( this, abstractContact.getAccount(), abstractContact.getUser())); return; } switch (action) { case ACTION_ROOM_INVITE: { action = null; Intent intent = getIntent(); String account = getRoomInviteAccount(intent); String user = getRoomInviteUser(intent); if (account != null && user != null) { try { MUCManager.getInstance().invite(account, user, abstractContact.getUser()); } catch (NetworkException e) { Application.getInstance().onError(e); } } finish(); break; } case Intent.ACTION_SEND: action = null; startActivity( ChatViewer.createSendIntent( this, abstractContact.getAccount(), abstractContact.getUser(), sendText)); finish(); break; case Intent.ACTION_CREATE_SHORTCUT: { createShortcut(abstractContact); finish(); break; } default: startActivity( ChatViewer.createSpecificChatIntent( this, abstractContact.getAccount(), abstractContact.getUser())); break; } }
private void createShortcut(AbstractContact abstractContact) { Intent intent = new Intent(); intent.putExtra( Intent.EXTRA_SHORTCUT_INTENT, ChatViewer.createShortCutIntent( this, abstractContact.getAccount(), abstractContact.getUser())); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, abstractContact.getName()); Bitmap bitmap; if (MUCManager.getInstance().hasRoom(abstractContact.getAccount(), abstractContact.getUser())) { bitmap = AvatarManager.getInstance().getRoomBitmap(abstractContact.getUser()); } else { bitmap = AvatarManager.getInstance().getUserBitmap(abstractContact.getUser()); } intent.putExtra( Intent.EXTRA_SHORTCUT_ICON, AvatarManager.getInstance().createShortcutBitmap(bitmap)); setResult(RESULT_OK, intent); }