Java Code Examples for android.view.MenuItem.setVisible()

The following are Jave code examples for showing how to use setVisible() of the android.view.MenuItem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Ghost-Android   File: PostViewActivity.java   View Source Code Vote up 6 votes
@Override
public void onClick(View view) {
    if (view.getId() == R.id.post_image_edit_layout) {
        PopupMenu popupMenu = new PopupMenu(this, mPostImageLayoutManager.getRootLayout());
        popupMenu.inflate(R.menu.insert_image);
        if (TextUtils.isEmpty(mPost.getFeatureImage())) {
            MenuItem removeImageItem = popupMenu.getMenu().findItem(R.id.action_image_remove);
            removeImageItem.setVisible(false);
        }
        popupMenu.setOnMenuItemClickListener(item -> {
            if (item.getItemId() == R.id.action_insert_image_url) {
                mPostEditFragment.onInsertImageUrlClicked(getInsertImageDoneAction());
            } else if (item.getItemId() == R.id.action_insert_image_upload) {
                mPostEditFragment.onInsertImageUploadClicked(getInsertImageDoneAction());
            } else if (item.getItemId() == R.id.action_image_remove) {
                getInsertImageDoneAction().call("");
            }
            return true;
        });
        popupMenu.show();
    }
}
 
Example 2
Project: encdroidMC   File: EDVolumeBrowserActivity.java   View Source Code Vote up 6 votes
@Override
	public void onCreateContextMenu(ContextMenu menu, View v,
			ContextMenuInfo menuInfo) {
		super.onCreateContextMenu(menu, v, menuInfo);
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.volume_browser_context, menu);
//		if (!this.mEDVolume.getFileProvider().allowRemoteCopy()){
//			MenuItem MenuItem =(MenuItem )menu.findItem(R.id.volume_browser_menu_copy);
//			MenuItem.setVisible(false);
//		}
		
		  AdapterView.AdapterContextMenuInfo info =
		            (AdapterView.AdapterContextMenuInfo) menuInfo;

		  int pos = info.position;
		  
		  EDFileChooserItem selectedFile = mCurFileList.get(pos-1);
		  MenuItem MenuItem =(MenuItem )menu.findItem(R.id.volume_browser_generage_thumbnail);
		  if (selectedFile != null && (MimeManagement.isImage(selectedFile.getName()) || MimeManagement.isVideo(selectedFile.getName()))){
			  MenuItem.setVisible(true);
		  } else {
			  MenuItem.setVisible(false);
		  }
		
	}
 
Example 3
Project: AURdroid   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    /*
      app share and rate group
      hide on AurPackageDetailsFragment
     */
    MenuItem menuItem = menu.findItem(R.id.menu_main_app_group);
    Fragment fragmentByTag = fragmentManager.findFragmentByTag(AUR_PACKAGE_DETAILS_FRAGMENT_TAG);
    menuItem.setVisible(fragmentByTag == null);
    // night mode
    switch (AppCompatDelegate.getDefaultNightMode()) {
        case AppCompatDelegate.MODE_NIGHT_AUTO:
            menu.findItem(R.id.menu_main_action_night_mode_auto).setChecked(true);
            break;
        case AppCompatDelegate.MODE_NIGHT_YES:
            menu.findItem(R.id.menu_main_action_night_mode_night).setChecked(true);
            break;
        case AppCompatDelegate.MODE_NIGHT_NO:
            menu.findItem(R.id.menu_main_action_night_mode_day).setChecked(true);
            break;
    }
    return true;
}
 
Example 4
Project: android-ponewheel   File: RideDetailActivity.java   View Source Code Vote up 6 votes
@Override public boolean onOptionsItemSelected(MenuItem item) {

        if (item.getItemId() == R.id.menu_item_prepare) {
            Toast.makeText(
                    this,
                    "Your file is being prepared",
                    Toast.LENGTH_SHORT)
                    .show();
            prepareItemForSharing();
            item.setVisible(false);

            // share icon will be visible after preparation is done
        } else {
            Timber.d("menuItem:"+item.toString());
        }

        return super.onOptionsItemSelected(item);
    }
 
