diff options
author | Christopher Baines <cbaines8@gmail.com> | 2012-03-06 15:44:49 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2012-03-06 15:44:49 +0000 |
commit | 1b2872b6e53791cf5619a016d2b22d015544c2c8 (patch) | |
tree | 142acf5d57575740a7eeda50fd47fb46a8e7b4cf | |
parent | 7d48b4d5c1a57ae12b55905b2f7cfa5d3623fbc6 (diff) | |
download | southamptonuniversitymap-1b2872b6e53791cf5619a016d2b22d015544c2c8.tar southamptonuniversitymap-1b2872b6e53791cf5619a016d2b22d015544c2c8.tar.gz |
Better BusActivity.
-rw-r--r-- | gen/net/cbaines/suma/R.java | 95 | ||||
-rw-r--r-- | res/menu/bus_menu.xml | 9 | ||||
-rw-r--r-- | res/menu/bus_stop_menu.xml (renamed from res/menu/stop_menu.xml) | 0 | ||||
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusActivity.java | 23 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusSpecificStopView.java | 33 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusSpecificTimetableAdapter.java | 4 | ||||
-rw-r--r-- | src/net/cbaines/suma/BusStopActivity.java | 14 |
8 files changed, 103 insertions, 78 deletions
diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index 49cba3e..3163564 100644 --- a/gen/net/cbaines/suma/R.java +++ b/gen/net/cbaines/suma/R.java @@ -98,15 +98,16 @@ public final class R { public static final int linearLayout1=0x7f0a0016; public static final int linearLayout2=0x7f0a0025; public static final int mapview=0x7f0a002f; - public static final int menu_about=0x7f0a003c; - public static final int menu_favourites=0x7f0a003d; - public static final int menu_find=0x7f0a0038; - public static final int menu_find_my_location=0x7f0a003a; - public static final int menu_next_stop=0x7f0a0040; - public static final int menu_preferences=0x7f0a0039; - public static final int menu_previous_stop=0x7f0a003e; - public static final int menu_refresh_stop=0x7f0a003f; - public static final int menu_view=0x7f0a003b; + public static final int menu_about=0x7f0a0040; + public static final int menu_favourites=0x7f0a0041; + public static final int menu_find=0x7f0a003c; + public static final int menu_find_my_location=0x7f0a003e; + public static final int menu_next_stop=0x7f0a003b; + public static final int menu_preferences=0x7f0a003d; + public static final int menu_previous_stop=0x7f0a0039; + public static final int menu_refresh_bus=0x7f0a0038; + public static final int menu_refresh_stop=0x7f0a003a; + public static final int menu_view=0x7f0a003f; public static final int radio_u1=0x7f0a0017; public static final int radio_u1n=0x7f0a0018; public static final int radio_u2=0x7f0a0019; @@ -137,8 +138,9 @@ public final class R { public static final int view_group_row=0x7f03000d; } public static final class menu { - public static final int map_menu=0x7f090000; - public static final int stop_menu=0x7f090001; + public static final int bus_menu=0x7f090000; + public static final int bus_stop_menu=0x7f090001; + public static final int map_menu=0x7f090002; } public static final class raw { public static final int org=0x7f060000; @@ -158,54 +160,54 @@ public final class R { public static final int U9=0x7f07000d; /** About Strings */ - public static final int about=0x7f070038; - public static final int about_android_market=0x7f070045; - public static final int about_android_market_summary=0x7f070046; - public static final int about_copyright=0x7f07003b; - public static final int about_copyright_summary=0x7f07003c; - public static final int about_data=0x7f070043; - public static final int about_data_summary=0x7f070044; - public static final int about_database=0x7f07004f; - public static final int about_database_summary=0x7f070050; - public static final int about_developer=0x7f070041; - public static final int about_developer_summary=0x7f070042; - public static final int about_donate=0x7f070051; - public static final int about_donate_summary=0x7f070052; + public static final int about=0x7f070039; + public static final int about_android_market=0x7f070046; + public static final int about_android_market_summary=0x7f070047; + public static final int about_copyright=0x7f07003c; + public static final int about_copyright_summary=0x7f07003d; + public static final int about_data=0x7f070044; + public static final int about_data_summary=0x7f070045; + public static final int about_database=0x7f070050; + public static final int about_database_summary=0x7f070051; + public static final int about_developer=0x7f070042; + public static final int about_developer_summary=0x7f070043; + public static final int about_donate=0x7f070052; + public static final int about_donate_summary=0x7f070053; public static final int about_help_message=0x7f070016; - public static final int about_license=0x7f07003d; - public static final int about_license_summary=0x7f07003e; - public static final int about_map_data=0x7f070047; - public static final int about_map_data_summary=0x7f070048; - public static final int about_map_icons=0x7f070049; - public static final int about_map_icons_summary=0x7f07004a; - public static final int about_map_tiles=0x7f07004d; - public static final int about_map_tiles_summary=0x7f07004e; + public static final int about_license=0x7f07003e; + public static final int about_license_summary=0x7f07003f; + public static final int about_map_data=0x7f070048; + public static final int about_map_data_summary=0x7f070049; + public static final int about_map_icons=0x7f07004a; + public static final int about_map_icons_summary=0x7f07004b; + public static final int about_map_tiles=0x7f07004e; + public static final int about_map_tiles_summary=0x7f07004f; /** About Messages */ public static final int about_menu_instruction_text=0x7f070031; - public static final int about_osm_map=0x7f07004b; - public static final int about_osm_map_summary=0x7f07004c; - public static final int about_project=0x7f07003f; - public static final int about_project_summary=0x7f070040; - public static final int about_version=0x7f070039; - public static final int about_version_summary=0x7f07003a; + public static final int about_osm_map=0x7f07004c; + public static final int about_osm_map_summary=0x7f07004d; + public static final int about_project=0x7f070040; + public static final int about_project_summary=0x7f070041; + public static final int about_version=0x7f07003a; + public static final int about_version_summary=0x7f07003b; public static final int app_name=0x7f070004; public static final int bitcoin_error_message=0x7f07001b; - public static final int buildingImageDescription=0x7f070053; + public static final int buildingImageDescription=0x7f070054; public static final int building_non_residential=0x7f070007; public static final int building_residential=0x7f070006; /** Bus Activity */ - public static final int bus_activity_destination_label=0x7f070059; - public static final int bus_activity_no_destination_message=0x7f07005a; + public static final int bus_activity_destination_label=0x7f07005a; + public static final int bus_activity_no_destination_message=0x7f07005b; /** Bus Stop Specific Stop View Strings */ - public static final int bus_stop_stop_view_on_click_toast_help_message=0x7f070055; - public static final int bus_stop_stop_view_on_click_toast_unidentified_message=0x7f070056; + public static final int bus_stop_stop_view_on_click_toast_help_message=0x7f070056; + public static final int bus_stop_stop_view_on_click_toast_unidentified_message=0x7f070057; /** Bus Specific Stop View Strings */ - public static final int bus_stop_view_on_click_toast_help_message=0x7f070057; - public static final int bus_stop_view_on_click_toast_unidentified_message=0x7f070058; + public static final int bus_stop_view_on_click_toast_help_message=0x7f070058; + public static final int bus_stop_view_on_click_toast_unidentified_message=0x7f070059; public static final int bustimes_favourite_checkbox_label=0x7f070032; public static final int credits_help_message=0x7f070019; public static final int donate_button=0x7f07001a; @@ -218,7 +220,7 @@ public final class R { public static final int findmylocation_help_message=0x7f070014; public static final int legal_message=0x7f070005; public static final int licence_help_message=0x7f070018; - public static final int map_activity_toast_help_message=0x7f070054; + public static final int map_activity_toast_help_message=0x7f070055; /** Help Messages */ public static final int map_help_message=0x7f070011; @@ -230,6 +232,7 @@ public final class R { public static final int menu_preferences=0x7f070001; public static final int menu_previous_stop=0x7f070035; public static final int menu_refresh_stop=0x7f070037; + public static final int menu_refresh_stops=0x7f070038; public static final int menu_view=0x7f070002; public static final int pref_bus_stop=0x7f070008; public static final int preferences=0x7f07001c; diff --git a/res/menu/bus_menu.xml b/res/menu/bus_menu.xml new file mode 100644 index 0000000..5e22663 --- /dev/null +++ b/res/menu/bus_menu.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android" > + + <item + android:id="@+id/menu_refresh_bus" + android:icon="@drawable/ic_menu_refresh" + android:title="@string/menu_refresh_stops"/> + +</menu>
\ No newline at end of file diff --git a/res/menu/stop_menu.xml b/res/menu/bus_stop_menu.xml index c44efa2..c44efa2 100644 --- a/res/menu/stop_menu.xml +++ b/res/menu/bus_stop_menu.xml diff --git a/res/values/strings.xml b/res/values/strings.xml index e17ab11..521f04c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -102,6 +102,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.< <string name="menu_previous_stop">Previous</string> <string name="menu_next_stop">Next</string> <string name="menu_refresh_stop">Refresh</string> + <string name="menu_refresh_stops">Refresh</string> <!-- About Strings --> <string name="about">About</string> @@ -139,7 +140,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.< <string name="bus_stop_stop_view_on_click_toast_unidentified_message">Bus schedules not available for unidentified buses</string> <!-- Bus Specific Stop View Strings --> - <string name="bus_stop_view_on_click_toast_help_message">Hold to view the bus stop</string> + <string name="bus_stop_view_on_click_toast_help_message">Hold to view the bus stop on the map</string> <string name="bus_stop_view_on_click_toast_unidentified_message">Arrival prediction not available for timetabled buses</string> <!-- Bus Activity --> diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java index 3292ce8..f2cf133 100644 --- a/src/net/cbaines/suma/BusActivity.java +++ b/src/net/cbaines/suma/BusActivity.java @@ -16,6 +16,8 @@ import android.os.Handler; import android.preference.PreferenceManager; import android.util.Log; import android.view.Gravity; +import android.view.Menu; +import android.view.MenuInflater; import android.view.View; import android.widget.LinearLayout; import android.widget.ListView; @@ -117,8 +119,8 @@ public class BusActivity extends ToastHelperActivity implements Preferences { if (bus.destinationString != null) { Log.i(TAG, "Bus destination string is " + bus.destinationString); - busDestTextView - .setText(getResources().getString(R.string.bus_activity_destination_label) + bus.destinationString); + busDestTextView.setText(getResources().getString(R.string.bus_activity_destination_label) + + bus.destinationString); busDestTextView.setVisibility(View.VISIBLE); } else { Log.i(TAG, "Bus destination string is null"); @@ -137,12 +139,14 @@ public class BusActivity extends ToastHelperActivity implements Preferences { 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; @@ -166,6 +170,13 @@ public class BusActivity extends ToastHelperActivity implements Preferences { } } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.bus_menu, menu); + return true; + } + public void onResume() { super.onResume(); @@ -296,7 +307,9 @@ public class BusActivity extends ToastHelperActivity implements Preferences { 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/BusSpecificStopView.java b/src/net/cbaines/suma/BusSpecificStopView.java index 6d7e6af..fdb6f56 100644 --- a/src/net/cbaines/suma/BusSpecificStopView.java +++ b/src/net/cbaines/suma/BusSpecificStopView.java @@ -28,10 +28,12 @@ import android.content.res.Resources; import android.net.Uri; import android.util.Log; import android.view.Gravity; +import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.widget.LinearLayout; +import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; @@ -46,6 +48,8 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener private final TextView location; private final TextView time; + private final ProgressBar timeProgress; + private String onClickMessage = ""; private final BusActivity context; @@ -68,6 +72,8 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener time.setTextSize(22f); time.setGravity(Gravity.RIGHT); + timeProgress = new ProgressBar(context, null, android.R.attr.progressBarStyleSmall); + Resources resources = context.getResources(); onClickHelpMessage = resources.getString(R.string.bus_stop_view_on_click_toast_help_message); onClickUnidentifiedMessage = resources.getString(R.string.bus_stop_view_on_click_toast_unidentified_message); @@ -76,7 +82,7 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener addView(location, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); addView(time, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); - + addView(timeProgress, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } public void setStop(Stop stop) { @@ -92,8 +98,12 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener } if (stop.arivalTime != null) { time.setText(stop.getShortTimeToArival()); + time.setVisibility(View.VISIBLE); + timeProgress.setVisibility(View.GONE); } else { + time.setVisibility(View.GONE); time.setText(""); + timeProgress.setVisibility(View.VISIBLE); } DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class); @@ -104,23 +114,12 @@ public class BusSpecificStopView extends LinearLayout implements OnClickListener busDao.refresh(stop.bus); if (stop.arivalTime != null) { - - if (stop.bus.id != null) { - if (stop.live) { - onClickMessage = "Bus " + stop.bus.toString() + " at " - + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); - } else { - onClickMessage = "Timetabled bus " + stop.bus.toString() + " at " - + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); - } + if (stop.live) { + onClickMessage = stop.busStop.description + " at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); } else { - if (stop.live) { - onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at " - + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); - } else { - onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at " - + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime); - } + onClickMessage = stop.busStop.description + " at " + + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime) + " (timetabled)"; } } else { if (stop.bus.id != null) { diff --git a/src/net/cbaines/suma/BusSpecificTimetableAdapter.java b/src/net/cbaines/suma/BusSpecificTimetableAdapter.java index 7bcb560..96fe713 100644 --- a/src/net/cbaines/suma/BusSpecificTimetableAdapter.java +++ b/src/net/cbaines/suma/BusSpecificTimetableAdapter.java @@ -60,8 +60,8 @@ public class BusSpecificTimetableAdapter extends BaseAdapter { } if (changed == null || changed[position]) { - a.reset(); - stopView.startAnimation(a); + // a.reset(); + // stopView.startAnimation(a); // Log.i(TAG, "Animating it"); } diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java index 9c49ff7..429f103 100644 --- a/src/net/cbaines/suma/BusStopActivity.java +++ b/src/net/cbaines/suma/BusStopActivity.java @@ -59,8 +59,8 @@ import com.j256.ormlite.dao.Dao; import com.j256.ormlite.stmt.PreparedQuery; import com.j256.ormlite.stmt.QueryBuilder; -public class BusStopActivity extends ToastHelperActivity implements OnCheckedChangeListener, Preferences, OnItemClickListener, - OnLongClickListener { +public class BusStopActivity extends ToastHelperActivity implements OnCheckedChangeListener, Preferences, + OnItemClickListener, OnLongClickListener { final static String TAG = "BusTimeActivity"; @@ -320,10 +320,10 @@ public class BusStopActivity extends ToastHelperActivity implements OnCheckedCha 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(); @@ -363,7 +363,7 @@ public class BusStopActivity extends ToastHelperActivity implements OnCheckedCha @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.stop_menu, menu); + inflater.inflate(R.menu.bus_stop_menu, menu); return true; } |