implement user stories

git-svn-id: https://osmand.googlecode.com/svn/trunk@112 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-06-01 21:39:35 +00:00
parent 7dd67ea397
commit 5a7c221e17
18 changed files with 213 additions and 90 deletions

View file

@ -15,6 +15,7 @@
<activity android:label="@string/search_activity" android:name=".activities.search.SearchActivity"></activity>
<activity android:name=".activities.search.SearchPOIActivity" android:label="@string/searchpoi_activity"></activity>
<activity android:name=".activities.search.SearchPOIListActivity"></activity>
<activity android:name=".activities.NavigatePointActivity"></activity>
<activity android:name=".activities.search.SearchAddressActivity"></activity>
<activity android:name=".activities.search.SearchCityByNameActivity"></activity>

View file

@ -2,7 +2,7 @@
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/map_context_menu" android:menuCategory="container"><item android:id="@+id/map_show_settings" android:title="@string/settings_Button"></item>
<item android:id="@+id/map_show_location" android:title="@string/show_location"></item>
<item android:title="@string/navigate_to_point" android:id="@+id/map_navigate_to_point"></item>
<item android:title="@string/map_specify_point" android:id="@+id/map_specify_point"></item>
</group>

View file

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="use_english_names_descr">Select use native or english names</string>
<string name="use_english_names">Use english names</string>
<string name="app_settings">Application settings</string>
<string name="search_address">Search address</string>
<string name="choose_building">Choose building</string>
<string name="choose_street">Choose street</string>

View file

