Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-10-11 18:43:19 +02:00
commit 9dfdbd2078
16 changed files with 291 additions and 97 deletions

View file

@ -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"

View file

@ -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"

View file

@ -3508,4 +3508,6 @@
<string name="poi_government_transportation">Транспортное учреждение</string>
<string name="poi_government_legislative">Законодательное учреждение</string>
<string name="poi_surface_clay">Глина</string>
</resources>

View file

@ -2490,7 +2490,7 @@
<string name="of">%1$d из %2$d</string>
<string name="shared_string_list">Список</string>
<string name="shared_string_groups">Группы</string>
<string name="passed">Последнее использование: %1$s</string>
<string name="passed">Пройдено: %1$s</string>
<string name="make_active">Сделать активным</string>
<string name="today">Сегодня</string>
<string name="yesterday">Вчера</string>

View file

@ -3485,4 +3485,14 @@
<string name="poi_vhf">VHF channel</string>
<string name="poi_gorge">Gorge</string>
<string name="poi_couloir">Couloir</string>
<string name="poi_mountain_area">Mountain area</string>
<string name="poi_surface_clay">Clay</string>
<string name="poi_surface_tartan">Tartan</string>
<string name="poi_surface_artificial_turf">Artificial turf</string>
<string name="poi_surface_decoturf">DecoTurf</string>
<string name="poi_surface_metal_grid">Metal grid</string>
</resources>

View file

@ -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();

View file

