Java Code Examples for android.view.ContextMenu

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project and-bible, under directory /AndBible/src/net/bible/android/control/page/.

Source file: CurrentPageBase.java

  18 
vote

@Override public void updateContextMenu(Menu menu){
  menu.findItem(R.id.notes).setVisible(false);
  menu.findItem(R.id.myNoteAddEdit).setVisible(false);
  menu.findItem(R.id.add_bookmark).setVisible(true);
  menu.findItem(R.id.compareTranslations).setVisible(false);
  if (getSingleKey() != null) {
    ContextMenu contextMenu=(ContextMenu)menu;
    contextMenu.setHeaderTitle(getSingleKey().getName());
  }
}
 

Example 2

From project aksunai, under directory /src/org/androidnerds/app/aksunai/.

Source file: Aksunai.java

  16 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo i){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)i;
  if (info.position == 0) {
    return;
  }
  menu.setHeaderTitle(R.string.menu_server_options);
  menu.add(R.string.connect);
  menu.add(R.string.edit);
  menu.add(R.string.remove);
}
 

Example 3

From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.

Source file: AAMain.java

  15 
vote

/** 
 * Creates a list of options when long pressing an item that has been registered for a context menu
 */
@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  selectedView=v;
  Article article=(Article)v.getTag();
  menu.add(ContextMenu.NONE,OPEN,0,"Open");
  menu.add(ContextMenu.NONE,SHARE,1,"Share");
  if (article.isRead())   menu.add(ContextMenu.NONE,MARK,1,"Mark as unread");
 else   menu.add(ContextMenu.NONE,MARK,1,"Mark as read");
}
 

Example 4

From project ActionBarSherlock, under directory /samples/demos/src/com/actionbarsherlock/sample/demos/.

Source file: ContextMenus.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  menu.add("One");
  menu.add("Two");
  menu.add("Three");
  menu.add("Four");
}
 

Example 5

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.

Source file: RelationsActivity.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override public void onCreateContextMenu(final ContextMenu menu,final View v,final ContextMenuInfo menuInfo){
  ExpandableListContextMenuInfo info=(ExpandableListContextMenuInfo)menuInfo;
  if (ExpandableListView.getPackedPositionType(info.packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
    boolean isFooterView=true;
    try {
      isFooterView=(Boolean)info.targetView.getTag(R.attr.IsFooterView);
    }
 catch (    NullPointerException e) {
      e.printStackTrace();
    }
    if (!isFooterView) {
      getMenuInflater().inflate(R.menu.list_context_menu,menu);
    }
  }
}
 

Example 6

From project Android-automation, under directory /TmtsApp/src/com/taobao/tmts/framework/app/.

Source file: ListViewActivity.java

  15 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.listview_layout);
  ListView listview=(ListView)findViewById(R.id.my_listview);
  ArrayList<HashMap<String,Object>> listitem=new ArrayList<HashMap<String,Object>>();
  for (int i=0; i < 100; i++) {
    HashMap<String,Object> map=new HashMap<String,Object>();
    map.put("itemimage",R.drawable.icon);
    map.put("itemTitle","Item" + i);
    map.put("itemText","Thank you!");
    listitem.add(map);
  }
  SimpleAdapter listitemAdapter=new SimpleAdapter(this,listitem,R.layout.listview_item_layout,new String[]{"itemimage","itemTitle","itemText"},new int[]{R.id.ItemImage,R.id.ItemTitle,R.id.ItemText});
  listview.setAdapter(listitemAdapter);
  listview.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
    }
  }
);
  listview.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
    @Override public void onCreateContextMenu(    ContextMenu menu,    View v,    ContextMenuInfo menuInfo){
      menu.setHeaderTitle("Hello");
      menu.add(0,0,0,"Item One");
      menu.add(0,1,0,"Item Two");
    }
  }
);
}
 

Example 7

From project android-client_1, under directory /src/com/buddycloud/view/.

Source file: RosterActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  getMenuInflater().inflate(R.menu.roster_context,menu);
  Intent openChannel=new Intent();
  openChannel.setClassName("com.buddycloud.android.buddydroid",ChannelMessageActivity.class.getCanonicalName());
  Cursor buddy=(Cursor)listAdapter.getItem(((AdapterContextMenuInfo)menuInfo).position);
  String jid=buddy.getString(buddy.getColumnIndex(Roster.JID));
  openChannel.setData(Uri.parse("channel:" + jid));
  menu.findItem(R.id.open_channel).setIntent(openChannel);
  super.onCreateContextMenu(menu,v,menuInfo);
}
 

Example 8

From project Android-FFXIEQ, under directory /ffxieq/src/com/github/kanata3249/ffxieq/android/.

Source file: AugmentSelectorActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.augmentselector_context,menu);
  MenuItem item=menu.findItem(R.id.DeleteAugment);
  if (item != null) {
    item.setEnabled(mLongClickingItemId != mAugID);
  }
}
 

Example 9

From project Android-File-Manager, under directory /src/com/nexes/manager/.

Source file: Main.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo info){
  super.onCreateContextMenu(menu,v,info);
  boolean multi_data=mHandler.hasMultiSelectData();
  AdapterContextMenuInfo _info=(AdapterContextMenuInfo)info;
  mSelectedListItem=mHandler.getData(_info.position);
  if (mFileMag.isDirectory(mSelectedListItem) && !mHandler.isMultiSelected()) {
    menu.setHeaderTitle("Folder operations");
    menu.add(0,D_MENU_DELETE,0,"Delete Folder");
    menu.add(0,D_MENU_RENAME,0,"Rename Folder");
    menu.add(0,D_MENU_COPY,0,"Copy Folder");
    menu.add(0,D_MENU_MOVE,0,"Move(Cut) Folder");
    menu.add(0,D_MENU_ZIP,0,"Zip Folder");
    menu.add(0,D_MENU_PASTE,0,"Paste into folder").setEnabled(mHoldingFile || multi_data);
    menu.add(0,D_MENU_UNZIP,0,"Extract here").setEnabled(mHoldingZip);
  }
 else   if (!mFileMag.isDirectory(mSelectedListItem) && !mHandler.isMultiSelected()) {
    menu.setHeaderTitle("File Operations");
    menu.add(0,F_MENU_DELETE,0,"Delete File");
    menu.add(0,F_MENU_RENAME,0,"Rename File");
    menu.add(0,F_MENU_COPY,0,"Copy File");
    menu.add(0,F_MENU_MOVE,0,"Move(Cut) File");
    menu.add(0,F_MENU_ATTACH,0,"Email File");
  }
}
 

Example 10

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.

Source file: CaptureActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  if (v.equals(ocrResultView)) {
    menu.add(Menu.NONE,OPTIONS_COPY_RECOGNIZED_TEXT_ID,Menu.NONE,"Copy recognized text");
    menu.add(Menu.NONE,OPTIONS_SHARE_RECOGNIZED_TEXT_ID,Menu.NONE,"Share recognized text");
  }
 else   if (v.equals(translationView)) {
    menu.add(Menu.NONE,OPTIONS_COPY_TRANSLATED_TEXT_ID,Menu.NONE,"Copy translated text");
    menu.add(Menu.NONE,OPTIONS_SHARE_TRANSLATED_TEXT_ID,Menu.NONE,"Share translated text");
  }
}
 

Example 11

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/list/activity/.

Source file: AbstractListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  ClassCastException e) {
    Log.e(cTag,"bad menuInfo",e);
    return;
  }
  Cursor cursor=(Cursor)getListAdapter().getItem(info.position);
  if (cursor == null) {
    return;
  }
  menu.setHeaderTitle(cursor.getString(1));
  Uri selectedUri=ContentUris.withAppendedId(getListConfig().getPersister().getContentUri(),info.id);
  MenuUtils.addSelectedAlternativeMenuItems(menu,selectedUri,false);
  MenuUtils.addDeleteMenuItem(menu);
}
 

Example 12

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.

Source file: Term.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  menu.setHeaderTitle(R.string.edit_text);
  menu.add(0,SELECT_TEXT_ID,0,R.string.select_text);
  menu.add(0,COPY_ALL_ID,0,R.string.copy_all);
  menu.add(0,PASTE_ID,0,R.string.paste);
  menu.add(0,SEND_CONTROL_KEY_ID,0,R.string.send_control_key);
  menu.add(0,SEND_FN_KEY_ID,0,R.string.send_fn_key);
  if (!canPaste()) {
    menu.getItem(PASTE_ID).setEnabled(false);
  }
}
 

Example 13

From project android-thaiime, under directory /common/src/com/android/ex/editstyledtext/.

Source file: EditStyledText.java

  15 
vote

@Override protected void onCreateContextMenu(ContextMenu menu){
  super.onCreateContextMenu(menu);
  MenuHandler handler=new MenuHandler();
  if (STR_HORIZONTALLINE != null) {
    menu.add(0,ID_HORIZONTALLINE,0,STR_HORIZONTALLINE).setOnMenuItemClickListener(handler);
  }
  if (isStyledText() && STR_CLEARSTYLES != null) {
    menu.add(0,ID_CLEARSTYLES,0,STR_CLEARSTYLES).setOnMenuItemClickListener(handler);
  }
  if (mManager.canPaste()) {
    menu.add(0,ID_PASTE,0,STR_PASTE).setOnMenuItemClickListener(handler).setAlphabeticShortcut('v');
  }
}
 

Example 14

From project android-vpn-settings, under directory /src/com/android/settings/vpn/.

Source file: VpnSettings.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  VpnProfile p=getProfile(getProfilePositionFrom((AdapterContextMenuInfo)menuInfo));
  if (p != null) {
    VpnState state=p.getState();
    menu.setHeaderTitle(p.getName());
    boolean isIdle=(state == VpnState.IDLE);
    boolean isNotConnect=(isIdle || (state == VpnState.DISCONNECTING) || (state == VpnState.CANCELLED));
    menu.add(0,CONTEXT_MENU_CONNECT_ID,0,R.string.vpn_menu_connect).setEnabled(isIdle && (mActiveProfile == null));
    menu.add(0,CONTEXT_MENU_DISCONNECT_ID,0,R.string.vpn_menu_disconnect).setEnabled(state == VpnState.CONNECTED);
    menu.add(0,CONTEXT_MENU_EDIT_ID,0,R.string.vpn_menu_edit).setEnabled(isNotConnect);
    menu.add(0,CONTEXT_MENU_DELETE_ID,0,R.string.vpn_menu_delete).setEnabled(isNotConnect);
  }
}
 

Example 15

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/activity/.

Source file: MovieLibraryActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
switch (mTabHost.getCurrentTab()) {
case 0:
    mMovieController.onCreateContextMenu(menu,v,menuInfo);
  break;
case 1:
mActorController.onCreateContextMenu(menu,v,menuInfo);
break;
case 2:
mGenresController.onCreateContextMenu(menu,v,menuInfo);
break;
case 3:
mFileController.onCreateContextMenu(menu,v,menuInfo);
break;
}
}
 

Example 16

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/activity/.

Source file: ShelvesActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  menu.setHeaderTitle(((TextView)info.targetView).getText());
  getMenuInflater().inflate(R.menu.book,menu);
}
 

Example 17

From project Android_1, under directory /PropagatedIntents/src/com/example/android/notepad/.

Source file: NotesList.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  ClassCastException e) {
    Log.e(TAG,"bad menuInfo",e);
    return;
  }
  Cursor cursor=(Cursor)getListAdapter().getItem(info.position);
  if (cursor == null) {
    return;
  }
  menu.setHeaderTitle(cursor.getString(COLUMN_INDEX_TITLE));
  menu.add(0,MENU_ITEM_DELETE,0,R.string.menu_delete);
}
 

Example 18

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/bluetooth/.

Source file: BluetoothSettings.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  if (mScreenType != SCREEN_TYPE_SETTINGS) {
    return;
  }
  CachedBluetoothDevice cachedDevice=getDeviceFromMenuInfo(menuInfo);
  if (cachedDevice == null)   return;
  cachedDevice.onCreateContextMenu(menu);
}
 

Example 19

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: GestureListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  menu.setHeaderTitle(((TextView)info.targetView).getText());
  menu.add(0,MENU_ID_REMOVE,0,R.string.gestures_delete);
}
 

Example 20

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: GalleryPicker.java

  15 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.gallerypicker);
  mGridView=(GridView)findViewById(R.id.albums);
  mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      launchFolderGallery(position);
    }
  }
);
  mGridView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener(){
    public void onCreateContextMenu(    ContextMenu menu,    View v,    final ContextMenuInfo menuInfo){
      onCreateGalleryPickerContextMenu(menu,menuInfo);
    }
  }
);
  mReceiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      onReceiveMediaBroadcast(intent);
    }
  }
;
  mDbObserver=new ContentObserver(mHandler){
    @Override public void onChange(    boolean selfChange){
      rebake(false,ImageManager.isMediaScannerScanning(getContentResolver()));
    }
  }
;
  ImageManager.ensureOSXCompatibleFolder();
}
 

Example 21

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: SimContacts.java

  15 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case MENU_IMPORT_ONE:
    ContextMenu.ContextMenuInfo menuInfo=item.getMenuInfo();
  if (menuInfo instanceof AdapterView.AdapterContextMenuInfo) {
    int position=((AdapterView.AdapterContextMenuInfo)menuInfo).position;
    importOneSimContact(position);
    return true;
  }
}
return super.onContextItemSelected(item);
}
 

Example 22

From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/.

Source file: MyTagList.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo info){
  Cursor cursor=mAdapter.getCursor();
  if (cursor == null || cursor.isClosed() || !cursor.moveToPosition(((AdapterContextMenuInfo)info).position)) {
    return;
  }
  menu.setHeaderTitle(cursor.getString(TagQuery.COLUMN_TITLE));
  long id=cursor.getLong(TagQuery.COLUMN_ID);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.my_tag_list_context_menu,menu);
  menu.findItem(R.id.set_as_active).setVisible(id != mActiveTagId);
  mTagIdLongPressed=id;
  if (mWriteSupport) {
    menu.add(0,1,0,"Write to tag");
  }
}
 

Example 23

From project andtweet, under directory /src/com/xorcode/andtweet/.

Source file: TweetListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,view,menuInfo);
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  ClassCastException e) {
    Log.e(TAG,"bad menuInfo",e);
    return;
  }
  int m=0;
  menu.add(0,CONTEXT_MENU_ITEM_REPLY,m++,R.string.menu_item_reply);
  menu.add(0,CONTEXT_MENU_ITEM_RETWEET,m++,R.string.menu_item_retweet);
  Uri uri=ContentUris.withAppendedId(Tweets.CONTENT_URI,info.id);
  Cursor c=getContentResolver().query(uri,new String[]{Tweets._ID,Tweets.MESSAGE,Tweets.AUTHOR_ID,Tweets.FAVORITED},null,null,null);
  try {
    c.moveToFirst();
    menu.setHeaderTitle(c.getString(c.getColumnIndex(Tweets.MESSAGE)));
    if (c.getInt(c.getColumnIndex(Tweets.FAVORITED)) == 1) {
      menu.add(0,CONTEXT_MENU_ITEM_DESTROY_FAVORITE,m++,R.string.menu_item_destroy_favorite);
    }
 else {
      menu.add(0,CONTEXT_MENU_ITEM_FAVORITE,m++,R.string.menu_item_favorite);
    }
    if (AndTweetPreferences.getDefaultSharedPreferences().getString(PreferencesActivity.KEY_TWITTER_USERNAME,null).equals(c.getString(c.getColumnIndex(Tweets.AUTHOR_ID)))) {
      menu.add(0,CONTEXT_MENU_ITEM_DESTROY_STATUS,m++,R.string.menu_item_destroy_status);
    }
  }
 catch (  Exception e) {
    Log.e(TAG,"onCreateContextMenu: " + e.toString());
  }
 finally {
    if (c != null && !c.isClosed())     c.close();
  }
}
 

Example 24

From project Anki-Android, under directory /src/com/ichi2/anki/.

Source file: SharedDeckPicker.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  Resources res=getResources();
  int position=((AdapterContextMenuInfo)menuInfo).position;
  Object obj=mAllSharedDecks.get(position);
  if (obj instanceof Download) {
    Download download=(Download)obj;
    menu.add(Menu.NONE,MENU_CANCEL,Menu.NONE,res.getString(R.string.cancel_download));
    if (download.getStatus() == SharedDeckDownload.STATUS_PAUSED) {
      menu.add(Menu.NONE,MENU_RESUME,Menu.NONE,res.getString(R.string.resume_download));
    }
 else     if (download.getStatus() == SharedDeckDownload.STATUS_UPDATING) {
      menu.add(Menu.NONE,MENU_PAUSE,Menu.NONE,res.getString(R.string.pause_download));
    }
  }
}
 

Example 25

From project apg, under directory /src/org/thialfihar/android/apg/.

Source file: MainActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  TextView nameTextView=(TextView)v.findViewById(R.id.accountName);
  if (nameTextView != null) {
    menu.setHeaderTitle(nameTextView.getText());
    menu.add(0,Id.menu.delete,0,R.string.menu_deleteAccount);
  }
}
 

Example 26

From project apps-for-android, under directory /Photostream/src/com/google/android/photostream/.

Source file: LoginActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  menu.setHeaderTitle(((TextView)info.targetView).getText());
  menu.add(0,MENU_ID_SHOW,0,R.string.context_menu_show_photostream);
  menu.add(0,MENU_ID_DELETE,0,R.string.context_menu_delete_user);
}
 

Example 27

From project BF3-Battlelog, under directory /src/com/ninetwozero/battlelog/activity/feed/.

Source file: FeedFragment.java

  15 
vote

public void createContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  FeedItem feedItem=(FeedItem)info.targetView.getTag();
  menu.add(Constants.MENU_ID_FEED,CONTEXT_ID_HOOAH,0,feedItem.isLiked() ? R.string.label_unhooah : R.string.label_hooah);
  if (feedItem.getNumLikes() > 0) {
    menu.add(Constants.MENU_ID_FEED,CONTEXT_ID_VIEW_HOOAH,0,"View hooahs");
  }
  menu.add(Constants.MENU_ID_FEED,CONTEXT_ID_SINGLE,0,R.string.label_single_post_view);
}
 

Example 28

From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/.

