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:xyz.klinker.blur.launcher3.Launcher.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        // Ignore the menu key if we are currently dragging or are on the custom content screen
        if (!isOnCustomContent() && !mDragController.isDragging()) {
            // Close any open folders
            closeFolder();/* ww  w  .j ava 2  s  . co  m*/

            // Stop resizing any widgets
            mWorkspace.exitWidgetResizeMode();

            // Show the overview mode if we are on the workspace
            if (mState == State.WORKSPACE && !mWorkspace.isInOverviewMode() && !mWorkspace.isSwitchingState()) {
                mOverviewPanel.requestFocus();
                showOverviewMode(true, true /* requestButtonFocus */);
            }
        }
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.gelakinetic.mtgfam.FamiliarActivity.java

/**
 * Called when a key down event has occurred. Checks if the fragment should handle the key event or if the
 * activity should//from  w  ww.j a v  a 2s  .c  o  m
 *
 * @param keyCode The key type for the event. We only care about KEYCODE_SEARCH
 * @param event   description of the key event
 * @return True if the event was handled, false if otherwise
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        Fragment f = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
        /* Check to see if the current fragment did anything with the search key */
        return ((FamiliarFragment) f).onInterceptSearchKey() || super.onKeyDown(keyCode, event);
    }
    /* Dinky workaround for LG phones: https://code.google.com/p/android/issues/detail?id=78154 */
    else if ((keyCode == KeyEvent.KEYCODE_MENU) /* &&
                                                (Build.VERSION.SDK_INT == 16) &&
                                                (Build.MANUFACTURER.compareTo("LGE") == 0) */) {
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.gelakinetic.mtgfam.FamiliarActivity.java

/**
 * Called when a key was released and not handled by any of the views inside of the activity.
 * So, for example, key presses while the cursor is inside a TextView will not trigger the event
 * (unless it is a navigation to another object) because TextView handles its own key presses.
 * The default implementation handles KEYCODE_BACK to stop the activity and go back.
 * This has a dinky workaround for LG phones
 *
 * @param keyCode The value in event.getKeyCode().
 * @param event   Description of the key event.
 * @return If you handled the event, return true. If you want to allow the event to be handled
 * by the next receiver, return false./*from  w  w w . j  ava 2  s .  com*/
 */
@Override
public boolean onKeyUp(int keyCode, @NotNull KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        if (toolbar != null) {
            if (toolbar.isOverflowMenuShowing()) {
                toolbar.dismissPopupMenus();
            } else {
                toolbar.showOverflowMenu();
            }
        }
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.aimfire.demo.CamcorderActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    //if((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || 
    //(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) || 
    //(keyCode == KeyEvent.KEYCODE_CAMERA))
    if (keyCode == KeyEvent.KEYCODE_CAMERA) {
        clickToggleRecording(null);//  ww  w  .j a v a 2 s.c  o m
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MENU) {
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:dev.ukanth.ufirewall.MainActivity.java

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

    if (event.getAction() == KeyEvent.ACTION_UP) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_MENU:
            if (mainMenu != null) {
                mainMenu.performIdentifierAction(R.id.menu_list_item, 0);
                return true;
            }/*from   w ww. j  a  v  a 2s  .  c  o  m*/
            break;
        case KeyEvent.KEYCODE_BACK:
            if (isDirty()) {
                new MaterialDialog.Builder(this).title(R.string.confirmation).cancelable(false)
                        .content(R.string.unsaved_changes_message).positiveText(R.string.apply)
                        .negativeText(R.string.discard).callback(new MaterialDialog.ButtonCallback() {
                            @Override
                            public void onPositive(MaterialDialog dialog) {
                                applyOrSaveRules();
                                dialog.dismiss();
                            }

                            @Override
                            public void onNegative(MaterialDialog dialog) {
                                setDirty(false);
                                Api.applications = null;
                                finish();
                                System.exit(0);
                                //force reload rules.
                                MainActivity.super.onKeyDown(keyCode, event);
                                dialog.dismiss();
                            }
                        }).show();
                return true;

            } else {
                setDirty(false);
                finish();
                System.exit(0);
            }

        }
    }
    return super.onKeyUp(keyCode, event);
}

