android.view.KeyEvent#isAltPressed ( )源码实例Demo

下面列出了android.view.KeyEvent#isAltPressed ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Conversations   文件: EditMessage.java
@Override
public boolean onKeyDown(int keyCode, KeyEvent e) {
    if (keyCode == KeyEvent.KEYCODE_ENTER && !e.isShiftPressed()) {
        lastInputWasTab = false;
        if (keyboardListener != null && keyboardListener.onEnterPressed()) {
            return true;
        }
    } else if (keyCode == KeyEvent.KEYCODE_TAB && !e.isAltPressed() && !e.isCtrlPressed()) {
        if (keyboardListener != null && keyboardListener.onTabPressed(this.lastInputWasTab)) {
            lastInputWasTab = true;
            return true;
        }
    } else {
        lastInputWasTab = false;
    }
    return super.onKeyDown(keyCode, e);
}
 
源代码2 项目: commcare-android   文件: FormEntryActivity.java
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            FirebaseAnalyticsUtil.reportFormQuitAttempt(AnalyticsParamValue.BACK_BUTTON_PRESS);
            triggerUserQuitInput();
            return true;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (event.isAltPressed() && !uiController.shouldIgnoreSwipeAction()) {
                uiController.setIsAnimatingSwipe();
                uiController.showNextView();
                return true;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (event.isAltPressed() && !uiController.shouldIgnoreSwipeAction()) {
                uiController.setIsAnimatingSwipe();
                uiController.showPreviousView(true);
                return true;
            }
            break;
    }
    return super.onKeyDown(keyCode, event);
}
 
源代码3 项目: commcare-android   文件: DrawActivity.java
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:

            createQuitDrawDialog();
            return true;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (event.isAltPressed()) {

                createQuitDrawDialog();
                return true;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (event.isAltPressed()) {

                createQuitDrawDialog();
                return true;
            }
            break;
    }
    return super.onKeyDown(keyCode, event);
}
 
源代码4 项目: talkback   文件: KeyAssignmentUtils.java
/**
 * Convert a KeyEvent into a long which can be kept in settings and compared to key presses when
 * the service is in use.
 *
 * @param keyEvent The key event to convert. The (non-extended) keycode must not be a modifier.
 * @return An extended key code that includes modifier information
 */
public static long keyEventToExtendedKeyCode(KeyEvent keyEvent) {
  long returnValue = keyEvent.getKeyCode();
  returnValue |= (keyEvent.isShiftPressed()) ? (((long) KeyEvent.META_SHIFT_ON) << 32) : 0;
  returnValue |= (keyEvent.isCtrlPressed()) ? (((long) KeyEvent.META_CTRL_ON) << 32) : 0;
  returnValue |= (keyEvent.isAltPressed()) ? (((long) KeyEvent.META_ALT_ON) << 32) : 0;
  return returnValue;
}
 
源代码5 项目: letv   文件: NestedScrollView.java
public boolean executeKeyEvent(KeyEvent event) {
    this.mTempRect.setEmpty();
    if (canScroll()) {
        boolean handled = false;
        if (event.getAction() == 0) {
            switch (event.getKeyCode()) {
                case 19:
                    if (!event.isAltPressed()) {
                        handled = arrowScroll(33);
                        break;
                    }
                    handled = fullScroll(33);
                    break;
                case 20:
                    if (!event.isAltPressed()) {
                        handled = arrowScroll(130);
                        break;
                    }
                    handled = fullScroll(130);
                    break;
                case 62:
                    pageScroll(event.isShiftPressed() ? 33 : 130);
                    break;
            }
        }
        return handled;
    } else if (!isFocused() || event.getKeyCode() == 4) {
        return false;
    } else {
        View currentFocused = findFocus();
        if (currentFocused == this) {
            currentFocused = null;
        }
        View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, 130);
        if (nextFocused == null || nextFocused == this || !nextFocused.requestFocus(130)) {
            return false;
        }
        return true;
    }
}
 
源代码6 项目: commcare-android   文件: StringWidget.java
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.isAltPressed()) {
        return false;
    }
    widgetEntryChanged();
    return super.onKeyDown(keyCode, event);
}
 