Source file: Birthday.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  menu.setHeaderTitle(R.string.context_menu_header);
  Event item=listOfContacts.get(((AdapterContextMenuInfo)menuInfo).position);
  MenuItem callItem=menu.add(R.string.context_menu_call).setEnabled(false);
  MenuItem smstItem=menu.add(R.string.context_menu_text).setEnabled(false);
  MenuItem emailItem=menu.add(R.string.context_menu_email).setEnabled(false);
  String phone=BirthdayProvider.getPhoneNumber(this,item.getContactId());
  if (phone != null) {
    smstItem.setEnabled(true);
    Intent smsIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("sms:" + phone));
    smsIntent.putExtra("sms_body",Utils.getCongrats(this,item));
    smstItem.setIntent(smsIntent);
    callItem.setEnabled(true);
    Intent callIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("tel:" + phone));
    callItem.setIntent(callIntent);
  }
  String email=BirthdayProvider.getEmail(this,item.getContactId());
  if (email != null) {
    emailItem.setEnabled(true);
    String subject=getString(R.string.congrats_subject);
    String body=Utils.getCongrats(this,item);
    Intent mailer=new Intent(Intent.ACTION_SEND);
    mailer.setType("text/plain");
    mailer.putExtra(Intent.EXTRA_EMAIL,new String[]{email});
    mailer.putExtra(Intent.EXTRA_SUBJECT,subject);
    mailer.putExtra(Intent.EXTRA_TEXT,body);
    emailItem.setIntent(mailer);
  }
}
 

Example 29

From project BombusLime, under directory /src/org/bombusim/lime/fragments/.

Source file: ChatFragment.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  menu.setHeaderTitle(R.string.messageMenuTitle);
  MenuInflater inflater=getActivity().getMenuInflater();
  inflater.inflate(R.menu.message_menu,menu);
}
 

Example 30

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: BookCatalogueClassic.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  ExpandableListView.ExpandableListContextMenuInfo info=(ExpandableListView.ExpandableListContextMenuInfo)menuInfo;
  try {
    if (ExpandableListView.getPackedPositionType(info.packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
      MenuItem delete=menu.add(0,DELETE_ID,0,R.string.menu_delete);
      delete.setIcon(android.R.drawable.ic_menu_delete);
      MenuItem edit_book=menu.add(0,EDIT_BOOK,0,R.string.edit_book);
      edit_book.setIcon(android.R.drawable.ic_menu_edit);
      MenuItem edit_book_notes=menu.add(0,EDIT_BOOK_NOTES,0,R.string.edit_book_notes);
      edit_book_notes.setIcon(R.drawable.ic_menu_compose);
      MenuItem edit_book_friends=menu.add(0,EDIT_BOOK_FRIENDS,0,R.string.edit_book_friends);
      edit_book_friends.setIcon(R.drawable.ic_menu_cc);
      MenuItem edit_book_send_to_gr=menu.add(0,EDIT_BOOK_SEND_TO_GR,0,R.string.edit_book_send_to_gr);
      edit_book_send_to_gr.setIcon(R.drawable.ic_menu_cc);
    }
 else     if (ExpandableListView.getPackedPositionType(info.packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
switch (sort) {
case SORT_AUTHOR:
case SORT_AUTHOR_GIVEN:
{
          MenuItem edit_book=menu.add(0,EDIT_AUTHOR_ID,0,R.string.menu_edit_author);
          edit_book.setIcon(android.R.drawable.ic_menu_edit);
          break;
        }
case SORT_SERIES:
{
        MenuItem delete=menu.add(0,DELETE_SERIES_ID,0,R.string.menu_delete_series);
        delete.setIcon(android.R.drawable.ic_menu_delete);
        MenuItem edit_book=menu.add(0,EDIT_SERIES_ID,0,R.string.menu_edit_series);
        edit_book.setIcon(android.R.drawable.ic_menu_edit);
        break;
      }
  }
}
}
 catch (NullPointerException e) {
Logger.logError(e);
}
}
 

Example 31

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/ui/.

Source file: ScriptActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  if (view.getId() == R.id.brick_list_view) {
    menu.setHeaderTitle(R.string.script_context_menu_title);
    if (adapter.getItem(listView.getTouchedListPosition()) instanceof Script) {
      scriptToEdit=(Script)adapter.getItem(listView.getTouchedListPosition());
      MenuInflater inflater=getMenuInflater();
      inflater.inflate(R.menu.script_menu,menu);
    }
  }
}
 

Example 32

From project cmsandroid, under directory /src/com/zia/freshdocs/activity/.

Source file: HostsActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  HostAdapter adapter=(HostAdapter)getListAdapter();
  CMISHost host=adapter.getItem(((AdapterContextMenuInfo)menuInfo).position);
  if (!host.getId().equals(Constants.NEW_HOST_ID)) {
    MenuInflater inflater=getMenuInflater();
    inflater.inflate(R.menu.host_context_menu,menu);
  }
}
 

Example 33

From project COSsettings, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: GestureListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  menu.setHeaderTitle(((TextView)info.targetView).getText());
  menu.add(0,MENU_ID_REMOVE,0,R.string.gestures_delete);
}
 

Example 34

From project creamed_glacier_app_settings, under directory /src/com/android/settings/vpn2/.

Source file: VpnSettings.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo info){
  if (mDialog != null) {
    Log.v(TAG,"onCreateContextMenu() is called when mDialog != null");
    return;
  }
  if (info instanceof AdapterContextMenuInfo) {
    Preference preference=(Preference)getListView().getItemAtPosition(((AdapterContextMenuInfo)info).position);
    if (preference instanceof VpnPreference) {
      VpnProfile profile=((VpnPreference)preference).getProfile();
      mSelectedKey=profile.key;
      menu.setHeaderTitle(profile.name);
      menu.add(Menu.NONE,R.string.vpn_menu_edit,0,R.string.vpn_menu_edit);
      menu.add(Menu.NONE,R.string.vpn_menu_delete,0,R.string.vpn_menu_delete);
    }
  }
}
 

Example 35

From project daily-money, under directory /dailymoney/src/com/bottleworks/dailymoney/ui/.

Source file: AccountDetailListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  if (v.getId() == R.id.accdetlist_list) {
    getMenuInflater().inflate(R.menu.accdetlist_ctxmenu,menu);
  }
}
 

Example 36

From project Diktofon, under directory /app/src/kaljurand_at_gmail_dot_com/diktofon/activity/.

Source file: RecordingListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.cm_notes,menu);
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  final Recording note=(Recording)mListView.getItemAtPosition(info.position);
  if (!note.needsTrans()) {
    MenuItem menuItem=menu.findItem(R.id.cm_notes_transcribe);
    menuItem.setEnabled(false);
  }
}
 

Example 37

From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/.

Source file: BrowseActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  menu.setHeaderTitle(items.get((int)info.id).mainText());
  android.view.MenuItem addItem=menu.add(ContextMenu.NONE,ADD,0,getResources().getString(irAdd));
  addItem.setOnMenuItemClickListener(this);
  android.view.MenuItem addAndReplaceItem=menu.add(ContextMenu.NONE,ADDNREPLACE,0,R.string.addAndReplace);
  addAndReplaceItem.setOnMenuItemClickListener(this);
  android.view.MenuItem addAndPlayItem=menu.add(ContextMenu.NONE,ADDNPLAY,0,R.string.addAndPlay);
  addAndPlayItem.setOnMenuItemClickListener(this);
}
 

Example 38

From project DroidExpenses, under directory /de.simtem.android.expenses/src/de/simtem/android/expenses/.

Source file: Accounts.java

  15 
vote

/** 
 * @see Activity#onCreateContextMenu(ContextMenu,View,ContextMenuInfo)
 */
@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  int position=((AdapterContextMenuInfo)menuInfo).position;
  Account account=accounts.getItem(position);
  if (account != null) {
    getMenuInflater().inflate(R.menu.account_context,menu);
    menu.setHeaderTitle(account.getName());
  }
}
 

Example 39

From project dungbeetle, under directory /src/edu/stanford/mobisocial/dungbeetle/.

Source file: GroupsActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  Cursor cursor=(Cursor)mGroups.getItem(info.position);
  final Group g=new Group(cursor);
  menu.setHeaderTitle(g.name);
  String[] menuItems=new String[]{"Delete"};
  for (int i=0; i < menuItems.length; i++) {
    menu.add(Menu.NONE,i,i,menuItems[i]);
  }
}
 

Example 40

From project ElectricSleep, under directory /src/com/androsz/electricsleepbeta/alarmclock/.

Source file: AlarmClock.java

  15 
vote

@Override public void onCreateContextMenu(final ContextMenu menu,final View view,final ContextMenuInfo menuInfo){
  menu.add(android.view.Menu.NONE,R.id.enable_alarm,android.view.Menu.NONE,R.string.enable_alarm);
  menu.add(android.view.Menu.NONE,R.id.edit_alarm,android.view.Menu.NONE,R.string.menu_edit_alarm);
  menu.add(android.view.Menu.NONE,R.id.delete_alarm,android.view.Menu.NONE,R.string.delete_alarm);
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  final Cursor c=(Cursor)mAlarmsList.getAdapter().getItem(info.position);
  final Alarm alarm=new Alarm(c);
  final Calendar cal=Calendar.getInstance();
  cal.set(Calendar.HOUR_OF_DAY,alarm.hour);
  cal.set(Calendar.MINUTE,alarm.minutes);
  final String time=Alarms.formatTime(this,cal);
  final View v=mFactory.inflate(R.layout.context_menu_header,null);
  TextView textView=(TextView)v.findViewById(R.id.header_time);
  textView.setText(time);
  textView=(TextView)v.findViewById(R.id.header_label);
  textView.setText(alarm.label);
  menu.setHeaderView(v);
  if (alarm.enabled) {
    menu.findItem(R.id.enable_alarm).setTitle(R.string.disable_alarm);
  }
}
 

Example 41

From project evodroid, under directory /src/com/sonorth/evodroid/.

Source file: EditPost.java

  15 
vote

