Exemplo n.º 1
0
 public boolean setShiftLocked(boolean shiftLocked) {
   AnyKeyboard keyboard = getKeyboard();
   if (keyboard != null) {
     if (keyboard.setShiftLocked(shiftLocked)) {
       invalidateAllKeys();
       return true;
     }
   }
   return false;
 }
 public void simulateKeyPress(final int keyCode, final boolean advanceTime) {
   onPress(keyCode);
   Robolectric.flushForegroundThreadScheduler();
   final AnyKeyboard keyboard = getCurrentKeyboard();
   Assert.assertNotNull(keyboard);
   Keyboard.Key key = null;
   for (Keyboard.Key aKey : keyboard.getKeys()) {
     if (aKey.getPrimaryCode() == keyCode) {
       key = aKey;
       break;
     }
   }
   if (key == null) {
     onKey(keyCode, null, 0, new int[0], true);
   } else {
     onKey(keyCode, key, 0, keyboard.getNearestKeys(key.x + 5, key.y + 5), true);
   }
   Robolectric.flushForegroundThreadScheduler();
   if (advanceTime) ShadowSystemClock.sleep(25);
   onRelease(keyCode);
   Robolectric.flushForegroundThreadScheduler();
 }
Exemplo n.º 3
0
  @Override
  public void setKeyboard(AnyKeyboard newKeyboard, float verticalCorrection) {
    mExtensionKey = null;
    mExtensionVisible = false;

    mUtilityKey = null;
    super.setKeyboard(newKeyboard, verticalCorrection);
    if (newKeyboard != null
        && newKeyboard instanceof GenericKeyboard
        && ((GenericKeyboard) newKeyboard).disableKeyPreviews()) {
      // Phone keyboard never shows popup preview (except language
      // switch).
      setPreviewEnabled(false);
    } else {
      setPreviewEnabled(AnyApplication.getConfig().getShowKeyPreview());
    }
    // TODO: For now! should be a calculated value
    // lots of key : true
    // some keys: false
    setProximityCorrectionEnabled(true);
    // One-seventh of the keyboard width seems like a reasonable threshold
    // mJumpThresholdSquare = newKeyboard.getMinWidth() / 7;
    // mJumpThresholdSquare *= mJumpThresholdSquare;
    // Assuming there are 4 rows, this is the coordinate of the last row
    // mLastRowY = (newKeyboard.getHeight() * 3) / 4;
    // setKeyboardLocal(newKeyboard);

    // looking for the space-bar, so I'll be able to detect swipes starting
    // at it
    mSpaceBarKey = null;
    if (newKeyboard != null) {
      for (Key aKey : newKeyboard.getKeys()) {
        if (aKey.getPrimaryCode() == KeyCodes.SPACE) {
          mSpaceBarKey = aKey;
          break;
        }
      }
    }
  }