diff options
Diffstat (limited to 'main/src/cgeo/geocaching/CacheMenuHandler.java')
| -rw-r--r-- | main/src/cgeo/geocaching/CacheMenuHandler.java | 55 |
1 files changed, 5 insertions, 50 deletions
diff --git a/main/src/cgeo/geocaching/CacheMenuHandler.java b/main/src/cgeo/geocaching/CacheMenuHandler.java index d0f1005..cfe9eeb 100644 --- a/main/src/cgeo/geocaching/CacheMenuHandler.java +++ b/main/src/cgeo/geocaching/CacheMenuHandler.java @@ -1,27 +1,17 @@ package cgeo.geocaching; -import cgeo.calendar.ICalendar; +import cgeo.calendar.CalendarAddon; import cgeo.geocaching.apps.cache.navi.NavigationAppFactory; -import cgeo.geocaching.geopoint.GeopointFormatter; -import cgeo.geocaching.network.Parameters; import cgeo.geocaching.ui.AbstractUIFactory; -import cgeo.geocaching.ui.dialog.Dialogs; -import cgeo.geocaching.utils.ProcessUtils; - -import org.apache.commons.lang3.StringUtils; import android.app.Activity; -import android.content.DialogInterface; -import android.content.Intent; -import android.net.Uri; import android.view.Menu; import android.view.MenuItem; -import java.util.Date; - /** - * Shared menu handling for all activities having menu items related to a cache. - * + * Shared menu handling for all activities having menu items related to a cache. <br> + * TODO: replace by a fragment + * */ public class CacheMenuHandler extends AbstractUIFactory { @@ -58,7 +48,7 @@ public class CacheMenuHandler extends AbstractUIFactory { cache.shareCache(activity, res); return true; case R.id.menu_calendar: - addToCalendarWithIntent(activity, cache); + CalendarAddon.addToCalendarWithIntent(activity, cache); return true; default: return false; @@ -84,39 +74,4 @@ public class CacheMenuHandler extends AbstractUIFactory { activity.getMenuInflater().inflate(R.menu.cache_options, menu); onPrepareOptionsMenu(menu, cache); } - - private static void addToCalendarWithIntent(final Activity activity, final Geocache cache) { - final boolean calendarAddOnAvailable = ProcessUtils.isIntentAvailable(ICalendar.INTENT, Uri.parse(ICalendar.URI_SCHEME + "://" + ICalendar.URI_HOST)); - - if (calendarAddOnAvailable) { - final Date hiddenDate = cache.getHiddenDate(); - final Parameters params = new Parameters( - ICalendar.PARAM_NAME, cache.getName(), - ICalendar.PARAM_NOTE, StringUtils.defaultString(cache.getPersonalNote()), - ICalendar.PARAM_HIDDEN_DATE, hiddenDate != null ? String.valueOf(hiddenDate.getTime()) : StringUtils.EMPTY, - 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()), - ICalendar.PARAM_START_TIME_MINUTES, StringUtils.defaultString(cache.guessEventTimeMinutes()) - ); - - activity.startActivity(new Intent(ICalendar.INTENT, - Uri.parse(ICalendar.URI_SCHEME + "://" + ICalendar.URI_HOST + "?" + params.toString()))); - } else { - // Inform user the calendar add-on is not installed and let them get it from Google Play - Dialogs.confirmYesNo(activity, R.string.addon_missing_title, new StringBuilder(res.getString(R.string.helper_calendar_missing)) - .append(' ') - .append(res.getString(R.string.addon_download_prompt)) - .toString(), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - final Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(ICalendar.CALENDAR_ADDON_URI)); - activity.startActivity(intent); - } - }); - } - } - } |
