List of usage examples for android.view KeyEvent META_SHIFT_ON
int META_SHIFT_ON
To view the source code for android.view KeyEvent META_SHIFT_ON.
Click Source Link
This mask is used to check whether one of the SHIFT meta keys is pressed.
From source file:com.android.launcher3.folder.Folder.java
public void updateTextViewFocus() { final View firstChild = mContent.getFirstItem(); final View lastChild = mContent.getLastItem(); if (firstChild != null && lastChild != null) { mFolderName.setNextFocusDownId(lastChild.getId()); mFolderName.setNextFocusRightId(lastChild.getId()); mFolderName.setNextFocusLeftId(lastChild.getId()); mFolderName.setNextFocusUpId(lastChild.getId()); // Hitting TAB from the folder name wraps around to the first item on the current // folder page, and hitting SHIFT+TAB from that item wraps back to the folder name. mFolderName.setNextFocusForwardId(firstChild.getId()); // When clicking off the folder when editing the name, this Folder gains focus. When // pressing an arrow key from that state, give the focus to the first item. this.setNextFocusDownId(firstChild.getId()); this.setNextFocusRightId(firstChild.getId()); this.setNextFocusLeftId(firstChild.getId()); this.setNextFocusUpId(firstChild.getId()); // When pressing shift+tab in the above state, give the focus to the last item. setOnKeyListener(new OnKeyListener() { @Override/*from w ww . java 2 s . co m*/ public boolean onKey(View v, int keyCode, KeyEvent event) { boolean isShiftPlusTab = keyCode == KeyEvent.KEYCODE_TAB && event.hasModifiers(KeyEvent.META_SHIFT_ON); if (isShiftPlusTab && Folder.this.isFocused()) { return lastChild.requestFocus(); } return false; } }); } }
From source file:com.android.launcher2.PagedView.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { // Handle mouse (or ext. device) by shifting the page depending on the scroll final float vscroll; final float hscroll; if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) { vscroll = 0;/*www . j a va2 s .co m*/ hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); } else { vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL); hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); } if (hscroll != 0 || vscroll != 0) { if (hscroll > 0 || vscroll > 0) { scrollRight(); } else { scrollLeft(); } return true; } } } } return super.onGenericMotionEvent(event); }
From source file:org.pocketworkstation.pckeyboard.LatinIME.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); // Enable shift key and DPAD to do selections if (inputView != null && inputView.isShown() && inputView.getShiftState() == Keyboard.SHIFT_ON) { 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);//from w w w . j a v a 2 s . c o m return true; } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolUpAction); } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolDownAction); } break; } return super.onKeyUp(keyCode, event); }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { 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; }//from w w w.ja v a 2s .com TKKeyboardView inputView = mKeyboardSwitcher.getInputView(); // Enable shift key and DPAD to do selections if (inputView != null && inputView.isShown() && inputView.getShiftState() == Keyboard.SHIFT_ON) { 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_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolUpAction); } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolDownAction); } break; } return super.onKeyUp(keyCode, event); }
From source file:com.appunite.list.GridView.java
private boolean commonKey(int keyCode, int count, KeyEvent event) { if (mAdapter == null) { return false; }/*w w w . ja va 2s. c o m*/ if (mDataChanged) { layoutChildren(); } boolean handled = false; int action = event.getAction(); if (action != KeyEvent.ACTION_UP) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_LEFT); } break; case KeyEvent.KEYCODE_DPAD_RIGHT: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_RIGHT); } break; case KeyEvent.KEYCODE_DPAD_UP: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_UP); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_DPAD_DOWN: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_DOWN); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded(); if (!handled && event.getRepeatCount() == 0 && getChildCount() > 0) { keyPressed(); handled = true; } } break; case KeyEvent.KEYCODE_SPACE: if (mPopup == null || !mPopup.isShowing()) { if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP); } } break; case KeyEvent.KEYCODE_PAGE_UP: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_PAGE_DOWN: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_MOVE_HOME: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_MOVE_END: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_TAB: // XXX Sometimes it is useful to be able to TAB through the items in // a GridView sequentially. Unfortunately this can create an // asymmetry in TAB navigation order unless the list selection // always reverts to the top or bottom when receiving TAB focus from // another widget. Leaving this behavior disabled for now but // perhaps it should be configurable (and more comprehensive). if (false) { if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || sequenceScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = resurrectSelectionIfNeeded() || sequenceScroll(FOCUS_BACKWARD); } } break; } } if (handled) { return true; } if (sendToTextFilter(keyCode, count, event)) { return true; } switch (action) { case KeyEvent.ACTION_DOWN: return super.onKeyDown(keyCode, event); case KeyEvent.ACTION_UP: return super.onKeyUp(keyCode, event); case KeyEvent.ACTION_MULTIPLE: return super.onKeyMultiple(keyCode, count, event); default: return false; } }
From source file:bw.com.yunifangstore.view.LazyViewPager.java
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy.//from w ww. j a v a2s. c o m * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } break; } } return handled; }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
private int getMetaState(boolean shifted) { int meta = 0; if (shifted)/*from w ww .j a v a2 s .c o m*/ meta |= KeyEvent.META_SHIFT_ON | KeyEvent.META_SHIFT_LEFT_ON; if (mModCtrl) meta |= KeyEvent.META_CTRL_ON | KeyEvent.META_CTRL_LEFT_ON; if (mModAlt) meta |= KeyEvent.META_ALT_ON | KeyEvent.META_ALT_LEFT_ON; if (mModMeta) meta |= KeyEvent.META_META_ON | KeyEvent.META_META_LEFT_ON; return meta; }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
private void sendShiftKey(InputConnection ic, boolean isDown) { int key = KeyEvent.KEYCODE_SHIFT_LEFT; int meta = KeyEvent.META_SHIFT_ON | KeyEvent.META_SHIFT_LEFT_ON; if (isDown) { sendKeyDown(ic, key, meta);//from w w w .j a v a 2 s . co m } else { sendKeyUp(ic, key, meta); } }
From source file:com.chenglong.muscle.ui.LazyViewPager.java
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy./*from www .ja v a 2 s . c o m*/ * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and // FOCUS_BACKWARD // before Android 3.0. Ignore the include_tab key on those // devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
From source file:beichen.douban.ui.view.LazyViewPager.java
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy.//from w w w . j a v a 2 s. c o m * * @param event * The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and // FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those // devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }