From 0e1262604f3a06469724b334a6f6268414e91fb8 Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Tue, 22 Apr 2014 11:03:23 +0200 Subject: fix #3697: have attended as log type on day of event --- main/src/cgeo/geocaching/Geocache.java | 20 ++++++++++++++++++++ main/src/cgeo/geocaching/LogCacheActivity.java | 24 ++++-------------------- 2 files changed, 24 insertions(+), 20 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index fa25576..1ed699e 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -25,6 +25,7 @@ import cgeo.geocaching.list.StoredList; import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.CancellableHandler; +import cgeo.geocaching.utils.DateUtils; import cgeo.geocaching.utils.ImageUtils; import cgeo.geocaching.utils.LazyInitializedList; import cgeo.geocaching.utils.Log; @@ -1808,4 +1809,23 @@ public class Geocache implements ICache, IWaypoint { return (getType().applyDistanceRule() || hasUserModifiedCoords()) && getConnector() == GCConnector.getInstance(); } + public LogType getDefaultLogType() { + if (isEventCache()) { + final Date eventDate = getHiddenDate(); + boolean expired = DateUtils.isPastEvent(this); + + if (hasOwnLog(LogType.WILL_ATTEND) || expired || (eventDate != null && DateUtils.daysSince(eventDate.getTime()) == 0)) { + return hasOwnLog(LogType.ATTENDED) ? LogType.NOTE : LogType.ATTENDED; + } + return LogType.WILL_ATTEND; + } + if (isFound()) { + return LogType.NOTE; + } + if (getType() == CacheType.WEBCAM) { + return LogType.WEBCAM_PHOTO_TAKEN; + } + return LogType.FOUND_IT; + } + } diff --git a/main/src/cgeo/geocaching/LogCacheActivity.java b/main/src/cgeo/geocaching/LogCacheActivity.java index 0f65a1d..a1368cc 100644 --- a/main/src/cgeo/geocaching/LogCacheActivity.java +++ b/main/src/cgeo/geocaching/LogCacheActivity.java @@ -3,7 +3,6 @@ package cgeo.geocaching; import cgeo.geocaching.connector.ILoggingManager; import cgeo.geocaching.connector.ImageResult; import cgeo.geocaching.connector.LogResult; -import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.enumerations.LogTypeTrackable; @@ -341,25 +340,10 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia private void setDefaultValues() { date = Calendar.getInstance(); rating = GCVote.NO_RATING; - if (cache.isEventCache()) { - final Date eventDate = cache.getHiddenDate(); - boolean expired = DateUtils.isPastEvent(cache); - - if (cache.hasOwnLog(LogType.WILL_ATTEND) || expired) { - typeSelected = cache.hasOwnLog(LogType.ATTENDED) ? LogType.NOTE : LogType.ATTENDED; - } else { - typeSelected = LogType.WILL_ATTEND; - } - // it this is an attended event log, use the event date by default instead of the current date - if (expired && typeSelected == LogType.ATTENDED) { - date.setTime(eventDate); - } - } else { - if (cache.isFound()) { - typeSelected = LogType.NOTE; - } else { - typeSelected = cache.getType() == CacheType.WEBCAM ? LogType.WEBCAM_PHOTO_TAKEN : LogType.FOUND_IT; - } + typeSelected = cache.getDefaultLogType(); + // it this is an attended event log, use the event date by default instead of the current date + if (cache.isEventCache() && DateUtils.isPastEvent(cache) && typeSelected == LogType.ATTENDED) { + date.setTime(cache.getHiddenDate()); } text = null; imageCaption = StringUtils.EMPTY; -- cgit v1.1