Updated search history for address search

This commit is contained in:
Denis 2015-03-05 17:19:15 +02:00
parent bf73d4cc49
commit 15f061e697
3 changed files with 25 additions and 11 deletions

View file

@ -53,6 +53,14 @@ public class PointDescription {
} }
} }
public void setTypeName(String typeName){
this.typeName = typeName;
}
public void setName(String name){
this.name = name;
}
public String getTypeName() { public String getTypeName() {
return typeName; return typeName;
} }

View file

@ -82,7 +82,6 @@ public class SearchAddressFragment extends Fragment {
@Override @Override
public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) { public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
boolean light = getApplication().getSettings().isLightActionBar();
Menu menu = onCreate; Menu menu = onCreate;
int orientation = ScreenOrientationHelper.getScreenOrientation(getActivity()); int orientation = ScreenOrientationHelper.getScreenOrientation(getActivity());
boolean portrait = orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || boolean portrait = orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ||
@ -93,7 +92,6 @@ public class SearchAddressFragment extends Fragment {
} else { } else {
((SearchActivity) getActivity()).getClearToolbar(false); ((SearchActivity) getActivity()).getClearToolbar(false);
} }
light = false;
} }
if(getActivity() instanceof SearchAddressActivity) { if(getActivity() instanceof SearchAddressActivity) {
MenuItem menuItem = menu.add(0, SELECT_POINT, 0, ""); MenuItem menuItem = menu.add(0, SELECT_POINT, 0, "");
@ -353,21 +351,31 @@ public class SearchAddressFragment extends Fragment {
return; return;
} }
AddressInformation ai = new AddressInformation(); AddressInformation ai = new AddressInformation();
PointDescription pointDescription = ai.getHistoryName();
if (!Algorithms.isEmpty(street2) && !Algorithms.isEmpty(street)) { if (!Algorithms.isEmpty(street2) && !Algorithms.isEmpty(street)) {
ai = AddressInformation.build2StreetIntersection(getActivity(), osmandSettings); ai = AddressInformation.build2StreetIntersection(getActivity(), osmandSettings);
pointDescription.setName(street2);
pointDescription.setTypeName(region + ", " + city);
} else if (!Algorithms.isEmpty(building)) { } else if (!Algorithms.isEmpty(building)) {
ai = AddressInformation.buildBuilding(getActivity(), osmandSettings); ai = AddressInformation.buildBuilding(getActivity(), osmandSettings);
pointDescription.setName(street + ", " + building);
pointDescription.setTypeName(region + ", " + city);
} else if (!Algorithms.isEmpty(street)) { } else if (!Algorithms.isEmpty(street)) {
ai = AddressInformation.buildStreet(getActivity(), osmandSettings); ai = AddressInformation.buildStreet(getActivity(), osmandSettings);
pointDescription.setName(street);
pointDescription.setTypeName(region + ", " + city);
} else if(!Algorithms.isEmpty(city)) { } else if(!Algorithms.isEmpty(city)) {
ai = AddressInformation.buildCity(getActivity(), osmandSettings); ai = AddressInformation.buildCity(getActivity(), osmandSettings);
pointDescription.setName(city);
pointDescription.setTypeName(region);
} }
if(mode == ADD_TO_FAVORITE) { if(mode == ADD_TO_FAVORITE) {
Bundle b = new Bundle(); Bundle b = new Bundle();
Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b); Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b);
dlg.show(); dlg.show();
FavoriteDialogs.prepareAddFavouriteDialog(getActivity(), dlg, b, searchPoint.getLatitude(), searchPoint.getLongitude(), FavoriteDialogs.prepareAddFavouriteDialog(getActivity(), dlg, b, searchPoint.getLatitude(), searchPoint.getLongitude(),
ai.getHistoryName()); pointDescription);
} else if(mode == SELECT_POINT ){ } else if(mode == SELECT_POINT ){
Intent intent = getActivity().getIntent(); Intent intent = getActivity().getIntent();
intent.putExtra(SELECT_ADDRESS_POINT_INTENT_KEY, ai.objectName); intent.putExtra(SELECT_ADDRESS_POINT_INTENT_KEY, ai.objectName);
@ -377,11 +385,11 @@ public class SearchAddressFragment extends Fragment {
getActivity().finish(); getActivity().finish();
} else { } else {
if (mode == NAVIGATE_TO) { if (mode == NAVIGATE_TO) {
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(), searchPoint.getLongitude(), ai.getHistoryName()); DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(), searchPoint.getLongitude(), pointDescription);
} else if (mode == ADD_WAYPOINT) { } else if (mode == ADD_WAYPOINT) {
DirectionsDialogs.addWaypointDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(), searchPoint.getLongitude(), ai.getHistoryName()); DirectionsDialogs.addWaypointDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(), searchPoint.getLongitude(), pointDescription);
} else if (mode == SHOW_ON_MAP) { } else if (mode == SHOW_ON_MAP) {
osmandSettings.setMapLocationToShow(searchPoint.getLatitude(), searchPoint.getLongitude(), ai.zoom, ai.getHistoryName()); osmandSettings.setMapLocationToShow(searchPoint.getLatitude(), searchPoint.getLongitude(), ai.zoom, pointDescription);
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
} }
} }

View file

@ -11,7 +11,6 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper;
@ -20,7 +19,6 @@ import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -90,7 +88,7 @@ public class DashRecentsFragment extends DashLocationFragment {
} else { } else {
loc = new LatLon(0f, 0f); loc = new LatLon(0f, 0f);
} }
setupFavorites(); setupRecents();
} }
@Override @Override
@ -98,7 +96,7 @@ public class DashRecentsFragment extends DashLocationFragment {
super.onPause(); super.onPause();
} }
public void setupFavorites(){ public void setupRecents(){
View mainView = getView(); View mainView = getView();
SearchHistoryHelper helper = SearchHistoryHelper.getInstance((OsmandApplication) getActivity().getApplicationContext()); SearchHistoryHelper helper = SearchHistoryHelper.getInstance((OsmandApplication) getActivity().getApplicationContext());
points = helper.getHistoryEntries(); points = helper.getHistoryEntries();