源代码7 项目: android_9.0.0_r45   文件: HorizontalScrollView.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.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    mTempRect.setEmpty();

    if (!canScroll()) {
        if (isFocused()) {
            View currentFocused = findFocus();
            if (currentFocused == this) currentFocused = null;
            View nextFocused = FocusFinder.getInstance().findNextFocus(this,
                    currentFocused, View.FOCUS_RIGHT);
            return nextFocused != null && nextFocused != this &&
                    nextFocused.requestFocus(View.FOCUS_RIGHT);
        }
        return false;
    }

    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_LEFT);
                } else {
                    handled = fullScroll(View.FOCUS_LEFT);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_RIGHT);
                } else {
                    handled = fullScroll(View.FOCUS_RIGHT);
                }
                break;
            case KeyEvent.KEYCODE_SPACE:
                pageScroll(event.isShiftPressed() ? View.FOCUS_LEFT : View.FOCUS_RIGHT);
                break;
        }
    }

    return handled;
}
 
源代码8 项目: 365browser   文件: KeyboardShortcuts.java
private static int getMetaState(KeyEvent event) {
    return (event.isCtrlPressed() ? CTRL : 0)
            | (event.isAltPressed() ? ALT : 0)
            | (event.isShiftPressed() ? SHIFT : 0);
}
 
源代码9 项目: MyBlogDemo   文件: NestedScrollView.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.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    mTempRect.setEmpty();

    if (!canScroll()) {
        if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) {
            View currentFocused = findFocus();
            if (currentFocused == this) currentFocused = null;
            View nextFocused = FocusFinder.getInstance().findNextFocus(this,
                    currentFocused, View.FOCUS_DOWN);
            return nextFocused != null
                    && nextFocused != this
                    && nextFocused.requestFocus(View.FOCUS_DOWN);
        }
        return false;
    }

    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_UP:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_UP);
                } else {
                    handled = fullScroll(View.FOCUS_UP);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_DOWN);
                } else {
                    handled = fullScroll(View.FOCUS_DOWN);
                }
                break;
            case KeyEvent.KEYCODE_SPACE:
                pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
                break;
        }
    }

    return handled;
}
 
源代码10 项目: JsDroidEditor   文件: HVScrollView.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.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    mTempRect.setEmpty();

    boolean handled = false;

    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
                if (canScrollH()) {
                    if (!event.isAltPressed()) {
                        handled = arrowScrollH(View.FOCUS_LEFT);
                    } else {
                        handled = fullScrollH(View.FOCUS_LEFT);
                    }
                }
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                if (canScrollH()) {
                    if (!event.isAltPressed()) {
                        handled = arrowScrollH(View.FOCUS_RIGHT);
                    } else {
                        handled = fullScrollH(View.FOCUS_RIGHT);
                    }
                }
                break;
            case KeyEvent.KEYCODE_DPAD_UP:
                if (canScrollV()) {
                    if (!event.isAltPressed()) {
                        handled = arrowScrollV(View.FOCUS_UP);
                    } else {
                        handled = fullScrollV(View.FOCUS_UP);
                    }
                }
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (canScrollV()) {
                    if (!event.isAltPressed()) {
                        handled = arrowScrollV(View.FOCUS_DOWN);
                    } else {
                        handled = fullScrollV(View.FOCUS_DOWN);
                    }
                }
                break;
        }
    }
    return handled;
}
 
源代码11 项目: javaide   文件: TwoDScrollView.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.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    mTempRect.setEmpty();
    if (!canScroll()) {
        if (isFocused()) {
            View currentFocused = findFocus();
            if (currentFocused == this) currentFocused = null;
            View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
            return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
        }
        return false;
    }
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_UP:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_UP, false);
                } else {
                    handled = fullScroll(View.FOCUS_UP, false);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_DOWN, false);
                } else {
                    handled = fullScroll(View.FOCUS_DOWN, false);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_LEFT:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_LEFT, true);
                } else {
                    handled = fullScroll(View.FOCUS_LEFT, true);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_RIGHT, true);
                } else {
                    handled = fullScroll(View.FOCUS_RIGHT, true);
                }
                break;
        }
    }
    return handled;
}
 
