diff --git a/DataExtractionOSM/src/com/osmand/ToDoConstants.java b/DataExtractionOSM/src/com/osmand/ToDoConstants.java
index 2a5c4c789d..165f65417b 100644
--- a/DataExtractionOSM/src/com/osmand/ToDoConstants.java
+++ b/DataExtractionOSM/src/com/osmand/ToDoConstants.java
@@ -11,6 +11,9 @@ public class ToDoConstants {
*/
public int DESCRIBE_ABOUT_AUTHORS = 8;
+ // TODO team :
+ // 1. write letters (UI/strings)
+
// TODO ANDROID
// 25. POI search near to map location (show categories & type). Second cut. (implement incremental search)
@@ -24,14 +27,13 @@ public class ToDoConstants {
// 8. Enable change POI directly on map (requires OSM login)
// 16. Support open street bugs api.
// 20. Implement save track/route to gpx (?)
+// 24. Show the whole street on map (when it is chosen in search activity). Possibly extend that story to show layer with streets.
+// 25. Show opened/closed amenities.
// TODO search story :
// 2) Find intersection of streets
- // 3) Shows progress dialog (?)
- // 6) Show street on map
- // 8) Show message (that user should input more than 2 symbols to get all)
- // 9) Loading cities in another thread
- // 10. fix bug with landscape layout (search address)
+ // 9) Loading cities (data) in another thread
+ // 10) fix bug with landscape layout (search address)
// FIXME Bugs Android :
@@ -53,6 +55,7 @@ public class ToDoConstants {
// 6. Implement renaming/deleting street/building/city
// 8. Implement basic transliteration version
// 7. Implement saving bundle of tiles in different folder
+ // 9. Using Collator in all TreeSet/TreeMap/Comparators
// 1. Download tiles without using dir tiles
diff --git a/OsmAnd/res/layout/search_by_name.xml b/OsmAnd/res/layout/search_by_name.xml
index 74b6c3fe36..fac952d58e 100644
--- a/OsmAnd/res/layout/search_by_name.xml
+++ b/OsmAnd/res/layout/search_by_name.xml
@@ -3,6 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
+
+
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 13975015b7..6bdb117716 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -40,4 +40,8 @@
#FF0000
searchpoi_activity
Find more
+Search city incrementally. In order to find villages input more than 3 first symbols.
+Search street incrementally
+Search building incrementally
+Choose region
diff --git a/OsmAnd/src/com/osmand/OsmandSettings.java b/OsmAnd/src/com/osmand/OsmandSettings.java
index 24b66d8a42..2469f9ae69 100644
--- a/OsmAnd/src/com/osmand/OsmandSettings.java
+++ b/OsmAnd/src/com/osmand/OsmandSettings.java
@@ -122,6 +122,7 @@ public class OsmandSettings {
public static final String LAST_SEARCHED_CITY = "last_searched_city";
public static final String LAST_SEARCHED_STREET = "last_searched_street";
public static final String LAST_SEARCHED_BUILDING = "last_searched_building";
+ public static final String LAST_SEARCHED_INTERSECTED_STREET = "last_searched_intersected_street";
public static String getLastSearchedRegion(Context ctx){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
@@ -140,7 +141,9 @@ public class OsmandSettings {
public static boolean setLastSearchedCity(Context ctx, Long cityId){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
- return prefs.edit().putLong(LAST_SEARCHED_CITY, cityId).commit();
+ return prefs.edit().
+ putLong(LAST_SEARCHED_CITY, cityId).putString(LAST_SEARCHED_STREET, "").putString(LAST_SEARCHED_BUILDING, "").
+ commit();
}
public static String getLastSearchedStreet(Context ctx){
@@ -150,7 +153,7 @@ public class OsmandSettings {
public static boolean setLastSearchedStreet(Context ctx, String street){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
- return prefs.edit().putString(LAST_SEARCHED_STREET, street).commit();
+ return prefs.edit().putString(LAST_SEARCHED_STREET, street).putString(LAST_SEARCHED_BUILDING, "").commit();
}
public static String getLastSearchedBuilding(Context ctx){
@@ -160,7 +163,21 @@ public class OsmandSettings {
public static boolean setLastSearchedBuilding(Context ctx, String building){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
- return prefs.edit().putString(LAST_SEARCHED_BUILDING, building).commit();
+ return prefs.edit().putString(LAST_SEARCHED_BUILDING, building).remove(LAST_SEARCHED_INTERSECTED_STREET).commit();
+ }
+
+
+ public static String getLastSearchedIntersectedStreet(Context ctx){
+ SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
+ if(!prefs.contains(LAST_SEARCHED_INTERSECTED_STREET)){
+ return null;
+ }
+ return prefs.getString(LAST_SEARCHED_INTERSECTED_STREET, "");
+ }
+
+ public static boolean setLastSearchedIntersectedStreet(Context ctx, String street){
+ SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
+ return prefs.edit().putString(LAST_SEARCHED_INTERSECTED_STREET, street).commit();
}
diff --git a/OsmAnd/src/com/osmand/RegionAddressRepository.java b/OsmAnd/src/com/osmand/RegionAddressRepository.java
index b96f56386b..bc5d5d6e93 100644
--- a/OsmAnd/src/com/osmand/RegionAddressRepository.java
+++ b/OsmAnd/src/com/osmand/RegionAddressRepository.java
@@ -58,6 +58,10 @@ public class RegionAddressRepository {
cityTypes.clear();
}
+ public boolean areCitiesPreloaded(){
+ return !cities.isEmpty();
+ }
+
public City getCityById(Long id){
if(id == -1){
// do not preload cities for that case
diff --git a/OsmAnd/src/com/osmand/activities/search/SearchActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchActivity.java
index 153723dbf5..848a75bebf 100644
--- a/OsmAnd/src/com/osmand/activities/search/SearchActivity.java
+++ b/OsmAnd/src/com/osmand/activities/search/SearchActivity.java
@@ -22,7 +22,7 @@ public class SearchActivity extends TabActivity {
super.onCreate(savedInstanceState);
TabHost host = getTabHost();
host.addTab(host.newTabSpec("Search_POI").setIndicator("Search POI").setContent(new Intent(this, SearchPOIListActivity.class)));
- host.addTab(host.newTabSpec("Search_Adress").setIndicator("Search Address").setContent(new Intent(this, SearchAddressActivity.class)));
+ host.addTab(host.newTabSpec("Search_Address").setIndicator("Search Address").setContent(new Intent(this, SearchAddressActivity.class)));
}
}
diff --git a/OsmAnd/src/com/osmand/activities/search/SearchAddressActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchAddressActivity.java
index 7128c39e53..c25521eeaf 100644
--- a/OsmAnd/src/com/osmand/activities/search/SearchAddressActivity.java
+++ b/OsmAnd/src/com/osmand/activities/search/SearchAddressActivity.java
@@ -2,6 +2,7 @@ package com.osmand.activities.search;
import android.app.Activity;
+import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -30,6 +31,7 @@ public class SearchAddressActivity extends Activity {
private City city = null;
private Street street = null;
private Building building = null;
+ private ProgressDialog dlg;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -42,7 +44,7 @@ public class SearchAddressActivity extends Activity {
cityButton = (Button) findViewById(R.id.CityButton);
countryButton = (Button) findViewById(R.id.CountryButton);
buildingButton = (Button) findViewById(R.id.BuildingButton);
- attachListeners();
+ attachListeners();
}
private void attachListeners() {
@@ -163,26 +165,75 @@ public class SearchAddressActivity extends Activity {
showOnMap.setEnabled(building != null || city != null || street != null);
}
+ public void loadData(){
+ if (region != null) {
+ city = region.getCityById(OsmandSettings.getLastSearchedCity(SearchAddressActivity.this));
+ if (city != null) {
+ street = region.getStreetByName(city, OsmandSettings.getLastSearchedStreet(SearchAddressActivity.this));
+ if (street != null) {
+ building = region.getBuildingByName(street, OsmandSettings
+ .getLastSearchedBuilding(SearchAddressActivity.this));
+ }
+ }
+ }
+ }
+
@Override
protected void onResume() {
super.onResume();
+
region = null;
+
+ String lastSearchedRegion = OsmandSettings.getLastSearchedRegion(SearchAddressActivity.this);
+ region = ResourceManager.getResourceManager().getRegionRepository(lastSearchedRegion);
+ String progressMsg = null;
+ // try to determine whether progress dialog & new thread needed
+ if(region.areCitiesPreloaded()){
+ progressMsg = "Loading cities...";
+ } else if(city == null || city.getId() != OsmandSettings.getLastSearchedCity(this)){
+ progressMsg = "Loading streets/buildings...";
+ }
city = null;
street = null;
building = null;
- String lastSearchedRegion = OsmandSettings.getLastSearchedRegion(this);
- region = ResourceManager.getResourceManager().getRegionRepository(lastSearchedRegion);
- if(region != null){
- city = region.getCityById(OsmandSettings.getLastSearchedCity(this));
- if(city != null){
- street = region.getStreetByName(city, OsmandSettings.getLastSearchedStreet(this));
- if(street != null){
- building = region.getBuildingByName(street, OsmandSettings.getLastSearchedBuilding(this));
+
+ if (progressMsg != null) {
+ dlg = ProgressDialog.show(this, "Loading", progressMsg, true);
+ new Thread("Loader search data") {
+ @Override
+ public void run() {
+ try {
+ loadData();
+ } finally {
+ dlg.dismiss();
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ updateUI();
+ }
+ });
+ }
}
- }
+ }.start();
+ } else {
+ loadData();
+ updateUI();
}
- updateUI();
+ }
+
+ @Override
+ protected void onPause() {
+ if(building == null && OsmandSettings.getLastSearchedBuilding(this).length() > 0){
+ OsmandSettings.setLastSearchedBuilding(this, "");
+ }
+ if(street == null && OsmandSettings.getLastSearchedStreet(this).length() > 0){
+ OsmandSettings.setLastSearchedStreet(this, "");
+ }
+ if(city == null && OsmandSettings.getLastSearchedCity(this) != -1){
+ OsmandSettings.setLastSearchedCity(this, -1l);
+ }
+ super.onPause();
}
diff --git a/OsmAnd/src/com/osmand/activities/search/SearchBuildingByNameActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchBuildingByNameActivity.java
index ffb36dfb10..77cea45736 100644
--- a/OsmAnd/src/com/osmand/activities/search/SearchBuildingByNameActivity.java
+++ b/OsmAnd/src/com/osmand/activities/search/SearchBuildingByNameActivity.java
@@ -7,6 +7,7 @@ import android.os.Bundle;
import android.widget.TextView;
import com.osmand.OsmandSettings;
+import com.osmand.R;
import com.osmand.RegionAddressRepository;
import com.osmand.ResourceManager;
import com.osmand.data.Building;
@@ -27,6 +28,7 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity
region = ResourceManager.getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(this));
location = OsmandSettings.getLastKnownMapLocation(this);
super.onCreate(savedInstanceState);
+ ((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_city);
}
@Override
diff --git a/OsmAnd/src/com/osmand/activities/search/SearchRegionByNameActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchRegionByNameActivity.java
index a134bbc551..419b5c3e69 100644
--- a/OsmAnd/src/com/osmand/activities/search/SearchRegionByNameActivity.java
+++ b/OsmAnd/src/com/osmand/activities/search/SearchRegionByNameActivity.java
@@ -3,14 +3,22 @@ package com.osmand.activities.search;
import java.util.ArrayList;
import java.util.List;
+import android.os.Bundle;
import android.widget.TextView;
import com.osmand.OsmandSettings;
+import com.osmand.R;
import com.osmand.RegionAddressRepository;
import com.osmand.ResourceManager;
public class SearchRegionByNameActivity extends SearchByNameAbstractActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ ((TextView)findViewById(R.id.Label)).setText(R.string.choose_available_region);
+ }
+
@Override
public List getObjects(String filter) {
return new ArrayList(ResourceManager.getResourceManager().getAddressRepositories());
diff --git a/OsmAnd/src/com/osmand/activities/search/SearchStreetByNameActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchStreetByNameActivity.java
index 4135376350..a392dee998 100644
--- a/OsmAnd/src/com/osmand/activities/search/SearchStreetByNameActivity.java
+++ b/OsmAnd/src/com/osmand/activities/search/SearchStreetByNameActivity.java
@@ -7,6 +7,7 @@ import android.os.Bundle;
import android.widget.TextView;
import com.osmand.OsmandSettings;
+import com.osmand.R;
import com.osmand.RegionAddressRepository;
import com.osmand.ResourceManager;
import com.osmand.data.City;
@@ -22,6 +23,7 @@ public class SearchStreetByNameActivity extends SearchByNameAbstractActivity