aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/BuildingNumOverlay.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/BuildingNumOverlay.java')
-rw-r--r--src/net/cbaines/suma/BuildingNumOverlay.java66
1 files changed, 35 insertions, 31 deletions
diff --git a/src/net/cbaines/suma/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java
index f11a166..8ec5ec4 100644
--- a/src/net/cbaines/suma/BuildingNumOverlay.java
+++ b/src/net/cbaines/suma/BuildingNumOverlay.java
@@ -94,33 +94,24 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
}
/**
- * Draw a marker on each of our items. populate() must have been called
- * first.<br/>
+ * Draw a marker on each of our items. populate() must have been called first.<br/>
* <br/>
- * The marker will be drawn twice for each Item in the Overlay--once in the
- * shadow phase, skewed and darkened, then again in the non-shadow phase.
- * The bottom-center of the marker will be aligned with the geographical
- * coordinates of the Item.<br/>
+ * The marker will be drawn twice for each Item in the Overlay--once in the shadow phase, skewed and darkened, then again in
+ * the non-shadow phase. The bottom-center of the marker will be aligned with the geographical coordinates of the Item.<br/>
* <br/>
- * The order of drawing may be changed by overriding the getIndexToDraw(int)
- * method. An item may provide an alternate marker via its
- * OverlayItem.getMarker(int) method. If that method returns null, the
- * default marker is used.<br/>
+ * The order of drawing may be changed by overriding the getIndexToDraw(int) method. An item may provide an alternate marker
+ * via its OverlayItem.getMarker(int) method. If that method returns null, the default marker is used.<br/>
* <br/>
- * The focused item is always drawn last, which puts it visually on top of
- * the other items.<br/>
+ * The focused item is always drawn last, which puts it visually on top of the other items.<br/>
*
* @param canvas
- * the Canvas upon which to draw. Note that this may already have
- * a transformation applied, so be sure to leave it the way you
- * found it
+ * the Canvas upon which to draw. Note that this may already have a transformation applied, so be sure to leave it
+ * the way you found it
* @param mapView
- * the MapView that requested the draw. Use
- * MapView.getProjection() to convert between on-screen pixels
- * and latitude/longitude pairs
+ * the MapView that requested the draw. Use MapView.getProjection() to convert between on-screen pixels and
+ * latitude/longitude pairs
* @param shadow
- * if true, draw the shadow layer. If false, draw the overlay
- * contents.
+ * if true, draw the shadow layer. If false, draw the overlay contents.
*/
@Override
public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
@@ -144,8 +135,7 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
final SharedPreferences favouritesPrefs = context.getSharedPreferences(FAVOURITES_PREFERENCES, 0);
/*
- * Draw in backward cycle, so the items with the least index are on the
- * front.
+ * Draw in backward cycle, so the items with the least index are on the front.
*/
for (Iterator<Building> buildingIter = buildings.iterator(); buildingIter.hasNext();) {
final Building building = buildingIter.next();
@@ -219,8 +209,7 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
if (showIdentifiers) {
str += " (" + building.id + ")";
}
- context.makeToast(str, context.getResources().getString(R.string.map_activity_toast_help_message),
- Toast.LENGTH_SHORT);
+ context.makeToast(str, context.getResources().getString(R.string.map_activity_toast_help_message), Toast.LENGTH_SHORT);
return true;
}
@@ -230,7 +219,7 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
public boolean onDoubleTap(final MotionEvent event, final MapView mapView) {
if (!this.isEnabled())
return false;
-
+
Building building = getSelectedItem(event, mapView);
if (building == null) {
@@ -256,6 +245,14 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
if (!this.isEnabled())
return false;
+ int pointerCount = event.getPointerCount();
+ if (pointerCount > 1) {
+ Log.v(TAG, "Detected a zoom " + pointerCount);
+ return false;
+ } else {
+ Log.v(TAG, "Zoom not detected " + pointerCount);
+ }
+
final Building building = getSelectedItem(event, mapView);
if (building == null) {
@@ -265,19 +262,27 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
Log.v(TAG, "building Pressed " + building.id);
final SharedPreferences favouritesPrefs = context.getSharedPreferences(FAVOURITES_PREFERENCES, 0);
+ // final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
if (favouritesPrefs.getBoolean(building.id, false)) {
favouritesPrefs.edit().remove(building.id).commit();
- context.makeToast(building.id + " removed from favourites", Toast.LENGTH_SHORT);
+ // if (sharedPrefs.getBoolean(SHOW_IDENTIFIERS, SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT)) {
+ context.makeToast(building.name + " removed from favourites", "(" + building.id + ")", Toast.LENGTH_SHORT);
+ // } else {
+ // context.makeToast(building.name + " removed from favourites", Toast.LENGTH_SHORT);
+ // }
} else {
- context.makeToast(building.id + " made a favourite", Toast.LENGTH_SHORT);
+ // if (sharedPrefs.getBoolean(SHOW_IDENTIFIERS, SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT)) {
+ context.makeToast(building.name + " added to favourites", "(" + building.id + ")", Toast.LENGTH_SHORT);
+ // } else {
+ // context.makeToast(building.name + " added to favourites", Toast.LENGTH_SHORT);
+ // }
favouritesPrefs.edit().putBoolean(building.id, true).commit();
}
- Collections.sort(buildings,
- new POIFavouriteComparator(context.getSharedPreferences(FAVOURITES_PREFERENCES, 0)));
+ Collections.sort(buildings, new POIFavouriteComparator(context.getSharedPreferences(FAVOURITES_PREFERENCES, 0)));
mapView.invalidate();
@@ -310,8 +315,7 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.i(TAG, "Got a favourites change in the BuildingNumOverlay for key " + key);
- Collections
- .sort(buildings, new POIFavouriteComparator(context.getSharedPreferences(FAVOURITES_PREFERENCES, 0)));
+ Collections.sort(buildings, new POIFavouriteComparator(context.getSharedPreferences(FAVOURITES_PREFERENCES, 0)));
}
}