diff --git a/OsmAnd/res/layout/bottom_sheet_double_item.xml b/OsmAnd/res/layout/bottom_sheet_double_item.xml
new file mode 100644
index 0000000000..af9d8a73fe
--- /dev/null
+++ b/OsmAnd/res/layout/bottom_sheet_double_item.xml
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_item_simple_56dp.xml b/OsmAnd/res/layout/bottom_sheet_item_simple_56dp.xml
index 37fb953b5c..7d8028b8a0 100644
--- a/OsmAnd/res/layout/bottom_sheet_item_simple_56dp.xml
+++ b/OsmAnd/res/layout/bottom_sheet_item_simple_56dp.xml
@@ -19,7 +19,7 @@
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_info_dark"/>
-
-
+ Swap start and destination
+ Add destination
+ Add intermediate
+ Add Start point
Intermediate point: %1$s
Waypoints: %1$s
transfers: %1$s
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index 817658b847..36b2495034 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -1874,6 +1874,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
showQuickSearch(mode, showCategories, "", null);
}
+ public void showQuickSearch(ShowQuickSearchMode mode, QuickSearchTab showSearchTab) {
+ showQuickSearch(mode, showSearchTab, "", null);
+ }
+
public void showQuickSearch(@NonNull ShowQuickSearchMode mode, boolean showCategories,
@NonNull String searchQuery, @Nullable LatLon searchLocation) {
if (mode == ShowQuickSearchMode.CURRENT) {
@@ -1916,6 +1920,48 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
}
+ public void showQuickSearch(@NonNull ShowQuickSearchMode mode, QuickSearchTab showSearchTab,
+ @NonNull String searchQuery, @Nullable LatLon searchLocation) {
+ if (mode == ShowQuickSearchMode.CURRENT) {
+ mapContextMenu.close();
+ } else {
+ hideContextMenu();
+ }
+ QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
+ if (mode == ShowQuickSearchMode.START_POINT_SELECTION || mode == ShowQuickSearchMode.DESTINATION_SELECTION
+ || mode == ShowQuickSearchMode.DESTINATION_SELECTION_AND_START || mode == ShowQuickSearchMode.INTERMEDIATE_SELECTION) {
+ if (fragment != null) {
+ fragment.dismiss();
+ }
+ if (mode == ShowQuickSearchMode.INTERMEDIATE_SELECTION) {
+ QuickSearchDialogFragment.showInstance(this, searchQuery, null,
+ QuickSearchType.INTERMEDIATE, showSearchTab, searchLocation);
+ } else if (mode == ShowQuickSearchMode.START_POINT_SELECTION) {
+ QuickSearchDialogFragment.showInstance(this, searchQuery, null,
+ QuickSearchType.START_POINT, showSearchTab, searchLocation);
+ } else if (mode == ShowQuickSearchMode.DESTINATION_SELECTION) {
+ QuickSearchDialogFragment.showInstance(this, searchQuery, null,
+ QuickSearchType.DESTINATION, showSearchTab, searchLocation);
+ } else {
+ QuickSearchDialogFragment.showInstance(this, searchQuery, null,
+ QuickSearchType.DESTINATION_AND_START, showSearchTab, searchLocation);
+ }
+ } else if (fragment != null) {
+ if (mode == ShowQuickSearchMode.NEW
+ || (mode == ShowQuickSearchMode.NEW_IF_EXPIRED && fragment.isExpired())) {
+ fragment.dismiss();
+ QuickSearchDialogFragment.showInstance(this, searchQuery, null,
+ QuickSearchType.REGULAR, showSearchTab, searchLocation);
+ } else {
+ fragment.show();
+ }
+ refreshMap();
+ } else {
+ QuickSearchDialogFragment.showInstance(this, searchQuery, null,
+ QuickSearchType.REGULAR, showSearchTab, searchLocation);
+ }
+ }
+
private void hideContextMenu() {
if (mapContextMenu.isVisible()) {
mapContextMenu.hide();
diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java
index 0e15a70874..4127b85184 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java
@@ -498,7 +498,7 @@ public class WaypointDialogHelper {
}
// switch start & finish
- private static void switchStartAndFinish(TargetPointsHelper targetPointsHelper, TargetPoint finish,
+ public static void switchStartAndFinish(TargetPointsHelper targetPointsHelper, TargetPoint finish,
Activity ctx, TargetPoint start, OsmandApplication app,
WaypointDialogHelper helper) {
targetPointsHelper.setStartPoint(new LatLon(finish.getLatitude(),
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java
index 8062e08019..ba0058df81 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java
@@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu.other;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ContextThemeWrapper;
@@ -156,6 +157,10 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
setupMapRouteInfoMenuSpinners(routeMenu);
updateMapRouteInfoMenuFromIcon(routeMenu);
}
+ Fragment fragment = getTargetFragment();
+ if (fragment != null) {
+ fragment.onActivityResult(getTargetRequestCode(), 0, null);
+ }
dismiss();
}
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java
new file mode 100644
index 0000000000..071ba73d35
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java
@@ -0,0 +1,309 @@
+package net.osmand.plus.routepreparationmenu;
+
+import android.content.Intent;
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.support.v4.app.FragmentManager;
+import android.text.SpannableString;
+import android.view.ContextThemeWrapper;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import net.osmand.AndroidUtils;
+import net.osmand.Location;
+import net.osmand.data.LatLon;
+import net.osmand.plus.MapMarkersHelper;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+import net.osmand.plus.TargetPointsHelper;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.base.MenuBottomSheetDialogFragment;
+import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
+import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
+import net.osmand.plus.helpers.FontCache;
+import net.osmand.plus.helpers.MapMarkerDialogHelper;
+import net.osmand.plus.helpers.WaypointDialogHelper;
+import net.osmand.plus.mapcontextmenu.other.FavouritesBottomSheetMenuFragment;
+import net.osmand.plus.search.QuickSearchDialogFragment;
+import net.osmand.plus.widgets.style.CustomTypefaceSpan;
+
+import java.util.List;
+
+public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
+
+ public static final String TAG = "AddPointBottomSheetDialog";
+ public static final String TARGET_KEY = "target";
+ public static final String INTERMEDIATE_KEY = "intermediate";
+
+ public static final int ADD_FAVOURITE_TO_ROUTE_REQUEST_CODE = 1;
+
+ private boolean target;
+ private boolean intermediate;
+
+ @Override
+ public void createMenuItems(Bundle savedInstanceState) {
+ Bundle args = getArguments();
+ if (args != null && args.containsKey(TARGET_KEY) && args.containsKey(INTERMEDIATE_KEY)) {
+ target = args.getBoolean(TARGET_KEY);
+ intermediate = args.getBoolean(INTERMEDIATE_KEY);
+ }
+ String title;
+ if (intermediate) {
+ title = getString(R.string.add_intermediate_point);
+ } else if (target) {
+ title = getString(R.string.add_destination_point);
+ } else {
+ title = getString(R.string.add_start_point);
+ }
+ items.add(new TitleItem(title));
+
+ createSearchItem();
+ if (intermediate) {
+ createSelectOnTheMapItem();
+ createFavouritesItem();
+ createMarkersItem();
+ } else if (target) {
+ createMyLocItem();
+ createSelectOnTheMapItem();
+ createFavouritesItem();
+ createMarkersItem();
+ items.add(new DividerHalfItem(getContext()));
+ createSwitchStartAndEndItem();
+ } else {
+ createMyLocItem();
+ createSelectOnTheMapItem();
+ createFavouritesItem();
+ createMarkersItem();
+ items.add(new DividerHalfItem(getContext()));
+ createSwitchStartAndEndItem();
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == ADD_FAVOURITE_TO_ROUTE_REQUEST_CODE) {
+ dismiss();
+ }
+ }
+
+ @Override
+ protected int getDismissButtonTextId() {
+ return R.string.shared_string_close;
+ }
+
+ private void createSearchItem() {
+ View searchView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_double_item, null);
+ TextView firstTitle = (TextView) searchView.findViewById(R.id.first_title);
+ TextView secondTitle = (TextView) searchView.findViewById(R.id.second_title);
+ ImageView firstIcon = (ImageView) searchView.findViewById(R.id.first_icon);
+ ImageView secondIcon = (ImageView) searchView.findViewById(R.id.second_icon);
+
+ firstTitle.setText(R.string.shared_string_search);
+ secondTitle.setText(R.string.shared_string_address);
+ firstIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_search_dark));
+ secondIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_street_name));
+
+ AndroidUtils.setBackground(getContext(), searchView.findViewById(R.id.first_divider),
+ nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+ AndroidUtils.setBackground(getContext(), searchView.findViewById(R.id.second_divider),
+ nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
+
+ searchView.findViewById(R.id.first_item).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MapActivity mapActivity = (MapActivity) getActivity();
+ if (mapActivity != null) {
+ mapActivity.showQuickSearch(getSearchMode(), QuickSearchDialogFragment.QuickSearchTab.HISTORY);
+ }
+ dismiss();
+ }
+ });
+ searchView.findViewById(R.id.second_item).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MapActivity mapActivity = (MapActivity) getActivity();
+ if (mapActivity != null) {
+ mapActivity.showQuickSearch(getSearchMode(), false);
+ }
+ dismiss();
+ }
+ });
+ items.add(new BaseBottomSheetItem.Builder().setCustomView(searchView).create());
+ }
+
+ private MapActivity.ShowQuickSearchMode getSearchMode() {
+ if (intermediate) {
+ return MapActivity.ShowQuickSearchMode.INTERMEDIATE_SELECTION;
+ } else if (target) {
+ return MapActivity.ShowQuickSearchMode.DESTINATION_SELECTION;
+ } else {
+ return MapActivity.ShowQuickSearchMode.START_POINT_SELECTION;
+ }
+ }
+
+ private void createMyLocItem() {
+ BaseBottomSheetItem myLocationItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getIcon(R.drawable.ic_action_location_color, 0))
+ .setTitle(getString(R.string.shared_string_my_location))
+ .setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ OsmandApplication app = getMyApplication();
+ if (app != null) {
+ TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
+ Location myLocation = app.getLocationProvider().getLastKnownLocation();
+ if (myLocation != null) {
+ LatLon ll = new LatLon(myLocation.getLatitude(), myLocation.getLongitude());
+ if (intermediate) {
+ app.showShortToastMessage(R.string.add_intermediate_point);
+ targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size());
+ } else if (target) {
+ app.showShortToastMessage(R.string.add_destination_point);
+ targetPointsHelper.navigateToPoint(ll, true, -1);
+ } else {
+ if (targetPointsHelper.getPointToStart() != null) {
+ targetPointsHelper.clearStartPoint(true);
+ app.getSettings().backupPointToStart();
+ }
+ }
+ }
+ }
+ dismiss();
+ }
+ }).create();
+ items.add(myLocationItem);
+ }
+
+ private void createSelectOnTheMapItem() {
+ BaseBottomSheetItem selectOnTheMapItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_show_on_map))
+ .setTitle(getString(R.string.shared_string_select_on_map))
+ .setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MapActivity mapActivity = (MapActivity) getActivity();
+ if (mapActivity != null) {
+ MapRouteInfoMenu menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
+ menu.selectOnScreen(target, intermediate);
+ }
+ dismiss();
+ }
+ })
+ .create();
+ items.add(selectOnTheMapItem);
+ }
+
+ private void createFavouritesItem() {
+ BaseBottomSheetItem favouritesItem = new SimpleBottomSheetItem.Builder()
+ .setIcon(getContentIcon(R.drawable.ic_action_fav_dark))
+ .setTitle(getString(R.string.shared_string_favorites))
+ .setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MapActivity mapActivity = (MapActivity) getActivity();
+ if (mapActivity != null) {
+ FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
+ FavouritesBottomSheetMenuFragment fragment = new FavouritesBottomSheetMenuFragment();
+ Bundle args = new Bundle();
+ args.putBoolean(FavouritesBottomSheetMenuFragment.TARGET, target);
+ args.putBoolean(FavouritesBottomSheetMenuFragment.INTERMEDIATE, intermediate);
+ fragment.setTargetFragment(AddPointBottomSheetDialog.this, ADD_FAVOURITE_TO_ROUTE_REQUEST_CODE);
+ fragment.setArguments(args);
+ fragment.show(fragmentManager, FavouritesBottomSheetMenuFragment.TAG);
+ }
+ }
+ })
+ .create();
+ items.add(favouritesItem);
+ }
+
+ private void createMarkersItem() {
+ final OsmandApplication app = getMyApplication();
+ if (app == null) {
+ return;
+ }
+ final View markersView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_double_item, null);
+
+ MapMarkersHelper markersHelper = app.getMapMarkersHelper();
+ List markers = markersHelper.getMapMarkers();
+ MapMarkersHelper.MapMarker marker = null;
+ if (markers.size() > 0) {
+ marker = markers.get(0);
+ }
+ TextView firstTitle = (TextView) markersView.findViewById(R.id.first_title);
+ TextView secondTitle = (TextView) markersView.findViewById(R.id.second_title);
+ ImageView firstIcon = (ImageView) markersView.findViewById(R.id.first_icon);
+ ImageView secondIcon = (ImageView) markersView.findViewById(R.id.second_icon);
+
+ firstTitle.setText(R.string.shared_string_markers);
+ firstIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_flag_dark));
+
+ if (marker != null) {
+ secondTitle.setText(marker.getName(getContext()));
+ secondIcon.setImageDrawable(MapMarkerDialogHelper.getMapMarkerIcon(app, marker.colorIndex));
+
+ }
+ markersView.findViewById(R.id.first_item).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MapActivity mapActivity = (MapActivity) getActivity();
+ if (mapActivity != null) {
+ MapRouteInfoMenu menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
+ menu.selectMapMarker(-1, target, intermediate);
+ dismiss();
+ }
+ }
+ });
+ markersView.findViewById(R.id.second_item).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MapActivity mapActivity = (MapActivity) getActivity();
+ if (mapActivity != null) {
+ MapRouteInfoMenu menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
+ menu.selectMapMarker(0, target, intermediate);
+ dismiss();
+ }
+ }
+ });
+ items.add(new BaseBottomSheetItem.Builder().setCustomView(markersView).create());
+ }
+
+ private void createSwitchStartAndEndItem() {
+ final View switchStartAndEndView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_item_simple_56dp, null);
+ TextView title = (TextView) switchStartAndEndView.findViewById(R.id.title);
+ ImageView iconIv = (ImageView) switchStartAndEndView.findViewById(R.id.icon);
+ iconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_change_navigation_points));
+
+ String titleS = getString(R.string.swap_start_and_destination);
+ SpannableString titleSpan = new SpannableString(titleS);
+ int firstIndex = titleS.indexOf(" ");
+ if (firstIndex != -1) {
+ Typeface typeface = FontCache.getRobotoMedium(getContext());
+ titleSpan.setSpan(new CustomTypefaceSpan(typeface), firstIndex, titleS.indexOf(" ", firstIndex + 1), 0);
+ titleSpan.setSpan(new CustomTypefaceSpan(typeface), titleS.lastIndexOf(" "), titleS.length(), 0);
+ }
+ title.setText(titleSpan);
+
+ switchStartAndEndView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MapActivity mapActivity = (MapActivity) getActivity();
+ if (mapActivity != null) {
+ TargetPointsHelper targetsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
+ WaypointDialogHelper.switchStartAndFinish(targetsHelper, targetsHelper.getPointToNavigate(),
+ mapActivity, targetsHelper.getPointToStart(), mapActivity.getMyApplication(),
+ mapActivity.getDashboard().getWaypointDialogHelper());
+ }
+ dismiss();
+ }
+ });
+ items.add(new BaseBottomSheetItem.Builder().setCustomView(switchStartAndEndView).create());
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
index ef6364b505..eeef67c876 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
@@ -14,8 +14,6 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
-import android.support.v7.widget.ListPopupWindow;
-import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -870,7 +868,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
RouteOptionsBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
}
- protected void clickRouteWaypoints() {
+ private void clickRouteWaypoints() {
if (getTargets().checkPointToNavigateShort()) {
mapActivity.getMapActions().openIntermediatePointsDialog();
}
@@ -894,6 +892,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
viaButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+// clickRouteWaypoints();
if (getTargets().checkPointToNavigateShort()) {
WaypointsFragment.showInstance(mapActivity);
}
@@ -905,9 +904,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
viaIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (getTargets().checkPointToNavigateShort()) {
- mapActivity.getMapActions().openIntermediatePointsDialog();
- }
+ clickRouteWaypoints();
}
});
LinearLayout viaButtonContainer = (LinearLayout) parentView.findViewById(R.id.via_button_container);
@@ -976,7 +973,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
toLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- toSpinner.performClick();
+ openAddPointDialog(true, false);
}
});
@@ -1002,38 +999,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
toButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- if (mapActivity != null) {
- final ListPopupWindow popup = new ListPopupWindow(mapActivity);
- popup.setAnchorView(toLayout);
- popup.setDropDownGravity(Gravity.END | Gravity.TOP);
- popup.setModal(true);
- popup.setAdapter(getIntermediatesPopupAdapter(mapActivity));
- popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- boolean hideDashboard = false;
- if (id == MapRouteInfoMenu.SPINNER_FAV_ID) {
- selectFavorite(null, false, true);
- } else if (id == MapRouteInfoMenu.SPINNER_MAP_ID) {
- hideDashboard = true;
- selectOnScreen(false, true);
- } else if (id == MapRouteInfoMenu.SPINNER_ADDRESS_ID) {
- mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.INTERMEDIATE_SELECTION, false);
- } else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_MORE_ID) {
- selectMapMarker(-1, false, true);
- } else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_1_ID) {
- selectMapMarker(0, false, true);
- } else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_2_ID) {
- selectMapMarker(1, false, true);
- }
- popup.dismiss();
- if (hideDashboard) {
- mapActivity.getDashboard().hideDashboard();
- }
- }
- });
- popup.show();
- }
+ openAddPointDialog(false, true);
}
});
@@ -1100,7 +1066,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
fromLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- fromSpinner.performClick();
+ openAddPointDialog(false, false);
}
});
@@ -1206,14 +1172,22 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
getTargets().setStartPoint(point, true, m.getPointDescription(mapActivity));
}
updateFromIcon();
-
} else {
-
MapMarkerSelectionFragment selectionFragment = MapMarkerSelectionFragment.newInstance(target, intermediate);
selectionFragment.show(mapActivity.getSupportFragmentManager(), MapMarkerSelectionFragment.TAG);
}
}
+ private void openAddPointDialog(final boolean target, final boolean intermediate) {
+ Bundle args = new Bundle();
+ args.putBoolean(AddPointBottomSheetDialog.TARGET_KEY, target);
+ args.putBoolean(AddPointBottomSheetDialog.INTERMEDIATE_KEY, intermediate);
+ AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
+ fragment.setArguments(args);
+ fragment.setUsedOnMap(false);
+ fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
+ }
+
private boolean isLight() {
return !nightMode;
}
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java
index 3926c0015c..4e653bf9b8 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java
@@ -10,7 +10,6 @@ import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.ListPopupWindow;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -271,7 +270,13 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- onWaypointItemClick(view.findViewById(R.id.waypoints_control_buttons));
+ Bundle args = new Bundle();
+ args.putBoolean(AddPointBottomSheetDialog.TARGET_KEY, false);
+ args.putBoolean(AddPointBottomSheetDialog.INTERMEDIATE_KEY, true);
+ AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
+ fragment.setArguments(args);
+ fragment.setUsedOnMap(false);
+ fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
}
});
@@ -597,47 +602,14 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
title.setText(app.getString(R.string.waypoints, (pointsSize != 0 ? pointsSize : 1)));
}
- private void onWaypointItemClick(View addWaypointItem) {
- if (mapActivity != null) {
- final MapRouteInfoMenu routeMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
- final ListPopupWindow popup = new ListPopupWindow(mapActivity);
- popup.setAnchorView(addWaypointItem);
- popup.setDropDownGravity(Gravity.END | Gravity.TOP);
- popup.setModal(true);
- popup.setAdapter(routeMenu.getIntermediatesPopupAdapter(mapActivity));
- popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- boolean hideDashboard = false;
- if (id == MapRouteInfoMenu.SPINNER_FAV_ID) {
- routeMenu.selectFavorite(null, false, true);
- } else if (id == MapRouteInfoMenu.SPINNER_MAP_ID) {
- hideDashboard = true;
- routeMenu.selectOnScreen(false, true);
- dismiss();
- } else if (id == MapRouteInfoMenu.SPINNER_ADDRESS_ID) {
- mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.INTERMEDIATE_SELECTION, false);
- } else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_MORE_ID) {
- routeMenu.selectMapMarker(-1, false, true);
- } else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_1_ID) {
- routeMenu.selectMapMarker(0, false, true);
- } else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_2_ID) {
- routeMenu.selectMapMarker(1, false, true);
- }
- popup.dismiss();
- if (hideDashboard) {
- mapActivity.getDashboard().hideDashboard();
- }
- }
- });
- popup.show();
- }
- }
-
private void applyPointsChanges() {
app.runInUIThread(new Runnable() {
@Override
public void run() {
+ OsmandApplication app = getMyApplication();
+ if (app == null || !isVisible()) {
+ return;
+ }
List allTargets = new ArrayList<>();
TargetPointsHelper.TargetPoint start = null;
List