From 409ab7c3e764a877116e7f05dd9fd5a5eaf2ccf0 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 8 Feb 2012 14:21:28 +0000 Subject: Preference changes and other stuff... --- src/net/cbaines/suma/BuildingActivity.java | 3 +- src/net/cbaines/suma/DataManager.java | 6 +- src/net/cbaines/suma/Preferences.java | 4 + .../suma/SouthamptonUniversityMapActivity.java | 203 +++++++++++---------- src/net/cbaines/suma/Stop.java | 8 +- src/net/cbaines/suma/StopView.java | 13 +- 6 files changed, 138 insertions(+), 99 deletions(-) (limited to 'src') diff --git a/src/net/cbaines/suma/BuildingActivity.java b/src/net/cbaines/suma/BuildingActivity.java index 7637439..df6dea2 100644 --- a/src/net/cbaines/suma/BuildingActivity.java +++ b/src/net/cbaines/suma/BuildingActivity.java @@ -1,4 +1,5 @@ /* + * Southampton University Map App * Copyright (C) 2011 Christopher Baines * @@ -57,8 +58,6 @@ public class BuildingActivity extends OrmLiteBaseActivity { // read the RDF/XML file model.read(in, null); - - instance = this; diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java index d4d0968..536cc64 100644 --- a/src/net/cbaines/suma/DataManager.java +++ b/src/net/cbaines/suma/DataManager.java @@ -430,6 +430,7 @@ public class DataManager { String time = stopObj.getString("time"); GregorianCalendar calender = new GregorianCalendar(); + boolean live = true; if (!time.equals("Due")) { Log.v(TAG, "Time: " + time + " current time " + calender.getTime()); @@ -438,6 +439,7 @@ public class DataManager { String[] minAndHour = time.split(":"); calender.set(Calendar.HOUR_OF_DAY, Integer.parseInt(minAndHour[0])); calender.set(Calendar.MINUTE, Integer.parseInt(minAndHour[1])); + live = false; } else { // Log.i(TAG, "Parsing " + time.substring(0, time.length() - 1) + " for min"); calender.add(Calendar.MINUTE, Integer.parseInt(time.substring(0, time.length() - 1))); @@ -534,7 +536,7 @@ public class DataManager { busDao.update(bus); - stop = new Stop(bus, busStop, calender.getTime(), now); + stop = new Stop(bus, busStop, calender.getTime(), now, live); return stop; @@ -574,7 +576,7 @@ public class DataManager { if (!keepNonUniLink && !stopObj.getString("name").startsWith("U")) { continue; } - + if (!keepUniLink && stopObj.getString("name").startsWith("U")) { continue; } diff --git a/src/net/cbaines/suma/Preferences.java b/src/net/cbaines/suma/Preferences.java index e2c79a0..c92a86c 100644 --- a/src/net/cbaines/suma/Preferences.java +++ b/src/net/cbaines/suma/Preferences.java @@ -1,12 +1,16 @@ package net.cbaines.suma; public interface Preferences { + // Preferences static final String GPS_ENABLED = "GPSEnabled"; static final boolean GPS_ENABLED_BY_DEFAULT = true; static final String UNI_LINK_BUS_TIMES = "uniLinkLiveBusTimesEnabled"; static final boolean UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT = true; static final String NON_UNI_LINK_BUS_TIMES = "nonUniLinkLiveBusTimesEnabled"; static final boolean NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT = false; + static final String UNI_LINK_BUS_STOPS = "uniLinkBusStop"; + static final boolean UNI_LINK_BUS_STOPS_ENABLED_BY_DEFAULT = true; static final String NON_UNI_LINK_BUS_STOPS = "nonUniLinkBusStop"; static final boolean NON_UNI_LINK_BUS_STOPS_ENABLED_BY_DEFAULT = false; + } diff --git a/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java b/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java index a5a255e..1d99921 100644 --- a/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java +++ b/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java @@ -90,25 +90,51 @@ public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity overlays = new HashMap(); private HashMap pastOverlays; + // Overlays + + // Scale Bar Overlay + private static final String SCALE_BAR_OVERLAY = "scaleBarOverlay"; private ScaleBarOverlay scaleBarOverlay; private static final boolean SCALE_BAR_OVERLAY_ENABLED_BY_DEFAULT = true; + + // My Location Overlay + private static final String MY_LOCATION_OVERLAY = "myLocationOverlay"; private MyLocationOverlay myLocationOverlay; + private static final boolean MY_LOCATION_OVERLAY_ENABLED_BY_DEFAULT = true; + + // Residential Building Overlay + private static final String RESIDENTIAL_BUILDINGS = "residentialBuildingOverlay"; private BuildingNumOverlay residentialBuildingOverlay; - private static final boolean NON_RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT = true; - private BuildingNumOverlay nonResidentialBuildingOverlay; private static final boolean RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT = true; - private BusStopOverlay busStopOverlay; - private static final boolean BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT = true; + + // Non-Residential Building Overlay + private static final String NON_RESIDENTIAL_BUILDINGS = "nonResidentialBuildingOverlay"; + private BuildingNumOverlay nonResidentialBuildingOverlay; + private static final boolean NON_RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT = true; + + // Uni-Link Bus Stop Overlay + private static final String UNI_LINK_BUS_STOPS = "uniLinkBusStopOverlay"; + private BusStopOverlay uniLinkBusStopOverlay; + private static final boolean UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT = true; + + // Uni-Link Bus Stop Overlay + private static final String NON_UNI_LINK_BUS_STOPS = "nonUniLinkBusStopOverlay"; + private BusStopOverlay nonUniLinkBusStopOverlay; + private static final boolean NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT = true; + + // Site Overlays private HashMap siteOverlays = new HashMap(21); - private static final boolean SITE_OVERLAY_ENABLED_BY_DEFAULT = false; + + // Route Overlays private HashMap routeOverlays = new HashMap(5); + + // View + private static final String RESIDENTIAL_BUILDING_OVERLAY = "Buildings:Residential"; + private static final String NON_RESIDENTIAL_BUILDING_OVERLAY = "Buildings:Non-Residential"; + private static final boolean SITE_OVERLAY_ENABLED_BY_DEFAULT = false; private static final boolean ROUTE_OVERLAY_ENABLED_BY_DEFAULT = true; - private String[] busRoutes; - private String[] buildingTypes; - private String[] other; - private String[] groupHeadings; - private String[] siteNames; + private static final int UNI_LINK_BUS_STOP_OVERLAY_RANK = 4; private FavouriteDialog favDialog; @@ -188,20 +214,12 @@ public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity sites = new ArrayList(size); - - try { - sites.addAll(getHelper().getSiteDao().queryForAll()); - } catch (SQLException e) { - e.printStackTrace(); - } - siteNames = new String[size]; - for (int i = 0; i < size; i++) { - siteNames[i] = sites.get(i).name; - } - } catch (SQLException e1) { - e1.printStackTrace(); - } - - busRoutes = getResources().getStringArray(R.array.uniLinkBusRoutes); - buildingTypes = getResources().getStringArray(R.array.buildingTypes); - other = getResources().getStringArray(R.array.utilityOverlays); - groupHeadings = getResources().getStringArray(R.array.preferencesHeadings); - Log.i(TAG, "Finished the database thread " + (System.currentTimeMillis() - startTime)); } @@ -388,12 +382,7 @@ public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity busStops; Log.v(TAG, "Begin fetching BusStops at " + (System.currentTimeMillis() - startTime)); - if (activityPrefs.getBoolean(NON_UNI_LINK_BUS_STOPS, NON_UNI_LINK_BUS_STOPS_ENABLED_BY_DEFAULT)) { + if (activityPrefs.getBoolean(UNI_LINK_BUS_STOPS, UNI_LINK_BUS_STOPS_ENABLED_BY_DEFAULT)) { busStops = getHelper().getBusStopDao().queryForAll(); } else { busStops = getHelper().getBusStopDao().queryForEq(BusStop.UNI_LINK_FIELD_NAME, true); } Log.v(TAG, "Finished fetching BusStops at " + (System.currentTimeMillis() - startTime)); - busStopOverlay = new BusStopOverlay(instance, busStops); + uniLinkBusStopOverlay = new BusStopOverlay(instance, busStops); } catch (SQLException e) { e.printStackTrace(); } } - overlays.put("BusStops", busStopOverlay); + overlays.put("BusStops", uniLinkBusStopOverlay); Log.v(TAG, "Applyed the site overlay, now sorting them"); synchronized (mapView.getOverlays()) { - mapView.getOverlays().add(busStopOverlay); + mapView.getOverlays().add(uniLinkBusStopOverlay); Collections.sort(mapView.getOverlays(), comparator); } } - busStopOverlay.setRoutes(0, activityPrefs.getBoolean("Bus Stops:U1", BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); - busStopOverlay.setRoutes(1, activityPrefs.getBoolean("Bus Stops:U1N", BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); - busStopOverlay.setRoutes(2, activityPrefs.getBoolean("Bus Stops:U2", BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); - busStopOverlay.setRoutes(3, activityPrefs.getBoolean("Bus Stops:U6", BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); - busStopOverlay.setRoutes(4, activityPrefs.getBoolean("Bus Stops:U9", BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); + uniLinkBusStopOverlay.setRoutes(0, activityPrefs.getBoolean("Bus Stops:U1", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); + uniLinkBusStopOverlay.setRoutes(1, activityPrefs.getBoolean("Bus Stops:U1N", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); + uniLinkBusStopOverlay.setRoutes(2, activityPrefs.getBoolean("Bus Stops:U2", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); + uniLinkBusStopOverlay.setRoutes(3, activityPrefs.getBoolean("Bus Stops:U6", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); + uniLinkBusStopOverlay.setRoutes(4, activityPrefs.getBoolean("Bus Stops:U9", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)); mapView.postInvalidate(); @@ -854,7 +843,7 @@ public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity sites = new ArrayList(size); + + try { + sites.addAll(getHelper().getSiteDao().queryForAll()); + } catch (SQLException e) { + e.printStackTrace(); + } + siteNames = new String[size]; + for (int i = 0; i < size; i++) { + siteNames[i] = sites.get(i).name; + } + } catch (SQLException e1) { + e1.printStackTrace(); + } + + busRoutes = getResources().getStringArray(R.array.uniLinkBusRoutes); + buildingTypes = getResources().getStringArray(R.array.buildingTypes); + other = getResources().getStringArray(R.array.utilityOverlays); + groupHeadings = getResources().getStringArray(R.array.preferencesHeadings); + } public void setOnItemClickListener(OnChildClickListener onChildClickListener) { @@ -1236,7 +1254,8 @@ public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity