Java Code Examples for android.view.KeyEvent#metaStateHasNoModifiers()
The following examples show how to use
android.view.KeyEvent#metaStateHasNoModifiers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VerticalViewPager.java From ankihelper with GNU General Public License v3.0 | 8 votes |
/** * 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. * * @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 (KeyEvent.metaStateHasNoModifiers(event.getMetaState())) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEvent.metaStateHasNoModifiers(event.getMetaState())) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
Example 2
Source File: LinkMovementMethod.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) { return true; } } break; } return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event); }
Example 3
Source File: LinkMovementMethod2.java From EhViewer with Apache License 2.0 | 6 votes |
@Override protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) { return true; } } break; } return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event); }
Example 4
Source File: AppCompatPreferenceActivity.java From MHViewer with Apache License 2.0 | 6 votes |
/** * KeyEvents with non-default modifiers are not dispatched to menu's performShortcut in API 25 * or lower. Here, we check if the keypress corresponds to a menuitem's shortcut combination * and perform the corresponding action. */ private boolean performMenuItemShortcut(int keycode, KeyEvent event) { if (!(Build.VERSION.SDK_INT >= 26) && !event.isCtrlPressed() && !KeyEvent.metaStateHasNoModifiers(event.getMetaState()) && event.getRepeatCount() == 0 && !KeyEvent.isModifierKey(event.getKeyCode())) { final Window currentWindow = getWindow(); if (currentWindow != null && currentWindow.getDecorView() != null) { final View decorView = currentWindow.getDecorView(); if (decorView.dispatchKeyShortcutEvent(event)) { return true; } } } return false; }
Example 5
Source File: LinkMovementMethod2.java From MHViewer with Apache License 2.0 | 6 votes |
@Override protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) { return true; } } break; } return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event); }
Example 6
Source File: AppCompatPreferenceActivity.java From EhViewer with Apache License 2.0 | 6 votes |
/** * KeyEvents with non-default modifiers are not dispatched to menu's performShortcut in API 25 * or lower. Here, we check if the keypress corresponds to a menuitem's shortcut combination * and perform the corresponding action. */ private boolean performMenuItemShortcut(int keycode, KeyEvent event) { if (!(Build.VERSION.SDK_INT >= 26) && !event.isCtrlPressed() && !KeyEvent.metaStateHasNoModifiers(event.getMetaState()) && event.getRepeatCount() == 0 && !KeyEvent.isModifierKey(event.getKeyCode())) { final Window currentWindow = getWindow(); if (currentWindow != null && currentWindow.getDecorView() != null) { final View decorView = currentWindow.getDecorView(); if (decorView.dispatchKeyShortcutEvent(event)) { return true; } } } return false; }
Example 7
Source File: MyLinkMovementMethod.java From FoldText_Java with MIT License | 6 votes |
@Override protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) { return true; } } break; } return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event); }
Example 8
Source File: LuaEditor.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public boolean onKeyShortcut(int keyCode, KeyEvent event) { final int filteredMetaState = event.getMetaState() & ~KeyEvent.META_CTRL_MASK; if (KeyEvent.metaStateHasNoModifiers(filteredMetaState)) { switch (keyCode) { case KeyEvent.KEYCODE_A: selectAll(); return true; case KeyEvent.KEYCODE_X: cut(); return true; case KeyEvent.KEYCODE_C: copy(); return true; case KeyEvent.KEYCODE_V: paste(); return true; } } return super.onKeyShortcut(keyCode, event); }
Example 9
Source File: DirectionalViewpager.java From ankihelper with GNU General Public License v3.0 | 6 votes |
/** * 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. * * @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 (KeyEvent.metaStateHasNoModifiers(event.getMetaState())) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEvent.metaStateHasNoModifiers(event.getMetaState())) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
Example 10
Source File: LinkMovementMethod.java From ForPDA with GNU General Public License v3.0 | 6 votes |
@Override protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) { return true; } } break; } return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event); }
Example 11
Source File: LinkMovementMethod2.java From Nimingban with Apache License 2.0 | 6 votes |
@Override protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) { return true; } } break; } return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event); }
Example 12
Source File: LongClickableLinkMovementMethod.java From iBeebo with GNU General Public License v3.0 | 5 votes |
@Override protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) { return true; } } break; } return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event); }
Example 13
Source File: LongClickableLinkMovementMethod.java From iBeebo with GNU General Public License v3.0 | 5 votes |
@Override protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) { return true; } } break; } return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event); }
Example 14
Source File: CountLinkMovementMethod.java From timecat with Apache License 2.0 | 5 votes |
@Override protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) { return true; } } break; } return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event); }
Example 15
Source File: v.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public static boolean b(int i) { return KeyEvent.metaStateHasNoModifiers(i); }
Example 16
Source File: KeyEventCompatHoneycomb.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public static boolean metaStateHasNoModifiers(int metaState) { return KeyEvent.metaStateHasNoModifiers(metaState); }
Example 17
Source File: KeyEventCompatHoneycomb.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static boolean metaStateHasNoModifiers(int metaState) { return KeyEvent.metaStateHasNoModifiers(metaState); }
Example 18
Source File: BaseMovementMethod.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Performs a movement key action. * The default implementation decodes the key down and invokes movement actions * such as {@link #down} and {@link #up}. * {@link #onKeyDown(TextView, Spannable, int, KeyEvent)} calls this method once * to handle an {@link KeyEvent#ACTION_DOWN}. * {@link #onKeyOther(TextView, Spannable, KeyEvent)} calls this method repeatedly * to handle each repetition of an {@link KeyEvent#ACTION_MULTIPLE}. * * @param widget The text view. * @param buffer The text buffer. * @param event The key event. * @param keyCode The key code. * @param movementMetaState The keyboard meta states used for movement. * @param event The key event. * @return True if the event was handled. */ protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return left(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_CTRL_ON)) { return leftWord(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return lineStart(widget, buffer); } break; case KeyEvent.KEYCODE_DPAD_RIGHT: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return right(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_CTRL_ON)) { return rightWord(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return lineEnd(widget, buffer); } break; case KeyEvent.KEYCODE_DPAD_UP: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return up(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return top(widget, buffer); } break; case KeyEvent.KEYCODE_DPAD_DOWN: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return down(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return bottom(widget, buffer); } break; case KeyEvent.KEYCODE_PAGE_UP: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return pageUp(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return top(widget, buffer); } break; case KeyEvent.KEYCODE_PAGE_DOWN: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return pageDown(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return bottom(widget, buffer); } break; case KeyEvent.KEYCODE_MOVE_HOME: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return home(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_CTRL_ON)) { return top(widget, buffer); } break; case KeyEvent.KEYCODE_MOVE_END: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return end(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_CTRL_ON)) { return bottom(widget, buffer); } break; } return false; }
Example 19
Source File: KeyEventCompatHoneycomb.java From V.FlyoutTest with MIT License | 4 votes |
public static boolean metaStateHasNoModifiers(int metaState) { return KeyEvent.metaStateHasNoModifiers(metaState); }
Example 20
Source File: KeyEventCompatHoneycomb.java From guideshow with MIT License | 4 votes |
public static boolean metaStateHasNoModifiers(int metaState) { return KeyEvent.metaStateHasNoModifiers(metaState); }