diff options
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/cgeo/geocaching/Geocache.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/LogCacheActivity.java | 6 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/twitter/Twitter.java | 9 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/utils/LogTemplateProvider.java | 25 |
4 files changed, 30 insertions, 12 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index 931206a..09a3734 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -463,7 +463,7 @@ public class Geocache implements ICache, IWaypoint { public void logOffline(final Activity fromActivity, final LogType logType) { final boolean mustIncludeSignature = StringUtils.isNotBlank(Settings.getSignature()) && Settings.isAutoInsertSignature(); - final String initial = mustIncludeSignature ? LogTemplateProvider.applyTemplates(Settings.getSignature(), new LogContext(this, true)) : ""; + final String initial = mustIncludeSignature ? LogTemplateProvider.applyTemplates(Settings.getSignature(), new LogContext(this, null, true)) : ""; logOffline(fromActivity, initial, Calendar.getInstance(), logType); } diff --git a/main/src/cgeo/geocaching/LogCacheActivity.java b/main/src/cgeo/geocaching/LogCacheActivity.java index 1e915ad..31d448a 100644 --- a/main/src/cgeo/geocaching/LogCacheActivity.java +++ b/main/src/cgeo/geocaching/LogCacheActivity.java @@ -277,7 +277,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia } else if (StringUtils.isNotBlank(Settings.getSignature()) && Settings.isAutoInsertSignature() && StringUtils.isBlank(currentLogText())) { - insertIntoLog(LogTemplateProvider.applyTemplates(Settings.getSignature(), new LogContext(cache)), false); + insertIntoLog(LogTemplateProvider.applyTemplates(Settings.getSignature(), new LogContext(cache, log)), false); } } updatePostButtonText(); @@ -545,7 +545,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia if (typeSelected == LogType.FOUND_IT) { if (tweetCheck.isChecked() && tweetBox.getVisibility() == View.VISIBLE) { - Twitter.postTweetCache(geocode); + Twitter.postTweetCache(geocode, logNow); } } if (GCVote.isValidRating(rating)) { @@ -609,7 +609,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia @Override protected LogContext getLogContext() { - return new LogContext(cache); + return new LogContext(cache, null); } private void selectAllTrackablesAction() { diff --git a/main/src/cgeo/geocaching/twitter/Twitter.java b/main/src/cgeo/geocaching/twitter/Twitter.java index 3dd1e17..670165e 100644 --- a/main/src/cgeo/geocaching/twitter/Twitter.java +++ b/main/src/cgeo/geocaching/twitter/Twitter.java @@ -3,6 +3,7 @@ package cgeo.geocaching.twitter; import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.DataStore; import cgeo.geocaching.Geocache; +import cgeo.geocaching.LogEntry; import cgeo.geocaching.Trackable; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.geopoint.Geopoint; @@ -23,9 +24,9 @@ public final class Twitter { private static final String HASH_PREFIX_WITH_BLANK = " #"; private static final int MAX_TWEET_SIZE = 140; - public static void postTweetCache(String geocode) { + public static void postTweetCache(String geocode, LogEntry logEntry) { final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); - postTweet(CgeoApplication.getInstance(), getStatusMessage(cache), null); + postTweet(CgeoApplication.getInstance(), getStatusMessage(cache, logEntry), null); } public static void postTweetTrackable(String geocode) { @@ -72,8 +73,8 @@ public final class Twitter { } } - static String getStatusMessage(Geocache cache) { - return appendHashTags(LogTemplateProvider.applyTemplates(Settings.getCacheTwitterMessage(), new LogContext(cache))); + static String getStatusMessage(Geocache cache, LogEntry logEntry) { + return appendHashTags(LogTemplateProvider.applyTemplates(Settings.getCacheTwitterMessage(), new LogContext(cache, logEntry))); } static String getStatusMessage(Trackable trackable) { diff --git a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java index bf2a27c..af183f7 100644 --- a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java +++ b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java @@ -1,6 +1,7 @@ package cgeo.geocaching.utils; import cgeo.geocaching.Geocache; +import cgeo.geocaching.LogEntry; import cgeo.geocaching.R; import cgeo.geocaching.Trackable; import cgeo.geocaching.connector.ConnectorFactory; @@ -35,9 +36,10 @@ public final class LogTemplateProvider { private Geocache cache; private Trackable trackable; private boolean offline = false; + private LogEntry logEntry; - public LogContext(final Geocache cache) { - this(cache, false); + public LogContext(final Geocache cache, LogEntry logEntry) { + this(cache, logEntry, false); } public LogContext(final Trackable trackable) { @@ -45,12 +47,13 @@ public final class LogTemplateProvider { } public LogContext(final boolean offline) { - this(null, offline); + this(null, null, offline); } - public LogContext(final Geocache cache, final boolean offline) { + public LogContext(final Geocache cache, LogEntry logEntry, final boolean offline) { this.cache = cache; this.offline = offline; + this.logEntry = logEntry; } public final Geocache getCache() { @@ -64,6 +67,10 @@ public final class LogTemplateProvider { public final boolean isOffline() { return offline; } + + public final LogEntry getLogEntry() { + return logEntry; + } } public abstract static class LogTemplate { @@ -207,6 +214,16 @@ public final class LogTemplateProvider { return StringUtils.EMPTY; } }); + templates.add(new LogTemplate("LOG", R.string.init_signature_template_log) { + @Override + public String getValue(LogContext context) { + LogEntry logEntry = context.getLogEntry(); + if (logEntry != null) { + return logEntry.getDisplayText(); + } + return StringUtils.EMPTY; + } + }); return templates; } |
