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:fr.plnech.igem.game.AbstractGameActivity.java

@Override
public boolean onKeyDown(final int pKeyCode, @NonNull final KeyEvent pEvent) {
    if (gameScene != null && pauseScene != null && pKeyCode == KeyEvent.KEYCODE_MENU
            && pEvent.getAction() == KeyEvent.ACTION_DOWN) {
        if (gameScene.hasChildScene()) { // The game is paused
            music.play();/* ww  w . j av  a2s  . c  o m*/
            pauseScene.back();
            updateNextStatus();
        } else {
            music.pause();
            gameScene.setChildScene(pauseScene, false, true, true);
        }
        return true;
    } else {
        return super.onKeyDown(pKeyCode, pEvent);
    }
}

From source file:fr.univsavoie.ltp.client.LoginActivity.java

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

From source file:com.jtxdriggers.android.ventriloid.Connected.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (pttEnabled && !pttToggle && keyCode == pttKey) {
        s.setPTTOn(false);//from   w  w  w  .  j a  va2 s.  c  o m
        bottomBar.setBackgroundResource(R.drawable.abs__ab_bottom_solid_light_holo);
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MENU && !sm.isMenuShowing()) {
        sm.showMenu();
        return true;
    }

    return super.onKeyUp(keyCode, event);
}

From source file:org.fossasia.phimpme.leafpic.activities.PlayerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    FrameLayout root = (FrameLayout) findViewById(R.id.root);
    findViewById(R.id.video_frame).setOnClickListener(new View.OnClickListener() {
        @Override// w  w  w  .ja v  a2 s  .co m
        public void onClick(View view) {
            toggleControlsVisibility();
        }
    });

    root.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            return !(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE
                    || keyCode == KeyEvent.KEYCODE_MENU) && mediaController.dispatchKeyEvent(event);
        }
    });

    root.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));

    shutterView = findViewById(R.id.shutter);

    videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);

    mediaController = new CustomMediaController(this, this);

    mediController_anchor = findViewById(R.id.media_player_anchor);
    mediaController.setAnchorView(root);
    //mediaController.setPaddingRelative(0,0,0,Measure.getNavBarHeight(PlayerActivity.this));
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    initUI();

    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager)
        CookieHandler.setDefault(defaultCookieManager);

    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
    audioCapabilitiesReceiver.register();
}

From source file:com.horaapps.leafpic.PlayerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    FrameLayout root = (FrameLayout) findViewById(R.id.root);
    root.setOnTouchListener(new OnTouchListener() {
        @Override//w  ww  . ja  v a2 s  . co  m
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                //view.performClick();
            }
            return true;
        }
    });

    root.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            return !(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE
                    || keyCode == KeyEvent.KEYCODE_MENU) && mediaController.dispatchKeyEvent(event);
        }
    });

    root.setBackgroundColor(R.color.md_black_1000);

    shutterView = findViewById(R.id.shutter);

    videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);

    mediaController = new KeyCompatibleMediaController(this);

    mediController_anchor = findViewById(R.id.media_player_anchor);
    mediaController.setAnchorView(mediController_anchor);
    mediaController.setPaddingRelative(0, 0, 0, Measure.getNavBarHeight(PlayerActivity.this));
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    initUI();

    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager)
        CookieHandler.setDefault(defaultCookieManager);

    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
    audioCapabilitiesReceiver.register();
}

From source file:com.hp.map.CustomerMapActivity.java

public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {

        menuDialog();//from   w  ww  .  j  av  a  2s  .c o  m
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.example.android.navigationdrawerexample.SecondActivity.java

@Override
public boolean onKeyUp(final int keyCode, final KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (mPopupMenu == null || mPopupMenu != null && mNeedToReinitPopupMenu) {
            mNeedToReinitPopupMenu = false;
            mPopupMenu = new PopupMenu(this, findViewById(R.id.action_overflow));
            mPopupMenu.inflate(R.menu.drawlayoutpopup_menu);
            mPopupMenu.setOnMenuItemClickListener(this);
        }//from   ww  w. j  a v a2  s  .c  o m
        mPopupMenu.show();
    }
    return super.onKeyUp(keyCode, event);
}

From source file:android.support.v7.view.menu.CascadingMenuPopup.java

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_MENU) {
        dismiss();/*from   ww  w .j  a v  a  2 s  .  co m*/
        return true;
    }
    return false;
}

From source file:de.vanita5.twittnuker.activity.support.HomeActivity.java

@Override
public boolean onKeyUp(final int keyCode, final KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU: {
        if (mSlidingMenu != null) {
            mSlidingMenu.toggle(true);/*from  w  w w . ja  v a2  s  .  com*/
            return true;
        }
        break;
    }
    default: {
        if (mHotKeyHandler.handleKey(keyCode, event))
            return true;
    }
    }
    return super.onKeyUp(keyCode, event);
}

From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java

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

        if (mSlidingView.isHidden() == false) {
            mSlidingView.hideSlide();/*  www  . ja  v  a 2 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.mAlbumsPosition;
                break;
            case MediaUtils.TYPE_ARTIST:
                mPagerAdapter.clearLimiter(MediaUtils.TYPE_ARTIST);
                pos = mPagerAdapter.mArtistsPosition;
                break;
            case MediaUtils.TYPE_GENRE:
                mPagerAdapter.clearLimiter(MediaUtils.TYPE_GENRE);
                pos = mPagerAdapter.mGenresPosition;
                break;
            case MediaUtils.TYPE_FILE:
                if (limiter.names.length > 1) {
                    File parentFile = ((File) limiter.data).getParentFile();
                    mPagerAdapter.setLimiter(FileSystemAdapter.buildLimiter(parentFile));
                } else {
                    mPagerAdapter.clearLimiter(MediaUtils.TYPE_FILE);
                }
                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;
    default:
        return false;
    }

    return true;
}