diff options
Diffstat (limited to 'main/src/cgeo/geocaching/maps')
16 files changed, 187 insertions, 127 deletions
diff --git a/main/src/cgeo/geocaching/maps/AbstractMap.java b/main/src/cgeo/geocaching/maps/AbstractMap.java index d9ee751..d341823 100644 --- a/main/src/cgeo/geocaching/maps/AbstractMap.java +++ b/main/src/cgeo/geocaching/maps/AbstractMap.java @@ -1,5 +1,6 @@ package cgeo.geocaching.maps; +import cgeo.geocaching.R; import cgeo.geocaching.maps.interfaces.MapActivityImpl; import android.app.Activity; @@ -50,7 +51,9 @@ public abstract class AbstractMap { } public boolean onCreateOptionsMenu(Menu menu) { - return mapActivity.superOnCreateOptionsMenu(menu); + final boolean result = mapActivity.superOnCreateOptionsMenu(menu); + mapActivity.getActivity().getMenuInflater().inflate(R.menu.map_activity, menu); + return result; } public boolean onPrepareOptionsMenu(Menu menu) { diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index d4754aa..0703dd8 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -609,7 +609,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto default: // DETAILED menu.findItem(R.id.menu_strategy_detailed).setChecked(true); } - } catch (Exception e) { + } catch (RuntimeException e) { Log.e("CGeoMap.onPrepareOptionsMenu", e); } @@ -948,7 +948,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto mapView.repaintRequired(overlayPosition); } } - } catch (Exception e) { + } catch (RuntimeException e) { Log.w("Failed to update location."); } } @@ -1179,33 +1179,29 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } searchResult = ConnectorFactory.searchByViewport(viewport.resize(0.8), tokens); - if (searchResult != null) { - downloaded = true; - if (searchResult.getError() == StatusCode.NOT_LOGGED_IN && Settings.isGCConnectorActive()) { - Login.login(); - tokens = null; - } else { - break; - } + downloaded = true; + if (searchResult.getError() == StatusCode.NOT_LOGGED_IN && Settings.isGCConnectorActive()) { + Login.login(); + tokens = null; + } else { + break; } count++; } while (count < 2); - if (searchResult != null) { - Set<Geocache> result = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); - CGeoMap.filter(result); - // update the caches - // first remove filtered out - final Set<String> filteredCodes = searchResult.getFilteredGeocodes(); - Log.d("Filtering out " + filteredCodes.size() + " caches: " + filteredCodes.toString()); - caches.removeAll(cgData.loadCaches(filteredCodes, LoadFlags.LOAD_CACHE_ONLY)); - cgData.removeCaches(filteredCodes, EnumSet.of(RemoveFlag.REMOVE_CACHE)); - // new collection type needs to remove first to refresh - caches.removeAll(result); - caches.addAll(result); - lastSearchResult = searchResult; - } + Set<Geocache> result = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); + CGeoMap.filter(result); + // update the caches + // first remove filtered out + final Set<String> filteredCodes = searchResult.getFilteredGeocodes(); + Log.d("Filtering out " + filteredCodes.size() + " caches: " + filteredCodes.toString()); + caches.removeAll(cgData.loadCaches(filteredCodes, LoadFlags.LOAD_CACHE_ONLY)); + cgData.removeCaches(filteredCodes, EnumSet.of(RemoveFlag.REMOVE_CACHE)); + // new collection type needs to remove first to refresh + caches.removeAll(result); + caches.addAll(result); + lastSearchResult = searchResult; //render displayExecutor.execute(new DisplayRunnable(viewport)); @@ -1422,7 +1418,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } sleep(delay); - } catch (Exception e) { + } catch (InterruptedException e) { // nothing } } @@ -1505,7 +1501,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto try { mapController.setCenter(mapItemFactory.getGeoPointBase(new Geopoint(mapState[0] / 1.0e6, mapState[1] / 1.0e6))); mapController.setZoom(mapState[2]); - } catch (Exception e) { + } catch (RuntimeException e) { // nothing at all } @@ -1529,7 +1525,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto if (viewport.getLatitudeSpan() != 0 && viewport.getLongitudeSpan() != 0) { mapController.zoomToSpan((int) (viewport.getLatitudeSpan() * 1e6), (int) (viewport.getLongitudeSpan() * 1e6)); } - } catch (Exception e) { + } catch (RuntimeException e) { // nothing at all } diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java index 8e117eb..8fbb3db 100644 --- a/main/src/cgeo/geocaching/maps/CachesOverlay.java +++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java @@ -4,7 +4,6 @@ import cgeo.geocaching.CachePopup; import cgeo.geocaching.Geocache; import cgeo.geocaching.IWaypoint; import cgeo.geocaching.R; -import cgeo.geocaching.settings.Settings; import cgeo.geocaching.WaypointPopup; import cgeo.geocaching.cgData; import cgeo.geocaching.activity.Progress; @@ -19,11 +18,13 @@ import cgeo.geocaching.maps.interfaces.MapItemFactory; import cgeo.geocaching.maps.interfaces.MapProjectionImpl; import cgeo.geocaching.maps.interfaces.MapProvider; import cgeo.geocaching.maps.interfaces.MapViewImpl; +import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.Log; import org.apache.commons.lang3.StringUtils; import android.content.Context; +import android.content.res.Resources.NotFoundException; import android.graphics.Canvas; import android.graphics.DashPathEffect; import android.graphics.Paint; @@ -121,6 +122,8 @@ public class CachesOverlay extends AbstractItemizedOverlay { try { lazyInitializeDrawingObjects(); canvas.setDrawFilter(setFilter); + final int height = canvas.getHeight(); + final int width = canvas.getWidth(); final int radius = calculateDrawingRadius(projection); final Point center = new Point(); @@ -130,16 +133,17 @@ public class CachesOverlay extends AbstractItemizedOverlay { final Geopoint itemCoord = item.getCoord().getCoords(); final GeoPointImpl itemGeo = mapItemFactory.getGeoPointBase(itemCoord); projection.toPixels(itemGeo, center); - - // dashed circle around the waypoint - blockedCircle.setColor(0x66BB0000); - blockedCircle.setStyle(Style.STROKE); - canvas.drawCircle(center.x, center.y, radius, blockedCircle); - - // filling the circle area with a transparent color - blockedCircle.setColor(0x44BB0000); - blockedCircle.setStyle(Style.FILL); - canvas.drawCircle(center.x, center.y, radius, blockedCircle); + if (center.x > -radius && center.y > -radius && center.x < width + radius && center.y < height + radius) { + // dashed circle around the waypoint + blockedCircle.setColor(0x66BB0000); + blockedCircle.setStyle(Style.STROKE); + canvas.drawCircle(center.x, center.y, radius, blockedCircle); + + // filling the circle area with a transparent color + blockedCircle.setColor(0x44BB0000); + blockedCircle.setStyle(Style.FILL); + canvas.drawCircle(center.x, center.y, radius, blockedCircle); + } } } canvas.setDrawFilter(removeFilter); @@ -243,7 +247,7 @@ public class CachesOverlay extends AbstractItemizedOverlay { } progress.dismiss(); - } catch (Exception e) { + } catch (NotFoundException e) { Log.e("CachesOverlay.onTap", e); if (progress != null) { progress.dismiss(); diff --git a/main/src/cgeo/geocaching/maps/MapProviderFactory.java b/main/src/cgeo/geocaching/maps/MapProviderFactory.java index 95ea265..a03fc47 100644 --- a/main/src/cgeo/geocaching/maps/MapProviderFactory.java +++ b/main/src/cgeo/geocaching/maps/MapProviderFactory.java @@ -1,11 +1,15 @@ package cgeo.geocaching.maps; import cgeo.geocaching.R; -import cgeo.geocaching.settings.Settings; +import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.maps.google.GoogleMapProvider; import cgeo.geocaching.maps.interfaces.MapProvider; import cgeo.geocaching.maps.interfaces.MapSource; import cgeo.geocaching.maps.mapsforge.MapsforgeMapProvider; +import cgeo.geocaching.settings.Settings; +import cgeo.geocaching.utils.Log; + +import org.apache.commons.lang3.StringUtils; import android.view.Menu; import android.view.SubMenu; @@ -26,13 +30,21 @@ public class MapProviderFactory { } public static boolean isGoogleMapsInstalled() { - boolean googleMaps = true; + // Check if API key is available + if (StringUtils.isBlank(cgeoapplication.getInstance().getString(R.string.maps_api_key))) { + Log.w("No Google API key available."); + return false; + } + + // Check if API is available try { Class.forName("com.google.android.maps.MapActivity"); } catch (ClassNotFoundException e) { - googleMaps = false; + return false; } - return googleMaps; + + // Assume that Google Maps is available and working + return true; } public static List<MapSource> getMapSources() { @@ -57,6 +69,12 @@ public class MapProviderFactory { parentMenu.setGroupCheckable(R.id.menu_group_map_sources, true, true); } + /** + * Return a map source by id. + * + * @param id the map source id + * @return the map source, or <tt>null</tt> if <tt>id</tt> does not correspond to a registered map source + */ public static MapSource getMapSource(int id) { for (MapSource mapSource : mapSources) { if (mapSource.getNumericalId() == id) { @@ -66,6 +84,15 @@ public class MapProviderFactory { return null; } + /** + * Return a map source if there is at least one. + * + * @return the first map source in the collection, or <tt>null</tt> if there are none registered + */ + public static MapSource getAnyMapSource() { + return mapSources.isEmpty() ? null : mapSources.get(0); + } + public static void registerMapSource(final MapSource mapSource) { mapSources.add(mapSource); } diff --git a/main/src/cgeo/geocaching/maps/PositionHistory.java b/main/src/cgeo/geocaching/maps/PositionHistory.java new file mode 100644 index 0000000..bc6779e --- /dev/null +++ b/main/src/cgeo/geocaching/maps/PositionHistory.java @@ -0,0 +1,63 @@ +package cgeo.geocaching.maps; + +import android.location.Location; + +import java.util.ArrayList; + +/** + * Map trail history + */ +public class PositionHistory { + + /** + * minimum distance between two recorded points of the trail + */ + private static final double MINIMUM_DISTANCE_METERS = 10.0; + + /** + * maximum number of positions to remember + */ + private static final int MAX_POSITIONS = 700; + + private ArrayList<Location> history = new ArrayList<Location>(); + + /** + * Adds the current position to the trail history to be able to show the trail on the map. + */ + void rememberTrailPosition(Location coordinates) { + if (coordinates.getAccuracy() >= 50f) { + return; + } + if (coordinates.getLatitude() == 0.0 && coordinates.getLongitude() == 0.0) { + return; + } + if (history.isEmpty()) { + history.add(coordinates); + return; + } + + Location historyRecent = history.get(history.size() - 1); + if (historyRecent.distanceTo(coordinates) <= MINIMUM_DISTANCE_METERS) { + return; + } + + history.add(coordinates); + + // avoid running out of memory + final int itemsToRemove = getHistory().size() - MAX_POSITIONS; + if (itemsToRemove > 0) { + for (int i = 0; i < itemsToRemove; i++) { + getHistory().remove(0); + } + } + } + + public ArrayList<Location> getHistory() { + return history; + } + + public void setHistory(ArrayList<Location> history) { + this.history = history; + } + +}
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/maps/PositionOverlay.java b/main/src/cgeo/geocaching/maps/PositionOverlay.java index c3a0834..b371eae 100644 --- a/main/src/cgeo/geocaching/maps/PositionOverlay.java +++ b/main/src/cgeo/geocaching/maps/PositionOverlay.java @@ -1,7 +1,6 @@ package cgeo.geocaching.maps; import cgeo.geocaching.R; -import cgeo.geocaching.settings.Settings; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.maps.interfaces.GeneralOverlay; import cgeo.geocaching.maps.interfaces.GeoPointImpl; @@ -9,6 +8,7 @@ import cgeo.geocaching.maps.interfaces.MapItemFactory; import cgeo.geocaching.maps.interfaces.MapProjectionImpl; import cgeo.geocaching.maps.interfaces.MapViewImpl; import cgeo.geocaching.maps.interfaces.OverlayImpl; +import cgeo.geocaching.settings.Settings; import android.app.Activity; import android.graphics.Bitmap; @@ -37,10 +37,7 @@ public class PositionOverlay implements GeneralOverlay { private int heightArrowHalf = 0; private PaintFlagsDrawFilter setfil = null; private PaintFlagsDrawFilter remfil = null; - private Location historyRecent = null; - private ArrayList<Location> history = new ArrayList<Location>(); - private Point historyPointN = new Point(); - private Point historyPointP = new Point(); + private PositionHistory positionHistory = new PositionHistory(); private Activity activity; private MapItemFactory mapItemFactory = null; private OverlayImpl ovlImpl = null; @@ -139,67 +136,44 @@ public class PositionOverlay implements GeneralOverlay { accuracyCircle.setStyle(Style.FILL); canvas.drawCircle(center.x, center.y, radius, accuracyCircle); - if (coordinates.getAccuracy() < 50f && ((historyRecent != null && historyRecent.distanceTo(coordinates) > 5.0) || historyRecent == null)) { - if (historyRecent != null) { - history.add(historyRecent); - } - historyRecent = coordinates; - - int toRemove = history.size() - 700; - - if (toRemove > 0) { - for (int cnt = 0; cnt < toRemove; cnt++) { - history.remove(cnt); - } - } - } + positionHistory.rememberTrailPosition(coordinates); if (Settings.isMapTrail()) { - int size = history.size(); + // always add current position to drawn history to have a closed connection + final ArrayList<Location> paintHistory = new ArrayList<Location>(positionHistory.getHistory()); + paintHistory.add(coordinates); + + int size = paintHistory.size(); if (size > 1) { int alphaCnt = size - 201; if (alphaCnt < 1) { alphaCnt = 1; } + Point pointNow = new Point(); + Point pointPrevious = new Point(); + Location prev = paintHistory.get(0); + projection.toPixels(mapItemFactory.getGeoPointBase(new Geopoint(prev)), pointPrevious); + for (int cnt = 1; cnt < size; cnt++) { - Location prev = history.get(cnt - 1); - Location now = history.get(cnt); - - if (prev != null && now != null) { - projection.toPixels(mapItemFactory.getGeoPointBase(new Geopoint(prev)), historyPointP); - projection.toPixels(mapItemFactory.getGeoPointBase(new Geopoint(now)), historyPointN); - - int alpha; - if ((alphaCnt - cnt) > 0) { - alpha = 255 / (alphaCnt - cnt); - } - else { - alpha = 255; - } - - historyLineShadow.setAlpha(alpha); - historyLine.setAlpha(alpha); - - canvas.drawLine(historyPointP.x, historyPointP.y, historyPointN.x, historyPointN.y, historyLineShadow); - canvas.drawLine(historyPointP.x, historyPointP.y, historyPointN.x, historyPointN.y, historyLine); - } - } - } + Location now = paintHistory.get(cnt); + projection.toPixels(mapItemFactory.getGeoPointBase(new Geopoint(now)), pointNow); - if (size > 0) { - Location prev = history.get(size - 1); - Location now = coordinates; + int alpha; + if ((alphaCnt - cnt) > 0) { + alpha = 255 / (alphaCnt - cnt); + } + else { + alpha = 255; + } - if (prev != null && now != null) { - projection.toPixels(mapItemFactory.getGeoPointBase(new Geopoint(prev)), historyPointP); - projection.toPixels(mapItemFactory.getGeoPointBase(new Geopoint(now)), historyPointN); + historyLineShadow.setAlpha(alpha); + historyLine.setAlpha(alpha); - historyLineShadow.setAlpha(255); - historyLine.setAlpha(255); + canvas.drawLine(pointPrevious.x, pointPrevious.y, pointNow.x, pointNow.y, historyLineShadow); + canvas.drawLine(pointPrevious.x, pointPrevious.y, pointNow.x, pointNow.y, historyLine); - canvas.drawLine(historyPointP.x, historyPointP.y, historyPointN.x, historyPointN.y, historyLineShadow); - canvas.drawLine(historyPointP.x, historyPointP.y, historyPointN.x, historyPointN.y, historyLine); + pointPrevious.set(pointNow.x, pointNow.y); } } } @@ -230,10 +204,10 @@ public class PositionOverlay implements GeneralOverlay { } public ArrayList<Location> getHistory() { - return history; + return positionHistory.getHistory(); } - public void setHistory(ArrayList<Location> inHistory) { - history = inHistory; + public void setHistory(ArrayList<Location> history) { + positionHistory.setHistory(history); } } diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java b/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java index dcff363..a98241f 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java @@ -1,6 +1,5 @@ package cgeo.geocaching.maps.google; -import cgeo.geocaching.R; import cgeo.geocaching.activity.FilteredActivity; import cgeo.geocaching.maps.AbstractMap; import cgeo.geocaching.maps.CGeoMap; @@ -84,9 +83,7 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F @Override public boolean superOnCreateOptionsMenu(Menu menu) { - final boolean result = super.onCreateOptionsMenu(menu); - getMenuInflater().inflate(R.menu.map_activity, menu); - return result; + return super.onCreateOptionsMenu(menu); } @Override diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapView.java b/main/src/cgeo/geocaching/maps/google/GoogleMapView.java index 6e5406e..3cf258e 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleMapView.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleMapView.java @@ -14,7 +14,7 @@ import cgeo.geocaching.maps.interfaces.MapProjectionImpl; import cgeo.geocaching.maps.interfaces.MapViewImpl; import cgeo.geocaching.maps.interfaces.OnMapDragListener; import cgeo.geocaching.maps.interfaces.OverlayImpl; -import cgeo.geocaching.maps.interfaces.OverlayImpl.overlayType; +import cgeo.geocaching.maps.interfaces.OverlayImpl.OverlayType; import cgeo.geocaching.utils.Log; import com.google.android.maps.GeoPoint; @@ -121,7 +121,7 @@ public class GoogleMapView extends MapView implements MapViewImpl { @Override public PositionOverlay createAddPositionOverlay(Activity activity) { - GoogleOverlay ovl = new GoogleOverlay(activity, overlayType.PositionOverlay); + GoogleOverlay ovl = new GoogleOverlay(activity, OverlayType.PositionOverlay); getOverlays().add(ovl); return (PositionOverlay) ovl.getBase(); } @@ -129,7 +129,7 @@ public class GoogleMapView extends MapView implements MapViewImpl { @Override public ScaleOverlay createAddScaleOverlay(Activity activity) { - GoogleOverlay ovl = new GoogleOverlay(activity, overlayType.ScaleOverlay); + GoogleOverlay ovl = new GoogleOverlay(activity, OverlayType.ScaleOverlay); getOverlays().add(ovl); return (ScaleOverlay) ovl.getBase(); } diff --git a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java index 773f9ff..bf4f606 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java @@ -20,7 +20,7 @@ public class GoogleOverlay extends Overlay implements OverlayImpl { private GeneralOverlay overlayBase = null; private Lock lock = new ReentrantLock(); - public GoogleOverlay(Activity activityIn, overlayType ovlType) { + public GoogleOverlay(Activity activityIn, OverlayType ovlType) { switch (ovlType) { case PositionOverlay: overlayBase = new PositionOverlay(activityIn, this); diff --git a/main/src/cgeo/geocaching/maps/interfaces/OverlayImpl.java b/main/src/cgeo/geocaching/maps/interfaces/OverlayImpl.java index 115b692..a17b5fb 100644 --- a/main/src/cgeo/geocaching/maps/interfaces/OverlayImpl.java +++ b/main/src/cgeo/geocaching/maps/interfaces/OverlayImpl.java @@ -6,7 +6,7 @@ package cgeo.geocaching.maps.interfaces; */ public interface OverlayImpl { - public enum overlayType { + public enum OverlayType { PositionOverlay, ScaleOverlay } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java index 232fe3c..a0384b8 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java @@ -1,6 +1,5 @@ package cgeo.geocaching.maps.mapsforge; -import cgeo.geocaching.R; import cgeo.geocaching.activity.FilteredActivity; import cgeo.geocaching.maps.AbstractMap; import cgeo.geocaching.maps.CGeoMap; @@ -79,9 +78,7 @@ public class MapsforgeMapActivity extends MapActivity implements MapActivityImpl @Override public boolean superOnCreateOptionsMenu(Menu menu) { - final boolean result = super.onCreateOptionsMenu(menu); - getMenuInflater().inflate(R.menu.map_activity, menu); - return result; + return super.onCreateOptionsMenu(menu); } @Override diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java index 7c6865d..d099b79 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java @@ -1,7 +1,6 @@ package cgeo.geocaching.maps.mapsforge; import cgeo.geocaching.R; -import cgeo.geocaching.settings.Settings; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.maps.AbstractMapProvider; import cgeo.geocaching.maps.MapProviderFactory; @@ -10,6 +9,7 @@ import cgeo.geocaching.maps.interfaces.MapProvider; import cgeo.geocaching.maps.interfaces.MapSource; import cgeo.geocaching.maps.mapsforge.v024.MapsforgeMapActivity024; import cgeo.geocaching.maps.mapsforge.v024.MapsforgeMapItemFactory024; +import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.Log; import org.apache.commons.lang3.StringUtils; @@ -169,9 +169,5 @@ public final class MapsforgeMapProvider extends AbstractMapProvider { final String mapName = StringUtils.capitalize(StringUtils.substringBeforeLast(new File(mapFile).getName(), ".")); registerMapSource(new OfflineMapSource(mapFile, this, mapName + " (" + resources.getString(R.string.map_source_osm_offline) + ")", MapGeneratorInternal.DATABASE_RENDERER)); } - // have a default entry, if no map files are available. otherwise we cannot select "offline" in the settings - if (offlineMaps.isEmpty()) { - registerMapSource(new OfflineMapSource("", this, resources.getString(R.string.map_source_osm_offline), MapGeneratorInternal.DATABASE_RENDERER)); - } } } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java index 2b0c1f7..dc4e82c 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java @@ -1,7 +1,6 @@ package cgeo.geocaching.maps.mapsforge; import cgeo.geocaching.R; -import cgeo.geocaching.settings.Settings; import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.maps.CachesOverlay; import cgeo.geocaching.maps.PositionOverlay; @@ -14,7 +13,8 @@ import cgeo.geocaching.maps.interfaces.MapSource; import cgeo.geocaching.maps.interfaces.MapViewImpl; import cgeo.geocaching.maps.interfaces.OnMapDragListener; import cgeo.geocaching.maps.interfaces.OverlayImpl; -import cgeo.geocaching.maps.interfaces.OverlayImpl.overlayType; +import cgeo.geocaching.maps.interfaces.OverlayImpl.OverlayType; +import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.Log; import org.apache.commons.lang3.StringUtils; @@ -46,6 +46,9 @@ public class MapsforgeMapView extends MapView implements MapViewImpl { public MapsforgeMapView(Context context, AttributeSet attrs) { super(context, attrs); gestureDetector = new GestureDetector(context, new GestureListener()); + if (Settings.isScaleMapsforgeText()) { + this.setTextScale(getResources().getDisplayMetrics().density); + } } @Override @@ -109,14 +112,14 @@ public class MapsforgeMapView extends MapView implements MapViewImpl { @Override public PositionOverlay createAddPositionOverlay(Activity activity) { - MapsforgeOverlay ovl = new MapsforgeOverlay(activity, overlayType.PositionOverlay); + MapsforgeOverlay ovl = new MapsforgeOverlay(activity, OverlayType.PositionOverlay); getOverlays().add(ovl); return (PositionOverlay) ovl.getBase(); } @Override public ScaleOverlay createAddScaleOverlay(Activity activity) { - MapsforgeOverlay ovl = new MapsforgeOverlay(activity, overlayType.ScaleOverlay); + MapsforgeOverlay ovl = new MapsforgeOverlay(activity, OverlayType.ScaleOverlay); getOverlays().add(ovl); return (ScaleOverlay) ovl.getBase(); } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java index dd7fb75..a94b988 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java @@ -21,7 +21,7 @@ public class MapsforgeOverlay extends Overlay implements OverlayImpl { private GeneralOverlay overlayBase = null; private Lock lock = new ReentrantLock(); - public MapsforgeOverlay(Activity activityIn, OverlayImpl.overlayType ovlType) { + public MapsforgeOverlay(Activity activityIn, OverlayImpl.OverlayType ovlType) { switch (ovlType) { case PositionOverlay: diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java index 8e3a4d8..a074e70 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java @@ -13,7 +13,7 @@ import cgeo.geocaching.maps.interfaces.MapProjectionImpl; import cgeo.geocaching.maps.interfaces.MapViewImpl; import cgeo.geocaching.maps.interfaces.OnMapDragListener; import cgeo.geocaching.maps.interfaces.OverlayImpl; -import cgeo.geocaching.maps.interfaces.OverlayImpl.overlayType; +import cgeo.geocaching.maps.interfaces.OverlayImpl.OverlayType; import cgeo.geocaching.utils.Log; import org.mapsforge.android.mapsold.GeoPoint; @@ -103,14 +103,14 @@ public class MapsforgeMapView024 extends MapView implements MapViewImpl { @Override public PositionOverlay createAddPositionOverlay(Activity activity) { - MapsforgeOverlay ovl = new MapsforgeOverlay(activity, overlayType.PositionOverlay); + MapsforgeOverlay ovl = new MapsforgeOverlay(activity, OverlayType.PositionOverlay); getOverlays().add(ovl); return (PositionOverlay) ovl.getBase(); } @Override public ScaleOverlay createAddScaleOverlay(Activity activity) { - MapsforgeOverlay ovl = new MapsforgeOverlay(activity, overlayType.ScaleOverlay); + MapsforgeOverlay ovl = new MapsforgeOverlay(activity, OverlayType.ScaleOverlay); getOverlays().add(ovl); return (ScaleOverlay) ovl.getBase(); } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java index d40b539..bdaac98 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java @@ -21,7 +21,7 @@ public class MapsforgeOverlay extends Overlay implements OverlayImpl { private GeneralOverlay overlayBase = null; private Lock lock = new ReentrantLock(); - public MapsforgeOverlay(Activity activityIn, OverlayImpl.overlayType ovlType) { + public MapsforgeOverlay(Activity activityIn, OverlayImpl.OverlayType ovlType) { switch (ovlType) { case PositionOverlay: |
