diff options
| author | koem <spam@petoria.de> | 2013-02-12 04:04:13 -0800 |
|---|---|---|
| committer | koem <spam@petoria.de> | 2013-02-12 04:04:13 -0800 |
| commit | 7b4a0b337a5f22bf0058c22967da94faea9ce318 (patch) | |
| tree | a9991f02c99d417e2517f8831c6505e385ee8459 /main/src | |
| parent | 70251c24f5fafeeb150a2142249245e9515f560b (diff) | |
| parent | 3c3b9bb7f748bd43126e39a83268d23056db6ca6 (diff) | |
| download | cgeo-7b4a0b337a5f22bf0058c22967da94faea9ce318.zip cgeo-7b4a0b337a5f22bf0058c22967da94faea9ce318.tar.gz cgeo-7b4a0b337a5f22bf0058c22967da94faea9ce318.tar.bz2 | |
Merge pull request #2465 from koem/oc_icons
Icons for OC
Diffstat (limited to 'main/src')
8 files changed, 167 insertions, 456 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 03c0bcf..a3535a6 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -1046,8 +1046,8 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc } final boolean strikethru = !CacheAttribute.isEnabled(attributeName); - final CacheAttribute attrib = CacheAttribute.getByGcRawName(CacheAttribute.trimAttributeName(attributeName)); - if (attrib != CacheAttribute.UNKNOWN) { + final CacheAttribute attrib = CacheAttribute.getByRawName(CacheAttribute.trimAttributeName(attributeName)); + if (attrib != null) { noAttributeIconsFound = false; Drawable d = res.getDrawable(attrib.drawableId); iv.setImageDrawable(d); @@ -1061,7 +1061,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc fl.addView(strikethruImage); } } else { - Drawable d = res.getDrawable(R.drawable.attribute_icon_not_found); + Drawable d = res.getDrawable(R.drawable.attribute_unknown); iv.setImageDrawable(d); } @@ -1088,10 +1088,11 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc for (String attributeName : cache.getAttributes()) { final boolean enabled = CacheAttribute.isEnabled(attributeName); // search for a translation of the attribute - CacheAttribute attrib = CacheAttribute.getByGcRawName(CacheAttribute.trimAttributeName(attributeName)); - if (attrib != CacheAttribute.UNKNOWN) { - attributeName = attrib.getL10n(enabled); + CacheAttribute attrib = CacheAttribute.getByRawName(CacheAttribute.trimAttributeName(attributeName)); + if (attrib == null) { + attrib = CacheAttribute.UNKNOWN; } + attributeName = attrib.getL10n(enabled); if (buffer.length() > 0) { buffer.append('\n'); } diff --git a/main/src/cgeo/geocaching/apps/cache/CacheBeaconApp.java b/main/src/cgeo/geocaching/apps/cache/CacheBeaconApp.java index 1f38ca7..9cfafb4 100644 --- a/main/src/cgeo/geocaching/apps/cache/CacheBeaconApp.java +++ b/main/src/cgeo/geocaching/apps/cache/CacheBeaconApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache; -import cgeo.geocaching.R; import cgeo.geocaching.Geocache; +import cgeo.geocaching.R; import cgeo.geocaching.enumerations.CacheAttribute; public class CacheBeaconApp extends AbstractGeneralApp { @@ -12,7 +12,7 @@ public class CacheBeaconApp extends AbstractGeneralApp { @Override public boolean isEnabled(Geocache cache) { - return cache.hasAttribute(CacheAttribute.WIRELESS_BEACON, true); + return cache.hasAttribute(CacheAttribute.WIRELESSBEACON, true); } } diff --git a/main/src/cgeo/geocaching/connector/oc/AttributeMapper.java b/main/src/cgeo/geocaching/connector/oc/AttributeMapper.java deleted file mode 100644 index 4358b00..0000000 --- a/main/src/cgeo/geocaching/connector/oc/AttributeMapper.java +++ /dev/null @@ -1,359 +0,0 @@ -package cgeo.geocaching.connector.oc; - -import cgeo.geocaching.enumerations.CacheAttribute; - -/** - * Maps opencaching attributes. List of available attributes is generated by accessing - * http://www.opencaching.de/xml/ocxml11.php?modifiedsince=20060320000000&user=0&session=0&attrlist=1 - * - * <attr id="1" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/night.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/night-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/night-disabled.png">Only at - * night</attr> - * <attr id="6" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/oconly.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/oconly-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/oconly-disabled.png">Only loggable at - * Opencaching</attr> - * <attr id="7" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/wwwlink.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/wwwlink-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/wwwlink-disabled.png">Hyperlink to another - * caching portal only</attr> - * <attr id="8" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/letter.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/letter-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/letter-disabled.png">Letterbox (needs - * stamp)</attr> - * <attr id="9" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/danger.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/danger-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/danger-disabled.png">Dangerous - * area</attr> - * <attr id="10" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/train.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/train-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/train-disabled.png">Active railway - * nearby</attr> - * <attr id="11" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/cliff.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/cliff-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/cliff-disabled.png">Cliff / - * Rocks</attr> - * <attr id="12" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/hunting.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/hunting-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/hunting-disabled.png">Hunting</attr> - * <attr - * id="13" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/thorn.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/thorn-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/thorn-disabled.png">Thorns</attr> - * <attr - * id="14" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/ticks.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/ticks-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/ticks-disabled.png">Ticks</attr> - * <attr - * id="15" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/mine.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/mine-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/mine-disabled.png">Abandoned - * mines</attr> - * <attr id="16" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/plants.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/plants-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/plants-disabled.png">Poisonous - * plants</attr> - * <attr id="17" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/animals.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/animals-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/animals-disabled.png">Dangerous - * animals</attr> - * <attr id="18" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/parking.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/parking-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/parking-disabled.png">Parking area - * nearby</attr> - * <attr id="19" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/public.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/public-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/public-disabled.png">Public - * transportation</attr> - * <attr id="20" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/water.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/water-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/water-disabled.png">Drinking water - * nearby</attr> - * <attr id="21" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/restrooms.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/restrooms-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/restrooms-disabled.png">Public restrooms - * nearby</attr> - * <attr id="22" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/phone.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/phone-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/phone-disabled.png">Public phone - * nearby</attr> - * <attr id="23" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/firstaid.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/firstaid-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/firstaid-disabled.png">First aid - * available</attr> - * <attr id="24" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/car.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/car-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/car-disabled.png">Near the parking - * area</attr> - * <attr id="25" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/hiking.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/hiking-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/hiking-disabled.png">Long walk</attr> - * <attr - * id="26" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/wading.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/wading-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/wading-disabled.png">Swamp or - * marsh</attr> - * <attr id="27" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/steep.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/steep-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/steep-disabled.png">Hilly area</attr> - * <attr - * id="28" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/climbing.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/climbing-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/climbing-disabled.png">Some climbing (no - * gear needed)</attr> - * <attr id="29" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/swimming.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/swimming-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/swimming-disabled.png">Swimming - * required</attr> - * <attr id="30" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/interestsign.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/interestsign-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/interestsign-disabled.png">Point of - * interest</attr> - * <attr id="31" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/moving.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/moving-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/moving-disabled.png">Moving - * target</attr> - * <attr id="32" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/webcam.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/webcam-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/webcam-disabled.png">Webcam </attr> - * <attr - * id="33" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/indoor.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/indoor-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/indoor-disabled.png">Wihin enclosed rooms - * (caves, buildings etc.)</attr> - * <attr id="34" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/submerged.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/submerged-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/submerged-disabled.png">In the - * water</attr> - * <attr id="35" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/nogps.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/nogps-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/nogps-disabled.png">Without GPS - * (letterboxes, cistes, compass juggling ...)</attr> - * <attr id="36" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/fee.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/fee-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/fee-disabled.png">Access or parking - * fee</attr> - * <attr id="37" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/overnight.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/overnight-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/overnight-disabled.png">Overnight stay - * necessary</attr> - * <attr id="38" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/available.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/available-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/available-disabled.png">Available 24 - * hours</attr> - * <attr id="39" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/time.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/time-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/time-disabled.png">Only available at - * specified times</attr> - * <attr id="40" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/day.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/day-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/day-disabled.png">by day only</attr> - * <attr - * id="41" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/tide.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/tide-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/tide-disabled.png">Tide</attr> - * <attr id="42" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/date.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/date-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/date-disabled.png">All seasons</attr> - * <attr - * id="43" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/naturschutz.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/naturschutz-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/naturschutz-disabled.png">Breeding season / - * protected nature</attr> - * <attr id="44" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/snow.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/snow-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/snow-disabled.png">Snow-proof hiding - * place</attr> - * <attr id="46" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/tools.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/tools-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/tools-disabled.png">Special - * equipment</attr> - * <attr id="47" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/compass.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/compass-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/compass-disabled.png">Compass</attr> - * <attr - * id="48" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/flashlight.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/flashlight-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/flashlight-disabled.png" - * >Flashlight</attr> - * <attr id="49" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/rappeling.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/rappeling-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/rappeling-disabled.png">Climbing - * gear</attr> - * <attr id="50" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/cave.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/cave-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/cave-disabled.png">Cave - * equipment</attr> - * <attr id="51" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/scuba.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/scuba-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/scuba-disabled.png">Diving - * equipment</attr> - * <attr id="52" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/boat.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/boat-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/boat-disabled.png">Watercraft</attr> - * <attr - * id="53" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/aircraft.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/aircraft-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/aircraft-disabled.png">Aircraft</attr> - * <attr - * id="54" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/wiki.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/wiki-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/wiki-disabled.png" - * >Investigation</attr> - * <attr id="55" - * icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/riddle.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/riddle-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/riddle-disabled.png">Puzzle / - * Mystery</attr> - * <attr id="56" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/arith_prob.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/arith_prob-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/arith_prob-disabled.png">Arithmetical - * problem</attr> - * <attr id="57" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/othercache.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/othercache-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/othercache-disabled.png">Other cache - * type</attr> - * <attr id="58" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/ask.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/ask-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/ask-disabled.png">Ask owner for start - * conditions</attr> - * <attr id="59" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/kids.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/kids-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/kids-disabled.png">Suited for - * children</attr> - * <attr id="60" icon_large="http://www.opencaching.de/resource2/ocstyle/images/attributes/calendar.png" - * icon_no="http://www.opencaching.de/resource2/ocstyle/images/attributes/calendar-no.png" - * icon_undef="http://www.opencaching.de/resource2/ocstyle/images/attributes/calendar-disabled.png">Only available - * during specified seasons</attr> - * - */ -public class AttributeMapper { - public static CacheAttribute getAttribute(int ocAttributeId) { - switch (ocAttributeId) { - case 1: - return CacheAttribute.NIGHT; - case 6: - return null; - case 7: - return null; - case 8: - return null; - case 9: - return CacheAttribute.DANGER; - case 10: - return null; - case 11: - return CacheAttribute.CLIFF; - case 12: - return CacheAttribute.HUNTING; - case 13: - return CacheAttribute.THORN; - case 14: - return CacheAttribute.TICKS; - case 15: - return CacheAttribute.MINE; - case 16: - return CacheAttribute.POISONOAK; - case 17: - return CacheAttribute.DANGEROUSANIMALS; - case 18: - return CacheAttribute.PARKING; - case 19: - return CacheAttribute.PUBLIC; - case 20: - return CacheAttribute.WATER; - case 21: - return CacheAttribute.RESTROOMS; - case 22: - return CacheAttribute.PHONE; - case 23: - return null; - case 24: - return CacheAttribute.PARKNGRAB; - case 25: - return CacheAttribute.HIKING; - case 26: - return null; - case 27: - return null; - case 28: - return CacheAttribute.CLIMBING; - case 29: - return CacheAttribute.SWIMMING; - case 30: - return null; - case 31: - return null; - case 32: - return null; // webcam, should be handled fine by type already - case 33: - return null; - case 34: - return null; - case 35: - return null; - case 36: - return CacheAttribute.FEE; - case 37: - return null; - case 38: - return CacheAttribute.AVAILABLE; - case 39: - return null; - case 40: - return null; - case 41: - return null; - case 42: - return null; - case 43: - return null; - case 44: - return null; - case 46: - return CacheAttribute.SPECIAL_TOOLS; - case 47: - return null; - case 48: - return CacheAttribute.FLASHLIGHT; - case 49: - return CacheAttribute.RAPPELLING; - case 50: - return null; - case 51: - return CacheAttribute.SCUBA; - case 52: - return CacheAttribute.BOAT; - case 53: - return null; - case 54: - return null; - case 55: - return null; - case 56: - return null; - case 57: - return null; - case 58: - return null; - case 59: - return CacheAttribute.KIDS; - case 60: - return CacheAttribute.SEASONAL; - default: - return null; - } - } -}
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java index 6d2de02..a9c041c 100644 --- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java +++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java @@ -434,7 +434,7 @@ public class OC11XMLParser { attributeNode.setEndTextElementListener(new EndTextElementListener() { @Override public void end(String body) { - CacheAttribute attribute = AttributeMapper.getAttribute(attributeId); + CacheAttribute attribute = CacheAttribute.getByOcId(attributeId); if (attribute != null) { // semantic of attributes on opencaching is always "yes" cacheHolder.cache.getAttributes().add(attribute.getAttributeName(true)); diff --git a/main/src/cgeo/geocaching/connector/oc/OCConnector.java b/main/src/cgeo/geocaching/connector/oc/OCConnector.java index 661f506..62dfb4c 100644 --- a/main/src/cgeo/geocaching/connector/oc/OCConnector.java +++ b/main/src/cgeo/geocaching/connector/oc/OCConnector.java @@ -1,7 +1,7 @@ package cgeo.geocaching.connector.oc; -import cgeo.geocaching.ICache; import cgeo.geocaching.Geocache; +import cgeo.geocaching.ICache; import cgeo.geocaching.connector.AbstractConnector; import cgeo.geocaching.enumerations.CacheRealm; diff --git a/main/src/cgeo/geocaching/enumerations/CacheAttribute.java b/main/src/cgeo/geocaching/enumerations/CacheAttribute.java index 01d76f5..530869f 100644 --- a/main/src/cgeo/geocaching/enumerations/CacheAttribute.java +++ b/main/src/cgeo/geocaching/enumerations/CacheAttribute.java @@ -5,124 +5,190 @@ import cgeo.geocaching.cgeoapplication; import org.apache.commons.lang3.StringUtils; +import android.util.SparseArray; + import java.util.Collections; import java.util.HashMap; import java.util.Map; - public enum CacheAttribute { - UNKNOWN(0, "unknown", R.drawable.attribute__strikethru, R.string.attribute_unknown_yes, R.string.attribute_unknown_no), - DOGS(1, "dogs", R.drawable.attribute_dogs, R.string.attribute_dogs_yes, R.string.attribute_dogs_no), - FEE(2, "fee", R.drawable.attribute_fee, R.string.attribute_fee_yes, R.string.attribute_fee_no), - RAPPELLING(3, "rappelling", R.drawable.attribute_rappelling, R.string.attribute_rappelling_yes, R.string.attribute_rappelling_no), - BOAT(4, "boat", R.drawable.attribute_boat, R.string.attribute_boat_yes, R.string.attribute_boat_no), - SCUBA(5, "scuba", R.drawable.attribute_scuba, R.string.attribute_scuba_yes, R.string.attribute_scuba_no), - KIDS(6, "kids", R.drawable.attribute_kids, R.string.attribute_kids_yes, R.string.attribute_kids_no), - ONEHOUR(7, "onehour", R.drawable.attribute_onehour, R.string.attribute_onehour_yes, R.string.attribute_onehour_no), - SCENIC(8, "scenic", R.drawable.attribute_scenic, R.string.attribute_scenic_yes, R.string.attribute_scenic_no), - HIKING(9, "hiking", R.drawable.attribute_hiking, R.string.attribute_hiking_yes, R.string.attribute_hiking_no), - CLIMBING(10, "climbing", R.drawable.attribute_climbing, R.string.attribute_climbing_yes, R.string.attribute_climbing_no), - WADING(11, "wading", R.drawable.attribute_wading, R.string.attribute_wading_yes, R.string.attribute_wading_no), - SWIMMING(12, "swimming", R.drawable.attribute_swimming, R.string.attribute_swimming_yes, R.string.attribute_swimming_no), - AVAILABLE(13, "available", R.drawable.attribute_available, R.string.attribute_available_yes, R.string.attribute_available_no), - NIGHT(14, "night", R.drawable.attribute_night, R.string.attribute_night_yes, R.string.attribute_night_no), - WINTER(15, "winter", R.drawable.attribute_winter, R.string.attribute_winter_yes, R.string.attribute_winter_no), - POISONOAK(17, "poisonoak", R.drawable.attribute_poisonoak, R.string.attribute_poisonoak_yes, R.string.attribute_poisonoak_no), - DANGEROUSANIMALS(18, "dangerousanimals", R.drawable.attribute_dangerousanimals, R.string.attribute_dangerousanimals_yes, R.string.attribute_dangerousanimals_no), - TICKS(19, "ticks", R.drawable.attribute_ticks, R.string.attribute_ticks_yes, R.string.attribute_ticks_no), - MINE(29, "mine", R.drawable.attribute_mine, R.string.attribute_mine_yes, R.string.attribute_mine_no), - CLIFF(21, "cliff", R.drawable.attribute_cliff, R.string.attribute_cliff_yes, R.string.attribute_cliff_no), - HUNTING(22, "hunting", R.drawable.attribute_hunting, R.string.attribute_hunting_yes, R.string.attribute_hunting_no), - DANGER(23, "danger", R.drawable.attribute_danger, R.string.attribute_danger_yes, R.string.attribute_danger_no), - WHEELCHAIR(24, "wheelchair", R.drawable.attribute_wheelchair, R.string.attribute_wheelchair_yes, R.string.attribute_wheelchair_no), - PARKING(25, "parking", R.drawable.attribute_parking, R.string.attribute_parking_yes, R.string.attribute_parking_no), - PUBLIC(26, "public", R.drawable.attribute_public, R.string.attribute_public_yes, R.string.attribute_public_no), - WATER(27, "water", R.drawable.attribute_water, R.string.attribute_water_yes, R.string.attribute_water_no), - RESTROOMS(28, "restrooms", R.drawable.attribute_restrooms, R.string.attribute_restrooms_yes, R.string.attribute_restrooms_no), - PHONE(29, "phone", R.drawable.attribute_phone, R.string.attribute_phone_yes, R.string.attribute_phone_no), - PICNIC(30, "picnic", R.drawable.attribute_picnic, R.string.attribute_picnic_yes, R.string.attribute_picnic_no), - CAMPING(31, "camping", R.drawable.attribute_camping, R.string.attribute_camping_yes, R.string.attribute_camping_no), - BICYCLES(32, "bicycles", R.drawable.attribute_bicycles, R.string.attribute_bicycles_yes, R.string.attribute_bicycles_no), - MOTORCYCLES(33, "motorcycles", R.drawable.attribute_motorcycles, R.string.attribute_motorcycles_yes, R.string.attribute_motorcycles_no), - QUADS(34, "quads", R.drawable.attribute_quads, R.string.attribute_quads_yes, R.string.attribute_quads_no), - JEEPS(35, "jeeps", R.drawable.attribute_jeeps, R.string.attribute_jeeps_yes, R.string.attribute_jeeps_no), - SNOWMOBILES(36, "snowmobiles", R.drawable.attribute_snowmobiles, R.string.attribute_snowmobiles_yes, R.string.attribute_snowmobiles_no), - HORSES(37, "horses", R.drawable.attribute_horses, R.string.attribute_horses_yes, R.string.attribute_horses_no), - CAMPFIRES(38, "campfires", R.drawable.attribute_campfires, R.string.attribute_campfires_yes, R.string.attribute_campfires_no), - THORN(39, "thorn", R.drawable.attribute_thorn, R.string.attribute_thorn_yes, R.string.attribute_thorn_no), - STEALTH(40, "stealth", R.drawable.attribute_stealth, R.string.attribute_stealth_yes, R.string.attribute_stealth_no), - STROLLER(41, "stroller", R.drawable.attribute_stroller, R.string.attribute_stroller_yes, R.string.attribute_stroller_no), - FIRSTAID(42, "firstaid", R.drawable.attribute_firstaid, R.string.attribute_firstaid_yes, R.string.attribute_firstaid_no), - COW(43, "cow", R.drawable.attribute_cow, R.string.attribute_cow_yes, R.string.attribute_cow_no), - FLASHLIGHT(44, "flashlight", R.drawable.attribute_flashlight, R.string.attribute_flashlight_yes, R.string.attribute_flashlight_no), - LANDF(45, "landf", R.drawable.attribute_landf, R.string.attribute_landf_yes, R.string.attribute_landf_no), - RV(46, "rv", R.drawable.attribute_rv, R.string.attribute_rv_yes, R.string.attribute_rv_no), - FIELD_PUZZLE(47, "field_puzzle", R.drawable.attribute_field_puzzle, R.string.attribute_field_puzzle_yes, R.string.attribute_field_puzzle_no), - UV(48, "uv", R.drawable.attribute_uv, R.string.attribute_uv_yes, R.string.attribute_uv_no), - SNOWSHOES(49, "snowshoes", R.drawable.attribute_snowshoes, R.string.attribute_snowshoes_yes, R.string.attribute_snowshoes_no), - SKIIS(50, "skiis", R.drawable.attribute_skiis, R.string.attribute_skiis_yes, R.string.attribute_skiis_no), - SPECIAL_TOOLS(51, "s_tool", R.drawable.attribute_s_tool, R.string.attribute_s_tool_yes, R.string.attribute_s_tool_no), - NIGHTCACHE(52, "nightcache", R.drawable.attribute_nightcache, R.string.attribute_nightcache_yes, R.string.attribute_nightcache_no), - PARKNGRAB(53, "parkngrab", R.drawable.attribute_parkngrab, R.string.attribute_parkngrab_yes, R.string.attribute_parkngrab_no), - ABANDONED_BUILDING(54, "abandonedbuilding", R.drawable.attribute_abandonedbuilding, R.string.attribute_abandonedbuilding_yes, R.string.attribute_abandonedbuilding_no), - HIKE_SHORT(55, "hike_short", R.drawable.attribute_hike_short, R.string.attribute_hike_short_yes, R.string.attribute_hike_short_no), - HIKE_MED(56, "hike_med", R.drawable.attribute_hike_med, R.string.attribute_hike_med_yes, R.string.attribute_hike_med_no), - HIKE_LONG(57, "hike_long", R.drawable.attribute_hike_long, R.string.attribute_hike_long_yes, R.string.attribute_hike_long_no), - FUEL(58, "fuel", R.drawable.attribute_fuel, R.string.attribute_fuel_yes, R.string.attribute_fuel_no), - FOOD(59, "food", R.drawable.attribute_food, R.string.attribute_food_yes, R.string.attribute_food_no), - WIRELESS_BEACON(60, "wirelessbeacon", R.drawable.attribute_wirelessbeacon, R.string.attribute_wirelessbeacon_yes, R.string.attribute_wirelessbeacon_no), - PARTNERSHIP(61, "partnership", R.drawable.attribute_partnership, R.string.attribute_partnership_yes, R.string.attribute_partnership_no), - SEASONAL(62, "seasonal", R.drawable.attribute_seasonal, R.string.attribute_seasonal_yes, R.string.attribute_seasonal_no), - TOURIST_OK(63, "touristok", R.drawable.attribute_touristok, R.string.attribute_touristok_yes, R.string.attribute_touristok_no), - TREECLIMBING(64, "treeclimbing", R.drawable.attribute_treeclimbing, R.string.attribute_treeclimbing_yes, R.string.attribute_treeclimbing_no), - FRONTYARD(65, "frontyard", R.drawable.attribute_frontyard, R.string.attribute_frontyard_yes, R.string.attribute_frontyard_no), - TEAMWORK(66, "teamwork", R.drawable.attribute_teamwork, R.string.attribute_teamwork_yes, R.string.attribute_teamwork_no); - - private static final String INTERNAL_PRE = "attribute_"; + // THIS LIST IS GENERATED: don't change anything here but in + // project/attributes/makeEnum.sh + DOGS(1, -1, "dogs", R.drawable.attribute_dogs, R.string.attribute_dogs_yes, R.string.attribute_dogs_no), + BICYCLES(32, -1, "bicycles", R.drawable.attribute_bicycles, R.string.attribute_bicycles_yes, R.string.attribute_bicycles_no), + MOTORCYCLES(33, -1, "motorcycles", R.drawable.attribute_motorcycles, R.string.attribute_motorcycles_yes, R.string.attribute_motorcycles_no), + QUADS(34, -1, "quads", R.drawable.attribute_quads, R.string.attribute_quads_yes, R.string.attribute_quads_no), + JEEPS(35, -1, "jeeps", R.drawable.attribute_jeeps, R.string.attribute_jeeps_yes, R.string.attribute_jeeps_no), + SNOWMOBILES(36, -1, "snowmobiles", R.drawable.attribute_snowmobiles, R.string.attribute_snowmobiles_yes, R.string.attribute_snowmobiles_no), + HORSES(37, -1, "horses", R.drawable.attribute_horses, R.string.attribute_horses_yes, R.string.attribute_horses_no), + CAMPFIRES(38, -1, "campfires", R.drawable.attribute_campfires, R.string.attribute_campfires_yes, R.string.attribute_campfires_no), + RV(46, -1, "rv", R.drawable.attribute_rv, R.string.attribute_rv_yes, R.string.attribute_rv_no), + KIDS(6, 59, "kids", R.drawable.attribute_kids, R.string.attribute_kids_yes, R.string.attribute_kids_no), + ONEHOUR(7, -1, "onehour", R.drawable.attribute_onehour, R.string.attribute_onehour_yes, R.string.attribute_onehour_no), + SCENIC(8, -1, "scenic", R.drawable.attribute_scenic, R.string.attribute_scenic_yes, R.string.attribute_scenic_no), + HIKING(9, 25, "hiking", R.drawable.attribute_hiking, R.string.attribute_hiking_yes, R.string.attribute_hiking_no), + CLIMBING(10, 28, "climbing", R.drawable.attribute_climbing, R.string.attribute_climbing_yes, R.string.attribute_climbing_no), + WADING(11, -1, "wading", R.drawable.attribute_wading, R.string.attribute_wading_yes, R.string.attribute_wading_no), + SWIMMING(12, 29, "swimming", R.drawable.attribute_swimming, R.string.attribute_swimming_yes, R.string.attribute_swimming_no), + AVAILABLE(13, 38, "available", R.drawable.attribute_available, R.string.attribute_available_yes, R.string.attribute_available_no), + NIGHT(14, -1, "night", R.drawable.attribute_night, R.string.attribute_night_yes, R.string.attribute_night_no), + WINTER(15, -1, "winter", R.drawable.attribute_winter, R.string.attribute_winter_yes, R.string.attribute_winter_no), + STEALTH(40, -1, "stealth", R.drawable.attribute_stealth, R.string.attribute_stealth_yes, R.string.attribute_stealth_no), + FIRSTAID(42, -1, "firstaid", R.drawable.attribute_firstaid, R.string.attribute_firstaid_yes, R.string.attribute_firstaid_no), + COW(43, -1, "cow", R.drawable.attribute_cow, R.string.attribute_cow_yes, R.string.attribute_cow_no), + FIELD_PUZZLE(47, -1, "field_puzzle", R.drawable.attribute_field_puzzle, R.string.attribute_field_puzzle_yes, R.string.attribute_field_puzzle_no), + NIGHTCACHE(52, 1, "nightcache", R.drawable.attribute_nightcache, R.string.attribute_nightcache_yes, R.string.attribute_nightcache_no), + PARKNGRAB(53, 24, "parkngrab", R.drawable.attribute_parkngrab, R.string.attribute_parkngrab_yes, R.string.attribute_parkngrab_no), + ABANDONEDBUILDING(54, -1, "abandonedbuilding", R.drawable.attribute_abandonedbuilding, R.string.attribute_abandonedbuilding_yes, R.string.attribute_abandonedbuilding_no), + HIKE_SHORT(55, -1, "hike_short", R.drawable.attribute_hike_short, R.string.attribute_hike_short_yes, R.string.attribute_hike_short_no), + HIKE_MED(56, -1, "hike_med", R.drawable.attribute_hike_med, R.string.attribute_hike_med_yes, R.string.attribute_hike_med_no), + HIKE_LONG(57, -1, "hike_long", R.drawable.attribute_hike_long, R.string.attribute_hike_long_yes, R.string.attribute_hike_long_no), + SEASONAL(62, 60, "seasonal", R.drawable.attribute_seasonal, R.string.attribute_seasonal_yes, R.string.attribute_seasonal_no), + TOURISTOK(63, -1, "touristok", R.drawable.attribute_touristok, R.string.attribute_touristok_yes, R.string.attribute_touristok_no), + FRONTYARD(65, -1, "frontyard", R.drawable.attribute_frontyard, R.string.attribute_frontyard_yes, R.string.attribute_frontyard_no), + TEAMWORK(66, -1, "teamwork", R.drawable.attribute_teamwork, R.string.attribute_teamwork_yes, R.string.attribute_teamwork_no), + LANDF(45, -1, "landf", R.drawable.attribute_landf, R.string.attribute_landf_yes, R.string.attribute_landf_no), + PARTNERSHIP(61, -1, "partnership", R.drawable.attribute_partnership, R.string.attribute_partnership_yes, R.string.attribute_partnership_no), + FEE(2, 36, "fee", R.drawable.attribute_fee, R.string.attribute_fee_yes, R.string.attribute_fee_no), + RAPPELLING(3, 49, "rappelling", R.drawable.attribute_rappelling, R.string.attribute_rappelling_yes, R.string.attribute_rappelling_no), + BOAT(4, 52, "boat", R.drawable.attribute_boat, R.string.attribute_boat_yes, R.string.attribute_boat_no), + SCUBA(5, 51, "scuba", R.drawable.attribute_scuba, R.string.attribute_scuba_yes, R.string.attribute_scuba_no), + FLASHLIGHT(44, 48, "flashlight", R.drawable.attribute_flashlight, R.string.attribute_flashlight_yes, R.string.attribute_flashlight_no), + UV(48, -1, "uv", R.drawable.attribute_uv, R.string.attribute_uv_yes, R.string.attribute_uv_no), + SNOWSHOES(49, -1, "snowshoes", R.drawable.attribute_snowshoes, R.string.attribute_snowshoes_yes, R.string.attribute_snowshoes_no), + SKIIS(50, -1, "skiis", R.drawable.attribute_skiis, R.string.attribute_skiis_yes, R.string.attribute_skiis_no), + S_TOOL(51, 46, "s_tool", R.drawable.attribute_s_tool, R.string.attribute_s_tool_yes, R.string.attribute_s_tool_no), + WIRELESSBEACON(60, -1, "wirelessbeacon", R.drawable.attribute_wirelessbeacon, R.string.attribute_wirelessbeacon_yes, R.string.attribute_wirelessbeacon_no), + TREECLIMBING(64, -1, "treeclimbing", R.drawable.attribute_treeclimbing, R.string.attribute_treeclimbing_yes, R.string.attribute_treeclimbing_no), + POISONOAK(17, 16, "poisonoak", R.drawable.attribute_poisonoak, R.string.attribute_poisonoak_yes, R.string.attribute_poisonoak_no), + DANGEROUSANIMALS(18, 17, "dangerousanimals", R.drawable.attribute_dangerousanimals, R.string.attribute_dangerousanimals_yes, R.string.attribute_dangerousanimals_no), + TICKS(19, 14, "ticks", R.drawable.attribute_ticks, R.string.attribute_ticks_yes, R.string.attribute_ticks_no), + MINE(20, 15, "mine", R.drawable.attribute_mine, R.string.attribute_mine_yes, R.string.attribute_mine_no), + CLIFF(21, 11, "cliff", R.drawable.attribute_cliff, R.string.attribute_cliff_yes, R.string.attribute_cliff_no), + HUNTING(22, 12, "hunting", R.drawable.attribute_hunting, R.string.attribute_hunting_yes, R.string.attribute_hunting_no), + DANGER(23, 9, "danger", R.drawable.attribute_danger, R.string.attribute_danger_yes, R.string.attribute_danger_no), + THORN(39, 13, "thorn", R.drawable.attribute_thorn, R.string.attribute_thorn_yes, R.string.attribute_thorn_no), + WHEELCHAIR(24, -1, "wheelchair", R.drawable.attribute_wheelchair, R.string.attribute_wheelchair_yes, R.string.attribute_wheelchair_no), + PARKING(25, 18, "parking", R.drawable.attribute_parking, R.string.attribute_parking_yes, R.string.attribute_parking_no), + PUBLIC(26, 19, "public", R.drawable.attribute_public, R.string.attribute_public_yes, R.string.attribute_public_no), + WATER(27, 20, "water", R.drawable.attribute_water, R.string.attribute_water_yes, R.string.attribute_water_no), + RESTROOMS(28, 21, "restrooms", R.drawable.attribute_restrooms, R.string.attribute_restrooms_yes, R.string.attribute_restrooms_no), + PHONE(29, 22, "phone", R.drawable.attribute_phone, R.string.attribute_phone_yes, R.string.attribute_phone_no), + PICNIC(30, -1, "picnic", R.drawable.attribute_picnic, R.string.attribute_picnic_yes, R.string.attribute_picnic_no), + CAMPING(31, -1, "camping", R.drawable.attribute_camping, R.string.attribute_camping_yes, R.string.attribute_camping_no), + STROLLER(41, -1, "stroller", R.drawable.attribute_stroller, R.string.attribute_stroller_yes, R.string.attribute_stroller_no), + FUEL(58, -1, "fuel", R.drawable.attribute_fuel, R.string.attribute_fuel_yes, R.string.attribute_fuel_no), + FOOD(59, -1, "food", R.drawable.attribute_food, R.string.attribute_food_yes, R.string.attribute_food_no), + OC_ONLY(-1, 6, "oc_only", R.drawable.attribute_oc_only, R.string.attribute_oc_only_yes, R.string.attribute_oc_only_no), + LINK_ONLY(-1, 7, "link_only", R.drawable.attribute_link_only, R.string.attribute_link_only_yes, R.string.attribute_link_only_no), + LETTERBOX(-1, 8, "letterbox", R.drawable.attribute_letterbox, R.string.attribute_letterbox_yes, R.string.attribute_letterbox_no), + RAILWAY(-1, 10, "railway", R.drawable.attribute_railway, R.string.attribute_railway_yes, R.string.attribute_railway_no), + SYRINGE(-1, 23, "syringe", R.drawable.attribute_syringe, R.string.attribute_syringe_yes, R.string.attribute_syringe_no), + SWAMP(-1, 26, "swamp", R.drawable.attribute_swamp, R.string.attribute_swamp_yes, R.string.attribute_swamp_no), + HILLS(-1, 27, "hills", R.drawable.attribute_hills, R.string.attribute_hills_yes, R.string.attribute_hills_no), + POI(-1, 30, "poi", R.drawable.attribute_poi, R.string.attribute_poi_yes, R.string.attribute_poi_no), + MOVING_TARGET(-1, 31, "moving_target", R.drawable.attribute_moving_target, R.string.attribute_moving_target_yes, R.string.attribute_moving_target_no), + WEBCAM(-1, 32, "webcam", R.drawable.attribute_webcam, R.string.attribute_webcam_yes, R.string.attribute_webcam_no), + INSIDE(-1, 33, "inside", R.drawable.attribute_inside, R.string.attribute_inside_yes, R.string.attribute_inside_no), + IN_WATER(-1, 34, "in_water", R.drawable.attribute_in_water, R.string.attribute_in_water_yes, R.string.attribute_in_water_no), + NO_GPS(-1, 35, "no_gps", R.drawable.attribute_no_gps, R.string.attribute_no_gps_yes, R.string.attribute_no_gps_no), + OVERNIGHT(-1, 37, "overnight", R.drawable.attribute_overnight, R.string.attribute_overnight_yes, R.string.attribute_overnight_no), + SPECIFIC_TIMES(-1, 39, "specific_times", R.drawable.attribute_specific_times, R.string.attribute_specific_times_yes, R.string.attribute_specific_times_no), + DAY(-1, 40, "day", R.drawable.attribute_day, R.string.attribute_day_yes, R.string.attribute_day_no), + TIDE(-1, 41, "tide", R.drawable.attribute_tide, R.string.attribute_tide_yes, R.string.attribute_tide_no), + ALL_SEASONS(-1, 42, "all_seasons", R.drawable.attribute_all_seasons, R.string.attribute_all_seasons_yes, R.string.attribute_all_seasons_no), + BREEDING(-1, 43, "breeding", R.drawable.attribute_breeding, R.string.attribute_breeding_yes, R.string.attribute_breeding_no), + SNOW_PROOF(-1, 44, "snow_proof", R.drawable.attribute_snow_proof, R.string.attribute_snow_proof_yes, R.string.attribute_snow_proof_no), + COMPASS(-1, 47, "compass", R.drawable.attribute_compass, R.string.attribute_compass_yes, R.string.attribute_compass_no), + CAVE(-1, 50, "cave", R.drawable.attribute_cave, R.string.attribute_cave_yes, R.string.attribute_cave_no), + AIRCRAFT(-1, 53, "aircraft", R.drawable.attribute_aircraft, R.string.attribute_aircraft_yes, R.string.attribute_aircraft_no), + INVESTIGATION(-1, 54, "investigation", R.drawable.attribute_investigation, R.string.attribute_investigation_yes, R.string.attribute_investigation_no), + PUZZLE(-1, 55, "puzzle", R.drawable.attribute_puzzle, R.string.attribute_puzzle_yes, R.string.attribute_puzzle_no), + ARITHMETIC(-1, 56, "arithmetic", R.drawable.attribute_arithmetic, R.string.attribute_arithmetic_yes, R.string.attribute_arithmetic_no), + OTHER_CACHE(-1, 57, "other_cache", R.drawable.attribute_other_cache, R.string.attribute_other_cache_yes, R.string.attribute_other_cache_no), + ASK_OWNER(-1, 58, "ask_owner", R.drawable.attribute_ask_owner, R.string.attribute_ask_owner_yes, R.string.attribute_ask_owner_no), + UNKNOWN(-1, -1, "unknown", R.drawable.attribute_unknown, R.string.attribute_unknown_yes, R.string.attribute_unknown_no); + // THIS LIST IS GENERATED: don't change anything here but in + // project/attributes/makeEnum.sh + private static final String INTERNAL_YES = "_yes"; private static final String INTERNAL_NO = "_no"; - public final int id; - public final String gcRawName; + public static final int NO_ID = -1; + + public final int gcid; + public final int ocid; + public final String rawName; public final int drawableId; public final int stringIdYes; public final int stringIdNo; - CacheAttribute(final int id, final String gcRawName, final int drawableId, final int stringIdYes, final int stringIdNo) { - this.id = id; - this.gcRawName = gcRawName; + CacheAttribute(final int gcid, final int ocid, final String rawName, + final int drawableId, final int stringIdYes, final int stringIdNo) { + this.gcid = gcid; + this.ocid = ocid; + this.rawName = rawName; this.drawableId = drawableId; this.stringIdYes = stringIdYes; this.stringIdNo = stringIdNo; } + /** + * get localized text + * + * @param enabled + * true: for positive text, false: for negative text + * @return the localized text + */ public String getL10n(final boolean enabled) { - return cgeoapplication.getInstance().getResources().getString(enabled ? stringIdYes : stringIdNo); + return cgeoapplication.getInstance().getResources().getString( + enabled ? stringIdYes : stringIdNo); } private final static Map<String, CacheAttribute> FIND_BY_GCRAWNAME; - static { final HashMap<String, CacheAttribute> mapGcRawNames = new HashMap<String, CacheAttribute>(); for (CacheAttribute attr : values()) { - mapGcRawNames.put(attr.gcRawName, attr); + mapGcRawNames.put(attr.rawName, attr); } FIND_BY_GCRAWNAME = Collections.unmodifiableMap(mapGcRawNames); } - public static CacheAttribute getByGcRawName(final String gcRawName) { - final CacheAttribute result = gcRawName != null ? FIND_BY_GCRAWNAME.get(gcRawName) : null; - if (result == null) { - return UNKNOWN; + private final static SparseArray<CacheAttribute> FIND_BY_GCID = new SparseArray<CacheAttribute>(); + static { + for (CacheAttribute attr : values()) { + if (attr.gcid != NO_ID) { + FIND_BY_GCID.put(attr.gcid, attr); + } + } + } + + private final static SparseArray<CacheAttribute> FIND_BY_OCID = new SparseArray<CacheAttribute>(); + static { + for (CacheAttribute attr : values()) { + if (attr.ocid != NO_ID) { + FIND_BY_OCID.put(attr.ocid, attr); + } } - return result; + } + + public static CacheAttribute getByRawName(final String rawName) { + return rawName != null ? FIND_BY_GCRAWNAME.get(rawName) : null; + } + + public static CacheAttribute getByGcId(final int gcid) { + return FIND_BY_GCID.get(gcid); + } + + public static CacheAttribute getByOcId(final int ocid) { + return FIND_BY_OCID.get(ocid); } public static String trimAttributeName(String attributeName) { if (null == attributeName) { return ""; } - return attributeName.replace(INTERNAL_PRE, "").replace(INTERNAL_YES, "").replace(INTERNAL_NO, "").trim(); + return attributeName.replace(INTERNAL_YES, "").replace(INTERNAL_NO, "").trim(); } public static boolean isEnabled(final String attributeName) { @@ -130,6 +196,6 @@ public enum CacheAttribute { } public String getAttributeName(final boolean yes) { - return gcRawName + (yes ? INTERNAL_YES : INTERNAL_NO); + return rawName + (yes ? INTERNAL_YES : INTERNAL_NO); } } diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java index 4997923..d130e1f 100644 --- a/main/src/cgeo/geocaching/export/GpxExport.java +++ b/main/src/cgeo/geocaching/export/GpxExport.java @@ -322,11 +322,14 @@ class GpxExport extends AbstractExport { gpx.startTag(PREFIX_GROUNDSPEAK, "attributes"); for (String attribute : cache.getAttributes()) { - final CacheAttribute attr = CacheAttribute.getByGcRawName(CacheAttribute.trimAttributeName(attribute)); + final CacheAttribute attr = CacheAttribute.getByRawName(CacheAttribute.trimAttributeName(attribute)); + if (attr == null) { + continue; + } final boolean enabled = CacheAttribute.isEnabled(attribute); gpx.startTag(PREFIX_GROUNDSPEAK, "attribute"); - gpx.attribute("", "id", Integer.toString(attr.id)); + gpx.attribute("", "id", Integer.toString(attr.gcid)); gpx.attribute("", "inc", enabled ? "1" : "0"); gpx.text(attr.getL10n(enabled)); gpx.endTag(PREFIX_GROUNDSPEAK, "attribute"); diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java index 9b10d20..a691677 100644 --- a/main/src/cgeo/geocaching/files/GPXParser.java +++ b/main/src/cgeo/geocaching/files/GPXParser.java @@ -4,9 +4,9 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.LogEntry; import cgeo.geocaching.R; import cgeo.geocaching.StoredList; +import cgeo.geocaching.Trackable; import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgData; -import cgeo.geocaching.Trackable; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.enumerations.CacheSize; |