public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  menu.add(0,0,0,getResources().getText(R.string.select_photo));
  if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
    menu.add(0,1,0,getResources().getText(R.string.take_photo));
  }
  menu.add(0,2,0,getResources().getText(R.string.select_video));
  if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
    menu.add(0,3,0,getResources().getText(R.string.take_video));
  }
}
 

Example 42

From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/.

Source file: FollowingActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  if (getUserId() == myself) {
    AdapterView.AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
    User user=getContextItemUser(info.position);
    menu.add(0,CONTENT_DEL_FRIEND,0,getResources().getString(R.string.cmenu_user_addfriend_prefix) + user.screenName + getResources().getString(R.string.cmenu_user_friend_suffix));
  }
}
 

Example 43

From project filemanager, under directory /FileManager/src/org/openintents/filemanager/lists/.

Source file: SimpleFileListFragment.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  MenuInflater inflater=new MenuInflater(getActivity());
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  ClassCastException e) {
    e.printStackTrace();
    return;
  }
  MenuUtils.fillContextMenu((FileHolder)mAdapter.getItem(info.position),menu,inflater,getActivity());
}
 

Example 44

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/samples/demos/src/com/actionbarsherlock/sample/demos/.

Source file: ContextMenus.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  menu.add("One");
  menu.add("Two");
  menu.add("Three");
  menu.add("Four");
}
 

Example 45

From project gh4a, under directory /src/com/gh4a/.

Source file: SearchActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  menu.clear();
  if (v.getId() == R.id.list_search) {
    AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
    menu.setHeaderTitle("Go to");
    if (mSearchByUser) {
      User user=(User)userAdapter.getItem(info.position);
      menu.add("User " + user.getLogin() + (!StringUtils.isBlank(user.getName()) ? " - " + user.getName() : ""));
    }
 else {
      SearchRepository repository=(SearchRepository)repositoryAdapter.getItem(info.position);
      menu.add("User " + repository.getOwner());
      menu.add("Repo " + repository.getName());
    }
  }
  super.onCreateContextMenu(menu,v,menuInfo);
}
 

Example 46

From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/app/.

Source file: LandingPage.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  ClassCastException e) {
    Log.e(TAG,"bad menuInfo",e);
    return;
  }
  Cursor providerCursor=(Cursor)getListAdapter().getItem(info.position);
  menu.setHeaderTitle(providerCursor.getString(PROVIDER_FULLNAME_COLUMN));
  if (providerCursor.isNull(ACTIVE_ACCOUNT_ID_COLUMN)) {
    menu.add(0,ID_ADD_ACCOUNT,0,R.string.menu_edit_account);
    menu.add(0,ID_REMOVE_ACCOUNT,0,R.string.menu_remove_account).setIcon(android.R.drawable.ic_menu_delete);
    return;
  }
  long providerId=providerCursor.getLong(PROVIDER_ID_COLUMN);
  boolean isLoggingIn=isSigningIn(providerCursor);
  boolean isLoggedIn=isSignedIn(providerCursor);
  BrandingResources brandingRes=mApp.getBrandingResource(providerId);
  menu.add(0,ID_VIEW_CONTACT_LIST,0,brandingRes.getString(BrandingResourceIDs.STRING_MENU_CONTACT_LIST));
  if (isLoggedIn) {
    menu.add(0,ID_SIGN_OUT,0,R.string.menu_sign_out).setIcon(android.R.drawable.ic_menu_close_clear_cancel);
  }
 else   if (isLoggingIn) {
    menu.add(0,ID_SIGN_OUT,0,R.string.menu_cancel_signin).setIcon(android.R.drawable.ic_menu_close_clear_cancel);
  }
 else {
    menu.add(0,ID_SIGN_IN,0,R.string.sign_in);
  }
  boolean isAccountEditable=providerCursor.getInt(ACTIVE_ACCOUNT_LOCKED) == 0;
  if (isAccountEditable && !isLoggingIn && !isLoggedIn) {
    menu.add(0,ID_EDIT_ACCOUNT,0,R.string.menu_edit_account).setIcon(android.R.drawable.ic_menu_edit);
    menu.add(0,ID_REMOVE_ACCOUNT,0,R.string.menu_remove_account).setIcon(android.R.drawable.ic_menu_delete);
  }
}
 

Example 47

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/actions/.

Source file: Statistics.java

  15 
vote

@Override public boolean onCreateOptionsMenu(Menu menu){
  boolean result=super.onCreateOptionsMenu(menu);
  menu.add(ContextMenu.NONE,MENU_GRAPHTYPE,ContextMenu.NONE,R.string.menu_graphtype).setIcon(R.drawable.ic_menu_picture).setAlphabeticShortcut('t');
  menu.add(ContextMenu.NONE,MENU_TRACKLIST,ContextMenu.NONE,R.string.menu_tracklist).setIcon(R.drawable.ic_menu_show_list).setAlphabeticShortcut('l');
  menu.add(ContextMenu.NONE,MENU_SHARE,ContextMenu.NONE,R.string.menu_shareTrack).setIcon(R.drawable.ic_menu_share).setAlphabeticShortcut('s');
  return result;
}
 

Example 48

From project hsDroid, under directory /src/de/nware/app/hsDroid/ui/.

Source file: Certifications.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  checkSession();
  setContentView(R.layout.certifications);
  customTitle(getString(R.string.title_Certifications));
  defaultDLPath=Environment.getExternalStorageDirectory() + "/" + Environment.DIRECTORY_DOWNLOADS;
  mPreferences=PreferenceManager.getDefaultSharedPreferences(this);
  listView=(ListView)findViewById(R.id.cert_listView);
  final ContentResolver resolver=getContentResolver();
  Cursor cursor=resolver.query(CertificationsCol.CONTENT_URI,null,null,null,null);
  startManagingCursor(cursor);
  final String[] from=new String[]{CertificationsCol.TITLE};
  final int[] to=new int[]{R.id.cert_textView};
  listView.setAdapter(new SimpleCursorAdapter(getApplicationContext(),R.layout.certifications_row_item,cursor,from,to));
  findViewById(R.id.certificationsProgress).setVisibility(View.GONE);
  listView.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      if (isSdCardAvailable()) {
        view.showContextMenu();
      }
    }
  }
);
  listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
    @Override public void onCreateContextMenu(    ContextMenu menu,    View view,    ContextMenuInfo menuInfo){
      menu.setHeaderTitle(R.string.title_certContextMenu_selectAction);
      getMenuInflater().inflate(R.menu.cert_menu,menu);
    }
  }
);
}
 

Example 49

From project jamendo-android, under directory /src/com/teleca/jamendo/activity/.

Source file: DownloadActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  if (v.getId() == R.id.DownloadListView) {
    MenuInflater inflater=getMenuInflater();
    inflater.inflate(R.menu.download_context,menu);
  }
}
 

Example 50

From project k-9, under directory /src/com/fsck/k9/activity/.

Source file: Accounts.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  menu.setHeaderTitle(R.string.accounts_context_menu_title);
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  BaseAccount account=mAdapter.getItem(info.position);
  if ((account instanceof Account) && !((Account)account).isEnabled()) {
    getMenuInflater().inflate(R.menu.disabled_accounts_context,menu);
  }
 else {
    getMenuInflater().inflate(R.menu.accounts_context,menu);
  }
  if (account instanceof SearchAccount) {
    for (int i=0; i < menu.size(); i++) {
      android.view.MenuItem item=menu.getItem(i);
      item.setVisible(false);
    }
  }
 else {
    EnumSet<ACCOUNT_LOCATION> accountLocation=accountLocation(account);
    if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) {
      menu.findItem(R.id.move_up).setEnabled(false);
    }
 else {
      menu.findItem(R.id.move_up).setEnabled(true);
    }
    if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) {
      menu.findItem(R.id.move_down).setEnabled(false);
    }
 else {
      menu.findItem(R.id.move_down).setEnabled(true);
    }
  }
}
 

Example 51

From project K6nele, under directory /app/src/ee/ioc/phon/android/speak/.

Source file: AppListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.cm_app,menu);
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  Cursor c=(Cursor)getListView().getItemAtPosition(info.position);
  long grammarId=c.getLong(c.getColumnIndex(App.Columns.GRAMMAR));
  long serverId=c.getLong(c.getColumnIndex(App.Columns.SERVER));
  if (grammarId == 0) {
    menu.findItem(R.id.cmAppRemoveGrammar).setEnabled(false);
  }
  if (serverId == 0) {
    menu.findItem(R.id.cmAppRemoveServer).setEnabled(false);
  }
}
 

Example 52

From project KeyboardTerm, under directory /src/tw/kenshinn/keyboardTerm/.

Source file: AddressBookActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  final Host host=getRealHost(info.position);
  menu.setHeaderTitle(host.getName());
  MenuItem connect=menu.add(R.string.addressbook_connect_host);
  connect.setOnMenuItemClickListener(new OnMenuItemClickListener(){
    public boolean onMenuItemClick(    MenuItem item){
      connect(host);
      return true;
    }
  }
);
  if (hosts.indexOf(host) != -1) {
    MenuItem edit=menu.add(R.string.addressbook_edit_host);
    edit.setOnMenuItemClickListener(new OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        Intent intent=new Intent();
        intent.setClass(AddressBookActivity.this,EditHostActivity.class);
        intent.putExtra("host",host);
        AddressBookActivity.this.startActivityForResult(intent,0);
        return true;
      }
    }
);
    MenuItem delete=menu.add(R.string.addressbook_delete_host);
    delete.setOnMenuItemClickListener(new OnMenuItemClickListener(){
      public boolean onMenuItemClick(      MenuItem item){
        dbUtils.hostDelegate.delete(host);
        AddressBookActivity.this.update();
        return true;
      }
    }
);
  }
}
 

