aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/Geocache.java7
-rw-r--r--main/src/cgeo/geocaching/network/HtmlImage.java10
-rw-r--r--main/src/cgeo/geocaching/utils/ImageUtils.java17
3 files changed, 24 insertions, 10 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java
index f6e3f18..a03f515 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.ImageUtils;
import cgeo.geocaching.utils.LazyInitializedList;
import cgeo.geocaching.utils.Log;
import cgeo.geocaching.utils.LogTemplateProvider;
@@ -159,6 +160,10 @@ public class Geocache implements ICache, IWaypoint {
private Handler changeNotificationHandler = null;
+ // Images whose URL contains one of those patterns will not be available on the Images tab
+ // for opening into an external application.
+ private final String[] NO_EXTERNAL = new String[]{"geocheck.org"};
+
/**
* Create a new cache. To be used everywhere except for the GPX parser
*/
@@ -1723,7 +1728,7 @@ public class Geocache implements ICache, IWaypoint {
Html.fromHtml(getDescription(), new ImageGetter() {
@Override
public Drawable getDrawable(final String source) {
- if (!urls.contains(source)) {
+ if (!urls.contains(source) && !ImageUtils.containsPattern(source, NO_EXTERNAL)) {
images.add(new Image(source, geocode));
urls.add(source);
}
diff --git a/main/src/cgeo/geocaching/network/HtmlImage.java b/main/src/cgeo/geocaching/network/HtmlImage.java
index 70cd095..5d713eb 100644
--- a/main/src/cgeo/geocaching/network/HtmlImage.java
+++ b/main/src/cgeo/geocaching/network/HtmlImage.java
@@ -132,7 +132,7 @@ public class HtmlImage implements Html.ImageGetter {
// decoding.
public Observable<BitmapDrawable> fetchDrawable(final String url) {
- if (StringUtils.isBlank(url) || isCounter(url)) {
+ if (StringUtils.isBlank(url) || ImageUtils.containsPattern(url, BLOCKED)) {
return Observable.from(getTransparent1x1Image(resources));
}
@@ -394,12 +394,4 @@ public class HtmlImage implements Html.ImageGetter {
bfOptions.inSampleSize = scale;
}
- private static boolean isCounter(final String url) {
- for (String entry : BLOCKED) {
- if (StringUtils.containsIgnoreCase(url, entry)) {
- return true;
- }
- }
- return false;
- }
}
diff --git a/main/src/cgeo/geocaching/utils/ImageUtils.java b/main/src/cgeo/geocaching/utils/ImageUtils.java
index 9f47ead..eb91724 100644
--- a/main/src/cgeo/geocaching/utils/ImageUtils.java
+++ b/main/src/cgeo/geocaching/utils/ImageUtils.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.utils;
import cgeo.geocaching.CgeoApplication;
import cgeo.geocaching.compatibility.Compatibility;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@@ -225,4 +226,20 @@ public final class ImageUtils {
}
return Uri.fromFile(file);
}
+
+ /**
+ * Check if the URL contains one of the given substrings.
+ *
+ * @param url the URL to check
+ * @param patterns a list of substrings to check against
+ * @return <tt>true</tt> if the URL contains at least one of the patterns, <tt>false</tt> otherwise
+ */
+ public static boolean containsPattern(final String url, final String[] patterns) {
+ for (String entry : patterns) {
+ if (StringUtils.containsIgnoreCase(url, entry)) {
+ return true;
+ }
+ }
+ return false;
+ }
}