예제 #1
0
  public void swipeUp() {
    if (mInputView == null) {
      return;
    }

    Keyboard currentKeyboard = mInputView.getKeyboard();
    if (mQwertyKeyboard == currentKeyboard) {
      int height = mQwertyKeyboard.getHeight();
      Log.d("Keyboard Height:", Integer.toString(height));
      if (height == 300) mQwertyKeyboard = new LatinKeyboard(this, R.xml.qwerty2);
      else if (height == 400) mQwertyKeyboard = new LatinKeyboard(this, R.xml.qwerty3);
      mInputView.setKeyboard(mQwertyKeyboard);
    } else if (currentKeyboard == mSymbolsKeyboard) {
      int height = mSymbolsKeyboard.getHeight();
      Log.d("Keyboard Height:", Integer.toString(height));
      if (height == 240) mSymbolsKeyboard = new LatinKeyboard(this, R.xml.symbols2);
      else if (height == 320) mSymbolsKeyboard = new LatinKeyboard(this, R.xml.symbols3);
      mInputView.setKeyboard(mSymbolsKeyboard);
    } else if (currentKeyboard == mSymbolsShiftedKeyboard) {
      int height = mSymbolsShiftedKeyboard.getHeight();
      Log.d("Keyboard Height:", Integer.toString(height));
      if (height == 240) mSymbolsShiftedKeyboard = new LatinKeyboard(this, R.xml.symbols_shift2);
      else if (height == 320)
        mSymbolsShiftedKeyboard = new LatinKeyboard(this, R.xml.symbols_shift3);
      mInputView.setKeyboard(mSymbolsShiftedKeyboard);
    }
  }
예제 #2
0
 public void onKey(int primaryCode, int[] keyCodes) {
   if (isWordSeparator(primaryCode)) {
     // Handle separator
     if (mComposing.length() > 0) {
       commitTyped(getCurrentInputConnection());
     }
     sendKey(primaryCode);
     updateShiftKeyState(getCurrentInputEditorInfo());
   } else if (primaryCode == Keyboard.KEYCODE_DELETE) {
     handleBackspace();
   } else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
     handleShift();
   } else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
     handleClose();
     return;
   } else if (primaryCode == LatinKeyboardView.KEYCODE_OPTIONS) {
     // Show a menu or somethin'
   } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE && mInputView != null) {
     Keyboard current = mInputView.getKeyboard();
     if (current == mSymbolsKeyboard || current == mSymbolsShiftedKeyboard) {
       current = mQwertyKeyboard;
     } else {
       current = mSymbolsKeyboard;
     }
     mInputView.setKeyboard(current);
     if (current == mSymbolsKeyboard) {
       current.setShifted(false);
     }
   } else {
     handleCharacter(primaryCode, keyCodes);
   }
 }
예제 #3
0
 /** Helper to update the shift state of our keyboard based on the initial editor state. */
 private void updateShiftKeyState(EditorInfo attr) {
   if (attr != null && mInputView != null && mQwertyKeyboard == mInputView.getKeyboard()) {
     int caps = 0;
     EditorInfo ei = getCurrentInputEditorInfo();
     if (ei != null && ei.inputType != InputType.TYPE_NULL) {
       caps = getCurrentInputConnection().getCursorCapsMode(attr.inputType);
     }
     mInputView.setShifted(mCapsLock || caps != 0);
   }
 }
예제 #4
0
  private void handleShift() {
    if (mInputView == null) {
      return;
    }

    Keyboard currentKeyboard = mInputView.getKeyboard();
    if (mQwertyKeyboard == currentKeyboard) {
      // Alphabet keyboard
      checkToggleCapsLock();
      mInputView.setShifted(mCapsLock || !mInputView.isShifted());
    } else if (currentKeyboard == mSymbolsKeyboard) {
      mSymbolsKeyboard.setShifted(true);
      mInputView.setKeyboard(mSymbolsShiftedKeyboard);
      mSymbolsShiftedKeyboard.setShifted(true);
    } else if (currentKeyboard == mSymbolsShiftedKeyboard) {
      mSymbolsShiftedKeyboard.setShifted(false);
      mInputView.setKeyboard(mSymbolsKeyboard);
      mSymbolsKeyboard.setShifted(false);
    }
  }