aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2014-05-24 06:40:14 +0200
committerBananeweizen <bananeweizen@gmx.de>2014-05-24 06:40:14 +0200
commite1652c16405ff34aa6272ba775e94127bb2c89b0 (patch)
treec9b5464502f823c5616c4c82fbfbc4f6d930637d /main/src
parent04f68f25f8f5174fbdb4c2656ece766abb3e6c1c (diff)
downloadcgeo-e1652c16405ff34aa6272ba775e94127bb2c89b0.zip
cgeo-e1652c16405ff34aa6272ba775e94127bb2c89b0.tar.gz
cgeo-e1652c16405ff34aa6272ba775e94127bb2c89b0.tar.bz2
fix #2049: automate download of cartridge
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java b/main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java
index 79a5975..b2a2cad 100644
--- a/main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java
@@ -3,14 +3,34 @@ package cgeo.geocaching.apps.cache;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.R;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.utils.TextUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+
+import java.util.regex.Pattern;
public class WhereYouGoApp extends AbstractGeneralApp {
+ private static final Pattern PATTERN_CARTRIDGE = Pattern.compile("(" + Pattern.quote("http://www.wherigo.com/cartridge/details.aspx?") + ".*?)" + Pattern.quote("\""));
+
public WhereYouGoApp() {
super(getString(R.string.cache_menu_whereyougo), R.id.cache_app_whereyougo, "menion.android.whereyougo");
}
@Override
public boolean isEnabled(Geocache cache) {
- return cache.getType() == CacheType.WHERIGO;
+ return cache.getType() == CacheType.WHERIGO && StringUtils.isNotEmpty(getWhereIGoUrl(cache));
+ }
+
+ @Override
+ public void navigate(Activity activity, Geocache cache) {
+ activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getWhereIGoUrl(cache))));
+ }
+
+ protected static String getWhereIGoUrl(Geocache cache) {
+ return TextUtils.getMatch(cache.getDescription(), PATTERN_CARTRIDGE, null);
}
}