List of usage examples for android.view MenuItem setVisible
public MenuItem setVisible(boolean visible);
From source file:com.openerp.addons.messages.Message.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_fragment_message, menu); // Associate searchable configuration with the SearchView searchView = (SearchView) menu.findItem(R.id.menu_message_search).getActionView(); Bundle bundle = getArguments();//from w w w.ja v a 2s . c o m if (bundle != null && bundle.containsKey("group_id")) { MenuItem compose = menu.findItem(R.id.menu_message_compose); compose.setVisible(false); } }
From source file:com.cerema.cloud2.ui.fragment.OCFileListFragment.java
private void showFileAction(int fileIndex) { Bundle args = getArguments();//from ww w. ja v a 2 s . co m PopupMenu pm = new PopupMenu(getActivity(), null); Menu menu = pm.getMenu(); boolean allowContextualActions = (args == null) ? true : args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, true); if (allowContextualActions) { MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.file_actions_menu, menu); OCFile targetFile = (OCFile) mAdapter.getItem(fileIndex); if (mContainerActivity.getStorageManager() != null) { FileMenuFilter mf = new FileMenuFilter(targetFile, mContainerActivity.getStorageManager().getAccount(), mContainerActivity, getActivity()); mf.filter(menu); } /// TODO break this direct dependency on FileDisplayActivity... if possible MenuItem item = menu.findItem(R.id.action_open_file_with); FileFragment frag = ((FileDisplayActivity) getActivity()).getSecondFragment(); if (frag != null && frag instanceof FileDetailFragment && frag.getFile().getFileId() == targetFile.getFileId()) { item = menu.findItem(R.id.action_see_details); if (item != null) { item.setVisible(false); item.setEnabled(false); } } FileActionsDialogFragment dialog = FileActionsDialogFragment.newInstance(menu, fileIndex, targetFile.getFileName()); dialog.setTargetFragment(this, 0); dialog.show(getFragmentManager(), FileActionsDialogFragment.FTAG_FILE_ACTIONS); } }
From source file:com.fsm.storybook.launcher.WebViewActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { mOptionsMenu = menu;// ww w.ja va 2 s .co m getMenuInflater().inflate(R.menu.web_view, menu); menu.findItem(R.id.settings).setIcon(R.drawable.setting); menu.findItem(R.id.settings).setVisible(false); menu.findItem(R.id.mo_previous).setIcon(R.drawable.mo_previous); menu.findItem(R.id.mo_next).setIcon(R.drawable.mo_next); menu.findItem(R.id.mo_play).setIcon(R.drawable.mo_play); menu.findItem(R.id.mo_pause).setIcon(R.drawable.mo_pause); MenuItem mo_previous = menu.findItem(R.id.mo_previous); MenuItem mo_next = menu.findItem(R.id.mo_next); MenuItem mo_play = menu.findItem(R.id.mo_play); MenuItem mo_pause = menu.findItem(R.id.mo_pause); mo_previous.setVisible(mIsMoAvailable); mo_next.setVisible(mIsMoAvailable); if (mIsMoAvailable) { mo_play.setVisible(!mIsMoPlaying); mo_pause.setVisible(mIsMoPlaying); } //force buttons to show up /* mo_previous.setVisible(true); mo_next.setVisible(true); mo_play.setVisible(!mIsMoPlaying); mo_pause.setVisible(mIsMoPlaying); */ return true; }
From source file:org.awesomeapp.messenger.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search)); if (mSearchView != null) { mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.setIconifiedByDefault(false); SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { public boolean onQueryTextChange(String query) { mConversationList.doSearch(query); return true; }/*from w ww .jav a 2 s .c o m*/ public boolean onQueryTextSubmit(String query) { mConversationList.doSearch(query); return true; } }; mSearchView.setOnQueryTextListener(queryTextListener); mSearchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { mConversationList.doSearch(null); return false; } }); } MenuItem mItem = menu.findItem(R.id.menu_lock_reset); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); if (!settings.contains(ImApp.PREFERENCE_KEY_TEMP_PASS)) mItem.setVisible(true); return true; }
From source file:com.dwdesign.tweetings.fragment.StatusFragment.java
@SuppressWarnings("deprecation") public void displayStatus(final ParcelableStatus status) { mStatus = null;// w w w. jav a2 s .c o m mImagesPreviewFragment.clear(); if (status == null || getActivity() == null) return; mStatus = status; final String buffer_authorised = mPreferences.getString(PREFERENCE_KEY_BUFFERAPP_ACCESS_TOKEN, null); mMenuBar.inflate(R.menu.menu_status); final MenuItem bufferView = mMenuBar.getMenu().findItem(MENU_ADD_TO_BUFFER); if (bufferView != null) { if (buffer_authorised != null && !buffer_authorised.equals("")) { bufferView.setVisible(true); } else { bufferView.setVisible(false); } } setMenuForStatus(getActivity(), mMenuBar.getMenu(), status); mMenuBar.show(); final boolean is_multiple_account_enabled = getActivatedAccountIds(getActivity()).length > 1; updateUserColor(); mContentScroller .setBackgroundResource(is_multiple_account_enabled ? R.drawable.ic_label_account_nopadding : 0); if (is_multiple_account_enabled) { final Drawable d = mContentScroller.getBackground(); if (d != null) { d.mutate().setColorFilter(getAccountColor(getActivity(), status.account_id), PorterDuff.Mode.MULTIPLY); mContentScroller.invalidate(); } } mNameView.setText(status.name); mScreenNameView.setText("@" + status.screen_name); mScreenNameView.setCompoundDrawablesWithIntrinsicBounds( getUserTypeIconRes(status.is_verified, status.is_protected), 0, 0, 0); mTextView.setText(status.text); final TwidereLinkify linkify = new TwidereLinkify(mTextView); linkify.setOnLinkClickListener(new OnLinkClickHandler(getActivity(), mAccountId)); linkify.addAllLinks(); final boolean is_reply = status.in_reply_to_status_id > 0; final String time = formatToLongTimeString(getActivity(), status.status_timestamp); final String strTime = "<a href=\"https://twitter.com/" + status.screen_name + "/status/" + String.valueOf(status.status_id) + "\">" + time + "</a>"; final String source_html = status.source; if (!isNullOrEmpty(time) && !isNullOrEmpty(source_html)) { mTimeAndSourceView.setText(Html.fromHtml(getString(R.string.time_source, strTime, source_html))); } else if (isNullOrEmpty(time) && !isNullOrEmpty(source_html)) { mTimeAndSourceView.setText(Html.fromHtml(getString(R.string.source, source_html))); } else if (!isNullOrEmpty(time) && isNullOrEmpty(source_html)) { mTimeAndSourceView.setText(time); } mTimeAndSourceView.setMovementMethod(LinkMovementMethod.getInstance()); mInReplyToView.setVisibility(is_reply ? View.VISIBLE : View.GONE); mConversationView.setVisibility(is_reply ? View.VISIBLE : View.GONE); if (is_reply) { mInReplyToView.setText(getString(R.string.in_reply_to, status.in_reply_to_screen_name)); Display display = getActivity().getWindowManager().getDefaultDisplay(); int width = display.getWidth(); // deprecated int height = display.getHeight(); // deprecated int heightOfConversation = (height / 2) - 48 - 44; ViewGroup.LayoutParams params = mConversationView.getLayoutParams(); params.height = heightOfConversation; mConversationView.setLayoutParams(params); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = null; ft = fragmentManager.beginTransaction(); final Fragment fragment = new ConversationFragment(); final Bundle args = new Bundle(); args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); args.putLong(INTENT_KEY_STATUS_ID, status.in_reply_to_status_id); fragment.setArguments(args); ft.replace(R.id.conversation, fragment, getString(R.string.view_conversation)); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); } if (status.play_package != null) { mMarketView.setVisibility(View.VISIBLE); mPlayInfoTask = new PlayStoreInfoTask(); mPlayInfoTask.execute(); } else { mMarketView.setVisibility(View.GONE); } final boolean hires_profile_image = getResources().getBoolean(R.bool.hires_profile_image); final String preview_image = hires_profile_image ? getBiggerTwitterProfileImage(status.profile_image_url_string) : status.profile_image_url_string; mLazyImageLoader.displayProfileImage(mProfileImageView, preview_image); final List<ImageSpec> images = getImagesInStatus(status.text_html); mImagesPreviewContainer.setVisibility(images.size() > 0 ? View.VISIBLE : View.GONE); mImagesPreviewFragment.addAll(images); mImagesPreviewFragment.update(); if (mLoadMoreAutomatically == true) { mImagesPreviewFragment.show(); } mRetweetedStatusView.setVisibility(status.is_protected ? View.GONE : View.VISIBLE); if (status.retweet_id > 0) { final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); final String retweeted_by = display_name ? status.retweeted_by_name : status.retweeted_by_screen_name; mRetweetedStatusView.setText(status.retweet_count > 1 ? getString(R.string.retweeted_by_with_count, retweeted_by, status.retweet_count - 1) : getString(R.string.retweeted_by, retweeted_by)); mRetweetedStatusView.setVisibility(View.VISIBLE); } else { mRetweetedStatusView.setVisibility(View.GONE); mRetweetedStatusView.setText(R.string.users_retweeted_this); } mLocationView.setVisibility(ParcelableLocation.isValidLocation(status.location) ? View.VISIBLE : View.GONE); if (mLoadMoreAutomatically) { showFollowInfo(true); showLocationInfo(true); } else { mFollowIndicator.setVisibility(View.GONE); } }
From source file:com.fjoglar.etsitnoticias.view.activities.NewsListActivity.java
private void setUpSearchView(MenuItem searchMenuItem, final MenuItem filterMenuItem) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) searchMenuItem.getActionView(); searchView.setMaxWidth(Integer.MAX_VALUE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); TextView searchText = (TextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text); searchText.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL)); // Hide filter option when SearchView is expanded, restore it when collapsed. MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override// w w w .ja va 2 s . c o m public boolean onMenuItemActionExpand(MenuItem item) { filterMenuItem.setVisible(false); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { filterMenuItem.setVisible(true); return true; } }); }
From source file:com.gmail.charleszq.picorner.ui.ImageDetailFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { MenuItem likeItem = menu.findItem(R.id.menu_item_like); MenuItem ownerPhotoItem = menu.findItem(R.id.menu_item_see_owner_photos); MenuItem commentItem = menu.findItem(R.id.menu_item_comment); MenuItem mapItem = menu.findItem(R.id.menu_item_view_on_map); MenuItem exifItem = menu.findItem(R.id.menu_item_view_exif); MenuItem detailItem = menu.findItem(R.id.menu_item_detail); PicornerApplication app = (PicornerApplication) getActivity().getApplication(); boolean ismyphoto = app.isMyOwnPhoto(mPhoto); ownerPhotoItem.setVisible(!ismyphoto); switch (mPhoto.getMediaSource()) { case FLICKR:/*from ww w . ja v a 2 s. c o m*/ menu.setGroupVisible(R.id.group_my_flickr_photo, ismyphoto); likeItem.setVisible(!ismyphoto); break; case PX500: menu.setGroupVisible(R.id.group_my_flickr_photo, false); likeItem.setVisible(!ismyphoto); break; case INSTAGRAM: commentItem.setVisible(false); exifItem.setVisible(false); menu.setGroupVisible(R.id.group_my_flickr_photo, false); break; case RSS: menu.setGroupVisible(R.id.group_my_flickr_photo, false); likeItem.setVisible(false); exifItem.setVisible(false); commentItem.setVisible(false); ownerPhotoItem.setVisible(false); detailItem.setVisible(false); break; } mapItem.setVisible(mPhoto.getLocation() != null); if (mUserLikeThePhoto) { likeItem.setIcon(R.drawable.star_big_on); } else { likeItem.setIcon(R.drawable.ic_menu_star); } // 500px menu group MenuItem voteItem = menu.findItem(R.id.menu_item_vote); if (mPhoto.getMediaSource() != MediaSourceType.PX500) { voteItem.setVisible(false); } else { voteItem.setVisible(SPUtil.getPx500OauthToken(getActivity()) != null && !app.isMyOwnPhoto(mPhoto) && !mPhoto.isUserVoted()); } }
From source file:com.slim.turboeditor.activity.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (fileOpened && searchResult != null) { MenuItem imReplace = menu.findItem(R.id.im_replace); MenuItem imReplaceAll = menu.findItem(R.id.im_replace_all); MenuItem imPrev = menu.findItem(R.id.im_previous_item); MenuItem imNext = menu.findItem(R.id.im_next_item); if (imReplace != null) imReplace.setVisible(searchResult.canReplaceSomething()); if (imReplaceAll != null) imReplaceAll.setVisible(searchResult.canReplaceSomething()); if (imPrev != null) imPrev.setVisible(searchResult.hasPrevious()); if (imNext != null) imNext.setVisible(searchResult.hasNext()); } else if (fileOpened) { MenuItem imSave = menu.findItem(R.id.im_save); MenuItem imUndo = menu.findItem(R.id.im_undo); MenuItem imRedo = menu.findItem(R.id.im_redo); if (mEditor != null) { if (imSave != null) imSave.setVisible(mEditor.canSaveFile()); if (imUndo != null) imUndo.setVisible(mEditor.getCanUndo()); if (imRedo != null) imRedo.setVisible(mEditor.getCanRedo()); } else {// w ww . j a v a 2 s .c o m imSave.setVisible(false); imUndo.setVisible(false); imRedo.setVisible(false); } } return true; }
From source file:com.www.avtovokzal.org.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { toolbarMenu = menu;//from ww w.j a v a 2s .c om getMenuInflater().inflate(R.menu.menu_items, menu); MenuItem item = toolbarMenu.findItem(R.id.lamp); item.setVisible(false); return true; }
From source file:de.vanita5.twittnuker.fragment.support.UserListDetailsFragment.java
private void setMenu(final Menu menu) { final AsyncTwitterWrapper twitter = getTwitterWrapper(); final ParcelableUserList userList = mUserList; final MenuItem followItem = menu.findItem(MENU_FOLLOW); if (followItem != null) { followItem.setEnabled(userList != null); if (userList == null) { followItem.setIcon(android.R.color.transparent); }//w w w. ja v a 2s. c o m } if (twitter == null || userList == null) return; final boolean isMyList = userList.user_id == userList.account_id; setMenuItemAvailability(menu, MENU_EDIT, isMyList); setMenuItemAvailability(menu, MENU_ADD, isMyList); setMenuItemAvailability(menu, MENU_DELETE, isMyList); final boolean isFollowing = userList.is_following; if (followItem != null) { followItem.setVisible(!isMyList); if (isFollowing) { followItem.setIcon(R.drawable.ic_iconic_action_cancel); followItem.setTitle(R.string.unsubscribe); } else { followItem.setIcon(R.drawable.ic_iconic_action_add); followItem.setTitle(R.string.subscribe); } } }