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:git.egatuts.nxtremotecontroller.activity.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (this.drawerFragment.isDrawerOpened()) {
            this.drawerFragment.closeDrawer();
        } else {/*  w w w. jav a  2 s  .  c  o  m*/
            this.drawerFragment.openDrawer();
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        Limiter limiter = mPagerAdapter.getCurrentLimiter();

        if (mSlidingView.isShrinkable()) {
            mSlidingView.hideSlide();//from  w  w  w .j  a va2  s. co  m
            break;
        }

        if (mBottomBarControls.showSearch(false)) {
            break;
        }

        if (limiter != null) {
            int pos = -1;
            switch (limiter.type) {
            case MediaUtils.TYPE_ALBUM:
                setLimiter(MediaUtils.TYPE_ARTIST, limiter.data.toString());
                pos = mPagerAdapter.getMediaTypePosition(limiter.type);
                break;
            case MediaUtils.TYPE_ARTIST:
            case MediaUtils.TYPE_ALBARTIST:
            case MediaUtils.TYPE_COMPOSER:
            case MediaUtils.TYPE_GENRE:
                mPagerAdapter.clearLimiter(limiter.type);
                pos = mPagerAdapter.getMediaTypePosition(limiter.type);
                break;
            case MediaUtils.TYPE_FILE:
                File parentFile = ((File) limiter.data).getParentFile();
                mPagerAdapter.setLimiter(FileSystemAdapter.buildLimiter(parentFile));
                break;
            }
            if (pos == -1) {
                updateLimiterViews();
            } else {
                mViewPager.setCurrentItem(pos);
            }
        } else {
            finish();
        }
        break;
    case KeyEvent.KEYCODE_MENU:
        // We intercept these to avoid showing the activity-default menu
        mBottomBarControls.openMenu();
        break;
    case KeyEvent.KEYCODE_SEARCH:
        mBottomBarControls.showSearch(true);
        break;
    default:
        return false;
    }

    return true;
}

From source file:com.darly.im.ui.CCPActivityBase.java

/**
 *
 * @param keyCode/*from   ww w  . java 2  s.  c o m*/
 * @param event
 * @return
 */
public boolean onKeyUp(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_MENU && event.getAction() == KeyEvent.ACTION_UP) {
        /*if(mOverFlowAction != null && mOverFlowAction.isEnabled()) {
           callMenuCallback(mOverFlowMenuItem, mOverFlowAction);
           return true;
        }*/
    }
    return false;
}

From source file:com.zhongzilu.bit100.view.activity.EditorActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (!mExpandLayout.isExpanded())
            //??/*from  w w w .  j  a  v a2 s .co  m*/
            mActionOtherOperate.setIcon(R.drawable.ic_arrow_up);
        else
            mActionOtherOperate.setIcon(R.drawable.ic_add_white_24dp);
        mExpandLayout.toggle();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (mEditorFragment.onBackPressed())
            return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.maskyn.fileeditorpro.activity.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        onBackPressed();/*from w  ww .  j  a v  a 2 s  .  c o m*/
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MENU) {
        return false;
    } else {
        if (mEditor == null)
            mEditor = (Editor) findViewById(R.id.editor);

        // this will happen on first key pressed on hard-keyboard only. Once myInputField
        // gets the focus again, it will automatically receive further key presses.

        try {
            if (fileOpened && mEditor != null && !mEditor.hasFocus()) {
                mEditor.requestFocus();
                mEditor.onKeyDown(keyCode, event);
                return true;
            }
        } catch (NullPointerException ex) {

        }
    }

    return false;
}

From source file:edu.mit.mobile.android.demomode.DemoMode.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (mLocked && keyCode != KeyEvent.KEYCODE_MENU) {
        return true;
    } else {//from  ww  w.  j a  v a  2  s.c o  m
        return super.onKeyDown(keyCode, event);
    }
}

From source file:org.zywx.wbpalmstar.engine.EBrowserActivity.java

@Override
public final boolean onKeyDown(int keyCode, KeyEvent event) {
    mKeyDown = true;//from w ww  .ja  va  2 s  .  c o m
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
    case KeyEvent.KEYCODE_MENU:
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:org.youaretheone.website.client.UoneSearchGsonActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        toggleMenu();/*w w  w  . j  a v a  2s .  c o m*/
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }

}

From source file:cc.softwarefactory.lokki.android.activities.MainActivity.java

@Override
public boolean onKeyUp(int keycode, KeyEvent e) {
    switch (keycode) {
    case KeyEvent.KEYCODE_MENU:
        mNavigationDrawerFragment.toggleDrawer();
        return true;

    case KeyEvent.KEYCODE_BACK:
        if (selectedOption == 0) {
            Log.e(TAG, "Exiting app because requested by user.");
            finish();/*from  w w  w.ja  v  a2  s .  co m*/
        } else if (selectedOption == -10) { // -10 is add contacts screen
            mNavigationDrawerFragment.selectItem(3); // 3 is contacts screen
            return true;
        } else {
            mNavigationDrawerFragment.selectItem(1);
            return true;
        }
    }
    return super.onKeyUp(keycode, e);
}

From source file:info.zamojski.soft.towercollector.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (event.getAction() == KeyEvent.ACTION_UP && mainMenu != null) {
            Log.i("onKeyUp(): Hardware menu key pressed");
            mainMenu.performIdentifierAction(R.id.main_menu_more, 0);
            return true;
        }//from  w ww. ja  v  a2  s  .  co m
    }
    return super.onKeyUp(keyCode, event);
}