aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/res/layout/cache.xml4
-rw-r--r--main/res/layout/cacheview_details.xml3
-rw-r--r--main/res/layout/navigate.xml2
-rw-r--r--main/res/values/strings.xml122
-rw-r--r--main/src/cgeo/geocaching/CacheCache.java8
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java41
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java22
-rw-r--r--main/src/cgeo/geocaching/cgBase.java6
-rw-r--r--main/src/cgeo/geocaching/cgSelectMapfile.java7
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java7
-rw-r--r--main/src/cgeo/geocaching/cgeogpxes.java7
-rw-r--r--main/src/cgeo/geocaching/cgeonavigate.java5
-rw-r--r--main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java1
-rw-r--r--main/src/cgeo/geocaching/files/GPXImporter.java5
-rw-r--r--main/src/cgeo/geocaching/files/GPXParser.java4
-rw-r--r--main/src/cgeo/geocaching/files/LocParser.java2
-rw-r--r--main/src/cgeo/geocaching/gcvote/GCVote.java6
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java2
-rw-r--r--main/src/cgeo/geocaching/ui/CacheListAdapter.java (renamed from main/src/cgeo/geocaching/CacheListAdapter.java)48
-rw-r--r--main/src/cgeo/geocaching/ui/CacheView.java (renamed from main/src/cgeo/geocaching/cgCacheView.java)9
-rw-r--r--main/src/cgeo/geocaching/ui/CompassMiniView.java (renamed from main/src/cgeo/geocaching/cgCompassMini.java)11
-rw-r--r--main/src/cgeo/geocaching/ui/CompassView.java (renamed from main/src/cgeo/geocaching/cgCompass.java)17
-rw-r--r--main/src/cgeo/geocaching/ui/DirectionImage.java (renamed from main/src/cgeo/geocaching/cgDirectionImg.java)6
-rw-r--r--main/src/cgeo/geocaching/ui/DistanceView.java (renamed from main/src/cgeo/geocaching/cgDistanceView.java)11
-rw-r--r--main/src/cgeo/geocaching/ui/GPXListAdapter.java (renamed from main/src/cgeo/geocaching/cgGPXListAdapter.java)17
-rw-r--r--main/src/cgeo/geocaching/ui/GPXView.java (renamed from main/src/cgeo/geocaching/cgGPXView.java)4
-rw-r--r--main/src/cgeo/geocaching/ui/MapfileListAdapter.java (renamed from main/src/cgeo/geocaching/cgMapfileListAdapter.java)12
-rw-r--r--main/src/cgeo/geocaching/utils/LeastRecentlyUsedCache.java24
-rw-r--r--main/src/cgeo/geocaching/utils/UnknownTagsHandler.java34
-rw-r--r--tests/src/cgeo/geocaching/cgBaseTest.java7
-rw-r--r--tests/src/cgeo/geocaching/files/GPXImporterTest.java1
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java2
32 files changed, 313 insertions, 144 deletions
diff --git a/main/res/layout/cache.xml b/main/res/layout/cache.xml
index 45703fb..bc109cf 100644
--- a/main/res/layout/cache.xml
+++ b/main/res/layout/cache.xml
@@ -71,7 +71,7 @@
android:layout_marginTop="1dip"
android:layout_marginBottom="1dip"
android:layout_marginRight="30dip" >
- <view class="cgeo.geocaching.cgDistanceView"
+ <view class="cgeo.geocaching.ui.DistanceView"
android:id="@+id/distance"
android:layout_width="78dip"
android:layout_height="wrap_content"
@@ -84,7 +84,7 @@
android:textSize="16dip"
android:textColor="?text_color"
android:gravity="center" />
- <view class="cgeo.geocaching.cgCompassMini"
+ <view class="cgeo.geocaching.ui.CompassMiniView"
android:id="@+id/direction"
android:layout_width="78dip"
android:layout_height="28px"
diff --git a/main/res/layout/cacheview_details.xml b/main/res/layout/cacheview_details.xml
index 990b197..3da0789 100644
--- a/main/res/layout/cacheview_details.xml
+++ b/main/res/layout/cacheview_details.xml
@@ -218,7 +218,8 @@
android:layout_gravity="center"
android:gravity="center"
android:scaleType="centerCrop"
- android:src="@null" />
+ android:src="@null"
+ android:onClick="showNavigationMenu" />
</LinearLayout>
</LinearLayout>
diff --git a/main/res/layout/navigate.xml b/main/res/layout/navigate.xml
index 58c1f93..8e98136 100644
--- a/main/res/layout/navigate.xml
+++ b/main/res/layout/navigate.xml
@@ -47,7 +47,7 @@
android:textSize="26dip"
android:textColor="?text_color"
android:text="@null" />
- <view class="cgeo.geocaching.cgCompass"
+ <view class="cgeo.geocaching.ui.CompassView"
android:id="@+id/rose"
android:layout_width="fill_parent"
android:layout_height="295dip"
diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml
index c1de535..243d460 100644
--- a/main/res/values/strings.xml
+++ b/main/res/values/strings.xml
@@ -119,85 +119,84 @@
<string name="err_none">OK</string>
<string name="err_start">Communication not started</string>
<string name="err_parse">Failed Login page parsing</string>
- <string name="err_server">Failed connection to Geocaching.com (server or connection down?)</string>
+ <string name="err_server">Unable to contact Geocaching.com. The website may be down or your Internet connection not working.</string>
<string name="err_login">No Login information stored</string>
- <string name="err_login_failed">Sorry, c:geo can\'t log in.</string>
- <string name="err_login_failed_toast">Sorry, c:geo can\'t log in. c:geo works in offline mode. Check your Login in settings or enable Internet connection.</string>
+ <string name="err_login_failed">c:geo can\'t log in.</string>
+ <string name="err_login_failed_toast">c:geo can\'t log in. c:geo works offline with Stored caches. Check your Login settings or enable Internet connection.</string>
<string name="err_unknown">Unknown error</string>
<string name="err_comm">Unknown communication error</string>
<string name="err_missing_auth">No username and/or password set.</string>
- <string name="err_wrong">Wrong Login information</string>
- <string name="err_maintenance">Geocaching.com site is under maintenance, try again later. c:geo works in offline mode.</string>
- <string name="err_license">User has not agreed to Geocaching.com license agreement, so c:geo can\'t load caches coordinates.</string>
- <string name="err_unpublished">The requested cache was unpublished</string>
- <string name="err_premium_only">This Cache is only available to Geocaching.com Premium Members</string>
- <string name="err_store">Sorry, c:geo can\'t store the cache.</string>
- <string name="err_drop">Sorry, c:geo can\'t drop cache.</string>
- <string name="err_detail_open">Sorry, c:geo can\'t open geocache details.</string>
- <string name="err_detail_cache">Sorry, c:geo can\'t display geocache you want. Is it really geocache?</string>
- <string name="err_detail_cache_find">Sorry, c:geo can\'t find geocache</string>
- <string name="err_detail_cache_find_some">Sorry, c:geo can\'t find that geocache.</string>
- <string name="err_detail_cache_find_any">Sorry, c:geo can\'t find any geocache.</string>
- <string name="err_detail_cache_find_next">Sorry, c:geo can\'t find next geocaches.</string>
- <string name="err_detail_cache_forgot">Sorry, c:geo forgot which geocache you want.</string>
- <string name="err_detail_cache_forgot_visit">Sorry, c:geo forgot which cache you visited.</string>
+ <string name="err_wrong">Login information incorrect</string>
+ <string name="err_maintenance">Geocaching.com is down for maintenance. c:geo works offline with Stored caches.</string>
+ <string name="err_license">You have not agreed to Geocaching.com license agreement, so c:geo can\'t load cache coordinates.</string>
+ <string name="err_unpublished">The requested cache is unpublished.</string>
+ <string name="err_premium_only">This Cache is only available to Geocaching.com Premium Members.</string>
+ <string name="err_store">c:geo can\'t store the cache.</string>
+ <string name="err_drop">c:geo can\'t drop cache.</string>
+ <string name="err_detail_open">c:geo can\'t open geocache details.</string>
+ <string name="err_detail_cache">c:geo can\'t display the geocache you want. Is it really a geocache?</string>
+ <string name="err_detail_cache_find">c:geo can\'t find geocache</string>
+ <string name="err_detail_cache_find_some">c:geo can\'t find that geocache.</string>
+ <string name="err_detail_cache_find_any">c:geo can\'t find any geocache.</string>
+ <string name="err_detail_cache_find_next">c:geo can\'t find next geocaches.</string>
+ <string name="err_detail_cache_forgot">c:geo forgot which geocache you want.</string>
+ <string name="err_detail_cache_forgot_visit">c:geo forgot which cache you visited.</string>
<string name="err_detail_no_spoiler">c:geo found no spoiler images for this cache.</string>
<string name="err_detail_no_map_static">c:geo found no static maps for this cache.</string>
- <string name="err_detail_not_load_map_static">Sorry, c:geo failed to load static maps.</string>
+ <string name="err_detail_not_load_map_static">c:geo failed to load static maps.</string>
<string name="err_detail_still_working">Still working on another task.</string>
<string name="err_watchlist_still_managing">Still managing your watchlist.</string>
<string name="err_watchlist_failed">Changing your watchlist failed.</string>
<string name="err_navigation_no">c:geo can\'t find any supported navigation.</string>
<string name="err_application_no">c:geo can\'t find any suitable application.</string>
- <string name="err_auth_initialize">Sorry, c:geo failed to initialize authorization process.</string>
+ <string name="err_auth_initialize">c:geo failed to initialize authorization process.</string>
<string name="err_auth_process">Authorization process failed.</string>
- <string name="err_cannot_log_visit">c:geo has not enough information to log visit. Please, do it from full cache details.</string>
- <string name="err_init_cleared">Sorry, c:geo can\'t clear login information.</string>
- <string name="err_download_fail">Sorry, c:geo failed to download caches because of </string>
- <string name="err_list_load_fail">Sorry, c:geo failed to load cache list.</string>
- <string name="err_store_failed">Sorry, c:geo can\'t store geocache.</string>
- <string name="err_refresh_failed">Sorry, c:geo can\'t refresh geocache.</string>
- <string name="err_dwld_details_failed">Sorry, c:geo failed to download cache details.</string>
- <string name="err_dwld_details_failed_reason">Sorry, c:geo failed to download cache details because of</string>
- <string name="err_load_descr_failed">Sorry, c:geo can\'t load description.</string>
+ <string name="err_cannot_log_visit">c:geo is unable to log your visit. Please log your visit from full cache details screen.</string>
+ <string name="err_init_cleared">c:geo can\'t clear login information.</string>
+ <string name="err_download_fail">c:geo failed to download caches.</string>
+ <string name="err_list_load_fail">c:geo failed to load cache list.</string>
+ <string name="err_store_failed">c:geo can\'t store geocache.</string>
+ <string name="err_refresh_failed">c:geo can\'t refresh geocache.</string>
+ <string name="err_dwld_details_failed">c:geo failed to download cache details.</string>
+ <string name="err_load_descr_failed">c:geo can\'t load description.</string>
<string name="err_location_unknown">c:geo doesn\'t know location of cache.</string>
<string name="err_missing_device_name">Please enter a device name before registering.</string>
- <string name="err_tb_display">Sorry, c:geo can\'t display trackable you want. Is it really trackable?</string>
- <string name="err_tb_details_open">Sorry, c:geo can\'t open trackable details.</string>
- <string name="err_tb_details_download">Sorry, c:geo failed to download trackable details because of</string>
- <string name="err_tb_forgot">Sorry, c:geo forgot which trackable you want.</string>
- <string name="err_tb_forgot_saw">Sorry, c:geo forgot which trackable you saw.</string>
- <string name="err_tb_find">Sorry, c:geo can\'t find trackable</string>
- <string name="err_tb_find_that">Sorry, c:geo can\'t find that trackable.</string>
+ <string name="err_tb_display">c:geo can\'t display trackable you want. Is it really a trackable?</string>
+ <string name="err_tb_details_open">c:geo can\'t open trackable details.</string>
+ <string name="err_tb_details_download">c:geo failed to download trackable details.</string>
+ <string name="err_tb_forgot">c:geo forgot which trackable you want.</string>
+ <string name="err_tb_forgot_saw">c:geo forgot which trackable you saw.</string>
+ <string name="err_tb_find">c:geo can\'t find trackable</string>
+ <string name="err_tb_find_that">c:geo can\'t find that trackable.</string>
- <string name="err_waypoint_cache_unknown">Sorry, c:geo doesn\'t know to which cache you want to add waypoint.</string>
- <string name="err_waypoint_unknown">Sorry, c:geo forgot what waypoint you want to display.</string>
- <string name="err_waypoint_add_failed">Sorry, c:geo failed to add your waypoint.</string>
- <string name="err_waypoint_load_failed">Sorry, c:geo failed to load waypoint.</string>
- <string name="err_waypoint_delete_failed">Sorry, c:geo can\'t delete waypoint.</string>
- <string name="err_waypoint_open_cache_failed">Sorry, c:geo can\'t open cache details.</string>
- <string name="err_point_unknown_position">Sorry, c:geo can\'t recognize where you are.</string>
+ <string name="err_waypoint_cache_unknown">c:geo doesn\'t know to which cache you want to add waypoint.</string>
+ <string name="err_waypoint_unknown">c:geo forgot what waypoint you want to display.</string>
+ <string name="err_waypoint_add_failed">c:geo failed to add your waypoint.</string>
+ <string name="err_waypoint_load_failed">c:geo failed to load waypoint.</string>
+ <string name="err_waypoint_delete_failed">c:geo can\'t delete waypoint.</string>
+ <string name="err_waypoint_open_cache_failed">c:geo can\'t open cache details.</string>
+ <string name="err_point_unknown_position">c:geo can\'t recognize where you are.</string>
<string name="err_point_no_position_given_title">Info required</string>
<string name="err_point_no_position_given">Fill at least latitude or longitude or distance and bearing. You can also fill all four fields.</string>
<string name="err_point_curr_position_unavailable">c:geo still doesn\'t have current coordinates. Please, wait a while…</string>
<string name="err_point_bear_and_dist_title">Need some help?</string>
<string name="err_point_bear_and_dist">Fill both bearing and distance. Bearing is angle 0 to 360 degrees relative to north. Distance with or without units.</string>
- <string name="err_point_location_error">Sorry, c:geo can\'t get location of waypoint.</string>
+ <string name="err_point_location_error">c:geo can\'t get location of waypoint.</string>
- <string name="err_log_load_data">Sorry, c:geo can\'t load data required to log visit.</string>
- <string name="err_log_load_data_again">Sorry, c:geo can\'t load data required to log visit. Trying again.</string>
+ <string name="err_log_load_data">c:geo can\'t load data required to log visit.</string>
+ <string name="err_log_load_data_again">c:geo can\'t load data required to log visit. Trying again.</string>
<string name="err_log_load_data_still">c:geo is still loading data required to post log. Please wait a little while longer.</string>
- <string name="err_log_failed_server">Sorry, c:geo failed to post log because server is not responding.</string>
+ <string name="err_log_failed_server">c:geo failed to post log because server is not responding.</string>
<string name="err_log_post_failed">It seems that your log was not posted. Please check it on Geocaching.com.</string>
- <string name="err_search_address_no_match">Sorry, c:geo found no matching place.</string>
- <string name="err_search_address_forgot">Sorry, c:geo forgot address you try to find.</string>
+ <string name="err_search_address_no_match">c:geo found no matching place.</string>
+ <string name="err_search_address_forgot">c:geo forgot the address you tried to find.</string>
<string name="err_search_address">Searching for places</string>
- <string name="err_parse_lat">Sorry, c:geo can\'t parse latitude.</string>
- <string name="err_parse_lon">Sorry, c:geo can\'t parse longitude.</string>
- <string name="err_parse_dist">Sorry, c:geo can\'t parse distance.</string>
- <string name="err_parse_lat_lon">Sorry, c:geo can\'t parse latitude or longitude.</string>
+ <string name="err_parse_lat">c:geo can\'t parse latitude.</string>
+ <string name="err_parse_lon">c:geo can\'t parse longitude.</string>
+ <string name="err_parse_dist">c:geo can\'t parse distance.</string>
+ <string name="err_parse_lat_lon">c:geo can\'t parse latitude or longitude.</string>
<string name="err_fieldnotes_export_failed">Export of Field Notes failed.</string>
@@ -207,13 +206,13 @@
<string name="warn_no_keyword">No Keyword given.</string>
<string name="warn_no_username">No Username given.</string>
<string name="warn_search_help_title">Need some help?</string>
- <string name="warn_search_help_address">Fill in an address or location name. For example use a postal address \"Radlicka 100, Prague, Czech Republic\", a city name \"Berlin\" or just a name of something like \"Yellowstone Park\".</string>
- <string name="warn_search_help_gccode">Fill in the code of a geocache. For example \"GC1VCAZ\".</string>
- <string name="warn_search_help_keyword">Fill some word that is supposed to be somewhere in the cache name you are trying to find.</string>
- <string name="warn_search_help_user">Fill in a username at Geocaching.com.</string>
- <string name="warn_search_help_tb">Fill in code of trackable. For example \"TB29QMZ\".</string>
+ <string name="warn_search_help_address">Enter an address or location name. For example use a postal address \"Radlicka 100, Prague, Czech Republic\", a city name \"Berlin\" or just a name of something like \"Yellowstone Park\".</string>
+ <string name="warn_search_help_gccode">Enter the code for a geocache. For example \"GC1VCAZ\".</string>
+ <string name="warn_search_help_keyword">Enter all or part of a geocache name. For example \"Night Cache\".</string>
+ <string name="warn_search_help_user">Enter a username from Geocaching.com.</string>
+ <string name="warn_search_help_tb">Enter the code for a trackable. For example \"TB29QMZ\".</string>
<string name="warn_log_text_fill">Please fill in text for your log.</string>
- <string name="warn_load_images">Sorry, c:geo failed to load images.</string>
+ <string name="warn_load_images">c:geo failed to load images.</string>
<string name="info_log_posted">c:geo successfully submitted the log.</string>
@@ -359,7 +358,7 @@
<string name="init_signature">Signature</string>
<string name="init_signature_help_button">Help</string>
<string name="init_signature_help_title">Signature Tips and Tricks</string>
- <string name="init_signature_help_text">Write your signature to use it in the log text.\nSpecial strings that can be used are: [DATE] , [TIME], [DATETIME], [USER] &amp; [NUMBER].\nThese will be expanded when the signature is inserted.</string>
+ <string name="init_signature_help_text">Enter your signature to use it in the log text.\nSpecial strings that can be used are: [DATE] , [TIME], [DATETIME], [USER] &amp; [NUMBER].\nThese will be expanded when the signature is inserted.</string>
<string name="init_signature_template_button">Insert Template</string>
<string name="init_signature_template_date">Date</string>
<string name="init_signature_template_time">Time</string>
@@ -486,6 +485,7 @@
<string name="cache_personal_note">Personal note</string>
<string name="cache_description">Description</string>
<string name="cache_description_long">Long Description</string>
+ <string name="cache_description_table_note">Description contains table formatting which may need to be viewed at geocaching.com to be seen correctly.</string>
<string name="cache_watchlist">Watchlist</string>
<string name="cache_watchlist_on">This cache is on your watchlist.</string>
<string name="cache_watchlist_not_on">This cache is not on your watchlist.</string>
@@ -579,7 +579,7 @@
<!-- file list base -->
<string name="file_searching_in">Searching for files\nin</string>
- <string name="file_list_no_files">Sorry, c:geo found no appropriate files.</string>
+ <string name="file_list_no_files">c:geo found no appropriate files.</string>
<string name="file_searching">Searching for matching files</string>
<string name="file_title_searching">Searching</string>
diff --git a/main/src/cgeo/geocaching/CacheCache.java b/main/src/cgeo/geocaching/CacheCache.java
index ea8d749..ec6e6db 100644
--- a/main/src/cgeo/geocaching/CacheCache.java
+++ b/main/src/cgeo/geocaching/CacheCache.java
@@ -1,11 +1,10 @@
package cgeo.geocaching;
import cgeo.geocaching.cgData.StorageLocation;
+import cgeo.geocaching.utils.LeastRecentlyUsedCache;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
* Cache for Caches. Every cache is stored in memory while c:geo is active to
@@ -15,12 +14,13 @@ import java.util.Map;
*/
public class CacheCache {
- final private Map<String, cgCache> cachesCache; // caching caches into memory
+ private static final int MAX_CACHED_CACHES = 1000;
+ final private LeastRecentlyUsedCache<String, cgCache> cachesCache;
private static CacheCache instance = null;
private CacheCache() {
- cachesCache = new HashMap<String, cgCache>();
+ cachesCache = new LeastRecentlyUsedCache<String, cgCache>(MAX_CACHED_CACHES);
}
public static CacheCache getInstance() {
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index f3c12cc..5fa4c55 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -33,6 +33,7 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Bitmap;
+import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@@ -44,12 +45,15 @@ import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
+import android.text.Editable;
import android.text.Html;
import android.text.Spannable;
import android.text.Spanned;
+import android.text.format.DateUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ImageSpan;
import android.text.style.StrikethroughSpan;
+import android.text.style.StyleSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ContextMenu;
@@ -554,7 +558,7 @@ public class CacheDetailActivity extends AbstractActivity {
}
if (SearchResult.getError(search) != null) {
- showToast(res.getString(R.string.err_dwld_details_failed_reason) + " " + SearchResult.getError(search) + ".");
+ showToast(res.getString(R.string.err_dwld_details_failed) + " " + SearchResult.getError(search).getErrorString(res) + ".");
finish();
return;
@@ -919,6 +923,17 @@ public class CacheDetailActivity extends AbstractActivity {
}
/**
+ * referenced from XML view
+ */
+ public void showNavigationMenu(@SuppressWarnings("unused") View view) {
+ showNavigationMenu();
+ }
+
+ private void showNavigationMenu() {
+ NavigationAppFactory.showNavigationMenu(geolocation, this, cache, search);
+ }
+
+ /**
* Opens a context menu to do actions on an username
*/
private class UserActionsClickListener implements View.OnClickListener {
@@ -1440,8 +1455,15 @@ public class CacheDetailActivity extends AbstractActivity {
}
// cache hidden
- if (cache.getHiddenDate() != null && cache.getHiddenDate().getTime() > 0) {
- addCacheDetail(cache.isEventCache() ? R.string.cache_event : R.string.cache_hidden, cgBase.formatFullDate(cache.getHiddenDate().getTime()));
+ if (cache.getHiddenDate() != null) {
+ long time = cache.getHiddenDate().getTime();
+ if (time > 0) {
+ String dateString = cgBase.formatFullDate(time);
+ if (cache.isEventCache()) {
+ dateString = DateUtils.formatDateTime(cgeoapplication.getInstance().getBaseContext(), time, DateUtils.FORMAT_SHOW_WEEKDAY) + ", " + dateString;
+ }
+ addCacheDetail(cache.isEventCache() ? R.string.cache_event : R.string.cache_hidden, dateString);
+ }
}
// cache location
@@ -2069,11 +2091,20 @@ public class CacheDetailActivity extends AbstractActivity {
// Fast preview: parse only HTML without loading any images
HtmlImageCounter imageCounter = new HtmlImageCounter();
- description = Html.fromHtml(descriptionString, imageCounter, new UnknownTagsHandler());
+ final UnknownTagsHandler unknownTagsHandler = new UnknownTagsHandler();
+ description = Html.fromHtml(descriptionString, imageCounter, unknownTagsHandler);
publishProgress();
if (imageCounter.getImageCount() > 0) {
// Complete view: parse again with loading images - if necessary ! If there are any images causing problems the user can see at least the preview
- description = Html.fromHtml(descriptionString, new HtmlImage(CacheDetailActivity.this, cache.getGeocode(), true, cache.getListId(), false), new UnknownTagsHandler());
+ description = Html.fromHtml(descriptionString, new HtmlImage(CacheDetailActivity.this, cache.getGeocode(), true, cache.getListId(), false), unknownTagsHandler);
+ publishProgress();
+ }
+
+ // if description has HTML table, add a note at the end of the long description
+ if (unknownTagsHandler.isTableDetected() && descriptionView == view.findViewById(R.id.longdesc)) {
+ final int startPos = description.length();
+ ((Editable) description).append("\n\n" + res.getString(R.string.cache_description_table_note));
+ ((Editable) description).setSpan(new StyleSpan(Typeface.ITALIC), startPos, description.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
publishProgress();
}
return null;
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
index bfda2ea..67ecfed 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.apps.cache.navi;
+import cgeo.geocaching.R;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
@@ -11,6 +12,8 @@ import cgeo.geocaching.geopoint.Geopoint;
import org.apache.commons.lang3.ArrayUtils;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -54,6 +57,25 @@ public final class NavigationAppFactory extends AbstractAppFactory {
}
}
+ public static void showNavigationMenu(final cgGeo geo, final Activity activity, final cgCache cache, final SearchResult search) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ builder.setTitle(R.string.cache_menu_navigate);
+ builder.setIcon(android.R.drawable.ic_menu_mapmode);
+ final List<NavigationApp> installed = getInstalledNavigationApps(activity);
+ String[] items = new String[installed.size()];
+ for (int i = 0; i < installed.size(); i++) {
+ items[i] = installed.get(i).getName();
+ }
+ builder.setItems(items, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int item) {
+ installed.get(item).invoke(geo, activity, cache, search, null, null);
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
+
+ }
+
public static List<NavigationApp> getInstalledNavigationApps(final Activity activity) {
final List<NavigationApp> installedNavigationApps = new ArrayList<NavigationApp>();
for (NavigationApp app : getNavigationApps()) {
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java
index a1c681e..c4a2f24 100644
--- a/main/src/cgeo/geocaching/cgBase.java
+++ b/main/src/cgeo/geocaching/cgBase.java
@@ -20,6 +20,7 @@ import cgeo.geocaching.geopoint.IConversion;
import cgeo.geocaching.geopoint.Viewport;
import cgeo.geocaching.network.HtmlImage;
import cgeo.geocaching.twitter.Twitter;
+import cgeo.geocaching.ui.DirectionImage;
import cgeo.geocaching.utils.BaseUtils;
import cgeo.geocaching.utils.CancellableHandler;
@@ -657,7 +658,7 @@ public class cgBase {
{
for (cgCache oneCache : parseResult.cacheList) {
if (oneCache.getCoords() == null && StringUtils.isNotEmpty(oneCache.getDirectionImg())) {
- cgDirectionImg.getDrawable(oneCache.getGeocode(), oneCache.getDirectionImg());
+ DirectionImage.getDrawable(oneCache.getGeocode(), oneCache.getDirectionImg());
}
}
}
@@ -1182,7 +1183,6 @@ public class cgBase {
//cache.setLogs(loadLogsFromDetails(page, cache, false));
if (Settings.isFriendLogsWanted()) {
sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_logs);
- int position = 0;
List<cgLog> allLogs = cache.getLogs();
List<cgLog> friendLogs = loadLogsFromDetails(page, cache, true, false);
if (friendLogs != null) {
@@ -1190,7 +1190,7 @@ public class cgBase {
if (allLogs.contains(log)) {
allLogs.get(allLogs.indexOf(log)).friend = true;
} else {
- allLogs.add(position++, log);
+ allLogs.add(log);
}
}
}
diff --git a/main/src/cgeo/geocaching/cgSelectMapfile.java b/main/src/cgeo/geocaching/cgSelectMapfile.java
index eebd2c9..b97d717 100644
--- a/main/src/cgeo/geocaching/cgSelectMapfile.java
+++ b/main/src/cgeo/geocaching/cgSelectMapfile.java
@@ -2,6 +2,7 @@ package cgeo.geocaching;
import cgeo.geocaching.files.FileList;
import cgeo.geocaching.files.LocalStorage;
+import cgeo.geocaching.ui.MapfileListAdapter;
import android.content.Intent;
import android.os.Bundle;
@@ -10,7 +11,7 @@ import android.os.Environment;
import java.io.File;
import java.util.List;
-public class cgSelectMapfile extends FileList<cgMapfileListAdapter> {
+public class cgSelectMapfile extends FileList<MapfileListAdapter> {
public cgSelectMapfile() {
super("map");
@@ -35,8 +36,8 @@ public class cgSelectMapfile extends FileList<cgMapfileListAdapter> {
}
@Override
- protected cgMapfileListAdapter getAdapter(List<File> files) {
- return new cgMapfileListAdapter(this, files);
+ protected MapfileListAdapter getAdapter(List<File> files) {
+ return new MapfileListAdapter(this, files);
}
@Override
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index 7ff3469..aa90336 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -31,6 +31,7 @@ import cgeo.geocaching.sorting.StateComparator;
import cgeo.geocaching.sorting.TerrainComparator;
import cgeo.geocaching.sorting.VisitComparator;
import cgeo.geocaching.sorting.VoteComparator;
+import cgeo.geocaching.ui.CacheListAdapter;
import cgeo.geocaching.utils.RunnableWithArgument;
import org.apache.commons.collections.CollectionUtils;
@@ -212,7 +213,7 @@ public class cgeocaches extends AbstractListActivity {
AlertDialog alert = dialog.create();
alert.show();
} else if (app != null && SearchResult.getError(search) != null) {
- showToast(res.getString(R.string.err_download_fail) + SearchResult.getError(search).getErrorString(res) + ".");
+ showToast(res.getString(R.string.err_download_fail) + " " + SearchResult.getError(search).getErrorString(res) + ".");
hideLoading();
showProgress(false);
@@ -281,7 +282,7 @@ public class cgeocaches extends AbstractListActivity {
}
if (SearchResult.getError(search) != null) {
- showToast(res.getString(R.string.err_download_fail) + SearchResult.getError(search).getErrorString(res) + ".");
+ showToast(res.getString(R.string.err_download_fail) + " " + SearchResult.getError(search).getErrorString(res) + ".");
listFooter.setOnClickListener(new MoreCachesListener());
hideLoading();
@@ -2634,7 +2635,7 @@ public class cgeocaches extends AbstractListActivity {
else if (type == CacheListType.HISTORY) {
adapter.setComparator(new VisitComparator());
}
- else {
+ else if (adapter.getCacheComparator() != null && adapter.getCacheComparator() instanceof DateComparator) {
adapter.setComparator(null);
}
}
diff --git a/main/src/cgeo/geocaching/cgeogpxes.java b/main/src/cgeo/geocaching/cgeogpxes.java
index cb8167a..ab903ec 100644
--- a/main/src/cgeo/geocaching/cgeogpxes.java
+++ b/main/src/cgeo/geocaching/cgeogpxes.java
@@ -4,6 +4,7 @@ import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.IConnector;
import cgeo.geocaching.files.FileList;
import cgeo.geocaching.files.GPXImporter;
+import cgeo.geocaching.ui.GPXListAdapter;
import org.apache.commons.lang3.StringUtils;
@@ -15,7 +16,7 @@ import android.os.Environment;
import java.io.File;
import java.util.List;
-public class cgeogpxes extends FileList<cgGPXListAdapter> {
+public class cgeogpxes extends FileList<GPXListAdapter> {
private static final String EXTRAS_LIST_ID = "list";
public cgeogpxes() {
@@ -25,8 +26,8 @@ public class cgeogpxes extends FileList<cgGPXListAdapter> {
private int listId = 1;
@Override
- protected cgGPXListAdapter getAdapter(List<File> files) {
- return new cgGPXListAdapter(this, files);
+ protected GPXListAdapter getAdapter(List<File> files) {
+ return new GPXListAdapter(this, files);
}
@Override
diff --git a/main/src/cgeo/geocaching/cgeonavigate.java b/main/src/cgeo/geocaching/cgeonavigate.java
index 45bdf43..519521d 100644
--- a/main/src/cgeo/geocaching/cgeonavigate.java
+++ b/main/src/cgeo/geocaching/cgeonavigate.java
@@ -3,6 +3,7 @@ package cgeo.geocaching;
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.CGeoMap;
+import cgeo.geocaching.ui.CompassView;
import org.apache.commons.lang3.StringUtils;
@@ -48,7 +49,7 @@ public class cgeonavigate extends AbstractActivity {
private TextView navLocation = null;
private TextView distanceView = null;
private TextView headingView = null;
- private cgCompass compassView = null;
+ private CompassView compassView = null;
private updaterThread updater = null;
private Handler updaterHandler = new Handler() {
@@ -124,7 +125,7 @@ public class cgeonavigate extends AbstractActivity {
}
// get textviews once
- compassView = (cgCompass) findViewById(R.id.rose);
+ compassView = (CompassView) findViewById(R.id.rose);
// start updater thread
updater = new updaterThread(updaterHandler);
diff --git a/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java b/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java
index a112a10..09fc8f1 100644
--- a/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java
+++ b/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java
@@ -124,6 +124,7 @@ final public class OkapiClient {
private static cgCache parseCache(final JSONObject response) {
final cgCache cache = new cgCache();
+ cache.setReliableLatLon(true);
try {
cache.setGeocode(response.getString(CACHE_CODE));
cache.setName(response.getString(CACHE_NAME));
diff --git a/main/src/cgeo/geocaching/files/GPXImporter.java b/main/src/cgeo/geocaching/files/GPXImporter.java
index 9ced045..e7853f0 100644
--- a/main/src/cgeo/geocaching/files/GPXImporter.java
+++ b/main/src/cgeo/geocaching/files/GPXImporter.java
@@ -1,9 +1,9 @@
package cgeo.geocaching.files;
import cgeo.geocaching.R;
+import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.SearchResult;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.activity.IAbstractActivity;
import cgeo.geocaching.activity.Progress;
@@ -153,6 +153,9 @@ public class GPXImporter {
cgeoapplication.removeCacheFromCache(cache.getGeocode());
app.addCacheToSearch(search, cache);
+ // save memory, imported caches are typically not used immediately
+ cgeoapplication.removeCacheFromCache(cache.getGeocode());
+
if (progressHandler.isCancelled()) {
throw new CancellationException();
}
diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java
index 5e17388..1082c9c 100644
--- a/main/src/cgeo/geocaching/files/GPXParser.java
+++ b/main/src/cgeo/geocaching/files/GPXParser.java
@@ -68,7 +68,7 @@ public abstract class GPXParser extends FileParser {
final protected String namespace;
final private String version;
- private cgCache cache = new cgCache();
+ private cgCache cache;
private cgTrackable trackable = new cgTrackable();
private cgLog log = new cgLog();
@@ -237,6 +237,7 @@ public abstract class GPXParser extends FileParser {
@Override
public Collection<cgCache> parse(final InputStream stream, final CancellableHandler progressHandler) throws IOException, ParserException {
+ resetCache();
final RootElement root = new RootElement(namespace, "gpx");
final Element waypoint = root.getChild(namespace, "wpt");
@@ -795,6 +796,7 @@ public abstract class GPXParser extends FileParser {
cmt = null;
cache = new cgCache();
+ cache.setReliableLatLon(true);
for (int i = 0; i < userData.length; i++) {
userData[i] = null;
}
diff --git a/main/src/cgeo/geocaching/files/LocParser.java b/main/src/cgeo/geocaching/files/LocParser.java
index 6f043f0..e35d7dd 100644
--- a/main/src/cgeo/geocaching/files/LocParser.java
+++ b/main/src/cgeo/geocaching/files/LocParser.java
@@ -51,6 +51,7 @@ public final class LocParser extends FileParser {
cgCoord coord = cidCoords.get(cache.getGeocode());
copyCoordToCache(coord, cache);
+ cache.setReliableLatLon(false);
}
}
}
@@ -155,6 +156,7 @@ public final class LocParser extends FileParser {
continue;
}
cgCache cache = new cgCache();
+ cache.setReliableLatLon(true);
copyCoordToCache(coord, cache);
caches.add(cache);
diff --git a/main/src/cgeo/geocaching/gcvote/GCVote.java b/main/src/cgeo/geocaching/gcvote/GCVote.java
index fede9df..377014e 100644
--- a/main/src/cgeo/geocaching/gcvote/GCVote.java
+++ b/main/src/cgeo/geocaching/gcvote/GCVote.java
@@ -4,6 +4,7 @@ import cgeo.geocaching.Parameters;
import cgeo.geocaching.Settings;
import cgeo.geocaching.cgBase;
import cgeo.geocaching.cgCache;
+import cgeo.geocaching.utils.LeastRecentlyUsedCache;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -26,12 +27,13 @@ public final class GCVote {
private static final Pattern patternVote = Pattern.compile("voteUser='([0-9.]+)'", Pattern.CASE_INSENSITIVE);
private static final Pattern patternVoteElement = Pattern.compile("<vote ([^>]+)>", Pattern.CASE_INSENSITIVE);
- private static Map<String, GCVoteRating> ratingsCache = new HashMap<String, GCVoteRating>(); // key = guid
+ private static final int MAX_CACHED_RATINGS = 1000;
+ private static LeastRecentlyUsedCache<String, GCVoteRating> ratingsCache = new LeastRecentlyUsedCache<String, GCVoteRating>(MAX_CACHED_RATINGS);
/**
* Get user rating for a given guid or geocode. For a guid first the ratings cache is checked
* before a request to gcvote.com is made.
- *
+ *
* @param guid
* @param geocode
* @return
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 3ba8d90..b5b648f 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -146,7 +146,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
private PositionOverlay overlayPosition = null;
// data for overlays
private static final int[][] INSET_RELIABLE = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; // center, 33x40 / 45x51
- private static final int[][] INSET_TYPE = { { 5, 8, 6, 10 }, { 4, 7, 5, 8 } }; // center, 22x22 / 36x36
+ private static final int[][] INSET_TYPE = { { 5, 8, 6, 10 }, { 4, 4, 5, 11 } }; // center, 22x22 / 36x36
private static final int[][] INSET_OWN = { { 21, 0, 0, 26 }, { 25, 0, 0, 35 } }; // top right, 12x12 / 16x16
private static final int[][] INSET_FOUND = { { 0, 0, 21, 28 }, { 0, 0, 25, 35 } }; // top left, 12x12 / 16x16
private static final int[][] INSET_USERMODIFIEDCOORDS = { { 21, 28, 0, 0 }, { 19, 25, 0, 0 } }; // bottom right, 12x12 / 26x26
diff --git a/main/src/cgeo/geocaching/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
index e417166..c2910cf 100644
--- a/main/src/cgeo/geocaching/CacheListAdapter.java
+++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
@@ -1,5 +1,15 @@
-package cgeo.geocaching;
-
+package cgeo.geocaching.ui;
+
+import cgeo.geocaching.CacheDetailActivity;
+import cgeo.geocaching.R;
+import cgeo.geocaching.Settings;
+import cgeo.geocaching.cgBase;
+import cgeo.geocaching.cgCache;
+import cgeo.geocaching.R.color;
+import cgeo.geocaching.R.drawable;
+import cgeo.geocaching.R.id;
+import cgeo.geocaching.R.layout;
+import cgeo.geocaching.R.string;
import cgeo.geocaching.enumerations.CacheListType;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
@@ -52,7 +62,7 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
final private Resources res;
/** Resulting list of caches */
final private List<cgCache> list;
- private cgCacheView holder = null;
+ private CacheView holder = null;
private LayoutInflater inflater = null;
private CacheComparator cacheComparator = null;
private Geopoint coords = null;
@@ -62,8 +72,8 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
private int checked = 0;
private boolean selectMode = false;
final private static Map<CacheType, Drawable> gcIconDrawables = new HashMap<CacheType, Drawable>();
- final private Set<cgCompassMini> compasses = new LinkedHashSet<cgCompassMini>();
- final private Set<cgDistanceView> distances = new LinkedHashSet<cgDistanceView>();
+ final private Set<CompassMiniView> compasses = new LinkedHashSet<CompassMiniView>();
+ final private Set<DistanceView> distances = new LinkedHashSet<DistanceView>();
final private int[] ratingBcgs = new int[3];
final private float pixelDensity;
private static final int SWIPE_MIN_DISTANCE = 60;
@@ -118,6 +128,10 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
forceSort(coords);
}
+ public CacheComparator getCacheComparator() {
+ return cacheComparator;
+ }
+
/**
* Called when a new page of caches was loaded.
*/
@@ -272,11 +286,11 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
lastSort = System.currentTimeMillis();
}
- for (final cgDistanceView distance : distances) {
+ for (final DistanceView distance : distances) {
distance.update(coordsIn);
}
- for (final cgCompassMini compass : compasses) {
+ for (final CompassMiniView compass : compasses) {
compass.updateCoords(coordsIn);
}
}
@@ -293,7 +307,7 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
azimuth = directionNow;
if (CollectionUtils.isNotEmpty(compasses)) {
- for (cgCompassMini compass : compasses) {
+ for (CompassMiniView compass : compasses) {
compass.updateAzimuth(azimuth);
}
}
@@ -346,15 +360,15 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
if (v == null) {
v = inflater.inflate(R.layout.cache, null);
- holder = new cgCacheView();
+ holder = new CacheView();
holder.checkbox = (CheckBox) v.findViewById(R.id.checkbox);
holder.oneInfo = (RelativeLayout) v.findViewById(R.id.one_info);
holder.oneCheckbox = (RelativeLayout) v.findViewById(R.id.one_checkbox);
holder.logStatusMark = (ImageView) v.findViewById(R.id.log_status_mark);
holder.text = (TextView) v.findViewById(R.id.text);
holder.directionLayout = (RelativeLayout) v.findViewById(R.id.direction_layout);
- holder.distance = (cgDistanceView) v.findViewById(R.id.distance);
- holder.direction = (cgCompassMini) v.findViewById(R.id.direction);
+ holder.distance = (DistanceView) v.findViewById(R.id.distance);
+ holder.direction = (CompassMiniView) v.findViewById(R.id.direction);
holder.dirImgLayout = (RelativeLayout) v.findViewById(R.id.dirimg_layout);
holder.dirImg = (ImageView) v.findViewById(R.id.dirimg);
holder.inventory = (RelativeLayout) v.findViewById(R.id.inventory);
@@ -363,7 +377,7 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
v.setTag(holder);
} else {
- holder = (cgCacheView) v.getTag();
+ holder = (CacheView) v.getTag();
}
if (cache.isOwn()) {
@@ -490,7 +504,7 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
holder.directionLayout.setVisibility(View.GONE);
holder.distance.clear();
- final Bitmap dirImgPre = BitmapFactory.decodeFile(cgDirectionImg.getDirectionFile(cache.getGeocode(), false).getPath());
+ final Bitmap dirImgPre = BitmapFactory.decodeFile(DirectionImage.getDirectionFile(cache.getGeocode(), false).getPath());
final Bitmap dirImg;
if (dirImgPre != null) { // null happens for invalid caches (not yet released)
dirImg = dirImgPre.copy(Bitmap.Config.ARGB_8888, true);
@@ -682,10 +696,10 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
class detectGesture extends GestureDetector.SimpleOnGestureListener {
- private cgCacheView holder = null;
+ private CacheView holder = null;
private cgCache cache = null;
- public detectGesture(cgCacheView holderIn, cgCache cacheIn) {
+ public detectGesture(CacheView holderIn, cgCache cacheIn) {
holder = holderIn;
cache = cacheIn;
}
@@ -752,7 +766,7 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
}
}
- private void moveRight(cgCacheView holder, cgCache cache, boolean force) {
+ private void moveRight(CacheView holder, cgCache cache, boolean force) {
if (cache == null) {
return;
}
@@ -787,7 +801,7 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
cache.setStatusCheckedView(true);
}
- private void moveLeft(cgCacheView holder, cgCache cache, boolean force) {
+ private void moveLeft(CacheView holder, cgCache cache, boolean force) {
if (cache == null) {
return;
}
diff --git a/main/src/cgeo/geocaching/cgCacheView.java b/main/src/cgeo/geocaching/ui/CacheView.java
index 39f5a45..7fba55d 100644
--- a/main/src/cgeo/geocaching/cgCacheView.java
+++ b/main/src/cgeo/geocaching/ui/CacheView.java
@@ -1,11 +1,12 @@
-package cgeo.geocaching;
+package cgeo.geocaching.ui;
+
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
-public class cgCacheView {
+public class CacheView {
// layouts & views
public RelativeLayout oneInfo;
public RelativeLayout oneCheckbox;
@@ -16,8 +17,8 @@ public class cgCacheView {
public TextView info;
public RelativeLayout inventory;
public RelativeLayout directionLayout;
- public cgDistanceView distance;
- public cgCompassMini direction;
+ public DistanceView distance;
+ public CompassMiniView direction;
public RelativeLayout dirImgLayout;
public ImageView dirImg;
}
diff --git a/main/src/cgeo/geocaching/cgCompassMini.java b/main/src/cgeo/geocaching/ui/CompassMiniView.java
index 4682502..5f3b8c2 100644
--- a/main/src/cgeo/geocaching/cgCompassMini.java
+++ b/main/src/cgeo/geocaching/ui/CompassMiniView.java
@@ -1,5 +1,8 @@
-package cgeo.geocaching;
+package cgeo.geocaching.ui;
+import cgeo.geocaching.R;
+import cgeo.geocaching.R.drawable;
+import cgeo.geocaching.R.styleable;
import cgeo.geocaching.geopoint.Geopoint;
import android.content.Context;
@@ -12,7 +15,7 @@ import android.graphics.PaintFlagsDrawFilter;
import android.util.AttributeSet;
import android.view.View;
-public class cgCompassMini extends View {
+public class CompassMiniView extends View {
private int arrowSkin = R.drawable.compass_arrow_mini_white;
private Context context = null;
private Geopoint cacheCoords = null;
@@ -22,12 +25,12 @@ public class cgCompassMini extends View {
private PaintFlagsDrawFilter setfil = null;
private PaintFlagsDrawFilter remfil = null;
- public cgCompassMini(Context contextIn) {
+ public CompassMiniView(Context contextIn) {
super(contextIn);
context = contextIn;
}
- public cgCompassMini(Context contextIn, AttributeSet attrs) {
+ public CompassMiniView(Context contextIn, AttributeSet attrs) {
super(contextIn, attrs);
context = contextIn;
diff --git a/main/src/cgeo/geocaching/cgCompass.java b/main/src/cgeo/geocaching/ui/CompassView.java
index aa4466b..20495c0 100644
--- a/main/src/cgeo/geocaching/cgCompass.java
+++ b/main/src/cgeo/geocaching/ui/CompassView.java
@@ -1,4 +1,7 @@
-package cgeo.geocaching;
+package cgeo.geocaching.ui;
+
+import cgeo.geocaching.R;
+import cgeo.geocaching.Settings;
import android.content.Context;
import android.graphics.Bitmap;
@@ -12,7 +15,7 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
-public class cgCompass extends View {
+public class CompassView extends View {
private changeThread watchdog = null;
private volatile boolean wantStop = false;
@@ -55,17 +58,17 @@ public class cgCompass extends View {
try {
invalidate();
} catch (Exception e) {
- Log.e(Settings.tag, "cgCompass.changeHandler: " + e.toString());
+ Log.e(Settings.tag, "CompassView.changeHandler: " + e.toString());
}
}
};
- public cgCompass(Context contextIn) {
+ public CompassView(Context contextIn) {
super(contextIn);
context = contextIn;
}
- public cgCompass(Context contextIn, AttributeSet attrs) {
+ public CompassView(Context contextIn, AttributeSet attrs) {
super(contextIn, attrs);
context = contextIn;
}
@@ -117,7 +120,7 @@ public class cgCompass extends View {
}
}
- protected synchronized void updateNorth(double northHeadingIn, double cacheHeadingIn) {
+ public synchronized void updateNorth(double northHeadingIn, double cacheHeadingIn) {
if (initialDisplay) {
// We will force the compass to move brutally if this is the first
// update since it is visible.
@@ -176,7 +179,7 @@ public class cgCompass extends View {
// nothing
}
- synchronized (cgCompass.this) {
+ synchronized (CompassView.this) {
azimuthShown = smoothUpdate(northMeasured, azimuthShown);
cacheHeadingShown = smoothUpdate(cacheHeadingMeasured, cacheHeadingShown);
}
diff --git a/main/src/cgeo/geocaching/cgDirectionImg.java b/main/src/cgeo/geocaching/ui/DirectionImage.java
index 7b28bf2..17c253a 100644
--- a/main/src/cgeo/geocaching/cgDirectionImg.java
+++ b/main/src/cgeo/geocaching/ui/DirectionImage.java
@@ -1,5 +1,7 @@
-package cgeo.geocaching;
+package cgeo.geocaching.ui;
+import cgeo.geocaching.Parameters;
+import cgeo.geocaching.cgBase;
import cgeo.geocaching.files.LocalStorage;
import org.apache.commons.lang3.StringUtils;
@@ -7,7 +9,7 @@ import org.apache.http.HttpResponse;
import java.io.File;
-public class cgDirectionImg {
+public class DirectionImage {
public static void getDrawable(final String geocode, final String code) {
if (StringUtils.isBlank(geocode) || StringUtils.isBlank(code)) {
diff --git a/main/src/cgeo/geocaching/cgDistanceView.java b/main/src/cgeo/geocaching/ui/DistanceView.java
index 704a655..49c90b7 100644
--- a/main/src/cgeo/geocaching/cgDistanceView.java
+++ b/main/src/cgeo/geocaching/ui/DistanceView.java
@@ -1,23 +1,24 @@
-package cgeo.geocaching;
+package cgeo.geocaching.ui;
+import cgeo.geocaching.cgBase;
import cgeo.geocaching.geopoint.Geopoint;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
-public class cgDistanceView extends TextView {
+public class DistanceView extends TextView {
private Geopoint cacheCoords = null;
- public cgDistanceView(Context context) {
+ public DistanceView(Context context) {
super(context);
}
- public cgDistanceView(Context context, AttributeSet attrs) {
+ public DistanceView(Context context, AttributeSet attrs) {
super(context, attrs);
}
- public cgDistanceView(Context context, AttributeSet attrs, int defStyle) {
+ public DistanceView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
diff --git a/main/src/cgeo/geocaching/cgGPXListAdapter.java b/main/src/cgeo/geocaching/ui/GPXListAdapter.java
index 7b163cf..23f38b0 100644
--- a/main/src/cgeo/geocaching/cgGPXListAdapter.java
+++ b/main/src/cgeo/geocaching/ui/GPXListAdapter.java
@@ -1,5 +1,10 @@
-package cgeo.geocaching;
+package cgeo.geocaching.ui;
+import cgeo.geocaching.R;
+import cgeo.geocaching.Settings;
+import cgeo.geocaching.cgeogpxes;
+import cgeo.geocaching.R.id;
+import cgeo.geocaching.R.layout;
import cgeo.geocaching.files.GPXImporter;
import android.app.Activity;
@@ -13,12 +18,12 @@ import android.widget.TextView;
import java.io.File;
import java.util.List;
-public class cgGPXListAdapter extends ArrayAdapter<File> {
- private cgGPXView holder = null;
+public class GPXListAdapter extends ArrayAdapter<File> {
+ private GPXView holder = null;
private cgeogpxes parent = null;
private LayoutInflater inflater = null;
- public cgGPXListAdapter(cgeogpxes parentIn, List<File> listIn) {
+ public GPXListAdapter(cgeogpxes parentIn, List<File> listIn) {
super(parentIn, 0, listIn);
parent = parentIn;
@@ -42,13 +47,13 @@ public class cgGPXListAdapter extends ArrayAdapter<File> {
if (v == null) {
v = inflater.inflate(R.layout.gpx_item, null);
- holder = new cgGPXView();
+ holder = new GPXView();
holder.filepath = (TextView) v.findViewById(R.id.filepath);
holder.filename = (TextView) v.findViewById(R.id.filename);
v.setTag(holder);
} else {
- holder = (cgGPXView) v.getTag();
+ holder = (GPXView) v.getTag();
}
final touchListener touchLst = new touchListener(file);
diff --git a/main/src/cgeo/geocaching/cgGPXView.java b/main/src/cgeo/geocaching/ui/GPXView.java
index a731f70..a93d0db 100644
--- a/main/src/cgeo/geocaching/cgGPXView.java
+++ b/main/src/cgeo/geocaching/ui/GPXView.java
@@ -1,8 +1,8 @@
-package cgeo.geocaching;
+package cgeo.geocaching.ui;
import android.widget.TextView;
-public class cgGPXView {
+public class GPXView {
// layouts & views
public TextView filepath;
public TextView filename;
diff --git a/main/src/cgeo/geocaching/cgMapfileListAdapter.java b/main/src/cgeo/geocaching/ui/MapfileListAdapter.java
index 5294ff2..cc16733 100644
--- a/main/src/cgeo/geocaching/cgMapfileListAdapter.java
+++ b/main/src/cgeo/geocaching/ui/MapfileListAdapter.java
@@ -1,4 +1,10 @@
-package cgeo.geocaching;
+package cgeo.geocaching.ui;
+
+import cgeo.geocaching.R;
+import cgeo.geocaching.Settings;
+import cgeo.geocaching.cgSelectMapfile;
+import cgeo.geocaching.R.id;
+import cgeo.geocaching.R.layout;
import android.app.Activity;
import android.graphics.Typeface;
@@ -12,13 +18,13 @@ import android.widget.TextView;
import java.io.File;
import java.util.List;
-public class cgMapfileListAdapter extends ArrayAdapter<File> {
+public class MapfileListAdapter extends ArrayAdapter<File> {
private cgSelectMapfile parentView;
private LayoutInflater inflater;
private MapfileView holder;
- public cgMapfileListAdapter(cgSelectMapfile parentIn, List<File> listIn) {
+ public MapfileListAdapter(cgSelectMapfile parentIn, List<File> listIn) {
super(parentIn, 0, listIn);
parentView = parentIn;
diff --git a/main/src/cgeo/geocaching/utils/LeastRecentlyUsedCache.java b/main/src/cgeo/geocaching/utils/LeastRecentlyUsedCache.java
new file mode 100644
index 0000000..6d18cf5
--- /dev/null
+++ b/main/src/cgeo/geocaching/utils/LeastRecentlyUsedCache.java
@@ -0,0 +1,24 @@
+package cgeo.geocaching.utils;
+
+import java.util.LinkedHashMap;
+
+/**
+ * Base class for a caching cache. Don't mix up with a geocache !
+ *
+ * @author blafoo
+ */
+public class LeastRecentlyUsedCache<K, V> extends LinkedHashMap<K, V> {
+
+ private static final long serialVersionUID = -5077882607489806620L;
+ private final int maxEntries;
+
+ public LeastRecentlyUsedCache(int maxEntries) {
+ this.maxEntries = maxEntries;
+ }
+
+ @Override
+ protected boolean removeEldestEntry(java.util.Map.Entry<K, V> eldest) {
+ return size() > maxEntries;
+ }
+
+}
diff --git a/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java b/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java
index e8f524b..9991a50 100644
--- a/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java
+++ b/main/src/cgeo/geocaching/utils/UnknownTagsHandler.java
@@ -10,12 +10,20 @@ import android.text.style.StrikethroughSpan;
public class UnknownTagsHandler implements TagHandler {
private static final int UNDEFINED_POSITION = -1;
+ private static int countCells = 0;
int strikePos = UNDEFINED_POSITION;
+ private boolean tableDetected = false;
public void handleTag(boolean opening, String tag, Editable output,
XMLReader xmlReader) {
if (tag.equalsIgnoreCase("strike") || tag.equals("s")) {
handleStrike(opening, output);
+ } else if (tag.equalsIgnoreCase("table")) {
+ handleTable();
+ } else if (tag.equalsIgnoreCase("td")) {
+ handleTd(opening, output);
+ } else if (tag.equalsIgnoreCase("tr")) {
+ handleTr(opening, output);
}
}
@@ -30,4 +38,30 @@ public class UnknownTagsHandler implements TagHandler {
}
}
}
+
+ public boolean isTableDetected() {
+ return tableDetected;
+ }
+
+ private void handleTable() {
+ tableDetected = true;
+ }
+
+ private static void handleTd(boolean opening, Editable output) {
+ // insert bar for each table column, see https://en.wikipedia.org/wiki/Box-drawing_characters
+ if (opening) {
+ if (countCells++ > 0) {
+ output.append('┆');
+ }
+ }
+ }
+
+ private static void handleTr(boolean opening, Editable output) {
+ // insert new line for each table row
+ if (opening) {
+ output.append('\n');
+ countCells = 0;
+ }
+ }
+
}
diff --git a/tests/src/cgeo/geocaching/cgBaseTest.java b/tests/src/cgeo/geocaching/cgBaseTest.java
index f7a6f45..f286fb6 100644
--- a/tests/src/cgeo/geocaching/cgBaseTest.java
+++ b/tests/src/cgeo/geocaching/cgBaseTest.java
@@ -90,7 +90,12 @@ public class cgBaseTest extends AndroidTestCase {
public static void testHumanDistance() {
assertEquals("?", cgBase.getHumanDistance(null));
- assertEquals("123 km", cgBase.getHumanDistance(123.456f));
+ if (Settings.isUseMetricUnits()) {
+ assertEquals("123 km", cgBase.getHumanDistance(123.456f));
+ }
+ else {
+ assertEquals("77 mi", cgBase.getHumanDistance(123.456f));
+ }
}
public static void testWaypointsFromNote() {
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
index b883278..1bc3e25 100644
--- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
@@ -115,6 +115,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
private static void assertCacheProperties(cgCache cache) {
assertNotNull(cache);
assertFalse(cache.getLocation().startsWith(","));
+ assertTrue(cache.isReliableLatLon());
}
public void testImportGpxError() throws IOException {
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index b30dc8a..e69800b 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -68,6 +68,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertEquals("Baden-Württemberg, Germany", cache.getLocation());
assertEquals("Ein alter Kindheitstraum, ein Schatz auf einer unbewohnten Insel. A old dream of my childhood, a treasure on a lonely is", cache.getShortdesc());
assertTrue(new Geopoint(48.85968, 9.18740).isEqualTo(cache.getCoords()));
+ assertTrue(cache.isReliableLatLon());
}
public void testGc31j2h() throws IOException, ParserException {
@@ -80,6 +81,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
// no waypoints without importing waypoint file
assertEquals(0, cache.getWaypoints().size());
+ assertTrue(cache.isReliableLatLon());
}
public void testGc31j2hWpts() throws IOException, ParserException {