本文整理匯總了Java中android.inputmethodservice.Keyboard.KEYCODE_SHIFT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Keyboard.KEYCODE_SHIFT屬性的具體用法?Java Keyboard.KEYCODE_SHIFT怎麽用?Java Keyboard.KEYCODE_SHIFT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.inputmethodservice.Keyboard
的用法示例。
在下文中一共展示了Keyboard.KEYCODE_SHIFT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPress
public void onPress(int primaryCode) {
if (mKeyboardSwitcher.isVibrateAndSoundFeedbackRequired()) {
vibrate();
playKeyClick(primaryCode);
}
final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_SHIFT) {
mShiftKeyState.onPress();
handleShift();
} else if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
changeKeyboardMode();
mSymbolKeyState.onPress();
mKeyboardSwitcher.setAutoModeSwitchStateMomentary();
} else {
mShiftKeyState.onOtherKeyPressed();
mSymbolKeyState.onOtherKeyPressed();
}
}
示例2: onRelease
public void onRelease(int primaryCode) {
// Reset any drag flags in the keyboard
((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).keyReleased();
//vibrate();
final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_SHIFT) {
if (mShiftKeyState.isMomentary())
resetShift();
mShiftKeyState.onRelease();
} else if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
// Snap back to the previous keyboard mode if the user chords the mode change key and
// other key, then released the mode change key.
if (mKeyboardSwitcher.isInChordingAutoModeSwitchState())
changeKeyboardMode();
mSymbolKeyState.onRelease();
}
}
示例3: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
InputConnection ic = getCurrentInputConnection() ;
playclick(primaryCode);
switch (primaryCode) {
case Keyboard.KEYCODE_DELETE:
ic.deleteSurroundingText(1, 0);
break;
case Keyboard.KEYCODE_SHIFT:
caps = !caps;
keyboard.setShifted(caps);
kv.invalidateAllKeys();
break;
case Keyboard.KEYCODE_DONE:
ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
break;
default:
char code = (char) primaryCode;
if(Character.isLetter(code) && caps) {
code = Character.toUpperCase(code);
}
ic.commitText(String.valueOf(code), 1);
break;
}
}
示例4: onKey
@Override
public void onKey(int primaryCode, int[] ints) {
Editable editable = getText();
int start = getSelectionStart();
switch (primaryCode) {
case Keyboard.KEYCODE_MODE_CHANGE:// 英文鍵盤與數字鍵盤切換-2
shiftKeyboard();
break;
case Keyboard.KEYCODE_DELETE:// 回退-5
if (editable != null && editable.length() > 0 && start > 0) {
editable.delete(start - 1, start);
}
break;
case Keyboard.KEYCODE_SHIFT:// 英文大小寫切換-1
shiftEnglish();
keyboardView.setKeyboard(keyboardEnglish);
break;
case Keyboard.KEYCODE_DONE:// 完成-4
break;
default:
editable.insert(start, Character.toString((char) primaryCode));
break;
}
}
示例5: onKey
public void onKey(int primaryCode, int[] keyCodes) {
if (primaryCode == Keyboard.KEYCODE_DELETE) {
handleBackspace();
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
handleShift();
} else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
handleClose();
return;
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
handleModeChange();
} else if (primaryCode == EntryKeyboard.KEYCODE_ENTER) {
handleEnter();
} else {
handleCharacter(primaryCode, keyCodes);
// Switch back to old keyboard if we're not in capslock mode
if (mKeyboardState == KEYBOARD_STATE_SHIFTED) {
// skip to the unlocked state
mKeyboardState = KEYBOARD_STATE_CAPSLOCK;
handleShift();
}
}
}
示例6: isModifierInternal
private boolean isModifierInternal(int keyIndex) {
Key key = getKey(keyIndex);
if (key == null)
return false;
int primaryCode = key.codes[0];
return primaryCode == Keyboard.KEYCODE_SHIFT
|| primaryCode == Keyboard.KEYCODE_MODE_CHANGE;
}
示例7: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
Editable editable = mEditText.getText();
int start = mEditText.getSelectionStart();
if (primaryCode == Keyboard.KEYCODE_CANCEL) { // cancel
hideKeyboard();
} else if (primaryCode == Keyboard.KEYCODE_DELETE) { // 回退
if (editable != null && editable.length() > 0) {
if (start > 0) {
editable.delete(start - 1, start);
}
}
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) { // 大小寫切換
// changeKeyboart();
// mKeyboardView.setKeyboard(mLetterKeyboard);
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { // 數字與字母鍵盤互換
// if (isNumber) {
// isNumber = false;
// mKeyboardView.setKeyboard(mLetterKeyboard);
// } else {
// isNumber = true;
mKeyboardView.setKeyboard(mNumberKeyboard);
// }
} else if (primaryCode == 57419) { // 左移
if (start > 0) {
mEditText.setSelection(start - 1);
}
} else if (primaryCode == 57419) { // 右移
if (start > mEditText.length()) {
mEditText.setSelection(start + 1);
}
} else { // 輸入鍵盤值
editable.insert(start, Character.toString((char) primaryCode));
}
}
示例8: onKey
@Override
public void onKey(int primaryCode, int[] ints) {
Log.d(TAG, "onKey " + primaryCode);
InputConnection ic = getCurrentInputConnection();
playClick(primaryCode);
switch (primaryCode) {
case Keyboard.KEYCODE_DELETE:
ic.deleteSurroundingText(1, 0);
break;
case Keyboard.KEYCODE_SHIFT:
handleShift();
break;
case Keyboard.KEYCODE_DONE:
ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
break;
case Keyboard.KEYCODE_ALT:
handleSymbolsSwitch();
break;
case Keyboard.KEYCODE_MODE_CHANGE:
handleLanguageSwitch();
break;
default:
char code = (char) primaryCode;
if (Character.isLetter(code) && isCapsOn) {
code = Character.toUpperCase(code);
}
ic.commitText(String.valueOf(code), 1);
break;
}
}
示例9: onKey
public void onKey(int primaryCode, int[] keyCodes) {
if (isWordSeparator(primaryCode)) {
// Handle separator. DCH: removed the space ' ' 0x0020
commitTyped(getCurrentInputConnection());
sendKey(primaryCode);
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {
handleBackspace();
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
handleShift();
} else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
handleClose();
} else if (primaryCode == ArabicKeyboardView.KEYCODE_LANGUAGE_SWITCH) {
handleLanguageSwitch();
} else if (primaryCode == ArabicKeyboardView.KEYCODE_OPTIONS) {
showOptionsMenu();
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE
&& mInputView != null) {
Keyboard current = mInputView.getKeyboard();
if (current == mSymbolsKeyboard || current == mSymbolsShiftedKeyboard) {
setArabicKeyboard(mArabicKeyboard);
} else {
setArabicKeyboard(mSymbolsKeyboard);
mSymbolsKeyboard.setShifted(false);
}
} else {
handleCharacter(primaryCode);
}
}
示例10: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
InputConnection input = getCurrentInputConnection();
playType(primaryCode);
switch (primaryCode) {
case Keyboard.KEYCODE_DELETE:
input.deleteSurroundingText(1, 0);
break;
case Keyboard.KEYCODE_SHIFT:
long now = System.currentTimeMillis();
if (isCapsLock) isCapsLock = false;
else if (lastCapsTime + 800 > now)
isCapsLock = true;
keyboardView.setShifted(isCapsLock || !keyboardView.isShifted());
lastCapsTime = now;
break;
case Keyboard.KEYCODE_DONE:
input.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
break;
default:
char code = (char) primaryCode;
if (Character.isLetter(code) && keyboardView.isShifted()) {
code = Character.toUpperCase(code);
keyboardView.setShifted(isCapsLock);
}
input.commitText(String.valueOf(code), 1);
}
vibrator.vibrate(20);
}
示例11: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
InputConnection ic = getCurrentInputConnection();
switch(primaryCode){
case PuffKeyboardView.KEYCODE_EDIT :
Intent intent = new Intent(this, DialogAcctList.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_CLEAR_TASK);
getApplicationContext().startActivity(intent);
stopSelf();
break;
case -11 :
ic.commitText(account, 1);
account = "";
break;
case -12:
ic.commitText(password, 1);
password = "";
break;
case -13:
ic.commitText(additional, 1);
additional = "";
break;
case Keyboard.KEYCODE_DONE:
ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
break;
case Keyboard.KEYCODE_DELETE:
ic.deleteSurroundingText(1, 0);
break;
case Keyboard.KEYCODE_MODE_CHANGE:
if(kv.getKeyboard() == symbolKeyboard || kv.getKeyboard() == symsftKeyboard) {
currentKeyboard = normalKeyboard;
} else {
currentKeyboard = symbolKeyboard;
}
kv.setKeyboard(currentKeyboard);
break;
case Keyboard.KEYCODE_SHIFT:
// if (kv.getKeyboard() == normalKeyboard) {
// caps = !caps;
// normalKeyboard.setShifted(caps);
// kv.invalidateAllKeys();
// }
if(currentKeyboard == shiftKeyboard) {
currentKeyboard = normalKeyboard;
} else {
currentKeyboard = shiftKeyboard;
}
kv.setKeyboard(currentKeyboard);
break;
case Keyboard.KEYCODE_ALT:
if (kv.getKeyboard() == symbolKeyboard) {
currentKeyboard = symsftKeyboard;
} else {
currentKeyboard = symbolKeyboard;
}
kv.setKeyboard(currentKeyboard);
break;
case -886 :
Toast.makeText(IMEService.this, "close", Toast.LENGTH_SHORT).show();
break ;
default:
char code = (char)primaryCode;
if (caps) {
code = Character.toUpperCase(code);
}
ic.commitText(String.valueOf(code),1);
break;
}
VibrateUtil.getStaticInstance(this).tick();
}
示例12: onKey
public void onKey(int primaryCode, int[] keyCodes) {
long when = SystemClock.uptimeMillis();
boolean mIsQuickPress = when < mLastKeyTime + QUICK_PRESS;
if (primaryCode != Keyboard.KEYCODE_DELETE || !mIsQuickPress) {
mDeleteCount = 0;
}
mLastKeyTime = when;
InputConnection ic = getCurrentInputConnection();
if (isWordSeparator(primaryCode)) {
// Handle separator
if (mComposing.length() > 0) {
commitTyped(ic);
}
sendKey(primaryCode);
if (mJustEnteredAutoSpace) {
swapPunctuationAndSpace();
}
updateShiftKeyState(getCurrentInputEditorInfo());
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {
handleBackspace();
mDeleteCount++;
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
handleShift();
} else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
handleClose();
return;
} else if (primaryCode == LatinKeyboardView.KEYCODE_OPTIONS) {
showChooseLexiconDialog();
// 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 {
mJustEnteredAutoSpace = false;
handleCharacter(primaryCode, keyCodes);
}
}
示例13: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
if (primaryCode == Keyboard.KEYCODE_DELETE) {
keyDownUp(KeyEvent.KEYCODE_DEL);
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
mInputView.setShifted(!mInputView.isShifted());
} else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
requestHideSelf(0);
mInputView.closing();
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE
&& mInputView != null) {
Keyboard current = mInputView.getKeyboard();
if (current == mSymbolKeyboard) {
current = mQwertyKeyboard;
} else {
current = mSymbolKeyboard;
}
mInputView.setKeyboard(current);
} else {
if (isInputViewShown()) {
if (mInputView.isShifted()) {
primaryCode = Character.toUpperCase(primaryCode);
}
}
getCurrentInputConnection().commitText(
String.valueOf((char) primaryCode), 1);
}
}
示例14: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
Editable editable = ed.getText();
int start = ed.getSelectionStart();
if (primaryCode == Keyboard.KEYCODE_CANCEL) {// 完成
hideKeyboard();
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {// 回退
if (editable != null && editable.length() > 0) {
if (start > 0) {
editable.delete(start - 1, start);
}
}
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {// 大小寫切換
changeKey();
mKeyboardView.setKeyboard(k1);
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {// 數字鍵盤切換
if (isNun) {
isNun = false;
mKeyboardView.setKeyboard(k1);
} else {
isNun = true;
mKeyboardView.setKeyboard(k2);
}
} else if (primaryCode == 57419) { // go left
if (start > 0) {
ed.setSelection(start - 1);
}
} else if (primaryCode == 57421) { // go right
if (start < ed.length()) {
ed.setSelection(start + 1);
}
} else {
editable.insert(start, Character.toString((char) primaryCode));
}
}
示例15: onKey
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 = mEmoticonsKeyboard;
} else if (current == mQwertyKeyboard) {
current = mSymbolsKeyboard;
}
else
{
current = mQwertyKeyboard;
}
mInputView.setKeyboard(current);
if (current == mSymbolsKeyboard) {
current.setShifted(false);
}
} else {
handleCharacter(primaryCode, keyCodes);
}
}