Example 53

From project kumvandroid, under directory /src/com/ijuru/kumva/activity/.

Source file: DictionariesActivity.java

  15 
vote

/** 
 * @see android.app.Activity#onCreateContextMenu(ContextMenu,View,ContextMenuInfo)
 */
@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  this.editDictionary=adapter.getItem(info.position);
  menu.setHeaderTitle(editDictionary.getName());
  menu.add(Menu.NONE,MENU_UPDATE,0,R.string.str_update);
  menu.add(Menu.NONE,MENU_REMOVE,1,R.string.str_remove);
}
 

Example 54

From project liquidroid, under directory /src/liqui/droid/activity/.

Source file: Search.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  menu.clear();
  if (v.getId() == R.id.list_search) {
    AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
    menu.setHeaderTitle("Go to");
    if (mSearchByUser) {
      Member user=(Member)mMemberAdapter.getItem(info.position);
      menu.add("User " + user.name + (!StringUtils.isBlank(user.name) ? " - " + user.name : ""));
    }
  }
  super.onCreateContextMenu(menu,v,menuInfo);
}
 

Example 55

From project Locast-Android, under directory /src/edu/mit/mobile/android/locast/casts/.

Source file: CastListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  final ClassCastException e) {
    Log.e(TAG,"bad menuInfo",e);
    return;
  }
  final Cursor c=(Cursor)getListAdapter().getItem(info.position);
  if (c == null) {
    return;
  }
  final MenuInflater menuInflater=getMenuInflater();
  menuInflater.inflate(R.menu.cast_context,menu);
  menuInflater.inflate(R.menu.cast_options,menu);
  menu.setHeaderTitle(c.getString(c.getColumnIndex(Cast._TITLE)));
  final boolean canEdit=Cast.canEdit(this,c);
  menu.findItem(R.id.cast_edit).setVisible(canEdit);
  menu.findItem(R.id.cast_delete).setVisible(canEdit);
}
 

Example 56

From project LoL-Chat, under directory /src/com/rei/lolchat/ui/.

Source file: ContactList.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.contactlist_context,menu);
  AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  Contact c=mListContact.get(info.position);
  try {
    mSelectedContact=mRoster.getContact(c.getJID());
  }
 catch (  RemoteException e) {
    e.printStackTrace();
  }
  menu.setHeaderTitle(mSelectedContact.getName());
}
 

Example 57

From project LunaTerm, under directory /src/tw/loli/lunaTerm/.

Source file: FunctionButtonActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  final FunctionButton btn=btns.get(info.position);
  menu.setHeaderTitle(btn.getName());
  MenuItem edit=menu.add(R.string.editfunctionbtn_edit);
  edit.setOnMenuItemClickListener(new OnMenuItemClickListener(){
    public boolean onMenuItemClick(    MenuItem item){
      Intent intent=new Intent();
      intent.setClass(FunctionButtonActivity.this,EditFunctionButtonActivity.class);
      intent.putExtra("button",btn);
      FunctionButtonActivity.this.startActivityForResult(intent,0);
      return true;
    }
  }
);
  MenuItem delete=menu.add(R.string.editfunctionbtn_delete);
  delete.setOnMenuItemClickListener(new OnMenuItemClickListener(){
    public boolean onMenuItemClick(    MenuItem item){
      dbUtils.functionsButtonsDelegate.delete(btn);
      FunctionButtonActivity.this.update();
      return true;
    }
  }
);
}
 

Example 58

From project Memo, under directory /src/com/ngarside/memo/.

Source file: ListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  menu.setHeaderTitle(getString(R.string.image));
  menu.add(0,v.getId(),0,getString(R.string.edit));
  menu.add(0,v.getId(),0,getString(R.string.delete));
  menu.add(0,v.getId(),0,getString(R.string.share));
  if (folders.getFolders().length > 0) {
    menu.add(0,v.getId(),0,getString(R.string.move));
  }
}
 

Example 59

From project MicDroid, under directory /src/com/intervigil/micdroid/.

Source file: RecordingLibrary.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  menu.setHeaderTitle(R.string.recording_options_title);
  menu.add(Menu.NONE,R.string.recording_options_play,Menu.NONE,R.string.recording_options_play);
  menu.add(Menu.NONE,R.string.recording_options_delete,Menu.NONE,R.string.recording_options_delete);
  menu.add(Menu.NONE,R.string.recording_options_rename,Menu.NONE,R.string.recording_options_rename);
  menu.add(Menu.NONE,R.string.recording_options_set_ringtone,Menu.NONE,R.string.recording_options_set_ringtone);
  menu.add(Menu.NONE,R.string.recording_options_set_notification,Menu.NONE,R.string.recording_options_set_notification);
  menu.add(Menu.NONE,R.string.recording_options_share,Menu.NONE,R.string.recording_options_share);
}
 

Example 60

From project mobilis, under directory /MobilisXHunt/MobilisXHunt_Android/src/de/tudresden/inf/rn/mobilis/android/xhunt/activity/.

Source file: LobbyActivity.java

  15 
vote

public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  XHuntPlayer player=mGame.getPlayerByJID(mMxaProxy.getXmppJid());
  Log.v(TAG,"serviceVersion: " + mMxaProxy.getIQProxy().getServiceVersion());
  MenuInflater inflater;
  if (player != null && player.isModerator()) {
    inflater=getMenuInflater();
    if (mMxaProxy.getIQProxy().getServiceVersion() > 2) {
      inflater.inflate(R.menu.context_lobby_ttmrx,menu);
    }
 else {
      inflater.inflate(R.menu.context_lobby,menu);
    }
    selectedPlayerJid=v.getTag().toString();
  }
 else   if (mMxaProxy.getIQProxy().getServiceVersion() > 2) {
    inflater=getMenuInflater();
    inflater.inflate(R.menu.context_lobby_ttagent,menu);
  }
}
 

Example 61

From project motelib, under directory /src/com/cafbit/motelib/settings/.

Source file: DevicesActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  if ((v.equals(getListView())) && (menuInfo instanceof AdapterContextMenuInfo)) {
    AdapterContextMenuInfo acmu=(AdapterContextMenuInfo)menuInfo;
    if (acmu.id != -1) {
      onDeviceCreateContextMenu((Device)adapter.getItem((int)acmu.id),menu);
    }
  }
}
 

Example 62

From project mp3tunes-android, under directory /src/com/mp3tunes/android/activity/.

Source file: AlbumBrowser.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfoIn){
  menu.add(0,QUEUE,0,R.string.menu_play_selection);
  menu.add(0,PLAY_SELECTION,0,R.string.menu_play_selection);
  menu.add(0,SEARCH,0,R.string.search);
  AdapterContextMenuInfo mi=(AdapterContextMenuInfo)menuInfoIn;
  mAlbumCursor.moveToPosition(mi.position);
  mCurrentAlbumId=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums._ID));
  mCurrentAlbumName=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
  menu.setHeaderTitle(mCurrentAlbumName);
}
 

Example 63

From project multi-translator, under directory /src/com/robtheis/translator/.

Source file: MultiTranslatorActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  if (v.equals(translation1)) {
    menu.add(Menu.NONE,OPTIONS_COPY_TRANSLATION1,Menu.NONE,"Copy translated text");
  }
 else   if (v.equals(translation2)) {
    menu.add(Menu.NONE,OPTIONS_COPY_TRANSLATION2,Menu.NONE,"Copy translated text");
  }
 else   if (v.equals(translation3)) {
    menu.add(Menu.NONE,OPTIONS_COPY_TRANSLATION3,Menu.NONE,"Copy translated text");
  }
 else   if (v.equals(translation4)) {
    menu.add(Menu.NONE,OPTIONS_COPY_TRANSLATION4,Menu.NONE,"Copy translated text");
  }
}
 

Example 64

From project MyExpenses, under directory /src/org/totschnig/myexpenses/.

Source file: MyExpenses.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  menu.add(0,R.id.DELETE_COMMAND,0,R.string.menu_delete);
  menu.add(0,R.id.SHOW_DETAIL_COMMAND,0,R.string.menu_show_detail);
  if (mDbHelper.getAccountCount(null) > 1) {
    menu.add(0,R.id.MOVE_TRANSACTION_COMMAND,0,R.string.menu_move_transaction);
  }
}
 

Example 65

From project NotePad, under directory /NotePad/src/org/openintents/notepad/noteslist/.

Source file: NotesList.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  ClassCastException e) {
    Log.e(TAG,"bad menuInfo",e);
    return;
  }
  Cursor cursor=(Cursor)getListAdapter().getItem(info.position);
  if (cursor == null) {
    return;
  }
  Uri noteUri=ContentUris.withAppendedId(getIntent().getData(),info.id);
  long encrypted=cursor.getLong(NotesListCursor.COLUMN_INDEX_ENCRYPTED);
  menu.setHeaderTitle(cursor.getString(NotesListCursor.COLUMN_INDEX_TITLE));
  menu.add(0,MENU_ITEM_EDIT_TAGS,0,R.string.menu_edit_tags);
  if (encrypted == 0) {
    menu.add(0,MENU_ITEM_SHARE,0,R.string.menu_share);
    menu.add(0,MENU_ITEM_ENCRYPT,0,R.string.menu_encrypt);
  }
 else {
    menu.add(0,MENU_ITEM_UNENCRYPT,0,R.string.menu_undo_encryption);
  }
  menu.add(0,MENU_ITEM_DELETE,0,R.string.menu_delete);
  if (encrypted == 0) {
    Intent intent=new Intent(null,noteUri);
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE,0,0,new ComponentName(this,NotesList.class),null,intent,0,null);
  }
}
 

