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="add_time_span">Periode toevoegen</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="data_is_not_available">Gegevens niet beschikbaar</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_save_changes">Wijzigingen opslaan</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 =
new PointDescription(currentLatLon.getLatitude(), currentLatLon.getLongitude());
getMyApplication().getSettings().setMapLocationToShow(
QuickSearchListFragment.showOnMap(getMapActivity(), dialogFragment,
currentLatLon.getLatitude(), currentLatLon.getLongitude(),
15, pointDescription, true, currentLatLon);
MapActivity.launchMapActivityMoveToTop(getActivity());
15, pointDescription, currentLatLon);
dismiss();
}

View file

@ -170,6 +170,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private boolean newSearch;
private boolean interruptedSearch;
private long hideTimeMs;
private boolean expired;
private boolean poiFilterApplied;
private boolean fabVisible;
private boolean runSearchFirstTime;
@ -352,7 +353,12 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} else {
SearchWord word = searchPhrase.getLastSelectedWord();
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();
String name = QuickSearchListItem.getName(app, searchResult);
String typeName = QuickSearchListItem.getTypeName(app, searchResult);
@ -732,7 +738,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
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() {
@ -757,6 +763,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
public void hide() {
paused = true;
hidden = true;
expired = searchType != QuickSearchType.REGULAR;
hideTimeMs = System.currentTimeMillis();
interruptedSearch = searching;
searching = false;
@ -784,11 +791,19 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (foundPartialLocation) {
buttonToolbarText.setText(app.getString(R.string.advanced_coords_search).toUpperCase());
} else if (searchEditText.getText().length() > 0) {
if (searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION) {
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 {
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 {
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) {
startLocationUpdate();
}
expired = false;
paused = false;
}
@ -986,7 +1002,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
searchView.setVisibility(View.GONE);
} else if (!show && tabsView.getVisibility() == View.VISIBLE) {
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);
searchView.setVisibility(View.VISIBLE);
}
@ -1647,7 +1664,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
searchQuery = txt;
searchEditText.setText(txt);
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();
SearchSettings settings = searchUICore.getSearchSettings();
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.dashboard.DashLocationFragment;
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.QuickSearchButtonListItem;
import net.osmand.plus.search.listitems.QuickSearchListItem;
@ -165,7 +166,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
dialogFragment.onSearchListFragmentResume(this);
}
private void showResult(SearchResult searchResult) {
public void showResult(SearchResult searchResult) {
if (searchResult.location != null) {
OsmandApplication app = getMyApplication();
String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
@ -207,6 +208,18 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
FavouritePoint fav = (FavouritePoint) object;
pointDescription = fav.getPointDescription();
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:
String typeNameHouse = null;
String name = searchResult.localeName;
@ -245,34 +258,34 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
dialogFragment.hideToolbar();
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()) {
case REGULAR: {
getMyApplication().getSettings().setMapLocationToShow(
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
searchResult.preferredZoom, pointDescription, true, object);
MapActivity.launchMapActivityMoveToTop(getActivity());
app.getSettings().setMapLocationToShow(latitude, longitude, zoom, pointDescription, true, object);
MapActivity.launchMapActivityMoveToTop(mapActivity);
dialogFragment.reloadHistory();
break;
}
case START_POINT: {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMapLayers().getMapControlsLayer().selectAddress(
pointDescription != null ? pointDescription.getName() : null,
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
false);
}
latitude, longitude, false);
break;
}
case DESTINATION: {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMapLayers().getMapControlsLayer().selectAddress(
pointDescription != null ? pointDescription.getName() : null,
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
true);
}
latitude, longitude, true);
break;
}
}