forked from organicmaps/organicmaps
[AND] Added context menu for track.
This commit is contained in:
parent
740ec04d1a
commit
c71743d624
4 changed files with 51 additions and 17 deletions
|
@ -59,6 +59,18 @@ extern "C"
|
|||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeDeleteTrack(
|
||||
JNIEnv * env, jobject thiz, jint cat, jint trk)
|
||||
{
|
||||
BookmarkCategory * pCat = frm()->GetBmCategory(cat);
|
||||
if (pCat)
|
||||
{
|
||||
pCat->DeleteTrack(trk);
|
||||
pCat->SaveToKMLFile();
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_getBookmark(
|
||||
JNIEnv * env, jobject thiz, jdouble px, jdouble py)
|
||||
|
|
|
@ -164,28 +164,33 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
|
|||
{
|
||||
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
|
||||
mSelectedPosition = info.position;
|
||||
final MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.pin_sets_context_menu, menu);
|
||||
|
||||
|
||||
for (final ShareAction sa : ShareAction.ACTIONS.values())
|
||||
final int type = mPinAdapter.getItemViewType(mSelectedPosition);
|
||||
if (type == BookmarkListAdapter.TYPE_BMK)
|
||||
{
|
||||
if (sa.isSupported(this))
|
||||
menu.add(Menu.NONE, sa.getId(), sa.getId(), getResources().getString(sa.getNameResId()));
|
||||
}
|
||||
final MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.pin_sets_context_menu, menu);
|
||||
|
||||
menu.setHeaderTitle(mManager.getBookmark(mEditedSet.getId(), mSelectedPosition).getName());
|
||||
for (final ShareAction sa : ShareAction.ACTIONS.values())
|
||||
{
|
||||
if (sa.isSupported(this))
|
||||
menu.add(Menu.NONE, sa.getId(), sa.getId(), getResources().getString(sa.getNameResId()));
|
||||
}
|
||||
final Bookmark bmk = (Bookmark) mPinAdapter.getItem(mSelectedPosition);
|
||||
menu.setHeaderTitle(bmk.getName());
|
||||
}
|
||||
else if (type == BookmarkListAdapter.TYPE_TRACK)
|
||||
{
|
||||
menu.add(Menu.NONE, MENU_DELETE_TRACK, MENU_DELETE_TRACK, getString(R.string.delete));
|
||||
final Track trk = (Track) mPinAdapter.getItem(mSelectedPosition);
|
||||
menu.setHeaderTitle(trk.getName());
|
||||
}
|
||||
}
|
||||
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void startPinActivity(int cat, int bmk)
|
||||
{
|
||||
startActivity(new Intent(this, BookmarkActivity.class)
|
||||
.putExtra(BookmarkActivity.PIN, new ParcelablePoint(cat, bmk)));
|
||||
}
|
||||
private final static int MENU_DELETE_TRACK = 0x42;
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item)
|
||||
|
@ -197,8 +202,8 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
|
|||
}
|
||||
else if (itemId == R.id.set_delete)
|
||||
{
|
||||
mManager.deleteBookmark(mEditedSet.getId(), mSelectedPosition);
|
||||
((BookmarkListAdapter) getListView().getAdapter()).notifyDataSetChanged();
|
||||
mManager.deleteBookmark((Bookmark) mPinAdapter.getItem(mSelectedPosition));
|
||||
mPinAdapter.notifyDataSetChanged();
|
||||
}
|
||||
else if (ShareAction.ACTIONS.containsKey(itemId))
|
||||
{
|
||||
|
@ -207,10 +212,22 @@ public class BookmarkListActivity extends AbstractBookmarkListActivity
|
|||
|
||||
shareAction.shareMapObject(this, bmk);
|
||||
}
|
||||
else if (itemId == MENU_DELETE_TRACK)
|
||||
{
|
||||
final Track track = (Track) mPinAdapter.getItem(mSelectedPosition);
|
||||
mManager.deleteTrack(track);
|
||||
mPinAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
||||
private void startPinActivity(int cat, int bmk)
|
||||
{
|
||||
startActivity(new Intent(this, BookmarkActivity.class)
|
||||
.putExtra(BookmarkActivity.PIN, new ParcelablePoint(cat, bmk)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
|
|
|
@ -235,7 +235,6 @@ public class BookmarkListAdapter extends BaseAdapter
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private final static int SECTION_TRACKS = 0;
|
||||
private final static int SECTION_BMKS = 1;
|
||||
|
||||
|
|
|
@ -44,6 +44,12 @@ public class BookmarkManager
|
|||
deleteBookmark(bmk.getCategoryId(), bmk.getBookmarkId());
|
||||
}
|
||||
|
||||
public void deleteTrack(Track track)
|
||||
{
|
||||
nativeDeleteTrack(track.getCategoryId(), track.getTrackId());
|
||||
}
|
||||
private native void nativeDeleteTrack(int cat, int trk);
|
||||
|
||||
public int addBookmarkToLastEditedCategory(String name, double lat, double lon)
|
||||
{
|
||||
Statistics.INSTANCE.trackBookmarkCreated(mContext);
|
||||
|
|
Loading…
Add table
Reference in a new issue