diff options
-rw-r--r-- | AndroidManifest.xml | 4 | ||||
-rw-r--r-- | gen/net/cbaines/suma/R.java | 110 | ||||
-rw-r--r-- | project.properties | 2 | ||||
-rw-r--r-- | res/layout/bus_route_activity.xml | 16 | ||||
-rw-r--r-- | res/layout/bus_stop_activity.xml | 13 | ||||
-rw-r--r-- | res/values/strings.xml | 4 | ||||
-rw-r--r-- | res/xml/preferences.xml | 9 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusRoute.java | 74 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusStopActivity.java | 10 | ||||
-rw-r--r-- | src/net/cbaines/suma/DataManager.java | 22 | ||||
-rw-r--r-- | src/net/cbaines/suma/DatabaseHelper.java | 8 | ||||
-rw-r--r-- | src/net/cbaines/suma/MapActivity.java | 2 | ||||
-rw-r--r-- | src/net/cbaines/suma/POIView.java | 28 | ||||
-rw-r--r-- | src/net/cbaines/suma/Preferences.java | 3 | ||||
-rw-r--r-- | src/net/cbaines/suma/PreferencesActivity.java | 3 | ||||
-rw-r--r-- | src/net/cbaines/suma/RouteStop.java (renamed from src/net/cbaines/suma/RouteStops.java) | 15 |
16 files changed, 185 insertions, 138 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1eb5c8a..42adfec 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -4,7 +4,9 @@ android:versionCode="7" android:versionName="0.4 (alpha)" > - <uses-sdk android:minSdkVersion="7" /> + <uses-sdk + android:minSdkVersion="4" + android:targetSdkVersion="10" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index 20027e0..aec5afc 100644 --- a/gen/net/cbaines/suma/R.java +++ b/gen/net/cbaines/suma/R.java @@ -68,10 +68,10 @@ public final class R { public static final int busActivityU2=0x7f0a000d; public static final int busActivityU6=0x7f0a000e; public static final int busActivityU9=0x7f0a000f; - public static final int busRouteActivityCode=0x7f0a0015; - public static final int busRouteActivityHeaderLayout=0x7f0a0013; + public static final int busRouteActivityCode=0x7f0a0013; + public static final int busRouteActivityHeaderLayout=0x7f0a0014; public static final int busRouteActivityID=0x7f0a0016; - public static final int busRouteActivityLabel=0x7f0a0014; + public static final int busRouteActivityLabel=0x7f0a0015; public static final int busRouteBusStops=0x7f0a0017; public static final int busStopID=0x7f0a001f; public static final int busStopListItems=0x7f0a0026; @@ -156,47 +156,47 @@ public final class R { public static final int U9=0x7f07000d; /** About Strings */ - public static final int about=0x7f070034; - public static final int about_android_market=0x7f070041; - public static final int about_android_market_summary=0x7f070042; - public static final int about_copyright=0x7f070037; - public static final int about_copyright_summary=0x7f070038; - public static final int about_data=0x7f07003f; - public static final int about_data_summary=0x7f070040; - public static final int about_database=0x7f07004b; - public static final int about_database_summary=0x7f07004c; - public static final int about_developer=0x7f07003d; - public static final int about_developer_summary=0x7f07003e; - public static final int about_donate=0x7f07004d; - public static final int about_donate_summary=0x7f07004e; + public static final int about=0x7f070038; + public static final int about_android_market=0x7f070045; + public static final int about_android_market_summary=0x7f070046; + public static final int about_copyright=0x7f07003b; + public static final int about_copyright_summary=0x7f07003c; + public static final int about_data=0x7f070043; + public static final int about_data_summary=0x7f070044; + public static final int about_database=0x7f07004f; + public static final int about_database_summary=0x7f070050; + public static final int about_developer=0x7f070041; + public static final int about_developer_summary=0x7f070042; + public static final int about_donate=0x7f070051; + public static final int about_donate_summary=0x7f070052; public static final int about_help_message=0x7f070016; - public static final int about_license=0x7f070039; - public static final int about_license_summary=0x7f07003a; - public static final int about_map_data=0x7f070043; - public static final int about_map_data_summary=0x7f070044; - public static final int about_map_icons=0x7f070045; - public static final int about_map_icons_summary=0x7f070046; - public static final int about_map_tiles=0x7f070049; - public static final int about_map_tiles_summary=0x7f07004a; + public static final int about_license=0x7f07003d; + public static final int about_license_summary=0x7f07003e; + public static final int about_map_data=0x7f070047; + public static final int about_map_data_summary=0x7f070048; + public static final int about_map_icons=0x7f070049; + public static final int about_map_icons_summary=0x7f07004a; + public static final int about_map_tiles=0x7f07004d; + public static final int about_map_tiles_summary=0x7f07004e; /** About Messages */ - public static final int about_menu_instruction_text=0x7f07002d; - public static final int about_osm_map=0x7f070047; - public static final int about_osm_map_summary=0x7f070048; - public static final int about_project=0x7f07003b; - public static final int about_project_summary=0x7f07003c; - public static final int about_version=0x7f070035; - public static final int about_version_summary=0x7f070036; + public static final int about_menu_instruction_text=0x7f070031; + public static final int about_osm_map=0x7f07004b; + public static final int about_osm_map_summary=0x7f07004c; + public static final int about_project=0x7f07003f; + public static final int about_project_summary=0x7f070040; + public static final int about_version=0x7f070039; + public static final int about_version_summary=0x7f07003a; public static final int app_name=0x7f070004; public static final int bitcoin_error_message=0x7f07001b; - public static final int buildingImageDescription=0x7f07004f; + public static final int buildingImageDescription=0x7f070053; public static final int building_non_residential=0x7f070007; public static final int building_residential=0x7f070006; - public static final int bustimes_favourite_checkbox_label=0x7f07002e; + public static final int bustimes_favourite_checkbox_label=0x7f070032; public static final int credits_help_message=0x7f070019; public static final int donate_button=0x7f07001a; - public static final int donate_dialog_error_title=0x7f070030; - public static final int donate_dialog_message=0x7f07002f; + public static final int donate_dialog_error_title=0x7f070034; + public static final int donate_dialog_message=0x7f070033; public static final int favourites_dialog_message=0x7f07001d; public static final int favourites_dialog_title=0x7f070010; public static final int favourites_help_message=0x7f070017; @@ -211,31 +211,35 @@ 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=0x7f070032; + public static final int menu_next_stop=0x7f070036; public static final int menu_preferences=0x7f070001; - public static final int menu_previous_stop=0x7f070031; - public static final int menu_refresh_stop=0x7f070033; + public static final int menu_previous_stop=0x7f070035; + public static final int menu_refresh_stop=0x7f070037; public static final int menu_view=0x7f070002; public static final int pref_bus_stop=0x7f070008; public static final int preferences=0x7f07001c; - public static final int preferences_catagory_data=0x7f070029; - public static final int preferences_catagory_live_bus_times=0x7f070022; /** Preferences Messages */ - public static final int preferences_catagory_positioning=0x7f07001e; - public static final int preferences_gps=0x7f07001f; - public static final int preferences_gps_disabled=0x7f070021; - public static final int preferences_gps_enabled=0x7f070020; + public static final int preferences_catagory_appearance=0x7f07001e; + public static final int preferences_catagory_data=0x7f07002d; + public static final int preferences_catagory_live_bus_times=0x7f070026; + public static final int preferences_catagory_positioning=0x7f070022; + public static final int preferences_gps=0x7f070023; + public static final int preferences_gps_disabled=0x7f070025; + public static final int preferences_gps_enabled=0x7f070024; public static final int preferences_help_message=0x7f070013; - public static final int preferences_non_uni_link=0x7f07002a; - public static final int preferences_non_uni_link_disabled=0x7f07002c; - public static final int preferences_non_uni_link_enabled=0x7f07002b; - public static final int preferences_non_uni_link_live_bus_times=0x7f070026; - public static final int preferences_non_uni_link_live_bus_times_disabled=0x7f070028; - public static final int preferences_non_uni_link_live_bus_times_enabled=0x7f070027; - public static final int preferences_uni_link_live_bus_times=0x7f070023; - public static final int preferences_uni_link_live_bus_times_disabled=0x7f070025; - public static final int preferences_uni_link_live_bus_times_enabled=0x7f070024; + public static final int preferences_non_uni_link=0x7f07002e; + public static final int preferences_non_uni_link_disabled=0x7f070030; + public static final int preferences_non_uni_link_enabled=0x7f07002f; + public static final int preferences_non_uni_link_live_bus_times=0x7f07002a; + public static final int preferences_non_uni_link_live_bus_times_disabled=0x7f07002c; + public static final int preferences_non_uni_link_live_bus_times_enabled=0x7f07002b; + public static final int preferences_show_identifiers=0x7f07001f; + public static final int preferences_show_identifiers_disabled=0x7f070021; + public static final int preferences_show_identifiers_enabled=0x7f070020; + public static final int preferences_uni_link_live_bus_times=0x7f070027; + public static final int preferences_uni_link_live_bus_times_disabled=0x7f070029; + public static final int preferences_uni_link_live_bus_times_enabled=0x7f070028; public static final int view_help_message=0x7f070015; } public static final class xml { diff --git a/project.properties b/project.properties index 5a70945..f049142 100644 --- a/project.properties +++ b/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-7 +target=android-10 diff --git a/res/layout/bus_route_activity.xml b/res/layout/bus_route_activity.xml index fde127c..94a0d07 100644 --- a/res/layout/bus_route_activity.xml +++ b/res/layout/bus_route_activity.xml @@ -6,6 +6,12 @@ android:orientation="vertical" android:theme="@android:style/Theme.NoTitleBar" > + <TextView + android:id="@+id/busRouteActivityCode" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceLarge" /> + <LinearLayout android:id="@+id/busRouteActivityHeaderLayout" android:layout_width="fill_parent" @@ -16,19 +22,13 @@ android:id="@+id/busRouteActivityLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" /> - - <TextView - android:id="@+id/busRouteActivityCode" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" /> + android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/busRouteActivityID" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" /> + android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> <ListView diff --git a/res/layout/bus_stop_activity.xml b/res/layout/bus_stop_activity.xml index 24200c6..fcfe6da 100644 --- a/res/layout/bus_stop_activity.xml +++ b/res/layout/bus_stop_activity.xml @@ -27,7 +27,7 @@ android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U1" - android:textAppearance="?android:attr/textAppearanceSmall" + android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#FFFFFF" /> <CheckBox @@ -40,7 +40,7 @@ android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U1N" - android:textAppearance="?android:attr/textAppearanceSmall" + android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#FFFFFF" /> <CheckBox @@ -53,7 +53,7 @@ android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U2" - android:textAppearance="?android:attr/textAppearanceSmall" + android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#FFFFFF" /> <CheckBox @@ -66,7 +66,7 @@ android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U6" - android:textAppearance="?android:attr/textAppearanceSmall" + android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#FFFFFF" /> <CheckBox @@ -79,14 +79,15 @@ android:paddingLeft="5dp" android:paddingRight="5dp" android:text="@string/U9" - android:textAppearance="?android:attr/textAppearanceSmall" + android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#FFFFFF" /> <CheckBox android:id="@+id/favouriteCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/bustimes_favourite_checkbox_label" /> + android:text="@string/bustimes_favourite_checkbox_label" + android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/busStopID" diff --git a/res/values/strings.xml b/res/values/strings.xml index 6333664..e0f62e0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -74,6 +74,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.< </string-array> <!-- Preferences Messages --> + <string name="preferences_catagory_appearance">Appearance</string> + <string name="preferences_show_identifiers">Show Identifiers</string> + <string name="preferences_show_identifiers_enabled">Showing Identifiers</string> + <string name="preferences_show_identifiers_disabled">Hiding Identifiers</string> <string name="preferences_catagory_positioning">Positioning</string> <string name="preferences_gps">GPS</string> <string name="preferences_gps_enabled">GPS Enabled</string> diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 4a12e1c..9de3a61 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -3,6 +3,15 @@ <PreferenceCategory android:orderingFromXml="true" + android:title="@string/preferences_catagory_appearance" > + <CheckBoxPreference + android:key="showIdentifiers" + android:summaryOff="@string/preferences_show_identifiers_disabled" + android:summaryOn="@string/preferences_show_identifiers_enabled" + android:title="@string/preferences_show_identifiers" /> + </PreferenceCategory> + <PreferenceCategory + android:orderingFromXml="true" android:title="@string/preferences_catagory_positioning" > <CheckBoxPreference android:key="GPSEnabled" diff --git a/src/net/cbaines/suma/BusRoute.java b/src/net/cbaines/suma/BusRoute.java index b4dd603..ff80c66 100644 --- a/src/net/cbaines/suma/BusRoute.java +++ b/src/net/cbaines/suma/BusRoute.java @@ -22,6 +22,7 @@ package net.cbaines.suma; import java.sql.SQLException; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -64,8 +65,7 @@ public class BusRoute { String label; /** - * The direction the bus is travelling if it is moving through the route and - * sequence is increasing. + * The direction the bus is travelling if it is moving through the route and sequence is increasing. * <ul> * <li>U1 = A</li> * <li>U2 = B</li> @@ -76,8 +76,7 @@ public class BusRoute { String forwardDirection; /** - * The direction the bus is travelling if it is moving through the route and - * sequence is decreasing. + * The direction the bus is travelling if it is moving through the route and sequence is decreasing. * <ul> * <li>U1 = C</li> * <li>U2 = C</li> @@ -93,8 +92,7 @@ public class BusRoute { BusRoute() { } - public BusRoute(Integer id, String code, String label, String forwardDirection, String reverseDirection, - boolean uniLink) { + public BusRoute(Integer id, String code, String label, String forwardDirection, String reverseDirection, boolean uniLink) { this.id = id.intValue(); this.code = code; this.label = label; @@ -153,18 +151,19 @@ public class BusRoute { DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); try { - Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao(); + Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao(); Dao<BusStop, String> busStopDao = helper.getBusStopDao(); - QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id); - PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id); + PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + List<RouteStop> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + Collections.sort(routeStopsFound); - ArrayList<Integer> stopIndexs = new ArrayList<Integer>(); + Set<Integer> stopIndexs = new HashSet<Integer>(); - for (RouteStops routeStop : routeStopsFound) { + for (RouteStop routeStop : routeStopsFound) { if (routeStop.busStop.id.equals(busStop.id)) { stopIndexs.add(routeStop.sequence - 1); } @@ -241,18 +240,19 @@ public class BusRoute { } try { - Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao(); + Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao(); Dao<BusStop, String> busStopDao = helper.getBusStopDao(); - QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id); - PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id); + PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + List<RouteStop> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + Collections.sort(routeStopsFound); int stopIndex = -1; - for (RouteStops routeStop : routeStopsFound) { + for (RouteStop routeStop : routeStopsFound) { if (routeStop.busStop.id.equals(busStop.id)) { if (stopIndex == -1) { stopIndex = routeStop.sequence - 1; @@ -377,8 +377,9 @@ public class BusRoute { } if (moveAmount > 0) { - Log.v(TAG, "Moving forward " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/" - + routeStopsFound.size() + ")"); + Log.v(TAG, + "Moving forward " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/" + + routeStopsFound.size() + ")"); int stopWanted = stopIndex + moveAmount; if ((stopWanted + 1) > routeStopsFound.size()) { Log.v(TAG, "Off the end of the route"); @@ -401,9 +402,8 @@ public class BusRoute { Log.v(TAG, "stopWanted " + stopWanted); busStopDao.refresh(routeStopsFound.get(stopWanted).busStop); - Log.v(TAG, - "Moving backwards " + moveAmount + " stops from " + busStop + " to " - + routeStopsFound.get(stopWanted).busStop + " in route " + this); + Log.v(TAG, "Moving backwards " + moveAmount + " stops from " + busStop + " to " + + routeStopsFound.get(stopWanted).busStop + " in route " + this); return routeStopsFound.get(stopWanted).busStop; } @@ -442,14 +442,15 @@ public class BusRoute { try { - Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao(); + Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao(); Dao<BusStop, String> busStopDao = helper.getBusStopDao(); - QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id); - PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id); + PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + List<RouteStop> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + Collections.sort(routeStopsFound); int startStopSeq = -1; int endStopSeq = -1; @@ -500,7 +501,7 @@ public class BusRoute { Log.e(TAG, "Error, unrecognised route " + id); } - for (RouteStops routeStop : routeStopsFound) { + for (RouteStop routeStop : routeStopsFound) { if (routeStop.sequence >= startStopSeq && routeStop.sequence <= endStopSeq) { busStopDao.refresh(routeStop.busStop); busStops.add(routeStop.busStop); @@ -525,16 +526,17 @@ public class BusRoute { try { - Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao(); + Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao(); Dao<BusStop, String> busStopDao = helper.getBusStopDao(); - QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id); - PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id); + PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + List<RouteStop> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + Collections.sort(routeStopsFound); - for (RouteStops routeStop : routeStopsFound) { + for (RouteStop routeStop : routeStopsFound) { busStopDao.refresh(routeStop.busStop); busStops.add(routeStop.busStop); } diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java index 55a0bd6..8bded40 100644 --- a/src/net/cbaines/suma/BusStopActivity.java +++ b/src/net/cbaines/suma/BusStopActivity.java @@ -153,15 +153,15 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme busStop = busStopDao.queryForId(busStopID); Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao(); - Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao(); + Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao(); for (BusRoute route : busRouteDao) { - QueryBuilder<RouteStops, Integer> queryBuilder = routeStopsDao.queryBuilder(); + QueryBuilder<RouteStop, Integer> queryBuilder = routeStopsDao.queryBuilder(); - queryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, route.id).and() - .eq(RouteStops.STOP_ID_FIELD_NAME, busStopID); + queryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, route.id).and() + .eq(RouteStop.STOP_ID_FIELD_NAME, busStopID); queryBuilder.setCountOf(true); - PreparedQuery<RouteStops> preparedQuery = queryBuilder.prepare(); + PreparedQuery<RouteStop> preparedQuery = queryBuilder.prepare(); long count = routeStopsDao.countOf(preparedQuery); diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java index 3a550a7..5e8b195 100644 --- a/src/net/cbaines/suma/DataManager.java +++ b/src/net/cbaines/suma/DataManager.java @@ -214,11 +214,11 @@ public class DataManager { Dao<BusStop, String> busStopDao = helper.getBusStopDao(); Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao(); - Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao(); + Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao(); TableUtils.clearTable(helper.getConnectionSource(), BusStop.class); TableUtils.clearTable(helper.getConnectionSource(), BusRoute.class); - TableUtils.clearTable(helper.getConnectionSource(), RouteStops.class); + TableUtils.clearTable(helper.getConnectionSource(), RouteStop.class); Log.i(TAG, "Loading busstops from csv"); @@ -340,7 +340,7 @@ public class DataManager { int sequence = Integer.parseInt(dataBits[1]); Log.i(TAG, "Creating RouteStop " + busStop.id + " " + busRoute.code + " " + sequence); - routeStopsDao.create(new RouteStops(busStop, busRoute, sequence)); + routeStopsDao.create(new RouteStop(busStop, busRoute, sequence)); if (busRoute.id == 326) { // U1 busStop.routes = (byte) (busStop.routes | 1); @@ -457,7 +457,7 @@ public class DataManager { helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); if (busRouteDao == null) busRouteDao = helper.getBusRouteDao(); - Dao<RouteStops, Integer> routeStopsDao = null; + Dao<RouteStop, Integer> routeStopsDao = null; if (routeStopsDao == null) routeStopsDao = helper.getRouteStopsDao(); if (busDao == null) @@ -568,12 +568,12 @@ public class DataManager { if (destStop != null) { - QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, route.id).and() - .eq(RouteStops.STOP_ID_FIELD_NAME, destStop.id); - PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, route.id).and() + .eq(RouteStop.STOP_ID_FIELD_NAME, destStop.id); + PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List<RouteStops> routeStops = routeStopsDao.query(routeStopsPreparedQuery); + List<RouteStop> routeStops = routeStopsDao.query(routeStopsPreparedQuery); if (routeStops.size() > 0) { Log.i(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route " + route.code); @@ -855,7 +855,7 @@ public class DataManager { public static void routeMovementTest(Context context) throws SQLException { - Dao<RouteStops, Integer> routeStopsDao = null; + Dao<RouteStop, Integer> routeStopsDao = null; if (helper == null) helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); @@ -870,7 +870,7 @@ public class DataManager { if (!busRoute.code.startsWith("U") || busRoute.code.equals("U9")) { continue; } - List<RouteStops> routeStops = routeStopsDao.queryForEq(RouteStops.ROUTE_ID_FIELD_NAME, busRoute.id); + List<RouteStop> routeStops = routeStopsDao.queryForEq(RouteStop.ROUTE_ID_FIELD_NAME, busRoute.id); ArrayList<String> directions = new ArrayList<String>(); if (busRoute.forwardDirection != null) { diff --git a/src/net/cbaines/suma/DatabaseHelper.java b/src/net/cbaines/suma/DatabaseHelper.java index 13f4957..facfe85 100644 --- a/src/net/cbaines/suma/DatabaseHelper.java +++ b/src/net/cbaines/suma/DatabaseHelper.java @@ -48,7 +48,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private Dao<Building, String> buildingDao = null; private Dao<BusStop, String> busStopDao = null; private Dao<BusRoute, Integer> busRouteDao = null; - private Dao<RouteStops, Integer> routeStopsDao = null; + private Dao<RouteStop, Integer> routeStopsDao = null; private Dao<Site, String> siteDao = null; private Dao<Bus, Integer> busDao = null; @@ -67,7 +67,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { TableUtils.createTable(connectionSource, Building.class); TableUtils.createTable(connectionSource, BusStop.class); TableUtils.createTable(connectionSource, BusRoute.class); - TableUtils.createTable(connectionSource, RouteStops.class); + TableUtils.createTable(connectionSource, RouteStop.class); TableUtils.createTable(connectionSource, Site.class); TableUtils.createTable(connectionSource, Bus.class); } catch (SQLException e) { @@ -125,9 +125,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { * Returns the Database Access Object (DAO) for our SimpleData class. It * will create it or just give the cached value. */ - public Dao<RouteStops, Integer> getRouteStopsDao() throws SQLException { + public Dao<RouteStop, Integer> getRouteStopsDao() throws SQLException { if (routeStopsDao == null) { - routeStopsDao = getDao(RouteStops.class); + routeStopsDao = getDao(RouteStop.class); } return routeStopsDao; } diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java index 8f555da..e2b9d66 100644 --- a/src/net/cbaines/suma/MapActivity.java +++ b/src/net/cbaines/suma/MapActivity.java @@ -389,7 +389,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements Dao<BusStop, String> busStopDao = helper.getBusStopDao(); Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao(); - Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao(); + Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao(); long busStopCount = busStopDao.countOf(); long busRouteCount = busRouteDao.countOf(); diff --git a/src/net/cbaines/suma/POIView.java b/src/net/cbaines/suma/POIView.java index b27b4f3..95c571c 100644 --- a/src/net/cbaines/suma/POIView.java +++ b/src/net/cbaines/suma/POIView.java @@ -20,6 +20,7 @@ package net.cbaines.suma; import android.content.Context; +import android.preference.PreferenceManager; import android.util.Log; import android.view.Display; import android.view.Gravity; @@ -27,7 +28,7 @@ import android.view.WindowManager; import android.widget.LinearLayout; import android.widget.TextView; -public class POIView extends LinearLayout { +public class POIView extends LinearLayout implements Preferences { private final static String TAG = "POIView"; @@ -37,6 +38,8 @@ public class POIView extends LinearLayout { private LayoutParams textLayoutParams; + private boolean identifiersEnabled; + final int width; public POIView(Context context, POI poi) { @@ -46,6 +49,9 @@ public class POIView extends LinearLayout { public POIView(Context context, POI poi, int distInM) { super(context); + identifiersEnabled = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SHOW_IDENTIFIERS, + SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT); + Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); width = display.getWidth(); // int height = display.getHeight(); @@ -85,14 +91,22 @@ public class POIView extends LinearLayout { Building building = (Building) poi; // Log.i(TAG, "Its a building of name " + building.name); - name.setText(building.name + " (" + building.id + ")"); + if (identifiersEnabled) { + name.setText(building.name + " (" + building.id + ")"); + } else { + name.setText(building.name); + } } else if (poi.type == POI.BUS_STOP) { BusStop busStop = (BusStop) poi; // Log.i(TAG, "Its a bus stop of description " + // busStop.description); - name.setText(busStop.description + " (" + busStop.id + ")"); + if (identifiersEnabled) { + name.setText(busStop.description + " (" + busStop.id + ")"); + } else { + name.setText(busStop.description); + } routes.setRoutes(busStop.routes); @@ -100,8 +114,11 @@ public class POIView extends LinearLayout { Site site = (Site) poi; // Log.i(TAG, "Its a site of name " + site.name); - - name.setText(site.name + " (" + site.id + ")"); + if (identifiersEnabled) { + name.setText(site.name + " (" + site.id + ")"); + } else { + name.setText(site.name); + } } else { Log.w(TAG, "Cant identify " + poi.type); @@ -121,5 +138,4 @@ public class POIView extends LinearLayout { // Log.w("POIView", "No dist avalible for S" + poi.id); } } - }
\ No newline at end of file diff --git a/src/net/cbaines/suma/Preferences.java b/src/net/cbaines/suma/Preferences.java index ff8f366..0508251 100644 --- a/src/net/cbaines/suma/Preferences.java +++ b/src/net/cbaines/suma/Preferences.java @@ -11,5 +11,8 @@ public interface Preferences { static final String NON_UNI_LINK_BUS_STOPS_OVERLAY = "nonUniLinkBusStops"; static final boolean NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT = false; + static final String SHOW_IDENTIFIERS = "showIdentifiers"; + static final boolean SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT = false; + static final String FAVOURITES_PREFERENCES = "favourites"; } diff --git a/src/net/cbaines/suma/PreferencesActivity.java b/src/net/cbaines/suma/PreferencesActivity.java index 39e6bb2..bab72bf 100644 --- a/src/net/cbaines/suma/PreferencesActivity.java +++ b/src/net/cbaines/suma/PreferencesActivity.java @@ -45,6 +45,9 @@ public class PreferencesActivity extends PreferenceActivity implements Preferenc if (!sharedPrefs.contains(NON_UNI_LINK_BUS_STOPS_OVERLAY)) { editor.putBoolean(NON_UNI_LINK_BUS_STOPS_OVERLAY, NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT); } + if (!sharedPrefs.contains(SHOW_IDENTIFIERS)) { + editor.putBoolean(SHOW_IDENTIFIERS, SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT); + } editor.commit(); addPreferencesFromResource(R.xml.preferences); diff --git a/src/net/cbaines/suma/RouteStops.java b/src/net/cbaines/suma/RouteStop.java index 2f6c00a..a19f4fa 100644 --- a/src/net/cbaines/suma/RouteStops.java +++ b/src/net/cbaines/suma/RouteStop.java @@ -23,15 +23,14 @@ import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; @DatabaseTable(tableName = "routestops") -public class RouteStops { +public class RouteStop implements Comparable<RouteStop> { public final static String STOP_ID_FIELD_NAME = "stop_id"; public final static String ROUTE_ID_FIELD_NAME = "route_id"; public final static String SEQUENCE_ID_FIELD_NAME = "sequence"; /** - * This id is generated by the database and set on the object when it is - * passed to the create method. An id is needed in case we need to update or - * delete this object in the future. + * This id is generated by the database and set on the object when it is passed to the create method. An id is needed in case + * we need to update or delete this object in the future. */ @DatabaseField(generatedId = true) int id; @@ -49,12 +48,16 @@ public class RouteStops { @DatabaseField(foreign = true, columnName = ROUTE_ID_FIELD_NAME, indexName = "routestops_routestop_idx") BusRoute busRoute; - RouteStops() { + RouteStop() { } - public RouteStops(BusStop stop, BusRoute route, int sequence) { + public RouteStop(BusStop stop, BusRoute route, int sequence) { this.busStop = stop; this.busRoute = route; this.sequence = sequence; } + + public int compareTo(RouteStop routeStop) { + return this.sequence - routeStop.sequence; + } } |