aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-03-02 10:45:03 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-03-02 10:45:03 +0000
commite3be46bdee08ad5b336e143861790b705defc0bc (patch)
tree0e7e2c4b3429af7e384bed376671ade3c615fdac
parent63d909ab022fb01a1364feffee6bd71d1c48c077 (diff)
downloadsouthamptonuniversitymap-e3be46bdee08ad5b336e143861790b705defc0bc.tar
southamptonuniversitymap-e3be46bdee08ad5b336e143861790b705defc0bc.tar.gz
More improvements to the toasts.
-rw-r--r--res/layout/bus_stop_activity.xml28
-rw-r--r--src/net/cbaines/suma/BusSpecificStopView.java27
-rw-r--r--src/net/cbaines/suma/BusStopSpecificStopView.java26
3 files changed, 59 insertions, 22 deletions
diff --git a/res/layout/bus_stop_activity.xml b/res/layout/bus_stop_activity.xml
index 7875852..66da2f6 100644
--- a/res/layout/bus_stop_activity.xml
+++ b/res/layout/bus_stop_activity.xml
@@ -21,11 +21,12 @@
android:id="@+id/radio_u1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginRight="2dp"
android:background="@drawable/u1_radio_button"
android:button="@drawable/empty"
android:checked="true"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
+ android:paddingLeft="3dp"
+ android:paddingRight="3dp"
android:text="@string/U1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
@@ -34,11 +35,12 @@
android:id="@+id/radio_u1n"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginRight="2dp"
android:background="@drawable/u1n_radio_button"
android:button="@drawable/empty"
android:checked="true"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
+ android:paddingLeft="3dp"
+ android:paddingRight="3dp"
android:text="@string/U1N"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
@@ -47,11 +49,12 @@
android:id="@+id/radio_u2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginRight="2dp"
android:background="@drawable/u2_radio_button"
android:button="@drawable/empty"
android:checked="true"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
+ android:paddingLeft="3dp"
+ android:paddingRight="3dp"
android:text="@string/U2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
@@ -60,11 +63,12 @@
android:id="@+id/radio_u6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginRight="2dp"
android:background="@drawable/u6_radio_button"
android:button="@drawable/empty"
android:checked="true"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
+ android:paddingLeft="3dp"
+ android:paddingRight="3dp"
android:text="@string/U6"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
@@ -73,11 +77,12 @@
android:id="@+id/radio_u9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginRight="2dp"
android:background="@drawable/u9_radio_button"
android:button="@drawable/empty"
android:checked="true"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
+ android:paddingLeft="3dp"
+ android:paddingRight="3dp"
android:text="@string/U9"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
@@ -86,6 +91,7 @@
android:id="@+id/favouriteCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginRight="2dp"
android:text="@string/bustimes_favourite_checkbox_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
@@ -93,8 +99,6 @@
android:id="@+id/busStopID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone" />
</LinearLayout>
diff --git a/src/net/cbaines/suma/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java
index 5ab7cd5..6d7e6af 100644
--- a/src/net/cbaines/suma/BusSpecificStopView.java
+++ b/src/net/cbaines/suma/BusSpecificStopView.java
@@ -25,6 +25,8 @@ import java.text.DateFormat;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
+import android.net.Uri;
+import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
@@ -144,7 +146,19 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
}
public void onClick(View v) {
- context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT);
+ DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
+ try {
+ Dao<Bus, Integer> busDao = helper.getBusDao();
+ busDao.refresh(stop.bus);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ if (stop.bus.id != null) {
+ context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT);
+ } else {
+ context.makeToast(onClickMessage, Toast.LENGTH_SHORT);
+ }
}
public boolean onLongClick(View v) { // TODO
@@ -156,10 +170,13 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener
busDao.refresh(stop.bus);
if (stop.bus.id != null) {
- // TODO Change to URI
- Intent i = new Intent(context, MapActivity.class);
- i.putExtra("poiPoint", stop.busStop.point.toDoubleString());
- ((Activity) context).startActivityForResult(i, 0);
+ Uri uri = Uri.parse("geo:" + Util.E6IntToDouble(stop.busStop.point.getLatitudeE6()) + ","
+ + Util.E6IntToDouble(stop.busStop.point.getLongitudeE6()) + "?z=18");
+
+ Log.i(TAG, "Starting a activity for " + uri);
+
+ Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
+ ((Activity) context).startActivity(mapIntent);
} else {
context.makeToast(onClickUnidentifiedMessage, Toast.LENGTH_SHORT);
}
diff --git a/src/net/cbaines/suma/BusStopSpecificStopView.java b/src/net/cbaines/suma/BusStopSpecificStopView.java
index c7f9bd8..eade3fe 100644
--- a/src/net/cbaines/suma/BusStopSpecificStopView.java
+++ b/src/net/cbaines/suma/BusStopSpecificStopView.java
@@ -31,7 +31,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.LinearLayout;
-import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -42,7 +41,7 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
// private final ImageView icon;
- // private static final String TAG = "StopView";
+ private static final String TAG = "StopView";
private final TextView name;
private final TextView time;
@@ -71,7 +70,8 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
Resources resources = context.getResources();
onClickHelpMessage = resources.getString(R.string.bus_stop_stop_view_on_click_toast_help_message);
- onClickUnidentifiedMessage = resources.getString(R.string.bus_stop_stop_view_on_click_toast_unidentified_message);
+ onClickUnidentifiedMessage = resources
+ .getString(R.string.bus_stop_stop_view_on_click_toast_unidentified_message);
setStop(stop);
@@ -121,7 +121,22 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
}
public void onClick(View v) {
- context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT);
+ Log.v(TAG, "onClick");
+ DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
+ try {
+ Dao<Bus, Integer> busDao = helper.getBusDao();
+ busDao.refresh(stop.bus);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ if (stop.bus.id != null) {
+ Log.v(TAG, "stop.bus != null");
+ context.makeToast(onClickMessage, onClickHelpMessage, Toast.LENGTH_SHORT);
+ } else {
+ Log.v(TAG, "stop.bus == null");
+ context.makeToast(onClickMessage, Toast.LENGTH_SHORT);
+ }
}
public boolean onLongClick(View v) {
@@ -134,7 +149,8 @@ public class BusStopSpecificStopView extends LinearLayout implements OnClickList
busDao.refresh(stop.bus);
busRouteDao.refresh(stop.bus.route);
- Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID " + stop.bus.id);
+ Log.i("StopView", "Bus route " + stop.bus.route + " Uni-Link " + stop.bus.route.uniLink + " Bus ID "
+ + stop.bus.id);
if (stop.bus.id != null && stop.bus.route.uniLink) {
Uri uri = Uri.parse("http://id.southampton.ac.uk/bus/" + stop.bus.id);