aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2015-02-14 11:09:11 +0100
committerBananeweizen <bananeweizen@gmx.de>2015-02-14 11:09:11 +0100
commita3416cc6dfb822d6b9ca7aa7c2403e14f75c94cd (patch)
tree1d180902b5cb81617cbbe385d670260d1a516225
parent75e2330c4496730e912222a4e015a41ce9d4ad3b (diff)
downloadcgeo-a3416cc6dfb822d6b9ca7aa7c2403e14f75c94cd.zip
cgeo-a3416cc6dfb822d6b9ca7aa7c2403e14f75c94cd.tar.gz
cgeo-a3416cc6dfb822d6b9ca7aa7c2403e14f75c94cd.tar.bz2
fix #4670: register for all opencaching URLs
-rw-r--r--main/AndroidManifest.xml323
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java25
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OCConnector.java22
-rw-r--r--tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java11
4 files changed, 346 insertions, 35 deletions
diff --git a/main/AndroidManifest.xml b/main/AndroidManifest.xml
index 25909d0..bbbb45e 100644
--- a/main/AndroidManifest.xml
+++ b/main/AndroidManifest.xml
@@ -281,7 +281,33 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
- <!-- geocaching.com cache related URLs -->
+ <!-- extremcaching.com -->
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="extremcaching.com"
+ android:pathPrefix="/index.php/output-2/"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.extremcaching.com"
+ android:pathPrefix="/index.php/output-2/"
+ android:scheme="http" />
+ </intent-filter>
+
+ <!-- geocaching.com -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
@@ -331,7 +357,45 @@
android:scheme="http" />
</intent-filter>
- <!-- opencaching.DE related URLs -->
+ <!-- opencaching.CZ -->
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="opencaching.cz"
+ android:pathPrefix="/OZ"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.cz"
+ android:pathPrefix="/OZ"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.cz"
+ android:pathPrefix="/viewcache.php"
+ android:scheme="http" />
+ </intent-filter>
+
+ <!-- opencaching.DE -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
@@ -369,7 +433,45 @@
android:scheme="http" />
</intent-filter>
- <!-- opencaching.FR related URLs -->
+ <!-- opencaching.ES -->
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="opencachingspain.es"
+ android:pathPrefix="/OC"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencachingspain.es"
+ android:pathPrefix="/OC"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencachingspain.es"
+ android:pathPrefix="/viewcache.php"
+ android:scheme="http" />
+ </intent-filter>
+
+ <!-- opencaching.FR -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
@@ -407,7 +509,7 @@
android:scheme="http" />
</intent-filter>
- <!-- extremcaching.com related URLs -->
+ <!-- opencaching.IT -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
@@ -416,8 +518,8 @@
<category android:name="android.intent.category.BROWSABLE" />
<data
- android:host="extremcaching.com"
- android:pathPrefix="/index.php/output-2/"
+ android:host="opencaching.it"
+ android:pathPrefix="/OC"
android:scheme="http" />
</intent-filter>
<intent-filter>
@@ -428,11 +530,212 @@
<category android:name="android.intent.category.BROWSABLE" />
<data
- android:host="www.extremcaching.com"
- android:pathPrefix="/index.php/output-2/"
+ android:host="www.opencaching.it"
+ android:pathPrefix="/OC"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.it"
+ android:pathPrefix="/viewcache.php"
android:scheme="http" />
</intent-filter>
+ <!-- opencaching.NO -->
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="opencaching.no"
+ android:pathPrefix="/OC"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.no"
+ android:pathPrefix="/OC"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.no"
+ android:pathPrefix="/viewcache.php"
+ android:scheme="http" />
+ </intent-filter>
+
+ <!-- opencaching.NL -->
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="opencaching.nl"
+ android:pathPrefix="/OB"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.nl"
+ android:pathPrefix="/OB"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.nl"
+ android:pathPrefix="/viewcache.php"
+ android:scheme="http" />
+ </intent-filter>
+
+ <!-- opencaching.PL -->
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="opencaching.pl"
+ android:pathPrefix="/OP"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.pl"
+ android:pathPrefix="/OP"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.pl"
+ android:pathPrefix="/viewcache.php"
+ android:scheme="http" />
+ </intent-filter>
+
+ <!-- opencaching.ORG.UK -->
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="opencaching.org.uk"
+ android:pathPrefix="/OK"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.org.uk"
+ android:pathPrefix="/OK"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.org.uk"
+ android:pathPrefix="/viewcache.php"
+ android:scheme="http" />
+ </intent-filter>
+
+ <!-- opencaching.US -->
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="opencaching.us"
+ android:pathPrefix="/OU"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.us"
+ android:pathPrefix="/OU"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="www.opencaching.us"
+ android:pathPrefix="/viewcache.php"
+ android:scheme="http" />
+ </intent-filter>
</activity>
<activity
@@ -506,7 +809,7 @@
android:scheme="http" />
</intent-filter>
- <!-- GeoKrety URLs -->
+ <!-- GeoKrety.org -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
@@ -532,7 +835,7 @@
android:scheme="http" />
</intent-filter>
- <!-- GeoKretyMap URLs -->
+ <!-- GeoKretyMap.org -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index da3100c..9dc2362 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -242,31 +242,6 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
return;
}
}
- } else if (uriHost.contains("coord.info")) {
- if (StringUtils.startsWith(uriPath, "/gc")) {
- geocode = uriPath.substring(1).toUpperCase(Locale.US);
- } else {
- showToast(res.getString(R.string.err_detail_open));
- finish();
- return;
- }
- } else if (uriHost.contains("opencaching.de") || uriHost.contains("opencaching.fr")) {
- if (StringUtils.startsWith(uriPath, "/oc")) {
- geocode = uriPath.substring(1).toUpperCase(Locale.US);
- } else {
- geocode = uri.getQueryParameter("wp");
- if (StringUtils.isNotBlank(geocode)) {
- geocode = geocode.toUpperCase(Locale.US);
- } else {
- showToast(res.getString(R.string.err_detail_open));
- finish();
- return;
- }
- }
- } else {
- showToast(res.getString(R.string.err_detail_open));
- finish();
- return;
}
}
diff --git a/main/src/cgeo/geocaching/connector/oc/OCConnector.java b/main/src/cgeo/geocaching/connector/oc/OCConnector.java
index 8ac457b..6d7b23a 100644
--- a/main/src/cgeo/geocaching/connector/oc/OCConnector.java
+++ b/main/src/cgeo/geocaching/connector/oc/OCConnector.java
@@ -5,7 +5,9 @@ import cgeo.geocaching.R;
import cgeo.geocaching.connector.AbstractConnector;
import cgeo.geocaching.enumerations.LogType;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
@@ -83,4 +85,24 @@ public class OCConnector extends AbstractConnector {
return STANDARD_LOG_TYPES;
}
+
+ @Override
+ @Nullable
+ public String getGeocodeFromUrl(@NonNull final String url) {
+ // different opencaching installations have different supported URLs
+
+ // host.tld/geocode
+ final String shortHost = StringUtils.remove(getHost(), "www.");
+ String geocode = StringUtils.substringAfter(url, shortHost + "/");
+ if (canHandle(geocode)) {
+ return geocode;
+ }
+
+ // host.tld/viewcache.php?wp=geocode
+ geocode = StringUtils.substringAfter(url, shortHost + "/viewcache.php?wp=");
+ if (canHandle(geocode)) {
+ return geocode;
+ }
+ return super.getGeocodeFromUrl(url);
+ }
}
diff --git a/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java b/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java
index 0aad3aa..697b8d8 100644
--- a/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/oc/OCConnectorTest.java
@@ -24,4 +24,15 @@ public class OCConnectorTest extends TestCase {
return ocConnector;
}
+ public static void testGetGeocodeFromUrlDe() throws Exception {
+ final IConnector connector = ConnectorFactory.getConnector("OC0028");
+ assertThat(connector.getGeocodeFromUrl("http://opencaching.de/OC0028")).isEqualTo("OC0028");
+ assertThat(connector.getGeocodeFromUrl("http://www.opencaching.de/OC0028")).isEqualTo("OC0028");
+ }
+
+ public static void testGetGeocodeFromUrlUs() throws Exception {
+ final IConnector connector = ConnectorFactory.getConnector("OU07A0");
+ assertThat(connector.getGeocodeFromUrl("http://www.opencaching.us/viewcache.php?wp=OU07A0")).isEqualTo("OU07A0");
+ }
+
}