Example 66

From project Notes, under directory /src/net/micode/notes/ui/.

Source file: NoteEditText.java

  15 
vote

@Override protected void onCreateContextMenu(ContextMenu menu){
  if (getText() instanceof Spanned) {
    int selStart=getSelectionStart();
    int selEnd=getSelectionEnd();
    int min=Math.min(selStart,selEnd);
    int max=Math.max(selStart,selEnd);
    final URLSpan[] urls=((Spanned)getText()).getSpans(min,max,URLSpan.class);
    if (urls.length == 1) {
      int defaultResId=0;
      for (      String schema : sSchemaActionResMap.keySet()) {
        if (urls[0].getURL().indexOf(schema) >= 0) {
          defaultResId=sSchemaActionResMap.get(schema);
          break;
        }
      }
      if (defaultResId == 0) {
        defaultResId=R.string.note_link_other;
      }
      menu.add(0,0,0,defaultResId).setOnMenuItemClickListener(new OnMenuItemClickListener(){
        public boolean onMenuItemClick(        MenuItem item){
          urls[0].onClick(NoteEditText.this);
          return true;
        }
      }
);
    }
  }
  super.onCreateContextMenu(menu);
}
 

Example 67

From project nuxeo-android, under directory /nuxeo-android-connector/src/main/java/org/nuxeo/android/activities/.

Source file: BaseDocumentsListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  if (v.getId() == listView.getId()) {
    AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
    Document doc=documentsList.getDocument(info.position);
    menu.setHeaderTitle(doc.getTitle());
    populateContextMenu(doc,menu);
  }
  super.onCreateContextMenu(menu,v,menuInfo);
}
 

Example 68

From project official-android-app--DEPRECATED-, under directory /src/com/plancake/android/app/activity/.

Source file: TasksActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  PlancakeTask task=taskItemAdapter.getItem(info.position);
  menu.setHeaderTitle(R.string.context_menu_title);
  int inboxListId=dbAdapter.getInboxListId();
  if ((task.note != null) && (task.note.length() > 0)) {
    menu.add(CONTEXT_MENU_ITEM_VIEW_NOTE,CONTEXT_MENU_ITEM_VIEW_NOTE,Menu.NONE,R.string.view_note);
  }
  if ((!task.isCompleted) && (!task.isModifiedLocally)) {
    menu.add(CONTEXT_MENU_ITEM_MARK_AS_DONE,CONTEXT_MENU_ITEM_MARK_AS_DONE,Menu.NONE,R.string.mark_as_done);
  }
  if (task.isCompleted) {
    menu.add(CONTEXT_MENU_ITEM_MARK_AS_INCOMPLETE,CONTEXT_MENU_ITEM_MARK_AS_INCOMPLETE,Menu.NONE,R.string.mark_as_incomplete);
  }
  if ((listId == inboxListId) && task.isModifiedLocally && !task.isCompleted) {
    menu.add(CONTEXT_MENU_ITEM_EDIT,CONTEXT_MENU_ITEM_EDIT,Menu.NONE,R.string.edit);
    menu.add(CONTEXT_MENU_ITEM_DELETE,CONTEXT_MENU_ITEM_DELETE,Menu.NONE,R.string.delete);
  }
}
 

Example 69

From project ohmagePhone, under directory /src/org/ohmage/activity/.

Source file: QueryTestActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  if (v instanceof TextView) {
    menu.add(0,CONTEXT_COPY,0,"Copy");
    TextView txView=(TextView)v;
    myTargetTextView=txView;
    txView.setBackgroundColor(Color.YELLOW);
  }
}
 

Example 70

From project Ohmage_Phone, under directory /src/org/ohmage/feedback/.

Source file: FBTestActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  if (v instanceof TextView) {
    menu.add(0,CONTEXT_COPY,0,"Copy");
    TextView txView=(TextView)v;
    myTargetTextView=txView;
    txView.setBackgroundColor(Color.YELLOW);
  }
}
 

Example 71

From project onebusaway-android, under directory /src/com/joulespersecond/seattlebusbot/.

Source file: MyRouteListFragmentBase.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  final TextView text=(TextView)info.targetView.findViewById(R.id.short_name);
  menu.setHeaderTitle(getString(R.string.route_name,text.getText()));
  if (isShortcutMode()) {
    menu.add(0,CONTEXT_MENU_DEFAULT,0,R.string.my_context_create_shortcut);
  }
 else {
    menu.add(0,CONTEXT_MENU_DEFAULT,0,R.string.my_context_get_route_info);
  }
  menu.add(0,CONTEXT_MENU_SHOW_ON_MAP,0,R.string.my_context_showonmap);
  final String url=QueryUtils.RouteList.getUrl(getListView(),info.position);
  if (!TextUtils.isEmpty(url)) {
    menu.add(0,CONTEXT_MENU_SHOW_URL,0,R.string.my_context_show_schedule);
  }
}
 

Example 72

From project OneMoreDream, under directory /src/com/dixheure/.

Source file: AlarmClock.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  getMenuInflater().inflate(R.menu.context_menu,menu);
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  final Cursor c=(Cursor)mAlarmsList.getAdapter().getItem((int)info.position);
  final Alarm alarm=new Alarm(c);
  final Calendar cal=Calendar.getInstance();
  cal.set(Calendar.HOUR_OF_DAY,alarm.hour);
  cal.set(Calendar.MINUTE,alarm.minutes);
  final String time=Alarms.formatTime(this,cal);
  final View v=mFactory.inflate(R.layout.context_menu_header,null);
  TextView textView=(TextView)v.findViewById(R.id.header_time);
  textView.setText(time);
  textView=(TextView)v.findViewById(R.id.header_label);
  textView.setText(alarm.label);
  menu.setHeaderView(v);
  if (alarm.enabled) {
    menu.findItem(R.id.enable_alarm).setTitle(R.string.disable_alarm);
  }
}
 

Example 73

From project OpenBike, under directory /src/fr/openbike/android/ui/.

Source file: OpenBikeListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,view,menuInfo);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.list_context_menu,menu);
  ViewHolder holder=((ViewHolder)((AdapterContextMenuInfo)menuInfo).targetView.getTag());
  menu.removeItem(holder.favorite.isChecked() ? R.id.add_favorite : R.id.remove_favorite);
  if (!Utils.isIntentAvailable(new Intent(Intent.ACTION_VIEW,Uri.parse("geo:0,0?q=bibi")),this)) {
    menu.removeItem(R.id.show_on_google_maps);
  }
  if (!Utils.isIntentAvailable(new Intent(Intent.ACTION_VIEW,Uri.parse("google.navigation:q=bibi")),this)) {
    menu.removeItem(R.id.navigate);
  }
  menu.removeItem(holder.favorite.isChecked() ? R.id.add_favorite : R.id.remove_favorite);
  mSelected=(String.valueOf((Integer)holder.favorite.getTag()));
  menu.setHeaderTitle(holder.name.getText());
}
 

Example 74

From project opensudoku, under directory /OpenSudoku/src/cz/romario/opensudoku/gui/.

Source file: FolderListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  ClassCastException e) {
    Log.e(TAG,"bad menuInfo",e);
    return;
  }
  Cursor cursor=(Cursor)getListAdapter().getItem(info.position);
  if (cursor == null) {
    return;
  }
  menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex(FolderColumns.NAME)));
  menu.add(0,MENU_ITEM_EXPORT,0,R.string.export_folder);
  menu.add(0,MENU_ITEM_RENAME,1,R.string.rename_folder);
  menu.add(0,MENU_ITEM_DELETE,2,R.string.delete_folder);
}
 

Example 75

From project opensudoku-blackberry, under directory /opensudoku/src/net/bmagro/blackberry/opensudoku/gui/.

Source file: FolderListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  ClassCastException e) {
    Log.e(TAG,"bad menuInfo",e);
    return;
  }
  Cursor cursor=(Cursor)getListAdapter().getItem(info.position);
  if (cursor == null) {
    return;
  }
  menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex(FolderColumns.NAME)));
  menu.add(0,MENU_ITEM_EXPORT,0,R.string.export_folder);
  menu.add(0,MENU_ITEM_RENAME,1,R.string.rename_folder);
  menu.add(0,MENU_ITEM_DELETE,2,R.string.delete_folder);
}
 

Example 76

From project packages_apps_Phone_1, under directory /src/com/android/phone/.

Source file: SimContacts.java

  15 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case MENU_IMPORT_ONE:
    ContextMenu.ContextMenuInfo menuInfo=item.getMenuInfo();
  if (menuInfo instanceof AdapterView.AdapterContextMenuInfo) {
    int position=((AdapterView.AdapterContextMenuInfo)menuInfo).position;
    importOneSimContact(position);
    return true;
  }
}
return super.onContextItemSelected(item);
}
 

Example 77

From project PageTurner, under directory /src/main/java/net/nightwhistler/pageturner/activity/.