源代码12 项目: emerald   文件: Apps.java
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (event.getAction() != KeyEvent.ACTION_DOWN) {
		return super.onKeyDown(keyCode, event);
	}
	if (keyCode == KeyEvent.KEYCODE_MENU) {
		menu();
		return true;
	} else if (keyCode == KeyEvent.KEYCODE_BACK) {
		//Log.v(APP_TAG, "BACK pressed");
		if (searchIsOpened) {
			closeSearch();
		} else if (!isDefaultLauncher()) {
			finish();
			return true;
		} else {
			if (categories.getCurCategory().equals(CategoryManager.HIDDEN)) {
				findViewById(R.id.quit_hidden_apps).setVisibility(View.GONE);
				hideMainBarIfNeeded();
			}
			categories.prevCategory();
		}
		loadFilteredApps();
		return true;
	} else if (event.isAltPressed()) {
		if (keyCode >= KeyEvent.KEYCODE_1 && keyCode <= KeyEvent.KEYCODE_9) {
			Object app = dock.getApp(keyCode-KeyEvent.KEYCODE_1);
			if (app != null) {
				if (app instanceof AppData) {
					launch((AppData)app);
				} else if (app instanceof ShortcutData) {
					launch((ShortcutData)app);
				}
				return true;
			} else {
				return super.onKeyDown(keyCode, event);
			}
		} else if (keyCode == KeyEvent.KEYCODE_0 && !searchIsOpened) {
			openSearch();
		} else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
			categories.setCurCategory(categories.getCategory(CategoryManager.PREVIOUS));
			loadFilteredApps();
		} else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
			categories.setCurCategory(categories.getCategory(CategoryManager.NEXT));
			loadFilteredApps();
		} else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
			openCategoriesList();
		} else {
			return super.onKeyDown(keyCode, event);
		}
		return super.onKeyDown(keyCode, event);
	} else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
		View view = getCurrentFocus();
		if (view != null) {
			Object viewTag = view.getTag();
			if (viewTag instanceof AppData) {
				launch((AppData)viewTag);
				return true;
			} else if (viewTag instanceof ShortcutData) {
				launch((ShortcutData)viewTag);
				return true;
			}
			return super.onKeyDown(keyCode, event);
		}
		return super.onKeyDown(keyCode, event);
	} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
		if (options.getBoolean(Keys.VOLUME_BUTTONS, false)) {
			categories.setCurCategory(categories.getCategory(CategoryManager.PREVIOUS));
			loadFilteredApps();
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}
	} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
		if (options.getBoolean(Keys.VOLUME_BUTTONS, false)) {
			categories.setCurCategory(categories.getCategory(CategoryManager.NEXT));
			loadFilteredApps();
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}
	} else {
		return super.onKeyDown(keyCode, event);
	}
}
 
源代码13 项目: zhangshangwuda   文件: CustomScrollView.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.
 * 
 * @param event
 *            The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
	mTempRect.setEmpty();

	boolean handled = false;

	if (event.getAction() == KeyEvent.ACTION_DOWN) {
		switch (event.getKeyCode()) {
		case KeyEvent.KEYCODE_DPAD_LEFT:
			if (canScrollH()) {
				if (!event.isAltPressed()) {
					handled = arrowScrollH(View.FOCUS_LEFT);
				} else {
					handled = fullScrollH(View.FOCUS_LEFT);
				}
			}
			break;
		case KeyEvent.KEYCODE_DPAD_RIGHT:
			if (canScrollH()) {
				if (!event.isAltPressed()) {
					handled = arrowScrollH(View.FOCUS_RIGHT);
				} else {
					handled = fullScrollH(View.FOCUS_RIGHT);
				}
			}
			break;
		case KeyEvent.KEYCODE_DPAD_UP:
			if (canScrollV()) {
				if (!event.isAltPressed()) {
					handled = arrowScrollV(View.FOCUS_UP);
				} else {
					handled = fullScrollV(View.FOCUS_UP);
				}
			}
			break;
		case KeyEvent.KEYCODE_DPAD_DOWN:
			if (canScrollV()) {
				if (!event.isAltPressed()) {
					handled = arrowScrollV(View.FOCUS_DOWN);
				} else {
					handled = fullScrollV(View.FOCUS_DOWN);
				}
			}
			break;
		}
	}
	return handled;
}
 
源代码14 项目: opensudoku   文件: SudokuBoardView.java
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (!mReadonly) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_UP:
                return moveCellSelection(0, -1);
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                return moveCellSelection(1, 0);
            case KeyEvent.KEYCODE_DPAD_DOWN:
                return moveCellSelection(0, 1);
            case KeyEvent.KEYCODE_DPAD_LEFT:
                return moveCellSelection(-1, 0);
            case KeyEvent.KEYCODE_0:
            case KeyEvent.KEYCODE_SPACE:
            case KeyEvent.KEYCODE_DEL:
                // clear value in selected cell
                // TODO: I'm not really sure that this is thread-safe
                if (mSelectedCell != null) {
                    if (event.isShiftPressed() || event.isAltPressed()) {
                        setCellNote(mSelectedCell, CellNote.EMPTY);
                    } else {
                        setCellValue(mSelectedCell, 0);
                        moveCellSelectionRight();
                    }
                }
                return true;
            case KeyEvent.KEYCODE_DPAD_CENTER:
                if (mSelectedCell != null) {
                    onCellTapped(mSelectedCell);
                }
                return true;
        }

        if (keyCode >= KeyEvent.KEYCODE_1 && keyCode <= KeyEvent.KEYCODE_9 && mSelectedCell != null) {
            int selNumber = keyCode - KeyEvent.KEYCODE_0;
            Cell cell = mSelectedCell;

            if (event.isShiftPressed() || event.isAltPressed()) {
                // add or remove number in cell's note
                setCellNote(cell, cell.getNote().toggleNumber(selNumber));
            } else {
                // enter number in cell
                setCellValue(cell, selNumber);
                moveCellSelectionRight();
            }
            return true;
        }
    }


    return false;
}
 
源代码15 项目: intra42   文件: TwoDScrollView.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.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    tempRect.setEmpty();
    if (!canScroll()) {
        if (isFocused()) {
            View currentFocused = findFocus();
            if (currentFocused == this) {
                currentFocused = null;
            }
            View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused,
                    View.FOCUS_DOWN);
            return nextFocused != null && nextFocused != this
                    && nextFocused.requestFocus(View.FOCUS_DOWN);
        }
        return false;
    }
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_UP:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_UP, false);
                } else {
                    handled = fullScroll(View.FOCUS_UP, false);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_DOWN, false);
                } else {
                    handled = fullScroll(View.FOCUS_DOWN, false);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_LEFT:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_LEFT, true);
                } else {
                    handled = fullScroll(View.FOCUS_LEFT, true);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_RIGHT, true);
                } else {
                    handled = fullScroll(View.FOCUS_RIGHT, true);
                }
                break;
        }
    }
    return handled;
}
 
源代码16 项目: delion   文件: KeyboardShortcuts.java
private static int getMetaState(KeyEvent event) {
    return (event.isCtrlPressed() ? CTRL : 0)
            | (event.isAltPressed() ? ALT : 0)
            | (event.isShiftPressed() ? SHIFT : 0);
}
 
