From 449b2b4709260db6c645befc18c45f61070254b3 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Mon, 11 Mar 2013 02:22:46 +0100 Subject: [PATCH] - get rid of some osmdroid cruft - move default marker to 'res' --- res/.gitignore | 1 - .../drawable}/marker_default.png | Bin .../drawable}/marker_default_focused_base.png | Bin res/drawable/pin.png | Bin 0 -> 1725 bytes .../overlay/DefaultResourceProxyImpl.java | 174 ------------------ .../oscim/overlay/ItemizedIconOverlay.java | 23 +-- src/org/oscim/overlay/ItemizedOverlay.java | 9 +- src/org/oscim/overlay/MapViewConstants.java | 51 ----- src/org/oscim/overlay/Overlay.java | 21 +-- src/org/oscim/overlay/OverlayConstants.java | 31 ---- src/org/oscim/overlay/PathOverlay.java | 2 +- src/org/oscim/overlay/ResourceProxy.java | 82 --------- 12 files changed, 12 insertions(+), 382 deletions(-) delete mode 100644 res/.gitignore rename {src/org/oscim/overlay => res/drawable}/marker_default.png (100%) rename {src/org/oscim/overlay => res/drawable}/marker_default_focused_base.png (100%) create mode 100644 res/drawable/pin.png delete mode 100644 src/org/oscim/overlay/DefaultResourceProxyImpl.java delete mode 100644 src/org/oscim/overlay/MapViewConstants.java delete mode 100644 src/org/oscim/overlay/OverlayConstants.java delete mode 100644 src/org/oscim/overlay/ResourceProxy.java diff --git a/res/.gitignore b/res/.gitignore deleted file mode 100644 index f935021a..00000000 --- a/res/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!.gitignore diff --git a/src/org/oscim/overlay/marker_default.png b/res/drawable/marker_default.png similarity index 100% rename from src/org/oscim/overlay/marker_default.png rename to res/drawable/marker_default.png diff --git a/src/org/oscim/overlay/marker_default_focused_base.png b/res/drawable/marker_default_focused_base.png similarity index 100% rename from src/org/oscim/overlay/marker_default_focused_base.png rename to res/drawable/marker_default_focused_base.png diff --git a/res/drawable/pin.png b/res/drawable/pin.png new file mode 100644 index 0000000000000000000000000000000000000000..46c70185a9cce81511db93eaa2a518d00b4fdef6 GIT binary patch literal 1725 z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rkfOHtAFd{^2EHc$Mk&$*PLL1={ z&I}DNh{*Vw*7SHDSz`#Sy?kb9_>=ZPw#T6MQa+Y3rrIUzETp{;S|zl1oEsXRtXO-o zU<_qzC(aEGUzavf+RDlLz7ZMCR7=fB!^cxQIca~qHZ(j@GUkofhKApL5WoKeM3sGj T{S(|)00000NkvXXu0mjfoL5k6 literal 0 HcmV?d00001 diff --git a/src/org/oscim/overlay/DefaultResourceProxyImpl.java b/src/org/oscim/overlay/DefaultResourceProxyImpl.java deleted file mode 100644 index a8da571e..00000000 --- a/src/org/oscim/overlay/DefaultResourceProxyImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2012 osmdroid - * Copyright 2013 Hannes Janetzek - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.overlay; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.util.DisplayMetrics; - -public class DefaultResourceProxyImpl implements ResourceProxy, MapViewConstants { - // private static final String TAG = DefaultResourceProxyImpl.class.getSimpleName(); - - private DisplayMetrics mDisplayMetrics; - - /** - * Constructor. - * - * @param pContext - * Used to get the display metrics that are used for scaling the - * bitmaps returned by {@@link getBitmap}. Can be null, - * in which case the bitmaps are not scaled. - */ - public DefaultResourceProxyImpl(final Context pContext) { - if (pContext != null) { - mDisplayMetrics = pContext.getResources().getDisplayMetrics(); - // if (DEBUGMODE) { - // logger.debug("mDisplayMetrics=" + mDisplayMetrics); - // } - } - } - - @Override - public String getString(final string pResId) { - switch (pResId) { - case mapnik: - return "Mapnik"; - case cyclemap: - return "Cycle Map"; - case public_transport: - return "Public transport"; - case base: - return "OSM base layer"; - case topo: - return "Topographic"; - case hills: - return "Hills"; - case cloudmade_standard: - return "CloudMade (Standard tiles)"; - case cloudmade_small: - return "CloudMade (small tiles)"; - case mapquest_osm: - return "Mapquest"; - case mapquest_aerial: - return "Mapquest Aerial"; - case bing: - return "Bing"; - case fiets_nl: - return "OpenFietsKaart overlay"; - case base_nl: - return "Netherlands base overlay"; - case roads_nl: - return "Netherlands roads overlay"; - case unknown: - return "Unknown"; - case format_distance_meters: - return "%s m"; - case format_distance_kilometers: - return "%s km"; - case format_distance_miles: - return "%s mi"; - case format_distance_nautical_miles: - return "%s nm"; - case format_distance_feet: - return "%s ft"; - case online_mode: - return "Online mode"; - case offline_mode: - return "Offline mode"; - case my_location: - return "My location"; - case compass: - return "Compass"; - case map_mode: - return "Map mode"; - default: - throw new IllegalArgumentException(); - } - } - - @Override - public String getString(final string pResId, final Object... formatArgs) { - return String.format(getString(pResId), formatArgs); - } - - @Override - public Bitmap getBitmap(final bitmap pResId) { - InputStream is = null; - try { - final String resName = pResId.name() + ".png"; - is = getClass().getResourceAsStream(resName); - if (is == null) { - throw new IllegalArgumentException("Resource not found: " + resName); - } - BitmapFactory.Options options = null; - if (mDisplayMetrics != null) { - options = getBitmapOptions(); - } - return BitmapFactory.decodeStream(is, null, options); - } catch (final OutOfMemoryError e) { - // logger.error("OutOfMemoryError getting bitmap resource: " + - // pResId); - System.gc(); - // there's not much we can do here - // - when we load a bitmap from resources we expect it to be found - throw e; - } finally { - if (is != null) { - try { - is.close(); - } catch (final IOException ignore) { - } - } - } - } - - private BitmapFactory.Options getBitmapOptions() { - try { - final Field density = DisplayMetrics.class.getDeclaredField("DENSITY_DEFAULT"); - final Field inDensity = BitmapFactory.Options.class.getDeclaredField("inDensity"); - final Field inTargetDensity = BitmapFactory.Options.class - .getDeclaredField("inTargetDensity"); - final Field targetDensity = DisplayMetrics.class.getDeclaredField("densityDpi"); - final BitmapFactory.Options options = new BitmapFactory.Options(); - inDensity.setInt(options, density.getInt(null)); - inTargetDensity.setInt(options, targetDensity.getInt(mDisplayMetrics)); - return options; - } catch (final IllegalAccessException ex) { - // ignore - } catch (final NoSuchFieldException ex) { - // ignore - } - return null; - } - - @Override - public Drawable getDrawable(final bitmap pResId) { - return new BitmapDrawable(getBitmap(pResId)); - } - - @Override - public float getDisplayMetricsDensity() { - return mDisplayMetrics.density; - } - -} diff --git a/src/org/oscim/overlay/ItemizedIconOverlay.java b/src/org/oscim/overlay/ItemizedIconOverlay.java index 98649f35..0a45e45d 100644 --- a/src/org/oscim/overlay/ItemizedIconOverlay.java +++ b/src/org/oscim/overlay/ItemizedIconOverlay.java @@ -17,8 +17,8 @@ package org.oscim.overlay; import java.util.List; +import org.oscim.app.R; import org.oscim.core.MercatorProjection; -import org.oscim.overlay.ResourceProxy.bitmap; import org.oscim.view.MapView; import org.oscim.view.MapViewPosition; @@ -42,35 +42,22 @@ public class ItemizedIconOverlay extends ItemizedOverl final MapView mapView, final List pList, final Drawable pDefaultMarker, - final ItemizedIconOverlay.OnItemGestureListener pOnItemGestureListener, - final ResourceProxy pResourceProxy) { + final ItemizedIconOverlay.OnItemGestureListener pOnItemGestureListener) { - super(mapView, pDefaultMarker, pResourceProxy); + super(mapView, pDefaultMarker); this.mItemList = pList; this.mOnItemGestureListener = pOnItemGestureListener; populate(); } - public ItemizedIconOverlay( - final MapView mapView, - final List pList, - final ItemizedIconOverlay.OnItemGestureListener pOnItemGestureListener, - final ResourceProxy pResourceProxy) { - - this(mapView, pList, pResourceProxy.getDrawable(bitmap.marker_default), - pOnItemGestureListener, - pResourceProxy); - } - public ItemizedIconOverlay( final MapView mapView, final Context pContext, final List pList, final ItemizedIconOverlay.OnItemGestureListener pOnItemGestureListener) { - this(mapView, pList, new DefaultResourceProxyImpl(pContext) - .getDrawable(bitmap.marker_default), - pOnItemGestureListener, new DefaultResourceProxyImpl(pContext)); + this(mapView, pList, pContext.getResources().getDrawable(R.drawable.marker_default), + pOnItemGestureListener); } @Override diff --git a/src/org/oscim/overlay/ItemizedOverlay.java b/src/org/oscim/overlay/ItemizedOverlay.java index 46b79f5d..1054d2db 100644 --- a/src/org/oscim/overlay/ItemizedOverlay.java +++ b/src/org/oscim/overlay/ItemizedOverlay.java @@ -84,7 +84,7 @@ public abstract class ItemizedOverlay extends Overlay // note: this is called from GL-Thread. so check your syncs! @Override - public synchronized void update(MapPosition curPos, + public synchronized void update(MapPosition curPos, boolean positionChanged, boolean tilesChanged) { @@ -236,10 +236,9 @@ public abstract class ItemizedOverlay extends Overlay */ public abstract int size(); - public ItemizedOverlay(MapView mapView, final Drawable pDefaultMarker, final ResourceProxy - pResourceProxy) { + public ItemizedOverlay(MapView mapView, final Drawable pDefaultMarker) { - super(pResourceProxy); + super(); if (pDefaultMarker == null) { throw new IllegalArgumentException("You must pass a default marker to ItemizedOverlay."); @@ -247,8 +246,6 @@ public abstract class ItemizedOverlay extends Overlay this.mDefaultMarker = pDefaultMarker; - // mInternalItemList = new ArrayList(); - mMapView = mapView; mLayer = new ItemOverlay(mapView); diff --git a/src/org/oscim/overlay/MapViewConstants.java b/src/org/oscim/overlay/MapViewConstants.java deleted file mode 100644 index abdd77fe..00000000 --- a/src/org/oscim/overlay/MapViewConstants.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2012 osmdroid - * Copyright 2013 Hannes Janetzek - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ - -// Created by plusminus on 18:00:24 - 25.09.2008 -package org.oscim.overlay; - -/** - * This class contains constants used by the map view. - * - * @author Nicolas Gramlich - */ -public interface MapViewConstants { - // =========================================================== - // Final Fields - // =========================================================== - - public static final boolean DEBUGMODE = false; - - public static final int NOT_SET = Integer.MIN_VALUE; - - public static final int ANIMATION_SMOOTHNESS_LOW = 4; - public static final int ANIMATION_SMOOTHNESS_DEFAULT = 10; - public static final int ANIMATION_SMOOTHNESS_HIGH = 20; - - public static final int ANIMATION_DURATION_SHORT = 500; - public static final int ANIMATION_DURATION_DEFAULT = 1000; - public static final int ANIMATION_DURATION_LONG = 2000; - - /** Minimum Zoom Level */ - public static final int MINIMUM_ZOOMLEVEL = 0; - - /** - * Maximum Zoom Level - we use Integers to store zoom levels so overflow - * happens at 2^32 - 1, - * but we also have a tile size that is typically 2^8, so (32-1)-8-1 = 22 - */ - public static final int MAXIMUM_ZOOMLEVEL = 22; -} diff --git a/src/org/oscim/overlay/Overlay.java b/src/org/oscim/overlay/Overlay.java index 658c6f04..a42ccf8c 100644 --- a/src/org/oscim/overlay/Overlay.java +++ b/src/org/oscim/overlay/Overlay.java @@ -23,7 +23,6 @@ import org.oscim.core.MapPosition; import org.oscim.renderer.overlays.RenderOverlay; import org.oscim.view.MapView; -import android.content.Context; import android.graphics.Point; import android.view.KeyEvent; import android.view.MotionEvent; @@ -39,7 +38,7 @@ import android.view.MotionEvent; * * @author Nicolas Gramlich */ -public abstract class Overlay implements OverlayConstants { +public abstract class Overlay { // =========================================================== // Constants @@ -55,8 +54,8 @@ public abstract class Overlay implements OverlayConstants { // Fields // =========================================================== - protected final ResourceProxy mResourceProxy; - protected final float mScale; + //protected final ResourceProxy mResourceProxy; + //protected final float mScale; // private static final Rect mRect = new Rect(); private boolean mEnabled = true; @@ -72,20 +71,6 @@ public abstract class Overlay implements OverlayConstants { // =========================================================== public Overlay() { - mResourceProxy = null; - mScale = 1; - // mResourceProxy = new DefaultResourceProxyImpl(ctx); - // mScale = ctx.getResources().getDisplayMetrics().density; - } - - public Overlay(final Context ctx) { - mResourceProxy = new DefaultResourceProxyImpl(ctx); - mScale = ctx.getResources().getDisplayMetrics().density; - } - - public Overlay(final ResourceProxy pResourceProxy) { - mResourceProxy = pResourceProxy; - mScale = mResourceProxy.getDisplayMetricsDensity(); } // =========================================================== diff --git a/src/org/oscim/overlay/OverlayConstants.java b/src/org/oscim/overlay/OverlayConstants.java deleted file mode 100644 index 4d119d87..00000000 --- a/src/org/oscim/overlay/OverlayConstants.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012 osmdroid - * Copyright 2013 Hannes Janetzek - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.overlay; - -/** - * This class contains constants used by the overlays. - */ -public interface OverlayConstants { - // =========================================================== - // Final Fields - // =========================================================== - - public static final boolean DEBUGMODE = false; - - public static final int NOT_SET = Integer.MIN_VALUE; - - public static final int DEFAULT_ZOOMLEVEL_MINIMAP_DIFFERENCE = 3; -} diff --git a/src/org/oscim/overlay/PathOverlay.java b/src/org/oscim/overlay/PathOverlay.java index 7723b1c7..f6573acf 100644 --- a/src/org/oscim/overlay/PathOverlay.java +++ b/src/org/oscim/overlay/PathOverlay.java @@ -163,7 +163,7 @@ public class PathOverlay extends Overlay { } public PathOverlay(MapView mapView, final int color, final Context ctx) { - super(ctx); + super(); this.mPaint.setColor(color); this.mPaint.setStrokeWidth(2.0f); this.mPaint.setStyle(Paint.Style.STROKE); diff --git a/src/org/oscim/overlay/ResourceProxy.java b/src/org/oscim/overlay/ResourceProxy.java deleted file mode 100644 index 8439334d..00000000 --- a/src/org/oscim/overlay/ResourceProxy.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2012 osmdroid - * Copyright 2013 Hannes Janetzek - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.overlay; - -import android.graphics.Bitmap; -import android.graphics.drawable.Drawable; - -public interface ResourceProxy { - - public static enum string { - - // tile sources - mapnik, cyclemap, public_transport, base, topo, hills, cloudmade_small, cloudmade_standard, mapquest_osm, mapquest_aerial, bing, - - // overlays - fiets_nl, base_nl, roads_nl, - - // other stuff - unknown, format_distance_meters, format_distance_kilometers, format_distance_miles, format_distance_nautical_miles, format_distance_feet, online_mode, offline_mode, my_location, compass, map_mode, - - } - - public static enum bitmap { - - /** - * For testing - the image doesn't exist. - */ - unknown, - - center, direction_arrow, marker_default, marker_default_focused_base, navto_small, next, previous, person, - - /** - * Menu icons - */ - ic_menu_offline, ic_menu_mylocation, ic_menu_compass, ic_menu_mapmode - } - - String getString(string pResId); - - /** - * Use a string resource as a format definition, and format using the - * supplied format arguments. - * - * @param pResId - * ... - * @param formatArgs - * ... - * @return ... - */ - String getString(string pResId, Object... formatArgs); - - Bitmap getBitmap(bitmap pResId); - - /** - * Get a bitmap as a {@link Drawable} - * - * @param pResId - * ... - * @return ... - */ - Drawable getDrawable(bitmap pResId); - - /** - * Gets the density from the current screen's DisplayMetrics - * - * @return the screen's density - */ - float getDisplayMetricsDensity(); -}