diff --git a/OsmAnd/res/drawable-large-hdpi/map_bicycle_bearing.png b/OsmAnd/res/drawable-large-hdpi/map_bicycle_bearing.png index 14f84d600e..4ae946f120 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_bicycle_bearing.png and b/OsmAnd/res/drawable-large-hdpi/map_bicycle_bearing.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_bicycle_bearing_night.png b/OsmAnd/res/drawable-large-hdpi/map_bicycle_bearing_night.png index 14f84d600e..db4067d686 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_bicycle_bearing_night.png and b/OsmAnd/res/drawable-large-hdpi/map_bicycle_bearing_night.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_bicycle_location_view_angle.png b/OsmAnd/res/drawable-large-hdpi/map_bicycle_location_view_angle.png index 23474b2aec..438e79b7d2 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_bicycle_location_view_angle.png and b/OsmAnd/res/drawable-large-hdpi/map_bicycle_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_bicycle_location_view_angle_night.png b/OsmAnd/res/drawable-large-hdpi/map_bicycle_location_view_angle_night.png index 3577d4460f..cc9d043ada 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_bicycle_location_view_angle_night.png and b/OsmAnd/res/drawable-large-hdpi/map_bicycle_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_car_bearing.png b/OsmAnd/res/drawable-large-hdpi/map_car_bearing.png index 8a1b6caf06..ec0255883c 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_car_bearing.png and b/OsmAnd/res/drawable-large-hdpi/map_car_bearing.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_car_bearing_night.png b/OsmAnd/res/drawable-large-hdpi/map_car_bearing_night.png index 05a7c55ed7..5254993ee9 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_car_bearing_night.png and b/OsmAnd/res/drawable-large-hdpi/map_car_bearing_night.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_car_location_view_angle.png b/OsmAnd/res/drawable-large-hdpi/map_car_location_view_angle.png index 4287aaa9e0..cf59821c0d 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_car_location_view_angle.png and b/OsmAnd/res/drawable-large-hdpi/map_car_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_car_location_view_angle_night.png b/OsmAnd/res/drawable-large-hdpi/map_car_location_view_angle_night.png index 52ef6e7e45..65f4e655c9 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_car_location_view_angle_night.png and b/OsmAnd/res/drawable-large-hdpi/map_car_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_default_location_view_angle.png b/OsmAnd/res/drawable-large-hdpi/map_default_location_view_angle.png index f6cabb22ca..2a07f316b2 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_default_location_view_angle.png and b/OsmAnd/res/drawable-large-hdpi/map_default_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_default_location_view_angle_night.png b/OsmAnd/res/drawable-large-hdpi/map_default_location_view_angle_night.png index 53396b9d75..9ed2f18387 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_default_location_view_angle_night.png and b/OsmAnd/res/drawable-large-hdpi/map_default_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_pedestrian_bearing.png b/OsmAnd/res/drawable-large-hdpi/map_pedestrian_bearing.png index b1ecd3e73c..37b064a8b7 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_pedestrian_bearing.png and b/OsmAnd/res/drawable-large-hdpi/map_pedestrian_bearing.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_pedestrian_bearing_night.png b/OsmAnd/res/drawable-large-hdpi/map_pedestrian_bearing_night.png index b1ecd3e73c..37fba19f8b 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_pedestrian_bearing_night.png and b/OsmAnd/res/drawable-large-hdpi/map_pedestrian_bearing_night.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_pedestrian_location_view_angle.png b/OsmAnd/res/drawable-large-hdpi/map_pedestrian_location_view_angle.png index 1e2b927b2c..b448d1c0d6 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_pedestrian_location_view_angle.png and b/OsmAnd/res/drawable-large-hdpi/map_pedestrian_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large-hdpi/map_pedestrian_location_view_angle_night.png b/OsmAnd/res/drawable-large-hdpi/map_pedestrian_location_view_angle_night.png index 8008d9e9a3..e433ed7e0b 100644 Binary files a/OsmAnd/res/drawable-large-hdpi/map_pedestrian_location_view_angle_night.png and b/OsmAnd/res/drawable-large-hdpi/map_pedestrian_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_bicycle_bearing.png b/OsmAnd/res/drawable-large-xhdpi/map_bicycle_bearing.png index 146386f060..a7d11cd28d 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_bicycle_bearing.png and b/OsmAnd/res/drawable-large-xhdpi/map_bicycle_bearing.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_bicycle_bearing_night.png b/OsmAnd/res/drawable-large-xhdpi/map_bicycle_bearing_night.png index d29cb35643..d20656fced 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_bicycle_bearing_night.png and b/OsmAnd/res/drawable-large-xhdpi/map_bicycle_bearing_night.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_bicycle_location_view_angle.png b/OsmAnd/res/drawable-large-xhdpi/map_bicycle_location_view_angle.png index d3d1fb392c..4b4e3440d1 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_bicycle_location_view_angle.png and b/OsmAnd/res/drawable-large-xhdpi/map_bicycle_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_bicycle_location_view_angle_night.png b/OsmAnd/res/drawable-large-xhdpi/map_bicycle_location_view_angle_night.png index c976173ed5..c3e2a1d2f7 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_bicycle_location_view_angle_night.png and b/OsmAnd/res/drawable-large-xhdpi/map_bicycle_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_car_bearing.png b/OsmAnd/res/drawable-large-xhdpi/map_car_bearing.png index de74ec55f6..c89f205923 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_car_bearing.png and b/OsmAnd/res/drawable-large-xhdpi/map_car_bearing.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_car_bearing_night.png b/OsmAnd/res/drawable-large-xhdpi/map_car_bearing_night.png index 95fe028890..6a57c27d92 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_car_bearing_night.png and b/OsmAnd/res/drawable-large-xhdpi/map_car_bearing_night.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_car_location_view_angle.png b/OsmAnd/res/drawable-large-xhdpi/map_car_location_view_angle.png index bdf31a4b89..7958970b06 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_car_location_view_angle.png and b/OsmAnd/res/drawable-large-xhdpi/map_car_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_car_location_view_angle_night.png b/OsmAnd/res/drawable-large-xhdpi/map_car_location_view_angle_night.png index 0da194afc6..3eb0592c29 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_car_location_view_angle_night.png and b/OsmAnd/res/drawable-large-xhdpi/map_car_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_default_location_view_angle.png b/OsmAnd/res/drawable-large-xhdpi/map_default_location_view_angle.png index ad5a7b0a90..2020edc07e 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_default_location_view_angle.png and b/OsmAnd/res/drawable-large-xhdpi/map_default_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_default_location_view_angle_night.png b/OsmAnd/res/drawable-large-xhdpi/map_default_location_view_angle_night.png index baac37cced..165f484907 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_default_location_view_angle_night.png and b/OsmAnd/res/drawable-large-xhdpi/map_default_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_bearing.png b/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_bearing.png index 0bc11d8efa..812436c026 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_bearing.png and b/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_bearing.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_bearing_night.png b/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_bearing_night.png index 300730c6bc..9ec8b8e195 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_bearing_night.png and b/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_bearing_night.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_location_view_angle.png b/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_location_view_angle.png index 9a214d49af..304d21fe3d 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_location_view_angle.png and b/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_location_view_angle_night.png b/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_location_view_angle_night.png index cf5944b83b..615088cf0a 100644 Binary files a/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_location_view_angle_night.png and b/OsmAnd/res/drawable-large-xhdpi/map_pedestrian_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large/map_bicycle_bearing.png b/OsmAnd/res/drawable-large/map_bicycle_bearing.png index a3d3c4f7bc..4a3ea967ad 100644 Binary files a/OsmAnd/res/drawable-large/map_bicycle_bearing.png and b/OsmAnd/res/drawable-large/map_bicycle_bearing.png differ diff --git a/OsmAnd/res/drawable-large/map_bicycle_bearing_night.png b/OsmAnd/res/drawable-large/map_bicycle_bearing_night.png index 7272338ff5..aa15798537 100644 Binary files a/OsmAnd/res/drawable-large/map_bicycle_bearing_night.png and b/OsmAnd/res/drawable-large/map_bicycle_bearing_night.png differ diff --git a/OsmAnd/res/drawable-large/map_bicycle_location_view_angle.png b/OsmAnd/res/drawable-large/map_bicycle_location_view_angle.png index afe8d0494a..9db72d533a 100644 Binary files a/OsmAnd/res/drawable-large/map_bicycle_location_view_angle.png and b/OsmAnd/res/drawable-large/map_bicycle_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large/map_bicycle_location_view_angle_night.png b/OsmAnd/res/drawable-large/map_bicycle_location_view_angle_night.png index 3b4e4d2fcb..a3bcf1a835 100644 Binary files a/OsmAnd/res/drawable-large/map_bicycle_location_view_angle_night.png and b/OsmAnd/res/drawable-large/map_bicycle_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large/map_car_bearing.png b/OsmAnd/res/drawable-large/map_car_bearing.png index d61f2b27e8..9cb7a8bdeb 100644 Binary files a/OsmAnd/res/drawable-large/map_car_bearing.png and b/OsmAnd/res/drawable-large/map_car_bearing.png differ diff --git a/OsmAnd/res/drawable-large/map_car_bearing_night.png b/OsmAnd/res/drawable-large/map_car_bearing_night.png index 788f60274d..4a1f583170 100644 Binary files a/OsmAnd/res/drawable-large/map_car_bearing_night.png and b/OsmAnd/res/drawable-large/map_car_bearing_night.png differ diff --git a/OsmAnd/res/drawable-large/map_car_location_view_angle.png b/OsmAnd/res/drawable-large/map_car_location_view_angle.png index 84fae72191..c949d7145f 100644 Binary files a/OsmAnd/res/drawable-large/map_car_location_view_angle.png and b/OsmAnd/res/drawable-large/map_car_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large/map_car_location_view_angle_night.png b/OsmAnd/res/drawable-large/map_car_location_view_angle_night.png index 2f162d6252..bae7aa9e95 100644 Binary files a/OsmAnd/res/drawable-large/map_car_location_view_angle_night.png and b/OsmAnd/res/drawable-large/map_car_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large/map_default_location_view_angle.png b/OsmAnd/res/drawable-large/map_default_location_view_angle.png index bab866ae74..f47ba42f86 100644 Binary files a/OsmAnd/res/drawable-large/map_default_location_view_angle.png and b/OsmAnd/res/drawable-large/map_default_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large/map_default_location_view_angle_night.png b/OsmAnd/res/drawable-large/map_default_location_view_angle_night.png index c70b2bd56c..f852001c23 100644 Binary files a/OsmAnd/res/drawable-large/map_default_location_view_angle_night.png and b/OsmAnd/res/drawable-large/map_default_location_view_angle_night.png differ diff --git a/OsmAnd/res/drawable-large/map_pedestrian_bearing.png b/OsmAnd/res/drawable-large/map_pedestrian_bearing.png index 5029658e23..de606621f1 100644 Binary files a/OsmAnd/res/drawable-large/map_pedestrian_bearing.png and b/OsmAnd/res/drawable-large/map_pedestrian_bearing.png differ diff --git a/OsmAnd/res/drawable-large/map_pedestrian_bearing_night.png b/OsmAnd/res/drawable-large/map_pedestrian_bearing_night.png index 5f3531dd04..35dfdc4cbc 100644 Binary files a/OsmAnd/res/drawable-large/map_pedestrian_bearing_night.png and b/OsmAnd/res/drawable-large/map_pedestrian_bearing_night.png differ diff --git a/OsmAnd/res/drawable-large/map_pedestrian_location_view_angle.png b/OsmAnd/res/drawable-large/map_pedestrian_location_view_angle.png index 5b4bb59c0c..a97d40ba4f 100644 Binary files a/OsmAnd/res/drawable-large/map_pedestrian_location_view_angle.png and b/OsmAnd/res/drawable-large/map_pedestrian_location_view_angle.png differ diff --git a/OsmAnd/res/drawable-large/map_pedestrian_location_view_angle_night.png b/OsmAnd/res/drawable-large/map_pedestrian_location_view_angle_night.png index f14b62edf2..24175e4361 100644 Binary files a/OsmAnd/res/drawable-large/map_pedestrian_location_view_angle_night.png and b/OsmAnd/res/drawable-large/map_pedestrian_location_view_angle_night.png differ diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 411f6b2e6c..8e2713d528 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -97,6 +97,8 @@ import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback; 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.MapControlsLayer; import net.osmand.plus.views.MapInfoLayer; @@ -1230,10 +1232,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } } OsmandPlugin.onMapActivityResult(requestCode, resultCode, data); - MapControlsLayer mcl = mapView.getLayerByClass(MapControlsLayer.class); - if (mcl != null) { - mcl.onActivityResult(requestCode, resultCode, data); - } } public void refreshMap() { @@ -1475,7 +1473,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven fragment.dismiss(); 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) { @@ -1485,22 +1484,37 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven fragment.dismiss(); refreshMap(); } - QuickSearchDialogFragment.showInstance(this, "", object, true, null); + QuickSearchDialogFragment.showInstance(this, "", object, + QuickSearchType.REGULAR, QuickSearchTab.CATEGORIES, null); } public void showQuickSearch(ShowQuickSearchMode mode, boolean showCategories) { hideContextMenu(); QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); - if (fragment != null) { - if (mode == ShowQuickSearchMode.NEW || (mode == ShowQuickSearchMode.NEW_IF_EXPIRED && fragment.isExpired())) { + if (mode == ShowQuickSearchMode.START_POINT_SELECTION || mode == ShowQuickSearchMode.DESTINATION_SELECTION) { + if (fragment != null) { 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 { fragment.show(); } refreshMap(); } 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_IF_EXPIRED, CURRENT, + START_POINT_SELECTION, + DESTINATION_SELECTION, } public InAppHelper execInAppTask(@NonNull InAppHelper.InAppRunnable runnable) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java index 94c54eddbc..be2a143eb0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java @@ -4,7 +4,6 @@ import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; -import android.content.Intent; import android.graphics.PointF; import android.graphics.drawable.Drawable; 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.ShowRouteInfoDialogFragment; import net.osmand.plus.activities.actions.AppModeDialog; -import net.osmand.plus.activities.search.SearchAddressActivity; import net.osmand.plus.dialogs.FavoriteDialogs; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.MapMarkerDialogHelper; @@ -306,10 +304,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } else if (id == SPINNER_MAP_ID) { selectOnScreen(true); } else if (id == SPINNER_ADDRESS_ID) { - Intent intent = new Intent(mapActivity, SearchAddressActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - intent.putExtra(TARGET_SELECT, true); - mapActivity.startActivityForResult(intent, MapControlsLayer.REQUEST_ADDRESS_SELECT); + mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.DESTINATION_SELECTION, false); + setupToSpinner(parentView); } else if (id == SPINNER_MAP_MARKER_MORE_ID) { selectMapMarker(-1, true); setupToSpinner(parentView); @@ -378,10 +374,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } else if (id == SPINNER_MAP_ID) { selectOnScreen(false); } else if (id == SPINNER_ADDRESS_ID) { - Intent intent = new Intent(mapActivity, SearchAddressActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - intent.putExtra(TARGET_SELECT, false); - mapActivity.startActivityForResult(intent, MapControlsLayer.REQUEST_ADDRESS_SELECT); + mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.START_POINT_SELECTION, false); + setupFromSpinner(parentView); } else if (id == SPINNER_MAP_MARKER_MORE_ID) { selectMapMarker(-1, false); setupFromSpinner(parentView); diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 6e21fa0597..32026106bd 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -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_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_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_TOOLBAR_TITLE_KEY = "quick_search_toolbar_title_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_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 LockableViewPager viewPager; private SearchFragmentPagerAdapter pagerAdapter; @@ -176,9 +178,22 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC private boolean citiesLoaded; private LatLon storedOriginalLocation; + private QuickSearchType searchType = QuickSearchType.REGULAR; + private static final double DISTANCE_THRESHOLD = 70000; // 70km private static final int EXPIRATION_TIME_MIN = 10; // 10 minutes + public enum QuickSearchTab { + HISTORY, + CATEGORIES, + ADDRESS, + } + + public enum QuickSearchType { + REGULAR, + START_POINT, + DESTINATION, + } @Override public void onCreate(Bundle savedInstanceState) { @@ -220,6 +235,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC Bundle arguments = getArguments(); if (savedInstanceState != null) { + searchType = QuickSearchType.valueOf(savedInstanceState.getString(QUICK_SEARCH_TYPE_KEY, QuickSearchType.REGULAR.name())); searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY); double lat = savedInstanceState.getDouble(QUICK_SEARCH_LAT_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); } if (searchQuery == null && arguments != null) { + searchType = QuickSearchType.valueOf(arguments.getString(QUICK_SEARCH_TYPE_KEY, QuickSearchType.REGULAR.name())); searchQuery = arguments.getString(QUICK_SEARCH_QUERY_KEY); runSearchFirstTime = arguments.getBoolean(QUICK_SEARCH_RUN_SEARCH_FIRST_TIME_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) searchQuery = ""; - boolean showCategories = false; + QuickSearchTab showSearchTab = QuickSearchTab.HISTORY; 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); @@ -462,8 +482,16 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC viewPager.setOffscreenPageLimit(2); pagerAdapter = new SearchFragmentPagerAdapter(getChildFragmentManager(), getResources()); viewPager.setAdapter(pagerAdapter); - if (centerLatLon != null || showCategories) { - viewPager.setCurrentItem(1); + switch (showSearchTab) { + 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); @@ -677,6 +705,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC getMapActivity().hideTopToolbar(toolbarController); } + public QuickSearchType getSearchType() { + return searchType; + } + public String getText() { return searchEditText.getText().toString(); } @@ -838,6 +870,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC @Override public void onSaveInstanceState(Bundle outState) { + outState.putString(QUICK_SEARCH_TYPE_KEY, searchType.name()); outState.putString(QUICK_SEARCH_QUERY_KEY, searchQuery); outState.putBoolean(QUICK_SEARCH_INTERRUPTED_SEARCH_KEY, interruptedSearch = searching); outState.putBoolean(QUICK_SEARCH_HIDDEN_KEY, hidden); @@ -985,6 +1018,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC case ADDRESS: addressSearchFragment = (QuickSearchAddressListFragment) searchListFragment; + if (addressSearch && !citiesLoaded) { + reloadCities(); + } break; case MAIN: @@ -1672,7 +1708,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull String searchQuery, @Nullable Object object, - boolean showCategories, + QuickSearchType searchType, + QuickSearchTab showSearchTab, @Nullable LatLon latLon) { try { @@ -1710,7 +1747,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC } 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) { bundle.putDouble(QUICK_SEARCH_LAT_KEY, latLon.getLatitude()); bundle.putDouble(QUICK_SEARCH_LON_KEY, latLon.getLongitude()); diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java index c8465e9938..7721f88a24 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java @@ -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.STREET_INTERSECTION) { - showOnMap(sr); + showResult(sr); } else { dialogFragment.completeQueryWithObject(item.getSearchResult()); } @@ -169,7 +165,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { dialogFragment.onSearchListFragmentResume(this); } - private void showOnMap(SearchResult searchResult) { + private void showResult(SearchResult searchResult) { if (searchResult.location != null) { OsmandApplication app = getMyApplication(); String lang = searchResult.requiredSearchPhrase.getSettings().getLang(); @@ -249,12 +245,37 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { dialogFragment.hideToolbar(); dialogFragment.hide(); - getMyApplication().getSettings().setMapLocationToShow( - searchResult.location.getLatitude(), searchResult.location.getLongitude(), - searchResult.preferredZoom, pointDescription, true, object); + switch (dialogFragment.getSearchType()) { + case REGULAR: { + getMyApplication().getSettings().setMapLocationToShow( + searchResult.location.getLatitude(), searchResult.location.getLongitude(), + searchResult.preferredZoom, pointDescription, true, object); - MapActivity.launchMapActivityMoveToTop(getActivity()); - dialogFragment.reloadHistory(); + MapActivity.launchMapActivityMoveToTop(getActivity()); + 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; + } + } } } diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 06af5a3501..bb45b710d3 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -3,7 +3,6 @@ package net.osmand.plus.views; import android.Manifest; import android.annotation.SuppressLint; import android.content.DialogInterface; -import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Canvas; import android.graphics.Color; @@ -43,7 +42,6 @@ import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.activities.MapActivity; 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.dialogs.DirectionsDialogs; import net.osmand.plus.mapcontextmenu.MapContextMenu; @@ -60,7 +58,6 @@ import gnu.trove.list.array.TIntArrayList; public class MapControlsLayer extends OsmandMapLayer { 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_FAB_PERMISSION = 201; 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) { - if (requestCode == REQUEST_ADDRESS_SELECT && resultCode == SearchAddressFragment.SELECT_ADDRESS_POINT_RESULT_OK) { - String name = data.getStringExtra(SearchAddressFragment.SELECT_ADDRESS_POINT_INTENT_KEY); - boolean target = data.getBooleanExtra(MapRouteInfoMenu.TARGET_SELECT, true); - LatLon latLon = new LatLon( - 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); - } + public void selectAddress(String name, double latitude, double longitude, boolean target) { + if (name != null) { + mapRouteInfoMenu.selectAddress(name, new LatLon(latitude, longitude), target); + } else { + mapRouteInfoMenu.selectAddress("", new LatLon(latitude, longitude), target); } }