aboutsummaryrefslogtreecommitdiff
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
parentff96598874103eb2141f01b8b9ace300dfd3ab45 (diff)
downloadsouthamptonuniversitymap-fc2b0ff3aefea51227894804cbcde97d55b79f30.tar
southamptonuniversitymap-fc2b0ff3aefea51227894804cbcde97d55b79f30.tar.gz
Better toasts implemented.
-rw-r--r--gen/net/cbaines/suma/R.java27
-rw-r--r--res/layout/toast_view.xml28
-rw-r--r--res/values/strings.xml2
-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
6 files changed, 76 insertions, 25 deletions
diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java
index 4633e09..8a2fd53 100644
--- a/gen/net/cbaines/suma/R.java
+++ b/gen/net/cbaines/suma/R.java
@@ -78,8 +78,8 @@ public final class R {
public static final int busStopTimes=0x7f0a001f;
public static final int busTimeContentLayout=0x7f0a001d;
public static final int centerLoadBar=0x7f0a0020;
- public static final int check1=0x7f0a0032;
- public static final int childname=0x7f0a0031;
+ public static final int check1=0x7f0a0035;
+ public static final int childname=0x7f0a0034;
public static final int donateBitcoinAddress=0x7f0a0029;
public static final int donateButton=0x7f0a0003;
public static final int donateDialogErrorMessage=0x7f0a0028;
@@ -97,15 +97,15 @@ public final class R {
public static final int linearLayout1=0x7f0a0015;
public static final int linearLayout2=0x7f0a0024;
public static final int mapview=0x7f0a002e;
- public static final int menu_about=0x7f0a0038;
- public static final int menu_favourites=0x7f0a0039;
- public static final int menu_find=0x7f0a0034;
- public static final int menu_find_my_location=0x7f0a0036;
- public static final int menu_next_stop=0x7f0a003c;
- public static final int menu_preferences=0x7f0a0035;
- public static final int menu_previous_stop=0x7f0a003a;
- public static final int menu_refresh_stop=0x7f0a003b;
- public static final int menu_view=0x7f0a0037;
+ public static final int menu_about=0x7f0a003b;
+ public static final int menu_favourites=0x7f0a003c;
+ public static final int menu_find=0x7f0a0037;
+ public static final int menu_find_my_location=0x7f0a0039;
+ public static final int menu_next_stop=0x7f0a003f;
+ public static final int menu_preferences=0x7f0a0038;
+ public static final int menu_previous_stop=0x7f0a003d;
+ public static final int menu_refresh_stop=0x7f0a003e;
+ public static final int menu_view=0x7f0a003a;
public static final int radio_u1=0x7f0a0016;
public static final int radio_u1n=0x7f0a0017;
public static final int radio_u2=0x7f0a0018;
@@ -114,7 +114,10 @@ public final class R {
public static final int searchBar=0x7f0a002a;
public static final int textView1=0x7f0a0000;
public static final int textView2=0x7f0a0001;
- public static final int view_list=0x7f0a0033;
+ public static final int toastViewLinearLayout=0x7f0a0031;
+ public static final int toastViewSubMessage=0x7f0a0033;
+ public static final int toastViewText=0x7f0a0032;
+ public static final int view_list=0x7f0a0036;
}
public static final class layout {
public static final int about_dialog=0x7f030000;
diff --git a/res/layout/toast_view.xml b/res/layout/toast_view.xml
index fab39b6..6431e6b 100644
--- a/res/layout/toast_view.xml
+++ b/res/layout/toast_view.xml
@@ -1,7 +1,25 @@
<?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"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/toastViewLinearLayout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:background="#000000"
- android:gravity="center_vertical|center_horizontal"
- android:padding="10dp" />
+ android:gravity="center_horizontal"
+ android:orientation="vertical"
+ android:padding="10dp" >
+
+ <TextView
+ android:id="@+id/toastViewText"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:gravity="center_vertical|center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/toastViewSubMessage"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:gravity="center_vertical|center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3b57955..34ee0c5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -132,6 +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>
+ <string name="map_activity_toast_help_message">Double tap 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 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();