Esempio n. 1
0
  /** Called whenever an action bar button is pressed. */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    mActivityLifecycleListener.onActivityOptionsItemSelected(this, item);

    // Whenever a user selects an option from the ActionBar, reset the auto-hide timer.
    startActionBarAutoHideTimer();

    if (id == R.id.actionbar_cardboard) {
      onCardboardItemSelected();
      return true;
    }
    if (id == R.id.actionbar_keyboard) {
      ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(0, 0);
      return true;
    }
    if (id == R.id.actionbar_hide) {
      hideActionBar();
      return true;
    }
    if (id == R.id.actionbar_disconnect || id == android.R.id.home) {
      JniInterface.disconnectFromHost();
      return true;
    }
    if (id == R.id.actionbar_send_ctrl_alt_del) {
      int[] keys = {
        KeyEvent.KEYCODE_CTRL_LEFT, KeyEvent.KEYCODE_ALT_LEFT, KeyEvent.KEYCODE_FORWARD_DEL,
      };
      for (int key : keys) {
        JniInterface.sendKeyEvent(0, key, true);
      }
      for (int key : keys) {
        JniInterface.sendKeyEvent(0, key, false);
      }
      return true;
    }
    if (id == R.id.actionbar_help) {
      HelpActivity.launch(this, HELP_URL);
      return true;
    }
    return super.onOptionsItemSelected(item);
  }