Java Code Examples for android.view.ContextMenu#size()
The following examples show how to use
android.view.ContextMenu#size() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogRecyclerViewAdapter.java From OpenLibre with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { MenuInflater inflater = new MenuInflater(itemView.getContext()); inflater.inflate(R.menu.menu_log_item_context, menu); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setOnMenuItemClickListener(this); } }
Example 2
Source File: ChromeContextMenuPopulator.java From delion with Apache License 2.0 | 5 votes |
private void removeUnsupportedItems(ContextMenu menu, int[] whitelist) { Arrays.sort(BASE_WHITELIST); Arrays.sort(whitelist); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (Arrays.binarySearch(whitelist, item.getItemId()) < 0 && Arrays.binarySearch(BASE_WHITELIST, item.getItemId()) < 0) { menu.removeItem(item.getItemId()); i--; } } }
Example 3
Source File: ChromeContextMenuPopulator.java From AndroidChromium with Apache License 2.0 | 5 votes |
private void removeUnsupportedItems(ContextMenu menu, int[] whitelist) { Arrays.sort(BASE_WHITELIST); Arrays.sort(whitelist); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (Arrays.binarySearch(whitelist, item.getItemId()) < 0 && Arrays.binarySearch(BASE_WHITELIST, item.getItemId()) < 0) { menu.removeItem(item.getItemId()); i--; } } }
Example 4
Source File: RecordingsAdapter.java From go-bees with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) { // Inflate menu menuInflater.inflate(R.menu.recording_item_menu, contextMenu); // Set click listener for (int i = 0; i < contextMenu.size(); i++) { contextMenu.getItem(i).setOnMenuItemClickListener(this); } }
Example 5
Source File: ApiariesAdapter.java From go-bees with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) { // Inflate menu menuInflater.inflate(R.menu.apiary_item_menu, contextMenu); // Set click listener for (int i = 0; i < contextMenu.size(); i++) { contextMenu.getItem(i).setOnMenuItemClickListener(this); } }
Example 6
Source File: HivesAdapter.java From go-bees with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) { // Inflate menu menuInflater.inflate(R.menu.hive_item_menu, contextMenu); // Set click listener for (int i = 0; i < contextMenu.size(); i++) { contextMenu.getItem(i).setOnMenuItemClickListener(this); } }
Example 7
Source File: MenuFragment.java From ticdesign with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v) { MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.default_hint, menu); int count = (Integer) v.getTag(); for (int i = menu.size(); i > count; i--) { MenuItem item = menu.getItem(i - 1); menu.removeItem(item.getItemId()); } }
Example 8
Source File: AppListFragment.java From Shelter with Do What The F*ck You Want To Public License | 4 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (mSelectedApp == null) return; if (mIsRemote) { if (!mSelectedApp.isSystem()) menu.add(Menu.NONE, MENU_ITEM_CLONE, Menu.NONE, R.string.clone_to_main_profile); // Freezing / Unfreezing is only available in profiles that we can control if (mSelectedApp.isHidden()) { menu.add(Menu.NONE, MENU_ITEM_UNFREEZE, Menu.NONE, R.string.unfreeze_app); menu.add(Menu.NONE, MENU_ITEM_LAUNCH, Menu.NONE, R.string.unfreeze_and_launch); } else { menu.add(Menu.NONE, MENU_ITEM_FREEZE, Menu.NONE, R.string.freeze_app); menu.add(Menu.NONE, MENU_ITEM_LAUNCH, Menu.NONE, R.string.launch); } // Cross-profile widget settings is also limited to work profile MenuItem crossProfileWdiegt = menu.add(Menu.NONE, MENU_ITEM_ALLOW_CROSS_PROFILE_WIDGET, Menu.NONE, R.string.allow_cross_profile_widgets); crossProfileWdiegt.setCheckable(true); crossProfileWdiegt.setChecked( mCrossProfileWidgetProviders.contains(mSelectedApp.getPackageName())); // TODO: If we implement God Mode (i.e. Shelter as device owner), we should // TODO: use two different lists to store auto freeze apps because we'll be // TODO: able to freeze apps in main profile. MenuItem autoFreeze = menu.add(Menu.NONE, MENU_ITEM_AUTO_FREEZE, Menu.NONE, R.string.auto_freeze); autoFreeze.setCheckable(true); autoFreeze.setChecked( LocalStorageManager.getInstance().stringListContains( LocalStorageManager.PREF_AUTO_FREEZE_LIST_WORK_PROFILE, mSelectedApp.getPackageName())); menu.add(Menu.NONE, MENU_ITEM_CREATE_UNFREEZE_SHORTCUT, Menu.NONE, R.string.create_unfreeze_shortcut); } else { menu.add(Menu.NONE, MENU_ITEM_CLONE, Menu.NONE, R.string.clone_to_work_profile); } if (!mSelectedApp.isSystem()) { // We can't uninstall system apps in both cases // but we'll be able to "freeze" them menu.add(Menu.NONE, MENU_ITEM_UNINSTALL, Menu.NONE, R.string.uninstall_app); } if (menu.size() > 0) { // Only set title when the menu is not empty // this ensures that no menu will be shown // if no operation available menu.setHeaderTitle( getString(R.string.app_context_menu_title, mSelectedApp.getLabel())); } }
Example 9
Source File: LongPressNetworkHook.java From WiFiKeyView with Apache License 2.0 | 4 votes |
@Override public void afterHookedMethod(MethodHookParam param) { WiFiKeyView.verboseLog(this, "afterHookedMethod(MethodHookParam)", "Injecting context menu item..."); // Get the context menu from the arguments ContextMenu menu = null; try { menu = ((ContextMenu) param.args[0]); } catch (ClassCastException cce) { // Another method was hooked, otherwise the footprint would have been the same, // something went horribly wrong here cce.printStackTrace(); } // Without the menu, there is nothing to do if (menu == null) { WiFiKeyView.verboseLog(this, "afterHookedMethod(MethodHookParam)", "Could not find ContextMenu in parameter -> null!"); return; } /* * If an network is not known there is only 1 option * 1. Connect * * If an network is already known there are 2 options for the menu items: * 1. Connect, Modify, Forget -> When not connected to the network * 2. Modify, Forget -> When connected to the network * * As we can only see the password previously entered, this only supports known networks */ int size = menu.size(); if ( (size == 2) || (size == 3) ) { menu.add( Menu.NONE, // Group (not used/needed) MENU_ID_SHOWPASSWORD, // Id (of the item) Menu.NONE, // Order (not used/needed) mContext.getString(R.string.menu_option_show_password) // Text (for display in the item) ); if (debug) { WiFiKeyView.verboseLog(this, "afterHookedMethod(MethodHookParam)", "Show password added to Context menu."); } } }