/**
 * 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) {
    mTempRect.setEmpty();

    if (!canScroll()) {
        if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) {
            View currentFocused = findFocus();
            if (currentFocused == this) currentFocused = null;
            View nextFocused = FocusFinder.getInstance().findNextFocus(this,
                    currentFocused, View.FOCUS_DOWN);
            return nextFocused != null
                    && nextFocused != this
                    && nextFocused.requestFocus(View.FOCUS_DOWN);
        }
        return false;
    }

    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_UP:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_UP);
                } else {
                    handled = fullScroll(View.FOCUS_UP);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_DOWN);
                } else {
                    handled = fullScroll(View.FOCUS_DOWN);
                }
                break;
            case KeyEvent.KEYCODE_SPACE:
                pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
                break;
        }
    }

    return handled;
}
 
源代码18 项目: prayer-times-android   文件: MyScrollView.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.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
boolean executeKeyEvent(@NonNull KeyEvent event) {
    mTempRect.setEmpty();

    if (!canScroll()) {
        if (isFocused() && (event.getKeyCode() != KeyEvent.KEYCODE_BACK)) {
            View currentFocused = findFocus();
            if (currentFocused == this) {
                currentFocused = null;
            }
            View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
            return (nextFocused != null) && (nextFocused != this) && nextFocused.requestFocus(View.FOCUS_DOWN);
        }
        return false;
    }

    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_UP:
                if (event.isAltPressed()) {
                    handled = fullScroll(View.FOCUS_UP);
                } else {
                    handled = arrowScroll(View.FOCUS_UP);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (event.isAltPressed()) {
                    handled = fullScroll(View.FOCUS_DOWN);
                } else {
                    handled = arrowScroll(View.FOCUS_DOWN);
                }
                break;
            case KeyEvent.KEYCODE_SPACE:
                pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
                break;
        }
    }

    return handled;
}
 
源代码19 项目: android-vlc-remote   文件: PlaybackActivity.java
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    int c = event.getUnicodeChar();
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        if (mVolumeLevel != VOLUME_LEVEL_UNKNOWN) {
            setVolume(mVolumeLevel + 20);
        } else {
            mMediaServer.status().command.volumeUp();
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        if (mVolumeLevel != VOLUME_LEVEL_UNKNOWN) {
            setVolume(mVolumeLevel - 20);
        } else {
            mMediaServer.status().command.volumeDown();
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
        if (event.isAltPressed()) {
            mMediaServer.status().command.seek(Uri.encode("-".concat(Preferences.get(this).getSeekTime())));
            return true;
        } else if (event.isShiftPressed()) {
            mMediaServer.status().command.seek(Uri.encode("-3"));
            return true;
        } else {
            mMediaServer.status().command.key("nav-left");
            return true;
        }
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
        if (event.isAltPressed()) {
            mMediaServer.status().command.seek(Uri.encode("+".concat(Preferences.get(this).getSeekTime())));
            return true;
        } else if (event.isShiftPressed()) {
            mMediaServer.status().command.seek(Uri.encode("+3"));
            return true;
        } else {
            mMediaServer.status().command.key("nav-right");
            return true;
        }
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
        mMediaServer.status().command.key("nav-up");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        mMediaServer.status().command.key("nav-down");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        mMediaServer.status().command.key("nav-activate");
        return true;
    } else if (c == ' ') {
        mMediaServer.status().command.playback.pause();
        return true;
    } else if (c == 's') {
        mMediaServer.status().command.playback.stop();
        return true;
    } else if (c == 'p') {
        mMediaServer.status().command.playback.previous();
        return true;
    } else if (c == 'n') {
        mMediaServer.status().command.playback.next();
        return true;
    } else if (c == '+') {
        // TODO: Play faster
        return super.onKeyDown(keyCode, event);
    } else if (c == '-') {
        // TODO: Play slower
        return super.onKeyDown(keyCode, event);
    } else if (c == 'f') {
        mMediaServer.status().command.fullscreen();
        return true;
    } else if (c == 'm') {
        mute();
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}
 
源代码20 项目: AirFree-Client   文件: ScrollViewer.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.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
 mTempRect.setEmpty();
 if (!canScroll()) {
	 if (isFocused()) {
		 View currentFocused = findFocus();
		 if (currentFocused == this) currentFocused = null;
		 View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
		 return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
	 }
	 return false;
 }
 boolean handled = false;
 if (event.getAction() == KeyEvent.ACTION_DOWN) {
	 switch (event.getKeyCode()) {
	 case KeyEvent.KEYCODE_DPAD_UP:
		 if (!event.isAltPressed()) {
			 handled = arrowScroll(View.FOCUS_UP, false);
		 } else {
			 handled = fullScroll(View.FOCUS_UP, false);
		 }
		 break;
	 case KeyEvent.KEYCODE_DPAD_DOWN:
		 if (!event.isAltPressed()) {
			 handled = arrowScroll(View.FOCUS_DOWN, false);
		 } else {
			 handled = fullScroll(View.FOCUS_DOWN, false);
		 }
		 break;
	 case KeyEvent.KEYCODE_DPAD_LEFT:
		 if (!event.isAltPressed()) {
			 handled = arrowScroll(View.FOCUS_LEFT, true);
		 } else {
			 handled = fullScroll(View.FOCUS_LEFT, true);
		 }
		 break;
	 case KeyEvent.KEYCODE_DPAD_RIGHT:
		 if (!event.isAltPressed()) {
			 handled = arrowScroll(View.FOCUS_RIGHT, true);
		 } else {
			 handled = fullScroll(View.FOCUS_RIGHT, true);
		 }
		 break;
	 }
 }
 return handled;
}
 
 方法所在类
 同类方法