Source file: ReadingActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  if (this.selectedWord != null) {
    final CharSequence word=this.selectedWord;
    String header=String.format(getString(R.string.word_select),selectedWord);
    menu.setHeaderTitle(header);
    final Intent intent=new Intent(PICK_RESULT_ACTION);
    intent.putExtra(EXTRA_QUERY,word.toString());
    intent.putExtra(EXTRA_FULLSCREEN,false);
    intent.putExtra(EXTRA_HEIGHT,400);
    intent.putExtra(EXTRA_GRAVITY,Gravity.BOTTOM);
    intent.putExtra(EXTRA_MARGIN_LEFT,100);
    if (isIntentAvailable(this,intent)) {
      MenuItem item=menu.add(getString(R.string.dictionary_lookup));
      item.setOnMenuItemClickListener(new OnMenuItemClickListener(){
        @Override public boolean onMenuItemClick(        MenuItem item){
          startActivityForResult(intent,5);
          return true;
        }
      }
);
    }
    MenuItem newItem=menu.add(getString(R.string.wikipedia_lookup));
    newItem.setOnMenuItemClickListener(new BrowserSearchMenuItem("http://en.wikipedia.org/wiki/Special:Search?search=" + URLEncoder.encode(word.toString())));
    MenuItem newItem2=menu.add(getString(R.string.google_lookup));
    newItem2.setOnMenuItemClickListener(new BrowserSearchMenuItem("http://www.google.com/search?q=" + URLEncoder.encode(word.toString())));
    this.selectedWord=null;
  }
}
 

Example 78

From project platform_frameworks_ex, under directory /common/java/com/android/ex/editstyledtext/.

Source file: EditStyledText.java

  15 
vote

@Override protected void onCreateContextMenu(ContextMenu menu){
  super.onCreateContextMenu(menu);
  MenuHandler handler=new MenuHandler();
  if (STR_HORIZONTALLINE != null) {
    menu.add(0,ID_HORIZONTALLINE,0,STR_HORIZONTALLINE).setOnMenuItemClickListener(handler);
  }
  if (isStyledText() && STR_CLEARSTYLES != null) {
    menu.add(0,ID_CLEARSTYLES,0,STR_CLEARSTYLES).setOnMenuItemClickListener(handler);
  }
  if (mManager.canPaste()) {
    menu.add(0,ID_PASTE,0,STR_PASTE).setOnMenuItemClickListener(handler).setAlphabeticShortcut('v');
  }
}
 

Example 79

From project platform_packages_apps_alarmclock, under directory /src/com/android/alarmclock/.

Source file: AlarmClock.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  getMenuInflater().inflate(R.menu.context_menu,menu);
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  final Cursor c=(Cursor)mAlarmsList.getAdapter().getItem((int)info.position);
  final Alarm alarm=new Alarm(c);
  final Calendar cal=Calendar.getInstance();
  cal.set(Calendar.HOUR_OF_DAY,alarm.hour);
  cal.set(Calendar.MINUTE,alarm.minutes);
  final String time=Alarms.formatTime(this,cal);
  final View v=mFactory.inflate(R.layout.context_menu_header,null);
  TextView textView=(TextView)v.findViewById(R.id.header_time);
  textView.setText(time);
  textView=(TextView)v.findViewById(R.id.header_label);
  textView.setText(alarm.label);
  menu.setHeaderView(v);
  if (alarm.enabled) {
    menu.findItem(R.id.enable_alarm).setTitle(R.string.disable_alarm);
  }
}
 

Example 80

From project platform_packages_apps_browser, under directory /src/com/android/browser/.

Source file: BrowserBookmarksPage.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  BookmarkContextMenuInfo info=(BookmarkContextMenuInfo)menuInfo;
  BrowserBookmarksAdapter adapter=getChildAdapter(info.groupPosition);
  Cursor cursor=adapter.getItem(info.childPosition);
  if (!canEdit(cursor)) {
    return;
  }
  boolean isFolder=cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0;
  final Activity activity=getActivity();
  MenuInflater inflater=activity.getMenuInflater();
  inflater.inflate(R.menu.bookmarkscontext,menu);
  if (isFolder) {
    menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU,true);
  }
 else {
    menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU,true);
    if (mDisableNewWindow) {
      menu.findItem(R.id.new_window_context_menu_id).setVisible(false);
    }
  }
  BookmarkItem header=new BookmarkItem(activity);
  header.setEnableScrolling(true);
  populateBookmarkItem(cursor,header,isFolder);
  menu.setHeaderView(header);
  int count=menu.size();
  for (int i=0; i < count; i++) {
    menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener);
  }
}
 

Example 81

From project platform_packages_apps_calculator, under directory /src/com/android/calculator2/.

Source file: CalculatorEditText.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu){
  MenuHandler handler=new MenuHandler();
  if (mMenuItemsStrings == null) {
    Resources resources=getResources();
    mMenuItemsStrings=new String[3];
    mMenuItemsStrings[CUT]=resources.getString(android.R.string.cut);
    mMenuItemsStrings[COPY]=resources.getString(android.R.string.copy);
    mMenuItemsStrings[PASTE]=resources.getString(android.R.string.paste);
  }
  for (int i=0; i < mMenuItemsStrings.length; i++) {
    menu.add(Menu.NONE,i,i,mMenuItemsStrings[i]).setOnMenuItemClickListener(handler);
  }
  if (getText().length() == 0) {
    menu.getItem(CUT).setVisible(false);
    menu.getItem(COPY).setVisible(false);
  }
  ClipData primaryClip=getPrimaryClip();
  if (primaryClip == null || primaryClip.getItemCount() == 0 || !canPaste(primaryClip.getItemAt(0).coerceToText(getContext()))) {
    menu.getItem(PASTE).setVisible(false);
  }
}
 

Example 82

From project platform_packages_apps_contacts, under directory /src/com/android/contacts/detail/.

Source file: ContactDetailFragment.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,view,menuInfo);
  AdapterView.AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  DetailViewEntry selectedEntry=(DetailViewEntry)mAllEntries.get(info.position);
  menu.setHeaderTitle(selectedEntry.data);
  menu.add(ContextMenu.NONE,ContextMenuIds.COPY_TEXT,ContextMenu.NONE,getString(R.string.copy_text));
  String selectedMimeType=selectedEntry.mimetype;
  boolean isUniqueMimeType=true;
  if (Phone.CONTENT_ITEM_TYPE.equals(selectedMimeType)) {
    isUniqueMimeType=mIsUniqueNumber;
  }
 else   if (Email.CONTENT_ITEM_TYPE.equals(selectedMimeType)) {
    isUniqueMimeType=mIsUniqueEmail;
  }
  if (selectedEntry.isPrimary) {
    menu.add(ContextMenu.NONE,ContextMenuIds.CLEAR_DEFAULT,ContextMenu.NONE,getString(R.string.clear_default));
  }
 else   if (!isUniqueMimeType) {
    menu.add(ContextMenu.NONE,ContextMenuIds.SET_DEFAULT,ContextMenu.NONE,getString(R.string.set_default));
  }
}
 

Example 83

From project platform_packages_apps_CytownPhone, under directory /src/com/android/phone/.

Source file: SimContacts.java

  15 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case MENU_IMPORT_ONE:
    ContextMenu.ContextMenuInfo menuInfo=item.getMenuInfo();
  if (menuInfo instanceof AdapterView.AdapterContextMenuInfo) {
    int position=((AdapterView.AdapterContextMenuInfo)menuInfo).position;
    importOneSimContact(position);
    return true;
  }
}
return super.onContextItemSelected(item);
}
 

Example 84

From project platform_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: GalleryPicker.java

  15 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.gallerypicker);
  mGridView=(GridView)findViewById(R.id.albums);
  mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      launchFolderGallery(position);
    }
  }
);
  mGridView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener(){
    public void onCreateContextMenu(    ContextMenu menu,    View v,    final ContextMenuInfo menuInfo){
      onCreateGalleryPickerContextMenu(menu,menuInfo);
    }
  }
);
  mReceiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      onReceiveMediaBroadcast(intent);
    }
  }
;
  mDbObserver=new ContentObserver(mHandler){
    @Override public void onChange(    boolean selfChange){
      rebake(false,ImageManager.isMediaScannerScanning(getContentResolver()));
    }
  }
;
  ImageManager.ensureOSXCompatibleFolder();
}
 

Example 85

From project platform_packages_apps_im, under directory /src/com/android/im/app/.

Source file: LandingPage.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info;
  try {
    info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  }
 catch (  ClassCastException e) {
    Log.e(TAG,"bad menuInfo",e);
    return;
  }
  Cursor providerCursor=(Cursor)getListAdapter().getItem(info.position);
  menu.setHeaderTitle(providerCursor.getString(PROVIDER_FULLNAME_COLUMN));
  if (providerCursor.isNull(ACTIVE_ACCOUNT_ID_COLUMN)) {
    menu.add(0,ID_ADD_ACCOUNT,0,R.string.menu_add_account);
    return;
  }
  long providerId=providerCursor.getLong(PROVIDER_ID_COLUMN);
  boolean isLoggingIn=isSigningIn(providerCursor);
  boolean isLoggedIn=isSignedIn(providerCursor);
  BrandingResources brandingRes=mApp.getBrandingResource(providerId);
  if (!isLoggedIn) {
    menu.add(0,ID_SIGN_IN,0,R.string.sign_in).setIcon(com.android.internal.R.drawable.ic_menu_login);
  }
 else {
    menu.add(0,ID_VIEW_CONTACT_LIST,0,brandingRes.getString(BrandingResourceIDs.STRING_MENU_CONTACT_LIST));
    menu.add(0,ID_SIGN_OUT,0,R.string.menu_sign_out).setIcon(android.R.drawable.ic_menu_close_clear_cancel);
  }
  boolean isAccountEditible=providerCursor.getInt(ACTIVE_ACCOUNT_LOCKED) == 0;
  if (isAccountEditible && !isLoggingIn && !isLoggedIn) {
    menu.add(0,ID_EDIT_ACCOUNT,0,R.string.menu_edit_account).setIcon(android.R.drawable.ic_menu_edit);
    menu.add(0,ID_REMOVE_ACCOUNT,0,R.string.menu_remove_account).setIcon(android.R.drawable.ic_menu_delete);
  }
  menu.add(0,ID_SETTINGS,0,R.string.menu_settings);
}
 

