Java Code Examples for android.view.KeyEvent#KEYCODE_EQUALS

The following examples show how to use android.view.KeyEvent#KEYCODE_EQUALS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbsSeekBar.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (isEnabled()) {
        int increment = mKeyProgressIncrement;
        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_MINUS:
                increment = -increment;
                // fallthrough
            case KeyEvent.KEYCODE_DPAD_RIGHT:
            case KeyEvent.KEYCODE_PLUS:
            case KeyEvent.KEYCODE_EQUALS:
                increment = isLayoutRtl() ? -increment : increment;

                if (setProgressInternal(getProgress() + increment, true, true)) {
                    onKeyChange();
                    return true;
                }
                break;
        }
    }

    return super.onKeyDown(keyCode, event);
}
 
Example 2
Source File: RangeSeekBar.java    From RangeSeekBar with MIT License 6 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (isEnabled()) {
        int increment = mKeyProgressIncrement;
        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_MINUS:
                increment = -increment;
                // fallthrough
            case KeyEvent.KEYCODE_DPAD_RIGHT:
            case KeyEvent.KEYCODE_PLUS:
            case KeyEvent.KEYCODE_EQUALS:
                if (setProgressInternal(getProgressStart() - increment, getProgressEnd() + increment, true, true)) {
                    onKeyChange();
                    return true;
                }
                break;
        }
    }

    return super.onKeyDown(keyCode, event);
}
 
Example 3
Source File: BaseSlider.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private Float calculateIncrementForKey(int keyCode) {
  // If this is a long press, increase the increment so it will only take around 20 steps.
  // Otherwise choose the smallest valid increment.
  float increment = isLongPress ? calculateStepIncrement(20) : calculateStepIncrement();
  switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_LEFT:
      return isRtl() ? increment : -increment;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
      return isRtl() ? -increment : increment;
    case KeyEvent.KEYCODE_MINUS:
      return -increment;
    case KeyEvent.KEYCODE_EQUALS:
      // Numpad Plus == Shift + Equals, at least in AVD, so fall through.
    case KeyEvent.KEYCODE_PLUS:
      return increment;
    default:
      return null;
  }
}
 
Example 4
Source File: BaseSlider.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private Boolean onKeyDownNoActiveThumb(int keyCode, @NonNull KeyEvent event) {
  switch (keyCode) {
    case KeyEvent.KEYCODE_TAB:
      if (event.hasNoModifiers()) {
        return moveFocus(1);
      }

      if (event.isShiftPressed()) {
        return moveFocus(-1);
      }
      return false;
    case KeyEvent.KEYCODE_DPAD_LEFT:
      moveFocusInAbsoluteDirection(-1);
      return true;
    case KeyEvent.KEYCODE_MINUS:
      moveFocus(-1);
      return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
      moveFocusInAbsoluteDirection(1);
      return true;
    case KeyEvent.KEYCODE_EQUALS:
      // Numpad Plus == Shift + Equals, at least in AVD, so fall through.
    case KeyEvent.KEYCODE_PLUS:
      moveFocus(1);
      return true;
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_ENTER:
      activeThumbIdx = focusedThumbIdx;
      postInvalidate();
      return true;
    default:
      // Nothing to do in this case.
  }

  return null;
}
 
Example 5
Source File: SliderKeyTestCommon.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testMoveThumbFocus_equalsMinus_correctThumbHasFocus() {
  slider.requestFocus();

  // Numpad Plus == Shift + Equals, at least in AVD.
  KeyEventBuilder equals = new KeyEventBuilder(KeyEvent.KEYCODE_EQUALS);
  KeyEventBuilder minus = new KeyEventBuilder(KeyEvent.KEYCODE_MINUS);

  sendKeyEventThereAndBack(equals, minus);
}