From 167cf2ae835ea47d7458014185a6998a5657c81c Mon Sep 17 00:00:00 2001 From: Marco Jacob Date: Wed, 25 Jan 2012 22:12:47 +0100 Subject: first approach, not yet tested --- main/src/cgeo/geocaching/cgeocoords.java | 20 +++++++++++++++++++- main/src/cgeo/geocaching/cgeowaypointadd.java | 3 ++- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/cgeocoords.java b/main/src/cgeo/geocaching/cgeocoords.java index 367fb22..452d5fb 100644 --- a/main/src/cgeo/geocaching/cgeocoords.java +++ b/main/src/cgeo/geocaching/cgeocoords.java @@ -29,6 +29,7 @@ public class cgeocoords extends Dialog { final private AbstractActivity context; final private cgGeo geo; + final private cgCache cache; private Geopoint gp; private EditText eLat, eLon; @@ -44,10 +45,11 @@ public class cgeocoords extends Dialog { private coordInputFormatEnum currentFormat = null; - public cgeocoords(final AbstractActivity context, final Geopoint gp, final cgGeo geo) { + public cgeocoords(final AbstractActivity context, final cgCache cache, final Geopoint gp, final cgGeo geo) { super(context); this.context = context; this.geo = geo; + this.cache = cache; if (gp != null) { this.gp = gp; @@ -131,6 +133,8 @@ public class cgeocoords extends Dialog { final Button buttonCurrent = (Button) findViewById(R.id.current); buttonCurrent.setOnClickListener(new CurrentListener()); + final Button buttonCache = (Button) findViewById(R.id.cache); + buttonCache.setOnClickListener(new CacheListener()); final Button buttonDone = (Button) findViewById(R.id.done); buttonDone.setOnClickListener(new InputDoneListener()); } @@ -481,6 +485,20 @@ public class cgeocoords extends Dialog { } } + private class CacheListener implements View.OnClickListener { + + @Override + public void onClick(View v) { + if (cache == null || cache.getCoords() == null) { + context.showToast(context.getResources().getString(R.string.err_location_unknown)); + return; + } + + gp = cache.getCoords(); + updateGUI(); + } + } + private class InputDoneListener implements View.OnClickListener { @Override diff --git a/main/src/cgeo/geocaching/cgeowaypointadd.java b/main/src/cgeo/geocaching/cgeowaypointadd.java index 74aee55..66e000e 100644 --- a/main/src/cgeo/geocaching/cgeowaypointadd.java +++ b/main/src/cgeo/geocaching/cgeowaypointadd.java @@ -229,7 +229,8 @@ public class cgeowaypointadd extends AbstractActivity { if (waypoint != null && waypoint.getCoords() != null) { gp = waypoint.getCoords(); } - cgeocoords coordsDialog = new cgeocoords(cgeowaypointadd.this, gp, geo); + cgCache cache = app.getCacheByGeocode(geocode); + cgeocoords coordsDialog = new cgeocoords(cgeowaypointadd.this, cache, gp, geo); coordsDialog.setCancelable(true); coordsDialog.setOnCoordinateUpdate(new cgeocoords.CoordinateUpdate() { @Override -- cgit v1.1 From 82918dd9e17d7871a43dc4e7c553df10ec82a799 Mon Sep 17 00:00:00 2001 From: Marco Jacob Date: Thu, 26 Jan 2012 21:05:05 +0100 Subject: Cache coords button invisible in other modes --- main/src/cgeo/geocaching/cgeoadvsearch.java | 2 +- main/src/cgeo/geocaching/cgeocoords.java | 6 +++++- main/src/cgeo/geocaching/cgeopoint.java | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/cgeoadvsearch.java b/main/src/cgeo/geocaching/cgeoadvsearch.java index 0951b31..754cbdb 100644 --- a/main/src/cgeo/geocaching/cgeoadvsearch.java +++ b/main/src/cgeo/geocaching/cgeoadvsearch.java @@ -263,7 +263,7 @@ public class cgeoadvsearch extends AbstractActivity { @Override public void onClick(View arg0) { - cgeocoords coordsDialog = new cgeocoords(cgeoadvsearch.this, null, geo); + cgeocoords coordsDialog = new cgeocoords(cgeoadvsearch.this, null, null, geo); coordsDialog.setCancelable(true); coordsDialog.setOnCoordinateUpdate(new cgeocoords.CoordinateUpdate() { @Override diff --git a/main/src/cgeo/geocaching/cgeocoords.java b/main/src/cgeo/geocaching/cgeocoords.java index 452d5fb..ff752f9 100644 --- a/main/src/cgeo/geocaching/cgeocoords.java +++ b/main/src/cgeo/geocaching/cgeocoords.java @@ -134,7 +134,11 @@ public class cgeocoords extends Dialog { final Button buttonCurrent = (Button) findViewById(R.id.current); buttonCurrent.setOnClickListener(new CurrentListener()); final Button buttonCache = (Button) findViewById(R.id.cache); - buttonCache.setOnClickListener(new CacheListener()); + if (cache != null) { + buttonCache.setOnClickListener(new CacheListener()); + } else { + buttonCache.setVisibility(View.INVISIBLE); + } final Button buttonDone = (Button) findViewById(R.id.done); buttonDone.setOnClickListener(new InputDoneListener()); } diff --git a/main/src/cgeo/geocaching/cgeopoint.java b/main/src/cgeo/geocaching/cgeopoint.java index 5d109c4..1800b72 100644 --- a/main/src/cgeo/geocaching/cgeopoint.java +++ b/main/src/cgeo/geocaching/cgeopoint.java @@ -285,7 +285,7 @@ public class cgeopoint extends AbstractActivity { if (latButton.getText().length() > 0 && lonButton.getText().length() > 0) { gp = new Geopoint(latButton.getText().toString() + " " + lonButton.getText().toString()); } - cgeocoords coordsDialog = new cgeocoords(cgeopoint.this, gp, geo); + cgeocoords coordsDialog = new cgeocoords(cgeopoint.this, null, gp, geo); coordsDialog.setCancelable(true); coordsDialog.setOnCoordinateUpdate(new cgeocoords.CoordinateUpdate() { @Override -- cgit v1.1 From 28fc9c31aad49ad911d950bb9d624d6905e2c459 Mon Sep 17 00:00:00 2001 From: Marco Jacob Date: Thu, 26 Jan 2012 21:26:31 +0100 Subject: View.GONE instead of View.INVISIBLE --- main/src/cgeo/geocaching/cgeocoords.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/cgeocoords.java b/main/src/cgeo/geocaching/cgeocoords.java index ff752f9..3aadf05 100644 --- a/main/src/cgeo/geocaching/cgeocoords.java +++ b/main/src/cgeo/geocaching/cgeocoords.java @@ -137,7 +137,7 @@ public class cgeocoords extends Dialog { if (cache != null) { buttonCache.setOnClickListener(new CacheListener()); } else { - buttonCache.setVisibility(View.INVISIBLE); + buttonCache.setVisibility(View.GONE); } final Button buttonDone = (Button) findViewById(R.id.done); buttonDone.setOnClickListener(new InputDoneListener()); -- cgit v1.1 From 460d78b9518386f567e5a4c5752ad653a3a48419 Mon Sep 17 00:00:00 2001 From: Torsten Keil Date: Sun, 29 Jan 2012 21:31:43 +0100 Subject: Added Geocode to entries in history list. --- main/src/cgeo/geocaching/ui/CacheListAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/ui/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java index bc046f1..3a93c6a 100644 --- a/main/src/cgeo/geocaching/ui/CacheListAdapter.java +++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java @@ -574,6 +574,10 @@ public class CacheListAdapter extends ArrayAdapter { cacheInfo.append(cgBase.formatTime(cache.getVisitedDate())); cacheInfo.append("; "); cacheInfo.append(cgBase.formatDate(cache.getVisitedDate())); + if (StringUtils.isNotBlank(cache.getGeocode())) { + cacheInfo.append(SEPARATOR); + cacheInfo.append(StringUtils.upperCase(cache.getGeocode())); + } holder.info.setText(cacheInfo.toString()); } else { ArrayList infos = new ArrayList(); -- cgit v1.1 From 6211a34e94f2355d4b0613c062fd126fc135f1dc Mon Sep 17 00:00:00 2001 From: Torsten Keil Date: Mon, 30 Jan 2012 20:55:34 +0100 Subject: changed order and used new separator --- main/src/cgeo/geocaching/ui/CacheListAdapter.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/ui/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java index 3a93c6a..0a4e395 100644 --- a/main/src/cgeo/geocaching/ui/CacheListAdapter.java +++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java @@ -570,15 +570,11 @@ public class CacheListAdapter extends ArrayAdapter { holder.favourite.setBackgroundResource(favoriteBack); if (cacheListType == CacheListType.HISTORY && cache.getVisitedDate() > 0) { - StringBuilder cacheInfo = new StringBuilder(50); - cacheInfo.append(cgBase.formatTime(cache.getVisitedDate())); - cacheInfo.append("; "); - cacheInfo.append(cgBase.formatDate(cache.getVisitedDate())); - if (StringUtils.isNotBlank(cache.getGeocode())) { - cacheInfo.append(SEPARATOR); - cacheInfo.append(StringUtils.upperCase(cache.getGeocode())); - } - holder.info.setText(cacheInfo.toString()); + ArrayList infos = new ArrayList(); + infos.add(StringUtils.upperCase(cache.getGeocode())); + infos.add(cgBase.formatDate(cache.getVisitedDate())); + infos.add(cgBase.formatTime(cache.getVisitedDate())); + holder.info.setText(StringUtils.join(infos, SEPARATOR)); } else { ArrayList infos = new ArrayList(); if (StringUtils.isNotBlank(cache.getGeocode())) { -- cgit v1.1 From cff161c259ff85c603478a95e7dcd6c01d66e9e5 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Tue, 31 Jan 2012 07:32:40 +0100 Subject: fix #1071: FC with unknown container size --- main/src/cgeo/geocaching/cgCache.java | 10 +++++++++- main/src/cgeo/geocaching/cgCoord.java | 2 +- main/src/cgeo/geocaching/files/LocParser.java | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index 432bd93..9fdaaaf 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -507,6 +507,9 @@ public class cgCache implements ICache { @Override public CacheSize getSize() { + if (size == null) { + return CacheSize.UNKNOWN; + } return size; } @@ -986,7 +989,12 @@ public class cgCache implements ICache { } public void setSize(CacheSize size) { - this.size = size; + if (size == null) { + this.size = CacheSize.UNKNOWN; + } + else { + this.size = size; + } } public void setDifficulty(float difficulty) { diff --git a/main/src/cgeo/geocaching/cgCoord.java b/main/src/cgeo/geocaching/cgCoord.java index 010fc22..0c5b5b5 100644 --- a/main/src/cgeo/geocaching/cgCoord.java +++ b/main/src/cgeo/geocaching/cgCoord.java @@ -20,7 +20,7 @@ public class cgCoord implements IBasicCache, IWaypoint { private Geopoint coords = new Geopoint(0, 0); private float difficulty = 0; private float terrain = 0; - private CacheSize size = null; + private CacheSize size = CacheSize.UNKNOWN; public cgCoord() { } diff --git a/main/src/cgeo/geocaching/files/LocParser.java b/main/src/cgeo/geocaching/files/LocParser.java index 38ddb80..7a8a674 100644 --- a/main/src/cgeo/geocaching/files/LocParser.java +++ b/main/src/cgeo/geocaching/files/LocParser.java @@ -125,7 +125,7 @@ public final class LocParser extends FileParser { } else if (size == 8) { pointCoord.setSize(CacheSize.SMALL); } else { - pointCoord.setSize(null); + pointCoord.setSize(CacheSize.UNKNOWN); } } -- cgit v1.1 From 51401c77601ef356c57772d1fb04cb7663811dbe Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Tue, 31 Jan 2012 07:39:04 +0100 Subject: refactoring: remove duplicate method --- main/src/cgeo/geocaching/apps/AbstractApp.java | 22 ++-------------------- main/src/cgeo/geocaching/cgeo.java | 4 ++-- 2 files changed, 4 insertions(+), 22 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/apps/AbstractApp.java b/main/src/cgeo/geocaching/apps/AbstractApp.java index 0c38b02..1161a05 100644 --- a/main/src/cgeo/geocaching/apps/AbstractApp.java +++ b/main/src/cgeo/geocaching/apps/AbstractApp.java @@ -1,15 +1,11 @@ package cgeo.geocaching.apps; +import cgeo.geocaching.cgeo; import cgeo.geocaching.cgeoapplication; -import org.apache.commons.collections.CollectionUtils; - import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; - -import java.util.List; public abstract class AbstractApp implements App { @@ -48,21 +44,7 @@ public abstract class AbstractApp implements App { if (getLaunchIntent(context) != null) { return true; } - return isIntentAvailable(context, intent); - } - - private static boolean isIntentAvailable(Context context, String action) { - final Intent intent = new Intent(action); - - return isIntentAvailable(context, intent); - } - - protected static boolean isIntentAvailable(Context context, Intent intent) { - final PackageManager packageManager = context.getPackageManager(); - final List list = packageManager.queryIntentActivities( - intent, PackageManager.MATCH_DEFAULT_ONLY); - - return CollectionUtils.isNotEmpty(list); + return cgeo.isIntentAvailable(context, intent); } @Override diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java index ff47b15..4de8e50 100644 --- a/main/src/cgeo/geocaching/cgeo.java +++ b/main/src/cgeo/geocaching/cgeo.java @@ -262,12 +262,12 @@ public class cgeo extends AbstractActivity { return true; } - private static boolean isIntentAvailable(Context context, String intent) { + public static boolean isIntentAvailable(Context context, String intent) { final PackageManager packageManager = context.getPackageManager(); final List list = packageManager.queryIntentActivities( new Intent(intent), PackageManager.MATCH_DEFAULT_ONLY); - return list.size() > 0; + return CollectionUtils.isNotEmpty(list); } @Override -- cgit v1.1 From e75feb79ade4d2978e52e12420ee68c19bf3db6b Mon Sep 17 00:00:00 2001 From: blafoo Date: Tue, 31 Jan 2012 18:43:29 +0100 Subject: Number of caches found. Fixes #1072 --- main/src/cgeo/geocaching/GCConstants.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/GCConstants.java b/main/src/cgeo/geocaching/GCConstants.java index eb6f61e..7130a05 100644 --- a/main/src/cgeo/geocaching/GCConstants.java +++ b/main/src/cgeo/geocaching/GCConstants.java @@ -59,8 +59,7 @@ public final class GCConstants { // Info box top-right public static final Pattern PATTERN_LOGIN_NAME = Pattern.compile("\"SignedInProfileLink\">([^<]+)"); public static final Pattern PATTERN_MEMBER_STATUS = Pattern.compile("([^<]+)"); - public static final Pattern PATTERN_CACHES_FOUND = Pattern.compile("title=\"Caches Found\"\\s*/>\\s*(\\d+)<"); - + public static final Pattern PATTERN_CACHES_FOUND = Pattern.compile(" (\\d+)&"); public static final Pattern PATTERN_AVATAR_IMAGE_PROFILE_PAGE = Pattern.compile("]*\\salt=\"Avatar\""); public static final Pattern PATTERN_LOGIN_NAME_LOGIN_PAGE = Pattern.compile("You are logged in as[^<]*]*>([^<]+)[^<]*"); public static final Pattern PATTERN_USERLOGGEDIN = Pattern.compile("Hello, (.*?)"); -- cgit v1.1 From 19a3e9b8e9b510daec48ad293381cb8c2658d611 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Tue, 31 Jan 2012 22:51:56 +0100 Subject: fix #1072: Visual login is not showing find-count --- main/src/cgeo/geocaching/GCConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/GCConstants.java b/main/src/cgeo/geocaching/GCConstants.java index 7130a05..a37b264 100644 --- a/main/src/cgeo/geocaching/GCConstants.java +++ b/main/src/cgeo/geocaching/GCConstants.java @@ -59,7 +59,7 @@ public final class GCConstants { // Info box top-right public static final Pattern PATTERN_LOGIN_NAME = Pattern.compile("\"SignedInProfileLink\">([^<]+)"); public static final Pattern PATTERN_MEMBER_STATUS = Pattern.compile("([^<]+)"); - public static final Pattern PATTERN_CACHES_FOUND = Pattern.compile(" (\\d+)&"); + public static final Pattern PATTERN_CACHES_FOUND = Pattern.compile("title=\"Caches Found\"\\s*/>\\s*(\\d+)"); public static final Pattern PATTERN_AVATAR_IMAGE_PROFILE_PAGE = Pattern.compile("]*\\salt=\"Avatar\""); public static final Pattern PATTERN_LOGIN_NAME_LOGIN_PAGE = Pattern.compile("You are logged in as[^<]*]*>([^<]+)[^<]*"); public static final Pattern PATTERN_USERLOGGEDIN = Pattern.compile("Hello, (.*?)"); -- cgit v1.1