Now includes offline system map
This commit is contained in:
parent
fd4a7b2cef
commit
d732f0854a
@ -4,5 +4,6 @@
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="lib" path="libs/commons-io-2.0.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
|
@ -1,50 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.dougkeen.bart" android:versionCode="6"
|
||||
android:versionName="1.0.1">
|
||||
package="com.dougkeen.bart"
|
||||
android:versionCode="7"
|
||||
android:versionName="1.0.2" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<uses-sdk android:minSdkVersion="7" />
|
||||
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
||||
android:debuggable="true">
|
||||
<activity android:name="RoutesListActivity"
|
||||
<application
|
||||
android:debuggable="true"
|
||||
android:icon="@drawable/icon"
|
||||
android:label="@string/app_name" >
|
||||
<activity
|
||||
android:label="@string/app_name"
|
||||
android:name="RoutesListActivity" >
|
||||
<intent-filter >
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter >
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.intent.action.EDIT" />
|
||||
<action android:name="android.intent.action.PICK" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="vnd.android.cursor.dir/com.dougkeen.bart.favorite" />
|
||||
</intent-filter>
|
||||
<intent-filter >
|
||||
<action android:name="android.intent.action.GET_CONTENT" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="vnd.android.cursor.item/com.dougkeen.bart.favorite" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="AddRouteActivity" android:label="@string/app_name">
|
||||
<activity
|
||||
android:label="@string/app_name"
|
||||
android:name="AddRouteActivity" >
|
||||
<intent-filter >
|
||||
<action android:name="android.intent.action.INSERT" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="vnd.android.cursor.dir/com.dougkeen.bart.favorite" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="ViewDeparturesActivity"
|
||||
android:label="@string/app_name">
|
||||
<activity
|
||||
android:label="@string/app_name"
|
||||
android:name="ViewDeparturesActivity" >
|
||||
<intent-filter >
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="vnd.android.cursor.item/com.dougkeen.bart.favorite" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<provider android:name=".data.BartContentProvider"
|
||||
android:authorities="com.dougkeen.bart.dataprovider" android:label="Don\'t Miss The Bart data provider" />
|
||||
<activity
|
||||
android:label="@string/app_name"
|
||||
android:name="ViewMapActivity" >
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:authorities="com.dougkeen.bart.dataprovider"
|
||||
android:label="Don\'t Miss The Bart data provider"
|
||||
android:name=".data.BartContentProvider" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -1,11 +0,0 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "build.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-7
|
BIN
res/drawable/map.png
Normal file
BIN
res/drawable/map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 629 KiB |
@ -13,7 +13,7 @@
|
||||
<string name="error_null_destination">You must select a destination station</string>
|
||||
<string name="error_null_origin">You must select an origin station</string>
|
||||
<string name="departure_wait_message">Please wait while real time departure data is
|
||||
loaded...</string>
|
||||
loaded</string>
|
||||
<string name="no_data_message">No departure data is currently available for this
|
||||
route. Note that this route may require a non-standard transfer due to
|
||||
a temporary change in service. Check for service advisories posted at
|
||||
|
@ -36,7 +36,6 @@ public class AddRouteActivity extends Activity {
|
||||
|
||||
Button saveButton = (Button) findViewById(R.id.saveButton);
|
||||
saveButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onSaveButtonClick();
|
||||
}
|
||||
@ -45,7 +44,6 @@ public class AddRouteActivity extends Activity {
|
||||
|
||||
Button cancelButton = (Button) findViewById(R.id.cancelButton);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
|
@ -42,20 +42,16 @@ public class RoutesListActivity extends ListActivity {
|
||||
setContentView(R.layout.main);
|
||||
|
||||
mQuery = managedQuery(Constants.FAVORITE_CONTENT_URI, new String[] {
|
||||
RoutesColumns._ID.string,
|
||||
RoutesColumns.FROM_STATION.string,
|
||||
RoutesColumns._ID.string, RoutesColumns.FROM_STATION.string,
|
||||
RoutesColumns.TO_STATION.string }, null, null,
|
||||
RoutesColumns._ID.string);
|
||||
|
||||
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
|
||||
R.layout.favorite_listing,
|
||||
mQuery,
|
||||
new String[] { RoutesColumns.FROM_STATION.string,
|
||||
RoutesColumns.TO_STATION.string },
|
||||
new int[] { R.id.originText,
|
||||
R.id.destinationText });
|
||||
R.layout.favorite_listing, mQuery, new String[] {
|
||||
RoutesColumns.FROM_STATION.string,
|
||||
RoutesColumns.TO_STATION.string }, new int[] {
|
||||
R.id.originText, R.id.destinationText });
|
||||
adapter.setViewBinder(new ViewBinder() {
|
||||
@Override
|
||||
public boolean setViewValue(View view, Cursor cursor,
|
||||
int columnIndex) {
|
||||
((TextView) view).setText(Station.getByAbbreviation(cursor
|
||||
@ -93,9 +89,7 @@ public class RoutesListActivity extends ListActivity {
|
||||
Constants.FAVORITE_CONTENT_URI));
|
||||
return true;
|
||||
} else if (itemId == R.id.view_system_map_button) {
|
||||
startActivity(new Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse(Constants.MAP_URL)));
|
||||
startActivity(new Intent(this, ViewMapActivity.class));
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
@ -132,8 +126,7 @@ public class RoutesListActivity extends ListActivity {
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
||||
.getMenuInfo();
|
||||
mCurrentlySelectedUri = ContentUris.withAppendedId(
|
||||
Constants.FAVORITE_CONTENT_URI,
|
||||
info.id);
|
||||
Constants.FAVORITE_CONTENT_URI, info.id);
|
||||
|
||||
if (item.getItemId() == R.id.view) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, mCurrentlySelectedUri));
|
||||
@ -154,7 +147,6 @@ public class RoutesListActivity extends ListActivity {
|
||||
builder.setMessage("Are you sure you want to delete this route?");
|
||||
builder.setPositiveButton(R.string.yes,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getContentResolver().delete(mCurrentlySelectedUri,
|
||||
null, null);
|
||||
@ -165,7 +157,6 @@ public class RoutesListActivity extends ListActivity {
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mCurrentlySelectedUri = null;
|
||||
mCurrentlySelectedRouteName = null;
|
||||
|
@ -44,7 +44,6 @@ public class ViewDeparturesActivity extends ListActivity {
|
||||
private boolean mIsAutoUpdating = false;
|
||||
|
||||
private final Runnable AUTO_UPDATE_RUNNABLE = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runAutoUpdate();
|
||||
}
|
||||
@ -135,8 +134,7 @@ public class ViewDeparturesActivity extends ListActivity {
|
||||
}
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
mWakeLock = powerManager
|
||||
.newWakeLock(
|
||||
PowerManager.SCREEN_DIM_WAKE_LOCK,
|
||||
.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,
|
||||
"ViewDeparturesActivity");
|
||||
mWakeLock.acquire();
|
||||
if (mDeparturesAdapter != null && !mDeparturesAdapter.isEmpty()) {
|
||||
@ -152,8 +150,8 @@ public class ViewDeparturesActivity extends ListActivity {
|
||||
if (!hasWindowFocus())
|
||||
return;
|
||||
if (mGetDeparturesTask != null
|
||||
&& mGetDeparturesTask.getStatus()
|
||||
.equals(AsyncTask.Status.RUNNING)) {
|
||||
&& mGetDeparturesTask.getStatus().equals(
|
||||
AsyncTask.Status.RUNNING)) {
|
||||
// Don't overlap fetches
|
||||
return;
|
||||
}
|
||||
@ -172,8 +170,7 @@ public class ViewDeparturesActivity extends ListActivity {
|
||||
mDataFetchIsPending = false;
|
||||
Log.w(Constants.TAG, e.getMessage(), e);
|
||||
Toast.makeText(ViewDeparturesActivity.this,
|
||||
R.string.could_not_connect,
|
||||
Toast.LENGTH_LONG).show();
|
||||
R.string.could_not_connect, Toast.LENGTH_LONG).show();
|
||||
((TextView) findViewById(android.R.id.empty))
|
||||
.setText(R.string.could_not_connect);
|
||||
// Try again in 60s
|
||||
@ -182,8 +179,7 @@ public class ViewDeparturesActivity extends ListActivity {
|
||||
};
|
||||
Log.i(Constants.TAG, "Fetching data from server");
|
||||
mGetDeparturesTask.execute(new GetRealTimeDeparturesTask.Params(
|
||||
mOrigin,
|
||||
mDestination));
|
||||
mOrigin, mDestination));
|
||||
}
|
||||
|
||||
protected void processLatestDepartures(RealTimeDepartures result) {
|
||||
@ -241,8 +237,7 @@ public class ViewDeparturesActivity extends ListActivity {
|
||||
mDeparturesAdapter.notifyDataSetChanged();
|
||||
|
||||
if (hasWindowFocus() && firstDeparture != null) {
|
||||
if (needsBetterAccuracy
|
||||
|| firstDeparture.hasDeparted()) {
|
||||
if (needsBetterAccuracy || firstDeparture.hasDeparted()) {
|
||||
// Get more data in 20s
|
||||
scheduleDataFetch(20000);
|
||||
} else {
|
||||
@ -277,7 +272,6 @@ public class ViewDeparturesActivity extends ListActivity {
|
||||
private void scheduleDataFetch(int millisUntilExecute) {
|
||||
if (!mDataFetchIsPending) {
|
||||
mListTitleView.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fetchLatestDepartures();
|
||||
}
|
||||
@ -314,15 +308,14 @@ public class ViewDeparturesActivity extends ListActivity {
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("http://m.bart.gov/schedules/qp_results.aspx?type=departure&date=today&time="
|
||||
+ DateFormat.format("h:mmaa",
|
||||
System.currentTimeMillis()) + "&orig="
|
||||
System.currentTimeMillis())
|
||||
+ "&orig="
|
||||
+ mOrigin.abbreviation
|
||||
+ "&dest="
|
||||
+ mDestination.abbreviation)));
|
||||
return true;
|
||||
} else if (itemId == R.id.view_system_map_button) {
|
||||
startActivity(new Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse(Constants.MAP_URL)));
|
||||
startActivity(new Intent(this, ViewMapActivity.class));
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
21
src/com/dougkeen/bart/ViewMapActivity.java
Normal file
21
src/com/dougkeen/bart/ViewMapActivity.java
Normal file
@ -0,0 +1,21 @@
|
||||
package com.dougkeen.bart;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.webkit.WebView;
|
||||
|
||||
public class ViewMapActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
WebView webview = new WebView(this);
|
||||
setContentView(webview);
|
||||
|
||||
webview.getSettings().setBuiltInZoomControls(true);
|
||||
webview.getSettings().setSupportZoom(true);
|
||||
|
||||
webview.loadUrl("file:///android_res/drawable/map.png");
|
||||
}
|
||||
}
|
@ -195,7 +195,6 @@ public class Departure implements Parcelable, Comparable<Departure> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Departure another) {
|
||||
return (this.getMinutes() > another.getMinutes()) ? 1 : (
|
||||
(this.getMinutes() == another.getMinutes()) ? 0 : -1);
|
||||
@ -270,12 +269,10 @@ public class Departure implements Parcelable, Comparable<Departure> {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(destination.abbreviation);
|
||||
dest.writeString(destinationColor);
|
||||
|
Loading…
Reference in New Issue
Block a user