aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/CacheDetailActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/CacheDetailActivity.java')
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java37
1 files changed, 15 insertions, 22 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index f5e2f52..d3bb28a 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -14,13 +14,13 @@ import cgeo.geocaching.enumerations.LoadFlags.SaveFlag;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.GeopointFormatter;
-import cgeo.geocaching.geopoint.HumanDistance;
-import cgeo.geocaching.geopoint.IConversion;
+import cgeo.geocaching.geopoint.Units;
import cgeo.geocaching.network.HtmlImage;
import cgeo.geocaching.network.Parameters;
import cgeo.geocaching.ui.CacheDetailsCreator;
import cgeo.geocaching.ui.DecryptTextClickListener;
import cgeo.geocaching.ui.Formatter;
+import cgeo.geocaching.ui.LoggingUI;
import cgeo.geocaching.utils.BaseUtils;
import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.ClipboardUtils;
@@ -46,7 +46,6 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
@@ -139,20 +138,13 @@ public class CacheDetailActivity extends AbstractActivity {
final StringBuilder dist = new StringBuilder();
if (geo.getCoords() != null && cache != null && cache.getCoords() != null) {
- dist.append(HumanDistance.getHumanDistance(geo.getCoords().distanceTo(cache.getCoords())));
+ dist.append(Units.getDistanceFromKilometers(geo.getCoords().distanceTo(cache.getCoords())));
}
if (cache != null && cache.getElevation() != null) {
if (geo.getAltitude() != 0.0) {
- final double diff = cache.getElevation() - geo.getAltitude();
- dist.append(diff >= 0 ? " ↗" : " ↘");
- if (Settings.isUseMetricUnits()) {
- dist.append(Math.abs((int) diff));
- dist.append(" m");
- } else {
- dist.append(Math.abs((int) (diff * IConversion.METERS_TO_FEET)));
- dist.append(" ft");
- }
+ final float diff = (float) (cache.getElevation() - geo.getAltitude());
+ dist.append(' ').append(Units.getElevation(diff));
}
}
@@ -565,7 +557,7 @@ public class CacheDetailActivity extends AbstractActivity {
GeneralAppsFactory.addMenuItems(subMenu, cache);
menu.add(1, MENU_CALENDAR, 0, res.getString(R.string.cache_menu_event)).setIcon(R.drawable.ic_menu_agenda); // add event to calendar
- addVisitMenu(menu, cache);
+ LoggingUI.addMenuItems(menu, cache);
menu.add(0, MENU_CACHES_AROUND, 0, res.getString(R.string.cache_menu_around)).setIcon(R.drawable.ic_menu_rotate); // caches around
menu.add(1, MENU_BROWSER, 0, res.getString(R.string.cache_menu_browser)).setIcon(R.drawable.ic_menu_globe); // browser
menu.add(0, MENU_SHARE, 0, res.getString(R.string.cache_menu_share)).setIcon(R.drawable.ic_menu_share); // share cache
@@ -593,10 +585,6 @@ public class CacheDetailActivity extends AbstractActivity {
case MENU_DEFAULT_NAVIGATION:
startDefaultNavigation();
return true;
- case MENU_LOG_VISIT:
- refreshOnResume = true;
- cache.logVisit(this);
- return true;
case MENU_BROWSER:
cache.openInBrowser(this);
return true;
@@ -619,8 +607,11 @@ public class CacheDetailActivity extends AbstractActivity {
if (GeneralAppsFactory.onMenuItemSelected(item, this, cache)) {
return true;
}
+ if (LoggingUI.onMenuItemSelected(item, this, cache)) {
+ refreshOnResume = true;
+ return true;
+ }
- cache.logOffline(this, LogType.getById(menuItem - MENU_LOG_VISIT_OFFLINE));
return true;
}
@@ -1830,7 +1821,7 @@ public class CacheDetailActivity extends AbstractActivity {
}
private Bitmap decode(final cgCache cache) {
- return BitmapFactory.decodeFile(StaticMapsProvider.getMapFile(cache.getGeocode(), "preview", false).getPath());
+ return StaticMapsProvider.getPreviewMap(cache.getGeocode());
}
@Override
@@ -2027,8 +2018,10 @@ public class CacheDetailActivity extends AbstractActivity {
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)) {
+ // If description has an HTML construct which may be problematic to render, add a note at the end of the long description.
+ // Technically, it may not be a table, but a pre, which has the same problems as a table, so the message is ok even though
+ // sometimes technically incorrect.
+ if (unknownTagsHandler.isProblematicDetected() && descriptionView == view.findViewById(R.id.longdesc)) {
final int startPos = description.length();
((Editable) description).append("\n\n").append(res.getString(R.string.cache_description_table_note));
((Editable) description).setSpan(new StyleSpan(Typeface.ITALIC), startPos, description.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);