Example 5
Project: ultrasonic   File: SelectPlaylistActivity.java   View Source Code Vote up 6 votes
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo)
{
	super.onCreateContextMenu(menu, view, menuInfo);

	MenuInflater inflater = getMenuInflater();
	if (Util.isOffline(this)) inflater.inflate(R.menu.select_playlist_context_offline, menu);
	else inflater.inflate(R.menu.select_playlist_context, menu);

	MenuItem downloadMenuItem = menu.findItem(R.id.album_menu_download);

	if (downloadMenuItem != null)
	{
		downloadMenuItem.setVisible(!Util.isOffline(this));
	}
}
 
Example 6
Project: microMathematics   File: BaseFragment.java   View Source Code Vote up 6 votes
public void updateModeTitle()
{
    android.support.v7.view.ActionMode mode = ((MainActivity) activity).getActionMode();
    if (mode != null)
    {
        final int selected = formulas.getSelectedEquations().size();
        final int total = formulas.getEquationsNumber();
        if (selected == 0)
        {
            mode.setTitle("");
        }
        else
        {
            mode.setTitle(String.valueOf(selected) + "/" + String.valueOf(total));
        }
        Menu m = mode.getMenu();
        if (m != null)
        {
            MenuItem mi = m.findItem(R.id.context_menu_expand);
            if (mi != null)
            {
                mi.setVisible(total > selected);
            }
        }
    }
}
 
Example 7
Project: CodeCompilerApp   File: SelectFileActivity.java   View Source Code Vote up 6 votes
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // menu items
    MenuItem imSetAsWorkingFolder = menu.findItem(R.id.im_set_as_working_folder);
    MenuItem imIsWorkingFolder = menu.findItem(R.id.im_is_working_folder);
    MenuItem imSelectFolder = menu.findItem(R.id.im_select_folder);
    if (imSetAsWorkingFolder != null) {
        // set the imSetAsWorkingFolder visible only if the two folder dont concide
        imSetAsWorkingFolder.setVisible(!currentFolder.equals(PreferenceHelper.getWorkingFolder(SelectFileActivity.this)));
    }
    if (imIsWorkingFolder != null) {
        // set visible is the other is invisible
        imIsWorkingFolder.setVisible(!imSetAsWorkingFolder.isVisible());
    }
    if (imSelectFolder != null) {
        imSelectFolder.setVisible(!wantAFile);
    }
    return super.onPrepareOptionsMenu(menu);
}
 
Example 8
Project: recyclerview-android   File: SingleModalChoiceModeExampleActivity.java   View Source Code Vote up 6 votes
@Override
public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) {
    final int checkedCount = mChoiceMode.getCheckedItemCount();
    
    // Show / hide menu items or menu groups based on number of checked items
    final MenuItem item = menu.findItem(R.id.action_delete);
    item.setVisible(checkedCount > 0);
    
    // Update action mode title
    if (checkedCount > 0) {
        final Resources resources = getResources();
        mode.setTitle(resources.getQuantityString(R.plurals.action_mode_x_items_selected,
                checkedCount, checkedCount));
    } else {
        mode.setTitle(R.string.action_mode_no_items_selected);
    }
    
    return true;
}
 
Example 9
Project: CSI-KJSCEOfficial   File: EventDetailsActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.activity_eventdetail_menu, menu);

    MenuItem feedbackMenuItem = menu.findItem(R.id.feedback_menu);
    if(!URLUtil.isValidUrl(event.getFeedback()))
        feedbackMenuItem.setVisible(false);
    return true;
}
 
Example 10
Project: ifcalc   File: DisciplinasActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_disciplinas, menu);
    MenuItem item = menu.findItem(R.id.action_refresh);
    if (DataSource.getInstance(this).containDisciplinasWeb())
        item.setVisible(true);
    return true;
}
 
