Fix address selection in route preparation

This commit is contained in:
Alexey Kulish 2017-04-17 17:50:11 +03:00
parent c08484d63e
commit bc6c8d02ca
4 changed files with 66 additions and 32 deletions

View file

@ -2393,11 +2393,11 @@ Lengtegraad:\t\t%2$s</string>
<string name="clear_updates_proposition_message">Je kan gedownloade updates verwijderen en terugkeren naar de originele kaart</string> <string name="clear_updates_proposition_message">Je kan gedownloade updates verwijderen en terugkeren naar de originele kaart</string>
<string name="add_time_span">Periode toevoegen</string> <string name="add_time_span">Periode toevoegen</string>
<string name="road_blocked">Weg geblokkeerd</string> <string name="road_blocked">Weg geblokkeerd</string>
<string name="shared_string_select">Blokkeer...</string> <string name="shared_string_select">Selekteer</string>
<string name="reports_for">Verslag voor:</string> <string name="reports_for">Verslag voor:</string>
<string name="data_is_not_available">Gegevens niet beschikbaar</string> <string name="data_is_not_available">Gegevens niet beschikbaar</string>
<string name="rendering_attr_hideUnderground_name">Ondergrondse objecten</string> <string name="rendering_attr_hideUnderground_name">Ondergrondse objecten</string>
<string name="shared_string_read_more">Lees meer...</string> <string name="shared_string_read_more">Lees meer</string>
<string name="shared_string_status">Status</string> <string name="shared_string_status">Status</string>
<string name="shared_string_save_changes">Wijzigingen opslaan</string> <string name="shared_string_save_changes">Wijzigingen opslaan</string>
<string name="shared_string_email_address">E-mailadres</string> <string name="shared_string_email_address">E-mailadres</string>

View file

@ -401,10 +401,10 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os
PointDescription pointDescription = PointDescription pointDescription =
new PointDescription(currentLatLon.getLatitude(), currentLatLon.getLongitude()); new PointDescription(currentLatLon.getLatitude(), currentLatLon.getLongitude());
getMyApplication().getSettings().setMapLocationToShow(
QuickSearchListFragment.showOnMap(getMapActivity(), dialogFragment,
currentLatLon.getLatitude(), currentLatLon.getLongitude(), currentLatLon.getLatitude(), currentLatLon.getLongitude(),
15, pointDescription, true, currentLatLon); 15, pointDescription, currentLatLon);
MapActivity.launchMapActivityMoveToTop(getActivity());
dismiss(); dismiss();
} }

View file

