List of usage examples for android.view KeyEvent KEYCODE_MENU
int KEYCODE_MENU
To view the source code for android.view KeyEvent KEYCODE_MENU.
Click Source Link
From source file:de.theknut.xposedgelsettings.ui.MainActivity.java
@SuppressWarnings("deprecation") @Override//w w w.j a va 2 s. co m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mContext = CommonUI.CONTEXT = mActivity = CommonUI.ACTIVITY = this; if (getSharedPreferences(Common.PREFERENCES_NAME, Context.MODE_WORLD_READABLE) .getBoolean("forceenglishlocale", false)) { Resources res = mContext.getResources(); Configuration conf = res.getConfiguration(); conf.locale = new Locale(Locale.US.getDisplayLanguage().toLowerCase()); res.updateConfiguration(conf, res.getDisplayMetrics()); } mTitle = mDrawerTitle = getTitle(); mFragmentTitles = getResources().getStringArray(R.array.fragmenttitles_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerLayout.getRootView().setBackgroundColor(CommonUI.UIColor); getActionBar().setBackgroundDrawable(new ColorDrawable(CommonUI.UIColor)); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mFragmentTitles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerLayout.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getRepeatCount() != 0) return false; if (!mDrawerLayout.isDrawerOpen(Gravity.LEFT)) { if ((keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) { mDrawerLayout.openDrawer(Gravity.LEFT); return true; } } else { if (keyCode == KeyEvent.KEYCODE_BACK) { MainActivity.this.finish(); return true; } else if (keyCode == KeyEvent.KEYCODE_MENU) { mDrawerLayout.closeDrawer(Gravity.LEFT); return true; } } return false; } }); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); getActionBar().setBackgroundDrawable(new ColorDrawable(CommonUI.UIColor)); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); SharedPreferences prefs = getSharedPreferences(Common.PREFERENCES_NAME, Context.MODE_WORLD_READABLE); CommonUI.NO_BACKGROUND_IMAGE = prefs.getBoolean("nobackgroundimage", false); CommonUI.AUTO_BLUR_IMAGE = prefs.getBoolean("autoblurimage", false); if (savedInstanceState == null) { Intent i = getIntent(); if (i != null && i.hasExtra("fragment")) { if (i.getStringExtra("fragment").equals("badges")) { selectItem(6); } } else { selectItem(0); } } }
From source file:us.nineworlds.serenity.ui.browser.tv.TVShowBrowserActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { SerenityGallery gallery = (SerenityGallery) findViewById(R.id.tvShowBannerGallery); boolean menuKeySlidingMenu = preferences.getBoolean("remote_control_menu", true); if (menuKeySlidingMenu) { if (keyCode == KeyEvent.KEYCODE_MENU) { if (drawerLayout.isDrawerOpen(linearDrawerLayout)) { drawerLayout.closeDrawers(); } else { drawerLayout.openDrawer(linearDrawerLayout); }// w w w . j av a 2 s . c o m return true; } } if (keyCode == KeyEvent.KEYCODE_BACK && drawerLayout.isDrawerOpen(linearDrawerLayout)) { drawerLayout.closeDrawers(); if (gallery != null) { gallery.requestFocusFromTouch(); } return true; } if (gallery == null) { return super.onKeyDown(keyCode, event); } AbstractPosterImageGalleryAdapter adapter = (AbstractPosterImageGalleryAdapter) gallery.getAdapter(); if (adapter != null) { int itemsCount = adapter.getCount(); if (contextMenuRequested(keyCode)) { View view = gallery.getSelectedView(); view.performLongClick(); return true; } if (isKeyCodeSkipBack(keyCode)) { int selectedItem = gallery.getSelectedItemPosition(); int newPosition = selectedItem - 10; if (newPosition < 0) { newPosition = 0; } gallery.setSelection(newPosition); gallery.requestFocusFromTouch(); return true; } if (isKeyCodeSkipForward(keyCode)) { int selectedItem = gallery.getSelectedItemPosition(); int newPosition = selectedItem + 10; if (newPosition > itemsCount) { newPosition = itemsCount - 1; } gallery.setSelection(newPosition); gallery.requestFocusFromTouch(); return true; } if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY || keyCode == KeyEvent.KEYCODE_BUTTON_R1) { SeriesContentInfo info = (SeriesContentInfo) gallery.getSelectedItem(); new FindUnwatchedAsyncTask(this).execute(info); return true; } } return super.onKeyDown(keyCode, event); }
From source file:us.nineworlds.serenity.ui.browser.tv.episodes.EpisodeBrowserActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { boolean menuKeySlidingMenu = prefs.getBoolean("remote_control_menu", true); if (menuKeySlidingMenu) { if (keyCode == KeyEvent.KEYCODE_MENU) { if (drawerLayout.isDrawerOpen(linearDrawerLayout)) { drawerLayout.closeDrawers(); } else { drawerLayout.openDrawer(linearDrawerLayout); }/*from ww w .j a v a2 s . c om*/ return true; } } if (keyCode == KeyEvent.KEYCODE_BACK && drawerLayout.isDrawerOpen(linearDrawerLayout)) { drawerLayout.closeDrawers(); View gallery = findViewById(R.id.moviePosterGallery); if (gallery != null) { gallery.requestFocusFromTouch(); } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.justplay1.shoppist.features.lists.MainActivity.java
@Override public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { if (!menuDrawer.isDrawerOpen(GravityCompat.START)) { menuDrawer.openDrawer(GravityCompat.START); } else {/*from ww w .j a v a 2 s . c o m*/ menuDrawer.closeDrawer(GravityCompat.START); } return true; } return super.onKeyUp(keyCode, event); }
From source file:com.mifos.mifosxdroid.tests.ClientChargesTest.java
/** * open charges fragment then choose the "new" options menu item */// w w w . j a va2 s . c o m private void openCreateNewCharge() throws InterruptedException { openCharges(); Thread.sleep(2000); ClientChargeFragment clientChargeFragment = (ClientChargeFragment) activity.getSupportFragmentManager() .findFragmentById(R.id.container); getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_MENU); chooseOptionItem(clientChargeFragment, ClientChargeFragment.MENU_ITEM_ADD_NEW_CHARGES); }
From source file:im.neon.activity.MXCActionBarActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_MENU) && (null == getSupportActionBar())) { // This is to fix a bug in the v7 support lib. If there is no options menu and you hit MENU, it will crash with a // NPE @ android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:274) // This can safely be removed if we add in menu options on this screen return true; }// ww w .j av a2 s .c o m return super.onKeyDown(keyCode, event); }
From source file:com.decad3nce.aegis.AegisActivity.java
@Override public boolean onKeyUp(int keycode, KeyEvent e) { switch (keycode) { case KeyEvent.KEYCODE_MENU: fullMenu.performIdentifierAction(R.id.full_menu_settings, 0); return true; }/*from ww w . ja v a2 s. c o m*/ return super.onKeyUp(keycode, e); }
From source file:id.ac.ui.cs.scele.mobile.activity.BaseNavigationActivity.java
/** * Overriding menu key press to show left navigation menu. All other menu * related functions like onPrepareOptionsMenuare, onCreateOptionsMenu are * also called once when the Activity is created. So, we are taking this * approach./*from w w w. j av a 2 s. co m*/ */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { if (!mDrawerLayout.isDrawerOpen(GravityCompat.START)) mDrawerLayout.openDrawer(Gravity.LEFT); else mDrawerLayout.closeDrawer(Gravity.LEFT); return true; } return super.onKeyDown(keyCode, event); }
From source file:us.nineworlds.serenity.ui.browser.movie.MovieBrowserActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { boolean menuKeySlidingMenu = prefs.getBoolean("remote_control_menu", true); if (menuKeySlidingMenu) { if (keyCode == KeyEvent.KEYCODE_MENU) { if (drawerLayout.isDrawerOpen(linearDrawerLayout)) { drawerLayout.closeDrawers(); } else { drawerLayout.openDrawer(linearDrawerLayout); }//from w w w .j av a 2 s . c o m return true; } } if (keyCode == KeyEvent.KEYCODE_BACK && drawerLayout.isDrawerOpen(linearDrawerLayout)) { drawerLayout.closeDrawers(); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.stj.fileexplorer.FileExplorerTabActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (mActionMode != null && isUiFocusable(mActionMode)) { return true; }//from w w w .j a va 2 s.co m invalidateOptionsMenu(); if (keyCode == KeyEvent.KEYCODE_MENU) { IMenuPressedListener menuPressedListener = (IMenuPressedListener) mTabsAdapter .getItem(mViewPager.getCurrentItem()); if (menuPressedListener.onMenuPressed()) { return true; } } else if (keyCode == KeyEvent.KEYCODE_BACK) { onRightKeyPress(); } return super.onKeyDown(keyCode, event); }