List of usage examples for android.view ContextMenu add
public MenuItem add(CharSequence title);
From source file:org.restcomm.android.olympus.MainFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (v.getId() == android.R.id.list) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; //menu.setHeaderTitle("Edit " + contactList.get(info.position).get(CONTACT_KEY)); // TODO: pretty bad logic, let's revisit this at some point so that we can use style resources instead menu.setHeaderTitle(Html.fromHtml("<font color='#DF3D00'>Settings</font>")); menu.add("Update Contact"); menu.add("Remove Contact"); }// w w w .j a va 2 s . c o m }
From source file:org.tigase.mobile.accountstatus.AccountsStatusFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (!JaxmppService.isServiceActive()) { return;/*from w w w . j ava2s. c om*/ } final int position = extractPosition(menuInfo); Log.v(TAG, "position for context menu element is " + position); if (position == -1) { return; } final Jaxmpp jaxmpp = adapter.getItem(position); if (jaxmpp.isConnected()) { menu.add(R.string.logoutButton).setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { new Thread() { @Override public void run() { try { JaxmppService.disable(jaxmpp.getSessionObject(), true); jaxmpp.disconnect(); ((MessengerApplication) getActivity().getApplication()) .clearPresences(jaxmpp.getSessionObject(), false); } catch (JaxmppException ex) { Log.e(TAG, "error manually disconnecting account " + jaxmpp.getSessionObject().getUserBareJid().toString(), ex); } } }.start(); return true; } }); menu.add(R.string.accountVCard).setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(); intent.setAction("org.tigase.mobile.account.personalInfo.EDIT"); intent.putExtra("account_jid", jaxmpp.getSessionObject().getUserBareJid().toString()); startActivity(intent); return true; } }); menu.add(R.string.pingServer).setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { new Thread() { @Override public void run() { try { PingModule.PingAsyncCallback pong = new PingAsyncCallback() { @Override public void onError(Stanza responseStanza, final ErrorCondition error) throws JaxmppException { FragmentActivity activity = getActivity(); if (activity != null) activity.runOnUiThread(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(getActivity(), "Ping error: " + error, Toast.LENGTH_LONG); toast.show(); } }); } @Override protected void onPong(final long time) { FragmentActivity activity = getActivity(); if (activity != null) activity.runOnUiThread(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(getActivity(), "Pong: " + time + "ms", Toast.LENGTH_LONG); toast.show(); } }); } @Override public void onTimeout() throws JaxmppException { FragmentActivity activity = getActivity(); if (activity != null) activity.runOnUiThread(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(getActivity(), "Ping timeout", Toast.LENGTH_LONG); toast.show(); } }); } }; jaxmpp.getModule(PingModule.class).ping( JID.jidInstance(jaxmpp.getSessionObject().getUserBareJid().getDomain()), pong); } catch (Exception ex) { Log.e(TAG, "error pinging server " + jaxmpp.getSessionObject().getUserBareJid().toString(), ex); } } }.start(); return true; } }); menu.add(R.string.account_advanced_preferences) .setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(); intent.setAction("org.tigase.mobile.account.advancedPreferences.EDIT"); intent.putExtra("account_jid", jaxmpp.getSessionObject().getUserBareJid().toString()); startActivity(intent); return true; } }); } else { menu.add(R.string.loginButton).setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { new Thread() { @Override public void run() { try { JaxmppService.disable(jaxmpp.getSessionObject(), false); jaxmpp.login(); } catch (JaxmppException ex) { Log.e(TAG, "error manually connecting account " + jaxmpp.getSessionObject().getUserBareJid().toString(), ex); } } }.start(); return true; } }); } }
From source file:com.moonpi.swiftnotes.MainActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add(getResources().getString(R.string.action_delete)); }
From source file:org.jsharkey.grouphome.LauncherActivity.java
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (!(v.getTag() instanceof EntryInfo)) return;//from ww w . j a v a 2 s. c o m EntryInfo info = (EntryInfo) v.getTag(); final String packageName = info.resolveInfo.activityInfo.applicationInfo.packageName; menu.setHeaderTitle(info.title); Intent detailsIntent = new Intent(); detailsIntent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); detailsIntent.putExtra("com.android.settings.ApplicationPkgName", packageName); menu.add("App details").setIntent(detailsIntent); Intent deleteIntent = new Intent(Intent.ACTION_DELETE); deleteIntent.setData(Uri.parse("package:" + packageName)); menu.add("Uninstall").setIntent(deleteIntent); }
From source file:net.sourceforge.servestream.fragment.BrowseFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { // create menu to handle stream URLs // create menu to handle deleting and sharing lists final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; final UriBean uri = (UriBean) getListView().getAdapter().getItem(info.position); try {//from w w w . j av a 2 s . c om final String streamURL = uri.getUri().toString(); // set the menu title to the name attribute of the URL link menu.setHeaderTitle(uri.getNickname()); // save the URL android.view.MenuItem save = menu.add(R.string.save_label); save.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(android.view.MenuItem arg0) { // prompt user to make sure they really want this new AlertDialog.Builder(BrowseFragment.this.getActivity()) .setMessage(getString(R.string.url_save_confirmation_msg, streamURL)) .setPositiveButton(R.string.confirm_label, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { saveUri(uri); BrowseFragment.this.getActivity() .sendBroadcast(new Intent(UrlListFragment.UPDATE_LIST)); } }).setNegativeButton(android.R.string.cancel, null).create().show(); return true; } }); // view the URL android.view.MenuItem view = menu.add(R.string.view_url_label); view.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(android.view.MenuItem arg0) { // display the URL new AlertDialog.Builder(BrowseFragment.this.getActivity()).setMessage(streamURL) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }).create().show(); return true; } }); } catch (Exception ex) { ex.printStackTrace(); } // add to playlist android.view.MenuItem add = menu.add(R.string.add_to_playlist_label); add.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(android.view.MenuItem item) { MusicUtils.addToCurrentPlaylistFromURL(BrowseFragment.this.getActivity(), uri, mQueueHandler); return true; } }); // share the URL android.view.MenuItem share = menu.add(R.string.share_label); share.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(android.view.MenuItem item) { String url = uri.getUri().toString(); String appName = getString(R.string.app_name); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_signature, url, appName)); startActivity(Intent.createChooser(intent, getString(R.string.share_label))); return true; } }); }
From source file:org.uguess.android.sysinfo.NetStateManager.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { int pos = ((AdapterContextMenuInfo) menuInfo).position; if (pos > 0) { menu.setHeaderTitle(R.string.actions); menu.add(R.string.copy_ip); }/* w w w.j av a2 s . c o m*/ }
From source file:com.moonpi.tapunlock.MainActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add(getResources().getString(R.string.rename_context_menu)); menu.add(getResources().getString(R.string.delete_context_menu)); }
From source file:roommateapp.info.droid.ActivityBuilding.java
/** * Create the context menu./* w w w . j a v a2 s .c om*/ */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // Set Headline menu.setHeaderTitle(getString(R.string.cmenu_hl)); // Remove default setting, if file was set as default String defaultFile = Preferences.getDefaultFile(getApplicationContext()); if (this.selectedBuilding.getFile().toString().equals(defaultFile)) { menu.add(getString(R.string.cmenu_remstd)); } // Navigation if (!this.selectedBuilding.getLat().equals("") && !this.selectedBuilding.getLng().equals("")) { menu.add(getString(R.string.cmenu_nav)); } // Display building information if (!this.selectedBuilding.getInfo().equals("")) { menu.add(getString(R.string.cmenu_info)); } // Display legend menu.add(getString(R.string.cmenu_legende)); // Display share option menu.add(getString(R.string.cmenu_share)); // Display filter settings menu.add(getString(R.string.cmenu_filter)); }
From source file:com.hughes.android.dictionary.DictionaryManagerActivity.java
@Override public void onCreateContextMenu(final ContextMenu menu, final View view, final ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); Log.d(LOG, "onCreateContextMenu, " + menuInfo); final AdapterContextMenuInfo adapterContextMenuInfo = (AdapterContextMenuInfo) menuInfo; final int position = adapterContextMenuInfo.position; final MyListAdapter.Row row = (MyListAdapter.Row) getListAdapter().getItem(position); if (row.dictionaryInfo == null) { return;//from www.j a v a 2 s .co m } if (position > 0 && row.onDevice) { final android.view.MenuItem moveToTopMenuItem = menu.add(R.string.moveToTop); moveToTopMenuItem.setOnMenuItemClickListener(new android.view.MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(android.view.MenuItem item) { application.moveDictionaryToTop(row.dictionaryInfo); setMyListAdapater(); return true; } }); } if (row.onDevice) { final android.view.MenuItem deleteMenuItem = menu.add(R.string.deleteDictionary); deleteMenuItem.setOnMenuItemClickListener(new android.view.MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(android.view.MenuItem item) { application.deleteDictionary(row.dictionaryInfo); setMyListAdapater(); return true; } }); } }
From source file:com.github.michalbednarski.intentslab.editor.IntentGeneralFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.intent_editor_general, container, false); // Prepare form mActionText = (AutoCompleteTextView) v.findViewById(R.id.action); mActionsSpinner = (Spinner) v.findViewById(R.id.action_spinner); mDataText = (AutoCompleteTextView) v.findViewById(R.id.data); mDataTextWrapper = v.findViewById(R.id.data_wrapper); mDataTextHeader = v.findViewById(R.id.data_header); mDataTypeHeader = v.findViewById(R.id.data_type_header); mDataTypeText = (TextView) v.findViewById(R.id.data_type); mDataTypeSpinner = (Spinner) v.findViewById(R.id.data_type_spinner); mDataTypeSpinnerWrapper = v.findViewById(R.id.data_type_spinner_wrapper); mDataTypeSlash = v.findViewById(R.id.data_type_slash); mDataSubtypeText = (TextView) v.findViewById(R.id.data_type_after_slash); mComponentText = (TextView) v.findViewById(R.id.component); mComponentTypeSpinner = (Spinner) v.findViewById(R.id.componenttype); mComponentTypeSpinner.setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.componenttypes))); mMethodSpinner = (Spinner) v.findViewById(R.id.method); mCategoriesContainer = (ViewGroup) v.findViewById(R.id.categories); mAddCategoryButton = (Button) v.findViewById(R.id.category_add); mCategoriesHeader = v.findViewById(R.id.categories_header); mResponseCodeTextView = (TextView) v.findViewById(R.id.response_code); mPackageNameText = (AutoCompleteTextView) v.findViewById(R.id.package_name); mResultCodeWrapper = v.findViewById(R.id.result_intent_wrapper); mComponentTypeAndMethodSpinners = v.findViewById(R.id.component_and_method_spinners); mComponentHeader = v.findViewById(R.id.component_header); mComponentFieldWithButtons = v.findViewById(R.id.component_field_with_buttons); mPackageNameHeader = v.findViewById(R.id.package_name_header); mIntentTrackerSummary = (TextView) v.findViewById(R.id.intent_tracker_summary); mIntentTrackerSummary.setMovementMethod(LinkMovementMethod.getInstance()); // Apparently using android:scrollHorizontally="true" does not work. // http://stackoverflow.com/questions/9011944/android-ice-cream-sandwich-edittext-disabling-spell-check-and-word-wrap mComponentText.setHorizontallyScrolling(true); // Bind button actions (android:onClick="" applies to hosting activity) mAddCategoryButton.setOnClickListener(new OnClickListener() { @Override/*from w w w. j av a 2 s .co m*/ public void onClick(View v) { addCategoryTextField(""); } }); v.findViewById(R.id.component_pick).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pickComponent(); } }); v.findViewById(R.id.component_pick).setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { findComponent(); return true; } }); v.findViewById(R.id.component_clear).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mComponentText.setText(""); } }); v.findViewById(R.id.data_query_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getIntentEditor().updateIntent(); startActivity( new Intent(getActivity(), AdvancedQueryActivity.class).setData(mEditedIntent.getData())); } }); v.findViewById(R.id.data_query_button) .setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { getIntentEditor().updateIntent(); final Uri uri = mEditedIntent.getData(); if (uri != null) { final String scheme = uri.getScheme(); final String authority = uri.getAuthority(); if ("content".equals(scheme) && authority != null) { menu.add("Wrap").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mDataText.setText("content://" + ((mEditedIntent.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0 ? ProxyProviderForGrantUriPermission.AUTHORITY : ProxyProvider.AUTHORITY) + "/" + authority + uri.getPath()); return true; } }); } } } }); // Set up autocomplete mUriAutocompleteAdapter = new UriAutocompleteAdapter(getActivity()); mDataText.setAdapter(mUriAutocompleteAdapter); mPackageNameText.setAdapter(new PackageNameAutocompleteAdapter(getActivity())); // Get edited intent for form filling mEditedIntent = getEditedIntent(); // Component field, affects options menu if (mEditedIntent.getComponent() != null) { mComponentText.setText(mEditedIntent.getComponent().flattenToShortString()); } mComponentText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateIntentComponent(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); // Fill the form setupActionSpinnerOrField(); updateNonActionIntentFilter(true); mDataText.setText(mEditedIntent.getDataString()); mPackageNameText.setText(mEditedIntent.getPackage()); showOrHideFieldsForResultIntent(); showOrHideAdvancedFields(); if (getComponentType() == IntentEditorConstants.RESULT) { mResponseCodeTextView.setText(String.valueOf(getIntentEditor().getMethodId())); mResponseCodeTextView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { try { getIntentEditor().setMethodId(Integer.parseInt(s.toString())); mResponseCodeTextView.setError(null); } catch (NumberFormatException e) { mResponseCodeTextView.setError(getIntentEditor().getText(R.string.value_parse_error)); } } @Override public void afterTextChanged(Editable s) { } }); } else { initComponentAndMethodSpinners(); } setupActionAutocomplete(); // Prepare intent tracker { IntentTracker tracker = getIntentEditor().getIntentTracker(); if (tracker != null) { tracker.setUpdateListener(this, true); } else { onNoTracker(); } } return v; }