aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java46
-rw-r--r--main/src/cgeo/geocaching/ICache.java4
-rw-r--r--main/src/cgeo/geocaching/VisitCacheActivity.java66
-rw-r--r--main/src/cgeo/geocaching/activity/ActivityMixin.java9
-rw-r--r--main/src/cgeo/geocaching/cgBase.java167
-rw-r--r--main/src/cgeo/geocaching/cgCache.java59
-rw-r--r--main/src/cgeo/geocaching/cgData.java31
-rw-r--r--main/src/cgeo/geocaching/cgLog.java6
-rw-r--r--main/src/cgeo/geocaching/cgeo.java4
-rw-r--r--main/src/cgeo/geocaching/cgeoapplication.java5
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java23
-rw-r--r--main/src/cgeo/geocaching/cgeopopup.java3
-rw-r--r--main/src/cgeo/geocaching/cgeotouch.java48
-rw-r--r--main/src/cgeo/geocaching/cgeotrackable.java6
-rw-r--r--main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java13
-rw-r--r--main/src/cgeo/geocaching/enumerations/LogType.java103
-rw-r--r--main/src/cgeo/geocaching/files/GPXParser.java8
-rw-r--r--main/src/cgeo/geocaching/sorting/FindsComparator.java4
-rw-r--r--tests/src/cgeo/geocaching/cgBaseTest.java5
-rw-r--r--tests/src/cgeo/geocaching/enumerations/LogTypeTest.java25
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java23
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2CJPF.java21
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2JVEH.java15
23 files changed, 341 insertions, 353 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 1fb8ae6..c388f67 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -7,6 +7,7 @@ import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
import cgeo.geocaching.compatibility.Compatibility;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.IConnector;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.GeopointFormatter;
import cgeo.geocaching.network.HtmlImage;
import cgeo.geocaching.utils.BaseUtils;
@@ -544,7 +545,7 @@ public class CacheDetailActivity extends AbstractActivity {
}
int logType = menuItem - MENU_LOG_VISIT_OFFLINE;
- cache.logOffline(this, logType);
+ cache.logOffline(this, LogType.getById(logType));
return true;
}
@@ -2054,21 +2055,20 @@ public class CacheDetailActivity extends AbstractActivity {
text.append(": ");
// sort the log counts by type id ascending. that way the FOUND, DNF log types are the first and most visible ones
- List<Entry<Integer, Integer>> sortedLogCounts = new ArrayList<Entry<Integer, Integer>>();
- for (Entry<Integer, Integer> entry : cache.getLogCounts().entrySet()) {
+ List<Entry<LogType, Integer>> sortedLogCounts = new ArrayList<Entry<LogType, Integer>>();
+ for (Entry<LogType, Integer> entry : cache.getLogCounts().entrySet()) {
sortedLogCounts.add(entry); // don't add these entries using addAll(), the iterator in the EntrySet can go wrong (see Findbugs)
}
- Collections.sort(sortedLogCounts, new Comparator<Entry<Integer, Integer>>() {
+ Collections.sort(sortedLogCounts, new Comparator<Entry<LogType, Integer>>() {
@Override
- public int compare(Entry<Integer, Integer> logCountItem1,
- Entry<Integer, Integer> logCountItem2) {
+ public int compare(Entry<LogType, Integer> logCountItem1,
+ Entry<LogType, Integer> logCountItem2) {
return logCountItem1.getKey().compareTo(logCountItem2.getKey());
}
});
- for (Entry<Integer, Integer> pair : sortedLogCounts) {
- int logTypeId = pair.getKey().intValue();
- String logTypeLabel = cgBase.logTypes1.get(logTypeId);
+ for (Entry<LogType, Integer> pair : sortedLogCounts) {
+ String logTypeLabel = pair.getKey().getL10n();
// it may happen that the label is unknown -> then avoid any output for this type
if (logTypeLabel != null) {
if (showLogCounter) {
@@ -2096,11 +2096,7 @@ public class CacheDetailActivity extends AbstractActivity {
((TextView) rowView.findViewById(R.id.added)).setVisibility(View.GONE);
}
- if (cgBase.logTypes1.containsKey(log.type)) {
- ((TextView) rowView.findViewById(R.id.type)).setText(cgBase.logTypes1.get(log.type));
- } else {
- ((TextView) rowView.findViewById(R.id.type)).setText(cgBase.logTypes1.get(cgBase.LOG_NOTE)); // note if type is unknown
- }
+ ((TextView) rowView.findViewById(R.id.type)).setText(log.type.getL10n());
((TextView) rowView.findViewById(R.id.author)).setText(StringEscapeUtils.unescapeHtml4(log.author));
if (log.found == -1) {
@@ -2153,20 +2149,20 @@ public class CacheDetailActivity extends AbstractActivity {
// Add colored mark
final ImageView logMark = (ImageView) rowView.findViewById(R.id.log_mark);
- if (log.type == cgBase.LOG_FOUND_IT
- || log.type == cgBase.LOG_WEBCAM_PHOTO_TAKEN
- || log.type == cgBase.LOG_ATTENDED) {
+ if (log.type == LogType.LOG_FOUND_IT
+ || log.type == LogType.LOG_WEBCAM_PHOTO_TAKEN
+ || log.type == LogType.LOG_ATTENDED) {
logMark.setImageResource(R.drawable.mark_green);
- } else if (log.type == cgBase.LOG_PUBLISH_LISTING
- || log.type == cgBase.LOG_ENABLE_LISTING
- || log.type == cgBase.LOG_OWNER_MAINTENANCE) {
+ } else if (log.type == LogType.LOG_PUBLISH_LISTING
+ || log.type == LogType.LOG_ENABLE_LISTING
+ || log.type == LogType.LOG_OWNER_MAINTENANCE) {
logMark.setImageResource(R.drawable.mark_green_more);
- } else if (log.type == cgBase.LOG_DIDNT_FIND_IT
- || log.type == cgBase.LOG_NEEDS_MAINTENANCE
- || log.type == cgBase.LOG_NEEDS_ARCHIVE) {
+ } else if (log.type == LogType.LOG_DIDNT_FIND_IT
+ || log.type == LogType.LOG_NEEDS_MAINTENANCE
+ || log.type == LogType.LOG_NEEDS_ARCHIVE) {
logMark.setImageResource(R.drawable.mark_red);
- } else if (log.type == cgBase.LOG_TEMP_DISABLE_LISTING
- || log.type == cgBase.LOG_ARCHIVE) {
+ } else if (log.type == LogType.LOG_TEMP_DISABLE_LISTING
+ || log.type == LogType.LOG_ARCHIVE) {
logMark.setImageResource(R.drawable.mark_red_more);
} else {
logMark.setVisibility(View.GONE);
diff --git a/main/src/cgeo/geocaching/ICache.java b/main/src/cgeo/geocaching/ICache.java
index 4d43e9b..8b0d2aa 100644
--- a/main/src/cgeo/geocaching/ICache.java
+++ b/main/src/cgeo/geocaching/ICache.java
@@ -3,6 +3,8 @@
*/
package cgeo.geocaching;
+import cgeo.geocaching.enumerations.LogType;
+
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -129,7 +131,7 @@ public interface ICache extends IBasicCache {
/**
* @return a statistic how often the caches has been found, disabled, archived etc.
*/
- public Map<Integer, Integer> getLogCounts();
+ public Map<LogType, Integer> getLogCounts();
/**
* get the name for lexicographical sorting.
diff --git a/main/src/cgeo/geocaching/VisitCacheActivity.java b/main/src/cgeo/geocaching/VisitCacheActivity.java
index 0da4db9..2c16b45 100644
--- a/main/src/cgeo/geocaching/VisitCacheActivity.java
+++ b/main/src/cgeo/geocaching/VisitCacheActivity.java
@@ -1,6 +1,7 @@
package cgeo.geocaching;
import cgeo.geocaching.LogTemplateProvider.LogTemplate;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.LogTypeTrackable;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.gcvote.GCVote;
@@ -44,7 +45,7 @@ public class VisitCacheActivity extends cgLogForm {
private LayoutInflater inflater = null;
private cgCache cache = null;
- private List<Integer> types = new ArrayList<Integer>();
+ private List<LogType> possibleLogTypes = new ArrayList<LogType>();
private ProgressDialog waitDialog = null;
private String cacheid = null;
private String geocode = null;
@@ -54,7 +55,7 @@ public class VisitCacheActivity extends cgLogForm {
private boolean gettingViewstate = true;
private List<cgTrackableLog> trackables = null;
private Calendar date = Calendar.getInstance();
- private int typeSelected = 1;
+ private LogType typeSelected = LogType.LOG_UNKNOWN;
private int attempts = 0;
private Button postButton = null;
private Button saveButton = null;
@@ -69,8 +70,8 @@ public class VisitCacheActivity extends cgLogForm {
@Override
public void handleMessage(Message msg) {
- if (!types.contains(typeSelected)) {
- typeSelected = types.get(0);
+ if (!possibleLogTypes.contains(typeSelected)) {
+ typeSelected = possibleLogTypes.get(0);
setType(typeSelected);
showToast(res.getString(R.string.info_log_type_changed));
@@ -180,7 +181,7 @@ public class VisitCacheActivity extends cgLogForm {
private void updatePostButtonText() {
if (postButton.isEnabled()) {
- if (typeSelected == cgBase.LOG_FOUND_IT && Settings.isGCvoteLogin()) {
+ if (typeSelected == LogType.LOG_FOUND_IT && Settings.isGCvoteLogin()) {
if (rating == 0) {
postButton.setText(res.getString(R.string.log_post_no_rate));
} else {
@@ -313,7 +314,7 @@ public class VisitCacheActivity extends cgLogForm {
final boolean signatureAvailable = Settings.getSignature() != null;
menu.findItem(MENU_SIGNATURE).setVisible(signatureAvailable);
- final boolean voteAvailable = Settings.isGCvoteLogin() && typeSelected == cgBase.LOG_FOUND_IT && StringUtils.isNotBlank(cache.getGuid());
+ final boolean voteAvailable = Settings.isGCvoteLogin() && typeSelected == LogType.LOG_FOUND_IT && StringUtils.isNotBlank(cache.getGuid());
menu.findItem(SUBMENU_VOTE).setVisible(voteAvailable);
return true;
@@ -358,9 +359,9 @@ public class VisitCacheActivity extends cgLogForm {
final int viewId = view.getId();
if (viewId == R.id.type) {
- for (final int typeOne : types) {
- menu.add(viewId, typeOne, 0, cgBase.logTypes2.get(typeOne));
- Log.w(Settings.tag, "Adding " + typeOne + " " + cgBase.logTypes2.get(typeOne));
+ for (final LogType typeOne : possibleLogTypes) {
+ menu.add(viewId, typeOne.id, 0, typeOne.getL10n());
+ Log.w(Settings.tag, "Adding " + typeOne + " " + typeOne.getL10n());
}
} else if (viewId == R.id.changebutton) {
final int textId = ((TextView) findViewById(viewId)).getId();
@@ -389,7 +390,7 @@ public class VisitCacheActivity extends cgLogForm {
final int id = item.getItemId();
if (group == R.id.type) {
- setType(id);
+ setType(LogType.getById(id));
return true;
} else if (group == R.id.changebutton) {
@@ -463,7 +464,7 @@ public class VisitCacheActivity extends cgLogForm {
clearButton = (Button) findViewById(R.id.clear);
saveButton = (Button) findViewById(R.id.save);
- types = cache.getPossibleLogTypes();
+ possibleLogTypes = cache.getPossibleLogTypes();
final cgLog log = app.loadLogOffline(geocode);
if (log != null) {
@@ -477,18 +478,18 @@ public class VisitCacheActivity extends cgLogForm {
insertIntoLog(LogTemplateProvider.applyTemplates(Settings.getSignature(), false), false);
}
- if (!types.contains(typeSelected)) {
+ if (!possibleLogTypes.contains(typeSelected)) {
if (alreadyFound) {
- typeSelected = cgBase.LOG_NOTE;
+ typeSelected = LogType.LOG_NOTE;
} else {
- typeSelected = types.get(0);
+ typeSelected = possibleLogTypes.get(0);
}
setType(typeSelected);
}
final Button typeButton = (Button) findViewById(R.id.type);
registerForContextMenu(typeButton);
- typeButton.setText(cgBase.logTypes2.get(typeSelected));
+ typeButton.setText(typeSelected.getL10n());
typeButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
@@ -533,24 +534,19 @@ public class VisitCacheActivity extends cgLogForm {
dateButton.setText(cgBase.formatShortDate(date.getTime().getTime()));
}
- public void setType(int type) {
+ public void setType(LogType type) {
final Button typeButton = (Button) findViewById(R.id.type);
- if (cgBase.logTypes2.get(type) != null) {
- typeSelected = type;
- }
- if (cgBase.logTypes2.get(typeSelected) == null) {
- typeSelected = 1;
- }
- typeButton.setText(cgBase.logTypes2.get(typeSelected));
+ typeSelected = type;
+ typeButton.setText(typeSelected.getL10n());
- if (type == 2 && !tbChanged) {
+ if (LogType.LOG_FOUND_IT == type && !tbChanged) {
// TODO: change action
- } else if (type != 2 && !tbChanged) {
+ } else if (LogType.LOG_FOUND_IT != type && !tbChanged) {
// TODO: change action
}
- if (type == cgBase.LOG_FOUND_IT && Settings.isUseTwitter()) {
+ if (type == LogType.LOG_FOUND_IT && Settings.isUseTwitter()) {
tweetBox.setVisibility(View.VISIBLE);
} else {
tweetBox.setVisibility(View.GONE);
@@ -589,9 +585,9 @@ public class VisitCacheActivity extends cgLogForm {
app.clearLogOffline(geocode);
if (alreadyFound) {
- typeSelected = cgBase.LOG_NOTE;
+ typeSelected = LogType.LOG_NOTE;
} else {
- typeSelected = types.get(0);
+ typeSelected = possibleLogTypes.get(0);
}
date.setTime(new Date());
text = null;
@@ -651,11 +647,11 @@ public class VisitCacheActivity extends cgLogForm {
viewstates = cgBase.getViewstates(page);
trackables = cgBase.parseTrackableLog(page);
- final List<Integer> typesPre = cgBase.parseTypes(page);
+ final List<LogType> typesPre = cgBase.parseTypes(page);
if (CollectionUtils.isNotEmpty(typesPre)) {
- types.clear();
- types.addAll(typesPre);
- types.remove(Integer.valueOf(cgBase.LOG_UPDATE_COORDINATES));
+ possibleLogTypes.clear();
+ possibleLogTypes.addAll(typesPre);
+ possibleLogTypes.remove(LogType.LOG_UPDATE_COORDINATES);
}
} catch (Exception e) {
Log.e(Settings.tag, "cgeovisit.loadData.run: " + e.toString());
@@ -701,7 +697,7 @@ public class VisitCacheActivity extends cgLogForm {
}
app.addLog(geocode, logNow);
- if (typeSelected == cgBase.LOG_FOUND_IT) {
+ if (typeSelected == LogType.LOG_FOUND_IT) {
app.markFound(geocode);
if (cache != null) {
cache.setFound(true);
@@ -719,13 +715,13 @@ public class VisitCacheActivity extends cgLogForm {
app.clearLogOffline(geocode);
}
- if (status == StatusCode.NO_ERROR && typeSelected == cgBase.LOG_FOUND_IT && Settings.isUseTwitter()
+ if (status == StatusCode.NO_ERROR && typeSelected == LogType.LOG_FOUND_IT && Settings.isUseTwitter()
&& Settings.isTwitterLoginValid()
&& tweetCheck.isChecked() && tweetBox.getVisibility() == View.VISIBLE) {
cgBase.postTweetCache(app, geocode);
}
- if (status == StatusCode.NO_ERROR && typeSelected == cgBase.LOG_FOUND_IT && Settings.isGCvoteLogin()) {
+ if (status == StatusCode.NO_ERROR && typeSelected == LogType.LOG_FOUND_IT && Settings.isGCvoteLogin()) {
GCVote.setRating(cache, rating);
}
diff --git a/main/src/cgeo/geocaching/activity/ActivityMixin.java b/main/src/cgeo/geocaching/activity/ActivityMixin.java
index 6286a6b..a3afc11 100644
--- a/main/src/cgeo/geocaching/activity/ActivityMixin.java
+++ b/main/src/cgeo/geocaching/activity/ActivityMixin.java
@@ -2,9 +2,9 @@ package cgeo.geocaching.activity;
import cgeo.geocaching.R;
import cgeo.geocaching.Settings;
-import cgeo.geocaching.cgBase;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgeo;
+import cgeo.geocaching.enumerations.LogType;
import org.apache.commons.lang3.StringUtils;
@@ -136,10 +136,9 @@ public final class ActivityMixin {
Resources res = ((Activity) activity).getResources();
if (Settings.getLogOffline()) {
SubMenu logMenu = menu.addSubMenu(1, IAbstractActivity.MENU_LOG_VISIT_OFFLINE, 0, res.getString(R.string.cache_menu_visit_offline)).setIcon(MENU_ICON_LOG_VISIT);
- List<Integer> logTypes = cache.getPossibleLogTypes();
- for (Integer logType : logTypes) {
- String label = cgBase.logTypes2.get(logType);
- logMenu.add(1, IAbstractActivity.MENU_LOG_VISIT_OFFLINE + logType.intValue(), 0, label);
+ List<LogType> logTypes = cache.getPossibleLogTypes();
+ for (LogType logType : logTypes) {
+ logMenu.add(1, IAbstractActivity.MENU_LOG_VISIT_OFFLINE + logType.id, 0, logType.getL10n());
}
logMenu.add(1, IAbstractActivity.MENU_LOG_VISIT, 0, res.getString(R.string.cache_menu_visit));
}
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java
index bf85bce..0d7d071 100644
--- a/main/src/cgeo/geocaching/cgBase.java
+++ b/main/src/cgeo/geocaching/cgBase.java
@@ -6,6 +6,7 @@ import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.GCConnector;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.LogTypeTrackable;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.enumerations.WaypointType;
@@ -100,10 +101,6 @@ public class cgBase {
private static final String passMatch = "(?<=[\\?&])[Pp]ass(w(or)?d)?=[^&#$]+";
public final static Map<WaypointType, String> waypointTypes = new HashMap<WaypointType, String>();
- public final static Map<String, Integer> logTypes = new HashMap<String, Integer>();
- public final static Map<String, Integer> logTypes0 = new HashMap<String, Integer>();
- public final static Map<Integer, String> logTypes1 = new HashMap<Integer, String>();
- public final static Map<Integer, String> logTypes2 = new HashMap<Integer, String>();
public final static Map<String, SimpleDateFormat> gcCustomDateFormats;
static {
final String[] formats = new String[] {
@@ -140,78 +137,10 @@ public class cgBase {
final private static Map<String, Integer> gcIcons = new HashMap<String, Integer>();
- public static final int LOG_FOUND_IT = 2;
- public static final int LOG_DIDNT_FIND_IT = 3;
- public static final int LOG_NOTE = 4;
- public static final int LOG_PUBLISH_LISTING = 1003; // unknown ID; used number doesn't match any GC.com's ID
- public static final int LOG_ENABLE_LISTING = 23;
- public static final int LOG_ARCHIVE = 5;
- public static final int LOG_TEMP_DISABLE_LISTING = 22;
- public static final int LOG_NEEDS_ARCHIVE = 7;
- public static final int LOG_WILL_ATTEND = 9;
- public static final int LOG_ATTENDED = 10;
- public static final int LOG_RETRIEVED_IT = 13;
- public static final int LOG_PLACED_IT = 14;
- public static final int LOG_GRABBED_IT = 19;
- public static final int LOG_NEEDS_MAINTENANCE = 45;
- public static final int LOG_OWNER_MAINTENANCE = 46;
- public static final int LOG_UPDATE_COORDINATES = 47;
- public static final int LOG_DISCOVERED_IT = 48;
- public static final int LOG_POST_REVIEWER_NOTE = 18;
- public static final int LOG_VISIT = 1001; // unknown ID; used number doesn't match any GC.com's ID
- public static final int LOG_WEBCAM_PHOTO_TAKEN = 11;
- public static final int LOG_ANNOUNCEMENT = 74;
-
private static final int NB_DOWNLOAD_RETRIES = 4;
public static final int UPDATE_LOAD_PROGRESS_DETAIL = 42186;
- static {
- logTypes.put("icon_smile", LOG_FOUND_IT);
- logTypes.put("icon_sad", LOG_DIDNT_FIND_IT);
- logTypes.put("icon_note", LOG_NOTE);
- logTypes.put("icon_greenlight", LOG_PUBLISH_LISTING);
- logTypes.put("icon_enabled", LOG_ENABLE_LISTING);
- logTypes.put("traffic_cone", LOG_ARCHIVE);
- logTypes.put("icon_disabled", LOG_TEMP_DISABLE_LISTING);
- logTypes.put("icon_remove", LOG_NEEDS_ARCHIVE);
- logTypes.put("icon_rsvp", LOG_WILL_ATTEND);
- logTypes.put("icon_attended", LOG_ATTENDED);
- logTypes.put("picked_up", LOG_RETRIEVED_IT);
- logTypes.put("dropped_off", LOG_PLACED_IT);
- logTypes.put("transfer", LOG_GRABBED_IT);
- logTypes.put("icon_needsmaint", LOG_NEEDS_MAINTENANCE);
- logTypes.put("icon_maint", LOG_OWNER_MAINTENANCE);
- logTypes.put("coord_update", LOG_UPDATE_COORDINATES);
- logTypes.put("icon_discovered", LOG_DISCOVERED_IT);
- logTypes.put("big_smile", LOG_POST_REVIEWER_NOTE);
- logTypes.put("icon_visited", LOG_VISIT); // unknown ID; used number doesn't match any GC.com's ID
- logTypes.put("icon_camera", LOG_WEBCAM_PHOTO_TAKEN); // unknown ID; used number doesn't match any GC.com's ID
- logTypes.put("icon_announcement", LOG_ANNOUNCEMENT); // unknown ID; used number doesn't match any GC.com's ID
-
- logTypes0.put("found it", LOG_FOUND_IT);
- logTypes0.put("didn't find it", LOG_DIDNT_FIND_IT);
- logTypes0.put("write note", LOG_NOTE);
- logTypes0.put("publish listing", LOG_PUBLISH_LISTING);
- logTypes0.put("enable listing", LOG_ENABLE_LISTING);
- logTypes0.put("archive", LOG_ARCHIVE);
- logTypes0.put("temporarily disable listing", LOG_TEMP_DISABLE_LISTING);
- logTypes0.put("needs archived", LOG_NEEDS_ARCHIVE);
- logTypes0.put("will attend", LOG_WILL_ATTEND);
- logTypes0.put("attended", LOG_ATTENDED);
- logTypes0.put("retrieved it", LOG_RETRIEVED_IT);
- logTypes0.put("placed it", LOG_PLACED_IT);
- logTypes0.put("grabbed it", LOG_GRABBED_IT);
- logTypes0.put("needs maintenance", LOG_NEEDS_MAINTENANCE);
- logTypes0.put("owner maintenance", LOG_OWNER_MAINTENANCE);
- logTypes0.put("update coordinates", LOG_UPDATE_COORDINATES);
- logTypes0.put("discovered it", LOG_DISCOVERED_IT);
- logTypes0.put("post reviewer note", LOG_POST_REVIEWER_NOTE);
- logTypes0.put("visit", LOG_VISIT); // unknown ID; used number doesn't match any GC.com's ID
- logTypes0.put("webcam photo taken", LOG_WEBCAM_PHOTO_TAKEN); // unknown ID; used number doesn't match any GC.com's ID
- logTypes0.put("announcement", LOG_ANNOUNCEMENT); // unknown ID; used number doesn't match any GC.com's ID
- }
-
private cgBase() {
//initialize(app);
throw new UnsupportedOperationException(); // static class, not to be instantiated
@@ -228,49 +157,6 @@ public class cgBase {
}
}
- // log types
-
- logTypes1.put(LOG_FOUND_IT, res.getString(R.string.log_found));
- logTypes1.put(LOG_DIDNT_FIND_IT, res.getString(R.string.log_dnf));
- logTypes1.put(LOG_NOTE, res.getString(R.string.log_note));
- logTypes1.put(LOG_PUBLISH_LISTING, res.getString(R.string.log_published));
- logTypes1.put(LOG_ENABLE_LISTING, res.getString(R.string.log_enabled));
- logTypes1.put(LOG_ARCHIVE, res.getString(R.string.log_archived));
- logTypes1.put(LOG_TEMP_DISABLE_LISTING, res.getString(R.string.log_disabled));
- logTypes1.put(LOG_NEEDS_ARCHIVE, res.getString(R.string.log_needs_archived));
- logTypes1.put(LOG_WILL_ATTEND, res.getString(R.string.log_attend));
- logTypes1.put(LOG_ATTENDED, res.getString(R.string.log_attended));
- logTypes1.put(LOG_RETRIEVED_IT, res.getString(R.string.log_retrieved));
- logTypes1.put(LOG_PLACED_IT, res.getString(R.string.log_placed));
- logTypes1.put(LOG_GRABBED_IT, res.getString(R.string.log_grabbed));
- logTypes1.put(LOG_NEEDS_MAINTENANCE, res.getString(R.string.log_maintenance_needed));
- logTypes1.put(LOG_OWNER_MAINTENANCE, res.getString(R.string.log_maintained));
- logTypes1.put(LOG_UPDATE_COORDINATES, res.getString(R.string.log_update));
- logTypes1.put(LOG_DISCOVERED_IT, res.getString(R.string.log_discovered));
- logTypes1.put(LOG_POST_REVIEWER_NOTE, res.getString(R.string.log_reviewed));
- logTypes1.put(LOG_VISIT, res.getString(R.string.log_taken));
- logTypes1.put(LOG_WEBCAM_PHOTO_TAKEN, res.getString(R.string.log_webcam));
- logTypes1.put(LOG_ANNOUNCEMENT, res.getString(R.string.log_announcement));
-
- logTypes2.put(LOG_FOUND_IT, res.getString(R.string.log_found)); // traditional, multi, mystery, earth, wherigo, virtual, letterbox
- logTypes2.put(LOG_DIDNT_FIND_IT, res.getString(R.string.log_dnf)); // traditional, multi, mystery, earth, wherigo, virtual, letterbox, webcam
- logTypes2.put(LOG_NOTE, res.getString(R.string.log_note)); // traditional, multi, mystery, earth, wherigo, virtual, event, letterbox, webcam, trackable
- logTypes2.put(LOG_PUBLISH_LISTING, res.getString(R.string.log_published)); // X
- logTypes2.put(LOG_ENABLE_LISTING, res.getString(R.string.log_enabled)); // owner
- logTypes2.put(LOG_ARCHIVE, res.getString(R.string.log_archived)); // traditional, multi, mystery, earth, event, wherigo, virtual, letterbox, webcam
- logTypes2.put(LOG_TEMP_DISABLE_LISTING, res.getString(R.string.log_disabled)); // owner
- logTypes2.put(LOG_NEEDS_ARCHIVE, res.getString(R.string.log_needs_archived)); // traditional, multi, mystery, earth, event, wherigo, virtual, letterbox, webcam
- logTypes2.put(LOG_WILL_ATTEND, res.getString(R.string.log_attend)); // event
- logTypes2.put(LOG_ATTENDED, res.getString(R.string.log_attended)); // event
- logTypes2.put(LOG_WEBCAM_PHOTO_TAKEN, res.getString(R.string.log_webcam)); // webcam
- logTypes2.put(LOG_RETRIEVED_IT, res.getString(R.string.log_retrieved)); //trackable
- logTypes2.put(LOG_GRABBED_IT, res.getString(R.string.log_grabbed)); //trackable
- logTypes2.put(LOG_NEEDS_MAINTENANCE, res.getString(R.string.log_maintenance_needed)); // traditional, mystery, multi, wherigo, virtual, letterbox, webcam
- logTypes2.put(LOG_OWNER_MAINTENANCE, res.getString(R.string.log_maintained)); // owner
- logTypes2.put(LOG_DISCOVERED_IT, res.getString(R.string.log_discovered)); //trackable
- logTypes2.put(LOG_POST_REVIEWER_NOTE, res.getString(R.string.log_reviewed)); // X
- logTypes2.put(LOG_ANNOUNCEMENT, res.getString(R.string.log_announcement)); // X
-
try {
final PackageManager manager = app.getPackageManager();
final PackageInfo info = manager.getPackageInfo(app.getPackageName(), 0);
@@ -1163,10 +1049,9 @@ public class cgBase {
String countStr = matcherLog.group(2).replaceAll("[.,]", "");
if (StringUtils.isNotBlank(typeStr)
- && logTypes.containsKey(typeStr.toLowerCase())
- && StringUtils.isNotBlank(countStr))
- {
- cache.getLogCounts().put(logTypes.get(typeStr.toLowerCase()), Integer.parseInt(countStr));
+ && LogType.LOG_UNKNOWN != LogType.getByIconName(typeStr)
+ && StringUtils.isNotBlank(countStr)) {
+ cache.getLogCounts().put(LogType.getByIconName(typeStr), Integer.parseInt(countStr));
}
}
}
@@ -1378,11 +1263,7 @@ public class cgBase {
// FIXME: use the "LogType" field instead of the "LogTypeImage" one.
final String logIconNameExt = entry.optString("LogTypeImage", ".gif");
final String logIconName = logIconNameExt.substring(0, logIconNameExt.length() - 4);
- if (logTypes.containsKey(logIconName)) {
- logDone.type = logTypes.get(logIconName);
- } else {
- logDone.type = logTypes.get("icon_note");
- }
+ logDone.type = LogType.getByIconName(logIconName);
try {
logDone.date = parseGcCustomDate(entry.getString("Visited")).getTime();
@@ -1663,15 +1544,7 @@ public class cgBase {
{
final cgLog logDone = new cgLog();
- if (logTypes.containsKey(matcherLogs.group(1).toLowerCase()))
- {
- logDone.type = logTypes.get(matcherLogs.group(1).toLowerCase().trim());
- }
- else
- {
- logDone.type = logTypes.get("icon_note");
- }
-
+ logDone.type = LogType.getByIconName(matcherLogs.group(1));
logDone.author = Html.fromHtml(matcherLogs.group(3)).toString().trim();
try
@@ -1702,12 +1575,12 @@ public class cgBase {
return trackable;
}
- public static List<Integer> parseTypes(String page) {
+ public static List<LogType> parseTypes(String page) {
if (StringUtils.isEmpty(page)) {
return null;
}
- final List<Integer> types = new ArrayList<Integer>();
+ final List<LogType> types = new ArrayList<LogType>();
final Matcher typeBoxMatcher = GCConstants.PATTERN_TYPEBOX.matcher(page);
String typesText = null;
@@ -1725,7 +1598,7 @@ public class cgBase {
final int type = Integer.parseInt(typeMatcher.group(2));
if (type > 0) {
- types.add(type);
+ types.add(LogType.getById(type));
}
}
}
@@ -2123,18 +1996,13 @@ public class cgBase {
}
public static StatusCode postLog(final cgeoapplication app, final String geocode, final String cacheid, final String[] viewstates,
- final int logType, final int year, final int month, final int day,
+ final LogType logType, final int year, final int month, final int day,
final String log, final List<cgTrackableLog> trackables) {
if (isEmpty(viewstates)) {
Log.e(Settings.tag, "cgeoBase.postLog: No viewstate given");
return StatusCode.LOG_POST_ERROR;
}
- if (!logTypes2.containsKey(logType)) {
- Log.e(Settings.tag, "cgeoBase.postLog: Unknown logtype");
- return StatusCode.LOG_POST_ERROR;
- }
-
if (StringUtils.isBlank(log)) {
Log.e(Settings.tag, "cgeoBase.postLog: No log text given");
return StatusCode.NO_LOG_TEXT;
@@ -2168,7 +2036,7 @@ public class cgBase {
"__EVENTTARGET", "",
"__EVENTARGUMENT", "",
"__LASTFOCUS", "",
- "ctl00$ContentBody$LogBookPanel1$ddLogType", Integer.toString(logType),
+ "ctl00$ContentBody$LogBookPanel1$ddLogType", Integer.toString(logType.id),
"ctl00$ContentBody$LogBookPanel1$DateTimeLogged", String.format("%02d", month) + "/" + String.format("%02d", day) + "/" + String.format("%04d", year),
"ctl00$ContentBody$LogBookPanel1$DateTimeLogged$Month", Integer.toString(month),
"ctl00$ContentBody$LogBookPanel1$DateTimeLogged$Day", Integer.toString(day),
@@ -2281,17 +2149,12 @@ public class cgBase {
}
public static StatusCode postLogTrackable(final String tbid, final String trackingCode, final String[] viewstates,
- final int logType, final int year, final int month, final int day, final String log) {
+ final LogType logType, final int year, final int month, final int day, final String log) {
if (isEmpty(viewstates)) {
Log.e(Settings.tag, "cgeoBase.postLogTrackable: No viewstate given");
return StatusCode.LOG_POST_ERROR;
}
- if (!logTypes2.containsKey(logType)) {
- Log.e(Settings.tag, "cgeoBase.postLogTrackable: Unknown logtype");
- return StatusCode.LOG_POST_ERROR;
- }
-
if (StringUtils.isBlank(log)) {
Log.e(Settings.tag, "cgeoBase.postLogTrackable: No log text given");
return StatusCode.NO_LOG_TEXT;
@@ -2306,7 +2169,7 @@ public class cgBase {
"__EVENTTARGET", "",
"__EVENTARGUMENT", "",
"__LASTFOCUS", "",
- "ctl00$ContentBody$LogBookPanel1$ddLogType", Integer.toString(logType),
+ "ctl00$ContentBody$LogBookPanel1$ddLogType", Integer.toString(logType.id),
"ctl00$ContentBody$LogBookPanel1$tbCode", trackingCode);
putViewstates(params, viewstates);
if (currentDate.get(Calendar.YEAR) == year && (currentDate.get(Calendar.MONTH) + 1) == month && currentDate.get(Calendar.DATE) == day) {
@@ -2809,8 +2672,8 @@ public class cgBase {
}
// store images from logs
- if (Settings.isStoreLogImages() && cache.getLogs() != null) {
- for (cgLog log : cache.getLogs()) {
+ if (Settings.isStoreLogImages() && cache.getLogs(true) != null) {
+ for (cgLog log : cache.getLogs(true)) {
if (CollectionUtils.isNotEmpty(log.logImages)) {
for (cgImage oneLogImg : log.logImages) {
imgGetter.getDrawable(oneLogImg.getUrl());
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index 0249586..babd243 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -6,6 +6,7 @@ import cgeo.geocaching.connector.GCConnector;
import cgeo.geocaching.connector.IConnector;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.GeopointFormatter;
import cgeo.geocaching.utils.CryptUtils;
@@ -90,7 +91,7 @@ public class cgCache implements ICache {
private ArrayList<cgImage> spoilers = null;
private List<cgLog> logs = null;
private List<cgTrackable> inventory = null;
- private Map<Integer, Integer> logCounts = new HashMap<Integer, Integer>();
+ private Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>();
private boolean logOffline = false;
// temporary values
private boolean statusChecked = false;
@@ -297,7 +298,7 @@ public class cgCache implements ICache {
return true;
}
- public boolean logOffline(final IAbstractActivity fromActivity, final int logType) {
+ public boolean logOffline(final IAbstractActivity fromActivity, final LogType logType) {
String log = "";
if (StringUtils.isNotBlank(Settings.getSignature())
&& Settings.isAutoInsertSignature()) {
@@ -307,8 +308,8 @@ public class cgCache implements ICache {
return true;
}
- void logOffline(final IAbstractActivity fromActivity, final String log, Calendar date, final int logType) {
- if (logType <= 0) {
+ void logOffline(final IAbstractActivity fromActivity, final String log, Calendar date, final LogType logType) {
+ if (logType == LogType.LOG_UNKNOWN) {
return;
}
cgeoapplication app = (cgeoapplication) ((Activity) fromActivity).getApplication();
@@ -323,38 +324,38 @@ public class cgCache implements ICache {
}
}
- public List<Integer> getPossibleLogTypes() {
+ public List<LogType> getPossibleLogTypes() {
boolean isOwner = owner != null && owner.equalsIgnoreCase(Settings.getUsername());
- List<Integer> types = new ArrayList<Integer>();
+ List<LogType> logTypes = new ArrayList<LogType>();
if (isEventCache()) {
- types.add(cgBase.LOG_WILL_ATTEND);
- types.add(cgBase.LOG_NOTE);
- types.add(cgBase.LOG_ATTENDED);
- types.add(cgBase.LOG_NEEDS_ARCHIVE);
+ logTypes.add(LogType.LOG_WILL_ATTEND);
+ logTypes.add(LogType.LOG_NOTE);
+ logTypes.add(LogType.LOG_ATTENDED);
+ logTypes.add(LogType.LOG_NEEDS_ARCHIVE);
if (isOwner) {
- types.add(cgBase.LOG_ANNOUNCEMENT);
+ logTypes.add(LogType.LOG_ANNOUNCEMENT);
}
} else if (CacheType.WEBCAM == cacheType) {
- types.add(cgBase.LOG_WEBCAM_PHOTO_TAKEN);
- types.add(cgBase.LOG_DIDNT_FIND_IT);
- types.add(cgBase.LOG_NOTE);
- types.add(cgBase.LOG_NEEDS_ARCHIVE);
- types.add(cgBase.LOG_NEEDS_MAINTENANCE);
+ logTypes.add(LogType.LOG_WEBCAM_PHOTO_TAKEN);
+ logTypes.add(LogType.LOG_DIDNT_FIND_IT);
+ logTypes.add(LogType.LOG_NOTE);
+ logTypes.add(LogType.LOG_NEEDS_ARCHIVE);
+ logTypes.add(LogType.LOG_NEEDS_MAINTENANCE);
} else {
- types.add(cgBase.LOG_FOUND_IT);
- types.add(cgBase.LOG_DIDNT_FIND_IT);
- types.add(cgBase.LOG_NOTE);
- types.add(cgBase.LOG_NEEDS_ARCHIVE);
- types.add(cgBase.LOG_NEEDS_MAINTENANCE);
+ logTypes.add(LogType.LOG_FOUND_IT);
+ logTypes.add(LogType.LOG_DIDNT_FIND_IT);
+ logTypes.add(LogType.LOG_NOTE);
+ logTypes.add(LogType.LOG_NEEDS_ARCHIVE);
+ logTypes.add(LogType.LOG_NEEDS_MAINTENANCE);
}
if (isOwner) {
- types.add(cgBase.LOG_OWNER_MAINTENANCE);
- types.add(cgBase.LOG_TEMP_DISABLE_LISTING);
- types.add(cgBase.LOG_ENABLE_LISTING);
- types.add(cgBase.LOG_ARCHIVE);
- types.remove(Integer.valueOf(cgBase.LOG_UPDATE_COORDINATES));
+ logTypes.add(LogType.LOG_OWNER_MAINTENANCE);
+ logTypes.add(LogType.LOG_TEMP_DISABLE_LISTING);
+ logTypes.add(LogType.LOG_ENABLE_LISTING);
+ logTypes.add(LogType.LOG_ARCHIVE);
+ logTypes.remove(LogType.LOG_UPDATE_COORDINATES);
}
- return types;
+ return logTypes;
}
public void openInBrowser(Activity fromActivity) {
@@ -567,7 +568,7 @@ public class cgCache implements ICache {
}
@Override
- public Map<Integer, Integer> getLogCounts() {
+ public Map<LogType, Integer> getLogCounts() {
return logCounts;
}
@@ -919,7 +920,7 @@ public class cgCache implements ICache {
this.inventory = inventory;
}
- public void setLogCounts(Map<Integer, Integer> logCounts) {
+ public void setLogCounts(Map<LogType, Integer> logCounts) {
this.logCounts = logCounts;
}
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index 3d377e1..677b329 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -2,6 +2,7 @@ package cgeo.geocaching;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.files.LocalStorage;
import cgeo.geocaching.geopoint.Geopoint;
@@ -1629,7 +1630,7 @@ public class cgData {
helper.bind(LOGS_GEOCODE, geocode);
helper.bind(LOGS_UPDATED, timeStamp);
- helper.bind(LOGS_TYPE, log.type);
+ helper.bind(LOGS_TYPE, log.type.id);
helper.bind(LOGS_AUTHOR, log.author);
helper.bind(LOGS_LOG, log.log);
helper.bind(LOGS_DATE, log.date);
@@ -1659,11 +1660,11 @@ public class cgData {
return true;
}
- public boolean saveLogCount(String geocode, Map<Integer, Integer> logCounts) {
+ public boolean saveLogCount(String geocode, Map<LogType, Integer> logCounts) {
return saveLogCount(geocode, logCounts, true);
}
- public boolean saveLogCount(String geocode, Map<Integer, Integer> logCounts, boolean drop) {
+ public boolean saveLogCount(String geocode, Map<LogType, Integer> logCounts, boolean drop) {
init();
if (StringUtils.isBlank(geocode) || MapUtils.isEmpty(logCounts)) {
@@ -1678,13 +1679,13 @@ public class cgData {
ContentValues values = new ContentValues();
- Set<Entry<Integer, Integer>> logCountsItems = logCounts.entrySet();
+ Set<Entry<LogType, Integer>> logCountsItems = logCounts.entrySet();
long timeStamp = System.currentTimeMillis();
- for (Entry<Integer, Integer> pair : logCountsItems) {
+ for (Entry<LogType, Integer> pair : logCountsItems) {
values.clear();
values.put("geocode", geocode);
values.put("updated", timeStamp);
- values.put("type", pair.getKey());
+ values.put("type", pair.getKey().id);
values.put("count", pair.getValue());
databaseRW.insert(dbTableLogCount, null, values);
@@ -1975,7 +1976,7 @@ public class cgData {
}
cache.getLogs().addAll(logs);
}
- final Map<Integer, Integer> logCounts = loadLogCounts(cache.getGeocode());
+ final Map<LogType, Integer> logCounts = loadLogCounts(cache.getGeocode());
if (MapUtils.isNotEmpty(logCounts)) {
cache.getLogCounts().clear();
cache.getLogCounts().putAll(logCounts);
@@ -2386,7 +2387,7 @@ public class cgData {
if (log == null || log.id != cursor.getInt(indexLogsId)) {
log = new cgLog();
log.id = cursor.getInt(indexLogsId);
- log.type = cursor.getInt(indexType);
+ log.type = LogType.getById(cursor.getInt(indexType));
log.author = cursor.getString(indexAuthor);
log.log = cursor.getString(indexLog);
log.date = cursor.getLong(indexDate);
@@ -2413,14 +2414,14 @@ public class cgData {
return logs;
}
- public Map<Integer, Integer> loadLogCounts(String geocode) {
+ public Map<LogType, Integer> loadLogCounts(String geocode) {
if (StringUtils.isBlank(geocode)) {
return null;
}
init();
- Map<Integer, Integer> logCounts = new HashMap<Integer, Integer>();
+ Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>();
Cursor cursor = databaseRO.query(
dbTableLogCount,
@@ -2438,7 +2439,7 @@ public class cgData {
int indexCount = cursor.getColumnIndex("count");
do {
- Integer type = cursor.getInt(indexType);
+ LogType type = LogType.getById(cursor.getInt(indexType));
Integer count = cursor.getInt(indexCount);
logCounts.put(type, count);
@@ -3013,11 +3014,11 @@ public class cgData {
}
}
- public boolean saveLogOffline(String geocode, Date date, int type, String log) {
+ public boolean saveLogOffline(String geocode, Date date, LogType type, String log) {
if (StringUtils.isBlank(geocode)) {
return false;
}
- if (type <= 0 && StringUtils.isBlank(log)) {
+ if (LogType.LOG_UNKNOWN == type && StringUtils.isBlank(log)) {
return false;
}
@@ -3026,7 +3027,7 @@ public class cgData {
ContentValues values = new ContentValues();
values.put("geocode", geocode);
values.put("updated", System.currentTimeMillis());
- values.put("type", type);
+ values.put("type", type.id);
values.put("log", log);
values.put("date", date.getTime());
@@ -3075,7 +3076,7 @@ public class cgData {
log = new cgLog();
log.id = cursor.getInt(cursor.getColumnIndex("_id"));
- log.type = cursor.getInt(cursor.getColumnIndex("type"));
+ log.type = LogType.getById(cursor.getInt(cursor.getColumnIndex("type")));
log.log = cursor.getString(cursor.getColumnIndex("log"));
log.date = cursor.getLong(cursor.getColumnIndex("date"));
}
diff --git a/main/src/cgeo/geocaching/cgLog.java b/main/src/cgeo/geocaching/cgLog.java
index e8ee43b..6bf807a 100644
--- a/main/src/cgeo/geocaching/cgLog.java
+++ b/main/src/cgeo/geocaching/cgLog.java
@@ -1,10 +1,12 @@
package cgeo.geocaching;
+import cgeo.geocaching.enumerations.LogType;
+
import java.util.List;
public class cgLog {
public int id = 0;
- public int type = cgBase.LOG_NOTE; // note
+ public LogType type = LogType.LOG_NOTE; // note
public String author = "";
public String log = "";
public long date = 0;
@@ -17,7 +19,7 @@ public class cgLog {
@Override
public int hashCode() {
- return (int) date * type * author.hashCode() * log.hashCode();
+ return (int) date * type.hashCode() * author.hashCode() * log.hashCode();
}
@Override
diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java
index 207a8cf..42eb667 100644
--- a/main/src/cgeo/geocaching/cgeo.java
+++ b/main/src/cgeo/geocaching/cgeo.java
@@ -4,6 +4,7 @@ import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.CGeoMap;
@@ -451,6 +452,9 @@ public class cgeo extends AbstractActivity {
for (CacheType cacheType : CacheType.values()) {
cacheType.setL10n();
}
+ for (LogType logType : LogType.values()) {
+ logType.setL10n();
+ }
Settings.getLogin();
diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java
index 529695c..e9cbb54 100644
--- a/main/src/cgeo/geocaching/cgeoapplication.java
+++ b/main/src/cgeo/geocaching/cgeoapplication.java
@@ -2,6 +2,7 @@ package cgeo.geocaching;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.geopoint.Geopoint;
@@ -593,7 +594,7 @@ public class cgeoapplication extends Application {
return storage.loadInventory(geocode);
}
- public Map<Integer, Integer> loadLogCounts(String geocode) {
+ public Map<LogType, Integer> loadLogCounts(String geocode) {
return storage.loadLogCounts(geocode);
}
@@ -646,7 +647,7 @@ public class cgeoapplication extends Application {
return lastCoords;
}
- public boolean saveLogOffline(String geocode, Date date, int logtype, String log) {
+ public boolean saveLogOffline(String geocode, Date date, LogType logtype, String log) {
return storage.saveLogOffline(geocode, date, logtype, log);
}
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index e0abcfb..391a30a 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -8,6 +8,7 @@ import cgeo.geocaching.apps.cachelist.CacheListAppFactory;
import cgeo.geocaching.enumerations.CacheListType;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.files.GPXImporter;
import cgeo.geocaching.filter.FilterBySize;
@@ -1268,7 +1269,7 @@ public class cgeocaches extends AbstractListActivity {
}
int logType = id - MENU_LOG_VISIT_OFFLINE;
- cache.logOffline(this, logType);
+ cache.logOffline(this, LogType.getById(logType));
}
return true;
}
@@ -2192,18 +2193,18 @@ public class cgeocaches extends AbstractListActivity {
SimpleDateFormat fieldNoteDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
StringBuffer fieldNoteBuffer = new StringBuffer(500);
- // We need our own HashMap because cgBase.LogTypes1 will give us localized and maybe
+ // We need our own HashMap because LogType will give us localized and maybe
// different strings than gc.com expects in the field note
// We only need such logtypes that are possible to log via c:geo
- Map<Integer, String> logTypes = new HashMap<Integer, String>();
- logTypes.put(cgBase.LOG_FOUND_IT, "Found it");
- logTypes.put(cgBase.LOG_DIDNT_FIND_IT, "Didn't find it");
- logTypes.put(cgBase.LOG_NOTE, "Write Note");
- logTypes.put(cgBase.LOG_NEEDS_ARCHIVE, "Needs archived");
- logTypes.put(cgBase.LOG_NEEDS_MAINTENANCE, "Needs Maintenance");
- logTypes.put(cgBase.LOG_WILL_ATTEND, "Will Attend");
- logTypes.put(cgBase.LOG_ATTENDED, "Attended");
- logTypes.put(cgBase.LOG_WEBCAM_PHOTO_TAKEN, "Webcam Photo Taken");
+ Map<LogType, String> logTypes = new HashMap<LogType, String>();
+ logTypes.put(LogType.LOG_FOUND_IT, "Found it");
+ logTypes.put(LogType.LOG_DIDNT_FIND_IT, "Didn't find it");
+ logTypes.put(LogType.LOG_NOTE, "Write Note");
+ logTypes.put(LogType.LOG_NEEDS_ARCHIVE, "Needs archived");
+ logTypes.put(LogType.LOG_NEEDS_MAINTENANCE, "Needs Maintenance");
+ logTypes.put(LogType.LOG_WILL_ATTEND, "Will Attend");
+ logTypes.put(LogType.LOG_ATTENDED, "Attended");
+ logTypes.put(LogType.LOG_WEBCAM_PHOTO_TAKEN, "Webcam Photo Taken");
for (cgCache cache : cacheList) {
if (checked > 0 && !cache.isStatusChecked()) {
diff --git a/main/src/cgeo/geocaching/cgeopopup.java b/main/src/cgeo/geocaching/cgeopopup.java
index 34c6a22..f6b8df0 100644
--- a/main/src/cgeo/geocaching/cgeopopup.java
+++ b/main/src/cgeo/geocaching/cgeopopup.java
@@ -4,6 +4,7 @@ import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.gcvote.GCVote;
import cgeo.geocaching.gcvote.GCVoteRating;
import cgeo.geocaching.utils.CancellableHandler;
@@ -191,7 +192,7 @@ public class cgeopopup extends AbstractActivity {
}
int logType = menuItem - MENU_LOG_VISIT_OFFLINE;
- cache.logOffline(this, logType);
+ cache.logOffline(this, LogType.getById(logType));
return true;
}
diff --git a/main/src/cgeo/geocaching/cgeotouch.java b/main/src/cgeo/geocaching/cgeotouch.java
index 701c998..e23a049 100644
--- a/main/src/cgeo/geocaching/cgeotouch.java
+++ b/main/src/cgeo/geocaching/cgeotouch.java
@@ -1,5 +1,6 @@
package cgeo.geocaching;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.StatusCode;
import org.apache.commons.lang3.StringUtils;
@@ -28,14 +29,14 @@ import java.util.List;
public class cgeotouch extends cgLogForm {
private cgTrackable trackable = null;
- private List<Integer> types = new ArrayList<Integer>();
+ private List<LogType> logTypes = new ArrayList<LogType>();
private ProgressDialog waitDialog = null;
private String guid = null;
private String geocode = null;
private String[] viewstates = null;
private boolean gettingViewstate = true;
private Calendar date = Calendar.getInstance();
- private int typeSelected = -1;
+ private LogType typeSelected = LogType.LOG_UNKNOWN;
private int attempts = 0;
private CheckBox tweetCheck = null;
private LinearLayout tweetBox = null;
@@ -223,8 +224,8 @@ public class cgeotouch extends cgLogForm {
final int viewId = view.getId();
if (viewId == R.id.type) {
- for (final int typeOne : types) {
- menu.add(viewId, typeOne, 0, cgBase.logTypes2.get(typeOne));
+ for (final LogType typeOne : logTypes) {
+ menu.add(viewId, typeOne.id, 0, typeOne.getL10n());
}
}
}
@@ -235,7 +236,7 @@ public class cgeotouch extends cgLogForm {
final int id = item.getItemId();
if (group == R.id.type) {
- setType(id);
+ setType(LogType.getById(id));
return true;
}
@@ -248,20 +249,20 @@ public class cgeotouch extends cgLogForm {
app.setAction("logging trackable");
}
- types.clear();
- types.add(cgBase.LOG_RETRIEVED_IT);
- types.add(cgBase.LOG_GRABBED_IT);
- types.add(cgBase.LOG_NOTE);
- types.add(cgBase.LOG_DISCOVERED_IT);
+ logTypes.clear();
+ logTypes.add(LogType.LOG_RETRIEVED_IT);
+ logTypes.add(LogType.LOG_GRABBED_IT);
+ logTypes.add(LogType.LOG_NOTE);
+ logTypes.add(LogType.LOG_DISCOVERED_IT);
- if (typeSelected < 0 && cgBase.logTypes2.get(typeSelected) == null) {
- typeSelected = types.get(2);
+ if (LogType.LOG_UNKNOWN == typeSelected) {
+ typeSelected = LogType.LOG_FOUND_IT;
}
setType(typeSelected);
Button typeButton = (Button) findViewById(R.id.type);
registerForContextMenu(typeButton);
- typeButton.setText(cgBase.logTypes2.get(typeSelected));
+ typeButton.setText(typeSelected.getL10n());
typeButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
openContextMenu(view);
@@ -304,16 +305,11 @@ public class cgeotouch extends cgLogForm {
dateButton.setText(cgBase.formatShortDate(date.getTime().getTime()));
}
- public void setType(int type) {
+ public void setType(LogType type) {
final Button typeButton = (Button) findViewById(R.id.type);
- if (cgBase.logTypes2.get(type) != null) {
- typeSelected = type;
- }
- if (cgBase.logTypes2.get(typeSelected) == null) {
- typeSelected = 0;
- }
- typeButton.setText(cgBase.logTypes2.get(typeSelected));
+ typeSelected = type;
+ typeButton.setText(typeSelected.getL10n());
if (tweetBox == null) {
tweetBox = (LinearLayout) findViewById(R.id.tweet_box);
@@ -383,15 +379,15 @@ public class cgeotouch extends cgLogForm {
viewstates = cgBase.getViewstates(page);
- final List<Integer> typesPre = cgBase.parseTypes(page);
+ final List<LogType> typesPre = cgBase.parseTypes(page);
if (typesPre.size() > 0) {
- types.clear();
- types.addAll(typesPre);
+ logTypes.clear();
+ logTypes.addAll(typesPre);
}
typesPre.clear();
- if (!types.contains(typeSelected)) {
- typeSelected = types.get(0);
+ if (!logTypes.contains(typeSelected)) {
+ typeSelected = logTypes.get(0);
setType(typeSelected);
showToast(res.getString(R.string.info_log_type_changed));
}
diff --git a/main/src/cgeo/geocaching/cgeotrackable.java b/main/src/cgeo/geocaching/cgeotrackable.java
index 93cf091..d6f5b83 100644
--- a/main/src/cgeo/geocaching/cgeotrackable.java
+++ b/main/src/cgeo/geocaching/cgeotrackable.java
@@ -446,11 +446,7 @@ public class cgeotrackable extends AbstractActivity {
((TextView) rowView.findViewById(R.id.added)).setText(cgBase.formatShortDate(log.date));
}
- if (cgBase.logTypes1.containsKey(log.type)) {
- ((TextView) rowView.findViewById(R.id.type)).setText(cgBase.logTypes1.get(log.type));
- } else {
- ((TextView) rowView.findViewById(R.id.type)).setText(cgBase.logTypes1.get(4)); // note if type is unknown
- }
+ ((TextView) rowView.findViewById(R.id.type)).setText(log.type.getL10n());
((TextView) rowView.findViewById(R.id.author)).setText(Html.fromHtml(log.author), TextView.BufferType.SPANNABLE);
if (StringUtils.isBlank(log.cacheName)) {
diff --git a/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java b/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java
index eef05e3..43c2291 100644
--- a/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java
+++ b/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java
@@ -10,6 +10,7 @@ import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.IConnector;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.GeopointFormatter;
import cgeo.geocaching.geopoint.GeopointParser;
@@ -138,8 +139,8 @@ final public class OkapiClient {
final JSONObject owner = response.getJSONObject(CACHE_OWNER);
cache.setOwner(parseUser(owner));
- cache.getLogCounts().put(cgBase.LOG_FOUND_IT, response.getInt(CACHE_FOUNDS));
- cache.getLogCounts().put(cgBase.LOG_DIDNT_FIND_IT, response.getInt(CACHE_NOTFOUNDS));
+ cache.getLogCounts().put(LogType.LOG_FOUND_IT, response.getInt(CACHE_FOUNDS));
+ cache.getLogCounts().put(LogType.LOG_DIDNT_FIND_IT, response.getInt(CACHE_NOTFOUNDS));
cache.setSize(getCacheSize(response));
cache.setDifficulty((float) response.getDouble(CACHE_DIFFICULTY));
cache.setTerrain((float) response.getDouble(CACHE_TERRAIN));
@@ -219,14 +220,14 @@ final public class OkapiClient {
return result;
}
- private static int parseLogType(String logType) {
+ private static LogType parseLogType(String logType) {
if ("Found it".equalsIgnoreCase(logType)) {
- return cgBase.LOG_FOUND_IT;
+ return LogType.LOG_FOUND_IT;
}
else if ("Didn't find it".equalsIgnoreCase(logType)) {
- return cgBase.LOG_DIDNT_FIND_IT;
+ return LogType.LOG_DIDNT_FIND_IT;
}
- return cgBase.LOG_NOTE;
+ return LogType.LOG_NOTE;
}
private static Date parseDate(final String date) {
diff --git a/main/src/cgeo/geocaching/enumerations/LogType.java b/main/src/cgeo/geocaching/enumerations/LogType.java
new file mode 100644
index 0000000..d09ca63
--- /dev/null
+++ b/main/src/cgeo/geocaching/enumerations/LogType.java
@@ -0,0 +1,103 @@
+package cgeo.geocaching.enumerations;
+
+import cgeo.geocaching.R;
+import cgeo.geocaching.cgeoapplication;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+
+
+/**
+ * Different log types
+ *
+ * @author blafoo
+ */
+public enum LogType {
+
+ LOG_FOUND_IT(2,"icon_smile","found it",R.string.log_found),
+ LOG_DIDNT_FIND_IT(3, "icon_sad", "didn't find it", R.string.log_dnf),
+ LOG_NOTE(4,"icon_note","write note",R.string.log_note),
+ LOG_PUBLISH_LISTING(1003,"icon_greenlight","publish listing",R.string.log_published), // unknown ID), used number doesn't match any GC.com's ID
+ LOG_ENABLE_LISTING(23,"icon_enabled","enable listing",R.string.log_enabled),
+ LOG_ARCHIVE(5,"traffic_cone","archive",R.string.log_archived),
+ LOG_TEMP_DISABLE_LISTING(22,"icon_disabled","temporarily disable listing",R.string.log_disabled),
+ LOG_NEEDS_ARCHIVE(7,"icon_remove","needs archived",R.string.log_needs_archived),
+ LOG_WILL_ATTEND(9,"icon_rsvp","will attend",R.string.log_attend),
+ LOG_ATTENDED(10,"icon_attended","attended",R.string.log_attended),
+ LOG_RETRIEVED_IT(13,"picked_up","retrieved it",R.string.log_retrieved),
+ LOG_PLACED_IT(14,"dropped_off","placed it",R.string.log_placed),
+ LOG_GRABBED_IT(19,"transfer","grabbed it",R.string.log_grabbed),
+ LOG_NEEDS_MAINTENANCE(45,"icon_needsmaint","needs maintenance",R.string.log_maintenance_needed),
+ LOG_OWNER_MAINTENANCE(46,"icon_maint","owner maintenance",R.string.log_maintained),
+ LOG_UPDATE_COORDINATES(47,"coord_update","update coordinates",R.string.log_update),
+ LOG_DISCOVERED_IT(48,"icon_discovered","discovered it",R.string.log_discovered),
+ LOG_POST_REVIEWER_NOTE(18,"big_smile","post reviewer note",R.string.log_reviewed),
+ LOG_VISIT(1001,"icon_visited","visit",R.string.log_reviewed), // unknown ID), used number doesn't match any GC.com's ID
+ LOG_WEBCAM_PHOTO_TAKEN(11,"icon_camera","webcam photo taken",R.string.log_webcam), // unknown ID; used number doesn't match any GC.com's ID
+ LOG_ANNOUNCEMENT(74, "icon_announcement", "announcement", R.string.log_announcement), // unknown ID; used number doesn't match any GC.com's ID
+ LOG_UNKNOWN(0, "unknown", "", R.string.err_unknown); // LogType not init. yet
+
+ public final int id;
+ private final String iconName;
+ private final String type;
+ private final int stringId;
+ private String l10n; // not final because the locale can be changed
+
+ private LogType(int id, String iconName, String type, int stringId) {
+ this.id = id;
+ this.iconName = iconName;
+ this.type = type;
+ this.stringId = stringId;
+ setL10n();
+ }
+
+ private final static Map<String, LogType> FIND_BY_ICONNAME;
+ private final static Map<String, LogType> FIND_BY_TYPE;
+ static {
+ final HashMap<String, LogType> mappingPattern = new HashMap<String, LogType>();
+ final HashMap<String, LogType> mappingType = new HashMap<String, LogType>();
+ for (LogType lt : values()) {
+ mappingPattern.put(lt.iconName, lt);
+ mappingType.put(lt.type, lt);
+ }
+ FIND_BY_ICONNAME = Collections.unmodifiableMap(mappingPattern);
+ FIND_BY_TYPE = Collections.unmodifiableMap(mappingType);
+ }
+
+ public final static LogType getById(final int id) {
+ for (LogType logType : values()) {
+ if (logType.id == id) {
+ return logType;
+ }
+ }
+ return LOG_UNKNOWN;
+ }
+
+ public static LogType getByIconName(final String imageType) {
+ final LogType result = imageType != null ? LogType.FIND_BY_ICONNAME.get(imageType.toLowerCase().trim()) : null;
+ if (result == null) {
+ return LOG_UNKNOWN;
+ }
+ return result;
+ }
+
+ public static LogType getByType(final String type) {
+ final LogType result = type != null ? LogType.FIND_BY_TYPE.get(type.toLowerCase().trim()) : null;
+ if (result == null) {
+ return LOG_UNKNOWN;
+ }
+ return result;
+ }
+
+ public final String getL10n() {
+ return l10n;
+ }
+
+ public void setL10n() {
+ this.l10n = cgeoapplication.getInstance().getBaseContext().getResources().getString(this.stringId);
+ }
+
+}
+
diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java
index 8e530a7..2792104 100644
--- a/main/src/cgeo/geocaching/files/GPXParser.java
+++ b/main/src/cgeo/geocaching/files/GPXParser.java
@@ -2,7 +2,6 @@ package cgeo.geocaching.files;
import cgeo.geocaching.R;
import cgeo.geocaching.Settings;
-import cgeo.geocaching.cgBase;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgLog;
import cgeo.geocaching.cgTrackable;
@@ -11,6 +10,7 @@ import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.utils.CancellableHandler;
@@ -709,11 +709,7 @@ public abstract class GPXParser extends FileParser {
@Override
public void end(String body) {
final String logType = validate(body).toLowerCase();
- if (cgBase.logTypes0.containsKey(logType)) {
- log.type = cgBase.logTypes0.get(logType);
- } else {
- log.type = cgBase.LOG_NOTE;
- }
+ log.type = LogType.getByType(logType);
}
});
diff --git a/main/src/cgeo/geocaching/sorting/FindsComparator.java b/main/src/cgeo/geocaching/sorting/FindsComparator.java
index 3895273..7a1555e 100644
--- a/main/src/cgeo/geocaching/sorting/FindsComparator.java
+++ b/main/src/cgeo/geocaching/sorting/FindsComparator.java
@@ -1,8 +1,8 @@
package cgeo.geocaching.sorting;
-import cgeo.geocaching.cgBase;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.enumerations.LogType;
public class FindsComparator extends AbstractCacheComparator {
@@ -29,7 +29,7 @@ public class FindsComparator extends AbstractCacheComparator {
if (cache.getLogCounts().isEmpty()) {
cache.setLogCounts(app.loadLogCounts(cache.getGeocode()));
}
- Integer logged = cache.getLogCounts().get(cgBase.LOG_FOUND_IT);
+ Integer logged = cache.getLogCounts().get(LogType.LOG_FOUND_IT);
if (logged != null) {
finds = logged.intValue();
}
diff --git a/tests/src/cgeo/geocaching/cgBaseTest.java b/tests/src/cgeo/geocaching/cgBaseTest.java
index 1fda8fb..52a1a98 100644
--- a/tests/src/cgeo/geocaching/cgBaseTest.java
+++ b/tests/src/cgeo/geocaching/cgBaseTest.java
@@ -1,5 +1,6 @@
package cgeo.geocaching;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.test.RegExPerformanceTest;
import cgeo.geocaching.test.mock.MockedCache;
@@ -60,8 +61,8 @@ public class cgBaseTest extends AndroidTestCase {
for (String attribute : cache.getAttributes()) {
Assert.assertTrue(cacheParsed.getAttributes().contains(attribute));
}
- for (Integer key : cache.getLogCounts().keySet()) {
- Assert.assertEquals(cache.getLogCounts().get(key), cacheParsed.getLogCounts().get(key));
+ for (LogType logType : cache.getLogCounts().keySet()) {
+ Assert.assertEquals(cache.getLogCounts().get(logType), cacheParsed.getLogCounts().get(logType));
}
if (null != cache.getInventory() || null != cacheParsed.getInventory()) {
Assert.assertEquals(cache.getInventory().size(), cacheParsed.getInventory().size());
diff --git a/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java b/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java
new file mode 100644
index 0000000..f9edb81
--- /dev/null
+++ b/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java
@@ -0,0 +1,25 @@
+package cgeo.geocaching.enumerations;
+
+import android.test.AndroidTestCase;
+
+public class LogTypeTest extends AndroidTestCase {
+
+ public static void testGetById() {
+ assertEquals(LogType.LOG_UNKNOWN, LogType.getById(0));
+ assertEquals(LogType.LOG_UNKNOWN, LogType.getById(4711));
+ assertEquals(LogType.LOG_ENABLE_LISTING, LogType.getById(23));
+ }
+
+ public static void testGetByIconName() {
+ assertEquals(LogType.LOG_UNKNOWN, LogType.getByIconName(""));
+ assertEquals(LogType.LOG_UNKNOWN, LogType.getByIconName(null));
+ assertEquals(LogType.LOG_WEBCAM_PHOTO_TAKEN, LogType.getByIconName("icon_camera"));
+ }
+
+ public static void testGetByType() {
+ assertEquals(LogType.LOG_UNKNOWN, LogType.getByIconName(""));
+ assertEquals(LogType.LOG_UNKNOWN, LogType.getByIconName(null));
+ assertEquals(LogType.LOG_GRABBED_IT, LogType.getByType("grabbed IT "));
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
index 16e7626..5ad739d 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.test.mock;
import cgeo.geocaching.cgBase;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
import java.text.ParseException;
@@ -118,17 +119,17 @@ public class GC1ZXX2 extends MockedCache {
@Override
- public Map<Integer, Integer> getLogCounts() {
- Map<Integer, Integer> logCounts = new HashMap<Integer, Integer>();
- logCounts.put(cgBase.LOG_PUBLISH_LISTING, 1);
- logCounts.put(cgBase.LOG_FOUND_IT, 369);
- logCounts.put(cgBase.LOG_POST_REVIEWER_NOTE, 1);
- logCounts.put(cgBase.LOG_DIDNT_FIND_IT, 7);
- logCounts.put(cgBase.LOG_NOTE, 10);
- logCounts.put(cgBase.LOG_ARCHIVE, 1);
- logCounts.put(cgBase.LOG_ENABLE_LISTING, 2);
- logCounts.put(cgBase.LOG_TEMP_DISABLE_LISTING, 3);
- logCounts.put(cgBase.LOG_OWNER_MAINTENANCE, 7);
+ public Map<LogType, Integer> getLogCounts() {
+ Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>();
+ logCounts.put(LogType.LOG_PUBLISH_LISTING, 1);
+ logCounts.put(LogType.LOG_FOUND_IT, 369);
+ logCounts.put(LogType.LOG_POST_REVIEWER_NOTE, 1);
+ logCounts.put(LogType.LOG_DIDNT_FIND_IT, 7);
+ logCounts.put(LogType.LOG_NOTE, 10);
+ logCounts.put(LogType.LOG_ARCHIVE, 1);
+ logCounts.put(LogType.LOG_ENABLE_LISTING, 2);
+ logCounts.put(LogType.LOG_TEMP_DISABLE_LISTING, 3);
+ logCounts.put(LogType.LOG_OWNER_MAINTENANCE, 7);
return logCounts;
}
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
index 673f59b..e23b883 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.test.mock;
import cgeo.geocaching.cgBase;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.GeopointFormatter;
@@ -136,16 +137,16 @@ public class GC2CJPF extends MockedCache {
}
@Override
- public Map<Integer, Integer> getLogCounts() {
- Map<Integer, Integer> logCounts = new HashMap<Integer, Integer>();
- logCounts.put(cgBase.LOG_PUBLISH_LISTING, 1);
- logCounts.put(cgBase.LOG_FOUND_IT, 62);
- logCounts.put(cgBase.LOG_DIDNT_FIND_IT, 3);
- logCounts.put(cgBase.LOG_NOTE, 6);
- logCounts.put(cgBase.LOG_ENABLE_LISTING, 2);
- logCounts.put(cgBase.LOG_TEMP_DISABLE_LISTING, 2);
- logCounts.put(cgBase.LOG_OWNER_MAINTENANCE, 3);
- logCounts.put(cgBase.LOG_NEEDS_MAINTENANCE, 2);
+ public Map<LogType, Integer> getLogCounts() {
+ Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>();
+ logCounts.put(LogType.LOG_PUBLISH_LISTING, 1);
+ logCounts.put(LogType.LOG_FOUND_IT, 62);
+ logCounts.put(LogType.LOG_DIDNT_FIND_IT, 3);
+ logCounts.put(LogType.LOG_NOTE, 6);
+ logCounts.put(LogType.LOG_ENABLE_LISTING, 2);
+ logCounts.put(LogType.LOG_TEMP_DISABLE_LISTING, 2);
+ logCounts.put(LogType.LOG_OWNER_MAINTENANCE, 3);
+ logCounts.put(LogType.LOG_NEEDS_MAINTENANCE, 2);
return logCounts;
}
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
index 9815fbe..c590992 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
@@ -5,6 +5,7 @@ import cgeo.geocaching.cgImage;
import cgeo.geocaching.cgTrackable;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
import java.text.ParseException;
@@ -111,13 +112,13 @@ public class GC2JVEH extends MockedCache {
}
@Override
- public Map<Integer, Integer> getLogCounts() {
- final Map<Integer, Integer> logCounts = new HashMap<Integer, Integer>();
- logCounts.put(cgBase.LOG_FOUND_IT, 64);
- logCounts.put(cgBase.LOG_NOTE, 7);
- logCounts.put(cgBase.LOG_TEMP_DISABLE_LISTING, 1);
- logCounts.put(cgBase.LOG_ENABLE_LISTING, 1);
- logCounts.put(cgBase.LOG_PUBLISH_LISTING, 1);
+ public Map<LogType, Integer> getLogCounts() {
+ final Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>();
+ logCounts.put(LogType.LOG_FOUND_IT, 64);
+ logCounts.put(LogType.LOG_NOTE, 7);
+ logCounts.put(LogType.LOG_TEMP_DISABLE_LISTING, 1);
+ logCounts.put(LogType.LOG_ENABLE_LISTING, 1);
+ logCounts.put(LogType.LOG_PUBLISH_LISTING, 1);
return logCounts;
}