aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/BusStopOverlay.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/BusStopOverlay.java')
-rw-r--r--src/net/cbaines/suma/BusStopOverlay.java47
1 files changed, 21 insertions, 26 deletions
diff --git a/src/net/cbaines/suma/BusStopOverlay.java b/src/net/cbaines/suma/BusStopOverlay.java
index b8f1077..254e03a 100644
--- a/src/net/cbaines/suma/BusStopOverlay.java
+++ b/src/net/cbaines/suma/BusStopOverlay.java
@@ -36,6 +36,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.preference.PreferenceManager;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Toast;
@@ -63,6 +64,8 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref
private boolean[] routes = new boolean[5];
+ private boolean showIdentifiers;
+
public BusStopOverlay(MapActivity context, List<BusStop> busStops) throws SQLException {
super(context);
@@ -71,6 +74,9 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref
marker = context.getResources().getDrawable(R.drawable.busstop);
favMarker = context.getResources().getDrawable(R.drawable.busstop_fav);
+ showIdentifiers = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SHOW_IDENTIFIERS,
+ SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT);
+
paint = new Paint();
paint.setStyle(Style.FILL);
paint.setStrokeWidth(6);
@@ -104,7 +110,8 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref
final SharedPreferences favouritesPreferences = 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 (int stopNum = 0; stopNum < busStops.size(); stopNum++) {
@@ -177,9 +184,9 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref
Log.e(TAG, "Unknown route code");
}
- canvas.drawRect(rectLeft, mCurScreenCoords.y + ((yOfsetPerMarker * makersPlaced) - (45 * scale)),
- rectRight, mCurScreenCoords.y + (yOfsetPerMarker * makersPlaced) - ((45 * scale) - markerYSize),
- paint);
+ canvas.drawRect(rectLeft, mCurScreenCoords.y
+ + ((yOfsetPerMarker * makersPlaced) - (45 * scale)), rectRight, mCurScreenCoords.y
+ + (yOfsetPerMarker * makersPlaced) - ((45 * scale) - markerYSize), paint);
makersPlaced++;
}
@@ -199,14 +206,12 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref
} else {
Log.i(TAG, "busStop Pressed " + busStop.id);
- if (context.activityToast == null) {
- context.activityToast = Toast
- .makeText(context, busStop.description + " (" + busStop.id + ")", Toast.LENGTH_SHORT);
- } else {
- context.activityToast.setDuration(Toast.LENGTH_SHORT);
- context.activityToast.setText(busStop.description + " (" + busStop.id + ")");
+ String str = busStop.description;
+ if (showIdentifiers) {
+ str += " (" + busStop.id + ")";
}
- context.activityToast.show();
+ str += "\n" + context.getResources().getString(R.string.map_activity_toast_help_message);
+ context.makeToast(str, Toast.LENGTH_SHORT);
return true;
}
@@ -250,26 +255,16 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref
if (favouritesPreferences.getBoolean(busStop.id, false)) {
favouritesPreferences.edit().remove(busStop.id).commit();
- if (context.activityToast == null) {
- context.activityToast = Toast.makeText(context, busStop.id + " removed from favourites", Toast.LENGTH_SHORT);
- } else {
- context.activityToast.setDuration(Toast.LENGTH_SHORT);
- context.activityToast.setText(busStop.id + " removed from favourites");
- }
- context.activityToast.show();
+ context.makeToast(busStop.id + " removed from favourites", Toast.LENGTH_SHORT);
+
} else {
- if (context.activityToast == null) {
- context.activityToast = Toast.makeText(context, busStop.id + " made a favourite", Toast.LENGTH_SHORT);
- } else {
- context.activityToast.setDuration(Toast.LENGTH_SHORT);
- context.activityToast.setText(busStop.id + " made a favourite");
- }
- context.activityToast.show();
+ context.makeToast(busStop.id + " made a favourite", Toast.LENGTH_SHORT);
favouritesPreferences.edit().putBoolean(busStop.id, true).commit();
}
- Collections.sort(busStops, new POIFavouriteComparator(context.getSharedPreferences(FAVOURITES_PREFERENCES, 0)));
+ Collections.sort(busStops,
+ new POIFavouriteComparator(context.getSharedPreferences(FAVOURITES_PREFERENCES, 0)));
mapView.invalidate();