Example #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);
    }
  }
Example #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);
   }
 }
Example #3
0
 /**
  * Called by the framework when your view for creating input needs to be generated. This will be
  * called the first time your input method is displayed, and every time it needs to be re-created
  * such as due to a configuration change.
  */
 @Override
 public View onCreateInputView() {
   mInputView = (LatinKeyboardView) getLayoutInflater().inflate(R.layout.input, null);
   mInputView.setOnKeyboardActionListener(this);
   mInputView.setKeyboard(mQwertyKeyboard);
   return mInputView;
 }
Example #4
0
 @Override
 public void onStartInputView(EditorInfo attribute, boolean restarting) {
   super.onStartInputView(attribute, restarting);
   // Apply the selected keyboard to the input view.
   mInputView.setKeyboard(mCurKeyboard);
   mInputView.closing();
   final InputMethodSubtype subtype = mInputMethodManager.getCurrentInputMethodSubtype();
   mInputView.setSubtypeOnSpaceKey(subtype);
 }
Example #5
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);
    }
  }