Merge pull request #6101 from osmandapp/SearchImprovement
Fix last searched city update
This commit is contained in:
commit
844d25452b
2 changed files with 147 additions and 135 deletions
|
@ -10,6 +10,9 @@
|
||||||
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<string name="search_street">Search street</string>
|
||||||
|
<string name="start_search_from_city">Start search from city</string>
|
||||||
<string name="shared_string_restore">Restore</string>
|
<string name="shared_string_restore">Restore</string>
|
||||||
<string name="keep_passed_markers_descr">Markers added as a group of Favorites or GPX waypoints marked "Passed" will remain on the map. If the group is not active, the markers will disappear from the map.</string>
|
<string name="keep_passed_markers_descr">Markers added as a group of Favorites or GPX waypoints marked "Passed" will remain on the map. If the group is not active, the markers will disappear from the map.</string>
|
||||||
<string name="keep_passed_markers">Keep passed markers on the map</string>
|
<string name="keep_passed_markers">Keep passed markers on the map</string>
|
||||||
|
|
|
@ -1255,10 +1255,21 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean searchFinished(SearchPhrase phrase) {
|
public boolean searchFinished(SearchPhrase phrase) {
|
||||||
SearchResultCollection res = getResultCollection();
|
|
||||||
if (SearchUICore.isDebugMode()) {
|
if (SearchUICore.isDebugMode()) {
|
||||||
LOG.info("UI >> Nearest cities found: " + getSearchResultCollectionFormattedSize(res));
|
LOG.info("UI >> Nearest cities found: " + getSearchResultCollectionFormattedSize(getResultCollection()));
|
||||||
}
|
}
|
||||||
|
updateCitiesItems();
|
||||||
|
if (SearchUICore.isDebugMode()) {
|
||||||
|
LOG.info("UI >> Nearest cities loaded");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
restoreSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCitiesItems() {
|
||||||
|
SearchResultCollection res = getResultCollection();
|
||||||
|
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
List<QuickSearchListItem> rows = new ArrayList<>();
|
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||||
|
@ -1283,7 +1294,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
|
|
||||||
final String lastCityName = lastCity == null ? settings.getLastSearchedCityName() : lastCity.localeName;
|
final String lastCityName = lastCity == null ? settings.getLastSearchedCityName() : lastCity.localeName;
|
||||||
if (!Algorithms.isEmpty(lastCityName)) {
|
if (!Algorithms.isEmpty(lastCityName)) {
|
||||||
String selectStreets = app.getString(R.string.select_street);
|
String selectStreets = app.getString(R.string.search_street);
|
||||||
String inCityName = app.getString(R.string.shared_string_in_name, lastCityName);
|
String inCityName = app.getString(R.string.shared_string_in_name, lastCityName);
|
||||||
Spannable spannable = new SpannableString(selectStreets + " " + inCityName);
|
Spannable spannable = new SpannableString(selectStreets + " " + inCityName);
|
||||||
boolean light = settings.isLightContent();
|
boolean light = settings.isLightContent();
|
||||||
|
@ -1347,7 +1358,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_building_number,
|
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_building_number,
|
||||||
app.getString(R.string.select_city), new OnClickListener() {
|
app.getString(R.string.start_search_from_city), new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
searchEditText.setHint(R.string.type_city_town);
|
searchEditText.setHint(R.string.type_city_town);
|
||||||
|
@ -1389,13 +1400,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addressSearchFragment.updateListAdapter(rows, false);
|
addressSearchFragment.updateListAdapter(rows, false);
|
||||||
if (SearchUICore.isDebugMode()) {
|
|
||||||
LOG.info("UI >> Nearest cities loaded");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
restoreSearch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadHistory() {
|
public void reloadHistory() {
|
||||||
|
@ -1804,14 +1808,19 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
if (addressSearch) {
|
if (addressSearch) {
|
||||||
startAddressSearch();
|
startAddressSearch();
|
||||||
if (sr.objectType == ObjectType.CITY) {
|
if (sr.objectType == ObjectType.CITY) {
|
||||||
if (sr.relatedObject != null && sr.relatedObject instanceof BinaryMapIndexReader) {
|
if (sr.relatedObject instanceof BinaryMapIndexReader) {
|
||||||
File f = ((BinaryMapIndexReader) sr.relatedObject).getFile();
|
File f = ((BinaryMapIndexReader) sr.relatedObject).getFile();
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
RegionAddressRepository region = app.getResourceManager().getRegionRepository(f.getName());
|
RegionAddressRepository region = app.getResourceManager().getRegionRepository(f.getName());
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
app.getSettings().setLastSearchedRegion(region.getFileName(), region.getEstimatedRegionCenter());
|
|
||||||
City city = (City) sr.object;
|
City city = (City) sr.object;
|
||||||
|
String lastSearchedRegion = app.getSettings().getLastSearchedRegion();
|
||||||
|
long lastCityId = app.getSettings().getLastSearchedCity();
|
||||||
|
if (!lastSearchedRegion.equals(region.getFileName()) || city.getId() != lastCityId) {
|
||||||
|
app.getSettings().setLastSearchedRegion(region.getFileName(), region.getEstimatedRegionCenter());
|
||||||
app.getSettings().setLastSearchedCity(city.getId(), sr.localeName, city.getLocation());
|
app.getSettings().setLastSearchedCity(city.getId(), sr.localeName, city.getLocation());
|
||||||
|
updateCitiesItems();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue