List of usage examples for android.view Menu setGroupVisible
public void setGroupVisible(int group, boolean visible);
From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java
private void setMenu() { if (mMenuBar == null) return;// w w w. j av a 2s.c o m final Menu menu = mMenuBar.getMenu(); final boolean hasMedia = hasMedia(), hasInReplyTo = mInReplyToStatus != null; /* * No media & Not reply: [Take photo][Add image][Attach location][Drafts] * Has media & Not reply: [Take photo][Media menu][Attach location][Drafts] * Is reply: [Media menu][View status][Attach location][Drafts] */ Utils.setMenuItemAvailability(menu, MENU_TAKE_PHOTO, !hasInReplyTo); Utils.setMenuItemAvailability(menu, R.id.take_photo_sub_item, hasInReplyTo); Utils.setMenuItemAvailability(menu, MENU_ADD_IMAGE, !hasMedia && !hasInReplyTo); Utils.setMenuItemAvailability(menu, MENU_VIEW, hasInReplyTo); Utils.setMenuItemAvailability(menu, R.id.media_menu, hasMedia || hasInReplyTo); Utils.setMenuItemAvailability(menu, MENU_TOGGLE_SENSITIVE, hasMedia); Utils.setMenuItemAvailability(menu, MENU_EDIT_MEDIA, hasMedia); menu.setGroupEnabled(MENU_GROUP_IMAGE_EXTENSION, hasMedia); menu.setGroupVisible(MENU_GROUP_IMAGE_EXTENSION, hasMedia); final MenuItem itemToggleSensitive = menu.findItem(MENU_TOGGLE_SENSITIVE); if (itemToggleSensitive != null) { itemToggleSensitive.setChecked(hasMedia && mIsPossiblySensitive); } ThemeUtils.resetCheatSheet(mMenuBar); // mMenuBar.show(); }
From source file:org.mariotaku.twidere.activity.support.ComposeActivity.java
private void setMenu() { if (mMenuBar == null) return;//from ww w. j a v a2 s . c o m final Menu menu = mMenuBar.getMenu(); final boolean hasMedia = hasMedia(), hasInReplyTo = mInReplyToStatus != null; /* * No media & Not reply: [Take photo][Add image][Attach location][Drafts] * Has media & Not reply: [Take photo][Media menu][Attach location][Drafts] * Is reply: [Media menu][View status][Attach location][Drafts] */ MenuUtils.setMenuItemAvailability(menu, MENU_TAKE_PHOTO, !hasInReplyTo); MenuUtils.setMenuItemAvailability(menu, R.id.take_photo_sub_item, hasInReplyTo); MenuUtils.setMenuItemAvailability(menu, MENU_ADD_IMAGE, !hasMedia && !hasInReplyTo); MenuUtils.setMenuItemAvailability(menu, MENU_VIEW, hasInReplyTo); MenuUtils.setMenuItemAvailability(menu, R.id.media_menu, hasMedia || hasInReplyTo); MenuUtils.setMenuItemAvailability(menu, MENU_TOGGLE_SENSITIVE, hasMedia); MenuUtils.setMenuItemAvailability(menu, MENU_EDIT_MEDIA, hasMedia); MenuUtils.setMenuItemAvailability(menu, R.id.link_to_quoted_status, isQuote()); menu.setGroupEnabled(MENU_GROUP_IMAGE_EXTENSION, hasMedia); menu.setGroupVisible(MENU_GROUP_IMAGE_EXTENSION, hasMedia); MenuUtils.setMenuItemChecked(menu, MENU_TOGGLE_SENSITIVE, hasMedia && mIsPossiblySensitive); MenuUtils.setMenuItemChecked(menu, R.id.link_to_quoted_status, mPreferences.getBoolean(KEY_LINK_TO_QUOTED_TWEET)); ThemeUtils.resetCheatSheet(mMenuBar); // mMenuBar.show(); }
From source file:github.daneren2005.dsub.fragments.SelectDirectoryFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { if (licenseValid == null) { menuInflater.inflate(R.menu.empty, menu); } else if (albumListType != null && !"starred".equals(albumListType)) { menuInflater.inflate(R.menu.select_album_list, menu); } else if (artist && !showAll) { menuInflater.inflate(R.menu.select_album, menu); if (!ServerInfo.hasTopSongs(context)) { menu.removeItem(R.id.menu_top_tracks); }//w w w . j a v a 2s .co m if (!ServerInfo.checkServerVersion(context, "1.11") || (id != null && "root".equals(id))) { menu.removeItem(R.id.menu_radio); menu.removeItem(R.id.menu_similar_artists); } else if (!ServerInfo.hasSimilarArtists(context)) { menu.removeItem(R.id.menu_similar_artists); } } else { if (podcastId == null) { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_song_offline, menu); } else { menuInflater.inflate(R.menu.select_song, menu); if (playlistId == null || !playlistOwner) { menu.removeItem(R.id.menu_remove_playlist); } } SharedPreferences prefs = Util.getPreferences(context); if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_NEXT, true)) { menu.setGroupVisible(R.id.hide_play_next, false); } if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_LAST, true)) { menu.setGroupVisible(R.id.hide_play_last, false); } } else { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_podcast_episode_offline, menu); } else { menuInflater.inflate(R.menu.select_podcast_episode, menu); if (!UserUtil.canPodcast()) { menu.removeItem(R.id.menu_download_all); } } } } if ("starred".equals(albumListType)) { menuInflater.inflate(R.menu.unstar, menu); } }
From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { if (licenseValid == null) { menuInflater.inflate(R.menu.empty, menu); } else if (albumListType != null && !"starred".equals(albumListType)) { menuInflater.inflate(R.menu.select_album_list, menu); } else if (artist && !showAll) { menuInflater.inflate(R.menu.select_album, menu); if (!ServerInfo.hasTopSongs(context)) { menu.removeItem(R.id.menu_top_tracks); }/* w ww .ja va2s . c om*/ if (!ServerInfo.checkServerVersion(context, "1.11")) { menu.removeItem(R.id.menu_radio); menu.removeItem(R.id.menu_similar_artists); } else if (!ServerInfo.hasSimilarArtists(context)) { menu.removeItem(R.id.menu_similar_artists); } } else { if (podcastId == null) { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_song_offline, menu); } else { menuInflater.inflate(R.menu.select_song, menu); if (playlistId == null || !playlistOwner) { menu.removeItem(R.id.menu_remove_playlist); } } SharedPreferences prefs = Util.getPreferences(context); if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_NEXT, true)) { menu.setGroupVisible(R.id.hide_play_next, false); } if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_LAST, true)) { menu.setGroupVisible(R.id.hide_play_last, false); } } else { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_podcast_episode_offline, menu); } else { menuInflater.inflate(R.menu.select_podcast_episode, menu); if (!UserUtil.canPodcast()) { menu.removeItem(R.id.menu_download_all); } } } } if ("starred".equals(albumListType)) { menuInflater.inflate(R.menu.unstar, menu); } }
From source file:com.android.launcher2.Launcher.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (mAppsCustomizeTabHost.isTransitioning()) { return false; }//from w ww .j a v a 2s.co m boolean allAppsVisible = (mAppsCustomizeTabHost.getVisibility() == View.VISIBLE); menu.setGroupVisible(MENU_GROUP_WALLPAPER, !allAppsVisible); return true; }
From source file:github.popeen.dsub.fragments.SubsonicFragment.java
public void onCreateContextMenuSupport(Menu menu, MenuInflater menuInflater, UpdateView updateView, Object selected) {// w w w. ja v a2s.c o m if (selected instanceof Entry) { Entry entry = (Entry) selected; if (entry instanceof PodcastEpisode) { if (Util.isOffline(context)) { if (entry.isVideo()) { menuInflater.inflate(R.menu.select_video_context_offline, menu); } else { menuInflater.inflate(R.menu.select_podcast_episode_context_offline, menu); } } else { if (entry.isVideo()) { menuInflater.inflate(R.menu.select_podcast_episode_video_context, menu); } else { menuInflater.inflate(R.menu.select_podcast_episode_context, menu); } if (entry.getBookmark() == null) { menu.removeItem(R.id.bookmark_menu_delete); } if (UserUtil.canPodcast()) { String status = ((PodcastEpisode) entry).getStatus(); if ("completed".equals(status)) { menu.removeItem(R.id.song_menu_server_download); } } else { menu.removeItem(R.id.song_menu_server_download); menu.removeItem(R.id.song_menu_server_delete); } } } else if (entry.isDirectory()) { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_album_context_offline, menu); } else { menuInflater.inflate(R.menu.select_album_context, menu); if (Util.isTagBrowsing(context)) { menu.removeItem(R.id.menu_rate); } } } else if (!entry.isVideo()) { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_song_context_offline, menu); } else { menuInflater.inflate(R.menu.select_song_context, menu); if (entry.getBookmark() == null) { menu.removeItem(R.id.bookmark_menu_delete); } String songPressAction = Util.getSongPressAction(context); if (!"next".equals(songPressAction) && !"last".equals(songPressAction)) { menu.setGroupVisible(R.id.hide_play_now, false); } } } else { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_video_context_offline, menu); } else { menuInflater.inflate(R.menu.select_video_context, menu); } } MenuItem starMenu = menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star); if (starMenu != null) { starMenu.setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); } if (!isShowArtistEnabled() || (!Util.isTagBrowsing(context) && entry.getParent() == null) || (Util.isTagBrowsing(context) && entry.getArtistId() == null)) { menu.setGroupVisible(R.id.hide_show_artist, false); } } else if (selected instanceof Artist) { Artist artist = (Artist) selected; if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_artist_context_offline, menu); } else { menuInflater.inflate(R.menu.select_artist_context, menu); menu.findItem(R.id.artist_menu_star) .setTitle(artist.isStarred() ? R.string.common_unstar : R.string.common_star); } } MenuUtil.hideMenuItems(context, menu, updateView); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (mIsEditMode || mIsWidgetEditMode) return false; // We can't trust the view state here since views we may not be done // binding./*from ww w. j a v a 2s . co m*/ // Get the vacancy state from the model instead. mMenuAddInfo = mWorkspace.findAllVacantCellsFromModel(); menu.setGroupVisible(MENU_GROUP_ADD, mMenuAddInfo != null && mMenuAddInfo.valid && (!allAppsOpen)); menu.setGroupVisible(MENU_GROUP_NORMAL, !allAppsOpen); menu.setGroupVisible(MENU_GROUP_CATALOGUE, allAppsOpen); if (mBlockDesktop) { menu.findItem(MENU_LOCK_DESKTOP).setTitle(R.string.menu_unlock); } else { menu.findItem(MENU_LOCK_DESKTOP).setTitle(R.string.menu_lock); } return true; }