diff options
| author | Torsten Keil <github@torsten-keil.net> | 2012-01-08 21:51:14 +0100 |
|---|---|---|
| committer | Torsten Keil <github@torsten-keil.net> | 2012-01-08 21:51:14 +0100 |
| commit | 964e7e719c6a6b2905ca305b06df81c3ca769c33 (patch) | |
| tree | 1ec6b85ce215d841293004412a66fe53754809c0 /main/src | |
| parent | 533a9f2caaaa6cd6ac2bbbabf612c083a9c41cc6 (diff) | |
| download | cgeo-964e7e719c6a6b2905ca305b06df81c3ca769c33.zip cgeo-964e7e719c6a6b2905ca305b06df81c3ca769c33.tar.gz cgeo-964e7e719c6a6b2905ca305b06df81c3ca769c33.tar.bz2 | |
Implementation for #957: Open cache from waypoint
- Added context menu entry
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/cgeo/geocaching/cgeowaypoint.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/cgeowaypoint.java b/main/src/cgeo/geocaching/cgeowaypoint.java index 218c61b..e2d544b 100644 --- a/main/src/cgeo/geocaching/cgeowaypoint.java +++ b/main/src/cgeo/geocaching/cgeowaypoint.java @@ -27,6 +27,7 @@ public class cgeowaypoint extends AbstractActivity { private static final int MENU_ID_NAVIGATION = 0; private static final int MENU_ID_CACHES_AROUND = 5; private static final int MENU_ID_DEFAULT_NAVIGATION = 2; + private static final int MENU_ID_OPEN_GEOCACHE = 6; private cgWaypoint waypoint = null; private String geocode = null; private int id = -1; @@ -214,6 +215,7 @@ public class cgeowaypoint extends AbstractActivity { addNavigationMenuItems(subMenu); menu.add(0, MENU_ID_CACHES_AROUND, 0, res.getString(R.string.cache_menu_around)).setIcon(android.R.drawable.ic_menu_rotate); // caches around + menu.add(0, MENU_ID_OPEN_GEOCACHE, 0, res.getString(R.string.waypoint_menu_open_cache)).setIcon(android.R.drawable.ic_menu_mylocation); // open geocache return true; } @@ -231,6 +233,9 @@ public class cgeowaypoint extends AbstractActivity { menu.findItem(MENU_ID_NAVIGATION).setVisible(visible); menu.findItem(MENU_ID_DEFAULT_NAVIGATION).setVisible(visible); menu.findItem(MENU_ID_CACHES_AROUND).setVisible(visible); + + boolean openGeocache = StringUtils.isEmpty(geocode) && !StringUtils.isEmpty(waypoint.getGeocode()); + menu.findItem(MENU_ID_OPEN_GEOCACHE).setVisible(openGeocache); } catch (Exception e) { // nothing } @@ -247,6 +252,9 @@ public class cgeowaypoint extends AbstractActivity { } else if (menuItem == MENU_ID_CACHES_AROUND) { cachesAround(); return true; + } else if (menuItem == MENU_ID_OPEN_GEOCACHE) { + goToGeocache(); + return true; } return NavigationAppFactory.onMenuItemSelected(item, geo, this, null, null, waypoint, null); @@ -262,6 +270,16 @@ public class cgeowaypoint extends AbstractActivity { finish(); } + private void goToGeocache() { + if (waypoint == null || waypoint.getGeocode() == null) { + showToast(res.getString(R.string.err_waypoint_open_cache_failed)); + } + + CacheDetailActivity.startActivity(this, waypoint.getGeocode()); + + finish(); + } + private class loadWaypoint extends Thread { @Override |
