List of usage examples for android.view MenuItem setVisible
public MenuItem setVisible(boolean visible);
From source file:org.apps8os.motivator.ui.MoodHistoryActivity.java
/** * Loading different view when orientation is portrait or landscape. */// ww w . j ava 2 s. co m @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Selecting the different attributes in the week view, not visible in portrait day view. if (mMenu != null) { MenuItem selectAttribute = mMenu.findItem(R.id.mood_history_select_attribute); if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { loadPortraitView(); selectAttribute.setVisible(false); } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { loadLandscapeView(); selectAttribute.setVisible(true); new ShowcaseView.Builder(this, true) .setTarget(new ActionItemTarget(this, R.id.mood_history_select_attribute)) .setContentTitle("Tlt voit valita mit kuvaajassa nytetn") .setContentText("Klikkaamalla tst voit vaihtaa mit kuvaajassa nytetn.") .hideOnTouchOutside().setStyle(R.style.ShowcaseView).singleShot(SELECT_ATTRIBUTE_HELP_ID) .build(); } } }
From source file:com.fastaccess.ui.modules.repos.RepoPagerActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { Repo repoModel = getPresenter().getRepo(); if (repoModel != null && repoModel.isFork() && repoModel.getParent() != null) { MenuItem menuItem = menu.findItem(R.id.originalRepo); menuItem.setVisible(true); menuItem.setTitle(repoModel.getParent().getFullName()); }/*www. j a va 2 s .c om*/ // menu.findItem(R.id.deleteRepo).setVisible(getPresenter().isRepoOwner()); if (menu.findItem(R.id.deleteRepo) != null) menu.findItem(R.id.deleteRepo).setVisible(false);//removing delete permission. return super.onPrepareOptionsMenu(menu); }
From source file:com.fa.mastodon.activity.AccountActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (!isSelf) { MenuItem follow = menu.findItem(R.id.action_follow); follow.setTitle(getFollowAction()); follow.setVisible(followState != FollowState.REQUESTED); MenuItem block = menu.findItem(R.id.action_block); String title;// ww w . ja v a2 s . c om if (blocking) { title = getString(R.string.action_unblock); } else { title = getString(R.string.action_block); } block.setTitle(title); MenuItem mute = menu.findItem(R.id.action_mute); if (muting) { title = getString(R.string.action_unmute); } else { title = getString(R.string.action_mute); } mute.setTitle(title); } else { // It shouldn't be possible to block or follow yourself. menu.removeItem(R.id.action_follow); menu.removeItem(R.id.action_block); menu.removeItem(R.id.action_mute); } return super.onPrepareOptionsMenu(menu); }
From source file:net.kourlas.voipms_sms.activities.ConversationActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.conversation, menu); this.menu = menu; if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { MenuItem phoneMenuItem = menu.findItem(R.id.call_button); phoneMenuItem.setVisible(false); }/*w w w . j a va2 s . com*/ SearchView searchView = (SearchView) menu.findItem(R.id.search_button).getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { adapter.refresh(newText); return true; } }); return super.onCreateOptionsMenu(menu); }
From source file:com.android.contacts.activities.ContactSelectionActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.search_menu, menu); final MenuItem searchItem = menu.findItem(R.id.menu_search); searchItem.setVisible(!mIsSearchMode && mIsSearchSupported); final Drawable searchIcon = searchItem.getIcon(); if (searchIcon != null) { searchIcon.mutate().setColorFilter(ContextCompat.getColor(this, R.color.actionbar_icon_color), PorterDuff.Mode.SRC_ATOP); }/*ww w . java 2 s . c om*/ return true; }
From source file:com.freecast.LudoCast.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); Log.d(TAG, "onCreateOptionsMenu() was called"); getMenuInflater().inflate(R.menu.main, menu); mediaRouteMenuItem = mCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item); mAppConnected = mCastManager.isConnected(); MenuItem actionRestart = menu.findItem(R.id.menu_restart); actionRestart.setVisible(false); //MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item); //MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat // .getActionProvider(mediaRouteMenuItem); // Set the MediaRouteActionProvider selector for device discovery. //mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector); return true;//from w w w. j a v a 2 s. co m }
From source file:org.dmfs.tasks.ViewTaskFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { /*/*from ww w. j a va2s . c om*/ * Don't show any options if we don't have a task to show. */ if (mTaskUri != null) { inflater.inflate(R.menu.view_task_fragment_menu, menu); if (mContentSet != null) { Integer status = TaskFieldAdapters.STATUS.get(mContentSet); if (status != null) { mOldStatus = status; } if (TaskFieldAdapters.IS_CLOSED.get(mContentSet) || status != null && status == Tasks.STATUS_COMPLETED) { // we disable the edit option, because the task is completed and the action button shows the edit option. MenuItem item = menu.findItem(R.id.edit_task); item.setEnabled(false); item.setVisible(false); } // check pinned status if (TaskFieldAdapters.PINNED.get(mContentSet)) { // we disable the edit option, because the task is completed and the action button shows the edit option. MenuItem item = menu.findItem(R.id.pin_task); item.setIcon(R.drawable.ic_pin_off_white_24dp); } else { MenuItem item = menu.findItem(R.id.pin_task); item.setIcon(R.drawable.ic_pin_white_24dp); } } } }
From source file:com.dycode.jepretstory.mediachooser.activity.HomeFragmentActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_home, menu); MenuItem cameraItem = menu.findItem(R.id.menuCamera); if (!MediaChooserConstants.showCameraVideo) { cameraItem.setVisible(false); }/*from ww w .j av a 2 s . c o m*/ this.mMenu = menu; //init menu states if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { setCurrentMode(MediaType.IMAGE); } else { setCurrentMode(MediaType.VIDEO); } } else { if (MediaChooserConstants.showImage) { setCurrentMode(MediaType.IMAGE); } else { setCurrentMode(MediaType.VIDEO); } } return super.onCreateOptionsMenu(menu); }
From source file:com.dwdesign.tweetings.fragment.BaseStatusesListFragment.java
public void openMenu(View view, ParcelableStatus status) { mPopupMenu = PopupMenu.getInstance(getActivity(), view); mPopupMenu.inflate(R.menu.action_status); final int activated_color = getResources().getColor(R.color.holo_blue_bright); final boolean click_to_open_menu = mPreferences.getBoolean(PREFERENCE_KEY_CLICK_TO_OPEN_MENU, false); final String buffer_authorised = mPreferences.getString(PREFERENCE_KEY_BUFFERAPP_ACCESS_TOKEN, null); final Menu menu = mPopupMenu.getMenu(); final MenuItem itemView = menu.findItem(MENU_VIEW); if (itemView != null) { itemView.setVisible(click_to_open_menu); }// w w w . ja va2 s . c om final MenuItem direct_retweet = menu.findItem(MENU_RETWEET); if (direct_retweet != null) { final Drawable icon = direct_retweet.getIcon().mutate(); direct_retweet.setVisible( (!status.is_protected && status.account_id != status.user_id) || isMyRetweet(status)); if (isMyRetweet(status)) { icon.setColorFilter(activated_color, PorterDuff.Mode.MULTIPLY); direct_retweet.setTitle(R.string.cancel_retweet); } else { icon.clearColorFilter(); direct_retweet.setTitle(R.string.retweet); } } final MenuItem bufferView = menu.findItem(MENU_ADD_TO_BUFFER); if (bufferView != null) { if (buffer_authorised != null && !buffer_authorised.equals("")) { bufferView.setVisible(true); } else { bufferView.setVisible(false); } } setMenuForStatus(getActivity(), menu, status); mPopupMenu.setOnMenuItemClickListener(this); mPopupMenu.show(); }
From source file:com.jaus.albertogiunta.justintrain_oraritreni.journeyFavourites.FavouriteJourneysActivity.java
private void setVisibilityOfProBedge() { if (ProPreferences.isPro(getViewContext()) && menu != null) { MenuItem item = menu.findItem(R.id.label_pro); if (item != null) item.setVisible(true); }//from ww w .j ava2s .c o m }