Example #1
0
  // ****************************************************************************
  // LibFreeRDP UI event listener implementation
  @Override
  public void OnSettingsChanged(int width, int height, int bpp) {

    if (bpp > 16) bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    else bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);

    session.setSurface(new BitmapDrawable(bitmap));

    // check this settings and initial settings - if they are not equal the server doesn't support
    // our settings
    // FIXME: the additional check (settings.getWidth() != width + 1) is for the RDVH bug fix to
    // avoid accidental notifications
    // (refer to android_freerdp.c for more info on this problem)
    BookmarkBase.ScreenSettings settings = session.getBookmark().getActiveScreenSettings();
    if ((settings.getWidth() != width && settings.getWidth() != width + 1)
        || settings.getHeight() != height
        || settings.getColors() != bpp)
      uiHandler.sendMessage(
          Message.obtain(
              null,
              UIHandler.DISPLAY_TOAST,
              getResources().getText(R.string.info_capabilities_changed)));
  }
Example #2
0
  private void connect(BookmarkBase bookmark) {
    session = GlobalApp.createSession(bookmark);
    session.setUIEventListener(this);

    // set writeable data directory
    LibFreeRDP.setDataDirectory(session.getInstance(), getFilesDir().toString());

    BookmarkBase.ScreenSettings screenSettings = session.getBookmark().getActiveScreenSettings();
    Log.v(TAG, "Screen Resolution: " + screenSettings.getResolutionString());
    if (screenSettings.isAutomatic()) {
      if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
          >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
        // large screen device i.e. tablet: simply use screen info
        screenSettings.setHeight(screen_height);
        screenSettings.setWidth(screen_width);
      } else {
        // small screen device i.e. phone:
        // Automatic uses the largest side length of the screen and makes a 16:10 resolution setting
        // out of it
        int screenMax = (screen_width > screen_height) ? screen_width : screen_height;
        screenSettings.setHeight(screenMax);
        screenSettings.setWidth((int) ((float) screenMax * 1.6f));
      }
    }

    progressDialog = new ProgressDialog(this);
    progressDialog.setTitle(bookmark.getLabel());
    progressDialog.setMessage(getResources().getText(R.string.dlg_msg_connecting));
    progressDialog.setButton(
        ProgressDialog.BUTTON_NEGATIVE,
        "Cancel",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            connectCancelledByUser = true;
            LibFreeRDP.cancelConnection(session.getInstance());
          }
        });
    progressDialog.setCancelable(false);
    progressDialog.show();

    Thread thread =
        new Thread(
            new Runnable() {
              public void run() {
                session.connect();
              }
            });
    thread.start();
  }