private void sendMessage() {
    String text = inputView.getText().toString().trim();

    if (text.isEmpty()) {
      return;
    }

    clearInputText();

    sendMessage(text);

    listener.onMessageSent();

    if (SettingsManager.chatsHideKeyboard() == SettingsManager.ChatsHideKeyboard.always
        || (getActivity().getResources().getBoolean(R.bool.landscape)
            && SettingsManager.chatsHideKeyboard()
                == SettingsManager.ChatsHideKeyboard.landscape)) {
      ChatViewer.hideKeyboard(getActivity());
    }
  }
  @Override
  public boolean onMenuItemClick(MenuItem item) {

    switch (item.getItemId()) {
        /* security menu */

      case R.id.action_start_encryption:
        startEncryption(account, user);
        return true;

      case R.id.action_restart_encryption:
        restartEncryption(account, user);
        return true;

      case R.id.action_stop_encryption:
        stopEncryption(account, user);
        return true;

      case R.id.action_verify_with_fingerprint:
        startActivity(FingerprintViewer.createIntent(getActivity(), account, user));
        return true;

      case R.id.action_verify_with_question:
        startActivity(QuestionViewer.createIntent(getActivity(), account, user, true, false, null));
        return true;

      case R.id.action_verify_with_shared_secret:
        startActivity(
            QuestionViewer.createIntent(getActivity(), account, user, false, false, null));
        return true;

        /* regular chat options menu */

      case R.id.action_view_contact:
        showContactInfo();
        return true;

      case R.id.action_chat_settings:
        startActivity(ChatContactSettings.createIntent(getActivity(), account, user));
        return true;

      case R.id.action_show_history:
        showHistory(account, user);
        return true;

      case R.id.action_authorization_settings:
        startActivity(ConferenceAdd.createIntent(getActivity(), account, user));
        return true;

      case R.id.action_close_chat:
        closeChat(account, user);
        return true;

      case R.id.action_clear_history:
        clearHistory(account, user);
        return true;

      case R.id.action_export_chat:
        onExportChatClick();
        return true;

      case R.id.action_call_attention:
        callAttention();
        return true;

      case R.id.action_block_contact:
        BlockContactDialog.newInstance(account, user)
            .show(getFragmentManager(), BlockContactDialog.class.getName());
        return true;

        /* conference specific options menu */

      case R.id.action_join_conference:
        MUCManager.getInstance().joinRoom(account, user, true);
        return true;

      case R.id.action_invite_to_chat:
        startActivity(ContactList.createRoomInviteIntent(getActivity(), account, user));
        return true;

      case R.id.action_leave_conference:
        leaveConference(account, user);
        return true;

      case R.id.action_list_of_occupants:
        startActivity(OccupantList.createIntent(getActivity(), account, user));
        return true;

        /* message popup menu */

      case R.id.action_message_repeat:
        if (clickedMessageItem.isUploadFileMessage()) {
          uploadFile(clickedMessageItem.getFile().getPath());
        } else {
          sendMessage(clickedMessageItem.getText());
        }
        return true;

      case R.id.action_message_copy:
        ((ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE))
            .setPrimaryClip(
                ClipData.newPlainText(
                    clickedMessageItem.getSpannable(), clickedMessageItem.getSpannable()));
        return true;

      case R.id.action_message_quote:
        setInputText("> " + clickedMessageItem.getText() + "\n");
        return true;

      case R.id.action_message_remove:
        MessageManager.getInstance().removeMessage(clickedMessageItem);
        updateChat();
        return true;

      case R.id.action_message_open_file:
        FileManager.openFile(getActivity(), clickedMessageItem.getFile());
        return true;

      case R.id.action_message_save_file:
        OnSaveFileToDownloadsClick();
        return true;

      case R.id.action_message_open_muc_private_chat:
        String occupantFullJid = user + "/" + clickedMessageItem.getResource();
        MessageManager.getInstance().openChat(account, occupantFullJid);
        startActivity(ChatViewer.createSpecificChatIntent(getActivity(), account, occupantFullJid));
        return true;

      default:
        return false;
    }
  }