@ -170,6 +170,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private boolean newSearch; private boolean newSearch;
private boolean interruptedSearch; private boolean interruptedSearch;
private long hideTimeMs; private long hideTimeMs;
private boolean expired;
private boolean poiFilterApplied; private boolean poiFilterApplied;
private boolean fabVisible; private boolean fabVisible;
private boolean runSearchFirstTime; private boolean runSearchFirstTime;
@ -352,7 +353,12 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} else { } else {
SearchWord word = searchPhrase.getLastSelectedWord(); SearchWord word = searchPhrase.getLastSelectedWord();
if (word != null) { if (word != null) {
if (word.getLocation() != null) { if ((searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION)
&& word.getLocation() != null) {
if (mainSearchFragment != null) {
mainSearchFragment.showResult(word.getResult());
}
} else if (word.getLocation() != null) {
SearchResult searchResult = word.getResult(); SearchResult searchResult = word.getResult();
String name = QuickSearchListItem.getName(app, searchResult); String name = QuickSearchListItem.getName(app, searchResult);
String typeName = QuickSearchListItem.getTypeName(app, searchResult); String typeName = QuickSearchListItem.getTypeName(app, searchResult);
@ -732,7 +738,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} }
public boolean isExpired() { public boolean isExpired() {
return hideTimeMs > 0 && System.currentTimeMillis() - hideTimeMs > EXPIRATION_TIME_MIN * 60 * 1000; return expired || (hideTimeMs > 0 && System.currentTimeMillis() - hideTimeMs > EXPIRATION_TIME_MIN * 60 * 1000);
} }
public void show() { public void show() {
@ -757,6 +763,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
public void hide() { public void hide() {
paused = true; paused = true;
hidden = true; hidden = true;
expired = searchType != QuickSearchType.REGULAR;
hideTimeMs = System.currentTimeMillis(); hideTimeMs = System.currentTimeMillis();
interruptedSearch = searching; interruptedSearch = searching;
searching = false; searching = false;
@ -784,10 +791,18 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (foundPartialLocation) { if (foundPartialLocation) {
buttonToolbarText.setText(app.getString(R.string.advanced_coords_search).toUpperCase()); buttonToolbarText.setText(app.getString(R.string.advanced_coords_search).toUpperCase());
} else if (searchEditText.getText().length() > 0) { } else if (searchEditText.getText().length() > 0) {
if (word != null && word.getResult() != null) { if (searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION) {
buttonToolbarText.setText(app.getString(R.string.show_something_on_map, word.getResult().localeName).toUpperCase()); if (word != null && word.getResult() != null) {
buttonToolbarText.setText(app.getString(R.string.shared_string_select).toUpperCase() + " " + word.getResult().localeName.toUpperCase());
} else {
buttonToolbarText.setText(app.getString(R.string.shared_string_select).toUpperCase());
}
} else { } else {
buttonToolbarText.setText(app.getString(R.string.shared_string_show_on_map).toUpperCase()); if (word != null && word.getResult() != null) {
buttonToolbarText.setText(app.getString(R.string.show_something_on_map, word.getResult().localeName).toUpperCase());
} else {
buttonToolbarText.setText(app.getString(R.string.shared_string_show_on_map).toUpperCase());
}
} }
} else { } else {
buttonToolbarText.setText(app.getString(R.string.shared_string_show_on_map).toUpperCase()); buttonToolbarText.setText(app.getString(R.string.shared_string_show_on_map).toUpperCase());
@ -891,6 +906,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (!useMapCenter) { if (!useMapCenter) {
startLocationUpdate(); startLocationUpdate();
} }
expired = false;
paused = false; paused = false;
} }
@ -986,7 +1002,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
searchView.setVisibility(View.GONE); searchView.setVisibility(View.GONE);
} else if (!show && tabsView.getVisibility() == View.VISIBLE) { } else if (!show && tabsView.getVisibility() == View.VISIBLE) {
tabToolbarView.setVisibility(View.GONE); tabToolbarView.setVisibility(View.GONE);
buttonToolbarView.setVisibility(searchUICore.getSearchSettings().isCustomSearch() ? View.GONE : View.VISIBLE); buttonToolbarView.setVisibility(searchUICore.getSearchSettings().isCustomSearch()
? View.GONE : View.VISIBLE);
tabsView.setVisibility(View.GONE); tabsView.setVisibility(View.GONE);
searchView.setVisibility(View.VISIBLE); searchView.setVisibility(View.VISIBLE);
} }
@ -1647,7 +1664,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
searchQuery = txt; searchQuery = txt;
searchEditText.setText(txt); searchEditText.setText(txt);
searchEditText.setSelection(txt.length()); searchEditText.setSelection(txt.length());
buttonToolbarView.setVisibility(View.VISIBLE); SearchWord lastWord = searchUICore.getPhrase().getLastSelectedWord();
boolean buttonToolbarVisible = lastWord == null || searchType == QuickSearchType.REGULAR ||
((searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION)
&& ObjectType.isAddress(lastWord.getType()));
buttonToolbarView.setVisibility(buttonToolbarVisible ? View.VISIBLE : View.GONE);
updateToolbarButton(); updateToolbarButton();
SearchSettings settings = searchUICore.getSearchSettings(); SearchSettings settings = searchUICore.getSearchSettings();
if (settings.getRadiusLevel() != 1) { if (settings.getRadiusLevel() != 1) {

View file

@ -29,6 +29,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.OsmAndListFragment; import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
import net.osmand.plus.search.listitems.QuickSearchBottomShadowListItem; import net.osmand.plus.search.listitems.QuickSearchBottomShadowListItem;
import net.osmand.plus.search.listitems.QuickSearchButtonListItem; import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.plus.search.listitems.QuickSearchListItem;
@ -165,7 +166,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
dialogFragment.onSearchListFragmentResume(this); dialogFragment.onSearchListFragmentResume(this);
} }
private void showResult(SearchResult searchResult) { public void showResult(SearchResult searchResult) {
if (searchResult.location != null) { if (searchResult.location != null) {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
String lang = searchResult.requiredSearchPhrase.getSettings().getLang(); String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
@ -207,6 +208,18 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
FavouritePoint fav = (FavouritePoint) object; FavouritePoint fav = (FavouritePoint) object;
pointDescription = fav.getPointDescription(); pointDescription = fav.getPointDescription();
break; break;
case CITY:
String cityName = searchResult.localeName;
String typeNameCity = QuickSearchListItem.getTypeName(app, searchResult);
pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeNameCity, cityName);
pointDescription.setIconName("ic_action_building_number");
break;
case STREET:
String streetName = searchResult.localeName;
String typeNameStreet = QuickSearchListItem.getTypeName(app, searchResult);
pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeNameStreet, streetName);
pointDescription.setIconName("ic_action_street_name");
break;
case HOUSE: case HOUSE:
String typeNameHouse = null; String typeNameHouse = null;
String name = searchResult.localeName; String name = searchResult.localeName;
@ -245,34 +258,34 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
dialogFragment.hideToolbar(); dialogFragment.hideToolbar();
dialogFragment.hide(); dialogFragment.hide();
showOnMap(getMapActivity(), dialogFragment,
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
searchResult.preferredZoom, pointDescription, object);
}
}
public static void showOnMap(MapActivity mapActivity, QuickSearchDialogFragment dialogFragment,
double latitude, double longitude, int zoom,
PointDescription pointDescription, Object object) {
if (mapActivity != null) {
OsmandApplication app = mapActivity.getMyApplication();
switch (dialogFragment.getSearchType()) { switch (dialogFragment.getSearchType()) {
case REGULAR: { case REGULAR: {
getMyApplication().getSettings().setMapLocationToShow( app.getSettings().setMapLocationToShow(latitude, longitude, zoom, pointDescription, true, object);
searchResult.location.getLatitude(), searchResult.location.getLongitude(), MapActivity.launchMapActivityMoveToTop(mapActivity);
searchResult.preferredZoom, pointDescription, true, object);
MapActivity.launchMapActivityMoveToTop(getActivity());
dialogFragment.reloadHistory(); dialogFragment.reloadHistory();
break; break;
} }
case START_POINT: { case START_POINT: {
MapActivity mapActivity = getMapActivity(); mapActivity.getMapLayers().getMapControlsLayer().selectAddress(
if (mapActivity != null) { pointDescription != null ? pointDescription.getName() : null,
mapActivity.getMapLayers().getMapControlsLayer().selectAddress( latitude, longitude, false);
pointDescription != null ? pointDescription.getName() : null,
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
false);
}
break; break;
} }
case DESTINATION: { case DESTINATION: {
MapActivity mapActivity = getMapActivity(); mapActivity.getMapLayers().getMapControlsLayer().selectAddress(
if (mapActivity != null) { pointDescription != null ? pointDescription.getName() : null,
mapActivity.getMapLayers().getMapControlsLayer().selectAddress( latitude, longitude, true);
pointDescription != null ? pointDescription.getName() : null,
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
true);
}
break; break;
} }
} }