Example 11
Project: Tusky   File: AccountActivity.java   View Source Code Vote up 5 votes
@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;
        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);
}
 
Example 12
Project: boohee_v5.6   File: BrowserActivity.java   View Source Code Vote up 5 votes
protected void setupShareBtn() {
    if (this.mMenu != null && this.mMenu.size() > 0) {
        MenuItem item = this.mMenu.findItem(R.id.action_share);
        if (item != null) {
            boolean z = !TextUtils.isEmpty(this.mUrl) && this.mUrl.contains("share=true");
            item.setVisible(z);
        }
    }
}
 
Example 13
Project: ifcalc   File: AnotacaoDetalheActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_detalhe, menu);
    MenuItem item = menu.findItem(R.id.action_delete);
    if (idAnotacao == null)
        item.setVisible(false);
    return true;
}
 
Example 14
Project: garras   File: PhotoFragment.java   View Source Code Vote up 5 votes
private void updateHeartButton(boolean isLike) {
    if (null != mPhotoMenu && UserUtils.isAuthorized()) {
        MenuItem item = mPhotoMenu.getItem(1);
        item.setVisible(true);
        item.setIcon(isLike ? R.drawable.ic_favorite_red_24dp : R.drawable.ic_favorite_border_24dp);
        View likeMenuView = mToolbar.findViewById(R.id.action_like);
        if (null == likeMenuView) return;
        SpringyAnimator springHelper = new SpringyAnimator(SpringAnimationType.SCALEXY, 100, 4, 0, 1);
        springHelper.startSpring(likeMenuView);
    }
}
 
Example 15
Project: Phoenix-for-VK   File: CommentsFragment.java   View Source Code Vote up 5 votes
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.findItem(R.id.open_poll).setVisible(mTopicPollAvailable);

    MenuItem gotoSource = menu.findItem(R.id.to_commented);
    gotoSource.setVisible(mGotoSourceAvailable);

    if (mGotoSourceAvailable) {
        gotoSource.setTitle(mGotoSourceText);
    }
}
 
Example 16
Project: memetastic   File: MainActivity.java   View Source Code Vote up 5 votes
public void updateHiddenNavOption() {
    MenuItem hiddenItem = _navigationView.getMenu().findItem(R.id.action_mode_hidden);
    for (String hidden : app.settings.getHiddenMemesTemplate()) {
        MemeData.Image image = MemeData.findImage(new File(hidden));
        if (image != null) {
            hiddenItem.setVisible(true);
            return;
        }
    }
    hiddenItem.setVisible(false);
}
 
Example 17
Project: lead-management-android   File: ContactsFragment.java   View Source Code Vote up 4 votes
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    MenuItem item = menu.findItem(R.id.action_search);
    item.setVisible(true);
}
 
Example 18
Project: chromium-for-android-56-debug-video   File: CustomTabAppMenuPropertiesDelegate.java   View Source Code Vote up 4 votes
@Override
public void prepareMenu(Menu menu) {
    Tab currentTab = mActivity.getActivityTab();
    if (currentTab != null) {
        MenuItem forwardMenuItem = menu.findItem(R.id.forward_menu_id);
        forwardMenuItem.setEnabled(currentTab.canGoForward());

        mReloadMenuItem = menu.findItem(R.id.reload_menu_id);
        mReloadMenuItem.setIcon(R.drawable.btn_reload_stop);
        loadingStateChanged(currentTab.isLoading());

        MenuItem shareItem = menu.findItem(R.id.share_row_menu_id);
        shareItem.setVisible(mShowShare);
        shareItem.setEnabled(mShowShare);
        if (mShowShare) {
            ShareHelper.configureDirectShareMenuItem(
                    mActivity, menu.findItem(R.id.direct_share_menu_id));
        }

        MenuItem iconRow = menu.findItem(R.id.icon_row_menu_id);
        MenuItem openInChromeItem = menu.findItem(R.id.open_in_browser_id);
        if (mIsMediaViewer) {
            // Most of the menu items don't make sense when viewing media.
            iconRow.setVisible(false);
            openInChromeItem.setVisible(false);
        } else {
            try {
                openInChromeItem.setTitle(mDefaultBrowserFetcher.get());
            } catch (InterruptedException | ExecutionException e) {
                openInChromeItem.setTitle(
                        mActivity.getString(R.string.menu_open_in_product_default));
            }
        }

        // Add custom menu items. Make sure they are only added once.
        if (!mIsCustomEntryAdded) {
            mIsCustomEntryAdded = true;
            for (int i = 0; i < mMenuEntries.size(); i++) {
                MenuItem item = menu.add(0, 0, 1, mMenuEntries.get(i));
                mItemToIndexMap.put(item, i);
            }
        }
    }
}
 
