aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-03-01 10:34:16 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-03-01 10:34:16 +0000
commitfc2b0ff3aefea51227894804cbcde97d55b79f30 (patch)
tree96ac783b9c8824af74fee5f69d7bf1cb092479c4 /src
parentff96598874103eb2141f01b8b9ace300dfd3ab45 (diff)
downloadsouthamptonuniversitymap-fc2b0ff3aefea51227894804cbcde97d55b79f30.tar
southamptonuniversitymap-fc2b0ff3aefea51227894804cbcde97d55b79f30.tar.gz
Better toasts implemented.
Diffstat (limited to 'src')
-rw-r--r--src/net/cbaines/suma/BuildingNumOverlay.java13
-rw-r--r--src/net/cbaines/suma/BusStopOverlay.java4
-rw-r--r--src/net/cbaines/suma/ToastHelperActivity.java27
3 files changed, 37 insertions, 7 deletions
diff --git a/src/net/cbaines/suma/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java
index 3e2a731..c2a9d7c 100644
--- a/src/net/cbaines/suma/BuildingNumOverlay.java
+++ b/src/net/cbaines/suma/BuildingNumOverlay.java
@@ -40,6 +40,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;
@@ -65,6 +66,8 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
private float userScale = 1f;
+ private boolean showIdentifiers;
+
public BuildingNumOverlay(MapActivity context, List<Building> buildings) throws SQLException {
super(context);
@@ -76,6 +79,9 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
final SharedPreferences favouritesPrefs = context.getSharedPreferences(FAVOURITES_PREFERENCES, 0);
favouritesPrefs.registerOnSharedPreferenceChangeListener(this);
+ showIdentifiers = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SHOW_IDENTIFIERS,
+ SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT);
+
paint = new Paint();
paint.setColor(Color.BLACK);
paint.setAntiAlias(true);
@@ -209,7 +215,12 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
} else {
Log.v(TAG, "building Pressed " + building.id);
- context.makeToast(building.name + " (" + building.id + ")", Toast.LENGTH_SHORT);
+ String str = building.name;
+ if (showIdentifiers) {
+ str += " (" + building.id + ")";
+ }
+ context.makeToast(str, context.getResources().getString(R.string.map_activity_toast_help_message),
+ Toast.LENGTH_SHORT);
return true;
}
diff --git a/src/net/cbaines/suma/BusStopOverlay.java b/src/net/cbaines/suma/BusStopOverlay.java
index 254e03a..778b306 100644
--- a/src/net/cbaines/suma/BusStopOverlay.java
+++ b/src/net/cbaines/suma/BusStopOverlay.java
@@ -210,8 +210,8 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref
if (showIdentifiers) {
str += " (" + busStop.id + ")";
}
- str += "\n" + context.getResources().getString(R.string.map_activity_toast_help_message);
- context.makeToast(str, Toast.LENGTH_SHORT);
+ context.makeToast(str, context.getResources().getString(R.string.map_activity_toast_help_message),
+ Toast.LENGTH_SHORT);
return true;
}
diff --git a/src/net/cbaines/suma/ToastHelperActivity.java b/src/net/cbaines/suma/ToastHelperActivity.java
index 6c5974c..a7997e9 100644
--- a/src/net/cbaines/suma/ToastHelperActivity.java
+++ b/src/net/cbaines/suma/ToastHelperActivity.java
@@ -1,5 +1,6 @@
package net.cbaines.suma;
+import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
@@ -7,17 +8,35 @@ import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
public class ToastHelperActivity extends OrmLiteBaseActivity<DatabaseHelper> {
- protected Toast toast;
- protected TextView toastView;
+ private Toast toast;
+ private View toastView;
+ private TextView toastMessageTextView;
+ private TextView toastSubMessageTextView;
void makeToast(String message, int length) {
+ makeToast(message, null, length);
+ }
+
+ void makeToast(String message, String subMessage, int length) {
if (toastView == null) {
- toastView = (TextView) getLayoutInflater().inflate(R.layout.toast_view, null);
+ toastView = (View) getLayoutInflater().inflate(R.layout.toast_view, null);
}
- toastView.setText(message);
if (toast == null) {
toast = new Toast(this);
}
+
+ toastMessageTextView = (TextView) toastView.findViewById(R.id.toastViewText);
+ toastMessageTextView.setText(message);
+
+ toastSubMessageTextView = (TextView) toastView.findViewById(R.id.toastViewSubMessage);
+ if (subMessage != null) {
+ toastSubMessageTextView.setText(subMessage);
+ toastSubMessageTextView.setVisibility(View.VISIBLE);
+ } else {
+ toastSubMessageTextView.setText("");
+ toastSubMessageTextView.setVisibility(View.GONE);
+ }
+
toast.setDuration(length);
toast.setView(toastView);
toast.show();