List of usage examples for android.view MenuItem setVisible
public MenuItem setVisible(boolean visible);
From source file:com.filemanager.free.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem s = menu.findItem(R.id.view); MenuItem search = menu.findItem(R.id.search); MenuItem paste = menu.findItem(R.id.paste); String f = null;/*from www. ja v a 2s . com*/ Fragment fragment; try { fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame); f = fragment.getClass().getName(); } catch (Exception e1) { return true; } if (f.contains("TabFragment")) { setActionBarTitle("File Manager"); if (aBoolean) { s.setTitle(getResources().getString(R.string.gridview)); } else { s.setTitle(getResources().getString(R.string.listview)); } try { TabFragment tabFragment = (TabFragment) fragment; Main ma = ((Main) tabFragment.getTab()); if (ma.IS_LIST) s.setTitle(R.string.gridview); else s.setTitle(R.string.listview); updatePath(ma.CURRENT_PATH, ma.results, ma.openMode, ma.folder_count, ma.file_count); } catch (Exception ignored) { } initiatebbar(); if (Build.VERSION.SDK_INT >= 21) toolbar.setElevation(0); invalidatePasteButton(paste); search.setVisible(true); if (indicator_layout != null) indicator_layout.setVisibility(View.VISIBLE); menu.findItem(R.id.search).setVisible(true); menu.findItem(R.id.home).setVisible(true); menu.findItem(R.id.history).setVisible(true); menu.findItem(R.id.sethome).setVisible(true); menu.findItem(R.id.item10).setVisible(true); if (showHidden) menu.findItem(R.id.hiddenitems).setVisible(true); menu.findItem(R.id.view).setVisible(true); menu.findItem(R.id.extract).setVisible(false); invalidatePasteButton(menu.findItem(R.id.paste)); findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE); } else if (f.contains("AppsList") || f.contains("ProcessViewer")) { appBarLayout.setExpanded(true); menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); findViewById(R.id.buttonbarframe).setVisibility(View.GONE); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.extract).setVisible(false); if (f.contains("ProcessViewer")) menu.findItem(R.id.item10).setVisible(false); else { menu.findItem(R.id.dsort).setVisible(false); menu.findItem(R.id.sortby).setVisible(false); } menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); } else if (f.contains("ZipViewer")) { menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); TextView textView = (TextView) mainActivity.pathbar.findViewById(R.id.fullpath); pathbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.item10).setVisible(false); menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); menu.findItem(R.id.extract).setVisible(true); } return super.onPrepareOptionsMenu(menu); }
From source file:com.android.contacts.activities.ContactDetailActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { final MenuItem starredMenuItem = menu.findItem(R.id.menu_star); /*//from w w w . j a v a 2 s . com * Bug Fix by Mediatek Begin. * Original Android's code: starredMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { // Toggle "starred" state // Make sure there is a contact if (mLookupUri != null) { // Read the current starred value from the UI instead of using the last // loaded state. This allows rapid tapping without writing the same // value several times final boolean isStarred = starredMenuItem.isChecked(); // To improve responsiveness, swap out the picture (and tag) in the UI already ContactDetailDisplayUtils.configureStarredMenuItem(starredMenuItem, mContactData.isDirectoryEntry(), mContactData.isUserProfile(), !isStarred); // Now perform the real save Intent intent = ContactSaveService.createSetStarredIntent( ContactDetailActivity.this, mLookupUri, !isStarred); ContactDetailActivity.this.startService(intent); } return true; } }); // If there is contact data, update the starred state if (mContactData != null) { ContactDetailDisplayUtils.configureStarredMenuItem(starredMenuItem, mContactData.isDirectoryEntry(), mContactData.isUserProfile(), mContactData.getStarred()); } * CR ID: ALPS00115684 */ if (this.mContactData != null && this.mContactData.getIndicate() < 0) { starredMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { // Toggle "starred" state // Make sure there is a contact if (mLookupUri != null) { // Read the current starred value from the UI instead of using the last // loaded state. This allows rapid tapping without writing the same // value several times final boolean isStarred = starredMenuItem.isChecked(); // To improve responsiveness, swap out the picture (and tag) in the UI already ContactDetailDisplayUtils.configureStarredMenuItem(starredMenuItem, mContactData.isDirectoryEntry(), mContactData.isUserProfile(), !isStarred); // Now perform the real save Intent intent = ContactSaveService.createSetStarredIntent(ContactDetailActivity.this, mLookupUri, !isStarred); ContactDetailActivity.this.startService(intent); } return true; } }); ContactDetailDisplayUtils.configureStarredMenuItem(starredMenuItem, mContactData.isDirectoryEntry(), mContactData.isUserProfile(), mContactData.getStarred()); } else { Log.i(TAG, "it is sim contact"); starredMenuItem.setVisible(false); } /* * Bug Fix by Mediatek End. */ /* * New Feature by Mediatek Begin. set this if show new association menu */ setAssociationMenu(menu, true); /* * New Feature by Mediatek End. */ return true; }
From source file:com.igniva.filemanager.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem s = menu.findItem(R.id.view); MenuItem search = menu.findItem(R.id.search); MenuItem paste = menu.findItem(R.id.paste); String f = null;//from ww w .j ava 2 s. c o m Fragment fragment; try { fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame); f = fragment.getClass().getName(); } catch (Exception e1) { return true; } if (f.contains("TabFragment")) { setActionBarTitle("Filemanager"); if (aBoolean) { s.setTitle(getResources().getString(R.string.gridview)); } else { s.setTitle(getResources().getString(R.string.listview)); } try { TabFragment tabFragment = (TabFragment) fragment; Main ma = ((Main) tabFragment.getTab()); if (ma.IS_LIST) s.setTitle(R.string.gridview); else s.setTitle(R.string.listview); updatePath(ma.CURRENT_PATH, ma.results, ma.openMode, ma.folder_count, ma.file_count); } catch (Exception e) { } initiatebbar(); if (Build.VERSION.SDK_INT >= 21) toolbar.setElevation(0); invalidatePasteButton(paste); search.setVisible(true); if (indicator_layout != null) indicator_layout.setVisibility(View.VISIBLE); menu.findItem(R.id.search).setVisible(true); menu.findItem(R.id.home).setVisible(true); menu.findItem(R.id.history).setVisible(true); menu.findItem(R.id.sethome).setVisible(true); menu.findItem(R.id.item10).setVisible(true); if (showHidden) menu.findItem(R.id.hiddenitems).setVisible(true); menu.findItem(R.id.view).setVisible(true); menu.findItem(R.id.extract).setVisible(false); invalidatePasteButton(menu.findItem(R.id.paste)); findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE); } else if (f.contains("AppsList") || f.contains("ProcessViewer") || f.contains(FTPServerFragment.class.getName())) { appBarLayout.setExpanded(true); menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); findViewById(R.id.buttonbarframe).setVisibility(View.GONE); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.extract).setVisible(false); if (f.contains("ProcessViewer")) menu.findItem(R.id.item10).setVisible(false); else { menu.findItem(R.id.dsort).setVisible(false); menu.findItem(R.id.sortby).setVisible(false); } menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); } else if (f.contains("ZipViewer")) { menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); TextView textView = (TextView) mainActivity.pathbar.findViewById(R.id.fullpath); pathbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.item10).setVisible(false); menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); menu.findItem(R.id.extract).setVisible(true); } return super.onPrepareOptionsMenu(menu); }
From source file:com.amaze.filemanager.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem s = menu.findItem(R.id.view); MenuItem search = menu.findItem(R.id.search); MenuItem paste = menu.findItem(R.id.paste); String f = null;/* ww w . j av a 2 s .c om*/ Fragment fragment; try { fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame); f = fragment.getClass().getName(); } catch (Exception e1) { return true; } if (f.contains("TabFragment")) { setActionBarTitle("Amaze"); if (aBoolean) { s.setTitle(getResources().getString(R.string.gridview)); } else { s.setTitle(getResources().getString(R.string.listview)); } try { TabFragment tabFragment = (TabFragment) fragment; Main ma = ((Main) tabFragment.getTab()); if (ma.IS_LIST) s.setTitle(R.string.gridview); else s.setTitle(R.string.listview); updatePath(ma.CURRENT_PATH, ma.results, ma.openMode, ma.folder_count, ma.file_count); } catch (Exception e) { } initiatebbar(); if (Build.VERSION.SDK_INT >= 21) toolbar.setElevation(0); invalidatePasteButton(paste); search.setVisible(true); if (indicator_layout != null) indicator_layout.setVisibility(View.VISIBLE); menu.findItem(R.id.search).setVisible(true); menu.findItem(R.id.home).setVisible(true); menu.findItem(R.id.history).setVisible(true); menu.findItem(R.id.sethome).setVisible(true); menu.findItem(R.id.item10).setVisible(true); if (showHidden) menu.findItem(R.id.hiddenitems).setVisible(true); menu.findItem(R.id.view).setVisible(true); menu.findItem(R.id.extract).setVisible(false); invalidatePasteButton(menu.findItem(R.id.paste)); findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE); } else if (f.contains("AppsList") || f.contains("ProcessViewer")) { appBarLayout.setExpanded(true); menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); findViewById(R.id.buttonbarframe).setVisibility(View.GONE); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.extract).setVisible(false); if (f.contains("ProcessViewer")) menu.findItem(R.id.item10).setVisible(false); else { menu.findItem(R.id.dsort).setVisible(false); menu.findItem(R.id.sortby).setVisible(false); } menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); } else if (f.contains("ZipViewer")) { menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); TextView textView = (TextView) mainActivity.pathbar.findViewById(R.id.fullpath); pathbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.item10).setVisible(false); menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); menu.findItem(R.id.extract).setVisible(true); } return super.onPrepareOptionsMenu(menu); }
From source file:com.android.mail.compose.ComposeActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { final boolean superCreated = super.onCreateOptionsMenu(menu); // Don't render any menu items when there are no accounts. if (mAccounts == null || mAccounts.length == 0) { return superCreated; }//from w w w. ja v a2 s. c o m MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.compose_menu, menu); /* * Start save in the correct enabled state. * 1) If a user launches compose from within gmail, save is disabled * until they add something, at which point, save is enabled, auto save * on exit; if the user empties everything, save is disabled, exiting does not * auto-save * 2) if a user replies/ reply all/ forwards from within gmail, save is * disabled until they change something, at which point, save is * enabled, auto save on exit; if the user empties everything, save is * disabled, exiting does not auto-save. * 3) If a user launches compose from another application and something * gets populated (attachments, recipients, body, subject, etc), save is * enabled, auto save on exit; if the user empties everything, save is * disabled, exiting does not auto-save */ mSave = menu.findItem(R.id.save); String action = getIntent() != null ? getIntent().getAction() : null; enableSave(mInnerSavedState != null ? mInnerSavedState.getBoolean(EXTRA_SAVE_ENABLED) : (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action) || Intent.ACTION_SENDTO.equals(action) || isDraftDirty())); final MenuItem helpItem = menu.findItem(R.id.help_info_menu_item); final MenuItem sendFeedbackItem = menu.findItem(R.id.feedback_menu_item); final MenuItem attachFromServiceItem = menu.findItem(R.id.attach_from_service_stub1); if (helpItem != null) { helpItem.setVisible(mAccount != null && mAccount.supportsCapability(AccountCapabilities.HELP_CONTENT)); } if (sendFeedbackItem != null) { sendFeedbackItem .setVisible(mAccount != null && mAccount.supportsCapability(AccountCapabilities.SEND_FEEDBACK)); } if (attachFromServiceItem != null) { attachFromServiceItem.setVisible(shouldEnableAttachFromServiceMenu(mAccount)); } // Show attach picture on pre-K devices. menu.findItem(R.id.add_photo_attachment).setVisible(!Utils.isRunningKitkatOrLater()); return true; }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
private void handleMoreMenu(Menu menu, boolean forceFromToolbar, int max) { if (forceFromToolbar || (menu.size() > max && Build.VERSION.SDK_INT > 13 && getWindowWidth() < 700)) { MenuItem more = menu.findItem(R.id.menu_more); if (more != null) { SubMenu moreSub = more.getSubMenu(); if (moreSub != null) { for (int i = Math.max(0, max - 1); i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.getItemId() == R.id.menu_more) continue; MenuItem ni = MenuUtils.transferMenu(item, moreSub); if (ni == null) continue; ni.setAlphabeticShortcut((char) ('a' + i)); item.setVisible(false); }//from w w w . j a va2 s.c om MenuUtils.scanMenuShortcuts(moreSub); } } } else MenuUtils.setMenuVisible(menu, false, R.id.menu_more); }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem s = menu.findItem(R.id.view); MenuItem search = menu.findItem(R.id.search); MenuItem paste = menu.findItem(R.id.paste); String fragmentName;//ww w.j a va2 s . c om Fragment fragment; try { fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame); fragmentName = fragment.getClass().getName(); } catch (Exception e) { return true; } if (fragmentName.contains("TabFragment")) { setActionBarTitle("Amaze"); if (useGridView) { s.setTitle(getResources().getString(R.string.gridview)); } else { s.setTitle(getResources().getString(R.string.listview)); } try { TabFragment tabFragment = (TabFragment) fragment; MainFragment ma = ((MainFragment) tabFragment.getTab()); if (ma.IS_LIST) s.setTitle(R.string.gridview); else s.setTitle(R.string.listview); updatePath(ma.CURRENT_PATH, ma.results, ma.openMode, ma.folder_count, ma.file_count); } catch (Exception e) { } initiatebbar(); if (SDK_INT >= 21) toolbar.setElevation(0); invalidatePasteButton(paste); search.setVisible(true); if (indicator_layout != null) indicator_layout.setVisibility(View.VISIBLE); menu.findItem(R.id.search).setVisible(true); menu.findItem(R.id.home).setVisible(true); menu.findItem(R.id.history).setVisible(true); menu.findItem(R.id.sethome).setVisible(true); menu.findItem(R.id.sort).setVisible(true); if (showHidden) menu.findItem(R.id.hiddenitems).setVisible(true); menu.findItem(R.id.view).setVisible(true); menu.findItem(R.id.extract).setVisible(false); invalidatePasteButton(menu.findItem(R.id.paste)); findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE); } else if (fragmentName.contains("AppsList") || fragmentName.contains("ProcessViewer") || fragmentName.contains(FTPServerFragment.class.getName())) { appBarLayout.setExpanded(true); menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); findViewById(R.id.buttonbarframe).setVisibility(View.GONE); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.extract).setVisible(false); if (fragmentName.contains("ProcessViewer")) menu.findItem(R.id.sort).setVisible(false); else { menu.findItem(R.id.dsort).setVisible(false); menu.findItem(R.id.sortby).setVisible(false); } menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); } else if (fragmentName.contains("ZipViewer")) { menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); TextView textView = (TextView) mainActivity.pathbar.findViewById(R.id.fullpath); pathbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.sort).setVisible(false); menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); menu.findItem(R.id.extract).setVisible(true); } return super.onPrepareOptionsMenu(menu); }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { mMenu = menu;/*w w w . java 2 s .c om*/ MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); SharedPreferences defaultprefs = PreferenceManager.getDefaultSharedPreferences(mContext); boolean layouttables = defaultprefs.getBoolean("arrange_tables", false); if (layouttables) { MenuItem tables = mMenu.findItem(R.id.layouttables); if (!tables.isVisible()) { tables.setVisible(true); invalidateOptionsMenu(); } MenuItem mesas = mMenu.findItem(R.id.menu_show_tables); if (!mesas.isVisible()) { mesas.setVisible(true); invalidateOptionsMenu(); } } return true; }
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { UrlPageModel model;/*from w w w .j a v a 2 s. c o m*/ switch (item.getItemId()) { case R.id.menu_add_post: openPostForm(tabModel.hash, presentationModel.source.boardModel, getSendPostModel()); return true; case R.id.menu_update: if (tabModel.type == TabModel.TYPE_LOCAL) { openFromChan(); } else { update(); } return true; case R.id.menu_catalog: model = new UrlPageModel(); model.chanName = chan.getChanName(); model.type = UrlPageModel.TYPE_CATALOGPAGE; model.boardName = tabModel.pageModel.boardName; UrlHandler.open(model, activity); return true; case R.id.menu_search: initSearchBar(); searchBarView.setVisibility(View.VISIBLE); ((EditText) searchBarView.findViewById(R.id.board_search_field)).requestFocus(); return true; case R.id.menu_save_page: saveThisPage(); return true; case R.id.menu_board_gallery: openGridGallery(); return true; case R.id.menu_quickaccess_add: QuickAccess.Entry newEntry = new QuickAccess.Entry(); newEntry.chan = chan; newEntry.boardName = presentationModel.source.boardModel.boardName; newEntry.boardDescription = presentationModel.source.boardModel.boardDescription; List<QuickAccess.Entry> quickaccessList = QuickAccess.getQuickAccessFromPreferences(); quickaccessList.add(0, newEntry); QuickAccess.saveQuickAccessToPreferences(quickaccessList); enableQuickAccessMenu = Boolean.FALSE; item.setVisible(false); return true; } return super.onOptionsItemSelected(item); }