From 9e830e2313fb9570d7e322dfa0cd5bc79cfd8645 Mon Sep 17 00:00:00 2001 From: Karsten Priegnitz Date: Tue, 23 Aug 2011 06:52:47 +0200 Subject: my name --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 715b53e..22cd548 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -916,7 +916,7 @@ · thiasB (code, loc. DE EN)\n · YraFyra (code, loc. SV)\n · zenobios (code, loc. DE EN)\n - · Köm (code, artwork computation)\n + · Karsten Priegnitz (code, artwork computation)\n \n · Mapsforge (OSM-rendering)\n · The Noun Project (graphics)\n -- cgit v1.1 From 7ccf3a1f52505905829b4e5f393cbea3677f4fed Mon Sep 17 00:00:00 2001 From: Karsten Priegnitz Date: Fri, 26 Aug 2011 16:46:17 +0200 Subject: attribute icon things --- .../Noun Project - Creative Commons Attribution.pdf | Bin 0 -> 56152 bytes res/values/strings.xml | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) create mode 100644 project/attributes/Noun Project - Creative Commons Attribution.pdf diff --git a/project/attributes/Noun Project - Creative Commons Attribution.pdf b/project/attributes/Noun Project - Creative Commons Attribution.pdf new file mode 100644 index 0000000..14f0c29 Binary files /dev/null and b/project/attributes/Noun Project - Creative Commons Attribution.pdf differ diff --git a/res/values/strings.xml b/res/values/strings.xml index 80089cf..78fc863 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -903,7 +903,6 @@ · Iiro Jäppinen (graphic)\n · inkantis (localization PL)\n · Jan Žatecký (graphic)\n - · Köm (code, artwork computation)\n · MichielK (code, loc. NL)\n · Pascal (localization NL)\n · Peter (localization HU)\n @@ -920,7 +919,7 @@ · Karsten Priegnitz (code, artwork computation)\n \n · Mapsforge (OSM-rendering)\n - · The Noun Project (graphics)\n + · The Noun Project (basis for attribute icons)\n -- cgit v1.1 From 5d0ae5674e92d70e97eea7e482ff861784332f95 Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Tue, 30 Aug 2011 21:34:59 +0200 Subject: refactoring: remove duplicate code --- src/cgeo/geocaching/apps/cache/navi/LocusApp.java | 8 +- .../apps/cachelist/LocusCacheListApp.java | 2 +- src/cgeo/geocaching/cgBase.java | 126 +++++++++++++-------- src/cgeo/geocaching/cgCacheListAdapter.java | 27 ++--- src/cgeo/geocaching/cgeocaches.java | 33 ++++++ src/cgeo/geocaching/cgeodetail.java | 51 +-------- src/cgeo/geocaching/cgeopopup.java | 36 +----- src/cgeo/geocaching/cgeotrackable.java | 18 +-- src/cgeo/geocaching/cgeowaypoint.java | 10 +- src/cgeo/geocaching/mapcommon/cgeomap.java | 6 +- 10 files changed, 135 insertions(+), 182 deletions(-) diff --git a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java index 2b4baf4..41b9896 100644 --- a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java +++ b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java @@ -60,12 +60,12 @@ class LocusApp extends AbstractLocusApp implements NavigationApp { int icon = -1; if (cache != null) { - icon = cgBase.getIcon(true, cache.type, cache.own, cache.found, + icon = cgBase.getMarkerIcon(true, cache.type, cache.own, cache.found, cache.disabled || cache.archived); } else if (waypoint != null) { - icon = cgBase.getIcon(false, waypoint.type, false, false, false); + icon = cgBase.getMarkerIcon(false, waypoint.type, false, false, false); } else { - icon = cgBase.getIcon(false, "waypoint", false, false, false); + icon = cgBase.getMarkerIcon(false, "waypoint", false, false, false); } if (icon > 0) { @@ -139,7 +139,7 @@ class LocusApp extends AbstractLocusApp implements NavigationApp { continue; } - final int wpIcon = cgBase.getIcon(false, wp.type, false, + final int wpIcon = cgBase.getMarkerIcon(false, wp.type, false, false, false); if (wpIcon > 0) { diff --git a/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java b/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java index 0e03821..a9c438b 100644 --- a/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java +++ b/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java @@ -44,7 +44,7 @@ class LocusCacheListApp extends AbstractLocusApp implements CacheListApp { // cache waypoints for (cgCache cache : cacheListCoord) { - final int wpIcon = cgBase.getIcon(true, cache.type, cache.own, cache.found, cache.disabled); + final int wpIcon = cgBase.getMarkerIcon(true, cache.type, cache.own, cache.found, cache.disabled); if (wpIcon > 0) { // load icon diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java index c8a5f14..79e67b5 100644 --- a/src/cgeo/geocaching/cgBase.java +++ b/src/cgeo/geocaching/cgBase.java @@ -5022,9 +5022,85 @@ public class cgBase { } return out; } + + public static int getCacheIcon(final String type) { + fillIconsMap(); + Integer iconId = gcIcons.get("type_" + type); + if (iconId != null) { + return iconId; + } + // fallback to traditional if some icon type is not correct + return gcIcons.get("type_traditional"); + } + + public static int getMarkerIcon(final boolean cache, final String type, final boolean own, final boolean found, final boolean disabled) { + fillIconsMap(); + + if (wpIcons.isEmpty()) { + wpIcons.put("waypoint", R.drawable.marker_waypoint_waypoint); + wpIcons.put("flag", R.drawable.marker_waypoint_flag); + wpIcons.put("pkg", R.drawable.marker_waypoint_pkg); + wpIcons.put("puzzle", R.drawable.marker_waypoint_puzzle); + wpIcons.put("stage", R.drawable.marker_waypoint_stage); + wpIcons.put("trailhead", R.drawable.marker_waypoint_trailhead); + } + + int icon = -1; + String iconTxt = null; + + if (cache) { + if (type != null && type.length() > 0) { + if (own) { + iconTxt = type + "-own"; + } else if (found) { + iconTxt = type + "-found"; + } else if (disabled) { + iconTxt = type + "-disabled"; + } else { + iconTxt = type; + } + } else { + iconTxt = "traditional"; + } + + if (gcIcons.containsKey(iconTxt)) { + icon = gcIcons.get(iconTxt); + } else { + icon = gcIcons.get("traditional"); + } + } else { + if (type != null && type.length() > 0) { + iconTxt = type; + } else { + iconTxt = "waypoint"; + } + + if (wpIcons.containsKey(iconTxt)) { + icon = wpIcons.get(iconTxt); + } else { + icon = wpIcons.get("waypoint"); + } + } + + return icon; + } - public static int getIcon(boolean cache, String type, boolean own, boolean found, boolean disabled) { + private static void fillIconsMap() { if (gcIcons.isEmpty()) { + gcIcons.put("type_ape", R.drawable.type_ape); + gcIcons.put("type_cito", R.drawable.type_cito); + gcIcons.put("type_earth", R.drawable.type_earth); + gcIcons.put("type_event", R.drawable.type_event); + gcIcons.put("type_letterbox", R.drawable.type_letterbox); + gcIcons.put("type_locationless", R.drawable.type_locationless); + gcIcons.put("type_mega", R.drawable.type_mega); + gcIcons.put("type_multi", R.drawable.type_multi); + gcIcons.put("type_traditional", R.drawable.type_traditional); + gcIcons.put("type_virtual", R.drawable.type_virtual); + gcIcons.put("type_webcam", R.drawable.type_webcam); + gcIcons.put("type_wherigo", R.drawable.type_wherigo); + gcIcons.put("type_mystery", R.drawable.type_mystery); + gcIcons.put("type_gchq", R.drawable.type_hq); // default markers gcIcons.put("ape", R.drawable.marker_cache_ape); gcIcons.put("cito", R.drawable.marker_cache_cito); @@ -5086,54 +5162,6 @@ public class cgBase { gcIcons.put("mystery-disabled", R.drawable.marker_cache_mystery_disabled); gcIcons.put("gchq-disabled", R.drawable.marker_cache_gchq_disabled); } - - if (wpIcons.isEmpty()) { - wpIcons.put("waypoint", R.drawable.marker_waypoint_waypoint); - wpIcons.put("flag", R.drawable.marker_waypoint_flag); - wpIcons.put("pkg", R.drawable.marker_waypoint_pkg); - wpIcons.put("puzzle", R.drawable.marker_waypoint_puzzle); - wpIcons.put("stage", R.drawable.marker_waypoint_stage); - wpIcons.put("trailhead", R.drawable.marker_waypoint_trailhead); - } - - int icon = -1; - String iconTxt = null; - - if (cache) { - if (type != null && type.length() > 0) { - if (own) { - iconTxt = type + "-own"; - } else if (found) { - iconTxt = type + "-found"; - } else if (disabled) { - iconTxt = type + "-disabled"; - } else { - iconTxt = type; - } - } else { - iconTxt = "traditional"; - } - - if (gcIcons.containsKey(iconTxt)) { - icon = gcIcons.get(iconTxt); - } else { - icon = gcIcons.get("traditional"); - } - } else { - if (type != null && type.length() > 0) { - iconTxt = type; - } else { - iconTxt = "waypoint"; - } - - if (wpIcons.containsKey(iconTxt)) { - icon = wpIcons.get(iconTxt); - } else { - icon = wpIcons.get("waypoint"); - } - } - - return icon; } public static boolean runNavigation(Activity activity, Resources res, cgSettings settings, Double latitude, Double longitude) { diff --git a/src/cgeo/geocaching/cgCacheListAdapter.java b/src/cgeo/geocaching/cgCacheListAdapter.java index 64bf3ea..57c6e5f 100644 --- a/src/cgeo/geocaching/cgCacheListAdapter.java +++ b/src/cgeo/geocaching/cgCacheListAdapter.java @@ -55,7 +55,7 @@ public class cgCacheListAdapter extends ArrayAdapter { private boolean sort = true; private int checked = 0; private boolean selectMode = false; - private HashMap gcIcons = new HashMap(); + private static HashMap gcIconDrawables = new HashMap(); private ArrayList compasses = new ArrayList(); private ArrayList distances = new ArrayList(); private int[] ratingBcgs = new int[3]; @@ -81,21 +81,10 @@ public class cgCacheListAdapter extends ArrayAdapter { activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); pixelDensity = metrics.density; - if (gcIcons == null || gcIcons.isEmpty()) { - gcIcons.put("ape", (Drawable) activity.getResources().getDrawable(R.drawable.type_ape)); - gcIcons.put("cito", (Drawable) activity.getResources().getDrawable(R.drawable.type_cito)); - gcIcons.put("earth", (Drawable) activity.getResources().getDrawable(R.drawable.type_earth)); - gcIcons.put("event", (Drawable) activity.getResources().getDrawable(R.drawable.type_event)); - gcIcons.put("letterbox", (Drawable) activity.getResources().getDrawable(R.drawable.type_letterbox)); - gcIcons.put("locationless", (Drawable) activity.getResources().getDrawable(R.drawable.type_locationless)); - gcIcons.put("mega", (Drawable) activity.getResources().getDrawable(R.drawable.type_mega)); - gcIcons.put("multi", (Drawable) activity.getResources().getDrawable(R.drawable.type_multi)); - gcIcons.put("traditional", (Drawable) activity.getResources().getDrawable(R.drawable.type_traditional)); - gcIcons.put("virtual", (Drawable) activity.getResources().getDrawable(R.drawable.type_virtual)); - gcIcons.put("webcam", (Drawable) activity.getResources().getDrawable(R.drawable.type_webcam)); - gcIcons.put("wherigo", (Drawable) activity.getResources().getDrawable(R.drawable.type_wherigo)); - gcIcons.put("mystery", (Drawable) activity.getResources().getDrawable(R.drawable.type_mystery)); - gcIcons.put("gchq", (Drawable) activity.getResources().getDrawable(R.drawable.type_hq)); + if (gcIconDrawables == null || gcIconDrawables.isEmpty()) { + for (String cacheType : cgBase.cacheTypesInv.keySet()) { + gcIconDrawables.put(cacheType, (Drawable) activity.getResources().getDrawable(cgBase.getCacheIcon(cacheType))); + } } if (settings.skin == 0) { @@ -471,10 +460,10 @@ public class cgCacheListAdapter extends ArrayAdapter { } holder.text.setText(cache.nameSp, TextView.BufferType.SPANNABLE); - if (gcIcons.containsKey(cache.type)) { // cache icon - holder.text.setCompoundDrawablesWithIntrinsicBounds(gcIcons.get(cache.type), null, null, null); + if (gcIconDrawables.containsKey(cache.type)) { // cache icon + holder.text.setCompoundDrawablesWithIntrinsicBounds(gcIconDrawables.get(cache.type), null, null, null); } else { // unknown cache type, "mystery" icon - holder.text.setCompoundDrawablesWithIntrinsicBounds(gcIcons.get("mystery"), null, null, null); + holder.text.setCompoundDrawablesWithIntrinsicBounds(gcIconDrawables.get("mystery"), null, null, null); } if (holder.inventory.getChildCount() > 0) { diff --git a/src/cgeo/geocaching/cgeocaches.java b/src/cgeo/geocaching/cgeocaches.java index 40b379f..c01ae72 100644 --- a/src/cgeo/geocaching/cgeocaches.java +++ b/src/cgeo/geocaching/cgeocaches.java @@ -40,6 +40,7 @@ import android.widget.EditText; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView; +import cgeo.geocaching.activity.AbstractActivity; import cgeo.geocaching.activity.AbstractListActivity; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.apps.cache.navi.NavigationAppFactory; @@ -2546,4 +2547,36 @@ public class cgeocaches extends AbstractListActivity { cachesIntent.putExtra(EXTRAS_LIST_TYPE, "offline"); context.startActivity(cachesIntent); } + + public static void startActivityCachesAround(final AbstractActivity context, final Double latitude, final Double longitude) { + cgeocaches cachesActivity = new cgeocaches(); + + Intent cachesIntent = new Intent(context, cachesActivity.getClass()); + cachesIntent.putExtra("type", "coordinate"); + cachesIntent.putExtra("latitude", latitude); + cachesIntent.putExtra("longitude", longitude); + cachesIntent.putExtra("cachetype", context.getSettings().cacheType); + + context.startActivity(cachesIntent); + } + + public static void startActivityCacheOwner(final AbstractActivity context, final String userName) { + final Intent cachesIntent = new Intent(context, cgeocaches.class); + + cachesIntent.putExtra("type", "owner"); + cachesIntent.putExtra("username", userName); + cachesIntent.putExtra("cachetype", context.getSettings().cacheType); + + context.startActivity(cachesIntent); + } + + public static void startActivityCacheUser(final AbstractActivity context, final String userName) { + final Intent cachesIntent = new Intent(context, cgeocaches.class); + + cachesIntent.putExtra("type", "username"); + cachesIntent.putExtra("username", userName); + cachesIntent.putExtra("cachetype", context.getSettings().cacheType); + + context.startActivity(cachesIntent); + } } \ No newline at end of file diff --git a/src/cgeo/geocaching/cgeodetail.java b/src/cgeo/geocaching/cgeodetail.java index 225e345..e4d748c 100644 --- a/src/cgeo/geocaching/cgeodetail.java +++ b/src/cgeo/geocaching/cgeodetail.java @@ -80,7 +80,6 @@ public class cgeodetail extends AbstractActivity { private loadLongDesc threadLongDesc = null; private Thread storeThread = null; private Thread refreshThread = null; - private HashMap gcIcons = new HashMap(); private ProgressDialog storeDialog = null; private ProgressDialog refreshDialog = null; private ProgressDialog dropDialog = null; @@ -449,24 +448,10 @@ public class cgeodetail extends AbstractActivity { final int id = item.getItemId(); if (id == 1) { - final Intent cachesIntent = new Intent(this, cgeocaches.class); - - cachesIntent.putExtra("type", "owner"); - cachesIntent.putExtra("username", contextMenuUser); - cachesIntent.putExtra("cachetype", settings.cacheType); - - startActivity(cachesIntent); - + cgeocaches.startActivityCacheOwner(this, contextMenuUser); return true; } else if (id == 2) { - final Intent cachesIntent = new Intent(this, cgeocaches.class); - - cachesIntent.putExtra("type", "username"); - cachesIntent.putExtra("username", contextMenuUser); - cachesIntent.putExtra("cachetype", settings.cacheType); - - startActivity(cachesIntent); - + cgeocaches.startActivityCacheUser(this, contextMenuUser); return true; } else if (id == 3) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/profile/?u=" + URLEncoder.encode(contextMenuUser)))); @@ -601,22 +586,6 @@ public class cgeodetail extends AbstractActivity { } try { - if (gcIcons == null || gcIcons.isEmpty()) { - gcIcons.put("ape", R.drawable.type_ape); - gcIcons.put("cito", R.drawable.type_cito); - gcIcons.put("earth", R.drawable.type_earth); - gcIcons.put("event", R.drawable.type_event); - gcIcons.put("letterbox", R.drawable.type_letterbox); - gcIcons.put("locationless", R.drawable.type_locationless); - gcIcons.put("mega", R.drawable.type_mega); - gcIcons.put("multi", R.drawable.type_multi); - gcIcons.put("traditional", R.drawable.type_traditional); - gcIcons.put("virtual", R.drawable.type_virtual); - gcIcons.put("webcam", R.drawable.type_webcam); - gcIcons.put("wherigo", R.drawable.type_wherigo); - gcIcons.put("gchq", R.drawable.type_hq); - gcIcons.put("mystery", R.drawable.type_mystery); - } if (null == geocode && cache.geocode.length() > 0) { @@ -639,11 +608,7 @@ public class cgeodetail extends AbstractActivity { detailsList.removeAllViews(); // actionbar icon, default myster< - String typeId = "mystery"; - if (cache.type != null && gcIcons.containsKey(cache.type)) { // cache icon - typeId = cache.type; - } - ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) getResources().getDrawable(gcIcons.get(typeId)), null, null, null); + ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) getResources().getDrawable(cgBase.getCacheIcon(cache.type)), null, null, null); // cache name (full name) itemLayout = (RelativeLayout) inflater.inflate(R.layout.cache_item, null); @@ -1426,15 +1391,7 @@ public class cgeodetail extends AbstractActivity { } private void cachesAround() { - cgeocaches cachesActivity = new cgeocaches(); - - Intent cachesIntent = new Intent(this, cachesActivity.getClass()); - cachesIntent.putExtra("type", "coordinate"); - cachesIntent.putExtra("latitude", cache.latitude); - cachesIntent.putExtra("longitude", cache.longitude); - cachesIntent.putExtra("cachetype", settings.cacheType); - - startActivity(cachesIntent); + cgeocaches.startActivityCachesAround(this, cache.latitude, cache.longitude); finish(); } diff --git a/src/cgeo/geocaching/cgeopopup.java b/src/cgeo/geocaching/cgeopopup.java index 54be58c..8531338 100644 --- a/src/cgeo/geocaching/cgeopopup.java +++ b/src/cgeo/geocaching/cgeopopup.java @@ -1,6 +1,5 @@ package cgeo.geocaching; -import java.util.HashMap; import java.util.Locale; import android.app.ProgressDialog; @@ -38,7 +37,6 @@ public class cgeopopup extends AbstractActivity { private ProgressDialog storeDialog = null; private ProgressDialog dropDialog = null; private TextView cacheDistance = null; - private HashMap gcIcons = new HashMap(); private Handler ratingHandler = new Handler() { @Override @@ -214,23 +212,6 @@ public class cgeopopup extends AbstractActivity { TextView itemValue; LinearLayout itemStars; - if (gcIcons == null || gcIcons.isEmpty()) { - gcIcons.put("ape", R.drawable.type_ape); - gcIcons.put("cito", R.drawable.type_cito); - gcIcons.put("earth", R.drawable.type_earth); - gcIcons.put("event", R.drawable.type_event); - gcIcons.put("letterbox", R.drawable.type_letterbox); - gcIcons.put("locationless", R.drawable.type_locationless); - gcIcons.put("mega", R.drawable.type_mega); - gcIcons.put("multi", R.drawable.type_multi); - gcIcons.put("traditional", R.drawable.type_traditional); - gcIcons.put("virtual", R.drawable.type_virtual); - gcIcons.put("webcam", R.drawable.type_webcam); - gcIcons.put("wherigo", R.drawable.type_wherigo); - gcIcons.put("mystery", R.drawable.type_mystery); - gcIcons.put("gchq", R.drawable.type_hq); - } - if (cache.name != null && cache.name.length() > 0) { setTitle(cache.name); } else { @@ -245,11 +226,7 @@ public class cgeopopup extends AbstractActivity { detailsList.removeAllViews(); // actionbar icon - if (cache.type != null && gcIcons.containsKey(cache.type)) { // cache icon - ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) getResources().getDrawable(gcIcons.get(cache.type)), null, null, null); - } else { // unknown cache type, "mystery" icon - ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) getResources().getDrawable(gcIcons.get("mystery")), null, null, null); - } + ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds((Drawable) getResources().getDrawable(cgBase.getCacheIcon(cache.type)), null, null, null); // cache type itemLayout = (RelativeLayout) inflater.inflate(R.layout.cache_item, null); @@ -561,16 +538,7 @@ public class cgeopopup extends AbstractActivity { showToast(res.getString(R.string.err_location_unknown)); } - cgeocaches cachesActivity = new cgeocaches(); - - Intent cachesIntent = new Intent(this, cachesActivity.getClass()); - - cachesIntent.putExtra("type", "coordinate"); - cachesIntent.putExtra("latitude", cache.latitude); - cachesIntent.putExtra("longitude", cache.longitude); - cachesIntent.putExtra("cachetype", settings.cacheType); - - startActivity(cachesIntent); + cgeocaches.startActivityCachesAround(this, cache.latitude, cache.longitude); finish(); } diff --git a/src/cgeo/geocaching/cgeotrackable.java b/src/cgeo/geocaching/cgeotrackable.java index d0f82be..d41324e 100644 --- a/src/cgeo/geocaching/cgeotrackable.java +++ b/src/cgeo/geocaching/cgeotrackable.java @@ -420,24 +420,10 @@ public class cgeotrackable extends AbstractActivity { final int id = item.getItemId(); if (id == 1) { - final Intent cachesIntent = new Intent(this, cgeocaches.class); - - cachesIntent.putExtra("type", "owner"); - cachesIntent.putExtra("username", contextMenuUser); - cachesIntent.putExtra("cachetype", settings.cacheType); - - startActivity(cachesIntent); - + cgeocaches.startActivityCacheOwner(this, contextMenuUser); return true; } else if (id == 2) { - final Intent cachesIntent = new Intent(this, cgeocaches.class); - - cachesIntent.putExtra("type", "username"); - cachesIntent.putExtra("username", contextMenuUser); - cachesIntent.putExtra("cachetype", settings.cacheType); - - startActivity(cachesIntent); - + cgeocaches.startActivityCacheUser(this, contextMenuUser); return true; } else if (id == 3) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/profile/?u=" + URLEncoder.encode(contextMenuUser)))); diff --git a/src/cgeo/geocaching/cgeowaypoint.java b/src/cgeo/geocaching/cgeowaypoint.java index e4ec379..b964df7 100644 --- a/src/cgeo/geocaching/cgeowaypoint.java +++ b/src/cgeo/geocaching/cgeowaypoint.java @@ -257,15 +257,7 @@ public class cgeowaypoint extends AbstractActivity { showToast(res.getString(R.string.err_location_unknown)); } - cgeocaches cachesActivity = new cgeocaches(); - - Intent cachesIntent = new Intent(this, cachesActivity.getClass()); - cachesIntent.putExtra("type", "coordinate"); - cachesIntent.putExtra("latitude", waypoint.latitude); - cachesIntent.putExtra("longitude", waypoint.longitude); - cachesIntent.putExtra("cachetype", settings.cacheType); - - startActivity(cachesIntent); + cgeocaches.startActivityCachesAround(this, waypoint.latitude, waypoint.longitude); finish(); } diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java index 8500e1c..9360899 100644 --- a/src/cgeo/geocaching/mapcommon/cgeomap.java +++ b/src/cgeo/geocaching/mapcommon/cgeomap.java @@ -1280,7 +1280,7 @@ public class cgeomap extends MapBase { coordinates.add(coord); item = settings.getMapFactory().getCacheOverlayItem(coord, cacheOne.type); - icon = cgBase.getIcon(true, cacheOne.type, cacheOne.own, cacheOne.found, cacheOne.disabled || cacheOne.archived); + icon = cgBase.getMarkerIcon(true, cacheOne.type, cacheOne.own, cacheOne.found, cacheOne.disabled || cacheOne.archived); pin = null; if (iconsCache.containsKey(icon)) { @@ -1324,7 +1324,7 @@ public class cgeomap extends MapBase { coordinates.add(coord); item = settings.getMapFactory().getCacheOverlayItem(coord, null); - icon = cgBase.getIcon(false, oneWaypoint.type, false, false, false); + icon = cgBase.getMarkerIcon(false, oneWaypoint.type, false, false, false); if (iconsCache.containsKey(icon)) { pin = iconsCache.get(icon); } else { @@ -1480,7 +1480,7 @@ public class cgeomap extends MapBase { coordinates.add(coord); CacheOverlayItemImpl item = settings.getMapFactory().getCacheOverlayItem(coord, null); - final int icon = cgBase.getIcon(false, waypointTypeIntent, false, false, false); + final int icon = cgBase.getMarkerIcon(false, waypointTypeIntent, false, false, false); Drawable pin = null; if (iconsCache.containsKey(icon)) { pin = iconsCache.get(icon); -- cgit v1.1 From 800b93221ca80ca351820e63a1135bab45b38d3e Mon Sep 17 00:00:00 2001 From: Karsten Priegnitz Date: Tue, 30 Aug 2011 22:15:33 +0200 Subject: GPX import of attributes - also: update DB to make attributes lowercase - also: don't show attribute icons when there no matching icons - this can be the case with stored caches before 7th or 8th of June 2011 - advice to update the cache is show also --- project/attributes/iconlist.txt | 137 +++++++++++++------------- res/values-de/strings.xml | 1 + res/values/strings.xml | 5 +- src/cgeo/geocaching/cgData.java | 14 ++- src/cgeo/geocaching/cgeodetail.java | 95 ++++++++++++------ src/cgeo/geocaching/files/GPXParser.java | 164 ++++++++++++++++++++++++++++++- 6 files changed, 313 insertions(+), 103 deletions(-) diff --git a/project/attributes/iconlist.txt b/project/attributes/iconlist.txt index fbfcdc1..69c9e75 100644 --- a/project/attributes/iconlist.txt +++ b/project/attributes/iconlist.txt @@ -2,98 +2,97 @@ # - internal name: used as # a) name of string, prefixed with "attribute_" # b) name of icon, prefixed with "attribute_" -# - yn: y = normal icon will be generated -# n = striked thru icon will be generated +# - gsx: id used in groundspeak GPX files # - man: graphic is selfmade or overhauled # - license: type of license # - copyright holder: Name of person # - URL: icon is based on graphic downloadable here # -# internal name | yn | man | license | copyright holder | URL +# internal name | gsx | man | license | copyright holder | URL # # Permissions (allowed / not allowed) # -dogs | yn | | CC | | http://thenounproject.com/noun/dog/#icon-No364 -bicycles | yn | x | PD | | http://thenounproject.com/noun/bicycle/#icon-No536 -motorcycles | yn | | PD | | http://thenounproject.com/noun/motorcycle/#icon-No53 -quads | yn | | PD | USA National Park Service | http://thenounproject.com/noun/4-wheeler/#icon-No228 -jeeps | yn | | PD | USA National Park Service | http://thenounproject.com/noun/jeep/#icon-No57 -snowmobiles | yn | | PD | USA National Park Service | http://thenounproject.com/noun/snowmobile/#icon-No505 -horses | yn | | PD | USA National Park Service | http://thenounproject.com/noun/horseback-trail/#icon-No329 -campfires | yn | | PD | USA National Park Service | http://thenounproject.com/noun/campfire/#icon-No196 -rv | yn | | PD | USA National Park Service | http://thenounproject.com/noun/camper/#icon-No86 +dogs | 1 | | CC | | http://thenounproject.com/noun/dog/#icon-No364 +bicycles | 32 | x | PD | | http://thenounproject.com/noun/bicycle/#icon-No536 +motorcycles | 33 | | PD | | http://thenounproject.com/noun/motorcycle/#icon-No53 +quads | 34 | | PD | USA National Park Service | http://thenounproject.com/noun/4-wheeler/#icon-No228 +jeeps | 35 | | PD | USA National Park Service | http://thenounproject.com/noun/jeep/#icon-No57 +snowmobiles | 36 | | PD | USA National Park Service | http://thenounproject.com/noun/snowmobile/#icon-No505 +horses | 37 | | PD | USA National Park Service | http://thenounproject.com/noun/horseback-trail/#icon-No329 +campfires | 38 | | PD | USA National Park Service | http://thenounproject.com/noun/campfire/#icon-No196 +rv | 46 | | PD | USA National Park Service | http://thenounproject.com/noun/camper/#icon-No86 # # Conditions (yes / no) # -kids | yn | x | PD | Jack Biesek, Gladys Brenner, Margaret Faye, Healther Merrifield, Kate Keating, Wendy Olmstead, Todd Pierce, Jamie Cowgill, Jim Bolek | http://thenounproject.com/noun/teddy-bear/#icon-No610 -onehour | yn | x | CC | The Noun Project | http://thenounproject.com/noun/stopwatch/#icon-No282 -scenic | yn | | PD | USA National Park Service | http://thenounproject.com/noun/binoculars/#icon-No112 -hiking | yn | | PD | USA National Park Service | http://thenounproject.com/noun/hiker/#icon-No562 -climbing | yn | | PD | USA National Park Service | http://thenounproject.com/noun/climbing/#icon-No526 -wading | y | x | PD | USA National Park Service | http://thenounproject.com/noun/wading/#icon-No581 -swimming | y | | PD | USA National Park Service | http://thenounproject.com/noun/swimming/#icon-No226 -available | yn | x | PD | koem | -night | yn | | PD | | http://thenounproject.com/noun/moon/#icon-No128 -winter | yn | | PD | USA National Park Service | http://thenounproject.com/noun/snow/#icon-No64 -stealth | yn | x | PD | Celine | http://www.specialweb.com/original/icons4.html -firstaid | y | | PD | Roger Cook, Dan Shanosky | http://thenounproject.com/noun/first-aid/#icon-No535 -cow | y | | PD | | http://www.openclipart.org/people/Anonymous/mucca.svg -field_puzzle | yn | x | PD | nicubunu | http://www.openclipart.org/detail/15169/red-jigsaw-piece-13-by-nicubunu -nightcache | yn | x | PD | | http://thenounproject.com/noun/moon/#icon-No128 -parkngrab | yn | x | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/parking/#icon-No27 -abandonedbuilding | yn | x | CC | The Noun Project | http://thenounproject.com/noun/home/#icon-No293 -hike_short | yn | x | PD | koem | -hike_med | yn | x | PD | koem | -hike_long | yn | x | PD | koem | -seasonal | yn | x | PD | USA National Park Service | http://thenounproject.com/noun/sun/#icon-No76 http://thenounproject.com/noun/snow/#icon-No64 -touristok | yn | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/baggage/#icon-No12 -frontyard | yn | x | PD | koem | -teamwork | yn | | CC | The Noun Project | http://thenounproject.com/noun/community/#icon-No288 +kids | 6 | x | PD | Jack Biesek, Gladys Brenner, Margaret Faye, Healther Merrifield, Kate Keating, Wendy Olmstead, Todd Pierce, Jamie Cowgill, Jim Bolek | http://thenounproject.com/noun/teddy-bear/#icon-No610 +onehour | 7 | x | CC | The Noun Project | http://thenounproject.com/noun/stopwatch/#icon-No282 +scenic | 8 | | PD | USA National Park Service | http://thenounproject.com/noun/binoculars/#icon-No112 +hiking | 9 | | PD | USA National Park Service | http://thenounproject.com/noun/hiker/#icon-No562 +climbing | 10 | | PD | USA National Park Service | http://thenounproject.com/noun/climbing/#icon-No526 +wading | 11 | x | PD | USA National Park Service | http://thenounproject.com/noun/wading/#icon-No581 +swimming | 12 | | PD | USA National Park Service | http://thenounproject.com/noun/swimming/#icon-No226 +available | 13 | x | PD | koem | +night | 14 | | PD | | http://thenounproject.com/noun/moon/#icon-No128 +winter | 15 | | PD | USA National Park Service | http://thenounproject.com/noun/snow/#icon-No64 +stealth | 40 | x | PD | Celine | http://www.specialweb.com/original/icons4.html +firstaid | 42 | | PD | Roger Cook, Dan Shanosky | http://thenounproject.com/noun/first-aid/#icon-No535 +cow | 43 | | PD | | http://www.openclipart.org/people/Anonymous/mucca.svg +field_puzzle | 47 | x | PD | nicubunu | http://www.openclipart.org/detail/15169/red-jigsaw-piece-13-by-nicubunu +nightcache | 52 | x | PD | | http://thenounproject.com/noun/moon/#icon-No128 +parkngrab | 53 | x | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/parking/#icon-No27 +abandonedbuilding | 54 | x | CC | The Noun Project | http://thenounproject.com/noun/home/#icon-No293 +hike_short | 55 | x | PD | koem | +hike_med | 56 | x | PD | koem | +hike_long | 57 | x | PD | koem | +seasonal | 62 | x | PD | USA National Park Service | http://thenounproject.com/noun/sun/#icon-No76 http://thenounproject.com/noun/snow/#icon-No64 +touristok | 63 | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/baggage/#icon-No12 +frontyard | 65 | x | PD | koem | +teamwork | 66 | | CC | The Noun Project | http://thenounproject.com/noun/community/#icon-No288 # # other # -landf | y | x | PD | koem | -partnership | y | | PD | worker | http://www.openclipart.org/detail/152875/hand-shake-by-worker +landf | 45 | x | PD | koem | +partnership | 61 | | PD | worker | http://www.openclipart.org/detail/152875/hand-shake-by-worker # # Equipment (required / not required) # -fee | y | x | PD | koem | -rappelling | y | | PD | USA National Park Service | http://thenounproject.com/noun/rock-climbing/#icon-No529 -boat | y | | PD | USA National Park Service | http://thenounproject.com/noun/motorboat/#icon-No661 -scuba | y | | PD | USA National Park Service | http://thenounproject.com/noun/scuba-diving/#icon-No242 -flashlight | y | | CC | The Noun Project | http://thenounproject.com/noun/flashlight/#icon-No516 -uv | y | x | PD | koem | -snowshoes | y | | PD | USA National Park Service | http://thenounproject.com/noun/snow-shoeing/#icon-No388 -skiis | y | | PD | USA National Park Service | http://thenounproject.com/noun/cross-country-skiing/#icon-No510 -s_tool | y | | CC | The Noun Project | http://thenounproject.com/noun/gears/#icon-No179 -wirelessbeacon | y | x | PD | | http://thenounproject.com/noun/non-ionizing-radiation/#icon-No277 -treeclimbing | yn | | CC | The Noun Project | http://thenounproject.com/noun/tree/#icon-No173 +fee | 2 | x | PD | koem | +rappelling | 3 | | PD | USA National Park Service | http://thenounproject.com/noun/rock-climbing/#icon-No529 +boat | 4 | | PD | USA National Park Service | http://thenounproject.com/noun/motorboat/#icon-No661 +scuba | 5 | | PD | USA National Park Service | http://thenounproject.com/noun/scuba-diving/#icon-No242 +flashlight | 44 | | CC | The Noun Project | http://thenounproject.com/noun/flashlight/#icon-No516 +uv | 48 | x | PD | koem | +snowshoes | 49 | | PD | USA National Park Service | http://thenounproject.com/noun/snow-shoeing/#icon-No388 +skiis | 50 | | PD | USA National Park Service | http://thenounproject.com/noun/cross-country-skiing/#icon-No510 +s_tool | 51 | | CC | The Noun Project | http://thenounproject.com/noun/gears/#icon-No179 +wirelessbeacon | 60 | x | PD | | http://thenounproject.com/noun/non-ionizing-radiation/#icon-No277 +treeclimbing | 64 | | CC | The Noun Project | http://thenounproject.com/noun/tree/#icon-No173 # # Hazards (present / not present) # -poisonoak | yn | | CC | The Noun Project | http://thenounproject.com/noun/mushroom/#icon-No309 -dangerousanimals | y | | PD | USA National Park Service | http://thenounproject.com/noun/snake/#icon-No201 -ticks | y | x | PD | koem | -mine | y | | PD | USA National Park Service | http://thenounproject.com/noun/rock-collecting/#icon-No528 -cliff | y | | PD | USA National Park Service | http://thenounproject.com/noun/falling-rocks/#icon-No520 -hunting | y | | CC | The Noun Project | http://thenounproject.com/noun/location/#icon-No418 -danger | y | x | PD | ryanlerch | http://www.openclipart.org/detail/1448/skull-and-crossbones-by-ryanlerch -thorn | y | | PD | emilie.rollandin | http://www.openclipart.org/detail/68125/spine-by-emilie.rollandin +poisonoak | 17 | | CC | The Noun Project | http://thenounproject.com/noun/mushroom/#icon-No309 +dangerousanimals | 18 | | PD | USA National Park Service | http://thenounproject.com/noun/snake/#icon-No201 +ticks | 19 | x | PD | koem | +mine | 20 | | PD | USA National Park Service | http://thenounproject.com/noun/rock-collecting/#icon-No528 +cliff | 21 | | PD | USA National Park Service | http://thenounproject.com/noun/falling-rocks/#icon-No520 +hunting | 22 | | CC | The Noun Project | http://thenounproject.com/noun/location/#icon-No418 +danger | 23 | x | PD | ryanlerch | http://www.openclipart.org/detail/1448/skull-and-crossbones-by-ryanlerch +thorn | 39 | | PD | emilie.rollandin | http://www.openclipart.org/detail/68125/spine-by-emilie.rollandin # # Facilities # -wheelchair | yn | | PD | USA National Park Service | http://thenounproject.com/noun/wheelchair-accessible/#icon-No354 -parking | yn | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/parking/#icon-No27 -public | y | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/bus/#icon-No97 -water | yn | | PD | USA National Park Service | http://thenounproject.com/noun/drinking-water/#icon-No214 -restrooms | yn | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/unisex/#icon-No50 -phone | yn | | PD | | http://thenounproject.com/noun/telephone/#icon-No127 -picnic | yn | | PD | USA National Park Service | http://thenounproject.com/noun/picnic-table/#icon-No208 -camping | yn | | PD | USA National Park Service | http://thenounproject.com/noun/campground/#icon-No209 -stroller | yn | | PD | USA National Park Service | http://thenounproject.com/noun/stroller/#icon-No161 -fuel | yn | | PD | | http://thenounproject.com/noun/gas/#icon-No155 -food | yn | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/restaurant/#icon-No33 +wheelchair | 24 | | PD | USA National Park Service | http://thenounproject.com/noun/wheelchair-accessible/#icon-No354 +parking | 25 | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/parking/#icon-No27 +public | 26 | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/bus/#icon-No97 +water | 27 | | PD | USA National Park Service | http://thenounproject.com/noun/drinking-water/#icon-No214 +restrooms | 28 | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/unisex/#icon-No50 +phone | 29 | | PD | | http://thenounproject.com/noun/telephone/#icon-No127 +picnic | 30 | | PD | USA National Park Service | http://thenounproject.com/noun/picnic-table/#icon-No208 +camping | 31 | | PD | USA National Park Service | http://thenounproject.com/noun/campground/#icon-No209 +stroller | 41 | | PD | USA National Park Service | http://thenounproject.com/noun/stroller/#icon-No161 +fuel | 58 | | PD | | http://thenounproject.com/noun/gas/#icon-No155 +food | 59 | | PD | Roger Cook, Don Shanosky | http://thenounproject.com/noun/restaurant/#icon-No33 # # own # -icon_not_found | y | x | PD | | selfmade +icon_not_found | | x | PD | koem | selfmade diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 3de4e61..98219a9 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -478,6 +478,7 @@ Tagen Premium Attribute + (aktualisiere den Cache um die Attribut-Icons anzuzeigen) Inventar Offline-Log Lade Logbild … diff --git a/res/values/strings.xml b/res/values/strings.xml index 63cebc5..a246e0a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -488,6 +488,7 @@ days ago Premium Attributes + (refresh cache to show attribute icons) Inventory Offline log Loading log Image … @@ -908,11 +909,7 @@ · Iiro Jäppinen (graphic)\n · inkantis (localization PL)\n · Jan Žatecký (graphic)\n -<<<<<<< HEAD:res/values/strings.xml -======= · JoWi24 (code)\n - · Köm (code, artwork computation)\n ->>>>>>> upstream/master:res/values/strings.xml · MichielK (code, loc. NL)\n · ncorreia (code, localization PT)\n · Pascal (localization NL)\n diff --git a/src/cgeo/geocaching/cgData.java b/src/cgeo/geocaching/cgData.java index ab24864..a8c6eda 100644 --- a/src/cgeo/geocaching/cgData.java +++ b/src/cgeo/geocaching/cgData.java @@ -35,7 +35,7 @@ public class cgData { private cgDbHelper dbHelper = null; private SQLiteDatabase databaseRO = null; private SQLiteDatabase databaseRW = null; - private static final int dbVersion = 55; + private static final int dbVersion = 56; private static final String dbName = "data"; private static final String dbTableCaches = "cg_caches"; private static final String dbTableLists = "cg_lists"; @@ -778,6 +778,18 @@ public class cgData { } } + + // make all internal attribute names lowercase + // @see issue #299 + if (oldVersion < 56) { // update to 56 + try { + db.execSQL("update " + dbTableAttributes + " set attribute = " + + "lower(attribute) where attribute like \"%_yes\" " + + "or attribute like \"%_no\""); + } catch (Exception e) { + Log.e(cgSettings.tag, "Failed to upgrade to ver. 56: " + e.toString()); + } + } } db.setTransactionSuccessful(); diff --git a/src/cgeo/geocaching/cgeodetail.java b/src/cgeo/geocaching/cgeodetail.java index 225e345..17d9e17 100644 --- a/src/cgeo/geocaching/cgeodetail.java +++ b/src/cgeo/geocaching/cgeodetail.java @@ -87,9 +87,15 @@ public class cgeodetail extends AbstractActivity { private ProgressDialog watchlistDialog = null; // progress dialog for watchlist add/remove private Thread watchlistThread = null; // thread for watchlist add/remove private HashMap calendars = new HashMap(); + private ViewGroup attributeIconsLayout; // layout for attribute icons private ViewGroup attributeDescriptionsLayout; // layout for attribute descriptions private boolean attributesShowAsIcons = true; // default: show icons + /** noAttributeImagesFound + * This will be the case if the cache was imported with an older version of c:geo. + * These older versions parsed the attribute description from the tooltip in the web + * page and put them into the DB. No icons can be matched for these. */ + private boolean noAttributeIconsFound = false; private int attributeBoxMaxWidth; private Handler storeCacheHandler = new Handler() { @@ -836,7 +842,8 @@ public class cgeodetail extends AbstractActivity { // cache attributes if (cache.attributes != null && cache.attributes.size() > 0) { - final LinearLayout attribBox = (LinearLayout) findViewById(R.id.attributes_innerbox); + final LinearLayout attribBox = (LinearLayout) findViewById( + R.id.attributes_innerbox); // maximum width for attribute icons is screen width - paddings of parents attributeBoxMaxWidth = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)) @@ -862,10 +869,18 @@ public class cgeodetail extends AbstractActivity { } ); // icons or text? - if (attributesShowAsIcons) + // + // also show icons when noAttributeImagesFound == true. Explanation: + // 1. no icons could be found in the first invocation of this method + // 2. user refreshes cache from web + // 3. now this method is called again + // 4. attributeShowAsIcons is false but noAttributeImagesFound is true + // => try to show them now + if (attributesShowAsIcons || noAttributeIconsFound) { showAttributeIcons(attribBox, attributeBoxMaxWidth); - else + } else { showAttributeDescriptions(attribBox); + } findViewById(R.id.attributes_box).setVisibility(View.VISIBLE); } @@ -1969,8 +1984,14 @@ public class cgeodetail extends AbstractActivity { * and makes it visible */ private void showAttributeIcons(LinearLayout attribBox, int parentWidth) { - if (attributeIconsLayout == null) + if (attributeIconsLayout == null) { attributeIconsLayout = createAttributeIconsLayout(parentWidth); + // no matching icons found? show text + if (noAttributeIconsFound) { + showAttributeDescriptions(attribBox); + return; + } + } attribBox.removeAllViews(); attribBox.addView(attributeIconsLayout); attributesShowAsIcons = true; @@ -1981,8 +2002,9 @@ public class cgeodetail extends AbstractActivity { * and makes it visible */ private void showAttributeDescriptions(LinearLayout attribBox) { - if (attributeDescriptionsLayout == null) + if (attributeDescriptionsLayout == null) { attributeDescriptionsLayout = createAttributeDescriptionsLayout(); + } attribBox.removeAllViews(); attribBox.addView(attributeDescriptionsLayout); attributesShowAsIcons = false; @@ -1992,10 +2014,17 @@ public class cgeodetail extends AbstractActivity { * toggle attribute descriptions and icons */ private void toggleAttributeDisplay(LinearLayout attribBox, int parentWidth) { - if (attributesShowAsIcons) + // Don't toggle when there are no icons to show. + if (noAttributeIconsFound) { + return; + } + + // toggle + if (attributesShowAsIcons) { showAttributeDescriptions(attribBox); - else + } else { showAttributeIcons(attribBox, parentWidth); + } } private ViewGroup createAttributeIconsLayout(int parentWidth) { @@ -2006,11 +2035,14 @@ public class cgeodetail extends AbstractActivity { LinearLayout attributeRow = newAttributeIconsRow(); rows.addView(attributeRow); + noAttributeIconsFound = true; + for(String attributeName : cache.attributes) { boolean strikethru = attributeName.endsWith("_no"); // cut off _yes / _no - if (attributeName.endsWith("_no") || attributeName.endsWith("_yes")) + if (attributeName.endsWith("_no") || attributeName.endsWith("_yes")) { attributeName = attributeName.substring(0, attributeName.lastIndexOf("_")); + } // check if another attribute icon fits in this row attributeRow.measure(0, 0); int rowWidth = attributeRow.getMeasuredWidth(); @@ -2024,26 +2056,30 @@ public class cgeodetail extends AbstractActivity { // dynamically search icon of the attribute Drawable d = null; - int id = res.getIdentifier("attribute_" + attributeName, "drawable", base.context.getPackageName()); - if (id > 0) + int id = res.getIdentifier("attribute_" + attributeName, "drawable", + base.context.getPackageName()); + if (id > 0) { + noAttributeIconsFound = false; d = res.getDrawable(id); - else + iv.setImageDrawable(d); + // strike through? + if (strikethru) { + // generate strikethru image with same properties as attribute image + ImageView strikethruImage = new ImageView(this); + strikethruImage.setLayoutParams(iv.getLayoutParams()); + d = res.getDrawable(R.drawable.attribute__strikethru); + strikethruImage.setImageDrawable(d); + fl.addView(strikethruImage); + } + } else { d = res.getDrawable(R.drawable.attribute_icon_not_found); - iv.setImageDrawable(d); - - // strike through? - if (strikethru) { - // generate strikethru image with same properties as attribute image - ImageView strikethruImage = new ImageView(this); - strikethruImage.setLayoutParams(iv.getLayoutParams()); - d = res.getDrawable(R.drawable.attribute__strikethru); - strikethruImage.setImageDrawable(d); - fl.addView(strikethruImage); - } + iv.setImageDrawable(d); + } + attributeRow.addView(fl); } - return rows; + return rows; } private LinearLayout newAttributeIconsRow() { @@ -2055,7 +2091,8 @@ public class cgeodetail extends AbstractActivity { } private ViewGroup createAttributeDescriptionsLayout() { - final LinearLayout descriptions = (LinearLayout) inflater.inflate(R.layout.attribute_descriptions, null); + final LinearLayout descriptions = (LinearLayout) inflater.inflate( + R.layout.attribute_descriptions, null); TextView attribView = (TextView) descriptions.getChildAt(0); StringBuilder buffer = new StringBuilder(); @@ -2064,18 +2101,20 @@ public class cgeodetail extends AbstractActivity { attribute = cache.attributes.get(i); // dynamically search for a translation of the attribute - int id = res.getIdentifier("attribute_" + attribute, "string", base.context.getPackageName()); + int id = res.getIdentifier("attribute_" + attribute, "string", + base.context.getPackageName()); if (id > 0) { String translated = res.getString(id); if (translated != null && translated.length() > 0) { attribute = translated; } } - if (buffer.length() > 0) { - buffer.append('\n'); - } + if (buffer.length() > 0) buffer.append('\n'); buffer.append(attribute); } + + if (noAttributeIconsFound) + buffer.append("\n\n").append(res.getString(R.string.cache_attributes_no_icons)); attribView.setText(buffer); diff --git a/src/cgeo/geocaching/files/GPXParser.java b/src/cgeo/geocaching/files/GPXParser.java index 2a3b167..7d59862 100644 --- a/src/cgeo/geocaching/files/GPXParser.java +++ b/src/cgeo/geocaching/files/GPXParser.java @@ -23,6 +23,7 @@ import android.sax.StartElementListener; import android.text.Html; import android.util.Log; import android.util.Xml; +import cgeo.geocaching.R; import cgeo.geocaching.cgBase; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgLog; @@ -54,6 +55,7 @@ public abstract class GPXParser extends FileParser { private cgCache cache = new cgCache(); private cgTrackable trackable = new cgTrackable(); private cgLog log = new cgLog(); + private CacheAttribute cacheAttribute = null; private boolean shortDescIsHtml = true; private boolean longDescIsHtml = true; @@ -62,6 +64,122 @@ public abstract class GPXParser extends FileParser { private String name = null; private String cmt = null; private String desc = null; + + private class CacheAttribute { + // List of cache attributes matching IDs used in GPX files. + // The ID is represented by the position of the String in the array. + // Strings are not used as text but as resource IDs of strings, just to be aware of changes + // made in strings.xml which then will lead to compile errors here and not to runtime errors. + private final int[] CACHE_ATTRIBUTES = { + -1, // 0 + R.string.attribute_dogs_yes, // 1 + R.string.attribute_fee_yes, // 2 + R.string.attribute_rappelling_yes, // 3 + R.string.attribute_boat_yes, // 4 + R.string.attribute_scuba_yes, // 5 + R.string.attribute_kids_yes, // 6 + R.string.attribute_onehour_yes, // 7 + R.string.attribute_scenic_yes, // 8 + R.string.attribute_hiking_yes, // 9 + R.string.attribute_climbing_yes, // 10 + R.string.attribute_wading_yes, // 11 + R.string.attribute_swimming_yes, // 12 + R.string.attribute_available_yes, // 13 + R.string.attribute_night_yes, // 14 + R.string.attribute_winter_yes, // 15 + -1, // 16 + R.string.attribute_poisonoak_yes, // 17 + R.string.attribute_dangerousanimals_yes, // 18 + R.string.attribute_ticks_yes, // 19 + R.string.attribute_mine_yes, // 20 + R.string.attribute_cliff_yes, // 21 + R.string.attribute_hunting_yes, // 22 + R.string.attribute_danger_yes, // 23 + R.string.attribute_wheelchair_yes, // 24 + R.string.attribute_parking_yes, // 25 + R.string.attribute_public_yes, // 26 + R.string.attribute_water_yes, // 27 + R.string.attribute_restrooms_yes, // 28 + R.string.attribute_phone_yes, // 29 + R.string.attribute_picnic_yes, // 30 + R.string.attribute_camping_yes, // 31 + R.string.attribute_bicycles_yes, // 32 + R.string.attribute_motorcycles_yes, // 33 + R.string.attribute_quads_yes, // 34 + R.string.attribute_jeeps_yes, // 35 + R.string.attribute_snowmobiles_yes, // 36 + R.string.attribute_horses_yes, // 37 + R.string.attribute_campfires_yes, // 38 + R.string.attribute_thorn_yes, // 39 + R.string.attribute_stealth_yes, // 40 + R.string.attribute_stroller_yes, // 41 + R.string.attribute_firstaid_yes, // 42 + R.string.attribute_cow_yes, // 43 + R.string.attribute_flashlight_yes, // 44 + R.string.attribute_landf_yes, // 45 + R.string.attribute_rv_yes, // 46 + R.string.attribute_field_puzzle_yes, // 47 + R.string.attribute_uv_yes, // 48 + R.string.attribute_snowshoes_yes, // 49 + R.string.attribute_skiis_yes, // 50 + R.string.attribute_s_tool_yes, // 51 + R.string.attribute_nightcache_yes, // 52 + R.string.attribute_parkngrab_yes, // 53 + R.string.attribute_abandonedbuilding_yes, // 54 + R.string.attribute_hike_short_yes, // 55 + R.string.attribute_hike_med_yes, // 56 + R.string.attribute_hike_long_yes, // 57 + R.string.attribute_fuel_yes, // 58 + R.string.attribute_food_yes, // 59 + R.string.attribute_wirelessbeacon_yes, // 60 + R.string.attribute_partnership_yes, // 61 + R.string.attribute_seasonal_yes, // 62 + R.string.attribute_touristok_yes, // 63 + R.string.attribute_treeclimbing_yes, // 64 + R.string.attribute_frontyard_yes, // 65 + R.string.attribute_teamwork_yes, // 66 + }; + private static final String YES = "_yes"; + private static final String NO = "_no"; + private final Pattern BASENAME_PATTERN = Pattern.compile("^.*attribute_(.*)(_yes|_no)"); + + private Boolean active = null; // for yes/no + private String baseName; // "food", "parkngrab", ... + + public void setActive(boolean active) { + this.active = active; + } + // map GPX-Attribute-Id to baseName + public void setBaseName(int id) { + this.baseName = null; + // get String out of array + if (CACHE_ATTRIBUTES.length <= id) + return; + int stringId = CACHE_ATTRIBUTES[id]; + if (stringId == -1) + return; // id not found + // get text for string + String stringName = null; + try { + stringName = app.getResources().getResourceName(stringId); + } catch (NullPointerException e) { + return; + } + if (stringName == null) + return; + // cut out baseName + Matcher m = BASENAME_PATTERN.matcher(stringName); + if (! m.matches()) + return; + this.baseName = m.group(1); + } + // @return baseName + "_yes" or "_no" e.g. "food_no" or "uv_yes" + public String getInternalId() { + if (baseName == null || active == null) + return null; + return baseName + (active ? YES : NO); + } + } public GPXParser(cgeoapplication appIn, int listIdIn, cgSearch searchIn, String namespaceIn, String versionIn) { app = appIn; @@ -287,7 +405,51 @@ public abstract class GPXParser extends FileParser { } }); - // waypoint.cache.difficulty + // waypoint.cache.attributes + // @see issue #299 + + // + // Bicycles + // Available at all times + // where inc = 0 => _no, inc = 1 => _yes + // IDs see array CACHE_ATTRIBUTES + final Element gcAttributes = gcCache.getChild(nsGC, "attributes"); + + // waypoint.cache.attribute + final Element gcAttribute = gcAttributes.getChild(nsGC, "attribute"); + + gcAttribute.setStartElementListener(new StartElementListener() { + @Override + public void start(Attributes attrs) { + cacheAttribute = new CacheAttribute(); + try { + if (attrs.getIndex("id") > -1) { + cacheAttribute.setBaseName(Integer.parseInt(attrs.getValue("id"))); + } + if (attrs.getIndex("inc") > -1) { + cacheAttribute.setActive(Integer.parseInt(attrs.getValue("inc")) != 0); + } + } catch (Exception e) { + // nothing + } + } + }); + + gcAttribute.setEndElementListener(new EndElementListener() { + @Override + public void end() { + if (cacheAttribute != null) { + String internalId = cacheAttribute.getInternalId(); + if (internalId != null) { + if (cache.attributes == null) + cache.attributes = new ArrayList(); + cache.attributes.add(internalId); + } + } + } + }); + + // waypoint.cache.difficulty gcCache.getChild(nsGC, "difficulty").setEndTextElementListener(new EndTextElementListener() { @Override -- cgit v1.1 From f083df4fd71ba7da380254dc3d79c4f95628fce1 Mon Sep 17 00:00:00 2001 From: Karsten Priegnitz Date: Wed, 31 Aug 2011 09:03:12 +0200 Subject: script to create ID-Mapping array --- project/attributes/makeGpxIdArray.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 project/attributes/makeGpxIdArray.sh diff --git a/project/attributes/makeGpxIdArray.sh b/project/attributes/makeGpxIdArray.sh new file mode 100755 index 0000000..f348771 --- /dev/null +++ b/project/attributes/makeGpxIdArray.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +require () { + hash $1 2>&- || { echo >&2 "I require $1 but it's not installed. Aborting."; exit 1; } +} + +require sed + +echo "private final int[] CACHE_ATTRIBUTES = {" + +cat iconlist.txt | grep -v "^#" \ + | cut -d "|" -f 1,2 \ + | sed "s/ *$//" \ + | grep "[0-9]$" \ + | sort -nk 3 \ + | sed "s/^\([^ ]*\)[ \|]*\([0-9]*\)$/ R.string.attribute_\1_yes, \/\/ GPX-ID \2/" \ + > $0.tmp + +maxid=`tail -n 1 $0.tmp | sed "s/^.* \([0-9]*\)$/\1/"` + +for n in `seq 0 $maxid`; do + l=`grep " $n$" $0.tmp` + if [ -z "$l" ]; then + echo " -1, // GPX-ID $n" + else + echo "$l" + fi +done + +echo "};" -- cgit v1.1 From 2f97deb9f64131c17e7f761746ba71b54e8af954 Mon Sep 17 00:00:00 2001 From: inkantis Date: Wed, 31 Aug 2011 09:49:23 +0200 Subject: German translation: added strings for GCVote stars --- res/values-de/strings.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 3de4e61..da84191 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -90,6 +90,15 @@ 4 Sterne 4,5 Sterne 5 Sterne + schlecht + lohnt nicht + schwach + ok + durchschnittlich + besser + gut + fast perfekt + großartig Webcam-Foto gemacht Loggen Log-Text -- cgit v1.1 From 1db09fef9cc7230b88e466621b012425048b12e1 Mon Sep 17 00:00:00 2001 From: cachapa Date: Wed, 31 Aug 2011 15:38:36 +0200 Subject: Added onPress and onSelected backgrounds to the actionbar buttons --- res/drawable/actionbar_button.xml | 11 +++++++++++ res/drawable/actionbar_button_pressed.xml | 6 ++++++ res/drawable/actionbar_button_selected.xml | 6 ++++++ res/values/styles.xml | 4 ++++ 4 files changed, 27 insertions(+) create mode 100644 res/drawable/actionbar_button.xml create mode 100644 res/drawable/actionbar_button_pressed.xml create mode 100644 res/drawable/actionbar_button_selected.xml diff --git a/res/drawable/actionbar_button.xml b/res/drawable/actionbar_button.xml new file mode 100644 index 0000000..85ce5a1 --- /dev/null +++ b/res/drawable/actionbar_button.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/res/drawable/actionbar_button_pressed.xml b/res/drawable/actionbar_button_pressed.xml new file mode 100644 index 0000000..593caea --- /dev/null +++ b/res/drawable/actionbar_button_pressed.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/res/drawable/actionbar_button_selected.xml b/res/drawable/actionbar_button_selected.xml new file mode 100644 index 0000000..ece89e1 --- /dev/null +++ b/res/drawable/actionbar_button_selected.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/res/values/styles.xml b/res/values/styles.xml index bc42e23..c271ed9 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -47,7 +47,9 @@ 4dip center center + true @drawable/actionbar_cgeo + @drawable/actionbar_button