@ -12,4 +12,6 @@
</PreferenceCategory>
<PreferenceCategory android:title="@string/map_source"><ListPreference android:title="@string/map_tile_source" android:summary="@string/map_tile_source_descr" android:key="map_tile_sources"></ListPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/app_settings"><CheckBoxPreference android:summary="@string/use_english_names_descr" android:title="@string/use_english_names" android:key="use_english_names"></CheckBoxPreference>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -54,8 +54,10 @@ public class AmenityIndexRepository {
am.setLocation(query.getDouble(IndexPoiTable.LATITUDE.ordinal()),
query.getDouble(IndexPoiTable.LONGITUDE.ordinal()));
am.setName(query.getString(IndexPoiTable.NAME.ordinal() ));
am.setEnName(query.getString(IndexPoiTable.NAME_EN.ordinal()));
am.setType(AmenityType.fromString(query.getString(IndexPoiTable.TYPE.ordinal())));
am.setSubType(query.getString(IndexPoiTable.SUBTYPE.ordinal()));
am.setOpeningHours(query.getString(IndexPoiTable.OPENING_HOURS.ordinal()));
amenities.add(am);
if(limit != -1 && amenities.size() >= limit){
break;

View file

@ -61,6 +61,18 @@ public class OsmandSettings {
return prefs.getBoolean(MAP_VIEW_3D, false);
}
// this value string is synchronized with settings_pref.xml preference name
public static final String USE_ENGLISH_NAMES = "use_english_names";
public static boolean usingEnglishNames(Context ctx){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.getBoolean(USE_ENGLISH_NAMES, false);
}
public static boolean setUseEnglishNames(Context ctx, boolean useEnglishNames){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.edit().putBoolean(USE_ENGLISH_NAMES, useEnglishNames).commit();
}
// this value string is synchronized with settings_pref.xml preference name
public static final String MAP_TILE_SOURCES = "map_tile_sources";

View file

@ -3,10 +3,12 @@ package com.osmand;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.TreeMap;
import java.util.Map;
import org.apache.commons.logging.Log;
@ -15,6 +17,7 @@ import android.database.sqlite.SQLiteDatabase;
import com.osmand.data.Building;
import com.osmand.data.City;
import com.osmand.data.Region;
import com.osmand.data.Street;
import com.osmand.data.City.CityType;
import com.osmand.data.index.IndexConstants;
@ -28,7 +31,9 @@ public class RegionAddressRepository {
private SQLiteDatabase db;
private String name;
private LinkedHashMap<Long, City> cities = new LinkedHashMap<Long, City>();
private TreeMap<CityType, List<City>> cityTypes = new TreeMap<CityType, List<City>>();
private Map<CityType, List<City>> cityTypes = new HashMap<CityType, List<City>>();
private boolean useEnglishNames = false;
public void initialize(final IProgress progress, File file) {
long start = System.currentTimeMillis();
@ -44,6 +49,7 @@ public class RegionAddressRepository {
}
public void close(){
clearCities();
if(db != null){
db.close();
}
@ -83,13 +89,40 @@ public class RegionAddressRepository {
preloadBuildings(street);
}
for(Building b : street.getBuildings()){
if(b.getName().equals(name)){
String bName = useEnglishNames ? b.getEnName() : b.getName();
if(bName.equals(name)){
return b;
}
}
return null;
}
public boolean useEnglishNames(){
return useEnglishNames;
}
public void setUseEnglishNames(boolean useEnglishNames) {
this.useEnglishNames = useEnglishNames;
// sort streets
for (City c : cities.values()) {
if (!c.isEmptyWithStreets()) {
ArrayList<Street> list = new ArrayList<Street>(c.getStreets());
c.removeAllStreets();
for (Street s : list) {
c.registerStreet(s, useEnglishNames);
}
}
}
// sort cities
ArrayList<City> list = new ArrayList<City>(cities.values());
Collections.sort(list, new Region.CityComparator(useEnglishNames));
cities.clear();
cityTypes.clear();
for(City c : list){
registerCity(c);
}
}
public void fillWithSuggestedBuildings(Street street, String name, List<Building> buildingsToFill){
preloadBuildings(street);
name = name.toLowerCase();
@ -99,7 +132,8 @@ public class RegionAddressRepository {
return;
}
for (Building building : street.getBuildings()) {
String lowerCase = building.getName().toLowerCase();
String bName = useEnglishNames ? building.getEnName() : building.getName();
String lowerCase = bName.toLowerCase();
if (lowerCase.startsWith(name)) {
buildingsToFill.add(ind, building);
ind++;
@ -118,7 +152,8 @@ public class RegionAddressRepository {
return;
}
for (Street s : c.getStreets()) {
String lowerCase = s.getName().toLowerCase();
String sName = useEnglishNames ? s.getEnName() : s.getName();
String lowerCase = sName.toLowerCase();
if (lowerCase.startsWith(name)) {
streetsToFill.add(ind, s);
ind++;
@ -138,7 +173,8 @@ public class RegionAddressRepository {
} else {
name = name.toLowerCase();
for (City c : cityTypes.get(t)) {
String lowerCase = c.getName().toLowerCase();
String cName = useEnglishNames ? c.getEnName() : c.getName();
String lowerCase = cName.toLowerCase();
if(lowerCase.startsWith(name)){
citiesToFill.add(c);
}
@ -151,7 +187,8 @@ public class RegionAddressRepository {
name = name.toLowerCase();
Collection<City> src = cities.values();
for (City c : src) {
String lowerCase = c.getName().toLowerCase();
String cName = useEnglishNames ? c.getEnName() : c.getName();
String lowerCase = cName.toLowerCase();
if (lowerCase.startsWith(name)) {
citiesToFill.add(ind, c);
ind++;
@ -168,7 +205,7 @@ public class RegionAddressRepository {
append(IndexCityTable.CITY_TYPE.toString()).append(" not in (").
append('\'').append(CityType.valueToString(CityType.CITY)).append('\'').append(", ").
append('\'').append(CityType.valueToString(CityType.TOWN)).append('\'').append(") and ").
append(IndexCityTable.NAME.toString()).append(" LIKE '"+name+"%'");
append(useEnglishNames ? IndexCityTable.NAME_EN.toString() : IndexCityTable.NAME.toString()).append(" LIKE '"+name+"%'");
Cursor query = db.query(IndexCityTable.getTable(), IndexConstants.generateColumnNames(IndexCityTable.values()),
where.toString(), null, null, null, null);
if (query.moveToFirst()) {
@ -195,6 +232,7 @@ public class RegionAddressRepository {
building.setLocation(query.getDouble(IndexBuildingTable.LATITUDE.ordinal()), query.getDouble(IndexBuildingTable.LONGITUDE
.ordinal()));
building.setName(query.getString(IndexBuildingTable.NAME.ordinal()));
building.setEnName(query.getString(IndexBuildingTable.NAME_EN.ordinal()));
street.registerBuilding(building);
} while (query.moveToNext());
}
@ -215,7 +253,8 @@ public class RegionAddressRepository {
street.setLocation(query.getDouble(IndexStreetTable.LATITUDE.ordinal()), query.getDouble(IndexStreetTable.LONGITUDE
.ordinal()));
street.setName(query.getString(IndexStreetTable.NAME.ordinal()));
city.registerStreet(street);
street.setEnName(query.getString(IndexStreetTable.NAME_EN.ordinal()));
city.registerStreet(street, useEnglishNames);
} while (query.moveToNext());
}
query.close();
@ -240,6 +279,7 @@ public class RegionAddressRepository {
city.setLocation(query.getDouble(IndexCityTable.LATITUDE.ordinal()), query.getDouble(IndexCityTable.LONGITUDE
.ordinal()));
city.setName(query.getString(IndexCityTable.NAME.ordinal()));
city.setEnName(query.getString(IndexCityTable.NAME_EN.ordinal()));
return city;
}
return null;

View file

@ -1,6 +1,7 @@
package com.osmand;
import java.io.File;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
@ -59,7 +60,7 @@ public class ResourceManager {
private MapTileDownloader downloader = MapTileDownloader.getInstance();
// Indexes
private Map<String, RegionAddressRepository> addressMap = new TreeMap<String, RegionAddressRepository>();
private Map<String, RegionAddressRepository> addressMap = new TreeMap<String, RegionAddressRepository>(Collator.getInstance());
protected List<AmenityIndexRepository> amenityRepositories = new ArrayList<AmenityIndexRepository>();
@ -253,8 +254,10 @@ public class ResourceManager {
for(AmenityIndexRepository r : amenityRepositories){
r.clearCache();
}
for(RegionAddressRepository r : addressMap.values()){
r.clearCities();
}
// TODO clear addresses indexes
System.gc();
}

View file

@ -1,7 +1,5 @@
package com.osmand.activities;
import java.text.MessageFormat;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
@ -27,7 +25,6 @@ import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.Toast;
import android.widget.ZoomControls;
import com.osmand.LogUtil;
@ -356,13 +353,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.map_show_location) {
float f = (Runtime.getRuntime().totalMemory()) / 1e6f;
String text = MessageFormat.format("Latitude : {0}, longitude : {1}, zoom : {2}, memory : {3}", mapView.getLatitude(), mapView
.getLongitude(), mapView.getZoom(), f);
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
return true;
} else if (item.getItemId() == R.id.map_show_settings) {
if (item.getItemId() == R.id.map_show_settings) {
final Intent settings = new Intent(MapActivity.this, SettingsActivity.class);
startActivity(settings);
return true;
@ -386,7 +377,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
}
private void openChangeLocationDialog() {
NavigatePointDialog dlg = new NavigatePointDialog(this, mapView);
NavigatePointActivity dlg = new NavigatePointActivity(this, mapView);
dlg.showDialog();
}

View file

@ -4,37 +4,78 @@ import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.osmand.LogUtil;
import com.osmand.OsmandSettings;
import com.osmand.R;
import com.osmand.osm.LatLon;
import com.osmand.views.OsmandMapTileView;
public class NavigatePointDialog {
public class NavigatePointActivity extends Activity {
Dialog dlg;
OsmandMapTileView view;
int currentFormat = Location.FORMAT_DEGREES;
public NavigatePointDialog(Context ctx, OsmandMapTileView view){
// dialog constructor
public NavigatePointActivity(Context ctx, OsmandMapTileView view){
this.view = view;
dlg = new Dialog(ctx);
}
public NavigatePointActivity() {
}
public void showDialog(){
dlg.setContentView(R.layout.navigate_point);
dlg.setTitle("Navigate to point");
initUI(view.getLatitude(), view.getLongitude());
dlg.show();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LatLon loc = OsmandSettings.getLastKnownMapLocation(this);
setContentView(R.layout.navigate_point);
setTitle("Navigate to point");
initUI(loc.getLatitude(), loc.getLongitude());
((Button) findViewById(R.id.Cancel)).setVisibility(View.INVISIBLE);
}
@Override
public View findViewById(int id) {
if(dlg != null){
return dlg.findViewById(id);
}
return super.findViewById(id);
}
public void close(){
if(dlg != null){
dlg.dismiss();
} else {
Intent newIntent = new Intent(this, MapActivity.class);
startActivity(newIntent);
}
}
public void initUI(double latitude, double longitude){
dlg.setContentView(R.layout.navigate_point);
dlg.setTitle("Navigate to point");
((TextView)dlg.findViewById(R.id.LatitudeEdit)).setText(convert(latitude, Location.FORMAT_DEGREES));
((TextView)dlg.findViewById(R.id.LongitudeEdit)).setText(convert(longitude, Location.FORMAT_DEGREES));
((RadioButton)dlg.findViewById(R.id.Format1)).setChecked(true);
((RadioGroup)dlg.findViewById(R.id.RadioGroup01)).setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
((TextView)findViewById(R.id.LatitudeEdit)).setText(convert(latitude, Location.FORMAT_DEGREES));
((TextView)findViewById(R.id.LongitudeEdit)).setText(convert(longitude, Location.FORMAT_DEGREES));
((RadioButton)findViewById(R.id.Format1)).setChecked(true);
((RadioGroup)findViewById(R.id.RadioGroup01)).setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
@ -47,35 +88,39 @@ public class NavigatePointDialog {
newFormat = Location.FORMAT_SECONDS;
}
try {
double lat = Location.convert(((TextView) dlg.findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = Location.convert(((TextView) dlg.findViewById(R.id.LongitudeEdit)).getText().toString());
((TextView)dlg.findViewById(R.id.LatitudeEdit)).setText(convert(lat, newFormat));
((TextView)dlg.findViewById(R.id.LongitudeEdit)).setText(convert(lon, newFormat));
double lat = Location.convert(((TextView) findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = Location.convert(((TextView) findViewById(R.id.LongitudeEdit)).getText().toString());
((TextView)findViewById(R.id.LatitudeEdit)).setText(convert(lat, newFormat));
((TextView)findViewById(R.id.LongitudeEdit)).setText(convert(lon, newFormat));
} catch (RuntimeException e) {
((TextView) findViewById(R.id.ValidateTextView)).setText("Locations are invalid");
Log.w(LogUtil.TAG, "Convertion failed", e);
}
}
});
((Button) dlg.findViewById(R.id.Cancel)).setOnClickListener(new View.OnClickListener() {
((Button) findViewById(R.id.Cancel)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dlg.dismiss();
close();
}
});
((Button) dlg.findViewById(R.id.ShowOnMap)).setOnClickListener(new View.OnClickListener() {
((Button) findViewById(R.id.ShowOnMap)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
double lat = Location.convert(((TextView) dlg.findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = Location.convert(((TextView) dlg.findViewById(R.id.LongitudeEdit)).getText().toString());
// TODO there is a bug in that convert if min = 59.23 or sec = 59.32 or deg=179.3
double lat = Location.convert(((TextView) findViewById(R.id.LatitudeEdit)).getText().toString());
double lon = Location.convert(((TextView) findViewById(R.id.LongitudeEdit)).getText().toString());
if(view != null) {
view.setLatLon(lat, lon);
} else {
OsmandSettings.setLastKnownMapLocation(dlg.getContext(), lat, lon);
OsmandSettings.setLastKnownMapLocation(NavigatePointActivity.this, lat, lon);
}
dlg.dismiss();
close();
} catch (RuntimeException e) {
((TextView) dlg.findViewById(R.id.ValidateTextView)).setText("Locations are invalid");
((TextView) findViewById(R.id.ValidateTextView)).setText("Locations are invalid");
Log.w(LogUtil.TAG, "Convertion failed", e);
}
}
});
@ -122,8 +167,6 @@ public class NavigatePointDialog {
return sb.toString();
}
public void showDialog(){
dlg.show();
}
}

View file

@ -26,6 +26,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
private CheckBoxPreference rotateMapToBearing;
private CheckBoxPreference showViewAngle;
private ListPreference positionOnMap;
private CheckBoxPreference useEnglishNames;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -40,6 +41,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
rotateMapToBearing.setOnPreferenceChangeListener(this);
showViewAngle =(CheckBoxPreference) screen.findPreference(OsmandSettings.SHOW_VIEW_ANGLE);
showViewAngle.setOnPreferenceChangeListener(this);
useEnglishNames =(CheckBoxPreference) screen.findPreference(OsmandSettings.USE_ENGLISH_NAMES);
useEnglishNames.setOnPreferenceChangeListener(this);
positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP);
positionOnMap.setOnPreferenceChangeListener(this);
@ -56,6 +59,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
showPoiOnMap.setChecked(OsmandSettings.isShowingPoiOverMap(this));
rotateMapToBearing.setChecked(OsmandSettings.isRotateMapToBearing(this));
showViewAngle.setChecked(OsmandSettings.isShowingViewAngle(this));
useEnglishNames.setChecked(OsmandSettings.usingEnglishNames(this));
String[] e = new String[] { "Center", "Bottom" };
positionOnMap.setEntryValues(e);
positionOnMap.setEntries(e);
@ -89,6 +93,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
} else if(preference == rotateMapToBearing){
edit.putBoolean(OsmandSettings.ROTATE_MAP_TO_BEARING, (Boolean) newValue);
edit.commit();
} else if(preference == useEnglishNames){
edit.putBoolean(OsmandSettings.USE_ENGLISH_NAMES, (Boolean) newValue);
edit.commit();
} else if(preference == showViewAngle){
edit.putBoolean(OsmandSettings.SHOW_VIEW_ANGLE, (Boolean) newValue);
edit.commit();

View file

@ -3,6 +3,8 @@
*/
package com.osmand.activities.search;
import com.osmand.activities.NavigatePointActivity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
@ -23,6 +25,7 @@ public class SearchActivity extends TabActivity {
TabHost host = getTabHost();
host.addTab(host.newTabSpec("Search_POI").setIndicator("Search POI").setContent(new Intent(this, SearchPOIListActivity.class)));
host.addTab(host.newTabSpec("Search_Address").setIndicator("Search Address").setContent(new Intent(this, SearchAddressActivity.class)));
host.addTab(host.newTabSpec("Search_Location").setIndicator("Search Location").setContent(new Intent(this, NavigatePointActivity.class)));
}
}

View file

@ -31,7 +31,6 @@ 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) {
@ -143,7 +142,7 @@ public class SearchAddressActivity extends Activity {
if(city == null){
cityButton.setText(R.string.choose_city);
} else {
cityButton.setText(city.getName());
cityButton.setText(city.getName(region.useEnglishNames()));
}
cityButton.setEnabled(region != null);
@ -151,7 +150,7 @@ public class SearchAddressActivity extends Activity {
if(street == null){
streetButton.setText(R.string.choose_street);
} else {
streetButton.setText(street.getName());
streetButton.setText(street.getName(region.useEnglishNames()));
}
streetButton.setEnabled(city != null);
@ -159,7 +158,7 @@ public class SearchAddressActivity extends Activity {
if(building == null){
buildingButton.setText(R.string.choose_building);
} else {
buildingButton.setText(building.getName());
buildingButton.setText(building.getName(region.useEnglishNames()));
}
buildingButton.setEnabled(street != null);
showOnMap.setEnabled(building != null || city != null || street != null);
@ -167,6 +166,9 @@ public class SearchAddressActivity extends Activity {
public void loadData(){
if (region != null) {
if(region.useEnglishNames() != OsmandSettings.usingEnglishNames(this)){
region.setUseEnglishNames(OsmandSettings.usingEnglishNames(this));
}
city = region.getCityById(OsmandSettings.getLastSearchedCity(SearchAddressActivity.this));
if (city != null) {
street = region.getStreetByName(city, OsmandSettings.getLastSearchedStreet(SearchAddressActivity.this));
@ -178,27 +180,8 @@ public class SearchAddressActivity extends Activity {
}
}
@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;
if (progressMsg != null) {
dlg = ProgressDialog.show(this, "Loading", progressMsg, true);
protected void startLoadDataInThread(String progressMsg){
final ProgressDialog dlg = ProgressDialog.show(this, "Loading", progressMsg, true);
new Thread("Loader search data") {
@Override
public void run() {
@ -215,6 +198,33 @@ public class SearchAddressActivity extends Activity {
}
}
}.start();
}
@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 != null) {
Long cityId = OsmandSettings.getLastSearchedCity(this);
if (!region.areCitiesPreloaded()) {
progressMsg = "Loading cities...";
} else if (cityId != -1 && region.getCityById(cityId).isEmptyWithStreets()) {
progressMsg = "Loading streets/buildings...";
} else if (OsmandSettings.usingEnglishNames(this) != region.useEnglishNames()) {
progressMsg = "Converting native/english names...";
}
}
city = null;
street = null;
building = null;
if (progressMsg != null) {
startLoadDataInThread(progressMsg);
} else {
loadData();
updateUI();
@ -224,15 +234,16 @@ public class SearchAddressActivity extends Activity {
@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);
}
// Do not reset settings (cause it is not so necessary)
// 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();
}

View file

@ -42,12 +42,12 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<B
@Override
public void updateTextView(Building obj, TextView txt) {
txt.setText(obj.getName());
txt.setText(obj.getName(region.useEnglishNames()));
}
@Override
public void itemSelected(Building obj) {
OsmandSettings.setLastSearchedBuilding(this, obj.getName());
OsmandSettings.setLastSearchedBuilding(this, obj.getName(region.useEnglishNames()));
finish();
}

View file

@ -38,9 +38,9 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City>
@Override
public void updateTextView(City obj, TextView txt) {
if(getFilter().length() > 2){
txt.setText(obj.getName() + " - " + MapUtils.getFormattedDistance((int) MapUtils.getDistance(obj.getLocation(), location)));
txt.setText(obj.getName(region.useEnglishNames()) + " - " + MapUtils.getFormattedDistance((int) MapUtils.getDistance(obj.getLocation(), location)));
} else {
txt.setText(obj.getName());
txt.setText(obj.getName(region.useEnglishNames()));
}
}

View file

@ -139,7 +139,7 @@ public class SearchPOIActivity extends ListActivity {
LatLon lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(SearchPOIActivity.this);
int dist = (int) (MapUtils.getDistance(anemity.getLocation(), lastKnownMapLocation.getLatitude(), lastKnownMapLocation
.getLongitude()));
String str = anemity.getStringWithoutType();
String str = anemity.getStringWithoutType(OsmandSettings.usingEnglishNames(SearchPOIActivity.this));
label.setText(str);
icon.setImageResource(R.drawable.poi);
distanceLabel.setText(" " + dist + " m ");

View file

@ -37,12 +37,12 @@ public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Str
@Override
public void updateTextView(Street obj, TextView txt) {
txt.setText(obj.getName());
txt.setText(obj.getName(region.useEnglishNames()));
}
@Override
public void itemSelected(Street obj) {
OsmandSettings.setLastSearchedStreet(this, obj.getName());
OsmandSettings.setLastSearchedStreet(this, obj.getName(region.useEnglishNames()));
finish();
}

View file

@ -11,6 +11,7 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.widget.Toast;
import com.osmand.OsmandSettings;
import com.osmand.ResourceManager;
import com.osmand.data.Amenity;
import com.osmand.osm.MapUtils;
@ -43,7 +44,11 @@ public class POIMapLayer implements OsmandMapLayer {
int x = view.getRotatedMapXForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
int y = view.getRotatedMapYForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
Toast.makeText(view.getContext(), n.getSimpleFormat(), Toast.LENGTH_SHORT).show();
String format = n.getSimpleFormat(OsmandSettings.usingEnglishNames(view.getContext()));
if(n.getOpeningHours() != null){
format += "\n Opening hours : " + n.getOpeningHours();
}
Toast.makeText(view.getContext(), format, Toast.LENGTH_SHORT).show();
return true;
}
}