From b5d0db004eaf72e9eeff0dfd7f612591d670b139 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 28 Feb 2012 14:01:42 +0000 Subject: Added a BusRoute activity, and moved more stuff over to the new uri system. --- gen/net/cbaines/suma/R.java | Bin 12914 -> 13305 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'gen') diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index 06657e6..20027e0 100644 Binary files a/gen/net/cbaines/suma/R.java and b/gen/net/cbaines/suma/R.java differ -- cgit v1.2.3 From 0b5aefbe0ff01638dd264222c5368ad02a0fe1ee Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 28 Feb 2012 19:09:23 +0000 Subject: Fixed two bugs relating to the query on the database not being ordered?, and implemented a new preference option. --- AndroidManifest.xml | 4 +- gen/net/cbaines/suma/R.java | Bin 13305 -> 13617 bytes project.properties | 2 +- res/layout/bus_route_activity.xml | 16 +++--- res/layout/bus_stop_activity.xml | 13 ++--- res/values/strings.xml | 4 ++ res/xml/preferences.xml | 9 ++++ src/net/cbaines/suma/BusRoute.java | 74 +++++++++++++------------- src/net/cbaines/suma/BusStopActivity.java | 10 ++-- src/net/cbaines/suma/DataManager.java | 22 ++++---- src/net/cbaines/suma/DatabaseHelper.java | 8 +-- src/net/cbaines/suma/MapActivity.java | 2 +- src/net/cbaines/suma/POIView.java | 28 +++++++--- src/net/cbaines/suma/Preferences.java | 3 ++ src/net/cbaines/suma/PreferencesActivity.java | 3 ++ src/net/cbaines/suma/RouteStop.java | 63 ++++++++++++++++++++++ src/net/cbaines/suma/RouteStops.java | 60 --------------------- 17 files changed, 182 insertions(+), 139 deletions(-) create mode 100644 src/net/cbaines/suma/RouteStop.java delete mode 100644 src/net/cbaines/suma/RouteStops.java (limited to 'gen') 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)" > - + diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index 20027e0..aec5afc 100644 Binary files a/gen/net/cbaines/suma/R.java and b/gen/net/cbaines/suma/R.java differ 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" > + + - - + android:textAppearance="?android:attr/textAppearanceMedium" /> + android:textAppearance="?android:attr/textAppearanceMedium" /> + android:text="@string/bustimes_favourite_checkbox_label" + android:textAppearance="?android:attr/textAppearanceMedium" /> + Appearance + Show Identifiers + Showing Identifiers + Hiding Identifiers Positioning GPS GPS Enabled 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 @@ -1,6 +1,15 @@ + + + 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. *
    *
  • U1 = A
  • *
  • U2 = B
  • @@ -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. *
      *
    • U1 = C
    • *
    • U2 = C
    • @@ -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 routeStopsDao = helper.getRouteStopsDao(); + Dao routeStopsDao = helper.getRouteStopsDao(); Dao busStopDao = helper.getBusStopDao(); - QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id); - PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id); + PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + List routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + Collections.sort(routeStopsFound); - ArrayList stopIndexs = new ArrayList(); + Set stopIndexs = new HashSet(); - 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 routeStopsDao = helper.getRouteStopsDao(); + Dao routeStopsDao = helper.getRouteStopsDao(); Dao busStopDao = helper.getBusStopDao(); - QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id); - PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id); + PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + List 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 routeStopsDao = helper.getRouteStopsDao(); + Dao routeStopsDao = helper.getRouteStopsDao(); Dao busStopDao = helper.getBusStopDao(); - QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id); - PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id); + PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + List 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 routeStopsDao = helper.getRouteStopsDao(); + Dao routeStopsDao = helper.getRouteStopsDao(); Dao busStopDao = helper.getBusStopDao(); - QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id); - PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id); + PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery); + List 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 impleme busStop = busStopDao.queryForId(busStopID); Dao busRouteDao = helper.getBusRouteDao(); - Dao routeStopsDao = helper.getRouteStopsDao(); + Dao routeStopsDao = helper.getRouteStopsDao(); for (BusRoute route : busRouteDao) { - QueryBuilder queryBuilder = routeStopsDao.queryBuilder(); + QueryBuilder 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 preparedQuery = queryBuilder.prepare(); + PreparedQuery 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 busStopDao = helper.getBusStopDao(); Dao busRouteDao = helper.getBusRouteDao(); - Dao routeStopsDao = helper.getRouteStopsDao(); + Dao 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 routeStopsDao = null; + Dao routeStopsDao = null; if (routeStopsDao == null) routeStopsDao = helper.getRouteStopsDao(); if (busDao == null) @@ -568,12 +568,12 @@ public class DataManager { if (destStop != null) { - QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, route.id).and() - .eq(RouteStops.STOP_ID_FIELD_NAME, destStop.id); - PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); + QueryBuilder routeStopsQueryBuilder = routeStopsDao.queryBuilder(); + routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, route.id).and() + .eq(RouteStop.STOP_ID_FIELD_NAME, destStop.id); + PreparedQuery routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - List routeStops = routeStopsDao.query(routeStopsPreparedQuery); + List 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 routeStopsDao = null; + Dao 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 = routeStopsDao.queryForEq(RouteStops.ROUTE_ID_FIELD_NAME, busRoute.id); + List routeStops = routeStopsDao.queryForEq(RouteStop.ROUTE_ID_FIELD_NAME, busRoute.id); ArrayList directions = new ArrayList(); 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 buildingDao = null; private Dao busStopDao = null; private Dao busRouteDao = null; - private Dao routeStopsDao = null; + private Dao routeStopsDao = null; private Dao siteDao = null; private Dao 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 getRouteStopsDao() throws SQLException { + public Dao 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 implements Dao busStopDao = helper.getBusStopDao(); Dao busRouteDao = helper.getBusRouteDao(); - Dao routeStopsDao = helper.getRouteStopsDao(); + Dao 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/RouteStop.java b/src/net/cbaines/suma/RouteStop.java new file mode 100644 index 0000000..a19f4fa --- /dev/null +++ b/src/net/cbaines/suma/RouteStop.java @@ -0,0 +1,63 @@ +/* + * 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.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +@DatabaseTable(tableName = "routestops") +public class RouteStop implements Comparable { + 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. + */ + @DatabaseField(generatedId = true) + int id; + + @DatabaseField + int sequence; + + // This is a foreign object which just stores the id from the User object in + // this table. + @DatabaseField(foreign = true, columnName = STOP_ID_FIELD_NAME, indexName = "routestops_routestop_idx") + BusStop busStop; + + // This is a foreign object which just stores the id from the Post object in + // this table. + @DatabaseField(foreign = true, columnName = ROUTE_ID_FIELD_NAME, indexName = "routestops_routestop_idx") + BusRoute busRoute; + + RouteStop() { + } + + 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; + } +} diff --git a/src/net/cbaines/suma/RouteStops.java b/src/net/cbaines/suma/RouteStops.java deleted file mode 100644 index 2f6c00a..0000000 --- a/src/net/cbaines/suma/RouteStops.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.field.DatabaseField; -import com.j256.ormlite.table.DatabaseTable; - -@DatabaseTable(tableName = "routestops") -public class RouteStops { - 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. - */ - @DatabaseField(generatedId = true) - int id; - - @DatabaseField - int sequence; - - // This is a foreign object which just stores the id from the User object in - // this table. - @DatabaseField(foreign = true, columnName = STOP_ID_FIELD_NAME, indexName = "routestops_routestop_idx") - BusStop busStop; - - // This is a foreign object which just stores the id from the Post object in - // this table. - @DatabaseField(foreign = true, columnName = ROUTE_ID_FIELD_NAME, indexName = "routestops_routestop_idx") - BusRoute busRoute; - - RouteStops() { - } - - public RouteStops(BusStop stop, BusRoute route, int sequence) { - this.busStop = stop; - this.busRoute = route; - this.sequence = sequence; - } -} -- cgit v1.2.3 From 5f2b8712079aeb5b7cee476b06b36013edac4fb3 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 28 Feb 2012 22:22:27 +0000 Subject: Next release, many improvements. --- AndroidManifest.xml | 8 +- gen/net/cbaines/suma/R.java | Bin 13617 -> 13490 bytes project.properties | 2 +- res/layout/building_activity.xml | 42 ++++---- res/layout/bus_activity.xml | 55 ----------- res/layout/bus_route_activity.xml | 6 +- res/layout/bus_stop_activity.xml | 3 +- res/layout/find.xml | 36 ------- res/layout/find_activity.xml | 36 +++++++ res/layout/main.xml | 15 --- res/layout/map_activity.xml | 15 +++ res/values/strings.xml | 2 +- src/net/cbaines/suma/BuildingActivity.java | 148 ++++++++++++++++------------- src/net/cbaines/suma/BusActivity.java | 37 -------- src/net/cbaines/suma/BusRouteActivity.java | 110 ++++++++++++++++++++- src/net/cbaines/suma/BusStopActivity.java | 21 ++-- src/net/cbaines/suma/FindActivity.java | 2 +- src/net/cbaines/suma/MapActivity.java | 2 +- 18 files changed, 289 insertions(+), 251 deletions(-) delete mode 100644 res/layout/find.xml create mode 100644 res/layout/find_activity.xml delete mode 100644 res/layout/main.xml create mode 100644 res/layout/map_activity.xml (limited to 'gen') diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 42adfec..af78fdb 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,12 +1,10 @@ + android:versionCode="8" + android:versionName="0.5 (alpha)" > - + diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index aec5afc..f7f3034 100644 Binary files a/gen/net/cbaines/suma/R.java and b/gen/net/cbaines/suma/R.java differ diff --git a/project.properties b/project.properties index f049142..5a70945 100644 --- a/project.properties +++ b/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-10 +target=android-7 diff --git a/res/layout/building_activity.xml b/res/layout/building_activity.xml index 6ed937f..777ad0a 100644 --- a/res/layout/building_activity.xml +++ b/res/layout/building_activity.xml @@ -10,31 +10,39 @@ android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" /> + + + + + android:layout_height="fill_parent" + android:gravity="center" + android:orientation="vertical" > - + android:layout_height="wrap_content" /> + android:text="" + android:textAppearance="?android:attr/textAppearanceLarge" /> - - \ No newline at end of file diff --git a/res/layout/bus_activity.xml b/res/layout/bus_activity.xml index 3037916..f8bbe59 100644 --- a/res/layout/bus_activity.xml +++ b/res/layout/bus_activity.xml @@ -17,61 +17,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" /> - - - - - - - - - - @@ -22,13 +22,15 @@ android:id="@+id/busRouteActivityLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:paddingRight="5dp" android:textAppearance="?android:attr/textAppearanceMedium" /> + android:textAppearance="?android:attr/textAppearanceMedium" + android:visibility="gone" /> + android:textAppearance="?android:attr/textAppearanceSmall" + android:visibility="gone" /> - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/find_activity.xml b/res/layout/find_activity.xml new file mode 100644 index 0000000..6b19c67 --- /dev/null +++ b/res/layout/find_activity.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/main.xml b/res/layout/main.xml deleted file mode 100644 index dff45bd..0000000 --- a/res/layout/main.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/res/layout/map_activity.xml b/res/layout/map_activity.xml new file mode 100644 index 0000000..dff45bd --- /dev/null +++ b/res/layout/map_activity.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index e0f62e0..f3850a3 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -106,7 +106,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.< About Version - 0.4 (alpha) + 0.5 (alpha) Copyright © 2012, Christopher Baines License diff --git a/src/net/cbaines/suma/BuildingActivity.java b/src/net/cbaines/suma/BuildingActivity.java index d9baa95..509bc41 100644 --- a/src/net/cbaines/suma/BuildingActivity.java +++ b/src/net/cbaines/suma/BuildingActivity.java @@ -28,6 +28,7 @@ import java.sql.SQLException; import android.content.Context; import android.content.SharedPreferences; import android.graphics.drawable.Drawable; +import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.Display; @@ -38,13 +39,13 @@ import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ImageButton; import android.widget.ImageView.ScaleType; +import android.widget.ProgressBar; import android.widget.TextView; import com.j256.ormlite.android.apptools.OrmLiteBaseActivity; import com.j256.ormlite.dao.Dao; -public class BuildingActivity extends OrmLiteBaseActivity implements OnCheckedChangeListener, - Preferences { +public class BuildingActivity extends OrmLiteBaseActivity implements OnCheckedChangeListener, Preferences { final static String TAG = "BusTimeActivity"; @@ -53,10 +54,12 @@ public class BuildingActivity extends OrmLiteBaseActivity implem private ImageButton imageButton; private TextView buildingName; - private TextView buildingID; private Building building; + private ProgressBar progressBar; + private TextView message; + private CheckBox favouritesCheckBox; public void onCreate(Bundle savedInstanceState) { @@ -85,7 +88,9 @@ public class BuildingActivity extends OrmLiteBaseActivity implem favouritesCheckBox.setOnCheckedChangeListener(this); buildingName = (TextView) findViewById(R.id.buildingActivityName); - buildingID = (TextView) findViewById(R.id.buildingActivityID); + + progressBar = (ProgressBar) findViewById(R.id.buildingActivityLoadBar); + message = (TextView) findViewById(R.id.buildingActivityMessage); Log.i(TAG, "Building id " + ID); @@ -94,83 +99,92 @@ public class BuildingActivity extends OrmLiteBaseActivity implem building = buildingDao.queryForId(ID); - buildingName.setText(building.name); + buildingName.setText("Building " + building.id + " - " + building.name); } catch (SQLException e1) { - // TODO Auto-generated catch block e1.printStackTrace(); } - buildingID.setText(ID); - try { + GetBuildingImageTask buildingImageTask = new GetBuildingImageTask(); + buildingImageTask.execute(building); - /* First, get the Display from the WindowManager */ - Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); - - /* Now we can retrieve all display-related infos */ - int orientation = display.getOrientation(); - Log.i(TAG, "orientation " + orientation); - Log.i(TAG, "width " + display.getWidth() + " height " + display.getHeight()); - int width; - // if (orientation == 0) { - width = display.getWidth(); - // } else { - // width = display.getHeight(); - // } - - URL imageURL; - Log.i(TAG, "Screen width " + width); - if (width >= 1000) { - imageURL = new URL("http://data.southampton.ac.uk/images/buildings/1000/" + ID + ".jpg"); - } else if (width >= 800) { - imageURL = new URL("http://data.southampton.ac.uk/images/buildings/1000/" + ID + ".jpg"); - } else if (width >= 600) { - imageURL = new URL("http://data.southampton.ac.uk/images/buildings/600/" + ID + ".jpg"); - } else if (width >= 400) { - imageURL = new URL("http://data.southampton.ac.uk/images/buildings/600/" + ID + ".jpg"); - } else if (width >= 300) { - imageURL = new URL("http://data.southampton.ac.uk/images/buildings/300/" + ID + ".jpg"); - } else if (width >= 200) { - imageURL = new URL("http://data.southampton.ac.uk/images/buildings/200/" + ID + ".jpg"); - } else { - imageURL = new URL("http://data.southampton.ac.uk/images/buildings/100/" + ID + ".jpg"); - } - Log.i(TAG, "URL " + imageURL); + } + + class GetBuildingImageTask extends AsyncTask { + String errorMessage; + + @Override + protected Drawable doInBackground(Building... buildings) { + Building building = buildings[0]; + + Log.i(TAG, "Getting image for " + building); + + try { + + Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); + + int orientation = display.getOrientation(); + Log.i(TAG, "orientation " + orientation); + Log.i(TAG, "width " + display.getWidth() + " height " + display.getHeight()); + int width; + width = display.getWidth(); + + URL imageURL; + Log.i(TAG, "Screen width " + width); + if (width >= 1000) { + imageURL = new URL("http://data.southampton.ac.uk/images/buildings/1000/" + building.id + ".jpg"); + } else if (width >= 800) { + imageURL = new URL("http://data.southampton.ac.uk/images/buildings/1000/" + building.id + ".jpg"); + } else if (width >= 600) { + imageURL = new URL("http://data.southampton.ac.uk/images/buildings/600/" + building.id + ".jpg"); + } else if (width >= 400) { + imageURL = new URL("http://data.southampton.ac.uk/images/buildings/600/" + building.id + ".jpg"); + } else if (width >= 300) { + imageURL = new URL("http://data.southampton.ac.uk/images/buildings/300/" + building.id + ".jpg"); + } else if (width >= 200) { + imageURL = new URL("http://data.southampton.ac.uk/images/buildings/200/" + building.id + ".jpg"); + } else { + imageURL = new URL("http://data.southampton.ac.uk/images/buildings/100/" + building.id + ".jpg"); + } + Log.i(TAG, "URL " + imageURL); - InputStream is = (InputStream) imageURL.getContent(); - Drawable image = Drawable.createFromStream(is, "src"); + InputStream is = (InputStream) imageURL.getContent(); + Drawable image = Drawable.createFromStream(is, "src"); - imageButton = new ImageButton(this); - imageButton = (ImageButton) findViewById(R.id.buildingActivityImage); - imageButton.setImageDrawable(image); - imageButton.setScaleType(ScaleType.CENTER_INSIDE); - imageButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { + return image; - } - }); - - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + } catch (MalformedURLException e) { + e.printStackTrace(); + errorMessage = "MalformedURLException"; + } catch (IOException e) { + e.printStackTrace(); + errorMessage = "IOException"; + } + + return null; } - } + protected void onPostExecute(Drawable image) { + progressBar.setVisibility(View.GONE); - public void onResume() { - super.onResume(); - } + if (image != null) { + Log.i(TAG, "Got a image for " + building + ", now displaying it"); - public void onPause() { - super.onPause(); - } + imageButton = (ImageButton) findViewById(R.id.buildingActivityImage); + imageButton.setImageDrawable(image); + imageButton.setScaleType(ScaleType.CENTER_INSIDE); + imageButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { - public void finish() { - setResult(RESULT_OK, getIntent()); - super.finish(); + } + }); + } else { + Log.e(TAG, "Error, null image, " + errorMessage); + + message.setText(errorMessage); + message.setVisibility(View.VISIBLE); + } + } } @Override diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java index f4edc3f..1a8baf9 100644 --- a/src/net/cbaines/suma/BusActivity.java +++ b/src/net/cbaines/suma/BusActivity.java @@ -27,12 +27,6 @@ import com.j256.ormlite.android.apptools.OrmLiteBaseActivity; public class BusActivity extends OrmLiteBaseActivity implements Preferences { final static String TAG = "BusActivity"; - private TextView U1RouteTextView; - private TextView U1NRouteTextView; - private TextView U2RouteTextView; - private TextView U6RouteTextView; - private TextView U9RouteTextView; - private TextView busIDTextView; private TextView busContentMessage; @@ -115,12 +109,6 @@ public class BusActivity extends OrmLiteBaseActivity implements } } - U1RouteTextView = (TextView) findViewById(R.id.busActivityU1); - U1NRouteTextView = (TextView) findViewById(R.id.busActivityU1N); - U2RouteTextView = (TextView) findViewById(R.id.busActivityU2); - U6RouteTextView = (TextView) findViewById(R.id.busActivityU6); - U9RouteTextView = (TextView) findViewById(R.id.busActivityU9); - busIDTextView = (TextView) findViewById(R.id.busActivityBusID); busContentMessage = (TextView) findViewById(R.id.busActivityMessage); @@ -136,31 +124,6 @@ public class BusActivity extends OrmLiteBaseActivity implements busIDTextView.setText("Unidentified"); } - U1RouteTextView.setVisibility(View.GONE); - U1NRouteTextView.setVisibility(View.GONE); - U2RouteTextView.setVisibility(View.GONE); - U6RouteTextView.setVisibility(View.GONE); - U9RouteTextView.setVisibility(View.GONE); - - // if (bus.route.uniLink) { - Log.i(TAG, "Bus is uniLink"); - if (bus.route.code.equals("U1")) { - U1RouteTextView.setVisibility(View.VISIBLE); - } else if (bus.route.code.equals("U1N")) { - U1NRouteTextView.setVisibility(View.VISIBLE); - } else if (bus.route.code.equals("U2")) { - U2RouteTextView.setVisibility(View.VISIBLE); - } else if (bus.route.code.equals("U6")) { - U6RouteTextView.setVisibility(View.VISIBLE); - } else if (bus.route.code.equals("U9")) { - U9RouteTextView.setVisibility(View.VISIBLE); - } else { - Log.e(TAG, "Route not found " + bus.route.code); - } - // } else { - // Log.i(TAG, "Bus is not uniLink"); - // } - } catch (NumberFormatException e) { e.printStackTrace(); } catch (SQLException e) { diff --git a/src/net/cbaines/suma/BusRouteActivity.java b/src/net/cbaines/suma/BusRouteActivity.java index 3670c68..0a352ce 100644 --- a/src/net/cbaines/suma/BusRouteActivity.java +++ b/src/net/cbaines/suma/BusRouteActivity.java @@ -3,15 +3,24 @@ package net.cbaines.suma; import java.sql.SQLException; import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; import android.os.Bundle; +import android.preference.PreferenceManager; import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.j256.ormlite.android.apptools.OrmLiteBaseActivity; -public class BusRouteActivity extends OrmLiteBaseActivity implements Preferences { +public class BusRouteActivity extends OrmLiteBaseActivity implements Preferences, OnItemClickListener, + OnItemLongClickListener { final static String TAG = "BusActivity"; private TextView busRouteLabel; @@ -22,6 +31,8 @@ public class BusRouteActivity extends OrmLiteBaseActivity implem private ListView busRouteView; + private POIArrayAdapter arrayAdapter; + private Context instance; public void onCreate(Bundle savedInstanceState) { @@ -50,6 +61,8 @@ public class BusRouteActivity extends OrmLiteBaseActivity implem BusRoute busRoute = null; + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + try { busRoute = helper.getBusRouteDao().queryForId(Integer.parseInt(strBusRouteID)); @@ -59,8 +72,11 @@ public class BusRouteActivity extends OrmLiteBaseActivity implem busRouteCode = (TextView) findViewById(R.id.busRouteActivityCode); busRouteCode.setText(busRoute.code); - busRouteID = (TextView) findViewById(R.id.busRouteActivityID); - busRouteID.setText(String.valueOf(busRoute.id)); + if (prefs.getBoolean(SHOW_IDENTIFIERS, SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT)) { + busRouteID = (TextView) findViewById(R.id.busRouteActivityID); + busRouteID.setText(String.valueOf(busRoute.id)); + busRouteID.setVisibility(View.VISIBLE); + } busRouteView = (ListView) findViewById(R.id.busRouteBusStops); @@ -70,7 +86,93 @@ public class BusRouteActivity extends OrmLiteBaseActivity implem e.printStackTrace(); } - POIArrayAdapter arrayAdapter = new POIArrayAdapter(instance, busRoute.getRouteBusStops(instance)); + arrayAdapter = new POIArrayAdapter(instance, busRoute.getRouteBusStops(instance)); busRouteView.setAdapter(arrayAdapter); + busRouteView.setOnItemClickListener(this); + busRouteView.setOnItemLongClickListener(this); + } + + public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { + Log.i(TAG, "OnItemClick pos " + position + " id " + id); + + String poiId = arrayAdapter.getItemStringId(position); + + Log.i(TAG, "POI " + poiId + " selected"); + + POI poi = null; + + if (poiId != null) { + Log.i(TAG, "Got id " + poiId); + try { + poi = getHelper().getBusStopDao().queryForId(poiId); + } catch (SQLException e) { + e.printStackTrace(); + } + + if (poi == null) { + Log.e(TAG, "Could not find poi " + poiId + " in onActivityResult"); + } else { + + BusStop busStop = (BusStop) poi; + + Log.i(TAG, "Pressed " + busStop.id); + + Uri uri = Uri.parse("http://id.southampton.ac.uk/bus-stop/" + busStop.id); + + Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath()); + + Intent busStopIntent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(busStopIntent); + + return true; + } + } else { + Log.i(TAG, "Got null poi id"); + + // mapController.setZoom(15); + // mapController.setCenter(new GeoPoint(50935551, -1393488)); + } + + return false; + } + + public void onItemClick(AdapterView parent, View view, int position, long id) { + Log.i(TAG, "OnItemClick pos " + position + " id " + id); + + String poiId = arrayAdapter.getItemStringId(position); + + Log.i(TAG, "POI " + poiId + " selected"); + + POI poi = null; + + if (poiId != null) { + Log.i(TAG, "Got id " + poiId); + try { + poi = getHelper().getBusStopDao().queryForId(poiId); + } catch (SQLException e) { + e.printStackTrace(); + } + + if (poi == null) { + Log.e(TAG, "Could not find poi " + poiId + " in onActivityResult"); + } else { + + Log.i(TAG, "Pressed " + poi.id); + + Uri uri = Uri.parse("geo:" + Util.E6IntToDouble(poi.point.getLatitudeE6()) + "," + + Util.E6IntToDouble(poi.point.getLongitudeE6()) + "?z=18"); + + Log.i(TAG, "Starting a activity for " + uri); + + Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(mapIntent); + + } + } else { + Log.i(TAG, "Got null poi id"); + + // mapController.setZoom(15); + // mapController.setCenter(new GeoPoint(50935551, -1393488)); + } } } diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java index 8bded40..cab81b1 100644 --- a/src/net/cbaines/suma/BusStopActivity.java +++ b/src/net/cbaines/suma/BusStopActivity.java @@ -61,8 +61,8 @@ import com.j256.ormlite.dao.Dao; import com.j256.ormlite.stmt.PreparedQuery; import com.j256.ormlite.stmt.QueryBuilder; -public class BusStopActivity extends OrmLiteBaseActivity implements OnCheckedChangeListener, - Preferences, OnItemClickListener, OnLongClickListener { +public class BusStopActivity extends OrmLiteBaseActivity implements OnCheckedChangeListener, Preferences, + OnItemClickListener, OnLongClickListener { final static String TAG = "BusTimeActivity"; @@ -123,6 +123,7 @@ public class BusStopActivity extends OrmLiteBaseActivity impleme final DatabaseHelper helper = getHelper(); SharedPreferences favouritesPreferences = getSharedPreferences(FAVOURITES_PREFERENCES, 0); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); instance = this; @@ -212,7 +213,12 @@ public class BusStopActivity extends OrmLiteBaseActivity impleme } busName = (TextView) findViewById(R.id.busStopName); - busID = (TextView) findViewById(R.id.busStopID); + + if (prefs.getBoolean(SHOW_IDENTIFIERS, SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT)) { + busID = (TextView) findViewById(R.id.busStopID); + busID.setText(busStopID); + busID.setVisibility(View.VISIBLE); + } busStopMessage = (TextView) findViewById(R.id.busStopMessage); progBar = (ProgressBar) findViewById(R.id.busStopLoadBar); @@ -222,7 +228,6 @@ public class BusStopActivity extends OrmLiteBaseActivity impleme Log.i(TAG, "Got busstop id " + busStopID); busName.setText(busStop.description); - busID.setText(busStopID); } public void onResume() { @@ -315,10 +320,10 @@ public class BusStopActivity extends OrmLiteBaseActivity impleme try { final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(instance); - newTimetable = DataManager.getTimetable(instance, busStop.id, sharedPrefs.getBoolean( - MapActivity.UNI_LINK_BUS_TIMES, MapActivity.UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT), sharedPrefs - .getBoolean(MapActivity.NON_UNI_LINK_BUS_TIMES, - MapActivity.NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)); + newTimetable = DataManager + .getTimetable(instance, busStop.id, sharedPrefs.getBoolean(MapActivity.UNI_LINK_BUS_TIMES, + MapActivity.UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT), sharedPrefs.getBoolean( + MapActivity.NON_UNI_LINK_BUS_TIMES, MapActivity.NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)); } catch (SQLException e) { errorMessage = "Error message regarding SQL?"; e.printStackTrace(); diff --git a/src/net/cbaines/suma/FindActivity.java b/src/net/cbaines/suma/FindActivity.java index 1af350a..669249c 100644 --- a/src/net/cbaines/suma/FindActivity.java +++ b/src/net/cbaines/suma/FindActivity.java @@ -241,7 +241,7 @@ public class FindActivity extends OrmLiteBaseActivity implements /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.find); + setContentView(R.layout.find_activity); searchBar = (EditText) findViewById(R.id.searchBar); searchBar.addTextChangedListener(this); diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java index e2b9d66..8a7a39a 100644 --- a/src/net/cbaines/suma/MapActivity.java +++ b/src/net/cbaines/suma/MapActivity.java @@ -196,7 +196,7 @@ public class MapActivity extends OrmLiteBaseActivity implements Thread databaseThread = new Thread(this); // Start the database thread databaseThread.start(); - setContentView(R.layout.main); + setContentView(R.layout.map_activity); Log.i(TAG, "Finished setting content view " + (System.currentTimeMillis() - startTime)); -- cgit v1.2.3