Esempio n. 1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here
    // ..
    int itemId = item.getItemId();

    if (itemId == R.id.session_touch_pointer) {
      // toggle touch pointer
      if (touchPointerView.getVisibility() == View.VISIBLE) {
        touchPointerView.setVisibility(View.INVISIBLE);
        sessionView.setTouchPointerPadding(0, 0);
      } else {
        touchPointerView.setVisibility(View.VISIBLE);
        sessionView.setTouchPointerPadding(
            touchPointerView.getPointerWidth(), touchPointerView.getPointerHeight());
      }
    } else if (itemId == R.id.session_sys_keyboard) {
      showKeyboard(!sysKeyboardVisible, false);
    } else if (itemId == R.id.session_ext_keyboard) {
      showKeyboard(false, !extKeyboardVisible);
    } else if (itemId == R.id.session_disconnect) {
      showKeyboard(false, false);
      LibFreeRDP.disconnect(session.getInstance());
    }

    return true;
  }
Esempio n. 2
0
 @Override
 public void onScrollChanged(ScrollView2D scrollView, int x, int y, int oldx, int oldy) {
   zoomControls.setIsZoomInEnabled(!sessionView.isAtMaxZoom());
   zoomControls.setIsZoomOutEnabled(!sessionView.isAtMinZoom());
   if (!GlobalSettings.getHideZoomControls() && zoomControls.getVisibility() != View.VISIBLE)
     zoomControls.show();
   resetZoomControlsAutoHideTimeout();
 }
Esempio n. 3
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);
 }
Esempio n. 4
0
 private Point mapScreenCoordToSessionCoord(int x, int y) {
   int mappedX = (int) ((float) (x + scrollView.getScrollX()) / sessionView.getZoom());
   int mappedY = (int) ((float) (y + scrollView.getScrollY()) / sessionView.getZoom());
   if (mappedX > bitmap.getWidth()) mappedX = bitmap.getWidth();
   if (mappedY > bitmap.getHeight()) mappedY = bitmap.getHeight();
   return new Point(mappedX, mappedY);
 }
Esempio n. 5
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;
  }
Esempio n. 6
0
  @Override
  public void OnGraphicsUpdate(int x, int y, int width, int height) {
    LibFreeRDP.updateGraphics(session.getInstance(), bitmap, x, y, width, height);

    sessionView.addInvalidRegion(new Rect(x, y, x + width, y + height));

    /* since sessionView can only be modified from the UI thread
     * any modifications to it need to be scheduled */

    uiHandler.sendEmptyMessage(UIHandler.REFRESH_SESSIONVIEW);
  }
Esempio n. 7
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.session_touch_pointer:
        {
          // toggle touch pointer
          if (touchPointerView.getVisibility() == View.VISIBLE) {
            touchPointerView.setVisibility(View.INVISIBLE);
            sessionView.setTouchPointerPadding(0, 0);
          } else {
            touchPointerView.setVisibility(View.VISIBLE);
            sessionView.setTouchPointerPadding(
                touchPointerView.getPointerWidth(), touchPointerView.getPointerHeight());
          }
          break;
        }

      case R.id.session_sys_keyboard:
        {
          showKeyboard(!sysKeyboardVisible, false);
          break;
        }

      case R.id.session_ext_keyboard:
        {
          showKeyboard(false, !extKeyboardVisible);
          break;
        }

      case R.id.session_disconnect:
        {
          showKeyboard(false, false);
          LibFreeRDP.disconnect(session.getInstance());
          break;
        }
    }

    return true;
  }
Esempio n. 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);
  }
Esempio n. 9
0
 @Override
 public void onTouchPointerResetScrollZoom() {
   sessionView.setZoom(1.0f);
   scrollView.scrollTo(0, 0);
 }
Esempio n. 10
0
 // ****************************************************************************
 // TouchPointerView.TouchPointerListener
 @Override
 public void onTouchPointerClose() {
   touchPointerView.setVisibility(View.INVISIBLE);
   sessionView.setTouchPointerPadding(0, 0);
 }