Example 19
Project: markor   File: FilesystemListFragment.java   View Source Code Vote up 4 votes
private void setRenameButtonVisibility(ActionMode actionMode, boolean visible) {
    Menu menu = actionMode.getMenu();
    MenuItem item = menu.findItem(R.id.context_menu_rename);
    item.setVisible(visible);
}
 
Example 20
Project: easyfilemanager   File: DocumentsActivity.java   View Source Code Vote up 4 votes
public void updateMenuItems(Menu menu){
    final FragmentManager fm = getFragmentManager();
    final RootInfo root = getCurrentRoot();
    final DocumentInfo cwd = getCurrentDirectory();

    if(isTelevision()) {
        menu.findItem(R.id.menu_create_dir).setVisible(showActionMenu());
        menu.findItem(R.id.menu_create_file).setVisible(showActionMenu());
    }
    final MenuItem search = menu.findItem(R.id.menu_search);
    final MenuItem sort = menu.findItem(R.id.menu_sort);
    final MenuItem sortSize = menu.findItem(R.id.menu_sort_size);
    final MenuItem grid = menu.findItem(R.id.menu_grid);
    final MenuItem list = menu.findItem(R.id.menu_list);
    final MenuItem settings = menu.findItem(R.id.menu_settings);

    // Open drawer means we hide most actions
    if (isRootsDrawerOpen()) {
        search.setVisible(false);
        sort.setVisible(false);
        grid.setVisible(false);
        list.setVisible(false);
        mIgnoreNextCollapse = true;
        search.collapseActionView();
        return;
    }

    sort.setVisible(cwd != null);
    grid.setVisible(!RootInfo.isOtherRoot(getCurrentRoot()) && mState.derivedMode != MODE_GRID);
    list.setVisible(mState.derivedMode != MODE_LIST);

    if (mState.currentSearch != null) {
        // Search uses backend ranking; no sorting
        //sort.setVisible(false);

        search.expandActionView();

        mSearchView.setIconified(false);
        mSearchView.clearFocus();
        mSearchView.setQuery(mState.currentSearch, false);
    } else {
        mIgnoreNextClose = true;
        mSearchView.setIconified(true);
        mSearchView.clearFocus();

        mIgnoreNextCollapse = true;
        search.collapseActionView();
    }

    // Only sort by size when visible
    sortSize.setVisible(mState.showSize);

    final boolean searchVisible;
    if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
        searchVisible = false;

        // No display options in recent directories
        if (cwd == null) {
            grid.setVisible(false);
            list.setVisible(false);
        }
        if (mState.action == State.ACTION_CREATE) {
            if (null != SaveFragment.get(fm))
                SaveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isCreateSupported());
        }
    } else {
        searchVisible = root != null
                && ((root.flags & Root.FLAG_SUPPORTS_SEARCH) != 0);
        // TODO: Is this useful?
        if(null != SaveFragment.get(fm))
            SaveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isCreateSupported());

        if(null != MoveFragment.get(fm))
            MoveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isMoveSupported());
    }

    // TODO: close any search in-progress when hiding
    search.setVisible(searchVisible);

    settings.setVisible(mState.action != ACTION_MANAGE);
}