List of usage examples for android.view KeyEvent getRepeatCount
public final int getRepeatCount()
From source file:com.ichi2.anki2.DeckPicker.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { Log.i(AnkiDroidApp.TAG, "DeckPicker - onBackPressed()"); finishWithAnimation();//from ww w . j a v a 2 s. c o m return true; } return super.onKeyDown(keyCode, event); }
From source file:com.sim2dial.dialer.LinphoneActivity.java
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (currentFragment == FragmentsAvailable.DIALER) { boolean isBackgroundModeActive = Engine.getPref().getBoolean( getString(R.string.pref_background_mode_key), getResources().getBoolean(R.bool.pref_background_mode_default)); if (!isBackgroundModeActive) { stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class)); finish();/*from ww w . j a v a2 s. c o m*/ } else if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) { return true; } } else if (!isTablet()) { int backStackEntryCount = getSupportFragmentManager().getBackStackEntryCount(); if (backStackEntryCount <= 1) { showStatusBar(); // hideStatusBar(); } if (currentFragment == FragmentsAvailable.SETTINGS) { // showStatusBar(); hideStatusBar(); reloadConfig(); updateAnimationsState(); } } } else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) { if (event.getRepeatCount() < 1) { // statusFragment.openOrCloseStatusBar(true); } } return super.onKeyDown(keyCode, event); }
From source file:com.hichinaschool.flashcards.anki.DeckPicker.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // Log.i(AnkiDroidApp.TAG, "DeckPicker - onBackPressed()"); if (mFragmented && getFragment().congratsShowing()) { getFragment().finishCongrats(); return true; }/*from www . ja v a 2 s . c o m*/ finishWithAnimation(); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.ichi2.anki2.Reviewer.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { Log.i(AnkiDroidApp.TAG, "Reviewer - onBackPressed()"); closeReviewer(RESULT_DEFAULT, false); return true; }//from ww w . j a va2s . c o m /** Enhancement 722: Hardware buttons for scrolling, I.Z. */ if (!mCurrentSimpleInterface) { if (keyCode == 92) { mCard.pageUp(false); if (mDoubleScrolling) { mCard.pageUp(false); } return true; } if (keyCode == 93) { mCard.pageDown(false); if (mDoubleScrolling) { mCard.pageDown(false); } return true; } if (mScrollingButtons && keyCode == 94) { mCard.pageUp(false); if (mDoubleScrolling) { mCard.pageUp(false); } return true; } if (mScrollingButtons && keyCode == 95) { mCard.pageDown(false); if (mDoubleScrolling) { mCard.pageDown(false); } return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { LogUtil.d(TAG, "keycode back , chatfooter mode: " + mChattingFooter.getMode()); if (!mChattingFooter.isButtomPanelNotVisibility()) { hideBottom();//ww w .j a v a2 s . c o m return true; } setIsFinish(true); } else if (keyCode == KeyEvent.KEYCODE_DEL) { if (event.getAction() == KeyEvent.ACTION_DOWN) { mHandlerDelChar = !(mChattingFooter.getCharAtCursor() != (char) (8197)); } if (event.getAction() == KeyEvent.ACTION_UP && mHandlerDelChar) { mHandlerDelChar = false; CCPChattingFooter2 footer = this.mChattingFooter; int selectionStart = footer.getSelectionStart(); String text = footer.getLastText().substring(0, selectionStart); int atIndex = text.lastIndexOf('@'); if (atIndex < text.length() && atIndex >= 0) { delAtSomeBody(text.substring(atIndex, selectionStart)); String subStartText = text.substring(0, atIndex); String subSecondText = footer.getLastText().substring(selectionStart); StringBuilder sb = new StringBuilder(); sb.append(subStartText).append(subSecondText); footer.setLastText(sb.toString()); footer.mEditText.setSelection(atIndex); } } } return super.onKeyDown(keyCode, event); }
From source file:com.hichinaschool.flashcards.anki.Reviewer.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // Log.i(AnkiDroidApp.TAG, "Reviewer - onBackPressed()"); closeReviewer(RESULT_DEFAULT, false); return true; }//w w w . ja v a2 s. c o m /** Enhancement 722: Hardware buttons for scrolling, I.Z. */ if (!mCurrentSimpleInterface) { if (keyCode == 92) { mCard.pageUp(false); if (mDoubleScrolling) { mCard.pageUp(false); } return true; } if (keyCode == 93) { mCard.pageDown(false); if (mDoubleScrolling) { mCard.pageDown(false); } return true; } if (mScrollingButtons && keyCode == 94) { mCard.pageUp(false); if (mDoubleScrolling) { mCard.pageUp(false); } return true; } if (mScrollingButtons && keyCode == 95) { mCard.pageDown(false); if (mDoubleScrolling) { mCard.pageDown(false); } return true; } } return super.onKeyDown(keyCode, event); }
From source file:org.pocketworkstation.pckeyboard.LatinIME.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (event.getRepeatCount() == 0 && mKeyboardSwitcher.getInputView() != null) { if (mKeyboardSwitcher.getInputView().handleBack()) { return true; }/*from w ww . j a v a 2 s.c o m*/ } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return true; } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return true; } break; } return super.onKeyDown(keyCode, event); }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (event.getRepeatCount() == 0 && mKeyboardSwitcher.getInputView() != null) { if (mKeyboardSwitcher.getInputView().handleBack()) { return true; } else if (mTutorial != null) { mTutorial.close();/*from ww w . jav a2 s. c o m*/ mTutorial = null; } } break; case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: // If tutorial is visible, don't allow dpad to work if (mTutorial != null) { return true; } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return true; } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return true; } break; } return super.onKeyDown(keyCode, event); }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
@Override public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) { Logger.d(TAG, "onKeyUp keycode=%d", keyCode); switch (keyCode) { // Issue 248/*ww w . j a v a2 s.c o m*/ case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: if (!isInputViewShown()) { return super.onKeyUp(keyCode, event); } if (mAskPrefs.useVolumeKeyForLeftRight()) { // no need of vol up/down sound return true; } case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: if (getInputView() != null && getInputView().isShown() && getInputView().isShifted()) { event = new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getDeviceId(), event.getScanCode(), KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON); InputConnection ic = getCurrentInputConnection(); if (ic != null) ic.sendKeyEvent(event); return true; } break; case KeyEvent.KEYCODE_ALT_LEFT: case KeyEvent.KEYCODE_ALT_RIGHT: case KeyEvent.KEYCODE_SHIFT_LEFT: case KeyEvent.KEYCODE_SHIFT_RIGHT: case KeyEvent.KEYCODE_SYM: mMetaState = MyMetaKeyKeyListener.handleKeyUp(mMetaState, keyCode, event); Logger.d(TAG + "-meta-key", getMetaKeysStates("onKeyUp")); setInputConnectionMetaStateAsCurrentMetaKeyKeyListenerState(); break; } return super.onKeyUp(keyCode, event); }
From source file:com.android.tv.MainActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (SystemProperties.LOG_KEYEVENT.getValue()) Log.d(TAG, "dispatchKeyEvent(" + event + ")"); // If an activity is closed on a back key down event, back key down events with none zero // repeat count or a back key up event can be happened without the first back key down // event which should be ignored in this activity. if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { mBackKeyPressed = true;//from w ww . j av a 2 s . co m } if (!mBackKeyPressed) { return true; } if (event.getAction() == KeyEvent.ACTION_UP) { mBackKeyPressed = false; } } // When side panel is closing, it has the focus. // Keep the focus, but just don't deliver the key events. if ((mOverlayRootView.hasFocusable() && !mOverlayManager.getSideFragmentManager().isHiding()) || mOverlayManager.getSideFragmentManager().isActive()) { return super.dispatchKeyEvent(event); } if (BLACKLIST_KEYCODE_TO_TIS.contains(event.getKeyCode()) || KeyEvent.isGamepadButton(event.getKeyCode())) { // If the event is in blacklisted or gamepad key, do not pass it to session. // Gamepad keys are blacklisted to support TV UIs and here's the detail. // If there's a TIS granted RECEIVE_INPUT_EVENT, TIF sends key events to TIS // and return immediately saying that the event is handled. // In this case, fallback key will be injected but with FLAG_CANCELED // while gamepads support DPAD_CENTER and BACK by fallback. // Since we don't expect that TIS want to handle gamepad buttons now, // blacklist gamepad buttons and wait for next fallback keys. // TODO) Need to consider other fallback keys (e.g. ESCAPE) return super.dispatchKeyEvent(event); } return dispatchKeyEventToSession(event) || super.dispatchKeyEvent(event); }