From 8ad11e0e6631001e1566e39a825df09476b8108c Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Wed, 25 Dec 2013 19:13:29 +0100 Subject: fix #3481: new navigation menu for Pebble application --- main/res/values/ids.xml | 1 + main/res/values/preference_keys.xml | 1 + main/res/values/strings.xml | 1 + .../apps/cache/navi/NavigationAppFactory.java | 3 +- .../cgeo/geocaching/apps/cache/navi/PebbleApp.java | 44 ++++++++++++++++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 main/src/cgeo/geocaching/apps/cache/navi/PebbleApp.java diff --git a/main/res/values/ids.xml b/main/res/values/ids.xml index 4e02973..8539275 100644 --- a/main/res/values/ids.xml +++ b/main/res/values/ids.xml @@ -23,5 +23,6 @@ + \ No newline at end of file diff --git a/main/res/values/preference_keys.xml b/main/res/values/preference_keys.xml index e11f5c1..0e4675d 100644 --- a/main/res/values/preference_keys.xml +++ b/main/res/values/preference_keys.xml @@ -120,6 +120,7 @@ navigationCacheBeacon navigationGcc navigationWhereYouGo + navigationPebble ocpl_tokensecret ocpl_tokenpublic ocpl-temp-token-secret diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml index d05e52e..385bec3 100644 --- a/main/res/values/strings.xml +++ b/main/res/values/strings.xml @@ -691,6 +691,7 @@ OruxMaps Cache Beacon Navigon + Pebble Status Saved Log Found diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index aae3c43..bf0e776 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -71,7 +71,8 @@ public final class NavigationAppFactory extends AbstractAppFactory { CACHE_BEACON(new CacheBeaconApp(), 14, R.string.pref_navigation_menu_cache_beacon), GCC(new GccApp(), 15, R.string.pref_navigation_menu_gcc), - WHERE_YOU_GO(new WhereYouGoApp(), 16, R.string.pref_navigation_menu_where_you_go); + WHERE_YOU_GO(new WhereYouGoApp(), 16, R.string.pref_navigation_menu_where_you_go), + PEBBLE(new PebbleApp(), 17, R.string.pref_navigation_menu_pebble); NavigationAppsEnum(final App app, final int id, final int preferenceKey) { this.app = app; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/PebbleApp.java b/main/src/cgeo/geocaching/apps/cache/navi/PebbleApp.java new file mode 100644 index 0000000..8ba3bef --- /dev/null +++ b/main/src/cgeo/geocaching/apps/cache/navi/PebbleApp.java @@ -0,0 +1,44 @@ +package cgeo.geocaching.apps.cache.navi; + +import cgeo.geocaching.Geocache; +import cgeo.geocaching.R; +import cgeo.geocaching.geopoint.Geopoint; + +import android.app.Activity; +import android.content.Intent; + +/** + * Application for communication with the Pebble watch. + * + */ +class PebbleApp extends AbstractPointNavigationApp { + + private static final String INTENT = "com.webmajstr.pebble_gc.NAVIGATE_TO"; + private static final String PACKAGE_NAME = "com.webmajstr.pebble_gc"; + + PebbleApp() { + super(getString(R.string.cache_menu_pebble), R.id.cache_app_pebble, INTENT, PACKAGE_NAME); + } + + @Override + public void navigate(Activity activity, Geopoint point) { + final Intent pebbleIntent = new Intent(INTENT); + pebbleIntent.putExtra("latitude", point.getLatitude()); + pebbleIntent.putExtra("longitude", point.getLongitude()); + activity.startActivity(pebbleIntent); + } + + @Override + public void navigate(Activity activity, Geocache cache) { + final Intent pebbleIntent = new Intent(INTENT); + pebbleIntent.putExtra("latitude", cache.getCoords().getLatitude()); + pebbleIntent.putExtra("longitude", cache.getCoords().getLongitude()); + pebbleIntent.putExtra("difficulty", cache.getDifficulty()); + pebbleIntent.putExtra("terrain", cache.getTerrain()); + pebbleIntent.putExtra("name", cache.getName()); + pebbleIntent.putExtra("code", cache.getGeocode()); + pebbleIntent.putExtra("size", cache.getSize().getL10n()); + activity.startActivity(pebbleIntent); + } + +} \ No newline at end of file -- cgit v1.1