Example usage for android.view KeyEvent KEYCODE_MENU

List of usage examples for android.view KeyEvent KEYCODE_MENU

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_MENU.

Prototype

int KEYCODE_MENU

To view the source code for android.view KeyEvent KEYCODE_MENU.

Click Source Link

Document

Key code constant: Menu key.

Usage

From source file:paulscode.android.mupen64plusae.GalleryActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        // Show the navigation drawer when the user presses the Menu button
        // http://stackoverflow.com/q/22220275
        if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
            mDrawerLayout.closeDrawer(GravityCompat.START);
        } else {/* w  w w. j a v  a2s.  c  o m*/
            mDrawerLayout.openDrawer(GravityCompat.START);
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:org.hw.parlance.ParlanceActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
        if (event.getRepeatCount() < 1) {
            statusFragment.openOrCloseStatusBar(true);
        }//from  w w w .  ja  v  a  2  s . c o m
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.google.android.apps.muzei.MuzeiActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU:
        if (mUiMode == UI_MODE_ART_DETAIL) {
            mOverflowMenuVisible = true;
            mOverflowMenu.show();/*from   w ww .j  av a 2s . c o  m*/
        }
        return true;
    }

    return super.onKeyUp(keyCode, event);
}

From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (isShowOptionsColumns()) {
            hideOptionsColumns();/*from  w  ww.j av  a  2  s  . c  o m*/
            return false;
        }
        if (popupLinks.isShowLinks()) {
            popupLinks.hideLinks();
            return false;
        }
        if (splitActionBarMenu.isShowing()) {
            splitActionBarMenu.hideSplitActionBarMenu();
            return false;
        }
        if (isShowColumnsItems) {
            showActionBarIndicatorAndMovePager(-1);
            return false;
        }
    }
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        goToColumn(0, false, -1);
    }
    return super.onKeyDown(keyCode, event);
}

From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java

@Override
boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU: {
        // LEWA MODIFY BEGIN
        if (true && mActionBar != null && mActionMode != null) {// action mode 
            mActionModeView.toggleActionModeOptionMenu();
        } else if (true && mActionBar != null) {
            //refresh menu
            if (splitActionBarView != null && mActivity != null) {
                LinearLayout splitView = splitActionBarView.getActionOptionMenuBar();
                if (splitView != null && splitView.getVisibility() != View.VISIBLE) {

                    //                  mActivity.invalidateOptionsMenu();

                    if (!mInvalidateMenuPosted) {
                        mInvalidateMenuPosted = true;
                        final MenuBuilder menu = createMenu();
                        if (mActivity.superOnCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu)
                                && mActivity.superOnPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu)) {
                            setMenu(menu);
                        } else {
                            setMenu(null);
                        }/*from  w  w w  .  j  ava  2  s  .c om*/
                        //                        updateActionMenuCount(splitActionBarView, mMenu);
                        mInvalidateMenuPosted = false;
                    } else {
                        return true;
                    }

                    //                   final MenuBuilder menu = createMenu();
                    //                  if (mMenu != null) {
                    //                      if (mActivity.superOnPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, mMenu)) {
                    //                           
                    //                               setMenu(mMenu);
                    //                           } else {
                    //      
                    //                               setMenu(null);
                    //                           }
                    //                           updateActionMenuCount(splitActionBarView, mMenu);
                    //                  } 

                }
            }

            mActionBarView.toggleActionOptionMenu();

        }
        // LEWA MODIFY END

        return true;
    }
    }
    return false;
}

From source file:com.abc.driver.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {

        if (menu_display) {
            menuWindow.dismiss();//  ww w . j av a2  s .c om
            menu_display = false;
        } else {
            onBackPressed();
        }
    }

    else if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (!menu_display) {
            inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
            layout = inflater.inflate(R.layout.main_menu, null);

            menuWindow = new PopupWindow(layout, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
            menuWindow.showAtLocation(this.findViewById(R.id.mainweixin),
                    Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
            mClose = (LinearLayout) layout.findViewById(R.id.menu_close);
            mCloseBtn = (LinearLayout) layout.findViewById(R.id.menu_close_btn);

            mCloseBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent intent = new Intent();
                    menuWindow.dismiss();
                }
            });
            menu_display = true;
        } else {
            menuWindow.dismiss();
            menu_display = false;
        }

        return false;
    }
    return false;
}

From source file:paulscode.android.mupen64plusae.game.GameFragment.java

