From ac9a84e8bb5dc43a5d72840eaa325c5e99ac610a Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 8 Mar 2012 22:03:48 +0000 Subject: Beginings of a welcome dialog, and overlay improvements. --- src/net/cbaines/suma/BuildingNumOverlay.java | 58 +++++++++++++--------------- 1 file changed, 27 insertions(+), 31 deletions(-) (limited to 'src/net/cbaines/suma/BuildingNumOverlay.java') diff --git a/src/net/cbaines/suma/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java index f11a166..b541aa1 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.
+ * Draw a marker on each of our items. populate() must have been called first.
*
- * 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.
+ * 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.
*
- * 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.
+ * 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.
*
- * The focused item is always drawn last, which puts it visually on top of - * the other items.
+ * The focused item is always drawn last, which puts it visually on top of the other items.
* * @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 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) { @@ -265,19 +254,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 +307,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))); } } -- cgit v1.2.3