diff options
author | Christopher Baines <cbaines8@gmail.com> | 2012-01-24 23:03:08 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2012-01-24 23:03:08 +0000 |
commit | efb193d6fbea2423d03eebf30e2359a6612134c1 (patch) | |
tree | 4dc77e89cae8c8154b6646583035492675eb21d4 | |
parent | f13680dc5ca55401484ea23fc9493a938cb8ae73 (diff) | |
download | southamptonuniversitymap-efb193d6fbea2423d03eebf30e2359a6612134c1.tar southamptonuniversitymap-efb193d6fbea2423d03eebf30e2359a6612134c1.tar.gz |
Many changes, began working on implementing filtering and route navigation within BusTimeActivity.
44 files changed, 421 insertions, 107 deletions
diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index 2535953..fff928a 100644 --- a/gen/net/cbaines/suma/R.java +++ b/gen/net/cbaines/suma/R.java @@ -24,11 +24,22 @@ public final class R { public static final int building_fav=0x7f020001; public static final int busstop=0x7f020002; public static final int busstop_fav=0x7f020003; - public static final int u1_back=0x7f020004; - public static final int u1n_back=0x7f020005; - public static final int u2_back=0x7f020006; - public static final int u6_back=0x7f020007; - public static final int u9_back=0x7f020008; + public static final int empty=0x7f020004; + public static final int u1_back=0x7f020005; + public static final int u1_back_selected=0x7f020006; + public static final int u1_radio_button=0x7f020007; + public static final int u1n_back=0x7f020008; + public static final int u1n_back_selected=0x7f020009; + public static final int u1n_radio_button=0x7f02000a; + public static final int u2_back=0x7f02000b; + public static final int u2_back_selected=0x7f02000c; + public static final int u2_radio_button=0x7f02000d; + public static final int u6_back=0x7f02000e; + public static final int u6_back_selected=0x7f02000f; + public static final int u6_radio_button=0x7f020010; + public static final int u9_back=0x7f020011; + public static final int u9_back_selected=0x7f020012; + public static final int u9_radio_button=0x7f020013; } public static final class id { public static final int busStopID=0x7f0a000c; @@ -36,11 +47,6 @@ public final class R { public static final int busStopMessage=0x7f0a000e; public static final int busStopName=0x7f0a0004; public static final int busStopTimes=0x7f0a0010; - public static final int busStopU1=0x7f0a0006; - public static final int busStopU1N=0x7f0a0007; - public static final int busStopU2=0x7f0a0008; - public static final int busStopU6=0x7f0a0009; - public static final int busStopU9=0x7f0a000a; public static final int busTimeContentLayout=0x7f0a000d; public static final int check1=0x7f0a0020; public static final int childname=0x7f0a001f; @@ -65,8 +71,16 @@ public final class R { public static final int menu_favourites=0x7f0a0027; public static final int menu_find=0x7f0a0022; public static final int menu_find_my_location=0x7f0a0024; + public static final int menu_next_stop=0x7f0a002a; public static final int menu_preferences=0x7f0a0023; + public static final int menu_previous_stop=0x7f0a0028; + public static final int menu_refresh_stop=0x7f0a0029; public static final int menu_view=0x7f0a0025; + public static final int radio_u1=0x7f0a0006; + public static final int radio_u1n=0x7f0a0007; + public static final int radio_u2=0x7f0a0008; + public static final int radio_u6=0x7f0a0009; + public static final int radio_u9=0x7f0a000a; public static final int searchBar=0x7f0a001a; public static final int textView1=0x7f0a0000; public static final int textView2=0x7f0a0001; @@ -85,14 +99,16 @@ public final class R { } public static final class menu { public static final int map_menu=0x7f090000; + public static final int stop_menu=0x7f090001; } public static final class raw { - public static final int u1=0x7f060000; - public static final int u1e=0x7f060001; - public static final int u1n=0x7f060002; - public static final int u2=0x7f060003; - public static final int u6=0x7f060004; - public static final int u9=0x7f060005; + public static final int ormlite_config=0x7f060000; + public static final int u1=0x7f060001; + public static final int u1e=0x7f060002; + public static final int u1n=0x7f060003; + public static final int u2=0x7f060004; + public static final int u6=0x7f060005; + public static final int u9=0x7f060006; } public static final class string { public static final int U1=0x7f070009; @@ -124,7 +140,10 @@ public final class R { public static final int menu_favourites=0x7f07000f; public static final int menu_find=0x7f070000; public static final int menu_find_my_location=0x7f070003; + public static final int menu_next_stop=0x7f070028; public static final int menu_preferences=0x7f070001; + public static final int menu_previous_stop=0x7f070027; + public static final int menu_refresh_stop=0x7f070029; public static final int menu_view=0x7f070002; public static final int pref_bus_stop=0x7f070008; public static final int preferences=0x7f07001b; diff --git a/res/drawable/empty.xml b/res/drawable/empty.xml new file mode 100644 index 0000000..840a0e7 --- /dev/null +++ b/res/drawable/empty.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<android:shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <android:size + android:height="0dp" + android:width="0dp" /> + +</android:shape>
\ No newline at end of file diff --git a/res/drawable/u1_back.xml b/res/drawable/u1_back.xml index d9f615b..069eb8e 100644 --- a/res/drawable/u1_back.xml +++ b/res/drawable/u1_back.xml @@ -1,14 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> -<shape xmlns:android="http://schemas.android.com/apk/res/android" +<android:shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > - <solid android:color="#008BD0" > - </solid> + <android:solid android:color="#000000" > + </android:solid> - <corners + <android:corners android:bottomLeftRadius="7dp" android:bottomRightRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp" /> -</shape>
\ No newline at end of file +</android:shape>
\ No newline at end of file diff --git a/res/drawable/u1_back_selected.xml b/res/drawable/u1_back_selected.xml new file mode 100644 index 0000000..4040762 --- /dev/null +++ b/res/drawable/u1_back_selected.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<android:shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <android:solid android:color="#008BD0" > + </android:solid> + + <android:corners + android:bottomLeftRadius="7dp" + android:bottomRightRadius="7dp" + android:topLeftRadius="7dp" + android:topRightRadius="7dp" /> + +</android:shape>
\ No newline at end of file diff --git a/res/drawable/u1_radio_button.xml b/res/drawable/u1_radio_button.xml new file mode 100644 index 0000000..5562342 --- /dev/null +++ b/res/drawable/u1_radio_button.xml @@ -0,0 +1,8 @@ +<android:selector xmlns:android="http://schemas.android.com/apk/res/android"> + + <android:item android:drawable="@drawable/u1_back_selected" android:state_checked="true" android:state_pressed="false"/> + <android:item android:drawable="@drawable/u1_back" android:state_checked="false" android:state_pressed="false"/> + <android:item android:drawable="@drawable/u1_back_selected" android:state_checked="true" android:state_pressed="true"/> + <android:item android:drawable="@drawable/u1_back" android:state_checked="false" android:state_pressed="true"/> + +</android:selector>
\ No newline at end of file diff --git a/res/drawable/u1n_back.xml b/res/drawable/u1n_back.xml index 3898629..069eb8e 100644 --- a/res/drawable/u1n_back.xml +++ b/res/drawable/u1n_back.xml @@ -1,14 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> -<shape xmlns:android="http://schemas.android.com/apk/res/android" +<android:shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > - <solid android:color="#002F6B" > - </solid> + <android:solid android:color="#000000" > + </android:solid> - <corners + <android:corners android:bottomLeftRadius="7dp" android:bottomRightRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp" /> -</shape>
\ No newline at end of file +</android:shape>
\ No newline at end of file diff --git a/res/drawable/u1n_back_selected.xml b/res/drawable/u1n_back_selected.xml new file mode 100644 index 0000000..3898629 --- /dev/null +++ b/res/drawable/u1n_back_selected.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <solid android:color="#002F6B" > + </solid> + + <corners + android:bottomLeftRadius="7dp" + android:bottomRightRadius="7dp" + android:topLeftRadius="7dp" + android:topRightRadius="7dp" /> + +</shape>
\ No newline at end of file diff --git a/res/drawable/u1n_radio_button.xml b/res/drawable/u1n_radio_button.xml new file mode 100644 index 0000000..b4bde8d --- /dev/null +++ b/res/drawable/u1n_radio_button.xml @@ -0,0 +1,8 @@ +<android:selector xmlns:android="http://schemas.android.com/apk/res/android"> + + <android:item android:drawable="@drawable/u1n_back_selected" android:state_checked="true" android:state_pressed="false"/> + <android:item android:drawable="@drawable/u1n_back" android:state_checked="false" android:state_pressed="false"/> + <android:item android:drawable="@drawable/u1n_back_selected" android:state_checked="true" android:state_pressed="true"/> + <android:item android:drawable="@drawable/u1n_back" android:state_checked="false" android:state_pressed="true"/> + +</android:selector>
\ No newline at end of file diff --git a/res/drawable/u2_back.xml b/res/drawable/u2_back.xml index e1fa567..9feb0ef 100644 --- a/res/drawable/u2_back.xml +++ b/res/drawable/u2_back.xml @@ -2,7 +2,7 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > - <solid android:color="#E2001A" > + <solid android:color="#000000" > </solid> <corners diff --git a/res/drawable/u2_back_selected.xml b/res/drawable/u2_back_selected.xml new file mode 100644 index 0000000..e1fa567 --- /dev/null +++ b/res/drawable/u2_back_selected.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <solid android:color="#E2001A" > + </solid> + + <corners + android:bottomLeftRadius="7dp" + android:bottomRightRadius="7dp" + android:topLeftRadius="7dp" + android:topRightRadius="7dp" /> + +</shape>
\ No newline at end of file diff --git a/res/drawable/u2_radio_button.xml b/res/drawable/u2_radio_button.xml new file mode 100644 index 0000000..a6ec1e6 --- /dev/null +++ b/res/drawable/u2_radio_button.xml @@ -0,0 +1,8 @@ +<android:selector xmlns:android="http://schemas.android.com/apk/res/android"> + + <android:item android:drawable="@drawable/u2_back_selected" android:state_checked="true" android:state_pressed="false"/> + <android:item android:drawable="@drawable/u2_back" android:state_checked="false" android:state_pressed="false"/> + <android:item android:drawable="@drawable/u2_back_selected" android:state_checked="true" android:state_pressed="true"/> + <android:item android:drawable="@drawable/u2_back" android:state_checked="false" android:state_pressed="true"/> + +</android:selector>
\ No newline at end of file diff --git a/res/drawable/u6_back.xml b/res/drawable/u6_back.xml index cd60db7..9feb0ef 100644 --- a/res/drawable/u6_back.xml +++ b/res/drawable/u6_back.xml @@ -2,7 +2,7 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > - <solid android:color="#F7A800" > + <solid android:color="#000000" > </solid> <corners diff --git a/res/drawable/u6_back_selected.xml b/res/drawable/u6_back_selected.xml new file mode 100644 index 0000000..cd60db7 --- /dev/null +++ b/res/drawable/u6_back_selected.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <solid android:color="#F7A800" > + </solid> + + <corners + android:bottomLeftRadius="7dp" + android:bottomRightRadius="7dp" + android:topLeftRadius="7dp" + android:topRightRadius="7dp" /> + +</shape>
\ No newline at end of file diff --git a/res/drawable/u6_radio_button.xml b/res/drawable/u6_radio_button.xml new file mode 100644 index 0000000..1d28ba1 --- /dev/null +++ b/res/drawable/u6_radio_button.xml @@ -0,0 +1,20 @@ +<android:selector xmlns:android="http://schemas.android.com/apk/res/android" > + + <android:item + android:drawable="@drawable/u6_back_selected" + android:state_checked="true" + android:state_pressed="false" /> + <android:item + android:drawable="@drawable/u6_back" + android:state_checked="false" + android:state_pressed="false" /> + <android:item + android:drawable="@drawable/u6_back_selected" + android:state_checked="true" + android:state_pressed="true" /> + <android:item + android:drawable="@drawable/u6_back" + android:state_checked="false" + android:state_pressed="true" /> + +</android:selector>
\ No newline at end of file diff --git a/res/drawable/u9_back.xml b/res/drawable/u9_back.xml index 6216ebc..9feb0ef 100644 --- a/res/drawable/u9_back.xml +++ b/res/drawable/u9_back.xml @@ -2,7 +2,7 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > - <solid android:color="#E75294" > + <solid android:color="#000000" > </solid> <corners diff --git a/res/drawable/u9_back_selected.xml b/res/drawable/u9_back_selected.xml new file mode 100644 index 0000000..6216ebc --- /dev/null +++ b/res/drawable/u9_back_selected.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <solid android:color="#E75294" > + </solid> + + <corners + android:bottomLeftRadius="7dp" + android:bottomRightRadius="7dp" + android:topLeftRadius="7dp" + android:topRightRadius="7dp" /> + +</shape>
\ No newline at end of file diff --git a/res/drawable/u9_radio_button.xml b/res/drawable/u9_radio_button.xml new file mode 100644 index 0000000..22443a5 --- /dev/null +++ b/res/drawable/u9_radio_button.xml @@ -0,0 +1,8 @@ +<android:selector xmlns:android="http://schemas.android.com/apk/res/android"> + + <android:item android:drawable="@drawable/u9_back_selected" android:state_checked="true" android:state_pressed="false"/> + <android:item android:drawable="@drawable/u9_back" android:state_checked="false" android:state_pressed="false"/> + <android:item android:drawable="@drawable/u9_back_selected" android:state_checked="true" android:state_pressed="true"/> + <android:item android:drawable="@drawable/u9_back" android:state_checked="false" android:state_pressed="true"/> + +</android:selector>
\ No newline at end of file diff --git a/res/layout/bustimes.xml b/res/layout/bustimes.xml index b076274..1928c79 100644 --- a/res/layout/bustimes.xml +++ b/res/layout/bustimes.xml @@ -17,56 +17,65 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" > - <TextView - android:id="@+id/busStopU1" + <CheckBox + android:id="@+id/radio_u1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="3dp" - android:background="@drawable/u1_back" + android:background="@drawable/u1_radio_button" + android:button="@drawable/empty" + android:checked="true" android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U1" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#FFFFFF" /> - <TextView - android:id="@+id/busStopU1N" + <CheckBox + android:id="@+id/radio_u1n" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="@drawable/u1n_back" + android:background="@drawable/u1n_radio_button" + android:button="@drawable/empty" + android:checked="true" android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U1N" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#FFFFFF" /> - <TextView - android:id="@+id/busStopU2" + <CheckBox + android:id="@+id/radio_u2" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="@drawable/u2_back" + android:background="@drawable/u2_radio_button" + android:button="@drawable/empty" + android:checked="true" android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U2" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#FFFFFF" /> - <TextView - android:id="@+id/busStopU6" + <CheckBox + android:id="@+id/radio_u6" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="@drawable/u6_back" + android:background="@drawable/u6_radio_button" + android:button="@drawable/empty" + android:checked="true" android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U6" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#FFFFFF" /> - <TextView - android:id="@+id/busStopU9" + <CheckBox + android:id="@+id/radio_u9" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="@drawable/u9_back" + android:background="@drawable/u9_radio_button" + android:button="@drawable/empty" + android:checked="true" android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U9" @@ -86,7 +95,6 @@ android:paddingLeft="5dp" android:paddingRight="5dp" android:textAppearance="?android:attr/textAppearanceSmall" /> - </LinearLayout> <LinearLayout diff --git a/res/menu/map_menu.xml b/res/menu/map_menu.xml index 29f9342..2734461 100644 --- a/res/menu/map_menu.xml +++ b/res/menu/map_menu.xml @@ -12,8 +12,7 @@ <item android:id="@+id/menu_find_my_location" android:icon="@android:drawable/ic_menu_mylocation" - android:title="@string/menu_find_my_location"> - </item> + android:title="@string/menu_find_my_location"/> <item android:id="@+id/menu_view" android:icon="@android:drawable/ic_menu_more" diff --git a/res/menu/stop_menu.xml b/res/menu/stop_menu.xml new file mode 100644 index 0000000..3b1bb40 --- /dev/null +++ b/res/menu/stop_menu.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android" > + + <item + android:id="@+id/menu_previous_stop" + android:icon="@android:drawable/ic_menu_search" + android:title="@string/menu_previous_stop"/> + <item + android:id="@+id/menu_refresh_stop" + android:icon="@android:drawable/ic_menu_search" + android:title="@string/menu_refresh_stop"/> + <item + android:id="@+id/menu_next_stop" + android:icon="@android:drawable/ic_menu_search" + android:title="@string/menu_next_stop"/> + +</menu>
\ No newline at end of file diff --git a/res/raw/ormlite_config.txt b/res/raw/ormlite_config.txt new file mode 100644 index 0000000..f807b08 --- /dev/null +++ b/res/raw/ormlite_config.txt @@ -0,0 +1,3 @@ +# +# generated on 2012/01/24 10:55:14 +# diff --git a/res/values/strings.xml b/res/values/strings.xml index 59e4696..f1060fe 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -81,5 +81,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.< <string name="bustimes_favourite_checkbox_label">Favourite</string> <string name="donate_dialog_message">Loading bitcoin client</string> <string name="donate_dialog_error_title">Error</string> + <string name="menu_previous_stop">Previous</string> + <string name="menu_next_stop">Next</string> + <string name="menu_refresh_stop">Refresh</string> </resources>
\ No newline at end of file diff --git a/src/net/cbaines/suma/Building.java b/src/net/cbaines/suma/Building.java index df8c303..8747a78 100644 --- a/src/net/cbaines/suma/Building.java +++ b/src/net/cbaines/suma/Building.java @@ -34,7 +34,7 @@ public class Building extends POI { @DatabaseField(canBeNull = false) public String name; @DatabaseField(canBeNull = false) - boolean residential; + public boolean residential; @DatabaseField(dataType = DataType.SERIALIZABLE, canBeNull = true) Polygon outline; @@ -46,7 +46,7 @@ public class Building extends POI { this.type = POI.BUILDING; } - Building(String id, GeoPoint point, boolean residential, String name) { + public Building(String id, GeoPoint point, boolean residential, String name) { this(id, point, residential, name, null); } diff --git a/src/net/cbaines/suma/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java index 080cdc6..4bd5f3a 100644 --- a/src/net/cbaines/suma/BuildingNumOverlay.java +++ b/src/net/cbaines/suma/BuildingNumOverlay.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; + import org.osmdroid.views.MapView; import org.osmdroid.views.MapView.Projection; import org.osmdroid.views.overlay.Overlay; diff --git a/src/net/cbaines/suma/Bus.java b/src/net/cbaines/suma/Bus.java index ff71df4..426ee3b 100644 --- a/src/net/cbaines/suma/Bus.java +++ b/src/net/cbaines/suma/Bus.java @@ -26,7 +26,7 @@ import com.j256.ormlite.table.DatabaseTable; public class Bus { @DatabaseField(id = true) - int id; + public int id; @DatabaseField(canBeNull = true, foreign = true) Stop lastKnownStop; @@ -46,7 +46,7 @@ public class Bus { this.lastKnownStop = lastKnownStop; } - Bus(int id, BusRoute lastKnownRoute) { + public Bus(int id, BusRoute lastKnownRoute) { this(id, lastKnownRoute, null); } diff --git a/src/net/cbaines/suma/BusRoute.java b/src/net/cbaines/suma/BusRoute.java index 016f3bd..43a5375 100644 --- a/src/net/cbaines/suma/BusRoute.java +++ b/src/net/cbaines/suma/BusRoute.java @@ -48,10 +48,10 @@ public class BusRoute { private static final String TAG = "BusRoute"; @DatabaseField(id = true) - int id; + public int id; @DatabaseField - String code; + public String code; @DatabaseField String label; @@ -59,7 +59,7 @@ public class BusRoute { BusRoute() { } - BusRoute(Integer id, String code, String label) { + public BusRoute(Integer id, String code, String label) { this.id = id.intValue(); this.code = code; this.label = label; @@ -183,4 +183,26 @@ public class BusRoute { } } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + id; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BusRoute other = (BusRoute) obj; + if (id != other.id) + return false; + return true; + } + } diff --git a/src/net/cbaines/suma/BusStop.java b/src/net/cbaines/suma/BusStop.java index 8e13f27..21f2dd9 100644 --- a/src/net/cbaines/suma/BusStop.java +++ b/src/net/cbaines/suma/BusStop.java @@ -37,9 +37,9 @@ public class BusStop extends POI { // Used to speed up accessing the relevent uni link routes for a bus stop, if == 0, this is not a uni link stop @DatabaseField(canBeNull = false) - byte routes; + public byte routes; - BusStop(String location, String description, String bay, GeoPoint point) { + public BusStop(String location, String description, String bay, GeoPoint point) { this.id = location; this.description = description; this.bay = bay; diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java index 1495258..7fc78ce 100644 --- a/src/net/cbaines/suma/BusStopActivity.java +++ b/src/net/cbaines/suma/BusStopActivity.java @@ -20,6 +20,7 @@ package net.cbaines.suma; import java.sql.SQLException; +import java.util.Iterator; import android.content.Context; import android.content.SharedPreferences; @@ -29,6 +30,8 @@ import android.os.Handler; import android.preference.PreferenceManager; import android.util.Log; import android.view.Gravity; +import android.view.Menu; +import android.view.MenuInflater; import android.view.View; import android.widget.CheckBox; import android.widget.CompoundButton; @@ -73,6 +76,12 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme private Handler mHandler; private Runnable refreshData; + private CheckBox U1RouteRadioButton; + private CheckBox U1NRouteRadioButton; + private CheckBox U2RouteRadioButton; + private CheckBox U6RouteRadioButton; + private CheckBox U9RouteRadioButton; + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bustimes); @@ -84,11 +93,17 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme busStopID = getIntent().getExtras().getString("busStopID"); busStopName = getIntent().getExtras().getString("busStopName"); - TextView U1RouteTextView = (TextView) findViewById(R.id.busStopU1); - TextView U1NRouteTextView = (TextView) findViewById(R.id.busStopU1N); - TextView U2RouteTextView = (TextView) findViewById(R.id.busStopU2); - TextView U6RouteTextView = (TextView) findViewById(R.id.busStopU6); - TextView U9RouteTextView = (TextView) findViewById(R.id.busStopU9); + U1RouteRadioButton = (CheckBox) findViewById(R.id.radio_u1); + U1NRouteRadioButton = (CheckBox) findViewById(R.id.radio_u1n); + U2RouteRadioButton = (CheckBox) findViewById(R.id.radio_u2); + U6RouteRadioButton = (CheckBox) findViewById(R.id.radio_u6); + U9RouteRadioButton = (CheckBox) findViewById(R.id.radio_u9); + + U1RouteRadioButton.setOnCheckedChangeListener(this); + U1NRouteRadioButton.setOnCheckedChangeListener(this); + U2RouteRadioButton.setOnCheckedChangeListener(this); + U6RouteRadioButton.setOnCheckedChangeListener(this); + U9RouteRadioButton.setOnCheckedChangeListener(this); try { Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao(); @@ -105,33 +120,33 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme if (route.code.equals("U1")) { if (count != 0) { - U1RouteTextView.setVisibility(View.VISIBLE); + U1RouteRadioButton.setVisibility(View.VISIBLE); } else { - U1RouteTextView.setVisibility(View.GONE); + U1RouteRadioButton.setVisibility(View.GONE); } } else if (route.code.equals("U1N")) { if (count != 0) { - U1NRouteTextView.setVisibility(View.VISIBLE); + U1NRouteRadioButton.setVisibility(View.VISIBLE); } else { - U1NRouteTextView.setVisibility(View.GONE); + U1NRouteRadioButton.setVisibility(View.GONE); } } else if (route.code.equals("U2")) { if (count != 0) { - U2RouteTextView.setVisibility(View.VISIBLE); + U2RouteRadioButton.setVisibility(View.VISIBLE); } else { - U2RouteTextView.setVisibility(View.GONE); + U2RouteRadioButton.setVisibility(View.GONE); } } else if (route.code.equals("U6")) { if (count != 0) { - U6RouteTextView.setVisibility(View.VISIBLE); + U6RouteRadioButton.setVisibility(View.VISIBLE); } else { - U6RouteTextView.setVisibility(View.GONE); + U6RouteRadioButton.setVisibility(View.GONE); } } else if (route.code.equals("U9")) { if (count != 0) { - U9RouteTextView.setVisibility(View.VISIBLE); + U9RouteRadioButton.setVisibility(View.VISIBLE); } else { - U9RouteTextView.setVisibility(View.GONE); + U9RouteRadioButton.setVisibility(View.GONE); } } else { Log.e(TAG, "Error unknown route " + route.code); @@ -221,13 +236,21 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme super.finish(); } - public void onCheckedChanged(CompoundButton arg0, boolean arg1) { - busStop.favourite = arg1; - try { - busStopDao.update(busStop); - dataChanged = true; - } catch (SQLException e) { - e.printStackTrace(); + public void onCheckedChanged(CompoundButton button, boolean checked) { + if (button.equals(busFavourite)) { + busStop.favourite = checked; + try { + busStopDao.update(busStop); + dataChanged = true; + } catch (SQLException e) { + e.printStackTrace(); + } + } else { + + Log.i(TAG, "Route radio button made " + checked); + + displayTimetable(timetable); + } } @@ -262,25 +285,70 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme } } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.stop_menu, menu); + return true; + } + private void displayTimetable(Timetable timetable) { - Log.i(TAG, "It contains " + timetable.size() + " stops"); + Timetable timetableToDisplay = (Timetable) timetable.clone(); + + Log.i(TAG, "It contains " + timetableToDisplay.size() + " stops"); if (timetable.size() == 0) { progBar.setVisibility(View.GONE); busStopMessage.setText("No Busses"); busStopMessage.setVisibility(View.VISIBLE); + busTimeContentLayout.setGravity(Gravity.CENTER); } else { - progBar.setVisibility(View.GONE); - busStopMessage.setVisibility(View.GONE); - TimetableAdapter adapter; - if ((adapter = (TimetableAdapter) busTimeList.getAdapter()) != null) { - adapter.updateTimetable(timetable); + + for (Iterator<Stop> stopIter = timetableToDisplay.iterator(); stopIter.hasNext();) { + Stop stop = stopIter.next(); + Log.i(TAG, "Begin filtering, looking at " + stop + " with route " + stop.route.code); + if (stop.route.code.equals("U1")) { + if (!U1RouteRadioButton.isChecked()) { + stopIter.remove(); + } + } else if (stop.route.code.equals("U1N")) { + if (!U1NRouteRadioButton.isChecked()) { + stopIter.remove(); + } + } else if (stop.route.code.equals("U2")) { + if (!U2RouteRadioButton.isChecked()) { + stopIter.remove(); + } + } else if (stop.route.code.equals("U6")) { + if (!U6RouteRadioButton.isChecked()) { + stopIter.remove(); + } + } else if (stop.route.code.equals("U9")) { + if (!U9RouteRadioButton.isChecked()) { + stopIter.remove(); + } + } + } + + if (timetableToDisplay.size() == 0) { + busTimeContentLayout.setGravity(Gravity.CENTER); + progBar.setVisibility(View.GONE); + busStopMessage.setText("No Busses (With the current enabled routes)"); + busStopMessage.setVisibility(View.VISIBLE); + busTimeList.setVisibility(View.GONE); } else { - adapter = new TimetableAdapter(this, timetable); - busTimeList.setAdapter(adapter); + busTimeList.setVisibility(View.VISIBLE); + progBar.setVisibility(View.GONE); + busStopMessage.setVisibility(View.GONE); + TimetableAdapter adapter; + if ((adapter = (TimetableAdapter) busTimeList.getAdapter()) != null) { + adapter.updateTimetable(timetableToDisplay); + } else { + adapter = new TimetableAdapter(this, timetableToDisplay); + busTimeList.setAdapter(adapter); + } + busTimeContentLayout.setGravity(Gravity.TOP); } - busTimeContentLayout.setGravity(Gravity.TOP); } } - } diff --git a/src/net/cbaines/suma/BusStopOverlay.java b/src/net/cbaines/suma/BusStopOverlay.java index 83b10c1..e77e862 100644 --- a/src/net/cbaines/suma/BusStopOverlay.java +++ b/src/net/cbaines/suma/BusStopOverlay.java @@ -23,6 +23,7 @@ import java.sql.SQLException; import java.util.Collections; import java.util.List; + import org.osmdroid.views.MapView; import org.osmdroid.views.MapView.Projection; import org.osmdroid.views.overlay.Overlay; diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java index e910c8e..d54b25b 100644 --- a/src/net/cbaines/suma/DataManager.java +++ b/src/net/cbaines/suma/DataManager.java @@ -29,6 +29,7 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -517,6 +518,7 @@ public class DataManager { Date now = new Date(System.currentTimeMillis()); stop = new Stop(stopObj.getString("name"), busStop, destStop, bus, calender.getTime(), now); + stop.route = route; /* * if (bus.lastKnownStop != null) { stopDao.delete(bus.lastKnownStop); // TODO Crude, might delete useful data @@ -540,6 +542,7 @@ public class DataManager { } else { stop = new Stop(stopObj.getString("name"), busStop, destStop, calender.getTime(), new Date(System.currentTimeMillis())); + stop.route = route; } diff --git a/src/net/cbaines/suma/DatabaseConfigUtil.java b/src/net/cbaines/suma/DatabaseConfigUtil.java new file mode 100644 index 0000000..831e8cb --- /dev/null +++ b/src/net/cbaines/suma/DatabaseConfigUtil.java @@ -0,0 +1,28 @@ +/* + * Southampton University Map App + * Copyright (C) 2011 Christopher Baines + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package net.cbaines.suma; + +import com.j256.ormlite.android.apptools.OrmLiteConfigUtil; + +public class DatabaseConfigUtil extends OrmLiteConfigUtil { + public static void main(String[] args) throws Exception { + writeConfigFile("ormlite_config.txt"); + } +} diff --git a/src/net/cbaines/suma/FavouriteDialog.java b/src/net/cbaines/suma/FavouriteDialog.java index e95ead2..ca39574 100644 --- a/src/net/cbaines/suma/FavouriteDialog.java +++ b/src/net/cbaines/suma/FavouriteDialog.java @@ -22,6 +22,7 @@ package net.cbaines.suma; import java.sql.SQLException; import java.util.ArrayList; + import android.app.Dialog; import android.content.Context; import android.util.Log; diff --git a/src/net/cbaines/suma/FindActivity.java b/src/net/cbaines/suma/FindActivity.java index 68db3c5..f0a16ac 100644 --- a/src/net/cbaines/suma/FindActivity.java +++ b/src/net/cbaines/suma/FindActivity.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; + import org.osmdroid.util.GeoPoint; import android.content.Context; diff --git a/src/net/cbaines/suma/POI.java b/src/net/cbaines/suma/POI.java index 37d6aaf..dba7924 100644 --- a/src/net/cbaines/suma/POI.java +++ b/src/net/cbaines/suma/POI.java @@ -51,7 +51,7 @@ public abstract class POI { @DatabaseField(canBeNull = false) public boolean favourite; // This field is not assessed by equals - int distTo = -1; // Used by the comparator to store distances, then later by the gui to display them. + public int distTo = -1; // Used by the comparator to store distances, then later by the gui to display them. public String type; diff --git a/src/net/cbaines/suma/POIArrayAdapter.java b/src/net/cbaines/suma/POIArrayAdapter.java index 83ee517..e35acf4 100644 --- a/src/net/cbaines/suma/POIArrayAdapter.java +++ b/src/net/cbaines/suma/POIArrayAdapter.java @@ -21,6 +21,7 @@ package net.cbaines.suma; import java.util.List; + import android.content.Context; import android.view.View; import android.view.ViewGroup; diff --git a/src/net/cbaines/suma/Polygon.java b/src/net/cbaines/suma/Polygon.java index 5020a33..b10fbc4 100644 --- a/src/net/cbaines/suma/Polygon.java +++ b/src/net/cbaines/suma/Polygon.java @@ -29,13 +29,13 @@ public class Polygon implements Serializable { */ private static final long serialVersionUID = 3029139596630651715L; - final GeoPoint[] points; + public final GeoPoint[] points; Polygon() { points = null; } - Polygon(GeoPoint[] points) { + public Polygon(GeoPoint[] points) { this.points = points; } diff --git a/src/net/cbaines/suma/RouteOverlayItem.java b/src/net/cbaines/suma/RouteOverlayItem.java index 77df6dc..98c4d28 100644 --- a/src/net/cbaines/suma/RouteOverlayItem.java +++ b/src/net/cbaines/suma/RouteOverlayItem.java @@ -21,6 +21,7 @@ package net.cbaines.suma; import java.util.ArrayList; + import org.osmdroid.util.GeoPoint; import org.osmdroid.views.overlay.OverlayItem; diff --git a/src/net/cbaines/suma/Site.java b/src/net/cbaines/suma/Site.java index 0447d8a..b13b9ae 100644 --- a/src/net/cbaines/suma/Site.java +++ b/src/net/cbaines/suma/Site.java @@ -27,17 +27,17 @@ import com.j256.ormlite.table.DatabaseTable; @DatabaseTable(tableName = "sites") public class Site extends POI { - + public static final String NAME_FIELD_NAME = "name"; public static final String OUTLINE_FIELD_NAME = "outline"; @DatabaseField(canBeNull = false) - String name; + public String name; @DatabaseField(dataType = DataType.SERIALIZABLE, canBeNull = true) - Polygon outline; + public Polygon outline; - Site(String id, String name, GeoPoint point, Polygon outline) { + public Site(String id, String name, GeoPoint point, Polygon outline) { super(id, point); this.name = name; this.outline = outline; diff --git a/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java b/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java index f183542..0461fdf 100644 --- a/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java +++ b/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java @@ -27,9 +27,9 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; + import org.osmdroid.DefaultResourceProxyImpl; import org.osmdroid.ResourceProxy; -import org.osmdroid.tileprovider.MapTileProviderArray; import org.osmdroid.tileprovider.tilesource.TileSourceFactory; import org.osmdroid.util.GeoPoint; import org.osmdroid.views.MapController; @@ -714,7 +714,6 @@ public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity<Databa MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.map_menu, menu); return true; - } @Override diff --git a/src/net/cbaines/suma/Stop.java b/src/net/cbaines/suma/Stop.java index 2fa8d33..04eb118 100644 --- a/src/net/cbaines/suma/Stop.java +++ b/src/net/cbaines/suma/Stop.java @@ -33,28 +33,30 @@ public class Stop { int id; @DatabaseField(canBeNull = false) - String name; + public String name; @DatabaseField(canBeNull = false, foreign = true) BusStop destStop; @DatabaseField(canBeNull = true, foreign = true) - Bus bus; + public Bus bus; @DatabaseField(canBeNull = false, foreign = true) - BusStop busStop; + public BusStop busStop; @DatabaseField(canBeNull = false) - Date arivalTime; + public Date arivalTime; @DatabaseField(canBeNull = false) Date timeOfFetch; + BusRoute route; + Stop() { } - Stop(String name, BusStop busStop, BusStop dest, Bus bus, Date arivalTime, Date timeOfFetch) { + public Stop(String name, BusStop busStop, BusStop dest, Bus bus, Date arivalTime, Date timeOfFetch) { this.name = name; this.busStop = busStop; this.destStop = dest; @@ -63,7 +65,7 @@ public class Stop { this.timeOfFetch = timeOfFetch; } - Stop(String name, BusStop busStop, BusStop dest, Date arivalTime, Date timeOfFetch) { + public Stop(String name, BusStop busStop, BusStop dest, Date arivalTime, Date timeOfFetch) { this(name, busStop, dest, null, arivalTime, timeOfFetch); } diff --git a/src/net/cbaines/suma/StopView.java b/src/net/cbaines/suma/StopView.java index 9e58eb4..e36b3d9 100644 --- a/src/net/cbaines/suma/StopView.java +++ b/src/net/cbaines/suma/StopView.java @@ -20,6 +20,7 @@ package net.cbaines.suma; import java.sql.SQLException; +import java.text.DateFormat; import android.content.Context; import android.view.Gravity; @@ -78,12 +79,11 @@ public class StopView extends LinearLayout implements OnClickListener { busDao.refresh(stop.bus); if (stop.bus != null) { - onClickMessage = "Bus " + stop.bus.toString(); + onClickMessage = "Bus " + stop.bus.toString() + " at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); } else { - onClickMessage = "Unidentified bus"; + onClickMessage = "Unidentified bus at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); } } catch (SQLException e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/net/cbaines/suma/StringDistanceComparator.java b/src/net/cbaines/suma/StringDistanceComparator.java index 0d19f53..9230f1c 100644 --- a/src/net/cbaines/suma/StringDistanceComparator.java +++ b/src/net/cbaines/suma/StringDistanceComparator.java @@ -21,6 +21,7 @@ package net.cbaines.suma; import java.util.Comparator; + public class StringDistanceComparator implements Comparator<POI> { private String userString; diff --git a/src/net/cbaines/suma/TimetableAdapter.java b/src/net/cbaines/suma/TimetableAdapter.java index 19ca5a5..b4dfab5 100644 --- a/src/net/cbaines/suma/TimetableAdapter.java +++ b/src/net/cbaines/suma/TimetableAdapter.java @@ -43,6 +43,8 @@ public class TimetableAdapter extends BaseAdapter { } public View getView(int position, View convertView, ViewGroup parent) { + Log.i(TAG, "Returning stop " + position + " " + timetable.get(position)); + StopView stopView; if (convertView == null) { stopView = new StopView(context, timetable.get(position)); @@ -52,7 +54,9 @@ public class TimetableAdapter extends BaseAdapter { } if (changed == null || changed[position]) { + a.reset(); stopView.startAnimation(a); + Log.i(TAG, "Animating it"); } return stopView; diff --git a/src/net/cbaines/suma/Util.java b/src/net/cbaines/suma/Util.java index 7efbcbf..420d848 100644 --- a/src/net/cbaines/suma/Util.java +++ b/src/net/cbaines/suma/Util.java @@ -21,6 +21,7 @@ package net.cbaines.suma; import java.util.ArrayList; + import org.osmdroid.util.GeoPoint; import android.location.Location; |