Merge pull request #4562 from osmandapp/sasha_pasha_branch
Sasha pasha branch
This commit is contained in:
commit
18db340d6b
9 changed files with 198 additions and 88 deletions
|
@ -7,21 +7,14 @@
|
|||
android:descendantFocusability="blocksDescendants"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<ImageView
|
||||
android:id="@+id/top_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/bg_shadow_list_top"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="4dp"/>
|
||||
|
||||
<include layout="@layout/card_top_divider"/>
|
||||
|
||||
</LinearLayout>
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_layout"
|
||||
|
|
|
@ -109,9 +109,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/measurement_tool_text_margin_small"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginRight="@dimen/measurement_tool_text_margin_small"
|
||||
android:layout_marginStart="@dimen/measurement_tool_text_margin"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
|
@ -134,8 +132,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginStart="@dimen/measurement_tool_text_margin"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
|
|
|
@ -1337,6 +1337,7 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> ANIMATE_MY_LOCATION = new BooleanPreference("animate_my_location", true).makeGlobal().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_START_MY_LOC = new BooleanPreference("route_map_markers_start_my_loc", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_ROUND_TRIP = new BooleanPreference("route_map_markers_round_trip", false).makeGlobal().cache();
|
||||
|
||||
public ITileSource getMapTileSource(boolean warnWhenSelected) {
|
||||
String tileName = MAP_TILE_SOURCES.get();
|
||||
|
|
|
@ -172,6 +172,10 @@ public class MarkersPlanRouteContext {
|
|||
for (LatLon l : markersHelper.getSelectedMarkersLatLon()) {
|
||||
addWptPt(points, l.getLatitude(), l.getLongitude());
|
||||
}
|
||||
if (app.getSettings().ROUTE_MAP_MARKERS_ROUND_TRIP.get() && !points.isEmpty()) {
|
||||
WptPt l = points.get(0);
|
||||
addWptPt(points, l.getLatitude(), l.getLongitude());
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ import android.widget.ImageView;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.TspAnt;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
|
@ -41,6 +41,8 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapmarkers.PlanRouteOptionsBottomSheetDialogFragment.PlanRouteOptionsFragmentListener;
|
||||
|
@ -48,6 +50,7 @@ import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback;
|
|||
import net.osmand.plus.mapmarkers.adapters.MapMarkersListAdapter;
|
||||
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment;
|
||||
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment.SnapToRoadFragmentListener;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.MapMarkersLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
|
@ -78,6 +81,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
private boolean nightMode;
|
||||
private boolean portrait;
|
||||
private boolean wasCollapseButtonVisible;
|
||||
private boolean cancelSnapToRoad = true;
|
||||
|
||||
private View mainView;
|
||||
private RecyclerView markersRv;
|
||||
|
@ -266,10 +270,11 @@ public class PlanRouteFragment extends Fragment {
|
|||
if (pos == RecyclerView.NO_POSITION) {
|
||||
return;
|
||||
}
|
||||
if (pos == 0) {
|
||||
Object item = adapter.getItem(pos);
|
||||
if (item instanceof Location) {
|
||||
markersHelper.setStartFromMyLocation(!mapActivity.getMyApplication().getSettings().ROUTE_MAP_MARKERS_START_MY_LOC.get());
|
||||
} else {
|
||||
MapMarker marker = adapter.getItem(pos);
|
||||
} else if (item instanceof MapMarker) {
|
||||
MapMarker marker = (MapMarker) item;
|
||||
selectedCount = marker.selected ? selectedCount - 1 : selectedCount + 1;
|
||||
marker.selected = !marker.selected;
|
||||
markersHelper.updateMapMarker(marker, false);
|
||||
|
@ -305,7 +310,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600;
|
||||
markersRv.setPadding(0, 0, 0, AndroidUtils.dpToPx(mapActivity, isSmartphone ? 72 : 108));
|
||||
markersRv.setPadding(0, AndroidUtils.dpToPx(mapActivity, isSmartphone ? 10 : 15), 0, AndroidUtils.dpToPx(mapActivity, isSmartphone ? 8 : 12));
|
||||
markersRv.setClipToPadding(false);
|
||||
markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
markersRv.setAdapter(adapter);
|
||||
|
@ -353,6 +358,10 @@ public class PlanRouteFragment extends Fragment {
|
|||
@Override
|
||||
public void onApplicationModeItemClick(ApplicationMode mode) {
|
||||
if (planRouteContext.getSnappedMode() != mode) {
|
||||
MapMarkersLayer layer = getMapMarkersLayer();
|
||||
if (layer != null) {
|
||||
layer.setDefaultAppMode(mode == ApplicationMode.DEFAULT);
|
||||
}
|
||||
planRouteContext.getSnappedToRoadPoints().clear();
|
||||
planRouteContext.setSnappedMode(mode);
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
|
@ -375,14 +384,58 @@ public class PlanRouteFragment extends Fragment {
|
|||
@Override
|
||||
public void navigateOnClick() {
|
||||
if (mapActivity != null) {
|
||||
Toast.makeText(mapActivity, "navigate", Toast.LENGTH_SHORT).show();
|
||||
boolean hasTargets = false;
|
||||
TargetPointsHelper targetPointsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
List<MapMarker> markers = markersHelper.getSelectedMarkers();
|
||||
if (markers.size() > 0) {
|
||||
int i = 0;
|
||||
if (markersHelper.isStartFromMyLocation()) {
|
||||
targetPointsHelper.clearStartPoint(false);
|
||||
} else {
|
||||
MapMarker m = markers.get(i++);
|
||||
targetPointsHelper.setStartPoint(new LatLon(m.getLatitude(), m.getLongitude()),
|
||||
false, m.getPointDescription(mapActivity));
|
||||
}
|
||||
List<TargetPoint> targetPoints = new ArrayList<>();
|
||||
for (int k = i; k < markers.size(); k++) {
|
||||
MapMarker m = markers.get(k);
|
||||
TargetPoint t = new TargetPoint(new LatLon(m.getLatitude(), m.getLongitude()),
|
||||
m.getPointDescription(mapActivity));
|
||||
targetPoints.add(t);
|
||||
}
|
||||
if (mapActivity.getMyApplication().getSettings().ROUTE_MAP_MARKERS_ROUND_TRIP.get()) {
|
||||
TargetPoint end = targetPointsHelper.getPointToStart();
|
||||
if (end == null) {
|
||||
Location loc = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
if (loc != null) {
|
||||
end = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()),
|
||||
new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION,
|
||||
getString(R.string.shared_string_my_location)));
|
||||
}
|
||||
}
|
||||
if (end != null) {
|
||||
targetPoints.add(end);
|
||||
}
|
||||
}
|
||||
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||
boolean updateRoute = routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode();
|
||||
targetPointsHelper.reorderAllTargetPoints(targetPoints, updateRoute);
|
||||
hasTargets = true;
|
||||
} else {
|
||||
targetPointsHelper.clearStartPoint(false);
|
||||
targetPointsHelper.clearPointToNavigate(false);
|
||||
}
|
||||
dismiss();
|
||||
mapActivity.getMapLayers().getMapControlsLayer().doRoute(hasTargets);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeRoundTripOnClick() {
|
||||
if (mapActivity != null) {
|
||||
Toast.makeText(mapActivity, "make round trip", Toast.LENGTH_SHORT).show();
|
||||
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
||||
settings.ROUTE_MAP_MARKERS_ROUND_TRIP.set(!settings.ROUTE_MAP_MARKERS_ROUND_TRIP.get());
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,6 +455,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
public void reverseOrderOnClick() {
|
||||
if (mapActivity != null) {
|
||||
markersHelper.reverseActiveMarkersOrder();
|
||||
adapter.reloadData();
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
|
@ -539,7 +593,9 @@ public class PlanRouteFragment extends Fragment {
|
|||
|
||||
mapActivity.getMapView().setMapPosition(previousMapPosition);
|
||||
|
||||
planRouteContext.cancelSnapToRoad();
|
||||
if (cancelSnapToRoad) {
|
||||
planRouteContext.cancelSnapToRoad();
|
||||
}
|
||||
markersLayer.setRoute(null);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
@ -610,6 +666,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
private void showHideMarkersList() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null && portrait) {
|
||||
cancelSnapToRoad = false;
|
||||
planRouteContext.setMarkersListOpened(!planRouteContext.isMarkersListOpened());
|
||||
int containerRes = planRouteContext.isMarkersListOpened() ? R.id.fragmentContainer : R.id.bottomFragmentContainer;
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
|
@ -670,18 +727,21 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
|
||||
public boolean quit(boolean hideMarkersListFirst) {
|
||||
if (planRouteContext.isMarkersListOpened() && hideMarkersListFirst) {
|
||||
if (portrait && planRouteContext.isMarkersListOpened() && hideMarkersListFirst) {
|
||||
showHideMarkersList();
|
||||
return false;
|
||||
} else {
|
||||
dismiss(getMapActivity());
|
||||
dismiss();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void dismiss(MapActivity activity) {
|
||||
planRouteContext.setFragmentVisible(false);
|
||||
activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
||||
private void dismiss() {
|
||||
MapActivity activity = getMapActivity();
|
||||
if (activity != null) {
|
||||
planRouteContext.setFragmentVisible(false);
|
||||
activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean showInstance(MapActivity mapActivity) {
|
||||
|
@ -755,6 +815,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
|
||||
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
|
||||
adapter.reloadData();
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.view.ViewGroup;
|
|||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -59,6 +60,8 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
|||
((ImageView) mainView.findViewById(R.id.door_to_door_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_door_to_door));
|
||||
((ImageView) mainView.findViewById(R.id.reverse_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_reverse_order));
|
||||
|
||||
((CompoundButton) mainView.findViewById(R.id.make_round_trip_switch)).setChecked(getMyApplication().getSettings().ROUTE_MAP_MARKERS_ROUND_TRIP.get());
|
||||
|
||||
if (!portrait) {
|
||||
((ImageView) mainView.findViewById(R.id.select_icon))
|
||||
.setImageDrawable(getContentIcon(selectAll ? R.drawable.ic_action_select_all : R.drawable.ic_action_deselect_all));
|
||||
|
|
|
@ -11,7 +11,10 @@ import android.view.ViewGroup;
|
|||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
||||
import net.osmand.plus.GeocodingLookupService.OnAddressLookupResult;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -23,6 +26,7 @@ import net.osmand.util.MapUtils;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -33,13 +37,18 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
private static final int LOCATION_ITEM_ID = 0;
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private List<MapMarker> markers;
|
||||
private List<Object> items = new LinkedList<>();
|
||||
private MapMarkersListAdapterListener listener;
|
||||
|
||||
private int startPos = -1;
|
||||
private int finishPos = -1;
|
||||
private int firstSelectedMarkerPos = -1;
|
||||
|
||||
private boolean showLocationItem;
|
||||
private Location myLoc;
|
||||
private AddressLookupRequest locRequest;
|
||||
private PointDescription locDescription;
|
||||
|
||||
private Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints;
|
||||
|
||||
public void setAdapterListener(MapMarkersListAdapterListener listener) {
|
||||
|
@ -51,8 +60,10 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
}
|
||||
|
||||
public MapMarkersListAdapter(MapActivity mapActivity) {
|
||||
locDescription = new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION,
|
||||
mapActivity.getString(R.string.shared_string_location));
|
||||
this.mapActivity = mapActivity;
|
||||
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
|
||||
reloadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,16 +84,16 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
boolean night = app.getDaynightHelper().isNightModeForMapControls();
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
|
||||
boolean locationItem = pos == 0;
|
||||
boolean locationItem = showLocationItem && pos == 0;
|
||||
boolean firstMarkerItem = showLocationItem ? pos == 1 : pos == 0;
|
||||
boolean lastMarkerItem = pos == getItemCount() - 1;
|
||||
boolean start = pos == startPos;
|
||||
boolean finish = pos == finishPos && startPos != finishPos;
|
||||
boolean firstSelectedMarker = pos == firstSelectedMarkerPos;
|
||||
|
||||
Location myLoc = app.getLocationProvider().getLastStaleKnownLocation();
|
||||
boolean useLocation = app.getMapMarkersHelper().isStartFromMyLocation() && myLoc != null;
|
||||
boolean useLocation = app.getMapMarkersHelper().isStartFromMyLocation() && showLocationItem;
|
||||
|
||||
MapMarker marker = locationItem ? null : getItem(pos);
|
||||
MapMarker marker = locationItem ? null : (MapMarker) getItem(pos);
|
||||
|
||||
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.bg_color_dark : R.color.bg_color_light));
|
||||
holder.title.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.color_white : R.color.color_black));
|
||||
|
@ -99,10 +110,13 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
}
|
||||
});
|
||||
holder.bottomShadow.setVisibility(lastMarkerItem ? View.VISIBLE : View.GONE);
|
||||
holder.iconReorder.setVisibility(View.VISIBLE);
|
||||
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
|
||||
holder.description.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.dash_search_icon_dark : R.color.icon_color));
|
||||
|
||||
holder.firstDescription.setVisibility((start || finish) ? View.VISIBLE : View.GONE);
|
||||
if (start) {
|
||||
holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_control_start) + (locationItem && !useLocation ? "" : " • "));
|
||||
holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_control_start) + " • ");
|
||||
} else if (finish) {
|
||||
holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_finish) + " • ");
|
||||
}
|
||||
|
@ -116,24 +130,20 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
|
||||
if (locationItem) {
|
||||
holder.topDivider.setVisibility(View.VISIBLE);
|
||||
holder.flagIconLeftSpace.setVisibility(View.VISIBLE);
|
||||
holder.icon.setImageDrawable(ContextCompat.getDrawable(mapActivity, R.drawable.map_pedestrian_location));
|
||||
holder.point.setVisibility(View.GONE);
|
||||
holder.checkBox.setChecked(app.getMapMarkersHelper().isStartFromMyLocation());
|
||||
holder.iconReorder.setVisibility(View.GONE);
|
||||
holder.description.setVisibility(View.GONE);
|
||||
holder.iconReorder.setAlpha(.5f);
|
||||
holder.iconReorder.setOnTouchListener(null);
|
||||
holder.distance.setVisibility(View.GONE);
|
||||
holder.description.setText(locDescription.getName());
|
||||
} else {
|
||||
holder.topDivider.setVisibility(View.GONE);
|
||||
holder.flagIconLeftSpace.setVisibility(View.GONE);
|
||||
holder.topDivider.setVisibility((!showLocationItem && firstMarkerItem) ? View.VISIBLE : View.GONE);
|
||||
if (!iconSettled) {
|
||||
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex)));
|
||||
}
|
||||
holder.point.setVisibility(View.VISIBLE);
|
||||
holder.checkBox.setChecked(marker.selected);
|
||||
|
||||
holder.iconReorder.setVisibility(View.VISIBLE);
|
||||
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
|
||||
holder.iconReorder.setAlpha(1f);
|
||||
holder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent event) {
|
||||
|
@ -144,8 +154,6 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
}
|
||||
});
|
||||
|
||||
holder.description.setVisibility(View.VISIBLE);
|
||||
holder.description.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.dash_search_icon_dark : R.color.icon_color));
|
||||
String descr;
|
||||
if ((descr = marker.groupName) != null) {
|
||||
if (descr.equals("")) {
|
||||
|
@ -164,14 +172,16 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
}
|
||||
|
||||
boolean showDistance = locationItem ? useLocation : marker.selected;
|
||||
boolean showPoint = showDistance && !locationItem;
|
||||
holder.distance.setVisibility(showDistance ? View.VISIBLE : View.GONE);
|
||||
holder.point.setVisibility(showPoint ? View.VISIBLE : View.GONE);
|
||||
int visibility = showDistance ? View.VISIBLE : View.GONE;
|
||||
holder.distance.setVisibility(visibility);
|
||||
holder.point.setVisibility(visibility);
|
||||
holder.leftPointSpace.setVisibility(visibility);
|
||||
holder.rightPointSpace.setVisibility(visibility);
|
||||
if (showDistance) {
|
||||
holder.distance.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.color_distance : R.color.color_myloc_distance));
|
||||
LatLon first = firstSelectedMarker && useLocation
|
||||
? new LatLon(myLoc.getLatitude(), myLoc.getLongitude())
|
||||
: getPreviousSelectedMarkerLatLon(pos - 1);
|
||||
: getPreviousSelectedMarkerLatLon(pos);
|
||||
float dist = 0;
|
||||
if (first != null && marker != null) {
|
||||
WptPt pt1 = new WptPt();
|
||||
|
@ -196,16 +206,16 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position == 0 ? LOCATION_ITEM_ID : getItem(position).hashCode();
|
||||
return position == 0 && showLocationItem ? LOCATION_ITEM_ID : getItem(position).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return markers.size() + 1;
|
||||
return items.size();
|
||||
}
|
||||
|
||||
public MapMarker getItem(int position) {
|
||||
return markers.get(position - 1);
|
||||
public Object getItem(int position) {
|
||||
return items.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -215,10 +225,12 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
|
||||
@Override
|
||||
public boolean onItemMove(int from, int to) {
|
||||
if (to == 0) {
|
||||
if (showLocationItem && to == 0) {
|
||||
return false;
|
||||
}
|
||||
Collections.swap(markers, from - 1, to - 1);
|
||||
int offset = showLocationItem ? 1 : 0;
|
||||
Collections.swap(mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers(), from - offset, to - offset);
|
||||
Collections.swap(items, from, to);
|
||||
notifyItemMoved(from, to);
|
||||
return true;
|
||||
}
|
||||
|
@ -235,39 +247,82 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
|
||||
private LatLon getPreviousSelectedMarkerLatLon(int currentMarkerPos) {
|
||||
for (int i = currentMarkerPos - 1; i >= 0; i--) {
|
||||
MapMarker m = markers.get(i);
|
||||
if (m.selected) {
|
||||
return m.point;
|
||||
Object item = items.get(i);
|
||||
if (item instanceof MapMarker) {
|
||||
MapMarker m = (MapMarker) item;
|
||||
if (m.selected) {
|
||||
return m.point;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
items.clear();
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
myLoc = app.getLocationProvider().getLastStaleKnownLocation();
|
||||
showLocationItem = myLoc != null;
|
||||
if (showLocationItem) {
|
||||
lookupLocationAddress(app);
|
||||
items.add(myLoc);
|
||||
}
|
||||
items.addAll(mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers());
|
||||
}
|
||||
|
||||
private void lookupLocationAddress(OsmandApplication app) {
|
||||
LatLon loc = new LatLon(myLoc.getLatitude(), myLoc.getLongitude());
|
||||
if (locRequest == null || !locRequest.getLatLon().equals(loc)) {
|
||||
if (locRequest != null) {
|
||||
app.getGeocodingLookupService().cancel(locRequest);
|
||||
}
|
||||
locRequest = new AddressLookupRequest(loc, new OnAddressLookupResult() {
|
||||
@Override
|
||||
public void geocodingDone(String address) {
|
||||
locRequest = null;
|
||||
locDescription.setName(address);
|
||||
if (showLocationItem) {
|
||||
notifyItemChanged(0);
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
app.getGeocodingLookupService().lookupAddress(locRequest);
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateStartAndFinishPos() {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
boolean startCalculated = false;
|
||||
boolean finishCalculated = false;
|
||||
boolean firstSelectedMarkerCalculated = false;
|
||||
if (app.getMapMarkersHelper().isStartFromMyLocation() && app.getLocationProvider().getLastStaleKnownLocation() != null) {
|
||||
if (app.getMapMarkersHelper().isStartFromMyLocation() && showLocationItem) {
|
||||
startPos = 0;
|
||||
startCalculated = true;
|
||||
}
|
||||
for (int i = 0; i < markers.size(); i++) {
|
||||
if (markers.get(i).selected) {
|
||||
if (!startCalculated) {
|
||||
startPos = i + 1;
|
||||
startCalculated = true;
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Object item = items.get(i);
|
||||
if (item instanceof MapMarker) {
|
||||
MapMarker m = (MapMarker) item;
|
||||
if (m.selected) {
|
||||
if (!startCalculated) {
|
||||
startPos = i;
|
||||
startCalculated = true;
|
||||
}
|
||||
firstSelectedMarkerPos = i;
|
||||
firstSelectedMarkerCalculated = true;
|
||||
break;
|
||||
}
|
||||
firstSelectedMarkerPos = i + 1;
|
||||
firstSelectedMarkerCalculated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = markers.size() - 1; i >= 0; i--) {
|
||||
if (markers.get(i).selected) {
|
||||
finishPos = i + 1;
|
||||
finishCalculated = true;
|
||||
break;
|
||||
for (int i = items.size() - 1; i >= 0; i--) {
|
||||
Object item = items.get(i);
|
||||
if (item instanceof MapMarker) {
|
||||
MapMarker m = (MapMarker) item;
|
||||
if (m.selected) {
|
||||
finishPos = i;
|
||||
finishCalculated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!startCalculated) {
|
||||
|
|
|
@ -817,7 +817,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.map_widget_back_to_loc));
|
||||
}
|
||||
boolean visible = !(tracked && rh.isFollowingMode());
|
||||
backToLocationControl.updateVisibility(visible && !dialogOpened);
|
||||
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode());
|
||||
if (app.accessibilityEnabled()) {
|
||||
backToLocationControl.iv.setClickable(enabled && visible);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
|
||||
private final RenderingLineAttributes lineAttrs = new RenderingLineAttributes("measureDistanceLine");
|
||||
private final RenderingLineAttributes textAttrs = new RenderingLineAttributes("rulerLineFont");
|
||||
private Paint paint;
|
||||
private final RenderingLineAttributes planRouteAttrs = new RenderingLineAttributes("markerPlanRouteline");
|
||||
private TrkSegment route;
|
||||
|
||||
private TIntArrayList tx = new TIntArrayList();
|
||||
|
@ -81,6 +81,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
private ContextMenuLayer contextMenuLayer;
|
||||
|
||||
private boolean inPlanRouteMode;
|
||||
private boolean defaultAppMode = true;
|
||||
|
||||
public MapMarkersLayer(MapActivity map) {
|
||||
this.map = map;
|
||||
|
@ -98,6 +99,10 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
this.inPlanRouteMode = inPlanRouteMode;
|
||||
}
|
||||
|
||||
public void setDefaultAppMode(boolean defaultAppMode) {
|
||||
this.defaultAppMode = defaultAppMode;
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
bitmapPaint = new Paint();
|
||||
bitmapPaint.setDither(true);
|
||||
|
@ -120,15 +125,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
bitmapPaintDestTeal = createPaintDest(R.color.marker_teal);
|
||||
bitmapPaintDestPurple = createPaintDest(R.color.marker_purple);
|
||||
|
||||
paint = new Paint();
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(7 * view.getDensity());
|
||||
paint.setAntiAlias(true);
|
||||
paint.setStrokeCap(Paint.Cap.ROUND);
|
||||
paint.setStrokeJoin(Paint.Join.ROUND);
|
||||
paint.setColor(ContextCompat.getColor(map, R.color.marker_red));
|
||||
paint.setAlpha(200);
|
||||
|
||||
float textSize = TEXT_SIZE * map.getResources().getDisplayMetrics().density;
|
||||
textAttrs.paint.setTextSize(textSize);
|
||||
textAttrs.paint2.setTextSize(textSize);
|
||||
|
@ -207,12 +203,13 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
List<MapMarker> activeMapMarkers = markersHelper.getMapMarkers();
|
||||
|
||||
if (route != null && route.points.size() > 0) {
|
||||
planRouteAttrs.updatePaints(view, nightMode, tileBox);
|
||||
route.renders.clear();
|
||||
route.renders.add(new Renderable.StandardTrack(new ArrayList<>(route.points), 17.2));
|
||||
route.drawRenderers(view.getZoom(), paint, canvas, tileBox);
|
||||
route.drawRenderers(view.getZoom(), defaultAppMode ? planRouteAttrs.paint : planRouteAttrs.paint2, canvas, tileBox);
|
||||
}
|
||||
|
||||
if (markersHelper.isStartFromMyLocation() && myLoc != null) {
|
||||
if (map.getMyApplication().getSettings().SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) {
|
||||
lineAttrs.updatePaints(view, nightMode, tileBox);
|
||||
textAttrs.updatePaints(view, nightMode, tileBox);
|
||||
textAttrs.paint.setStyle(Paint.Style.FILL);
|
||||
|
@ -247,9 +244,9 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
float centerToMarkerDist = (float) MapUtils.getDistance(tileBox.getLatLonFromPixel(pos[0], pos[1]), marker.getLatitude(), marker.getLongitude());
|
||||
String centerToMarkerDistSt = OsmAndFormatter.getFormattedDistance(centerToMarkerDist, view.getApplication());
|
||||
if (locX >= markerX) {
|
||||
distanceText = centerToMarkerDistSt + " | " + generalDistSt;
|
||||
distanceText = centerToMarkerDistSt + " • " + generalDistSt;
|
||||
} else {
|
||||
distanceText = generalDistSt + " | " + centerToMarkerDistSt;
|
||||
distanceText = generalDistSt + " • " + centerToMarkerDistSt;
|
||||
}
|
||||
} else {
|
||||
distanceText = generalDistSt;
|
||||
|
|
Loading…
Reference in a new issue