From source file:org.linphone.LinphoneActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (currentFragment == FragmentsAvailable.SETTINGS) {
            //dialer.setVisibility(View.GONE);
            settings.setVisibility(View.VISIBLE);
            //mCall.setVisibility(View.VISIBLE);
        }/*from  ww w.j  ava  2 s. c o  m*/
        if (currentFragment == FragmentsAvailable.DIALER || currentFragment == FragmentsAvailable.CONTACTS
                || currentFragment == FragmentsAvailable.HISTORY
                || currentFragment == FragmentsAvailable.CHATLIST
                || currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
                || currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS) {
            boolean isBackgroundModeActive = LinphonePreferences.instance().isBackgroundModeEnabled();
            if (!isBackgroundModeActive) {
                stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
                finish();
            } else if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) {
                return true;
            }
        } else {
            if (isTablet()) {
                if (currentFragment == FragmentsAvailable.SETTINGS) {
                    updateAnimationsState();
                }
            }
        }
    } else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
        if (event.getRepeatCount() < 1) {
            statusFragment.openOrCloseStatusBar(true);
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.android.launcher3.Launcher.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        // Ignore the menu key if we are currently dragging or are on the custom content screen
        if (!isOnCustomContent() && !mDragController.isDragging()) {
            // Close any open folders
            closeFolder();// w ww .j a v a2  s  . c o m

            // Close any shortcuts containers
            closeShortcutsContainer();

            // Stop resizing any widgets
            mWorkspace.exitWidgetResizeMode();

            // Show the overview mode if we are on the workspace
            if (mState == State.WORKSPACE && !mWorkspace.isInOverviewMode() && !mWorkspace.isSwitchingState()) {
                mOverviewPanel.requestFocus();
                showOverviewMode(true, true /* requestButtonFocus */);
            }
        }
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        /*//  ww  w  .j a v a  2 s.  com
        ImageView ib = (ImageView) findViewById(R.id.action_overflow);
        if (ib.getVisibility() == View.VISIBLE) {
        ib.performClick();
        }
        */
        // return 'true' to prevent further propagation of the key event
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.sim2dial.dialer.LinphoneActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (currentFragment == FragmentsAvailable.DIALER) {
            boolean isBackgroundModeActive = Engine.getPref().getBoolean(
                    getString(R.string.pref_background_mode_key),
                    getResources().getBoolean(R.bool.pref_background_mode_default));
            if (!isBackgroundModeActive) {
                stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
                finish();//from www .ja v  a2 s .co m
            } else if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) {
                return true;
            }
        } else if (!isTablet()) {
            int backStackEntryCount = getSupportFragmentManager().getBackStackEntryCount();
            if (backStackEntryCount <= 1) {
                showStatusBar();
                // hideStatusBar();
            }

            if (currentFragment == FragmentsAvailable.SETTINGS) {
                // showStatusBar();
                hideStatusBar();
                reloadConfig();
                updateAnimationsState();
            }
        }
    } else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
        if (event.getRepeatCount() < 1) {
            // statusFragment.openOrCloseStatusBar(true);

        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.youku.player.base.YoukuBasePlayerActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    try {//  w  ww  .  j  a  va  2 s  . c  o  m
        switch (keyCode) {
        case KeyEvent.KEYCODE_MENU:
            // ?menu?
            if (event.getRepeatCount() > 0) {
                return true;
            }
            return mediaPlayerDelegate.isFullScreen;
        case KeyEvent.KEYCODE_BACK:
            // ???
            if (event.getRepeatCount() > 0) {
                return true;
            }
            if (!mediaPlayerDelegate.isDLNA) {
                if (mediaPlayerDelegate.isFullScreen && !isFromLocal()
                        && (mediaPlayerDelegate.videoInfo != null && !mediaPlayerDelegate.videoInfo.isHLS)) {
                    goSmall();
                    return true;
                } else {
                    onkeyback();
                    return true;
                }
            } else {
                return true;
            }
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            return volumeDown();
        case KeyEvent.KEYCODE_VOLUME_UP:
            return volumeUp();
        case KeyEvent.KEYCODE_SEARCH:
            return mediaPlayerDelegate.isFullScreen;
        case 125:
            /** popupwindow */
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return super.onKeyDown(keyCode, event);
}