List of usage examples for android.view Menu NONE
int NONE
To view the source code for android.view Menu NONE.
Click Source Link
From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java
private void showMenuColumnsOptions(View view) { final List<String> list = new ArrayList<String>(); final List<Long> types = new ArrayList<Long>(); ArrayList<Entity> userEntityList = DataFramework.getInstance().getEntityList("users", "service is null or service = \"twitter.com\""); for (Entity user : userEntityList) { list.add(getString(R.string.addColumnUser, user.getString("name"))); types.add(user.getId());//from w ww . ja v a2 s. com } list.add(getString(R.string.addTrendingTopic)); types.add(1001L); list.add(getString(R.string.addSavedTweet)); types.add(1002L); list.add(getString(R.string.sortColumns)); types.add(1003L); list.add(getString(R.string.removeColumns)); types.add(1004L); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { PopupMenu popupMenu = new PopupMenu(this, view); int count = 0; for (String item : list) { popupMenu.getMenu().add(Menu.NONE, count, Menu.NONE, item); count++; } popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { long id = types.get(item.getItemId()); String title = list.get(item.getItemId()); switch ((int) id) { case 1001: newTrending(); break; case 1002: openSavedTweetColumn(); break; case 1003: goToSortColumns(); break; case 1004: goToRemoveColumns(); break; default: showActionBarIndicatorAndMovePager(-1); showDialogAddColumnUser(title, id); break; } return true; } }); popupMenu.show(); } else { AlertDialogFragment frag = new AlertDialogFragment(); Bundle args = new Bundle(); args.putInt(AlertDialogFragment.KEY_ALERT_TITLE, R.string.actions); args.putBoolean(AlertDialogFragment.KEY_ALERT_HAS_POSITIVE_BUTTON, false); args.putBoolean(AlertDialogFragment.KEY_ALERT_CANCELABLE, false); args.putStringArrayList(AlertDialogFragment.KEY_ALERT_ARRAY_STRING_ITEMS, (ArrayList<String>) list); frag.setArguments(args); frag.setAlertButtonListener(new AlertDialogFragment.AlertButtonListener() { @Override public void OnAlertButtonOk() { } @Override public void OnAlertButtonCancel() { } @Override public void OnAlertButtonNeutral() { } @Override public void OnAlertItems(int which) { long id = types.get(which); String title = list.get(which); switch ((int) id) { case 1001: newTrending(); break; case 1002: openSavedTweetColumn(); break; case 1003: goToSortColumns(); break; case 1004: goToRemoveColumns(); break; default: showActionBarIndicatorAndMovePager(-1); showDialogAddColumnUser(title, id); break; } } }); frag.show(getSupportFragmentManager(), "dialog"); } }
From source file:org.alfresco.mobile.android.application.fragments.workflow.task.TaskDetailsFragment.java
public void getMenu(Menu menu) { MenuItem mi;//w ww . j a va 2 s. co m String processDefinitionKey = WorkflowUtils.getKeyFromProcessDefinitionId(processDefinitionId); if (endedAt == null && processDefinitionKey.startsWith(WorkflowModel.KEY_PREFIX_ACTIVITI)) { mi = menu.add(Menu.NONE, R.id.menu_process_details, Menu.FIRST, R.string.process_diagram); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } mi = menu.add(Menu.NONE, R.id.menu_process_history, Menu.FIRST + 1, R.string.tasks_history); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if (currentTask == null || endedAt != null) { return; } // unclaim : I unassign myself (generally created by a pooled process) if (currentTask.getAssigneeIdentifier() != null && WorkflowModel.FAMILY_PROCESS_POOLED_REVIEW.contains(processDefinitionKey)) { mi = menu.add(Menu.NONE, R.id.menu_task_unclaim, Menu.FIRST + 2, R.string.task_unclaim); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT); } // reassign : I have a task and I decide I dont want to be responsible // anymore of this task so I reassign to a specific person else if (currentTask.getAssigneeIdentifier() != null) { mi = menu.add(Menu.NONE, R.id.menu_task_reassign, Menu.FIRST + 3, R.string.task_reassign); mi.setIcon(R.drawable.ic_reassign); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } // claim : I assign to me an unassigned task (created by a pooled // process) else if ((currentTask.getAssigneeIdentifier() == null && WorkflowModel.FAMILY_PROCESS_POOLED_REVIEW.contains(processDefinitionKey)) || "unclaimed".equals(state)) { mi = menu.add(Menu.NONE, R.id.menu_task_claim, Menu.FIRST + 4, R.string.task_claim); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT); } }
From source file:com.maxwen.wallpaper.board.activities.WallpaperBoardActivity.java
public void fileCategoryMenu(Menu menu) { List<Category> categories = new Database(this).getCategories(); for (Category c : categories) { menu.removeItem(MENU_CATEGORY_START + c.getId()); MenuItem item = menu.add(Menu.NONE, MENU_CATEGORY_START + c.getId(), Menu.NONE, c.getName()); item.setCheckable(true);/*from ww w .j a v a2 s . c o m*/ item.setChecked(c.isSelected()); } }
From source file:com.gh4a.fragment.EventListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId() == R.id.list_view) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Event event = (Event) mAdapter.getItem(info.position); int groupId = getMenuGroupId(); //if payload is a base class, return void. Think that it is an old event which not supported //by API v3. if (event.getPayload().getClass().getSimpleName().equals("EventPayload")) { return; }/*from w w w. j a va 2 s . c o m*/ String eventType = event.getType(); EventRepository eventRepo = event.getRepo(); String[] repoNamePart = eventRepo.getName().split("/"); String repoOwner = null; String repoName = null; if (repoNamePart.length == 2) { repoOwner = repoNamePart[0]; repoName = repoNamePart[1]; } String repoUrl = eventRepo.getUrl(); menu.setHeaderTitle("Go to"); /** Common menu */ menu.add(groupId, MENU_USER, Menu.NONE, "User " + event.getActor().getLogin()); if (repoOwner != null) { menu.add(groupId, MENU_REPO, Menu.NONE, "Repo " + repoOwner + "/" + repoName); } /** PushEvent extra menu for commits */ if (Event.TYPE_PUSH.equals(eventType)) { if (repoOwner != null) { PushPayload payload = (PushPayload) event.getPayload(); menu.add(groupId, MENU_COMPARE, Menu.NONE, "Compare " + payload.getHead()); List<Commit> commits = payload.getCommits(); for (Commit commit : commits) { menu.add(groupId, MENU_COMMIT, Menu.NONE, "Commit " + commit.getSha()); } } } /** IssueEvent extra menu for commits */ else if (Event.TYPE_ISSUES.equals(eventType)) { IssuesPayload payload = (IssuesPayload) event.getPayload(); menu.add(groupId, MENU_ISSUE, Menu.NONE, "Issue " + payload.getIssue().getNumber()); } /** FollowEvent */ else if (Event.TYPE_FOLLOW.equals(eventType)) { FollowPayload payload = (FollowPayload) event.getPayload(); if (payload.getTarget() != null) { menu.add(groupId, MENU_USER, Menu.NONE, "User " + payload.getTarget().getLogin()); } } /** CommitCommentEvent */ else if (Event.TYPE_COMMIT_COMMENT.equals(eventType)) { if (repoOwner != null) { CommitCommentPayload payload = (CommitCommentPayload) event.getPayload(); menu.add(groupId, MENU_COMMIT, Menu.NONE, "Commit " + payload.getComment().getCommitId().substring(0, 7)); //menu.add("Comment in browser"); } } /** GistEvent */ else if (Event.TYPE_GIST.equals(eventType)) { GistPayload payload = (GistPayload) event.getPayload(); menu.add(groupId, MENU_GIST, Menu.NONE, "Gist " + payload.getGist().getId()); } /** DownloadEvent */ else if (Event.TYPE_DOWNLOAD.equals(eventType)) { DownloadPayload payload = (DownloadPayload) event.getPayload(); menu.add(groupId, MENU_FILE, Menu.NONE, "File " + payload.getDownload().getName()); } /** ForkEvent */ else if (Event.TYPE_FORK.equals(eventType)) { ForkPayload payload = (ForkPayload) event.getPayload(); Repository forkee = payload.getForkee(); if (forkee != null) { menu.add(groupId, MENU_FORKED_REPO, Menu.NONE, "Forked repo " + forkee.getOwner().getLogin() + "/" + forkee.getName()); } } /** GollumEvent */ else if (Event.TYPE_GOLLUM.equals(eventType)) { menu.add(groupId, MENU_WIKI_IN_BROWSER, Menu.NONE, "Wiki in browser"); } /** PullRequestEvent */ else if (Event.TYPE_PULL_REQUEST.equals(eventType)) { PullRequestPayload payload = (PullRequestPayload) event.getPayload(); menu.add(groupId, MENU_PULL_REQ, Menu.NONE, "Pull request " + payload.getNumber()); } /** IssueCommentEvent */ else if (Event.TYPE_ISSUE_COMMENT.equals(eventType)) { menu.add(groupId, MENU_OPEN_ISSUES, Menu.NONE, "Open issues"); } } }
From source file:com.example.javier.MaterialDesignApp.PlayerActivity.java
public void showVerboseLogPopup(View v) { PopupMenu popup = new PopupMenu(this, v); Menu menu = popup.getMenu();//from ww w.ja va 2 s . c o m menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal); menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose); menu.setGroupCheckable(Menu.NONE, true, true); menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == 0) { VerboseLogUtil.setEnableAllTags(false); } else { VerboseLogUtil.setEnableAllTags(true); } return true; } }); popup.show(); }
From source file:org.uguess.android.sysinfo.ProcessManager.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); int pos = ((AdapterContextMenuInfo) menuInfo).position; ProcessItem rap = (ProcessItem) getListView().getItemAtPosition(pos); menu.setHeaderTitle(R.string.actions); menu.add(Menu.NONE, MI_DISPLAY, Menu.NONE, R.string.switch_to); boolean protect = ignoreList.contains(rap.procInfo.processName) || rap.sys; if (protect) { menu.add(Menu.NONE, MI_ENDTASK, Menu.NONE, R.string.end_task).setEnabled(false); } else {/* w w w.jav a 2s.c o m*/ menu.add(Menu.NONE, MI_ENDTASK, Menu.NONE, R.string.end_task); } menu.add(Menu.NONE, MI_END_OTHERS, Menu.NONE, R.string.end_others); if (protect) { menu.add(Menu.NONE, MI_IGNORE, Menu.NONE, R.string.ignore).setEnabled(false); } else { menu.add(Menu.NONE, MI_IGNORE, Menu.NONE, R.string.ignore); } menu.add(Menu.NONE, MI_DETAILS, Menu.NONE, R.string.details); }
From source file:com.yeldi.yeldibazaar.AppDetails.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.clear();/*from ww w. j a v a 2s. c o m*/ if (app == null) return true; DB.Apk curver = app.getCurrentVersion(); if (app.hasUpdates == true) { MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, INSTALL, 0, R.string.menu_update).setIcon(R.drawable.ic_menu_refresh), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } if (app.installedVersion == null && curver != null) { MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, INSTALL, 1, R.string.menu_install).setIcon(android.R.drawable.ic_menu_add), MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } else if (app.installedVersion != null) { MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, UNINSTALL, 1, R.string.menu_uninstall) .setIcon(android.R.drawable.ic_menu_delete), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); if (mPm.getLaunchIntentForPackage(app.id) != null) { MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, LAUNCH, 1, R.string.menu_launch) .setIcon(android.R.drawable.ic_media_play), MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } } MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, SHARE, 1, R.string.menu_share).setIcon(android.R.drawable.ic_menu_share), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); if (app.detail_webURL.length() > 0) { menu.add(Menu.NONE, WEBSITE, 2, R.string.menu_website).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_trackerURL.length() > 0) { menu.add(Menu.NONE, ISSUES, 3, R.string.menu_issues).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_sourceURL.length() > 0) { menu.add(Menu.NONE, SOURCE, 4, R.string.menu_source).setIcon(android.R.drawable.ic_menu_view); } menu.add(Menu.NONE, MARKET, 5, R.string.menu_market).setIcon(android.R.drawable.ic_menu_view); if (app.detail_bitcoinAddr != null) { menu.add(Menu.NONE, BITCOIN, 6, R.string.menu_bitcoin).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_flattrID != null) { menu.add(Menu.NONE, FLATTR, 7, R.string.menu_flattr).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_donateURL != null) { menu.add(Menu.NONE, DONATE, 8, R.string.menu_donate).setIcon(android.R.drawable.ic_menu_view); } return true; }
From source file:biz.bokhorst.xprivacy.ActivityApp.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // Check if running boolean running = false; ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); for (RunningAppProcessInfo info : activityManager.getRunningAppProcesses()) if (info.uid == mAppInfo.getUid()) running = true;/*ww w.j a va 2s . c om*/ PackageManager pm = getPackageManager(); List<String> listPackageNames = mAppInfo.getPackageName(); List<String> listApplicationName = mAppInfo.getApplicationName(); for (int i = 0; i < listPackageNames.size(); i++) { Menu appMenu = (listPackageNames.size() == 1) ? menu : menu.addSubMenu(i, Menu.NONE, Menu.NONE, listApplicationName.get(i)); // Launch MenuItem launch = appMenu.add(i, MENU_LAUNCH, Menu.NONE, getString(R.string.menu_app_launch)); if (pm.getLaunchIntentForPackage(listPackageNames.get(i)) == null) launch.setEnabled(false); // Settings appMenu.add(i, MENU_SETTINGS, Menu.NONE, getString(R.string.menu_app_settings)); // Kill MenuItem kill = appMenu.add(i, MENU_KILL, Menu.NONE, getString(R.string.menu_app_kill)); kill.setEnabled(running && PrivacyManager.isApplication(mAppInfo.getUid())); // Play store MenuItem store = appMenu.add(i, MENU_STORE, Menu.NONE, getString(R.string.menu_app_store)); if (!Util.hasMarketLink(this, listPackageNames.get(i))) store.setEnabled(false); } }
From source file:it.geosolutions.geocollect.android.core.form.FormEditActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { Log.v("FEA", "CreatingMenu for " + v.getClass().getName()); super.onCreateContextMenu(menu, v, menuInfo); // a longPress on an Image is detected // Currently supported Actions are: // - Delete Image if (v instanceof GridView) { menu.setHeaderTitle(getString(R.string.gallery_context_menu_title)); // Delete Option menu.add(Menu.NONE, CONTEXT_IMAGE_ACTION_DELETE, Menu.NONE, getString(R.string.gallery_context_menu_delete)); }/*from ww w. j a v a2 s. c om*/ }
From source file:org.alfresco.mobile.android.application.fragments.node.browser.ProgressNodeAdapter.java
public void getMenu(Menu menu, Node node) { MenuItem mi;/*w w w .j a va 2 s . c o m*/ mi = menu.add(Menu.NONE, R.id.menu_node_details, Menu.FIRST, R.string.action_view_properties); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if (ConfigurableActionHelper.isVisible(getActivity(), SessionUtils.getAccount(getActivity()), SessionUtils.getSession(getActivity()), node, ConfigurableActionHelper.ACTION_NODE_EDIT)) { mi = menu.add(Menu.NONE, R.id.menu_action_edit, Menu.FIRST + 50, R.string.action_edit_properties); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } if (ConfigurableActionHelper.isVisible(getActivity(), SessionUtils.getAccount(getActivity()), SessionUtils.getSession(getActivity()), node, ConfigurableActionHelper.ACTION_NODE_DELETE)) { mi = menu.add(Menu.NONE, R.id.menu_action_delete_folder, Menu.FIRST + 1000, R.string.delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } }