aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/cgeo/calendar/ICalendar.java16
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java18
2 files changed, 34 insertions, 0 deletions
diff --git a/main/src/cgeo/calendar/ICalendar.java b/main/src/cgeo/calendar/ICalendar.java
new file mode 100644
index 0000000..bc08ef4
--- /dev/null
+++ b/main/src/cgeo/calendar/ICalendar.java
@@ -0,0 +1,16 @@
+package cgeo.calendar;
+
+public interface ICalendar {
+ static final String INTENT = "cgeo.calendar.RESERVE";
+
+ static final String URI_SCHEME = "add";
+ static final String URI_HOST = "cgeo.org";
+
+ static final String PARAM_SHORT_DESC = "shortDesc"; // cache short description
+ static final String PARAM_HIDDEN_DATE = "hiddenDate"; // cache hidden date in milliseconds
+ static final String PARAM_URL = "url"; // cache URL
+ static final String PARAM_NOTE = "note"; // personal note
+ static final String PARAM_NAME = "name"; // cache name
+ static final String PARAM_LOCATION = "location"; // cache location, or empty string
+ static final String PARAM_COORDS = "coords"; // cache coords, or empty string
+}
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 325ef38..7a1cf22 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -1,5 +1,6 @@
package cgeo.geocaching;
+import cgeo.calendar.ICalendar;
import cgeo.geocaching.cgData.StorageLocation;
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.activity.Progress;
@@ -524,6 +525,7 @@ public class CacheDetailActivity extends AbstractActivity {
return true;
} else if (menuItem == MENU_CALENDAR) {
addToCalendar();
+ // addToCalendarWithIntent();
return true;
} else if (menuItem == MENU_SHARE) {
if (cache != null) {
@@ -726,6 +728,22 @@ public class CacheDetailActivity extends AbstractActivity {
finish();
}
+ private void addToCalendarWithIntent() {
+ // this method is NOT unused :)
+ final Parameters params = new Parameters(
+ ICalendar.PARAM_NAME, cache.getName(),
+ ICalendar.PARAM_NOTE, StringUtils.defaultString(cache.getPersonalNote()),
+ ICalendar.PARAM_HIDDEN_DATE, String.valueOf(cache.getHiddenDate().getTime()),
+ ICalendar.PARAM_URL, StringUtils.defaultString(cache.getUrl()),
+ ICalendar.PARAM_COORDS, cache.getCoords() == null ? "" : cache.getCoords().format(GeopointFormatter.Format.LAT_LON_DECMINUTE_RAW),
+ ICalendar.PARAM_LOCATION, StringUtils.defaultString(cache.getLocation()),
+ ICalendar.PARAM_SHORT_DESC, StringUtils.defaultString(cache.getShortDescription())
+ );
+
+ startActivity(new Intent(ICalendar.INTENT,
+ Uri.parse(ICalendar.URI_SCHEME + "://" + ICalendar.URI_HOST + "?" + params.toString())));
+ }
+
/**
* Adds the cache to the Android-calendar if it is an event.
*/