Add the ability to add intermediate points from waypoints dialog options menu
This commit is contained in:
parent
b69d6cd1d9
commit
cc2b19994a
7 changed files with 198 additions and 64 deletions
|
@ -1821,11 +1821,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
hideContextMenu();
|
||||
}
|
||||
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
|
||||
if (mode == ShowQuickSearchMode.START_POINT_SELECTION || mode == ShowQuickSearchMode.DESTINATION_SELECTION) {
|
||||
if (mode == ShowQuickSearchMode.START_POINT_SELECTION || mode == ShowQuickSearchMode.DESTINATION_SELECTION
|
||||
|| mode == ShowQuickSearchMode.INTERMEDIATE_SELECTION) {
|
||||
if (fragment != null) {
|
||||
fragment.dismiss();
|
||||
}
|
||||
if (mode == ShowQuickSearchMode.START_POINT_SELECTION) {
|
||||
if (mode == ShowQuickSearchMode.INTERMEDIATE_SELECTION) {
|
||||
QuickSearchDialogFragment.showInstance(this, "", null,
|
||||
QuickSearchType.INTERMEDIATE, showCategories ? QuickSearchTab.CATEGORIES : QuickSearchTab.ADDRESS, null);
|
||||
} else if (mode == ShowQuickSearchMode.START_POINT_SELECTION) {
|
||||
QuickSearchDialogFragment.showInstance(this, "", null,
|
||||
QuickSearchType.START_POINT, showCategories ? QuickSearchTab.CATEGORIES : QuickSearchTab.ADDRESS, null);
|
||||
} else {
|
||||
|
@ -1915,6 +1919,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
CURRENT,
|
||||
START_POINT_SELECTION,
|
||||
DESTINATION_SELECTION,
|
||||
INTERMEDIATE_SELECTION
|
||||
}
|
||||
|
||||
public InAppHelper execInAppTask(@NonNull InAppHelper.InAppRunnable runnable) {
|
||||
|
|
|
@ -15,6 +15,8 @@ import android.support.annotation.Nullable;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
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.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
|
@ -45,6 +47,7 @@ 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.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.views.controls.DynamicListView.DragIcon;
|
||||
import net.osmand.plus.views.controls.ListDividerShape;
|
||||
|
@ -1027,7 +1030,19 @@ public class WaypointDialogHelper {
|
|||
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
|
||||
// add waypoint item
|
||||
final BaseBottomSheetItem[] addWaypointItem = new BaseBottomSheetItem[1];
|
||||
addWaypointItem[0] = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_plus))
|
||||
.setTitle(getString(R.string.add_waypoint))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onWaypointItemClick(addWaypointItem);
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(addWaypointItem[0]);
|
||||
|
||||
BaseBottomSheetItem clearIntermediatesItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_clear_all))
|
||||
|
@ -1057,6 +1072,41 @@ public class WaypointDialogHelper {
|
|||
return R.string.shared_string_close;
|
||||
}
|
||||
|
||||
private void onWaypointItemClick(BaseBottomSheetItem[] addWaypointItem) {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
final MapRouteInfoMenu routeMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
|
||||
final ListPopupWindow popup = new ListPopupWindow(mapActivity);
|
||||
popup.setAnchorView(addWaypointItem[0].getView());
|
||||
popup.setDropDownGravity(Gravity.END | Gravity.TOP);
|
||||
popup.setVerticalOffset(AndroidUtils.dpToPx(mapActivity, 48f));
|
||||
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) {
|
||||
if (id == MapRouteInfoMenu.SPINNER_FAV_ID) {
|
||||
routeMenu.selectFavorite(null, false, true);
|
||||
} else if (id == MapRouteInfoMenu.SPINNER_MAP_ID) {
|
||||
routeMenu.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) {
|
||||
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();
|
||||
dismiss();
|
||||
mapActivity.getDashboard().hideDashboard();
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MapActivity getMapActivity() {
|
||||
Activity activity = getActivity();
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.content.DialogInterface;
|
|||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -67,6 +69,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
private GeocodingLookupService geocodingLookupService;
|
||||
private boolean selectFromMapTouch;
|
||||
private boolean selectFromMapForTarget;
|
||||
private boolean selectFromMapForIntermediate;
|
||||
|
||||
private boolean showMenu = false;
|
||||
private static boolean visible;
|
||||
|
@ -84,19 +87,19 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
private OnMarkerSelectListener onMarkerSelectListener;
|
||||
|
||||
private static final long SPINNER_MY_LOCATION_ID = 1;
|
||||
private static final long SPINNER_FAV_ID = 2;
|
||||
private static final long SPINNER_MAP_ID = 3;
|
||||
private static final long SPINNER_ADDRESS_ID = 4;
|
||||
public static final long SPINNER_FAV_ID = 2;
|
||||
public static final long SPINNER_MAP_ID = 3;
|
||||
public static final long SPINNER_ADDRESS_ID = 4;
|
||||
private static final long SPINNER_START_ID = 5;
|
||||
private static final long SPINNER_FINISH_ID = 6;
|
||||
private static final long SPINNER_HINT_ID = 100;
|
||||
private static final long SPINNER_MAP_MARKER_1_ID = 301;
|
||||
private static final long SPINNER_MAP_MARKER_2_ID = 302;
|
||||
public static final long SPINNER_MAP_MARKER_1_ID = 301;
|
||||
public static final long SPINNER_MAP_MARKER_2_ID = 302;
|
||||
private static final long SPINNER_MAP_MARKER_3_ID = 303;
|
||||
private static final long SPINNER_MAP_MARKER_MORE_ID = 350;
|
||||
public static final long SPINNER_MAP_MARKER_MORE_ID = 350;
|
||||
|
||||
public interface OnMarkerSelectListener {
|
||||
void onSelect(int index, boolean target);
|
||||
void onSelect(int index, boolean target, boolean intermediate);
|
||||
}
|
||||
|
||||
public MapRouteInfoMenu(MapActivity mapActivity, MapControlsLayer mapControlsLayer) {
|
||||
|
@ -109,8 +112,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
geocodingLookupService = mapActivity.getMyApplication().getGeocodingLookupService();
|
||||
onMarkerSelectListener = new OnMarkerSelectListener() {
|
||||
@Override
|
||||
public void onSelect(int index, boolean target) {
|
||||
selectMapMarker(index, target);
|
||||
public void onSelect(int index, boolean target, boolean intermediate) {
|
||||
selectMapMarker(index, target, intermediate);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -131,7 +134,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
if (selectFromMapTouch) {
|
||||
LatLon latlon = tileBox.getLatLonFromPixel(point.x, point.y);
|
||||
selectFromMapTouch = false;
|
||||
if (selectFromMapForTarget) {
|
||||
if (selectFromMapForIntermediate) {
|
||||
getTargets().navigateToPoint(latlon, true, getTargets().getIntermediatePoints().size());
|
||||
} else if (selectFromMapForTarget) {
|
||||
getTargets().navigateToPoint(latlon, true, -1);
|
||||
} else {
|
||||
getTargets().setStartPoint(latlon, true, null);
|
||||
|
@ -337,21 +342,21 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
@Override
|
||||
public void run() {
|
||||
if (id == SPINNER_FAV_ID) {
|
||||
selectFavorite(parentView, true);
|
||||
selectFavorite(parentView, true, false);
|
||||
} else if (id == SPINNER_MAP_ID) {
|
||||
selectOnScreen(true);
|
||||
selectOnScreen(true, false);
|
||||
} else if (id == SPINNER_ADDRESS_ID) {
|
||||
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.DESTINATION_SELECTION, false);
|
||||
setupToSpinner(parentView);
|
||||
} else if (id == SPINNER_MAP_MARKER_MORE_ID) {
|
||||
selectMapMarker(-1, true);
|
||||
selectMapMarker(-1, true, false);
|
||||
setupToSpinner(parentView);
|
||||
} else if (id == SPINNER_MAP_MARKER_1_ID) {
|
||||
selectMapMarker(0, true);
|
||||
selectMapMarker(0, true, false);
|
||||
} else if (id == SPINNER_MAP_MARKER_2_ID) {
|
||||
selectMapMarker(1, true);
|
||||
selectMapMarker(1, true, false);
|
||||
} else if (id == SPINNER_MAP_MARKER_3_ID) {
|
||||
selectMapMarker(2, true);
|
||||
selectMapMarker(2, true, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -407,21 +412,21 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
}
|
||||
updateFromIcon(parentView);
|
||||
} else if (id == SPINNER_FAV_ID) {
|
||||
selectFavorite(parentView, false);
|
||||
selectFavorite(parentView, false, false);
|
||||
} else if (id == SPINNER_MAP_ID) {
|
||||
selectOnScreen(false);
|
||||
selectOnScreen(false, false);
|
||||
} else if (id == SPINNER_ADDRESS_ID) {
|
||||
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.START_POINT_SELECTION, false);
|
||||
setupFromSpinner(parentView);
|
||||
} else if (id == SPINNER_MAP_MARKER_MORE_ID) {
|
||||
selectMapMarker(-1, false);
|
||||
selectMapMarker(-1, false, false);
|
||||
setupFromSpinner(parentView);
|
||||
} else if (id == SPINNER_MAP_MARKER_1_ID) {
|
||||
selectMapMarker(0, false);
|
||||
selectMapMarker(0, false, false);
|
||||
} else if (id == SPINNER_MAP_MARKER_2_ID) {
|
||||
selectMapMarker(1, false);
|
||||
selectMapMarker(1, false, false);
|
||||
} else if (id == SPINNER_MAP_MARKER_3_ID) {
|
||||
selectMapMarker(2, false);
|
||||
selectMapMarker(2, false, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -450,15 +455,18 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
getTargets().getPointToStart() == null ? R.drawable.ic_action_location_color : R.drawable.list_startpoint));
|
||||
}
|
||||
|
||||
protected void selectOnScreen(boolean target) {
|
||||
public void selectOnScreen(boolean target, boolean intermediate) {
|
||||
selectFromMapTouch = true;
|
||||
selectFromMapForTarget = target;
|
||||
selectFromMapForIntermediate = intermediate;
|
||||
hide();
|
||||
}
|
||||
|
||||
public void selectAddress(String name, LatLon l, final boolean target) {
|
||||
public void selectAddress(String name, LatLon l, final boolean target, final boolean intermediate) {
|
||||
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, name);
|
||||
if (target) {
|
||||
if (intermediate) {
|
||||
getTargets().navigateToPoint(l, true, getTargets().getIntermediatePoints().size(), pd);
|
||||
} else if (target) {
|
||||
getTargets().navigateToPoint(l, true, -1, pd);
|
||||
} else {
|
||||
getTargets().setStartPoint(l, true, pd);
|
||||
|
@ -466,31 +474,35 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
updateMenu();
|
||||
}
|
||||
|
||||
protected void selectFavorite(final View parentView, final boolean target) {
|
||||
public void selectFavorite(@Nullable final View parentView, final boolean target, final boolean intermediate) {
|
||||
final FavouritesAdapter favouritesAdapter = new FavouritesAdapter(mapActivity, mapActivity.getMyApplication()
|
||||
.getFavorites().getVisibleFavouritePoints(), false);
|
||||
Dialog[] dlgHolder = new Dialog[1];
|
||||
OnItemClickListener click = getOnFavoriteClickListener(target, favouritesAdapter, dlgHolder);
|
||||
OnDismissListener dismissListener = new DialogInterface.OnDismissListener() {
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (target) {
|
||||
setupToSpinner(parentView);
|
||||
} else {
|
||||
setupFromSpinner(parentView);
|
||||
OnItemClickListener click = getOnFavoriteClickListener(target, intermediate, favouritesAdapter, dlgHolder);
|
||||
OnDismissListener dismissListener = null;
|
||||
if (!intermediate && parentView != null) {
|
||||
dismissListener = new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (target) {
|
||||
setupToSpinner(parentView);
|
||||
} else {
|
||||
setupFromSpinner(parentView);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
favouritesAdapter.updateLocation(mapActivity.getMapLocation());
|
||||
FavoriteDialogs.showFavoritesDialog(mapActivity, favouritesAdapter, click, dismissListener, dlgHolder, true);
|
||||
}
|
||||
|
||||
private void selectMapMarker(final int index, final boolean target) {
|
||||
public void selectMapMarker(final int index, final boolean target, final boolean intermediate) {
|
||||
if (index != -1) {
|
||||
MapMarker m = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers().get(index);
|
||||
LatLon point = new LatLon(m.getLatitude(), m.getLongitude());
|
||||
if (target) {
|
||||
if (intermediate) {
|
||||
getTargets().navigateToPoint(point, true, getTargets().getIntermediatePoints().size(), m.getPointDescription(mapActivity));
|
||||
} else if (target) {
|
||||
getTargets().navigateToPoint(point, true, -1, m.getPointDescription(mapActivity));
|
||||
} else {
|
||||
getTargets().setStartPoint(point, true, m.getPointDescription(mapActivity));
|
||||
|
@ -499,7 +511,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
|
||||
} else {
|
||||
|
||||
MapMarkerSelectionFragment selectionFragment = MapMarkerSelectionFragment.newInstance(target);
|
||||
MapMarkerSelectionFragment selectionFragment = MapMarkerSelectionFragment.newInstance(target, intermediate);
|
||||
selectionFragment.show(mapActivity.getSupportFragmentManager(), MapMarkerSelectionFragment.TAG);
|
||||
}
|
||||
}
|
||||
|
@ -513,7 +525,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
return iconsCache.getIcon(iconId, 0);
|
||||
}
|
||||
|
||||
private OnItemClickListener getOnFavoriteClickListener(final boolean target, final FavouritesAdapter favouritesAdapter,
|
||||
private OnItemClickListener getOnFavoriteClickListener(final boolean target,
|
||||
final boolean intermediate,
|
||||
final FavouritesAdapter favouritesAdapter,
|
||||
final Dialog[] dlg) {
|
||||
return new AdapterView.OnItemClickListener() {
|
||||
|
||||
|
@ -521,7 +535,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
FavouritePoint fp = favouritesAdapter.getItem(position);
|
||||
LatLon point = new LatLon(fp.getLatitude(), fp.getLongitude());
|
||||
if (target) {
|
||||
if (intermediate) {
|
||||
getTargets().navigateToPoint(point, true, getTargets().getIntermediatePoints().size(), fp.getPointDescription());
|
||||
} else if (target) {
|
||||
getTargets().navigateToPoint(point, true, -1, fp.getPointDescription());
|
||||
} else {
|
||||
getTargets().setStartPoint(point, true, fp.getPointDescription());
|
||||
|
@ -529,7 +545,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
if (dlg != null && dlg.length > 0 && dlg[0] != null) {
|
||||
dlg[0].dismiss();
|
||||
}
|
||||
updateFromIcon();
|
||||
if (!intermediate) {
|
||||
updateFromIcon();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -822,6 +840,26 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
return toSpinner;
|
||||
}
|
||||
|
||||
public RoutePopupListArrayAdapter getIntermediatesPopupAdapter(Context ctx) {
|
||||
List<RouteSpinnerRow> viaActions = new ArrayList<>();
|
||||
|
||||
viaActions.add(new RouteSpinnerRow(SPINNER_FAV_ID, R.drawable.ic_action_fav_dark,
|
||||
mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis)));
|
||||
viaActions.add(new RouteSpinnerRow(SPINNER_MAP_ID, R.drawable.ic_action_marker_dark,
|
||||
mapActivity.getString(R.string.shared_string_select_on_map)));
|
||||
viaActions.add(new RouteSpinnerRow(SPINNER_ADDRESS_ID, R.drawable.ic_action_home_dark,
|
||||
mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)));
|
||||
|
||||
addMarkersToSpinner(viaActions);
|
||||
|
||||
RoutePopupListArrayAdapter viaAdapter = new RoutePopupListArrayAdapter(ctx);
|
||||
for (RouteSpinnerRow row : viaActions) {
|
||||
viaAdapter.add(row);
|
||||
}
|
||||
|
||||
return viaAdapter;
|
||||
}
|
||||
|
||||
private void addMarkersToSpinner(List<RouteSpinnerRow> actions) {
|
||||
MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||
List<MapMarker> markers = markersHelper.getMapMarkers();
|
||||
|
@ -944,11 +982,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
}
|
||||
}
|
||||
|
||||
private class RouteSpinnerArrayAdapter extends ArrayAdapter<RouteSpinnerRow> {
|
||||
private class RouteBaseArrayAdapter extends ArrayAdapter<RouteSpinnerRow> {
|
||||
|
||||
public RouteSpinnerArrayAdapter(Context context) {
|
||||
super(context, android.R.layout.simple_spinner_item);
|
||||
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
RouteBaseArrayAdapter(@NonNull Context context, int resource) {
|
||||
super(context, resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -968,8 +1005,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
return id != SPINNER_HINT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View getRowItemView(int position, View convertView, ViewGroup parent) {
|
||||
TextView label = (TextView) super.getView(position, convertView, parent);
|
||||
RouteSpinnerRow row = getItem(position);
|
||||
label.setText(row.text);
|
||||
|
@ -978,8 +1014,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
View getListItemView(int position, View convertView, ViewGroup parent) {
|
||||
long id = getItemId(position);
|
||||
TextView label = (TextView) super.getDropDownView(position, convertView, parent);
|
||||
|
||||
|
@ -1011,4 +1046,36 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
private class RouteSpinnerArrayAdapter extends RouteBaseArrayAdapter {
|
||||
|
||||
RouteSpinnerArrayAdapter(Context context) {
|
||||
super(context, android.R.layout.simple_spinner_item);
|
||||
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
return getRowItemView(position, convertView, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
return getListItemView(position, convertView, parent);
|
||||
}
|
||||
}
|
||||
|
||||
private class RoutePopupListArrayAdapter extends RouteBaseArrayAdapter {
|
||||
|
||||
RoutePopupListArrayAdapter(Context context) {
|
||||
super(context, android.R.layout.simple_spinner_dropdown_item);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
return getListItemView(position, convertView, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.List;
|
|||
public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
|
||||
public static final String TAG = "MapMarkerSelectionFragment";
|
||||
private static final String TARGET_KEY = "target_key";
|
||||
private static final String INTERMEDIATE_KEY = "intermediate_key";
|
||||
|
||||
private LatLon loc;
|
||||
private Float heading;
|
||||
|
@ -37,6 +38,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
|
|||
private boolean nightMode;
|
||||
private int screenOrientation;
|
||||
private boolean target;
|
||||
private boolean intermediate;
|
||||
|
||||
private OnMarkerSelectListener onClickListener;
|
||||
|
||||
|
@ -52,6 +54,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
|
|||
}
|
||||
if (bundle != null) {
|
||||
target = bundle.getBoolean(TARGET_KEY);
|
||||
intermediate = bundle.getBoolean(INTERMEDIATE_KEY);
|
||||
}
|
||||
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
|
@ -104,7 +107,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (onClickListener != null) {
|
||||
onClickListener.onSelect(position, target);
|
||||
onClickListener.onSelect(position, target, intermediate);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
@ -116,6 +119,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
|
|||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(TARGET_KEY, target);
|
||||
outState.putBoolean(INTERMEDIATE_KEY, intermediate);
|
||||
}
|
||||
|
||||
private class MapMarkersListAdapter extends ArrayAdapter<MapMarker> {
|
||||
|
@ -140,10 +144,11 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public static MapMarkerSelectionFragment newInstance(boolean target) {
|
||||
public static MapMarkerSelectionFragment newInstance(boolean target, boolean intermediate) {
|
||||
MapMarkerSelectionFragment fragment = new MapMarkerSelectionFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(TARGET_KEY, target);
|
||||
args.putBoolean(INTERMEDIATE_KEY, intermediate);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
|
|
@ -198,6 +198,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
REGULAR,
|
||||
START_POINT,
|
||||
DESTINATION,
|
||||
INTERMEDIATE
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -365,7 +366,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
} else {
|
||||
SearchWord word = searchPhrase.getLastSelectedWord();
|
||||
if (word != null) {
|
||||
if ((searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION)
|
||||
if ((searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION || searchType == QuickSearchType.INTERMEDIATE)
|
||||
&& word.getLocation() != null) {
|
||||
if (mainSearchFragment != null) {
|
||||
mainSearchFragment.showResult(word.getResult());
|
||||
|
@ -801,7 +802,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
if (foundPartialLocation) {
|
||||
buttonToolbarText.setText(app.getString(R.string.advanced_coords_search).toUpperCase());
|
||||
} else if (searchEditText.getText().length() > 0) {
|
||||
if (searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION) {
|
||||
if (searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION || searchType == QuickSearchType.INTERMEDIATE) {
|
||||
if (word != null && word.getResult() != null) {
|
||||
buttonToolbarText.setText(app.getString(R.string.shared_string_select).toUpperCase() + " " + word.getResult().localeName.toUpperCase());
|
||||
} else {
|
||||
|
@ -1761,7 +1762,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
searchEditText.setSelection(txt.length());
|
||||
SearchWord lastWord = searchUICore.getPhrase().getLastSelectedWord();
|
||||
boolean buttonToolbarVisible = lastWord == null || searchType == QuickSearchType.REGULAR ||
|
||||
((searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION)
|
||||
((searchType == QuickSearchType.START_POINT || searchType == QuickSearchType.DESTINATION || searchType == QuickSearchType.INTERMEDIATE)
|
||||
&& ObjectType.isAddress(lastWord.getType()));
|
||||
buttonToolbarView.setVisibility(buttonToolbarVisible ? View.VISIBLE : View.GONE);
|
||||
updateToolbarButton();
|
||||
|
|
|
@ -269,13 +269,19 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
case START_POINT: {
|
||||
mapActivity.getMapLayers().getMapControlsLayer().selectAddress(
|
||||
pointDescription != null ? pointDescription.getName() : null,
|
||||
latitude, longitude, false);
|
||||
latitude, longitude, false, false);
|
||||
break;
|
||||
}
|
||||
case DESTINATION: {
|
||||
mapActivity.getMapLayers().getMapControlsLayer().selectAddress(
|
||||
pointDescription != null ? pointDescription.getName() : null,
|
||||
latitude, longitude, true);
|
||||
latitude, longitude, true, false);
|
||||
break;
|
||||
}
|
||||
case INTERMEDIATE: {
|
||||
mapActivity.getMapLayers().getMapControlsLayer().selectAddress(
|
||||
pointDescription != null ? pointDescription.getName() : null,
|
||||
latitude, longitude, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1294,11 +1294,11 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
};
|
||||
}
|
||||
|
||||
public void selectAddress(String name, double latitude, double longitude, boolean target) {
|
||||
public void selectAddress(String name, double latitude, double longitude, boolean target, boolean intermediate) {
|
||||
if (name != null) {
|
||||
mapRouteInfoMenu.selectAddress(name, new LatLon(latitude, longitude), target);
|
||||
mapRouteInfoMenu.selectAddress(name, new LatLon(latitude, longitude), target, intermediate);
|
||||
} else {
|
||||
mapRouteInfoMenu.selectAddress("", new LatLon(latitude, longitude), target);
|
||||
mapRouteInfoMenu.selectAddress("", new LatLon(latitude, longitude), target, intermediate);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue