This commit is contained in:
Alexey Kulish 2017-04-07 12:02:30 +03:00
parent 6f15d8b70e
commit 0141812ed8
47 changed files with 112 additions and 53 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9 KiB

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9 KiB

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9 KiB

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -97,6 +97,8 @@ import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback; import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback;
import net.osmand.plus.search.QuickSearchDialogFragment; import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapControlsLayer; import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.MapInfoLayer;
@ -1230,10 +1232,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
} }
OsmandPlugin.onMapActivityResult(requestCode, resultCode, data); OsmandPlugin.onMapActivityResult(requestCode, resultCode, data);
MapControlsLayer mcl = mapView.getLayerByClass(MapControlsLayer.class);
if (mcl != null) {
mcl.onActivityResult(requestCode, resultCode, data);
}
} }
public void refreshMap() { public void refreshMap() {
@ -1475,7 +1473,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
fragment.dismiss(); fragment.dismiss();
refreshMap(); refreshMap();
} }
QuickSearchDialogFragment.showInstance(this, "", null, true, new LatLon(latitude, longitude)); QuickSearchDialogFragment.showInstance(this, "", null,
QuickSearchType.REGULAR, QuickSearchTab.CATEGORIES, new LatLon(latitude, longitude));
} }
public void showQuickSearch(Object object) { public void showQuickSearch(Object object) {
@ -1485,22 +1484,37 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
fragment.dismiss(); fragment.dismiss();
refreshMap(); refreshMap();
} }
QuickSearchDialogFragment.showInstance(this, "", object, true, null); QuickSearchDialogFragment.showInstance(this, "", object,
QuickSearchType.REGULAR, QuickSearchTab.CATEGORIES, null);
} }
public void showQuickSearch(ShowQuickSearchMode mode, boolean showCategories) { public void showQuickSearch(ShowQuickSearchMode mode, boolean showCategories) {
hideContextMenu(); hideContextMenu();
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
if (fragment != null) { if (mode == ShowQuickSearchMode.START_POINT_SELECTION || mode == ShowQuickSearchMode.DESTINATION_SELECTION) {
if (mode == ShowQuickSearchMode.NEW || (mode == ShowQuickSearchMode.NEW_IF_EXPIRED && fragment.isExpired())) { if (fragment != null) {
fragment.dismiss(); fragment.dismiss();
QuickSearchDialogFragment.showInstance(this, "", null, showCategories, null); }
if (mode == ShowQuickSearchMode.START_POINT_SELECTION) {
QuickSearchDialogFragment.showInstance(this, "", null,
QuickSearchType.START_POINT, showCategories ? QuickSearchTab.CATEGORIES : QuickSearchTab.ADDRESS, null);
} else {
QuickSearchDialogFragment.showInstance(this, "", null,
QuickSearchType.DESTINATION, showCategories ? QuickSearchTab.CATEGORIES : QuickSearchTab.ADDRESS, null);
}
} else if (fragment != null) {
if (mode == ShowQuickSearchMode.NEW
|| (mode == ShowQuickSearchMode.NEW_IF_EXPIRED && fragment.isExpired())) {
fragment.dismiss();
QuickSearchDialogFragment.showInstance(this, "", null,
QuickSearchType.REGULAR, showCategories ? QuickSearchTab.CATEGORIES : QuickSearchTab.HISTORY, null);
} else { } else {
fragment.show(); fragment.show();
} }
refreshMap(); refreshMap();
} else { } else {
QuickSearchDialogFragment.showInstance(this, "", null, showCategories, null); QuickSearchDialogFragment.showInstance(this, "", null,
QuickSearchType.REGULAR, showCategories ? QuickSearchTab.CATEGORIES : QuickSearchTab.HISTORY, null);
} }
} }
@ -1557,6 +1571,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
NEW, NEW,
NEW_IF_EXPIRED, NEW_IF_EXPIRED,
CURRENT, CURRENT,
START_POINT_SELECTION,
DESTINATION_SELECTION,
} }
public InAppHelper execInAppTask(@NonNull InAppHelper.InAppRunnable runnable) { public InAppHelper execInAppTask(@NonNull InAppHelper.InAppRunnable runnable) {

View file

@ -4,7 +4,6 @@ import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -41,7 +40,6 @@ import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.ShowRouteInfoDialogFragment; import net.osmand.plus.activities.ShowRouteInfoDialogFragment;
import net.osmand.plus.activities.actions.AppModeDialog; import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.plus.activities.search.SearchAddressActivity;
import net.osmand.plus.dialogs.FavoriteDialogs; import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.MapMarkerDialogHelper; import net.osmand.plus.helpers.MapMarkerDialogHelper;
@ -306,10 +304,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else if (id == SPINNER_MAP_ID) { } else if (id == SPINNER_MAP_ID) {
selectOnScreen(true); selectOnScreen(true);
} else if (id == SPINNER_ADDRESS_ID) { } else if (id == SPINNER_ADDRESS_ID) {
Intent intent = new Intent(mapActivity, SearchAddressActivity.class); mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.DESTINATION_SELECTION, false);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); setupToSpinner(parentView);
intent.putExtra(TARGET_SELECT, true);
mapActivity.startActivityForResult(intent, MapControlsLayer.REQUEST_ADDRESS_SELECT);
} else if (id == SPINNER_MAP_MARKER_MORE_ID) { } else if (id == SPINNER_MAP_MARKER_MORE_ID) {
selectMapMarker(-1, true); selectMapMarker(-1, true);
setupToSpinner(parentView); setupToSpinner(parentView);
@ -378,10 +374,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else if (id == SPINNER_MAP_ID) { } else if (id == SPINNER_MAP_ID) {
selectOnScreen(false); selectOnScreen(false);
} else if (id == SPINNER_ADDRESS_ID) { } else if (id == SPINNER_ADDRESS_ID) {
Intent intent = new Intent(mapActivity, SearchAddressActivity.class); mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.START_POINT_SELECTION, false);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); setupFromSpinner(parentView);
intent.putExtra(TARGET_SELECT, false);
mapActivity.startActivityForResult(intent, MapControlsLayer.REQUEST_ADDRESS_SELECT);
} else if (id == SPINNER_MAP_MARKER_MORE_ID) { } else if (id == SPINNER_MAP_MARKER_MORE_ID) {
selectMapMarker(-1, false); selectMapMarker(-1, false);
setupFromSpinner(parentView); setupFromSpinner(parentView);

View file

@ -110,7 +110,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private static final String QUICK_SEARCH_LAT_KEY = "quick_search_lat_key"; private static final String QUICK_SEARCH_LAT_KEY = "quick_search_lat_key";
private static final String QUICK_SEARCH_LON_KEY = "quick_search_lon_key"; private static final String QUICK_SEARCH_LON_KEY = "quick_search_lon_key";
private static final String QUICK_SEARCH_INTERRUPTED_SEARCH_KEY = "quick_search_interrupted_search_key"; private static final String QUICK_SEARCH_INTERRUPTED_SEARCH_KEY = "quick_search_interrupted_search_key";
private static final String QUICK_SEARCH_SHOW_CATEGORIES_KEY = "quick_search_show_categories_key";
private static final String QUICK_SEARCH_HIDDEN_KEY = "quick_search_hidden_key"; private static final String QUICK_SEARCH_HIDDEN_KEY = "quick_search_hidden_key";
private static final String QUICK_SEARCH_TOOLBAR_TITLE_KEY = "quick_search_toolbar_title_key"; private static final String QUICK_SEARCH_TOOLBAR_TITLE_KEY = "quick_search_toolbar_title_key";
private static final String QUICK_SEARCH_TOOLBAR_VISIBLE_KEY = "quick_search_toolbar_visible_key"; private static final String QUICK_SEARCH_TOOLBAR_VISIBLE_KEY = "quick_search_toolbar_visible_key";
@ -119,6 +118,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private static final String QUICK_SEARCH_RUN_SEARCH_FIRST_TIME_KEY = "quick_search_run_search_first_time_key"; private static final String QUICK_SEARCH_RUN_SEARCH_FIRST_TIME_KEY = "quick_search_run_search_first_time_key";
private static final String QUICK_SEARCH_PHRASE_DEFINED_KEY = "quick_search_phrase_defined_key"; private static final String QUICK_SEARCH_PHRASE_DEFINED_KEY = "quick_search_phrase_defined_key";
private static final String QUICK_SEARCH_SHOW_TAB_KEY = "quick_search_show_tab_key";
private static final String QUICK_SEARCH_TYPE_KEY = "quick_search_type_key";
private Toolbar toolbar; private Toolbar toolbar;
private LockableViewPager viewPager; private LockableViewPager viewPager;
private SearchFragmentPagerAdapter pagerAdapter; private SearchFragmentPagerAdapter pagerAdapter;
@ -176,9 +178,22 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private boolean citiesLoaded; private boolean citiesLoaded;
private LatLon storedOriginalLocation; private LatLon storedOriginalLocation;
private QuickSearchType searchType = QuickSearchType.REGULAR;
private static final double DISTANCE_THRESHOLD = 70000; // 70km private static final double DISTANCE_THRESHOLD = 70000; // 70km
private static final int EXPIRATION_TIME_MIN = 10; // 10 minutes private static final int EXPIRATION_TIME_MIN = 10; // 10 minutes
public enum QuickSearchTab {
HISTORY,
CATEGORIES,
ADDRESS,
}
public enum QuickSearchType {
REGULAR,
START_POINT,
DESTINATION,
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -220,6 +235,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
Bundle arguments = getArguments(); Bundle arguments = getArguments();
if (savedInstanceState != null) { if (savedInstanceState != null) {
searchType = QuickSearchType.valueOf(savedInstanceState.getString(QUICK_SEARCH_TYPE_KEY, QuickSearchType.REGULAR.name()));
searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY); searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY);
double lat = savedInstanceState.getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN); double lat = savedInstanceState.getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN);
double lon = savedInstanceState.getDouble(QUICK_SEARCH_LON_KEY, Double.NaN); double lon = savedInstanceState.getDouble(QUICK_SEARCH_LON_KEY, Double.NaN);
@ -233,6 +249,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
fabVisible = savedInstanceState.getBoolean(QUICK_SEARCH_FAB_VISIBLE_KEY, false); fabVisible = savedInstanceState.getBoolean(QUICK_SEARCH_FAB_VISIBLE_KEY, false);
} }
if (searchQuery == null && arguments != null) { if (searchQuery == null && arguments != null) {
searchType = QuickSearchType.valueOf(arguments.getString(QUICK_SEARCH_TYPE_KEY, QuickSearchType.REGULAR.name()));
searchQuery = arguments.getString(QUICK_SEARCH_QUERY_KEY); searchQuery = arguments.getString(QUICK_SEARCH_QUERY_KEY);
runSearchFirstTime = arguments.getBoolean(QUICK_SEARCH_RUN_SEARCH_FIRST_TIME_KEY, false); runSearchFirstTime = arguments.getBoolean(QUICK_SEARCH_RUN_SEARCH_FIRST_TIME_KEY, false);
phraseDefined = arguments.getBoolean(QUICK_SEARCH_PHRASE_DEFINED_KEY, false); phraseDefined = arguments.getBoolean(QUICK_SEARCH_PHRASE_DEFINED_KEY, false);
@ -246,9 +263,12 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (searchQuery == null) if (searchQuery == null)
searchQuery = ""; searchQuery = "";
boolean showCategories = false; QuickSearchTab showSearchTab = QuickSearchTab.HISTORY;
if (arguments != null) { if (arguments != null) {
showCategories = arguments.getBoolean(QUICK_SEARCH_SHOW_CATEGORIES_KEY, false); showSearchTab = QuickSearchTab.valueOf(arguments.getString(QUICK_SEARCH_SHOW_TAB_KEY, QuickSearchTab.HISTORY.name()));
}
if (showSearchTab == QuickSearchTab.ADDRESS) {
addressSearch = true;
} }
tabToolbarView = view.findViewById(R.id.tab_toolbar_layout); tabToolbarView = view.findViewById(R.id.tab_toolbar_layout);
@ -462,8 +482,16 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
viewPager.setOffscreenPageLimit(2); viewPager.setOffscreenPageLimit(2);
pagerAdapter = new SearchFragmentPagerAdapter(getChildFragmentManager(), getResources()); pagerAdapter = new SearchFragmentPagerAdapter(getChildFragmentManager(), getResources());
viewPager.setAdapter(pagerAdapter); viewPager.setAdapter(pagerAdapter);
if (centerLatLon != null || showCategories) { switch (showSearchTab) {
viewPager.setCurrentItem(1); case HISTORY:
viewPager.setCurrentItem(0);
break;
case CATEGORIES:
viewPager.setCurrentItem(1);
break;
case ADDRESS:
viewPager.setCurrentItem(2);
break;
} }
tabLayout = (TabLayout) view.findViewById(R.id.tab_layout); tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
@ -677,6 +705,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
getMapActivity().hideTopToolbar(toolbarController); getMapActivity().hideTopToolbar(toolbarController);
} }
public QuickSearchType getSearchType() {
return searchType;
}
public String getText() { public String getText() {
return searchEditText.getText().toString(); return searchEditText.getText().toString();
} }
@ -838,6 +870,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
outState.putString(QUICK_SEARCH_TYPE_KEY, searchType.name());
outState.putString(QUICK_SEARCH_QUERY_KEY, searchQuery); outState.putString(QUICK_SEARCH_QUERY_KEY, searchQuery);
outState.putBoolean(QUICK_SEARCH_INTERRUPTED_SEARCH_KEY, interruptedSearch = searching); outState.putBoolean(QUICK_SEARCH_INTERRUPTED_SEARCH_KEY, interruptedSearch = searching);
outState.putBoolean(QUICK_SEARCH_HIDDEN_KEY, hidden); outState.putBoolean(QUICK_SEARCH_HIDDEN_KEY, hidden);
@ -985,6 +1018,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
case ADDRESS: case ADDRESS:
addressSearchFragment = (QuickSearchAddressListFragment) searchListFragment; addressSearchFragment = (QuickSearchAddressListFragment) searchListFragment;
if (addressSearch && !citiesLoaded) {
reloadCities();
}
break; break;
case MAIN: case MAIN:
@ -1672,7 +1708,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
public static boolean showInstance(@NonNull MapActivity mapActivity, public static boolean showInstance(@NonNull MapActivity mapActivity,
@NonNull String searchQuery, @NonNull String searchQuery,
@Nullable Object object, @Nullable Object object,
boolean showCategories, QuickSearchType searchType,
QuickSearchTab showSearchTab,
@Nullable LatLon latLon) { @Nullable LatLon latLon) {
try { try {
@ -1710,7 +1747,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} }
bundle.putString(QUICK_SEARCH_QUERY_KEY, searchQuery); bundle.putString(QUICK_SEARCH_QUERY_KEY, searchQuery);
bundle.putBoolean(QUICK_SEARCH_SHOW_CATEGORIES_KEY, showCategories); bundle.putString(QUICK_SEARCH_SHOW_TAB_KEY, showSearchTab.name());
bundle.putString(QUICK_SEARCH_TYPE_KEY, searchType.name());
if (latLon != null) { if (latLon != null) {
bundle.putDouble(QUICK_SEARCH_LAT_KEY, latLon.getLatitude()); bundle.putDouble(QUICK_SEARCH_LAT_KEY, latLon.getLatitude());
bundle.putDouble(QUICK_SEARCH_LON_KEY, latLon.getLongitude()); bundle.putDouble(QUICK_SEARCH_LON_KEY, latLon.getLongitude());

View file

@ -80,10 +80,6 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
} }
} }
}); });
//View header = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_header, null);
//View footer = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_footer, null);
//listView.addHeaderView(header, null, false);
//listView.addFooterView(footer, null, false);
} }
} }
@ -108,7 +104,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|| sr.objectType == ObjectType.WPT || sr.objectType == ObjectType.WPT
|| sr.objectType == ObjectType.STREET_INTERSECTION) { || sr.objectType == ObjectType.STREET_INTERSECTION) {
showOnMap(sr); showResult(sr);
} else { } else {
dialogFragment.completeQueryWithObject(item.getSearchResult()); dialogFragment.completeQueryWithObject(item.getSearchResult());
} }
@ -169,7 +165,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
dialogFragment.onSearchListFragmentResume(this); dialogFragment.onSearchListFragmentResume(this);
} }
private void showOnMap(SearchResult searchResult) { private 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();
@ -249,12 +245,37 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
dialogFragment.hideToolbar(); dialogFragment.hideToolbar();
dialogFragment.hide(); dialogFragment.hide();
getMyApplication().getSettings().setMapLocationToShow( switch (dialogFragment.getSearchType()) {
searchResult.location.getLatitude(), searchResult.location.getLongitude(), case REGULAR: {
searchResult.preferredZoom, pointDescription, true, object); getMyApplication().getSettings().setMapLocationToShow(
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
searchResult.preferredZoom, pointDescription, true, object);
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
dialogFragment.reloadHistory(); 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);
}
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);
}
break;
}
}
} }
} }

View file

@ -3,7 +3,6 @@ package net.osmand.plus.views;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
@ -43,7 +42,6 @@ import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode; import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
import net.osmand.plus.activities.search.SearchAddressFragment;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
@ -60,7 +58,6 @@ import gnu.trove.list.array.TIntArrayList;
public class MapControlsLayer extends OsmandMapLayer { public class MapControlsLayer extends OsmandMapLayer {
private static final int TIMEOUT_TO_SHOW_BUTTONS = 7000; private static final int TIMEOUT_TO_SHOW_BUTTONS = 7000;
public static final int REQUEST_ADDRESS_SELECT = 2;
private static final int REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION = 200; private static final int REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION = 200;
private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201; private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201;
private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202; private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202;
@ -1173,18 +1170,11 @@ public class MapControlsLayer extends OsmandMapLayer {
}; };
} }
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void selectAddress(String name, double latitude, double longitude, boolean target) {
if (requestCode == REQUEST_ADDRESS_SELECT && resultCode == SearchAddressFragment.SELECT_ADDRESS_POINT_RESULT_OK) { if (name != null) {
String name = data.getStringExtra(SearchAddressFragment.SELECT_ADDRESS_POINT_INTENT_KEY); mapRouteInfoMenu.selectAddress(name, new LatLon(latitude, longitude), target);
boolean target = data.getBooleanExtra(MapRouteInfoMenu.TARGET_SELECT, true); } else {
LatLon latLon = new LatLon( mapRouteInfoMenu.selectAddress("", new LatLon(latitude, longitude), target);
data.getDoubleExtra(SearchAddressFragment.SELECT_ADDRESS_POINT_LAT, 0),
data.getDoubleExtra(SearchAddressFragment.SELECT_ADDRESS_POINT_LON, 0));
if (name != null) {
mapRouteInfoMenu.selectAddress(name, latLon, target);
} else {
mapRouteInfoMenu.selectAddress("", latLon, target);
}
} }
} }