@ -1440,7 +1440,7 @@ public class GpxUiHelper {
calculatedH[k] = ph + (values.get(nextW).getY() - ph) / (values.get(nextW).getX() - pd) * (calculatedDist[k] - pd);
}
double SLOPE_PROXIMITY = 150;
double SLOPE_PROXIMITY = 100;
if (totalDistance - SLOPE_PROXIMITY < 0) {
if (useRightAxis) {

View file

@ -889,26 +889,31 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
}
int dp16 = dpToPx(16f);
boolean has16margin = false;
int titleButtonHeight = 0;
View titleButtonContainer = view.findViewById(R.id.title_button_container);
if (titleButtonContainer.getVisibility() == View.VISIBLE) {
titleButtonHeight = titleButtonContainer.getMeasuredHeight() - dp16;
if (titleButtonHeight < 0) {
titleButtonHeight = 0;
} else {
has16margin = true;
}
}
int downloadButtonsHeight = 0;
View downloadButtonsContainer = view.findViewById(R.id.download_buttons_container);
if (downloadButtonsContainer.getVisibility() == View.VISIBLE) {
downloadButtonsHeight = downloadButtonsContainer.getMeasuredHeight() - dp16;
downloadButtonsHeight = downloadButtonsContainer.getMeasuredHeight() - (has16margin ? 0 : dp16);
if (downloadButtonsHeight < 0) {
downloadButtonsHeight = 0;
} else {
has16margin = true;
}
}
int titleProgressHeight = 0;
View titleProgressContainer = view.findViewById(R.id.title_progress_container);
if (titleProgressContainer.getVisibility() == View.VISIBLE) {
titleProgressHeight = titleProgressContainer.getMeasuredHeight() - dp16;
titleProgressHeight = titleProgressContainer.getMeasuredHeight() - (has16margin ? 0 : dp16);
if (titleProgressHeight < 0) {
titleProgressHeight = 0;
}

View file

@ -11,6 +11,7 @@ import net.osmand.data.TransportStop;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
@ -104,6 +105,12 @@ public class AmenityMenuController extends MenuController {
return true;
}
@Override
public String getNameStr() {
OsmandSettings settings = getMapActivity().getMyApplication().getSettings();
return amenity.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get());
}
@Override
public String getTypeStr() {
return getTypeStr(amenity);

View file

@ -55,7 +55,7 @@ public class RenderedObjectMenuController extends MenuController {
@Override
public String getNameStr() {
if (!Algorithms.isEmpty(renderedObject.getName())) {
if (!Algorithms.isEmpty(renderedObject.getName()) && !isStartingWithRTLChar(renderedObject.getName())) {
return renderedObject.getName();
} else if (renderedObject.getTags().size() > 0) {
String lang = getMapActivity().getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get().toLowerCase();
@ -67,6 +67,8 @@ public class RenderedObjectMenuController extends MenuController {
name = renderedObject.getTags().get("name");
}
return name;
} else if (!Algorithms.isEmpty(renderedObject.getName())) {
return renderedObject.getName();
}
return "";
}
@ -97,4 +99,13 @@ public class RenderedObjectMenuController extends MenuController {
}
addMyLocationToPlainItems(latLon);
}
private boolean isStartingWithRTLChar(String s) {
byte directionality = Character.getDirectionality(s.charAt(0));
return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT
|| directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
|| directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
|| directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE;
}
}

View file

@ -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;
}

View file

@ -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;
@ -38,9 +38,12 @@ import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
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 +51,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;
@ -59,9 +63,10 @@ import java.util.List;
import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT;
public class PlanRouteFragment extends Fragment {
public class PlanRouteFragment extends Fragment implements OsmAndLocationListener {
public static final String TAG = "PlanRouteFragment";
private static final int MIN_DISTANCE_FOR_RECALCULATE = 50; // in meters
private MapMarkersHelper markersHelper;
private MarkersPlanRouteContext planRouteContext;
@ -78,6 +83,9 @@ public class PlanRouteFragment extends Fragment {
private boolean nightMode;
private boolean portrait;
private boolean wasCollapseButtonVisible;
private boolean cancelSnapToRoad = true;
private Location location;
private View mainView;
private RecyclerView markersRv;
@ -251,7 +259,6 @@ public class PlanRouteFragment extends Fragment {
adapter = new MapMarkersListAdapter(mapActivity);
adapter.setHasStableIds(true);
adapter.calculateStartAndFinishPos();
adapter.setSnappedToRoadPoints(planRouteContext.getSnappedToRoadPoints());
final ItemTouchHelper touchHelper = new ItemTouchHelper(new MapMarkersItemTouchHelperCallback(adapter));
touchHelper.attachToRecyclerView(markersRv);
@ -266,10 +273,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 +313,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);
@ -317,12 +325,59 @@ public class PlanRouteFragment extends Fragment {
return view;
}
@Override
public void onResume() {
super.onResume();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMyApplication().getLocationProvider().addLocationListener(this);
}
}
@Override
public void onPause() {
super.onPause();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMyApplication().getLocationProvider().removeLocationListener(this);
}
}
@Override
public void onDestroyView() {
super.onDestroyView();
exitPlanRouteMode();
}
@Override
public void updateLocation(Location loc) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
final Location location = mapActivity.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
boolean newLocation = (this.location == null && location != null) || location == null;
boolean locationChanged = this.location != null && location != null
&& this.location.getLatitude() != location.getLatitude()
&& this.location.getLongitude() != location.getLongitude();
boolean farEnough = locationChanged && MapUtils.getDistance(this.location.getLatitude(), this.location.getLongitude(),
location.getLatitude(), location.getLongitude()) >= MIN_DISTANCE_FOR_RECALCULATE;
if (newLocation || farEnough) {
mapActivity.getMyApplication().runInUIThread(new Runnable() {
@Override
public void run() {
PlanRouteFragment.this.location = location;
adapter.reloadData();
try {
adapter.notifyDataSetChanged();
} catch (Exception e) {
// to avoid crash because of:
// java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
}
}
});
}
}
}
private MapActivity getMapActivity() {
return (MapActivity) getActivity();
}
@ -353,6 +408,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 +434,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,7 +505,7 @@ public class PlanRouteFragment extends Fragment {
public void reverseOrderOnClick() {
if (mapActivity != null) {
markersHelper.reverseActiveMarkersOrder();
adapter.calculateStartAndFinishPos();
adapter.reloadData();
adapter.notifyDataSetChanged();
planRouteContext.recreateSnapTrkSegment();
}
@ -539,7 +642,9 @@ public class PlanRouteFragment extends Fragment {
mapActivity.getMapView().setMapPosition(previousMapPosition);
if (cancelSnapToRoad) {
planRouteContext.cancelSnapToRoad();
}
markersLayer.setRoute(null);
mapActivity.refreshMap();
}
@ -610,6 +715,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,19 +776,22 @@ 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) {
private void dismiss() {
MapActivity activity = getMapActivity();
if (activity != null) {
planRouteContext.setFragmentVisible(false);
activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
}
}
public static boolean showInstance(MapActivity mapActivity) {
try {
@ -755,7 +864,7 @@ public class PlanRouteFragment extends Fragment {
}
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
adapter.calculateStartAndFinishPos();
adapter.reloadData();
adapter.notifyDataSetChanged();
planRouteContext.recreateSnapTrkSegment();
}

View file

@ -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));

View file

@ -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,41 +247,85 @@ 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);
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());
calculateStartAndFinishPos();
}
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) {
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 + 1;
startPos = i;
startCalculated = true;
}
firstSelectedMarkerPos = i + 1;
firstSelectedMarkerPos = i;
firstSelectedMarkerCalculated = true;
break;
}
}
for (int i = markers.size() - 1; i >= 0; i--) {
if (markers.get(i).selected) {
finishPos = i + 1;
}
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) {
startPos = -1;
}

View file

@ -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);
}

View file

@ -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;