Example 86

From project platform_packages_apps_mms, under directory /src/com/android/mms/ui/.

Source file: ComposeMessageActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  if (menuInfo != null) {
    Contact c=((RecipientContextMenuInfo)menuInfo).recipient;
    RecipientsMenuClickListener l=new RecipientsMenuClickListener(c);
    menu.setHeaderTitle(c.getName());
    if (c.existsInDatabase()) {
      menu.add(0,MENU_VIEW_CONTACT,0,R.string.menu_view_contact).setOnMenuItemClickListener(l);
    }
 else     if (canAddToContacts(c)) {
      menu.add(0,MENU_ADD_TO_CONTACTS,0,R.string.menu_add_to_contacts).setOnMenuItemClickListener(l);
    }
  }
}
 

Example 87

From project platform_packages_apps_music, under directory /src/com/android/music/.

Source file: AlbumBrowserActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfoIn){
  menu.add(0,PLAY_SELECTION,0,R.string.play_selection);
  SubMenu sub=menu.addSubMenu(0,ADD_TO_PLAYLIST,0,R.string.add_to_playlist);
  MusicUtils.makePlaylistMenu(this,sub);
  menu.add(0,DELETE_ITEM,0,R.string.delete_item);
  AdapterContextMenuInfo mi=(AdapterContextMenuInfo)menuInfoIn;
  mAlbumCursor.moveToPosition(mi.position);
  mCurrentAlbumId=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums._ID));
  mCurrentAlbumName=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
  mCurrentArtistNameForAlbum=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ARTIST));
  mIsUnknownArtist=mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
  mIsUnknownAlbum=mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
  if (mIsUnknownAlbum) {
    menu.setHeaderTitle(getString(R.string.unknown_album_name));
  }
 else {
    menu.setHeaderTitle(mCurrentAlbumName);
  }
  if (!mIsUnknownAlbum || !mIsUnknownArtist) {
    menu.add(0,SEARCH,0,R.string.search_title);
  }
}
 

Example 88

From project platform_packages_apps_phone, under directory /src/com/android/phone/.

Source file: SimContacts.java

  15 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case MENU_IMPORT_ONE:
    ContextMenu.ContextMenuInfo menuInfo=item.getMenuInfo();
  if (menuInfo instanceof AdapterView.AdapterContextMenuInfo) {
    int position=((AdapterView.AdapterContextMenuInfo)menuInfo).position;
    importOneSimContact(position);
    return true;
  }
}
return super.onContextItemSelected(item);
}
 

Example 89

From project platform_packages_apps_settings, under directory /src/com/android/settings/vpn2/.

Source file: VpnSettings.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo info){
  if (mDialog != null) {
    Log.v(TAG,"onCreateContextMenu() is called when mDialog != null");
    return;
  }
  if (info instanceof AdapterContextMenuInfo) {
    Preference preference=(Preference)getListView().getItemAtPosition(((AdapterContextMenuInfo)info).position);
    if (preference instanceof VpnPreference) {
      VpnProfile profile=((VpnPreference)preference).getProfile();
      mSelectedKey=profile.key;
      menu.setHeaderTitle(profile.name);
      menu.add(Menu.NONE,R.string.vpn_menu_edit,0,R.string.vpn_menu_edit);
      menu.add(Menu.NONE,R.string.vpn_menu_delete,0,R.string.vpn_menu_delete);
    }
  }
}
 

Example 90

From project QuotaForAndroid, under directory /Quota/src/com/southfreo/quota/activities/.

Source file: SummaryActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  if (v == getListView()) {
    AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
    menu.setHeaderTitle("Provider Options");
    menu.add(0,0,0,"Delete");
    menu.add(1,1,1,"Force refresh");
  }
}
 

Example 91

From project Racenet-for-Android, under directory /src/org/racenet/.

Source file: NewsListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  ExpandableListContextMenuInfo info=(ExpandableListContextMenuInfo)menuInfo;
  final String title=((TextView)info.targetView).getText().toString();
  menu.setHeaderTitle(title);
  menu.add(0,0,0,"Delete");
}
 

Example 92

From project rapidandroid, under directory /rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/.

Source file: FormCreator.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.form_create);
  ListView lsv=(ListView)findViewById(R.id.lsv_createfields);
  lsv.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener(){
    public void onCreateContextMenu(    ContextMenu menu,    View v,    ContextMenuInfo menuInfo){
      menu.setHeaderTitle("Current Field");
      menu.add(0,CONTEXT_MOVE_UP,0,"Move Up");
      menu.add(0,CONTEXT_MOVE_DOWN,0,"Move Down");
      menu.add(0,CONTEXT_REMOVE,0,"Remove").setIcon(android.R.drawable.ic_menu_delete);
    }
  }
);
  lsv.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> arg0,    View arg1,    int arg2,    long arg3){
      selectedFieldPosition=arg2;
    }
  }
);
  TextView noFields=new TextView(this);
  noFields.setText("No fields");
  lsv.setEmptyView(noFields);
  updateFieldList();
}
 

Example 93

From project reddit-is-fun, under directory /src/com/andrewshu/android/reddit/comments/.

Source file: CommentsListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  int rowId=(int)info.id;
  ThingInfo item=mCommentsAdapter.getItem(rowId);
  if (rowId == 0) {
    menu.add(0,Constants.SHARE_CONTEXT_ITEM,Menu.NONE,"Share");
    if (getOpThingInfo().isSaved()) {
      menu.add(0,Constants.UNSAVE_CONTEXT_ITEM,Menu.NONE,"Unsave");
    }
 else {
      menu.add(0,Constants.SAVE_CONTEXT_ITEM,Menu.NONE,"Save");
    }
    if (getOpThingInfo().isHidden()) {
      menu.add(0,Constants.UNHIDE_CONTEXT_ITEM,Menu.NONE,"Unhide");
    }
 else {
      menu.add(0,Constants.HIDE_CONTEXT_ITEM,Menu.NONE,"Hide");
    }
    menu.add(0,Constants.DIALOG_VIEW_PROFILE,Menu.NONE,String.format(getResources().getString(R.string.user_profile),item.getAuthor()));
  }
 else   if (isLoadMoreCommentsPosition(rowId)) {
    menu.add(0,Constants.DIALOG_GOTO_PARENT,Menu.NONE,"Go to parent");
  }
 else   if (isHiddenCommentHeadPosition(rowId)) {
    menu.add(0,Constants.DIALOG_SHOW_COMMENT,Menu.NONE,"Show comment");
    menu.add(0,Constants.DIALOG_GOTO_PARENT,Menu.NONE,"Go to parent");
  }
 else {
    if (mSettings.getUsername() != null && mSettings.getUsername().equalsIgnoreCase(item.getAuthor())) {
      menu.add(0,Constants.DIALOG_EDIT,Menu.NONE,"Edit");
      menu.add(0,Constants.DIALOG_DELETE,Menu.NONE,"Delete");
    }
    menu.add(0,Constants.DIALOG_HIDE_COMMENT,Menu.NONE,"Hide comment");
    menu.add(0,Constants.DIALOG_GOTO_PARENT,Menu.NONE,"Go to parent");
    menu.add(0,Constants.DIALOG_VIEW_PROFILE,Menu.NONE,String.format(getResources().getString(R.string.user_profile),item.getAuthor()));
  }
}
 

Example 94

From project safe, under directory /Safe/src/org/openintents/safe/.

Source file: CategoryList.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  AdapterView.AdapterContextMenuInfo info;
  info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  menu.setHeaderTitle(rows.get(info.position).plainName);
  menu.add(0,OPEN_CATEGORY_INDEX,0,R.string.open).setIcon(android.R.drawable.ic_menu_view).setAlphabeticShortcut('o');
  menu.add(0,EDIT_CATEGORY_INDEX,0,R.string.password_edit).setIcon(android.R.drawable.ic_menu_edit).setAlphabeticShortcut('e');
  menu.add(0,DEL_CATEGORY_INDEX,0,R.string.password_delete).setIcon(android.R.drawable.ic_menu_delete).setAlphabeticShortcut('d');
}
 

Example 95

From project SASAbus, under directory /src/it/sasabz/android/sasabus/.

Source file: SelectFavoritenActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  if (v.getId() == android.R.id.list) {
    AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
    menu.setHeaderTitle(list.get(info.position).toString());
    menu.add(Menu.NONE,0,0,R.string.delete);
  }
}
 

Example 96

From project Schedule, under directory /android/src/com/happytap/schedule/activity/.

Source file: StationListActivity.java

  15 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  if (!preferences.contains("f_" + currentStopId)) {
    favorite=menu.add("Add as Favorite");
    favorite.setVisible(false);
  }
 else {
    unfavorite=menu.add("Remove from Favorites");
    unfavorite.setVisible(false);
  }
  super.onCreateContextMenu(menu,v,menuInfo);
}