Exemple #1
0
  // update the state of our modifier keys
  private void updateModifierKeyStates() {
    // check if any key is in the keycodes list

    List<Keyboard.Key> keys = modifiersKeyboard.getKeys();
    for (Iterator<Keyboard.Key> it = keys.iterator(); it.hasNext(); ) {
      // if the key is a sticky key - just set it to off
      Keyboard.Key curKey = it.next();
      if (curKey.sticky) {
        switch (keyboardMapper.getModifierState(curKey.codes[0])) {
          case KeyboardMapper.KEYSTATE_ON:
            curKey.on = true;
            curKey.pressed = false;
            break;

          case KeyboardMapper.KEYSTATE_OFF:
            curKey.on = false;
            curKey.pressed = false;
            break;

          case KeyboardMapper.KEYSTATE_LOCKED:
            curKey.on = true;
            curKey.pressed = true;
            break;
        }
      }
    }

    // refresh image
    modifiersKeyboardView.invalidateAllKeys();
  }
Exemple #2
0
 // binds the current session to the activity by wiring it up with the sessionView and updating all
 // internal objects accordingly
 private void bindSession() {
   Log.v("SessionActivity", "bindSession called");
   session.setUIEventListener(this);
   sessionView.onSurfaceChange(session);
   scrollView.requestLayout();
   keyboardMapper.reset(this);
 }
Exemple #3
0
  // displays either the system or the extended keyboard or non of  them
  private void showKeyboard(boolean showSystemKeyboard, boolean showExtendedKeyboard) {
    // no matter what we are doing ... hide the zoom controls
    // TODO: this is not working correctly as hiding the keyboard issues a onScrollChange
    // notification showing the control again ...
    uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
    if (zoomControls.getVisibility() == View.VISIBLE) zoomControls.hide();

    InputMethodManager mgr;
    if (showSystemKeyboard) {
      // hide extended keyboard
      keyboardView.setVisibility(View.GONE);

      // show system keyboard
      mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      if (!mgr.isActive(sessionView))
        Log.e(TAG, "Failed to show system keyboard: SessionView is not the active view!");
      mgr.showSoftInput(sessionView, 0);

      // show modifiers keyboard
      modifiersKeyboardView.setVisibility(View.VISIBLE);
    } else if (showExtendedKeyboard) {
      // hide system keyboard
      mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      mgr.hideSoftInputFromWindow(sessionView.getWindowToken(), 0);

      // show extended keyboard
      keyboardView.setKeyboard(specialkeysKeyboard);
      keyboardView.setVisibility(View.VISIBLE);
      modifiersKeyboardView.setVisibility(View.VISIBLE);
    } else {
      // hide both
      mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      mgr.hideSoftInputFromWindow(sessionView.getWindowToken(), 0);
      keyboardView.setVisibility(View.GONE);
      modifiersKeyboardView.setVisibility(View.GONE);

      // clear any active key modifiers)
      keyboardMapper.clearlAllModifiers();
    }

    sysKeyboardVisible = showSystemKeyboard;
    extKeyboardVisible = showExtendedKeyboard;
  }
Exemple #4
0
 // ****************************************************************************
 // KeyboardView.KeyboardActionEventListener
 @Override
 public void onKey(int primaryCode, int[] keyCodes) {
   keyboardMapper.processCustomKeyEvent(primaryCode);
 }
Exemple #5
0
 // onKeyMultiple is called for input of some special characters like umlauts and some symbol
 // characters
 @Override
 public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
   return keyboardMapper.processAndroidKeyEvent(event);
 }
Exemple #6
0
 @Override
 public boolean onKeyUp(int keycode, KeyEvent event) {
   return keyboardMapper.processAndroidKeyEvent(event);
 }
Exemple #7
0
 @Override
 public void onBackPressed() {
   // hide keyboards (if any visible) or send alt+f4 to the session
   if (sysKeyboardVisible || extKeyboardVisible) showKeyboard(false, false);
   else keyboardMapper.sendAltF4();
 }
Exemple #8
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // show status bar or make fullscreen?
    if (GlobalSettings.getHideStatusBar())
      getWindow()
          .setFlags(
              WindowManager.LayoutParams.FLAG_FULLSCREEN,
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.setContentView(R.layout.session);

    Log.v(TAG, "Session.onCreate");

    // ATTENTION: We use the onGlobalLayout notification to start our session.
    // This is because only then we can know the exact size of our session when using fit screen
    // accounting for any status bars etc. that Android might throws on us. A bit weird looking
    // but this is the only way ...
    final View activityRootView = findViewById(R.id.session_root_view);
    activityRootView
        .getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new OnGlobalLayoutListener() {
              @Override
              public void onGlobalLayout() {
                screen_width = activityRootView.getWidth();
                screen_height = activityRootView.getHeight();

                // start session
                if (!sessionRunning && getIntent() != null) {
                  processIntent(getIntent());
                  sessionRunning = true;
                }
              }
            });

    sessionView = (SessionView) findViewById(R.id.sessionView);
    sessionView.setScaleGestureDetector(new ScaleGestureDetector(this, new PinchZoomListener()));
    sessionView.setSessionViewListener(this);
    sessionView.requestFocus();

    touchPointerView = (TouchPointerView) findViewById(R.id.touchPointerView);
    touchPointerView.setTouchPointerListener(this);

    keyboardMapper = new KeyboardMapper();
    keyboardMapper.init(this);

    modifiersKeyboard = new Keyboard(getApplicationContext(), R.xml.modifiers_keyboard);
    specialkeysKeyboard = new Keyboard(getApplicationContext(), R.xml.specialkeys_keyboard);
    numpadKeyboard = new Keyboard(getApplicationContext(), R.xml.numpad_keyboard);
    cursorKeyboard = new Keyboard(getApplicationContext(), R.xml.cursor_keyboard);

    // hide keyboard below the sessionView
    keyboardView = (KeyboardView) findViewById(R.id.extended_keyboard);
    keyboardView.setKeyboard(specialkeysKeyboard);
    keyboardView.setOnKeyboardActionListener(this);

    modifiersKeyboardView = (KeyboardView) findViewById(R.id.extended_keyboard_header);
    modifiersKeyboardView.setKeyboard(modifiersKeyboard);
    modifiersKeyboardView.setOnKeyboardActionListener(this);

    scrollView = (ScrollView2D) findViewById(R.id.sessionScrollView);
    scrollView.setScrollViewListener(this);
    uiHandler = new UIHandler();
    libFreeRDPBroadcastReceiver = new LibFreeRDPBroadcastReceiver();

    zoomControls = (ZoomControls) findViewById(R.id.zoomControls);
    zoomControls.hide();
    zoomControls.setOnZoomInClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            resetZoomControlsAutoHideTimeout();
            zoomControls.setIsZoomInEnabled(sessionView.zoomIn(ZOOMING_STEP));
            zoomControls.setIsZoomOutEnabled(true);
          }
        });
    zoomControls.setOnZoomOutClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            resetZoomControlsAutoHideTimeout();
            zoomControls.setIsZoomOutEnabled(sessionView.zoomOut(ZOOMING_STEP));
            zoomControls.setIsZoomInEnabled(true);
          }
        });

    toggleMouseButtons = false;

    createDialogs();

    // register freerdp events broadcast receiver
    IntentFilter filter = new IntentFilter();
    filter.addAction(GlobalApp.ACTION_EVENT_FREERDP);
    registerReceiver(libFreeRDPBroadcastReceiver, filter);
  }