diff options
-rw-r--r-- | gen/net/cbaines/suma/R.java | 8 | ||||
-rw-r--r-- | res/layout/toast_view.xml | 7 | ||||
-rw-r--r-- | res/values/strings.xml | 1 | ||||
-rw-r--r-- | src/net/cbaines/suma/BuildingNumOverlay.java | 28 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusStopOverlay.java | 47 | ||||
-rw-r--r-- | src/net/cbaines/suma/MapActivity.java | 13 | ||||
-rw-r--r-- | src/net/cbaines/suma/ToastHelperActivity.java | 26 |
7 files changed, 65 insertions, 65 deletions
diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index f7f3034..4633e09 100644 --- a/gen/net/cbaines/suma/R.java +++ b/gen/net/cbaines/suma/R.java @@ -127,9 +127,10 @@ public final class R { public static final int find_activity=0x7f030007; public static final int map_activity=0x7f030008; public static final int poi_dialog=0x7f030009; - public static final int view_child_row=0x7f03000a; - public static final int view_dialog=0x7f03000b; - public static final int view_group_row=0x7f03000c; + public static final int toast_view=0x7f03000a; + public static final int view_child_row=0x7f03000b; + public static final int view_dialog=0x7f03000c; + public static final int view_group_row=0x7f03000d; } public static final class menu { public static final int map_menu=0x7f090000; @@ -201,6 +202,7 @@ public final class R { public static final int findmylocation_help_message=0x7f070014; public static final int legal_message=0x7f070005; public static final int licence_help_message=0x7f070018; + public static final int map_activity_toast_help_message=0x7f070054; /** Help Messages */ public static final int map_help_message=0x7f070011; diff --git a/res/layout/toast_view.xml b/res/layout/toast_view.xml new file mode 100644 index 0000000..fab39b6 --- /dev/null +++ b/res/layout/toast_view.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="#000000" + android:gravity="center_vertical|center_horizontal" + android:padding="10dp" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index f3850a3..3b57955 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -132,5 +132,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.< <string name="about_donate">Donate</string> <string name="about_donate_summary">Make a personal donation to the developer through Bitcoin.</string> <string name="buildingImageDescription">Image of the Building</string> + <string name="map_activity_toast_help_message">Double tap the map icons for more info</string> </resources>
\ No newline at end of file diff --git a/src/net/cbaines/suma/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java index a4cf556..3e2a731 100644 --- a/src/net/cbaines/suma/BuildingNumOverlay.java +++ b/src/net/cbaines/suma/BuildingNumOverlay.java @@ -209,14 +209,7 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared } else { Log.v(TAG, "building Pressed " + building.id); - if (context.activityToast == null) { - context.activityToast = Toast.makeText(context, building.name + " (" + building.id + ")", - Toast.LENGTH_SHORT); - } else { - context.activityToast.setDuration(Toast.LENGTH_SHORT); - context.activityToast.setText(building.name + " (" + building.id + ")"); - } - context.activityToast.show(); + context.makeToast(building.name + " (" + building.id + ")", Toast.LENGTH_SHORT); return true; } @@ -262,24 +255,9 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared if (favouritesPrefs.getBoolean(building.id, false)) { favouritesPrefs.edit().remove(building.id).commit(); - if (context.activityToast == null) { - context.activityToast = Toast.makeText(context, building.id + " removed from favourites", - Toast.LENGTH_SHORT); - } else { - context.activityToast.setDuration(Toast.LENGTH_SHORT); - context.activityToast.setText(building.id + " removed from favourites"); - } - context.activityToast.show(); - + context.makeToast(building.id + " removed from favourites", Toast.LENGTH_SHORT); } else { - if (context.activityToast == null) { - context.activityToast = Toast.makeText(context, building.id + " made a favourite", - Toast.LENGTH_SHORT); - } else { - context.activityToast.setDuration(Toast.LENGTH_SHORT); - context.activityToast.setText(building.id + " made a favourite"); - } - context.activityToast.show(); + context.makeToast(building.id + " made a favourite", Toast.LENGTH_SHORT); favouritesPrefs.edit().putBoolean(building.id, true).commit(); } 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(); diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java index 8a7a39a..728591d 100644 --- a/src/net/cbaines/suma/MapActivity.java +++ b/src/net/cbaines/suma/MapActivity.java @@ -61,9 +61,7 @@ import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemLongClickListener; -import android.widget.Toast; -import com.j256.ormlite.android.apptools.OrmLiteBaseActivity; import com.j256.ormlite.dao.Dao; /** @@ -71,9 +69,8 @@ import com.j256.ormlite.dao.Dao; * @author Christopher Baines <cbaines8@gmail.com> * */ -public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements MapViewConstants, Runnable, - RouteColorConstants, OnItemClickListener, OnItemLongClickListener, OnSharedPreferenceChangeListener, - Preferences { +public class MapActivity extends ToastHelperActivity implements MapViewConstants, Runnable, RouteColorConstants, + OnItemClickListener, OnItemLongClickListener, OnSharedPreferenceChangeListener, Preferences { /** * Enable to use the database in the assets folder, if its not enabled, the @@ -175,12 +172,6 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements static final String[][] PREFERENCES_CHILDREN = { UNI_LINK_ROUTES, UNI_LINK_ROUTES, BUILDING_TYPES, SITE_NAMES, OTHER_OVERLAY_NAMES }; - /** - * The toast for this activity, storing the toast centrally allows it to be - * changed quickly, instead of a queue building up - */ - Toast activityToast; - private MapActivity instance; private static final String TAG = "SUM"; diff --git a/src/net/cbaines/suma/ToastHelperActivity.java b/src/net/cbaines/suma/ToastHelperActivity.java new file mode 100644 index 0000000..6c5974c --- /dev/null +++ b/src/net/cbaines/suma/ToastHelperActivity.java @@ -0,0 +1,26 @@ +package net.cbaines.suma; + +import android.widget.TextView; +import android.widget.Toast; + +import com.j256.ormlite.android.apptools.OrmLiteBaseActivity; + +public class ToastHelperActivity extends OrmLiteBaseActivity<DatabaseHelper> { + + protected Toast toast; + protected TextView toastView; + + void makeToast(String message, int length) { + if (toastView == null) { + toastView = (TextView) getLayoutInflater().inflate(R.layout.toast_view, null); + } + toastView.setText(message); + if (toast == null) { + toast = new Toast(this); + } + toast.setDuration(length); + toast.setView(toastView); + toast.show(); + } + +} |