use of android.view.KeyCharacterMap in project little-bear-dictionary by daimajia.
the class ActionBarSherlockCompat method preparePanel.
// /////////////////////////////////////////////////////////////////////////
// Menu callback lifecycle and creation
// /////////////////////////////////////////////////////////////////////////
private boolean preparePanel() {
// Already prepared (isPrepared will be reset to false later)
if (mMenuIsPrepared) {
return true;
}
// Init the panel state's menu--return false if init failed
if (mMenu == null || mMenuRefreshContent) {
if (mMenu == null) {
if (!initializePanelMenu() || (mMenu == null)) {
return false;
}
}
if (wActionBar != null) {
wActionBar.setMenu(mMenu, this);
}
// Call callback, and return if it doesn't want to display menu.
// Creating the panel menu will involve a lot of manipulation;
// don't dispatch change events to presenters until we're done.
mMenu.stopDispatchingItemsChanged();
if (!callbackCreateOptionsMenu(mMenu)) {
// Ditch the menu created above
mMenu = null;
if (wActionBar != null) {
// Don't show it in the action bar either
wActionBar.setMenu(null, this);
}
return false;
}
mMenuRefreshContent = false;
}
// Callback and return if the callback does not want to show the menu
// Preparing the panel menu can involve a lot of manipulation;
// don't dispatch change events to presenters until we're done.
mMenu.stopDispatchingItemsChanged();
// an opportunity to override frozen/restored state in onPrepare.
if (mMenuFrozenActionViewState != null) {
mMenu.restoreActionViewStates(mMenuFrozenActionViewState);
mMenuFrozenActionViewState = null;
}
if (!callbackPrepareOptionsMenu(mMenu)) {
if (wActionBar != null) {
// The app didn't want to show the menu for now but it still exists.
// Clear it out of the action bar.
wActionBar.setMenu(null, this);
}
mMenu.startDispatchingItemsChanged();
return false;
}
// Set the proper keymap
KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
mMenu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC);
mMenu.startDispatchingItemsChanged();
// Set other state
mMenuIsPrepared = true;
return true;
}
use of android.view.KeyCharacterMap in project Ushahidi_Android by ushahidi.
the class ActionBarSherlockCompat method preparePanel.
// /////////////////////////////////////////////////////////////////////////
// Menu callback lifecycle and creation
// /////////////////////////////////////////////////////////////////////////
private boolean preparePanel() {
// Already prepared (isPrepared will be reset to false later)
if (mMenuIsPrepared) {
return true;
}
// Init the panel state's menu--return false if init failed
if (mMenu == null || mMenuRefreshContent) {
if (mMenu == null) {
if (!initializePanelMenu() || (mMenu == null)) {
return false;
}
}
if (wActionBar != null) {
wActionBar.setMenu(mMenu, this);
}
// Call callback, and return if it doesn't want to display menu.
// Creating the panel menu will involve a lot of manipulation;
// don't dispatch change events to presenters until we're done.
mMenu.stopDispatchingItemsChanged();
if (!callbackCreateOptionsMenu(mMenu)) {
// Ditch the menu created above
mMenu = null;
if (wActionBar != null) {
// Don't show it in the action bar either
wActionBar.setMenu(null, this);
}
return false;
}
mMenuRefreshContent = false;
}
// Callback and return if the callback does not want to show the menu
// Preparing the panel menu can involve a lot of manipulation;
// don't dispatch change events to presenters until we're done.
mMenu.stopDispatchingItemsChanged();
// an opportunity to override frozen/restored state in onPrepare.
if (mMenuFrozenActionViewState != null) {
mMenu.restoreActionViewStates(mMenuFrozenActionViewState);
mMenuFrozenActionViewState = null;
}
if (!callbackPrepareOptionsMenu(mMenu)) {
if (wActionBar != null) {
// The app didn't want to show the menu for now but it still exists.
// Clear it out of the action bar.
wActionBar.setMenu(null, this);
}
mMenu.startDispatchingItemsChanged();
return false;
}
// Set the proper keymap
KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
mMenu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC);
mMenu.startDispatchingItemsChanged();
// Set other state
mMenuIsPrepared = true;
return true;
}
use of android.view.KeyCharacterMap in project cornerstone by Onskreen.
the class PhoneWindowManager method dispatchUnhandledKey.
/**
* {@inheritDoc}
*/
@Override
public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) {
// Note: This method is only called if the initial down was unhandled.
if (DEBUG_INPUT) {
Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() + ", flags=" + event.getFlags() + ", keyCode=" + event.getKeyCode() + ", scanCode=" + event.getScanCode() + ", metaState=" + event.getMetaState() + ", repeatCount=" + event.getRepeatCount() + ", policyFlags=" + policyFlags);
}
KeyEvent fallbackEvent = null;
if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) {
final KeyCharacterMap kcm = event.getKeyCharacterMap();
final int keyCode = event.getKeyCode();
final int metaState = event.getMetaState();
final boolean initialDown = event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0;
// Check for fallback actions specified by the key character map.
final FallbackAction fallbackAction;
if (initialDown) {
fallbackAction = kcm.getFallbackAction(keyCode, metaState);
} else {
fallbackAction = mFallbackActions.get(keyCode);
}
if (fallbackAction != null) {
if (DEBUG_INPUT) {
Slog.d(TAG, "Fallback: keyCode=" + fallbackAction.keyCode + " metaState=" + Integer.toHexString(fallbackAction.metaState));
}
final int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK;
fallbackEvent = KeyEvent.obtain(event.getDownTime(), event.getEventTime(), event.getAction(), fallbackAction.keyCode, event.getRepeatCount(), fallbackAction.metaState, event.getDeviceId(), event.getScanCode(), flags, event.getSource(), null);
if (!interceptFallback(win, fallbackEvent, policyFlags)) {
fallbackEvent.recycle();
fallbackEvent = null;
}
if (initialDown) {
mFallbackActions.put(keyCode, fallbackAction);
} else if (event.getAction() == KeyEvent.ACTION_UP) {
mFallbackActions.remove(keyCode);
fallbackAction.recycle();
}
}
}
if (DEBUG_INPUT) {
if (fallbackEvent == null) {
Slog.d(TAG, "No fallback.");
} else {
Slog.d(TAG, "Performing fallback: " + fallbackEvent);
}
}
return fallbackEvent;
}
use of android.view.KeyCharacterMap in project httpclient by pixmob.
the class ActionBarSherlockCompat method preparePanel.
// /////////////////////////////////////////////////////////////////////////
// Menu callback lifecycle and creation
// /////////////////////////////////////////////////////////////////////////
private boolean preparePanel() {
// Already prepared (isPrepared will be reset to false later)
if (mMenuIsPrepared) {
return true;
}
// Init the panel state's menu--return false if init failed
if (mMenu == null || mMenuRefreshContent) {
if (mMenu == null) {
if (!initializePanelMenu() || (mMenu == null)) {
return false;
}
}
if (wActionBar != null) {
wActionBar.setMenu(mMenu, this);
}
// Call callback, and return if it doesn't want to display menu.
// Creating the panel menu will involve a lot of manipulation;
// don't dispatch change events to presenters until we're done.
mMenu.stopDispatchingItemsChanged();
if (!callbackCreateOptionsMenu(mMenu)) {
// Ditch the menu created above
mMenu = null;
if (wActionBar != null) {
// Don't show it in the action bar either
wActionBar.setMenu(null, this);
}
return false;
}
mMenuRefreshContent = false;
}
// Callback and return if the callback does not want to show the menu
// Preparing the panel menu can involve a lot of manipulation;
// don't dispatch change events to presenters until we're done.
mMenu.stopDispatchingItemsChanged();
// an opportunity to override frozen/restored state in onPrepare.
if (mMenuFrozenActionViewState != null) {
mMenu.restoreActionViewStates(mMenuFrozenActionViewState);
mMenuFrozenActionViewState = null;
}
if (!callbackPrepareOptionsMenu(mMenu)) {
if (wActionBar != null) {
// The app didn't want to show the menu for now but it still exists.
// Clear it out of the action bar.
wActionBar.setMenu(null, this);
}
mMenu.startDispatchingItemsChanged();
return false;
}
// Set the proper keymap
KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
mMenu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC);
mMenu.startDispatchingItemsChanged();
// Set other state
mMenuIsPrepared = true;
return true;
}
use of android.view.KeyCharacterMap in project platform_frameworks_base by android.
the class PhoneWindow method preparePanel.
/**
* Prepares the panel to either be opened or chorded. This creates the Menu
* instance for the panel and populates it via the Activity callbacks.
*
* @param st The panel state to prepare.
* @param event The event that triggered the preparing of the panel.
* @return Whether the panel was prepared. If the panel should not be shown,
* returns false.
*/
public final boolean preparePanel(PanelFeatureState st, KeyEvent event) {
if (isDestroyed()) {
return false;
}
// Already prepared (isPrepared will be reset to false later)
if (st.isPrepared) {
return true;
}
if ((mPreparedPanel != null) && (mPreparedPanel != st)) {
// Another Panel is prepared and possibly open, so close it
closePanel(mPreparedPanel, false);
}
final Callback cb = getCallback();
if (cb != null) {
st.createdPanelView = cb.onCreatePanelView(st.featureId);
}
final boolean isActionBarMenu = (st.featureId == FEATURE_OPTIONS_PANEL || st.featureId == FEATURE_ACTION_BAR);
if (isActionBarMenu && mDecorContentParent != null) {
// Enforce ordering guarantees around events so that the action bar never
// dispatches menu-related events before the panel is prepared.
mDecorContentParent.setMenuPrepared();
}
if (st.createdPanelView == null) {
// Init the panel state's menu--return false if init failed
if (st.menu == null || st.refreshMenuContent) {
if (st.menu == null) {
if (!initializePanelMenu(st) || (st.menu == null)) {
return false;
}
}
if (isActionBarMenu && mDecorContentParent != null) {
if (mActionMenuPresenterCallback == null) {
mActionMenuPresenterCallback = new ActionMenuPresenterCallback();
}
mDecorContentParent.setMenu(st.menu, mActionMenuPresenterCallback);
}
// Call callback, and return if it doesn't want to display menu.
// Creating the panel menu will involve a lot of manipulation;
// don't dispatch change events to presenters until we're done.
st.menu.stopDispatchingItemsChanged();
if ((cb == null) || !cb.onCreatePanelMenu(st.featureId, st.menu)) {
// Ditch the menu created above
st.setMenu(null);
if (isActionBarMenu && mDecorContentParent != null) {
// Don't show it in the action bar either
mDecorContentParent.setMenu(null, mActionMenuPresenterCallback);
}
return false;
}
st.refreshMenuContent = false;
}
// Callback and return if the callback does not want to show the menu
// Preparing the panel menu can involve a lot of manipulation;
// don't dispatch change events to presenters until we're done.
st.menu.stopDispatchingItemsChanged();
// an opportunity to override frozen/restored state in onPrepare.
if (st.frozenActionViewState != null) {
st.menu.restoreActionViewStates(st.frozenActionViewState);
st.frozenActionViewState = null;
}
if (!cb.onPreparePanel(st.featureId, st.createdPanelView, st.menu)) {
if (isActionBarMenu && mDecorContentParent != null) {
// The app didn't want to show the menu for now but it still exists.
// Clear it out of the action bar.
mDecorContentParent.setMenu(null, mActionMenuPresenterCallback);
}
st.menu.startDispatchingItemsChanged();
return false;
}
// Set the proper keymap
KeyCharacterMap kmap = KeyCharacterMap.load(event != null ? event.getDeviceId() : KeyCharacterMap.VIRTUAL_KEYBOARD);
st.qwertyMode = kmap.getKeyboardType() != KeyCharacterMap.NUMERIC;
st.menu.setQwertyMode(st.qwertyMode);
st.menu.startDispatchingItemsChanged();
}
// Set other state
st.isPrepared = true;
st.isHandled = false;
mPreparedPanel = st;
return true;
}
Aggregations