public void updateContent(int[] selectedIDs) {
    ChessBoardPanel panel = UIHandler.getInstance(null).getChessBoardPanel();
    BufferedImage image = panel.getChessBoardImage();
    Dimension d = panel.getChessBoardPreferredSize();
    if (image == null) setBoardImage(d.width, d.height);
    else setBoardImage(image);

    pointList.clear();
    selectedPointList.clear();

    for (Point p : UIHandler.getInstance(null).getPointList()) {
      Point np = new Point(this, p.getId());
      Point.InfoPack infoPack = p.getRelativeInformation();
      np.setSizeByRelative(infoPack.posX, infoPack.posY, infoPack.width, infoPack.height);
      pointList.add(np);
    }
    for (Point p : UIHandler.getInstance(null).getPointList()) {
      Point np = findPointInListById(pointList, p.getId());
      for (Point.EdgePointPair edgePointPair : p.getAllEdgePointPair()) {
        Point targetPoint = findPointInListById(pointList, edgePointPair.targetPoint.getId());
        if (targetPoint != null) np.addEdgePointPairs(edgePointPair.direction, targetPoint);
      }
    }

    for (int id : selectedIDs) {
      for (Point p : pointList) {
        if (p.getId() == id) {
          selectedPointList.add(p);
          break;
        }
      }
    }
  }
Example #2
0
  @Override
  public void onTouchPointerMove(int x, int y) {
    Point p = mapScreenCoordToSessionCoord(x, y);
    LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y, Mouse.getMoveEvent());

    if (autoScrollTouchPointer && !uiHandler.hasMessages(UIHandler.SCROLLING_REQUESTED)) {
      Log.v(TAG, "Starting auto-scroll");
      uiHandler.sendEmptyMessageDelayed(UIHandler.SCROLLING_REQUESTED, SCROLLING_TIMEOUT);
    }
  }
Example #3
0
  private void sendDelayedMoveEvent(int x, int y) {
    if (uiHandler.hasMessages(UIHandler.SEND_MOVE_EVENT)) {
      uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
      discardedMoveEvents++;
    } else discardedMoveEvents = 0;

    if (discardedMoveEvents > MAX_DISCARDED_MOVE_EVENTS)
      LibFreeRDP.sendCursorEvent(session.getInstance(), x, y, Mouse.getMoveEvent());
    else
      uiHandler.sendMessageDelayed(
          Message.obtain(null, UIHandler.SEND_MOVE_EVENT, x, y), SEND_MOVE_EVENT_TIMEOUT);
  }
 public void sendUIMessageEmptyDelayed(int what, long delayMillis) {
   if (null != mUIHandler) {
     mUIHandler.sendEmptyMessageDelayed(what, delayMillis);
   } else {
     uiHandlerNotInit();
   }
 }
 // 目前只提供两个sendUIMessage的方法,如果需要使用其他handler发送消息的方法getUIHandler后处理
 public void sendUIMessage(Message msg) {
   if (null != mUIHandler) {
     mUIHandler.sendMessage(msg);
   } else {
     uiHandlerNotInit();
   }
 }
Example #6
0
  @Override
  public boolean OnVerifiyCertificate(String subject, String issuer, String fingerprint) {

    // see if global settings says accept all
    if (GlobalSettings.getAcceptAllCertificates()) return true;

    // this is where the return code of our dialog will be stored
    callbackDialogResult = false;

    // set message
    String msg = getResources().getString(R.string.dlg_msg_verify_certificate);
    msg = msg + "\n\nSubject: " + subject + "\nIssuer: " + issuer + "\nFingerprint: " + fingerprint;
    dlgVerifyCertificate.setMessage(msg);

    // start dialog in UI thread
    uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG, dlgVerifyCertificate));

    // wait for result
    try {
      synchronized (dlgVerifyCertificate) {
        dlgVerifyCertificate.wait();
      }
    } catch (InterruptedException e) {
    }

    return callbackDialogResult;
  }
Example #7
0
  @Override
  public void OnGraphicsResize(int width, int height) {
    // replace bitmap
    bitmap = Bitmap.createBitmap(width, height, bitmap.getConfig());
    session.setSurface(new BitmapDrawable(bitmap));

    /* since sessionView can only be modified from the UI thread
     * any modifications to it need to be scheduled */
    uiHandler.sendEmptyMessage(UIHandler.GRAPHICS_CHANGED);
  }
Example #8
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);
  }
Example #9
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;
  }
  @Override
  public void onResume() {
    super.onResume();

    Bundle args = getArguments();
    uiHandler = new UIHandler();
    validationErrors = new HashMap<ProxyStatusProperties, CharSequence>();

    if (args != null && args.containsKey(SELECTED_PROXY_ARG)) {
      cachedObjId = (UUID) getArguments().getSerializable(SELECTED_PROXY_ARG);
      selectedProxy = (ProxyEntity) App.getCacheManager().get(cachedObjId);
    }

    if (selectedProxy == null) {
      // TODO: temporary fix. needs improvements. remove cachemanager!
      NavigationUtils.GoToMainActivity(getActivity());
    }

    uiHandler.callRefreshUI();
  }
Example #11
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 #12
0
  @Override
  public boolean OnAuthenticate(
      StringBuilder username, StringBuilder domain, StringBuilder password) {
    // this is where the return code of our dialog will be stored
    callbackDialogResult = false;

    // set text fields
    ((EditText) userCredView.findViewById(R.id.editTextUsername)).setText(username);
    ((EditText) userCredView.findViewById(R.id.editTextDomain)).setText(domain);
    ((EditText) userCredView.findViewById(R.id.editTextPassword)).setText(password);

    // start dialog in UI thread
    uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG, dlgUserCredentials));

    // wait for result
    try {
      synchronized (dlgUserCredentials) {
        dlgUserCredentials.wait();
      }
    } catch (InterruptedException e) {
    }

    // clear buffers
    username.setLength(0);
    domain.setLength(0);
    password.setLength(0);

    // read back user credentials
    username.append(
        ((EditText) userCredView.findViewById(R.id.editTextUsername)).getText().toString());
    domain.append(((EditText) userCredView.findViewById(R.id.editTextDomain)).getText().toString());
    password.append(
        ((EditText) userCredView.findViewById(R.id.editTextPassword)).getText().toString());

    return callbackDialogResult;
  }
Example #13
0
 /** 需要在父类onDestroy中调用,如果有特殊地方需要调用清除消息,可以调用 */
 public void recycleUIHandler() {
   if (null != mUIHandler) {
     mUIHandler.removeCallbacksAndMessages(null);
   }
 }
Example #14
0
 // ****************************************************************************
 // ScrollView2DListener implementation
 private void resetZoomControlsAutoHideTimeout() {
   uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
   uiHandler.sendEmptyMessageDelayed(UIHandler.HIDE_ZOOMCONTROLS, ZOOMCONTROLS_AUTOHIDE_TIMEOUT);
 }
Example #15
0
 private void cancelDelayedMoveEvent() {
   uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
 }
 protected void showToastRemote(String message) {
   Message msg = uiHandler.obtainMessage(UIHandler.DISPLAY_UI_TOAST);
   msg.obj = message;
   uiHandler.sendMessage(msg);
 }