diff options
-rw-r--r-- | AndroidManifest.xml | 8 | ||||
-rw-r--r-- | gen/net/cbaines/suma/R.java | 54 | ||||
-rw-r--r-- | res/layout/search_activity.xml | 30 | ||||
-rw-r--r-- | res/values/strings.xml | 10 | ||||
-rw-r--r-- | src/net/cbaines/suma/BuildingNumOverlay.java | 24 | ||||
-rw-r--r-- | src/net/cbaines/suma/DatabaseHelper.java | 4 | ||||
-rw-r--r-- | src/net/cbaines/suma/MapActivity.java | 2 | ||||
-rw-r--r-- | src/net/cbaines/suma/SearchResultsActivity.java | 374 |
8 files changed, 58 insertions, 448 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 04e0d73..24b5cd1 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.cbaines.suma" - android:versionCode="11" - android:versionName="0.8 (alpha)" > + android:versionCode="12" + android:versionName="0.9 (beta)" > <uses-sdk android:minSdkVersion="8" @@ -58,10 +58,6 @@ android:name="android.app.searchable" android:resource="@xml/searchable" /> </activity> - <activity android:name=".SearchResultsActivity" > - </activity> - <activity android:name=".SearchResultsActivity" > - </activity> <activity android:name="BusStopActivity" > <intent-filter android:label="@string/app_name" > <action android:name="android.intent.action.VIEW" /> diff --git a/gen/net/cbaines/suma/R.java b/gen/net/cbaines/suma/R.java index 1572f39..9babefb 100644 --- a/gen/net/cbaines/suma/R.java +++ b/gen/net/cbaines/suma/R.java @@ -83,8 +83,8 @@ public final class R { public static final int busStopTimes=0x7f0a0023; public static final int busTimeContentLayout=0x7f0a0022; public static final int centerLoadBar=0x7f0a0024; - public static final int check1=0x7f0a0039; - public static final int childname=0x7f0a0038; + public static final int check1=0x7f0a0036; + public static final int childname=0x7f0a0035; public static final int donateBitcoinAddress=0x7f0a002e; public static final int donateButton=0x7f0a0003; public static final int donateDialogErrorMessage=0x7f0a002d; @@ -94,24 +94,21 @@ public final class R { public static final int favouriteCheckBox=0x7f0a0020; public static final int favouriteDialogMessage=0x7f0a0030; public static final int favouriteListItems=0x7f0a0031; - public static final int findContentLayout=0x7f0a0032; - public static final int findListItems=0x7f0a0034; - public static final int findLoadBar=0x7f0a0033; public static final int helpExpandableListView=0x7f0a0002; public static final int layout_root=0x7f0a0027; public static final int linearLayout1=0x7f0a001a; public static final int linearLayout2=0x7f0a0029; public static final int mapview=0x7f0a002f; - public static final int menu_about=0x7f0a0047; - public static final int menu_favourites=0x7f0a0048; - public static final int menu_find=0x7f0a0043; - public static final int menu_find_my_location=0x7f0a0045; - public static final int menu_next_stop=0x7f0a0042; - public static final int menu_preferences=0x7f0a0044; - public static final int menu_previous_stop=0x7f0a0040; - public static final int menu_refresh_bus=0x7f0a003f; - public static final int menu_refresh_stop=0x7f0a0041; - public static final int menu_view=0x7f0a0046; + public static final int menu_about=0x7f0a0044; + public static final int menu_favourites=0x7f0a0045; + public static final int menu_find=0x7f0a0040; + public static final int menu_find_my_location=0x7f0a0042; + public static final int menu_next_stop=0x7f0a003f; + public static final int menu_preferences=0x7f0a0041; + public static final int menu_previous_stop=0x7f0a003d; + public static final int menu_refresh_bus=0x7f0a003c; + public static final int menu_refresh_stop=0x7f0a003e; + public static final int menu_view=0x7f0a0043; public static final int radio_u1=0x7f0a001b; public static final int radio_u1n=0x7f0a001c; public static final int radio_u2=0x7f0a001d; @@ -119,14 +116,14 @@ public final class R { public static final int radio_u9=0x7f0a001f; public static final int textView1=0x7f0a0000; public static final int textView2=0x7f0a0001; - public static final int textView3=0x7f0a003c; - public static final int textView4=0x7f0a003d; - public static final int toastViewLinearLayout=0x7f0a0035; - public static final int toastViewSubMessage=0x7f0a0037; - public static final int toastViewText=0x7f0a0036; - public static final int view_list=0x7f0a003a; - public static final int welcomeDialogButton=0x7f0a003b; - public static final int welcomeDialogMessage=0x7f0a003e; + public static final int textView3=0x7f0a0039; + public static final int textView4=0x7f0a003a; + public static final int toastViewLinearLayout=0x7f0a0032; + public static final int toastViewSubMessage=0x7f0a0034; + public static final int toastViewText=0x7f0a0033; + public static final int view_list=0x7f0a0037; + public static final int welcomeDialogButton=0x7f0a0038; + public static final int welcomeDialogMessage=0x7f0a003b; } public static final class layout { public static final int about_dialog=0x7f030000; @@ -139,12 +136,11 @@ public final class R { public static final int donate_dialog=0x7f030007; public static final int map_activity=0x7f030008; public static final int poi_dialog=0x7f030009; - public static final int search_activity=0x7f03000a; - public static final int toast_view=0x7f03000b; - public static final int view_child_row=0x7f03000c; - public static final int view_dialog=0x7f03000d; - public static final int view_group_row=0x7f03000e; - public static final int welcome_dialog=0x7f03000f; + public static final int toast_view=0x7f03000a; + public static final int view_child_row=0x7f03000b; + public static final int view_dialog=0x7f03000c; + public static final int view_group_row=0x7f03000d; + public static final int welcome_dialog=0x7f03000e; } public static final class menu { public static final int bus_menu=0x7f090000; diff --git a/res/layout/search_activity.xml b/res/layout/search_activity.xml deleted file mode 100644 index 6e6bcd3..0000000 --- a/res/layout/search_activity.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:gravity="center|top" - android:orientation="vertical" - android:theme="@android:style/Theme.NoTitleBar" > - - <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/findContentLayout" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:gravity="center" - android:orientation="vertical" > - - <ProgressBar - android:id="@+id/findLoadBar" - style="?android:attr/progressBarStyleLarge" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - <ListView - android:id="@+id/findListItems" - android:layout_width="fill_parent" - android:layout_height="wrap_content" > - </ListView> - </LinearLayout> - -</LinearLayout>
\ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 7a62ceb..6f6cecc 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -23,11 +23,11 @@ <!-- Welcome Dialog --> <string name="welcome_dialog_title">Southampton University Map App</string> - <string name="welcome_dialog_version">Version 0.7 (alpha)</string> + <string name="welcome_dialog_version">Version 0.9 (beta)</string> <string name="welcome_dialog_copyright">© 2011 Christopher Baines</string> <string name="welcome_dialog_upgrade_message">Thanks for upgrading this app, and it\'s hoped that its better for you than the previous version. Noteable changes include\:\n - • New Search\n - • Other\n + • This message\n + • New Search interface\n \nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -39,7 +39,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</string> <string name="welcome_dialog_install_message">Welcome to the Southampton University Map App. Noteable features include\:\n - • Search for Buildings\n + • Search for Buildings and Bus Stops\n • Get Live Bus Times\n \nThis program is free software; you can redistribute it and/or @@ -125,7 +125,7 @@ GNU General Public License for more details.</string> <!-- About Strings --> <string name="about">About</string> <string name="about_version">Version</string> - <string name="about_version_summary">0.7 (alpha)</string> + <string name="about_version_summary">0.9 (beta)</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/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java index b541aa1..6acffa1 100644 --- a/src/net/cbaines/suma/BuildingNumOverlay.java +++ b/src/net/cbaines/suma/BuildingNumOverlay.java @@ -239,12 +239,34 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared } } + /** + * <b>You can prevent all(!) other Touch-related events from happening!</b><br /> + * By default does nothing (<code>return false</code>). If you handled the Event, return <code>true</code>, otherwise return + * <code>false</code>. If you returned <code>true</code> none of the following Overlays or the underlying {@link MapView} has + * the chance to handle this event. + */ + public boolean onTouchEvent(final MotionEvent event, final MapView mapView) { + Log.i(TAG, "getAction " + event.getAction()); + Log.i(TAG, "getDownTime " + event.getDownTime()); + Log.i(TAG, "getPointerCount " + event.getPointerCount()); + + return true; + } + @Override public boolean onLongPress(final MotionEvent event, final MapView mapView) { if (!this.isEnabled()) return false; + int pointerCount = event.getPointerCount(); + if (pointerCount > 1) { + Log.v(TAG, "Detected a zoom " + pointerCount); + return false; + } else { + Log.v(TAG, "Zoom not detected " + pointerCount); + } + final Building building = getSelectedItem(event, mapView); if (building == null) { @@ -254,7 +276,7 @@ public class BuildingNumOverlay extends Overlay implements Preferences, OnShared Log.v(TAG, "building Pressed " + building.id); final SharedPreferences favouritesPrefs = context.getSharedPreferences(FAVOURITES_PREFERENCES, 0); - final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + // final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); if (favouritesPrefs.getBoolean(building.id, false)) { favouritesPrefs.edit().remove(building.id).commit(); diff --git a/src/net/cbaines/suma/DatabaseHelper.java b/src/net/cbaines/suma/DatabaseHelper.java index 17ef720..21ee99b 100644 --- a/src/net/cbaines/suma/DatabaseHelper.java +++ b/src/net/cbaines/suma/DatabaseHelper.java @@ -210,9 +210,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { myOutput.flush(); myOutput.close(); myInput.close(); - + // getWritableDatabase().close(); - + Log.i(TAG, "Finished copying db"); } diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java index 2bdc3d7..f462060 100644 --- a/src/net/cbaines/suma/MapActivity.java +++ b/src/net/cbaines/suma/MapActivity.java @@ -195,7 +195,7 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants Log.i(TAG, "Begining loading database " + (System.currentTimeMillis() - startTime)); - DatabaseHelper helper = getHelper(); + DatabaseHelper helper = getHelperInternal(this); Log.i(TAG, "Got the helper at " + (System.currentTimeMillis() - startTime)); boolean dbExist = helper.checkDataBase(); diff --git a/src/net/cbaines/suma/SearchResultsActivity.java b/src/net/cbaines/suma/SearchResultsActivity.java deleted file mode 100644 index 503c876..0000000 --- a/src/net/cbaines/suma/SearchResultsActivity.java +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Southampton University Map App - * Copyright (C) 2011 Christopher Baines - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package net.cbaines.suma; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.osmdroid.util.GeoPoint; - -import android.app.SearchManager; -import android.content.Context; -import android.content.Intent; -import android.location.Location; -import android.location.LocationListener; -import android.location.LocationManager; -import android.net.Uri; -import android.os.Bundle; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.Log; -import android.view.Gravity; -import android.view.View; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.AdapterView.OnItemLongClickListener; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ProgressBar; - -import com.j256.ormlite.android.apptools.OrmLiteBaseActivity; -import com.j256.ormlite.dao.Dao; -import com.j256.ormlite.stmt.PreparedQuery; -import com.j256.ormlite.stmt.QueryBuilder; - -public class SearchResultsActivity extends OrmLiteBaseActivity<DatabaseHelper> implements Runnable, TextWatcher, - OnItemClickListener, LocationListener, OnItemLongClickListener { - - final static String TAG = "FindActivity"; - - public static final String ORIGIN = "o"; - public static final int MAP_ACTIVITY = 0; - - private ListView listItems; - private ProgressBar progBar; - private LinearLayout findContentLayout; - - private String searchTerm = ""; - - private Dao<Building, String> buildingDao; - private Dao<BusStop, String> busStopDao; - private Dao<Site, String> siteDao; - - private POIArrayAdapter adapter; - - private GeoPoint userLocation; - - private Thread searchThread; - - ArrayList<POI> getNearestPOIs(int distance) { - Log.i(TAG, "Getting nearest POI's"); - ArrayList<POI> nearestPOIs = new ArrayList<POI>(); - for (Iterator<Building> buildingDaoIter = buildingDao.iterator(); buildingDaoIter.hasNext();) { - POI poi = buildingDaoIter.next(); - int dist = poi.point.distanceTo(userLocation); - if (dist < distance) { - poi.distTo = dist; - nearestPOIs.add(poi); - } - } - - for (Iterator<BusStop> busStopDaoIter = busStopDao.iterator(); busStopDaoIter.hasNext();) { - POI poi = busStopDaoIter.next(); - int dist = poi.point.distanceTo(userLocation); - if (dist < distance) { - poi.distTo = dist; - nearestPOIs.add(poi); - } - } - - Collections.sort(nearestPOIs, new POIDistanceComparator(userLocation, true)); - - Log.i(TAG, "Got " + nearestPOIs.size() + " nearest POI's"); - return nearestPOIs; - } - - // Search thread - public void run() { - POIArrayAdapter tempAdaptor; - GeoPoint thisUserLocation = userLocation; - - Log.i(TAG, "Search thread started"); - String thisSearchTerm = searchTerm; - - ArrayList<POI> foundPOIsArray = null; - - Log.i(TAG, "Search term length " + thisSearchTerm.length() + " userLocation == null " - + (thisUserLocation == null)); - if (thisSearchTerm.length() == 0 && thisUserLocation != null) { - foundPOIsArray = getNearestPOIs(200); - - } - - if (foundPOIsArray != null && foundPOIsArray.size() != 0) { - - tempAdaptor = new POIArrayAdapter(this, foundPOIsArray); - } else { - - try { - - foundPOIsArray = new ArrayList<POI>(); - - if (thisSearchTerm.length() == 0) { - for (Building building : buildingDao) { - foundPOIsArray.add(building); - } - - if (!thisSearchTerm.equals(searchTerm)) - return; - - for (BusStop busStop : busStopDao) { - foundPOIsArray.add(busStop); - } - - if (!thisSearchTerm.equals(searchTerm)) - return; - - for (Site site : siteDao) { - foundPOIsArray.add(site); - } - - } else { - - QueryBuilder<Building, String> buildingQueryBuilder = buildingDao.queryBuilder(); - buildingQueryBuilder.where().like(Building.ID_FIELD_NAME, "%" + thisSearchTerm + "%").or() - .like(Building.NAME_FIELD_NAME, "%" + thisSearchTerm + "%"); - PreparedQuery<Building> buildingPreparedQuery = buildingQueryBuilder.prepare(); - List<Building> buildings = buildingDao.query(buildingPreparedQuery); - for (Building building : buildings) { - foundPOIsArray.add(building); - } - buildings = null; - - if (!thisSearchTerm.equals(searchTerm)) - return; - - if (thisSearchTerm.contains("site")) { - for (Site site : siteDao) { - foundPOIsArray.add(site); - } - } else { - QueryBuilder<Site, String> siteQueryBuilder = siteDao.queryBuilder(); - siteQueryBuilder.where().like(Site.ID_FIELD_NAME, "%" + thisSearchTerm + "%").or() - .like(Site.NAME_FIELD_NAME, "%" + thisSearchTerm + "%"); - PreparedQuery<Site> sitePreparedQuery = siteQueryBuilder.prepare(); - List<Site> sites = siteDao.query(sitePreparedQuery); - for (Site site : sites) { - foundPOIsArray.add(site); - } - sites = null; - } - - if (!thisSearchTerm.equals(searchTerm)) - return; - - // if (thisSearchTerm.contains("bus")) { - // for (BusStop busStop : busStopDao) { - // foundPOIsArray.add(busStop); - // } - // } else { - QueryBuilder<BusStop, String> busStopQueryBuilder = busStopDao.queryBuilder(); - busStopQueryBuilder.where().like(BusStop.ID_FIELD_NAME, "%" + thisSearchTerm + "%").or() - .like(BusStop.DESCRIPTION_FIELD_NAME, "%" + thisSearchTerm + "%"); - PreparedQuery<BusStop> busStopPreparedQuery = busStopQueryBuilder.prepare(); - List<BusStop> busStops = busStopDao.query(busStopPreparedQuery); - for (BusStop busStop : busStops) { - foundPOIsArray.add(busStop); - } - busStops = null; - // } - - if (!thisSearchTerm.equals(searchTerm)) - return; - - Log.i(TAG, "Found " + foundPOIsArray.size() + " pois"); - - if (thisUserLocation != null) { - Collections.sort(foundPOIsArray, new POIDistanceComparator(userLocation)); - } else { - Collections.sort(foundPOIsArray, new StringDistanceComparator(thisSearchTerm)); - } - - } - - if (!thisSearchTerm.equals(searchTerm)) - return; - - tempAdaptor = new POIArrayAdapter(this, foundPOIsArray); - - } catch (SQLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return; - } - } - - if (thisSearchTerm.equals(searchTerm)) { - Log.i(TAG, "Search terms still equal, starting post"); - adapter = tempAdaptor; - listItems.post(new Runnable() { - public void run() { - listItems.setAdapter(adapter); - if (progBar.getVisibility() != View.GONE) { - progBar.setVisibility(View.GONE); - findContentLayout.setGravity(Gravity.TOP); - } - } - }); - } else { - Log.i(TAG, "Search terms no longer equal, exiting"); - } - } - - /** Called when the activity is first created. */ - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.search_activity); - - Log.i(TAG, "FindActivity started"); - - Intent intent = getIntent(); - if (Intent.ACTION_SEARCH.equals(intent.getAction())) { - searchTerm = intent.getStringExtra(SearchManager.QUERY); - Log.i(TAG, "Searching for " + searchTerm); - } - - listItems = (ListView) findViewById(R.id.findListItems); - listItems.setOnItemClickListener(this); - listItems.setOnItemLongClickListener(this); - - progBar = (ProgressBar) findViewById(R.id.findLoadBar); - findContentLayout = (LinearLayout) findViewById(R.id.findContentLayout); - - try { - buildingDao = getHelper().getBuildingDao(); - busStopDao = getHelper().getBusStopDao(); - siteDao = getHelper().getSiteDao(); - } catch (SQLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - // Acquire a reference to the system Location Manager - LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); - Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - if (lastKnownLocation != null) { - userLocation = Util.locationToGeoPoint(lastKnownLocation); - } else { - lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); - if (lastKnownLocation != null) { - userLocation = Util.locationToGeoPoint(lastKnownLocation); - - } - } - // Register the listener with the Location Manager to receive location - // updates - locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 10, this); - try { - locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 10, this); - } catch (Exception e) { - // Ignore anything that goes wrong here... - } - - searchThread = new Thread(this); - searchThread.start(); - - } - - public void afterTextChanged(Editable s) { - searchTerm = s.toString(); - Log.i(TAG, "Text changed " + searchTerm + " starting search thread"); - new Thread(this).start(); - } - - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - Log.i(TAG, "OnItemClick pos " + position + " id " + id); - - POI poi = adapter.getPOIItem(position); - - 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); - } - - public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { - - POI poi = adapter.getPOIItem(position); - - Log.i(TAG, "Long Click Event ID: " + poi.id); - Uri uri = null; - - if (poi.type.equals(POI.BUS_STOP)) { - Log.i(TAG, "Its a bus stop"); - - BusStop busStop = (BusStop) poi; - - uri = Uri.parse("http://id.southampton.ac.uk/bus-stop/" + busStop.id); - - } else if (poi.type.equals(POI.BUILDING)) { - Log.i(TAG, "Its a buildings"); - - Building building = (Building) poi; - - uri = Uri.parse("http://id.southampton.ac.uk/building/" + building.id); - } else { - Log.e(TAG, "Error in onItemLongClick"); - return false; - } - - Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath()); - - Intent busStopIntent = new Intent(Intent.ACTION_VIEW, uri); - startActivity(busStopIntent); - - return true; - } - - public void onLocationChanged(Location location) { - Log.i(TAG, "Got location update for FindActivity"); - userLocation = Util.locationToGeoPoint(location); - if (!searchThread.isAlive()) { - searchThread = new Thread(this); - searchThread.start(); - } - } - - public void onProviderDisabled(String arg0) { - } - - public void onProviderEnabled(String provider) { - } - - public void onStatusChanged(String provider, int status, Bundle extras) { - } -}
\ No newline at end of file |