aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-28 22:22:27 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-28 22:22:27 +0000
commit5f2b8712079aeb5b7cee476b06b36013edac4fb3 (patch)
tree99c01ccf78dc130a8ca9b8a2d19384b9f91e1768
parent0b5aefbe0ff01638dd264222c5368ad02a0fe1ee (diff)
downloadsouthamptonuniversitymap-5f2b8712079aeb5b7cee476b06b36013edac4fb3.tar
southamptonuniversitymap-5f2b8712079aeb5b7cee476b06b36013edac4fb3.tar.gz
Next release, many improvements.
-rw-r--r--AndroidManifest.xml8
-rw-r--r--gen/net/cbaines/suma/R.java119
-rw-r--r--project.properties2
-rw-r--r--res/layout/building_activity.xml42
-rw-r--r--res/layout/bus_activity.xml55
-rw-r--r--res/layout/bus_route_activity.xml6
-rw-r--r--res/layout/bus_stop_activity.xml3
-rw-r--r--res/layout/find_activity.xml (renamed from res/layout/find.xml)0
-rw-r--r--res/layout/map_activity.xml (renamed from res/layout/main.xml)0
-rw-r--r--res/values/strings.xml2
-rw-r--r--src/net/cbaines/suma/BuildingActivity.java148
-rw-r--r--src/net/cbaines/suma/BusActivity.java37
-rw-r--r--src/net/cbaines/suma/BusRouteActivity.java110
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java21
-rw-r--r--src/net/cbaines/suma/FindActivity.java2
-rw-r--r--src/net/cbaines/suma/MapActivity.java2
16 files changed, 296 insertions, 261 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 42adfec..af78fdb 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.cbaines.suma"
- android:versionCode="7"
- android:versionName="0.4 (alpha)" >
+ android:versionCode="8"
+ android:versionName="0.5 (alpha)" >
- <uses-sdk
- android:minSdkVersion="4"
- android:targetSdkVersion="10" />
+ <uses-sdk android:minSdkVersion="7" />
<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 aec5afc..f7f3034 100644
--- a/gen/net/cbaines/suma/R.java
+++ b/gen/net/cbaines/suma/R.java
@@ -54,70 +54,67 @@ public final class R {
public static final int u9_radio_button=0x7f02001d;
}
public static final class id {
- public static final int buildingActivityFavouriteCheckBox=0x7f0a0006;
- public static final int buildingActivityID=0x7f0a0007;
- public static final int buildingActivityImage=0x7f0a0008;
+ public static final int buildingActivityFavouriteCheckBox=0x7f0a0005;
+ public static final int buildingActivityImage=0x7f0a0006;
+ public static final int buildingActivityLoadBar=0x7f0a0008;
+ public static final int buildingActivityLoadBarLayout=0x7f0a0007;
+ public static final int buildingActivityMessage=0x7f0a0009;
public static final int buildingActivityName=0x7f0a0004;
- public static final int busActivityBusID=0x7f0a000a;
- public static final int busActivityContentLayout=0x7f0a0010;
- public static final int busActivityHeaderLayout=0x7f0a0009;
- public static final int busActivityMessage=0x7f0a0011;
- public static final int busActivityTimes=0x7f0a0012;
- public static final int busActivityU1=0x7f0a000b;
- public static final int busActivityU1N=0x7f0a000c;
- public static final int busActivityU2=0x7f0a000d;
- public static final int busActivityU6=0x7f0a000e;
- public static final int busActivityU9=0x7f0a000f;
- public static final int busRouteActivityCode=0x7f0a0013;
- public static final int busRouteActivityHeaderLayout=0x7f0a0014;
- public static final int busRouteActivityID=0x7f0a0016;
- public static final int busRouteActivityLabel=0x7f0a0015;
- public static final int busRouteBusStops=0x7f0a0017;
- public static final int busStopID=0x7f0a001f;
- public static final int busStopListItems=0x7f0a0026;
- public static final int busStopLoadBar=0x7f0a0024;
- public static final int busStopMessage=0x7f0a0021;
- public static final int busStopName=0x7f0a0018;
- public static final int busStopTimes=0x7f0a0022;
- public static final int busTimeContentLayout=0x7f0a0020;
- public static final int centerLoadBar=0x7f0a0023;
- public static final int check1=0x7f0a0035;
- public static final int childname=0x7f0a0034;
- public static final int donateBitcoinAddress=0x7f0a002c;
+ public static final int busActivityBusID=0x7f0a000b;
+ public static final int busActivityContentLayout=0x7f0a000c;
+ public static final int busActivityHeaderLayout=0x7f0a000a;
+ public static final int busActivityMessage=0x7f0a000d;
+ public static final int busActivityTimes=0x7f0a000e;
+ public static final int busRouteActivityCode=0x7f0a000f;
+ public static final int busRouteActivityHeaderLayout=0x7f0a0010;
+ public static final int busRouteActivityID=0x7f0a0012;
+ public static final int busRouteActivityLabel=0x7f0a0011;
+ public static final int busRouteBusStops=0x7f0a0013;
+ public static final int busStopID=0x7f0a001c;
+ public static final int busStopListItems=0x7f0a0023;
+ public static final int busStopLoadBar=0x7f0a0021;
+ public static final int busStopMessage=0x7f0a001e;
+ public static final int busStopName=0x7f0a0014;
+ public static final int busStopTimes=0x7f0a001f;
+ public static final int busTimeContentLayout=0x7f0a001d;
+ public static final int centerLoadBar=0x7f0a0020;
+ public static final int check1=0x7f0a0032;
+ public static final int childname=0x7f0a0031;
+ public static final int donateBitcoinAddress=0x7f0a0029;
public static final int donateButton=0x7f0a0003;
- public static final int donateDialogErrorMessage=0x7f0a002b;
- public static final int donateDialogMessage=0x7f0a0028;
- public static final int donateDialogMessageLayout=0x7f0a002a;
- public static final int donateDialogProgress=0x7f0a0029;
- public static final int favouriteCheckBox=0x7f0a001e;
- public static final int favouriteDialogMessage=0x7f0a0032;
- public static final int favouriteListItems=0x7f0a0033;
- public static final int findContentLayout=0x7f0a002e;
- public static final int findListItems=0x7f0a0030;
- public static final int findLoadBar=0x7f0a002f;
+ public static final int donateDialogErrorMessage=0x7f0a0028;
+ public static final int donateDialogMessage=0x7f0a0025;
+ public static final int donateDialogMessageLayout=0x7f0a0027;
+ public static final int donateDialogProgress=0x7f0a0026;
+ public static final int favouriteCheckBox=0x7f0a001b;
+ public static final int favouriteDialogMessage=0x7f0a002f;
+ public static final int favouriteListItems=0x7f0a0030;
+ public static final int findContentLayout=0x7f0a002b;
+ public static final int findListItems=0x7f0a002d;
+ public static final int findLoadBar=0x7f0a002c;
public static final int helpExpandableListView=0x7f0a0002;
- public static final int layout_root=0x7f0a0025;
- public static final int linearLayout1=0x7f0a0005;
- public static final int linearLayout2=0x7f0a0027;
- public static final int mapview=0x7f0a0031;
- public static final int menu_about=0x7f0a003b;
- public static final int menu_favourites=0x7f0a003c;
- public static final int menu_find=0x7f0a0037;
- public static final int menu_find_my_location=0x7f0a0039;
- public static final int menu_next_stop=0x7f0a003f;
- public static final int menu_preferences=0x7f0a0038;
- public static final int menu_previous_stop=0x7f0a003d;
- public static final int menu_refresh_stop=0x7f0a003e;
- public static final int menu_view=0x7f0a003a;
- public static final int radio_u1=0x7f0a0019;
- public static final int radio_u1n=0x7f0a001a;
- public static final int radio_u2=0x7f0a001b;
- public static final int radio_u6=0x7f0a001c;
- public static final int radio_u9=0x7f0a001d;
- public static final int searchBar=0x7f0a002d;
+ public static final int layout_root=0x7f0a0022;
+ public static final int linearLayout1=0x7f0a0015;
+ public static final int linearLayout2=0x7f0a0024;
+ public static final int mapview=0x7f0a002e;
+ public static final int menu_about=0x7f0a0038;
+ public static final int menu_favourites=0x7f0a0039;
+ public static final int menu_find=0x7f0a0034;
+ public static final int menu_find_my_location=0x7f0a0036;
+ public static final int menu_next_stop=0x7f0a003c;
+ public static final int menu_preferences=0x7f0a0035;
+ public static final int menu_previous_stop=0x7f0a003a;
+ public static final int menu_refresh_stop=0x7f0a003b;
+ public static final int menu_view=0x7f0a0037;
+ public static final int radio_u1=0x7f0a0016;
+ public static final int radio_u1n=0x7f0a0017;
+ public static final int radio_u2=0x7f0a0018;
+ public static final int radio_u6=0x7f0a0019;
+ public static final int radio_u9=0x7f0a001a;
+ public static final int searchBar=0x7f0a002a;
public static final int textView1=0x7f0a0000;
public static final int textView2=0x7f0a0001;
- public static final int view_list=0x7f0a0036;
+ public static final int view_list=0x7f0a0033;
}
public static final class layout {
public static final int about_dialog=0x7f030000;
@@ -127,8 +124,8 @@ public final class R {
public static final int bus_stop_activity=0x7f030004;
public static final int bus_stop_dialog=0x7f030005;
public static final int donate_dialog=0x7f030006;
- public static final int find=0x7f030007;
- public static final int main=0x7f030008;
+ public static final int find_activity=0x7f030007;
+ public static final int map_activity=0x7f030008;
public static final int poi_dialog=0x7f030009;
public static final int view_child_row=0x7f03000a;
public static final int view_dialog=0x7f03000b;
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" />
+ <CheckBox
+ android:id="@+id/buildingActivityFavouriteCheckBox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/bustimes_favourite_checkbox_label" />
+
+ <ImageButton
+ android:id="@+id/buildingActivityImage"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@null"
+ android:contentDescription="@string/buildingImageDescription" />
+
<LinearLayout
- android:id="@+id/linearLayout1"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/buildingActivityLoadBarLayout"
android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
+ android:layout_height="fill_parent"
+ android:gravity="center"
+ android:orientation="vertical" >
- <CheckBox
- android:id="@+id/buildingActivityFavouriteCheckBox"
+ <ProgressBar
+ android:id="@+id/buildingActivityLoadBar"
+ style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/bustimes_favourite_checkbox_label" />
+ android:layout_height="wrap_content" />
<TextView
- android:id="@+id/buildingActivityID"
+ android:id="@+id/buildingActivityMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall" />
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
- <ImageButton
- android:id="@+id/buildingActivityImage"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@null"
- android:contentDescription="@string/buildingImageDescription" />
-
</LinearLayout> \ 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" />
-
- <TextView
- android:id="@+id/busActivityU1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/u1_back_selected"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
- android:text="@string/U1"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="#FFFFFF" />
-
- <TextView
- android:id="@+id/busActivityU1N"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/u1n_back_selected"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
- android:text="@string/U1N"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="#FFFFFF" />
-
- <TextView
- android:id="@+id/busActivityU2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/u2_back_selected"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
- android:text="@string/U2"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="#FFFFFF" />
-
- <TextView
- android:id="@+id/busActivityU6"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/u6_back_selected"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
- android:text="@string/U6"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="#FFFFFF" />
-
- <TextView
- android:id="@+id/busActivityU9"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/u9_back_selected"
- android:paddingLeft="5dp"
- android:paddingRight="5dp"
- android:text="@string/U9"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
diff --git a/res/layout/bus_route_activity.xml b/res/layout/bus_route_activity.xml
index 94a0d07..48cdadc 100644
--- a/res/layout/bus_route_activity.xml
+++ b/res/layout/bus_route_activity.xml
@@ -8,7 +8,7 @@
<TextView
android:id="@+id/busRouteActivityCode"
- android:layout_width="wrap_content"
+ android:layout_width="fill_parent"
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" />
<TextView
android:id="@+id/busRouteActivityID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium" />
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:visibility="gone" />
</LinearLayout>
<ListView
diff --git a/res/layout/bus_stop_activity.xml b/res/layout/bus_stop_activity.xml
index fcfe6da..3f4dc98 100644
--- a/res/layout/bus_stop_activity.xml
+++ b/res/layout/bus_stop_activity.xml
@@ -95,7 +95,8 @@
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall" />
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:visibility="gone" />
</LinearLayout>
<LinearLayout
diff --git a/res/layout/find.xml b/res/layout/find_activity.xml
index 6b19c67..6b19c67 100644
--- a/res/layout/find.xml
+++ b/res/layout/find_activity.xml
diff --git a/res/layout/main.xml b/res/layout/map_activity.xml
index dff45bd..dff45bd 100644
--- a/res/layout/main.xml
+++ b/res/layout/map_activity.xml
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 Strings -->
<string name="about">About</string>
<string name="about_version">Version</string>
- <string name="about_version_summary">0.4 (alpha)</string>
+ <string name="about_version_summary">0.5 (alpha)</string>
<string name="about_copyright">Copyright</string>
<string name="about_copyright_summary">© 2012, Christopher Baines</string>
<string name="about_license">License</string>
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<DatabaseHelper> implements OnCheckedChangeListener,
- Preferences {
+public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> implements OnCheckedChangeListener, Preferences {
final static String TAG = "BusTimeActivity";
@@ -53,10 +54,12 @@ public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> 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<DatabaseHelper> 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<DatabaseHelper> 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<Building, Integer, Drawable> {
+ 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<DatabaseHelper> 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<DatabaseHelper> 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<DatabaseHelper> 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<DatabaseHelper> implements Preferences {
+public class BusRouteActivity extends OrmLiteBaseActivity<DatabaseHelper> implements Preferences, OnItemClickListener,
+ OnItemLongClickListener {
final static String TAG = "BusActivity";
private TextView busRouteLabel;
@@ -22,6 +31,8 @@ public class BusRouteActivity extends OrmLiteBaseActivity<DatabaseHelper> implem
private ListView busRouteView;
+ private POIArrayAdapter arrayAdapter;
+
private Context instance;
public void onCreate(Bundle savedInstanceState) {
@@ -50,6 +61,8 @@ public class BusRouteActivity extends OrmLiteBaseActivity<DatabaseHelper> 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<DatabaseHelper> 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<DatabaseHelper> 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<DatabaseHelper> implements OnCheckedChangeListener,
- Preferences, OnItemClickListener, OnLongClickListener {
+public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> implements OnCheckedChangeListener, Preferences,
+ OnItemClickListener, OnLongClickListener {
final static String TAG = "BusTimeActivity";
@@ -123,6 +123,7 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> 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<DatabaseHelper> 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<DatabaseHelper> 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<DatabaseHelper> 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<DatabaseHelper> 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<DatabaseHelper> 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));