aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-27 23:26:34 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-27 23:26:34 +0000
commita6dcb82b21325934ae3f4df9cfc5aad04d414653 (patch)
tree505d19676af1aca93683f2ab30556b323db69b56
parent9b09f1286a8a003f0d24f745f648748cd3c2f2e2 (diff)
downloadsouthamptonuniversitymap-a6dcb82b21325934ae3f4df9cfc5aad04d414653.tar
southamptonuniversitymap-a6dcb82b21325934ae3f4df9cfc5aad04d414653.tar.gz
Really cool uri stuff, needs more thinking about, but its really cool :)
-rw-r--r--AndroidManifest.xml72
-rw-r--r--src/net/cbaines/suma/AboutActivity.java117
-rw-r--r--src/net/cbaines/suma/BuildingActivity.java19
-rw-r--r--src/net/cbaines/suma/BuildingNumOverlay.java11
-rw-r--r--src/net/cbaines/suma/BusActivity.java75
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java39
-rw-r--r--src/net/cbaines/suma/BusStopOverlay.java12
-rw-r--r--src/net/cbaines/suma/DonateDialog.java86
8 files changed, 268 insertions, 163 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6355013..0445178 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -13,6 +13,12 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <supports-screens
+ android:anyDensity="true"
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="true" />
+
<application
android:debuggable="true"
android:icon="@drawable/icon"
@@ -29,12 +35,78 @@
<activity android:name="FindActivity" >
</activity>
<activity android:name="BusStopActivity" >
+ <intent-filter android:label="@string/app_name" >
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="id.southampton.ac.uk"
+ android:pathPrefix="/bus-stop/"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter android:label="@string/app_name" >
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="data.southampton.ac.uk"
+ android:pathPrefix="/bus-stop/"
+ android:scheme="http" />
+ </intent-filter>
</activity>
<activity android:name="BusActivity" >
+ <intent-filter android:label="@string/app_name" >
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="id.southampton.ac.uk"
+ android:pathPrefix="/bus/"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter android:label="@string/app_name" >
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="data.southampton.ac.uk"
+ android:pathPrefix="/bus/"
+ android:scheme="http" />
+ </intent-filter>
</activity>
<activity android:name="AboutActivity" >
</activity>
<activity android:name="BuildingActivity" >
+ <intent-filter android:label="@string/app_name" >
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="id.southampton.ac.uk"
+ android:pathPrefix="/building/"
+ android:scheme="http" />
+ </intent-filter>
+ <intent-filter android:label="@string/app_name" >
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="data.southampton.ac.uk"
+ android:pathPrefix="/building/"
+ android:scheme="http" />
+ </intent-filter>
</activity>
<activity
android:name=".PreferencesActivity"
diff --git a/src/net/cbaines/suma/AboutActivity.java b/src/net/cbaines/suma/AboutActivity.java
index a455d70..d245352 100644
--- a/src/net/cbaines/suma/AboutActivity.java
+++ b/src/net/cbaines/suma/AboutActivity.java
@@ -30,72 +30,73 @@ import android.util.Log;
public class AboutActivity extends PreferenceActivity {
- static final int DONATE_DIALOG_ID = 0;
+ static final int DONATE_DIALOG_ID = 0;
- private static final String KEY_ABOUT_LICENSE = "about_license";
- private static final String KEY_ABOUT_PROJECT = "about_project";
- private static final String KEY_ABOUT_DEVELOPER = "about_developer";
- private static final String KEY_ABOUT_DATA = "about_data";
- private static final String KEY_ABOUT_ANDROID_MARKET = "about_android_market";
- private static final String KEY_ABOUT_MAP_DATA = "about_map_data";
- private static final String KEY_ABOUT_MAP_ICONS = "about_map_icons";
- private static final String KEY_ABOUT_OSM_MAP = "about_osm_map";
- private static final String KEY_ABOUT_MAP_TILES = "about_map_tiles";
- private static final String KEY_ABOUT_DATABASE = "about_database";
- private static final String KEY_ABOUT_DONATE = "about_donate";
+ private static final String KEY_ABOUT_LICENSE = "about_license";
+ private static final String KEY_ABOUT_PROJECT = "about_project";
+ private static final String KEY_ABOUT_DEVELOPER = "about_developer";
+ private static final String KEY_ABOUT_DATA = "about_data";
+ private static final String KEY_ABOUT_ANDROID_MARKET = "about_android_market";
+ private static final String KEY_ABOUT_MAP_DATA = "about_map_data";
+ private static final String KEY_ABOUT_MAP_ICONS = "about_map_icons";
+ private static final String KEY_ABOUT_OSM_MAP = "about_osm_map";
+ private static final String KEY_ABOUT_MAP_TILES = "about_map_tiles";
+ private static final String KEY_ABOUT_DATABASE = "about_database";
+ private static final String KEY_ABOUT_DONATE = "about_donate";
- private static final String TAG = "AboutActivity";
+ private static final String TAG = "AboutActivity";
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.about);
- }
+ addPreferencesFromResource(R.xml.about);
+ }
- @Override
- public boolean onPreferenceTreeClick(final PreferenceScreen preferenceScreen, final Preference preference) {
- try {
- final String key = preference.getKey();
- if (KEY_ABOUT_LICENSE.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.gnu.org/licenses/gpl-2.0.html")));
- } else if (KEY_ABOUT_PROJECT.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/cbaines/SouthamptonUniversityMap")));
- } else if (KEY_ABOUT_DEVELOPER.equals(key)) {
- Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
- emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "cbaines8@gmail.com" });
- emailIntent.setType("text/plain");
+ @Override
+ public boolean onPreferenceTreeClick(final PreferenceScreen preferenceScreen, final Preference preference) {
+ try {
+ final String key = preference.getKey();
+ if (KEY_ABOUT_LICENSE.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.gnu.org/licenses/gpl-2.0.html")));
+ } else if (KEY_ABOUT_PROJECT.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/cbaines/SouthamptonUniversityMap")));
+ } else if (KEY_ABOUT_DEVELOPER.equals(key)) {
+ Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
+ emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "cbaines8@gmail.com" });
+ emailIntent.setType("text/plain");
- startActivity(Intent.createChooser(emailIntent, "Email the developer"));
- } else if (KEY_ABOUT_DATA.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://data.southampton.ac.uk/bus-routes.html")));
- } else if (KEY_ABOUT_ANDROID_MARKET.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=net.cbaines.suma")));
- } else if (KEY_ABOUT_MAP_DATA.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("http://data.southampton.ac.uk/places.html"))));
- } else if (KEY_ABOUT_MAP_ICONS.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://mapicons.nicolasmollet.com/")));
- } else if (KEY_ABOUT_OSM_MAP.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.openstreetmap.org/")));
- } else if (KEY_ABOUT_MAP_TILES.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mapquest.com/")));
- } else if (KEY_ABOUT_DATABASE.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("http://ormlite.com/"))));
- } else if (KEY_ABOUT_DONATE.equals(key)) {
- showDialog(DONATE_DIALOG_ID);
- }
- } catch (Exception e) {
- Log.e("Error opening one of the icons", TAG, e);
+ startActivity(Intent.createChooser(emailIntent, "Email the developer"));
+ } else if (KEY_ABOUT_DATA.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://data.southampton.ac.uk/bus-routes.html")));
+ } else if (KEY_ABOUT_ANDROID_MARKET.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=net.cbaines.suma")));
+ } else if (KEY_ABOUT_MAP_DATA.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW,
+ Uri.parse(String.format("http://data.southampton.ac.uk/places.html"))));
+ } else if (KEY_ABOUT_MAP_ICONS.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://mapicons.nicolasmollet.com/")));
+ } else if (KEY_ABOUT_OSM_MAP.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.openstreetmap.org/")));
+ } else if (KEY_ABOUT_MAP_TILES.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mapquest.com/")));
+ } else if (KEY_ABOUT_DATABASE.equals(key)) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("http://ormlite.com/"))));
+ } else if (KEY_ABOUT_DONATE.equals(key)) {
+ showDialog(DONATE_DIALOG_ID);
+ }
+ } catch (Exception e) {
+ Log.e("Error opening one of the icons", TAG, e);
+ }
+ return false;
}
- return false;
- }
- protected Dialog onCreateDialog(int id) {
- switch (id) {
- case DONATE_DIALOG_ID:
- DonateDialog donateDialog = new DonateDialog(this);
- return donateDialog;
+ protected Dialog onCreateDialog(int id) {
+ switch (id) {
+ case DONATE_DIALOG_ID:
+ DonateDialog donateDialog = new DonateDialog(this);
+ return donateDialog;
+ }
+ return null;
}
- return null;
- }
}
diff --git a/src/net/cbaines/suma/BuildingActivity.java b/src/net/cbaines/suma/BuildingActivity.java
index 6b03164..fdfa49d 100644
--- a/src/net/cbaines/suma/BuildingActivity.java
+++ b/src/net/cbaines/suma/BuildingActivity.java
@@ -63,7 +63,24 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> implem
setContentView(R.layout.building_activity);
instance = this;
- String ID = getIntent().getExtras().getString("buildingID");
+ String ID;
+
+ Log.i(TAG, "getIntent().getDataString() " + getIntent().getDataString());
+
+ if (getIntent().getDataString().startsWith("http://data")) {
+
+ String[] uriParts = getIntent().getDataString().split("/");
+
+ ID = uriParts[uriParts.length - 1].replace(".html", "");
+
+ } else {
+
+ String[] uriParts = getIntent().getDataString().split("/");
+
+ ID = uriParts[uriParts.length - 1];
+ }
+
+ Log.i(TAG, "ID " + ID);
final SharedPreferences favouritesPrefs = instance.getSharedPreferences(FAVOURITES_PREFERENCES, 0);
diff --git a/src/net/cbaines/suma/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java
index cc20003..87d4156 100644
--- a/src/net/cbaines/suma/BuildingNumOverlay.java
+++ b/src/net/cbaines/suma/BuildingNumOverlay.java
@@ -29,7 +29,6 @@ import org.osmdroid.views.MapView;
import org.osmdroid.views.MapView.Projection;
import org.osmdroid.views.overlay.Overlay;
-import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
@@ -40,6 +39,7 @@ import android.graphics.Paint.Style;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Toast;
@@ -221,9 +221,12 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared
} else {
Log.i(TAG, "Pressed " + building.id);
- Intent i = new Intent(context, BuildingActivity.class);
- i.putExtra("buildingID", building.id);
- ((Activity) context).startActivityForResult(i, 0);
+ Uri uri = Uri.parse("http://id.southampton.ac.uk/building/" + building.id);
+
+ Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath());
+
+ Intent buildingIntent = new Intent(Intent.ACTION_VIEW, uri);
+ context.startActivity(buildingIntent);
return true;
}
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index 2b76176..f4edc3f 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -24,8 +24,7 @@ import android.widget.Toast;
import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
-public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
- Preferences {
+public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements Preferences {
final static String TAG = "BusActivity";
private TextView U1RouteTextView;
@@ -71,13 +70,28 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
setContentView(R.layout.bus_activity);
instance = this;
- String busID = getIntent().getExtras().getString("busID");
+ Log.i(TAG, "getIntent().getDataString() " + getIntent().getDataString());
+
+ String busID;
+
+ if (getIntent().getDataString().startsWith("http://data")) {
+
+ String[] uriParts = getIntent().getDataString().split("/");
+
+ busID = uriParts[uriParts.length - 1].replace(".html", "");
+
+ } else {
+
+ String[] uriParts = getIntent().getDataString().split("/");
+
+ busID = uriParts[uriParts.length - 1];
+ }
+
String busStopID = getIntent().getExtras().getString("busStopID");
final DatabaseHelper helper = getHelper();
try {
- List<Bus> buses = helper.getBusDao().queryForEq(Bus.ID_FIELD_NAME,
- busID);
+ List<Bus> buses = helper.getBusDao().queryForEq(Bus.ID_FIELD_NAME, busID);
bus = null;
if (buses.size() == 0) {
Log.e(TAG, "Bus " + busID + " not found!");
@@ -91,8 +105,7 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
busStop = null;
if (busStopID != null) {
- List<BusStop> busStops = helper.getBusStopDao().queryForEq(
- BusStop.ID_FIELD_NAME, busStopID);
+ List<BusStop> busStops = helper.getBusStopDao().queryForEq(BusStop.ID_FIELD_NAME, busStopID);
if (busStops.size() == 0) {
Log.e(TAG, "BusStop " + busStopID + " not found!");
} else if (busStops.size() == 1) {
@@ -115,8 +128,7 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
timetableView = (ListView) findViewById(R.id.busActivityTimes);
if (bus.id != null) {
- Log.i(TAG, "Bus id is not null (" + bus.id
- + ") setting busIDTextView");
+ Log.i(TAG, "Bus id is not null (" + bus.id + ") setting busIDTextView");
busIDTextView.setText(bus.id + " " + bus.getName());
} else {
Log.w(TAG, "Bus id is null?");
@@ -165,29 +177,23 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}
/*
- * for (int i = 0;; i++) { BusStop nextStop =
- * bus.route.moveInRoute(instance, busStops.get(i), bus.direction, 1);
+ * for (int i = 0;; i++) { BusStop nextStop = bus.route.moveInRoute(instance, busStops.get(i), bus.direction, 1);
*
- * if (nextStop.equals(busStop) || (bus.destination != null &&
- * bus.destination.equals(nextStop))) { break; }
+ * if (nextStop.equals(busStop) || (bus.destination != null && bus.destination.equals(nextStop))) { break; }
*
* busStops.add(nextStop); busStopsActive.add(false);
*
- * if (busStops.size() > 50) { Log.e(TAG, "Got more than 50 bus stops");
- * break; } }
+ * if (busStops.size() > 50) { Log.e(TAG, "Got more than 50 bus stops"); break; } }
*/
refreshData = new Runnable() {
public void run() {
- for (int num = timetableView.getFirstVisiblePosition(); num < timetableView
- .getLastVisiblePosition(); num++) {
+ for (int num = timetableView.getFirstVisiblePosition(); num < timetableView.getLastVisiblePosition(); num++) {
Stop stop = timetable.get(num);
GetTimetableStopTask task = tasks.get(busStops.get(num));
- if (stop.timeOfFetch == null
- || (stop.timeOfFetch.getTime() - System
- .currentTimeMillis()) > 20000) {
+ if (stop.timeOfFetch == null || (stop.timeOfFetch.getTime() - System.currentTimeMillis()) > 20000) {
if (task != null) {
if (task.getStatus() == AsyncTask.Status.FINISHED) {
task = null;
@@ -212,12 +218,9 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
public void onResume() {
super.onResume();
- SharedPreferences sharedPrefs = PreferenceManager
- .getDefaultSharedPreferences(this);
- if (sharedPrefs.getBoolean(UNI_LINK_BUS_TIMES,
- UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)
- || sharedPrefs.getBoolean(NON_UNI_LINK_BUS_TIMES,
- NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)) {
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ if (sharedPrefs.getBoolean(UNI_LINK_BUS_TIMES, UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)
+ || sharedPrefs.getBoolean(NON_UNI_LINK_BUS_TIMES, NON_UNI_LINK_BUS_TIMES_ENABLED_BY_DEFAULT)) {
Log.i(TAG, "Live Times enabled");
timetable = (Timetable) getLastNonConfigurationInstance();
@@ -227,8 +230,7 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
Log.i(TAG, "No Previous timetable");
timetable = new Timetable();
for (int i = 0; i < busStops.size(); i++) {
- timetable.add(new Stop(bus, busStops.get(i), null, null,
- false));
+ timetable.add(new Stop(bus, busStops.get(i), null, null, false));
}
Log.v(TAG, "Finished adding placeholder stops");
} else {
@@ -261,8 +263,7 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
super.onPause();
}
- private class GetTimetableStopTask extends
- AsyncTask<BusStop, Integer, Stop> {
+ private class GetTimetableStopTask extends AsyncTask<BusStop, Integer, Stop> {
private String errorMessage;
private BusStop busStop;
@@ -331,26 +332,20 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
} else {
if (visibleTimetable.size() == 0) {
busActivityContentLayout.setGravity(Gravity.CENTER);
- busContentMessage
- .setText("No Busses (With the current enabled routes)");
+ busContentMessage.setText("No Busses (With the current enabled routes)");
busContentMessage.setVisibility(View.VISIBLE);
timetableView.setVisibility(View.GONE);
} else {
timetableView.setVisibility(View.VISIBLE);
busContentMessage.setVisibility(View.GONE);
BusSpecificTimetableAdapter adapter;
- if ((adapter = (BusSpecificTimetableAdapter) timetableView
- .getAdapter()) != null) {
+ if ((adapter = (BusSpecificTimetableAdapter) timetableView.getAdapter()) != null) {
adapter.updateTimetable(visibleTimetable);
} else {
- adapter = new BusSpecificTimetableAdapter(this,
- visibleTimetable);
+ adapter = new BusSpecificTimetableAdapter(this, visibleTimetable);
timetableView.setAdapter(adapter);
if (busStop != null) {
- Log.i(TAG,
- "Moving to position of " + busStop.description
- + " which is "
- + busStops.indexOf(busStop));
+ Log.i(TAG, "Moving to position of " + busStop.description + " which is " + busStops.indexOf(busStop));
timetableView.setSelection(busStops.indexOf(busStop));
}
}
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index bc8e22e..dbed3ee 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -75,9 +75,6 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
protected Timetable timetable;
private Timetable visibleTimetable;
- protected String busStopID;
- private String busStopName;
-
private Dao<BusStop, String> busStopDao;
private BusStop busStop;
@@ -106,15 +103,29 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
super.onCreate(savedInstanceState);
setContentView(R.layout.bus_stop_activity);
+ Log.i(TAG, "getIntent().getDataString() " + getIntent().getDataString());
+
+ String busStopID;
+
+ if (getIntent().getDataString().startsWith("http://data")) {
+
+ String[] uriParts = getIntent().getDataString().split("/");
+
+ busStopID = uriParts[uriParts.length - 1].replace(".html", "");
+
+ } else {
+
+ String[] uriParts = getIntent().getDataString().split("/");
+
+ busStopID = uriParts[uriParts.length - 1];
+ }
+
final DatabaseHelper helper = getHelper();
SharedPreferences favouritesPreferences = getSharedPreferences(FAVOURITES_PREFERENCES, 0);
instance = this;
- busStopID = getIntent().getExtras().getString("busStopID");
- busStopName = getIntent().getExtras().getString("busStopName");
-
U1RouteRadioButton = (CheckBox) findViewById(R.id.radio_u1);
U1NRouteRadioButton = (CheckBox) findViewById(R.id.radio_u1n);
U2RouteRadioButton = (CheckBox) findViewById(R.id.radio_u2);
@@ -128,6 +139,10 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
U9RouteRadioButton.setOnCheckedChangeListener(this);
try {
+ Dao<BusStop, String> busStopDao = helper.getBusStopDao();
+
+ busStop = busStopDao.queryForId(busStopID);
+
Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao();
Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
@@ -201,7 +216,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
Log.i(TAG, "Got busstop id " + busStopID);
- busName.setText(busStopName);
+ busName.setText(busStop.description);
busID.setText(busStopID);
}
@@ -217,7 +232,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
refreshData = new Runnable() {
public void run() {
timetableTask = new GetTimetableTask();
- timetableTask.execute(busStopID);
+ timetableTask.execute(busStop.id);
mHandler.postDelayed(refreshData, 20000);
}
};
@@ -296,7 +311,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(instance);
newTimetable = DataManager
- .getTimetable(instance, busStopID, sharedPrefs.getBoolean(MapActivity.UNI_LINK_BUS_TIMES,
+ .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) {
@@ -319,7 +334,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
}
protected void onPostExecute(Timetable newTimetable) {
- Log.i(TAG, "Got timetable for " + busStopID);
+ Log.i(TAG, "Got timetable for " + busStop.id);
if (newTimetable == null) {
Log.i(TAG, "Its null");
@@ -355,9 +370,9 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
try {
Set<BusStop> tmpStops;
if (item.getItemId() == R.id.menu_next_stop) {
- tmpStops = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), 1);
+ tmpStops = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStop.id), 1);
} else {
- tmpStops = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStopID), -1);
+ tmpStops = route.moveInRoute(this, getHelper().getBusStopDao().queryForId(busStop.id), -1);
}
for (BusStop busStop : tmpStops) {
if (!busStops.contains(busStop)) {
diff --git a/src/net/cbaines/suma/BusStopOverlay.java b/src/net/cbaines/suma/BusStopOverlay.java
index 4705d1d..b8f1077 100644
--- a/src/net/cbaines/suma/BusStopOverlay.java
+++ b/src/net/cbaines/suma/BusStopOverlay.java
@@ -27,7 +27,6 @@ import org.osmdroid.views.MapView;
import org.osmdroid.views.MapView.Projection;
import org.osmdroid.views.overlay.Overlay;
-import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Canvas;
@@ -36,6 +35,7 @@ import android.graphics.Paint.Style;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Toast;
@@ -222,10 +222,12 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref
} else {
Log.i(TAG, "Pressed " + busStop.id);
- Intent i = new Intent(context, BusStopActivity.class);
- i.putExtra("busStopID", busStop.id);
- i.putExtra("busStopName", busStop.description);
- ((Activity) context).startActivityForResult(i, 0);
+ 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);
+ context.startActivity(busStopIntent);
return true;
}
diff --git a/src/net/cbaines/suma/DonateDialog.java b/src/net/cbaines/suma/DonateDialog.java
index be5cd41..a364104 100644
--- a/src/net/cbaines/suma/DonateDialog.java
+++ b/src/net/cbaines/suma/DonateDialog.java
@@ -31,62 +31,62 @@ import android.widget.TextView;
public class DonateDialog extends Dialog implements Runnable {
- // private static final String TAG = "DonateDialog";
+ // private static final String TAG = "DonateDialog";
- private static final String bitcoinAddress = "1LFATViKkmbm6m4u1Ghi9wqrgVy2B6M412";
+ private static final String bitcoinAddress = "1LFATViKkmbm6m4u1Ghi9wqrgVy2B6M412";
- private final Context context;
+ private final Context context;
- private final TextView dialogMessage;
- private final ProgressBar progressBar;
+ private final TextView dialogMessage;
+ private final ProgressBar progressBar;
- private final LinearLayout errorLayout;
- private final TextView donateDialogErrorMessage;
- private final TextView donateBitcoinAddress;
+ private final LinearLayout errorLayout;
+ private final TextView donateDialogErrorMessage;
+ private final TextView donateBitcoinAddress;
- public DonateDialog(Context context) {
- super(context);
+ public DonateDialog(Context context) {
+ super(context);
- this.context = context;
+ this.context = context;
- setContentView(R.layout.donate_dialog);
- setTitle("Donate");
+ setContentView(R.layout.donate_dialog);
+ setTitle("Donate");
- dialogMessage = (TextView) findViewById(R.id.donateDialogMessage);
- progressBar = (ProgressBar) findViewById(R.id.donateDialogProgress);
+ dialogMessage = (TextView) findViewById(R.id.donateDialogMessage);
+ progressBar = (ProgressBar) findViewById(R.id.donateDialogProgress);
- errorLayout = (LinearLayout) findViewById(R.id.donateDialogMessageLayout);
- donateDialogErrorMessage = (TextView) findViewById(R.id.donateDialogErrorMessage);
- donateBitcoinAddress = (TextView) findViewById(R.id.donateBitcoinAddress);
+ errorLayout = (LinearLayout) findViewById(R.id.donateDialogMessageLayout);
+ donateDialogErrorMessage = (TextView) findViewById(R.id.donateDialogErrorMessage);
+ donateBitcoinAddress = (TextView) findViewById(R.id.donateBitcoinAddress);
- new Thread(this).start();
- }
-
- public void run() {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- e.printStackTrace();
+ new Thread(this).start();
}
- try {
-
- Intent donateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("bitcoin:" + bitcoinAddress
- + "?label=Southampton%20Uni%20Map%20App&message=Donation%20for%20the%20Southampton%20University%20Map%20App"));
- context.startActivity(donateIntent);
-
- } catch (ActivityNotFoundException e) {
- errorLayout.post(new Runnable() {
- public void run() {
- dialogMessage.setText(R.string.donate_dialog_error_title);
- progressBar.setVisibility(View.GONE);
- errorLayout.setVisibility(View.VISIBLE);
- donateDialogErrorMessage.setVisibility(View.VISIBLE);
- donateBitcoinAddress.setText(bitcoinAddress);
- donateBitcoinAddress.setVisibility(View.VISIBLE);
+ public void run() {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ try {
+
+ Intent donateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("bitcoin:" + bitcoinAddress
+ + "?label=Southampton%20Uni%20Map%20App&message=Donation%20for%20the%20Southampton%20University%20Map%20App"));
+ context.startActivity(donateIntent);
+
+ } catch (ActivityNotFoundException e) {
+ errorLayout.post(new Runnable() {
+ public void run() {
+ dialogMessage.setText(R.string.donate_dialog_error_title);
+ progressBar.setVisibility(View.GONE);
+ errorLayout.setVisibility(View.VISIBLE);
+ donateDialogErrorMessage.setVisibility(View.VISIBLE);
+ donateBitcoinAddress.setText(bitcoinAddress);
+ donateBitcoinAddress.setVisibility(View.VISIBLE);
+ }
+ });
}
- });
}
- }
}