/**
 * Handle view onKey callbacks// w  w w .  j  a v  a2 s  .  c  o  m
 * @param view If view is NULL then this keycode will not be handled by the key provider. This is to avoid
 *             the situation where user maps the menu key to the menu command.
 * @param keyCode key code
 * @param event key event
 * @return True if handled
 */
@Override
public boolean onKey(View view, int keyCode, KeyEvent event) {
    final boolean keyDown = event.getAction() == KeyEvent.ACTION_DOWN;

    boolean handled = false;

    // Attempt to reconnect any disconnected devices
    mGamePrefs.playerMap.reconnectDevice(AbstractProvider.getHardwareId(event));

    if (!mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
        // If PeripheralControllers exist and handle the event,
        // they return true. Else they return false, signaling
        // Android to handle the event (menu button, vol keys).
        if (mKeyProvider != null && view != null) {
            handled = mKeyProvider.onKey(view, keyCode, event);

            //Don't use built in keys in the device to hide the touch controls
            if (handled && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_BACK
                    && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN
                    && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE && mGlobalPrefs.touchscreenAutoHideEnabled) {
                mOverlay.onTouchControlsHide();
            }
        }
    }

    if (!handled) {
        if (keyDown && keyCode == KeyEvent.KEYCODE_MENU) {
            if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
                mDrawerLayout.closeDrawer(GravityCompat.START);
                mOverlay.requestFocus();
            } else {
                mCoreFragment.pauseEmulator();
                mDrawerLayout.openDrawer(GravityCompat.START);
                mDrawerOpenState = true;
                mGameSidebar.requestFocus();
                mGameSidebar.smoothScrollToPosition(0);
            }
            return true;
        } else if (keyDown && keyCode == KeyEvent.KEYCODE_BACK) {
            if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
                mDrawerLayout.closeDrawer(GravityCompat.START);
                mOverlay.requestFocus();
            } else {
                //We are using the slide gesture for the menu, so the back key can be used to exit
                if (mGlobalPrefs.inGameMenuIsSwipGesture) {
                    mWaitingOnConfirmation = true;
                    mCoreFragment.exit();
                }
                //Else the back key bring up the in-game menu
                else {
                    mCoreFragment.pauseEmulator();
                    mDrawerLayout.openDrawer(GravityCompat.START);
                    mDrawerOpenState = true;
                    mGameSidebar.requestFocus();
                    mGameSidebar.smoothScrollToPosition(0);
                }
            }
            return true;
        }
    }

    return handled;
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU:
        onKeyUpPanel(Window.FEATURE_OPTIONS_PANEL, event);
        return true;
    case KeyEvent.KEYCODE_BACK:
        PanelFeatureState st = getPanelState(Window.FEATURE_OPTIONS_PANEL, false);
        if (st != null && st.isOpen) {
            closePanel(st, true);//from  w ww  .  j av a 2s .  com
            return true;
        }
        if (onBackPressed()) {
            return true;
        }
        break;
    }
    return false;
}

From source file:com.justwayward.reader.ui.activity.ReadActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        if (mTocListPopupWindow != null && mTocListPopupWindow.isShowing()) {
            mTocListPopupWindow.dismiss();
            gone(mTvBookReadTocTitle);/*from   w  w  w  .  jav  a2 s  .c o  m*/
            visible(mTvBookReadReading, mTvBookReadCommunity, mTvBookReadChangeSource);
            return true;
        } else if (isVisible(rlReadAaSet)) {
            gone(rlReadAaSet);
            return true;
        } else if (isVisible(mLlBookReadBottom)) {
            hideReadBar();
            return true;
        } else if (!CollectionsManager.getInstance().isCollected(bookId)) {
            showJoinBookShelfDialog(recommendBooks);
            return true;
        }
        break;
    case KeyEvent.KEYCODE_MENU:
        toggleReadBar();
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (SettingManager.getInstance().isVolumeFlipEnable()) {
            return true;
        }
        break;
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (SettingManager.getInstance().isVolumeFlipEnable()) {
            return true;
        }
        break;
    default:
        break;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.gelakinetic.mtgfam.activities.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    /*/*from  w  w  w.  jav a 2  s. c om*/
     * This is for ForceOverflow
     */
    if (DEVICE_VERSION < DEVICE_HONEYCOMB) {
        if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_MENU) {
            openOptionsMenu();
            return true;
        }
    }
    return super.onKeyUp(keyCode, event);
}