diff --git a/OsmAnd/res/layout-land/fragment_plan_route.xml b/OsmAnd/res/layout-land/fragment_plan_route.xml
index ff21237f2e..d85da7b8fc 100644
--- a/OsmAnd/res/layout-land/fragment_plan_route.xml
+++ b/OsmAnd/res/layout-land/fragment_plan_route.xml
@@ -1,53 +1,35 @@
-
+ android:background="@android:color/transparent"
+ android:orientation="vertical">
+ android:layout_width="@dimen/dashboard_land_width"
+ android:layout_height="match_parent"
+ android:background="?attr/left_menu_view_bg"
+ android:orientation="vertical">
-
-
-
+ android:layout_height="@dimen/dashboard_map_toolbar"
+ android:background="?attr/bg_color"
+ android:minHeight="@dimen/dashboard_map_toolbar"
+ app:contentInsetLeft="54dp"
+ app:contentInsetStart="54dp">
-
-
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
+
+
-
+
diff --git a/OsmAnd/res/layout/fragment_map_markers_dialog.xml b/OsmAnd/res/layout/fragment_map_markers_dialog.xml
index f513542ed8..fafc9dc53b 100644
--- a/OsmAnd/res/layout/fragment_map_markers_dialog.xml
+++ b/OsmAnd/res/layout/fragment_map_markers_dialog.xml
@@ -2,9 +2,9 @@
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+ android:textSize="@dimen/dialog_header_text_size"
+ osmand:typeface="@string/font_roboto_medium"/>
+ android:textSize="@dimen/default_list_text_size"
+ osmand:typeface="@string/font_roboto_regular"/>
diff --git a/OsmAnd/res/layout/fragment_plan_route.xml b/OsmAnd/res/layout/fragment_plan_route.xml
index a4d2861a8a..e880146c09 100644
--- a/OsmAnd/res/layout/fragment_plan_route.xml
+++ b/OsmAnd/res/layout/fragment_plan_route.xml
@@ -113,18 +113,11 @@
osmand:typeface="@string/font_roboto_medium"/>
-
-
+ android:background="@color/ctx_menu_info_view_bg_dark">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml
index 7b17f3a440..7b10fff56d 100644
--- a/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml
+++ b/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml
@@ -32,6 +32,38 @@
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
+
+
+
+
+
+
+
1) {
+ WptPt wptPt = new WptPt();
+ wptPt.lon = Double.parseDouble(pointAttrs[0]);
+ wptPt.lat = Double.parseDouble(pointAttrs[1]);
+ ((TrkSegment) parse).points.add(wptPt);
+ if (arrLength > 2) {
+ wptPt.ele = Double.parseDouble(pointAttrs[2]);
+ }
+ }
+ } catch (NumberFormatException e) {
+ }
+ }
+ }
// main object to parse
} else if (parse instanceof WptPt) {
if (parser.getName().equals("name")) {
diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
index c295947bec..1f8023a472 100644
--- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
+++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
@@ -4,7 +4,6 @@ import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
-import android.util.Pair;
import net.osmand.IndexConstants;
import net.osmand.data.FavouritePoint;
@@ -16,6 +15,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
+import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@@ -28,7 +28,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER;
@@ -44,8 +43,7 @@ public class MapMarkersHelper {
private MapMarkersDbHelper markersDbHelper;
private boolean startFromMyLocation;
- private final Map, List> snappedToRoadPoints = new ConcurrentHashMap<>();
- private ApplicationMode snappedMode;
+ private MarkersPlanRouteContext planRouteContext;
public interface MapMarkerChangedListener {
void onMapMarkerChanged(MapMarker mapMarker);
@@ -230,22 +228,15 @@ public class MapMarkersHelper {
this.ctx = ctx;
settings = ctx.getSettings();
markersDbHelper = ctx.getMapMarkersDbHelper();
+ planRouteContext = new MarkersPlanRouteContext(ctx);
startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get();
removeDisabledGroups();
loadMarkers();
createMapMarkersGroups();
}
- public Map, List> getSnappedToRoadPoints() {
- return snappedToRoadPoints;
- }
-
- public ApplicationMode getSnappedMode() {
- return snappedMode;
- }
-
- public void setSnappedMode(ApplicationMode snappedMode) {
- this.snappedMode = snappedMode;
+ public MarkersPlanRouteContext getPlanRouteContext() {
+ return planRouteContext;
}
public boolean isStartFromMyLocation() {
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index a20d730996..a20e988e01 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -11,7 +11,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
-import android.graphics.Rect;
import android.media.AudioManager;
import android.net.Uri;
import android.os.AsyncTask;
@@ -59,7 +58,6 @@ import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.ApplicationMode;
-import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
@@ -315,6 +313,18 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
mIsDestroyed = false;
}
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ FragmentManager fm = getSupportFragmentManager();
+ Fragment planRouteFragment = fm.findFragmentByTag(PlanRouteFragment.TAG);
+ if (planRouteFragment != null) {
+ fm.beginTransaction()
+ .remove(planRouteFragment)
+ .commitNowAllowingStateLoss();
+ app.getMapMarkersHelper().getPlanRouteContext().setFragmentShowed(true);
+ }
+ super.onSaveInstanceState(outState);
+ }
private void checkAppInitialization() {
if (app.isApplicationInitializing()) {
@@ -447,7 +457,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
private void changeKeyguardFlags() {
if (settings.WAKE_ON_VOICE_INT.get() > 0) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED,
- WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}
@@ -558,6 +568,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
super.onResume();
long tm = System.currentTimeMillis();
+ if (app.getMapMarkersHelper().getPlanRouteContext().isFragmentShowed()) {
+ PlanRouteFragment.showInstance(getSupportFragmentManager(), AndroidUiHelper.isOrientationPortrait(this));
+ }
+
if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) {
if (!dashboardOnMap.isVisible()) {
if (settings.SHOW_DASHBOARD_ON_START.get()) {
@@ -1321,7 +1335,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
Intent intent = getIntent();
if (intent != null && intent.getData() != null) {
Uri data = intent.getData();
- if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme()))&& data.getHost() != null && data.getHost().contains("osmand.net") &&
+ if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme())) && data.getHost() != null && data.getHost().contains("osmand.net") &&
data.getPath() != null && data.getPath().startsWith("/go")) {
String lat = data.getQueryParameter("lat");
String lon = data.getQueryParameter("lon");
@@ -1730,7 +1744,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
public QuickSearchDialogFragment getQuickSearchDialogFragment() {
Fragment fragment = getSupportFragmentManager().findFragmentByTag(QuickSearchDialogFragment.TAG);
- return fragment!= null && !fragment.isDetached() && !fragment.isRemoving() ? (QuickSearchDialogFragment) fragment : null;
+ return fragment != null && !fragment.isDetached() && !fragment.isRemoving() ? (QuickSearchDialogFragment) fragment : null;
}
public PlanRouteFragment getPlanRouteFragment() {
diff --git a/OsmAnd/src/net/osmand/plus/helpers/kml2gpx.xslt b/OsmAnd/src/net/osmand/plus/helpers/kml2gpx.xslt
index 8b2677e875..2d5b32048a 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/kml2gpx.xslt
+++ b/OsmAnd/src/net/osmand/plus/helpers/kml2gpx.xslt
@@ -6,68 +6,69 @@
http://opensource.org/licenses/gpl-2.0.php
-->
-
+ xmlns:gx="http://www.google.com/kml/ext/2.2"
+ xmlns:kml="http://www.opengis.net/kml/2.2"
-
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -75,66 +76,76 @@
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -142,4 +153,4 @@
-
\ No newline at end of file
+
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java
index 413e330aae..3721a6f52d 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java
@@ -7,7 +7,6 @@ import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.SwitchCompat;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
@@ -183,10 +182,10 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java
index 6d751f9138..bdd6947c25 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java
@@ -43,7 +43,7 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialo
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
- boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
+ final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_history_bottom_sheet_dialog, container);
@@ -111,10 +111,10 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialo
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, nightMode,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, nightMode,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
index b1c17d407d..17287c5793 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java
@@ -25,6 +25,7 @@ import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TrackActivity;
+import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener;
import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener;
@@ -209,7 +210,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
@Override
public void buildRouteOnClick() {
- PlanRouteFragment.showInstance(mapActivity.getSupportFragmentManager());
+ PlanRouteFragment.showInstance(mapActivity.getSupportFragmentManager(), AndroidUiHelper.isOrientationPortrait(mapActivity));
dismiss();
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java
new file mode 100644
index 0000000000..22149490e0
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkersPlanRouteContext.java
@@ -0,0 +1,263 @@
+package net.osmand.plus.mapmarkers;
+
+import android.util.Pair;
+
+import net.osmand.Location;
+import net.osmand.data.LatLon;
+import net.osmand.plus.ApplicationMode;
+import net.osmand.plus.GPXUtilities.TrkSegment;
+import net.osmand.plus.GPXUtilities.WptPt;
+import net.osmand.plus.MapMarkersHelper;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.routing.RouteCalculationParams;
+import net.osmand.plus.routing.RoutingHelper;
+import net.osmand.router.RouteCalculationProgress;
+import net.osmand.util.MapUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+public class MarkersPlanRouteContext {
+
+ private static final int MAX_DIST_FOR_SNAP_TO_ROAD = 500 * 1000; // 500 km
+
+ private OsmandApplication app;
+
+ private final Map, List> snappedToRoadPoints = new ConcurrentHashMap<>();
+ private final Queue> snapToRoadPairsToCalculate = new ConcurrentLinkedQueue<>();
+ private final TrkSegment snapTrkSegment = new TrkSegment();
+
+ private ApplicationMode snappedMode;
+ private RouteCalculationProgress calculationProgress;
+ private int calculatedPairs;
+
+ private PlanRouteProgressListener listener;
+ private boolean progressBarVisible;
+ private boolean fragmentShowed;
+
+ Map, List> getSnappedToRoadPoints() {
+ return snappedToRoadPoints;
+ }
+
+ TrkSegment getSnapTrkSegment() {
+ return snapTrkSegment;
+ }
+
+ ApplicationMode getSnappedMode() {
+ return snappedMode;
+ }
+
+ void setSnappedMode(ApplicationMode snappedMode) {
+ this.snappedMode = snappedMode;
+ }
+
+ public PlanRouteProgressListener getListener() {
+ return listener;
+ }
+
+ public void setListener(PlanRouteProgressListener listener) {
+ this.listener = listener;
+ }
+
+ boolean isProgressBarVisible() {
+ return progressBarVisible;
+ }
+
+ void setProgressBarVisible(boolean progressBarVisible) {
+ this.progressBarVisible = progressBarVisible;
+ }
+
+ public boolean isFragmentShowed() {
+ return fragmentShowed;
+ }
+
+ public void setFragmentShowed(boolean fragmentShowed) {
+ this.fragmentShowed = fragmentShowed;
+ }
+
+ public MarkersPlanRouteContext(OsmandApplication app) {
+ this.app = app;
+ }
+
+ void cancelSnapToRoad() {
+ listener.hideProgressBar();
+ snapToRoadPairsToCalculate.clear();
+ if (calculationProgress != null) {
+ calculationProgress.isCancelled = true;
+ }
+ }
+
+ private void scheduleRouteCalculateIfNotEmpty(List points) {
+ if (points.isEmpty()) {
+ return;
+ }
+ findPairsToCalculate(points);
+ RoutingHelper routingHelper = app.getRoutingHelper();
+ if (!snapToRoadPairsToCalculate.isEmpty() && !routingHelper.isRouteBeingCalculated()) {
+ routingHelper.startRouteCalculationThread(getParams(), true, true);
+ app.runInUIThread(new Runnable() {
+ @Override
+ public void run() {
+ listener.showProgressBar();
+ }
+ });
+ }
+ }
+
+ private void findPairsToCalculate(List points) {
+ snapToRoadPairsToCalculate.clear();
+ for (int i = 0; i < points.size() - 1; i++) {
+ Pair pair = new Pair<>(points.get(i), points.get(i + 1));
+ if (snappedToRoadPoints.get(pair) == null) {
+ double dist = MapUtils.getDistance(pair.first.lat, pair.first.lon, pair.second.lat, pair.second.lon);
+ if (dist < MAX_DIST_FOR_SNAP_TO_ROAD) {
+ snapToRoadPairsToCalculate.add(pair);
+ }
+ }
+ }
+ }
+
+ void recreateSnapTrkSegment() {
+ recreateSnapTrkSegment(true);
+ }
+
+ private void recreateSnapTrkSegment(boolean adjustMap) {
+ snapTrkSegment.points.clear();
+ List points = getPointsToCalculate();
+ if (snappedMode == ApplicationMode.DEFAULT) {
+ snapTrkSegment.points.addAll(points);
+ } else if (points.size() > 1) {
+ for (int i = 0; i < points.size() - 1; i++) {
+ Pair pair = new Pair<>(points.get(i), points.get(i + 1));
+ List pts = snappedToRoadPoints.get(pair);
+ if (pts != null) {
+ snapTrkSegment.points.addAll(pts);
+ } else {
+ scheduleRouteCalculateIfNotEmpty(points);
+ snapTrkSegment.points.addAll(Arrays.asList(pair.first, pair.second));
+ }
+ }
+ }
+ listener.showMarkersRouteOnMap(adjustMap);
+ app.runInUIThread(new Runnable() {
+ @Override
+ public void run() {
+ listener.updateText();
+ }
+ });
+ }
+
+ private List getPointsToCalculate() {
+ MapMarkersHelper markersHelper = app.getMapMarkersHelper();
+ List points = new LinkedList<>();
+ Location myLoc = app.getLocationProvider().getLastStaleKnownLocation();
+ if (markersHelper.isStartFromMyLocation() && myLoc != null) {
+ addWptPt(points, myLoc.getLatitude(), myLoc.getLongitude());
+ }
+ for (LatLon l : markersHelper.getSelectedMarkersLatLon()) {
+ addWptPt(points, l.getLatitude(), l.getLongitude());
+ }
+ return points;
+ }
+
+ private void addWptPt(List points, double lat, double lon) {
+ WptPt pt = new WptPt();
+ pt.lat = lat;
+ pt.lon = lon;
+ points.add(pt);
+ }
+
+ private RouteCalculationParams getParams() {
+ final Pair currentPair = snapToRoadPairsToCalculate.poll();
+
+ Location start = new Location("");
+ start.setLatitude(currentPair.first.getLatitude());
+ start.setLongitude(currentPair.first.getLongitude());
+
+ LatLon end = new LatLon(currentPair.second.getLatitude(), currentPair.second.getLongitude());
+
+ final RouteCalculationParams params = new RouteCalculationParams();
+ params.inSnapToRoadMode = true;
+ params.start = start;
+ params.end = end;
+ RoutingHelper.applyApplicationSettings(params, app.getSettings(), snappedMode);
+ params.mode = snappedMode;
+ params.ctx = app;
+ params.calculationProgress = calculationProgress = new RouteCalculationProgress();
+ params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
+ @Override
+ public void updateProgress(int progress) {
+ int pairs = calculatedPairs + snapToRoadPairsToCalculate.size();
+ if (pairs != 0) {
+ int pairProgress = 100 / pairs;
+ progress = calculatedPairs * pairProgress + progress / pairs;
+ }
+ listener.updateProgress(progress);
+ }
+
+ @Override
+ public void requestPrivateAccessRouting() {
+
+ }
+
+ @Override
+ public void finish() {
+ calculatedPairs = 0;
+ }
+ };
+ params.resultListener = new RouteCalculationParams.RouteCalculationResultListener() {
+ @Override
+ public void onRouteCalculated(List locations) {
+ ArrayList pts = new ArrayList<>(locations.size());
+ for (Location loc : locations) {
+ WptPt pt = new WptPt();
+ pt.lat = loc.getLatitude();
+ pt.lon = loc.getLongitude();
+ pts.add(pt);
+ }
+ calculatedPairs++;
+ snappedToRoadPoints.put(currentPair, pts);
+ recreateSnapTrkSegment(false);
+ app.runInUIThread(new Runnable() {
+ @Override
+ public void run() {
+ listener.refresh();
+ }
+ });
+ if (!snapToRoadPairsToCalculate.isEmpty()) {
+ app.getRoutingHelper().startRouteCalculationThread(getParams(), true, true);
+ } else {
+ app.runInUIThread(new Runnable() {
+ @Override
+ public void run() {
+ listener.hideProgressBar();
+ }
+ });
+ }
+ }
+ };
+
+ return params;
+ }
+
+ interface PlanRouteProgressListener {
+
+ void showProgressBar();
+
+ void updateProgress(int progress);
+
+ void hideProgressBar();
+
+ void refresh();
+
+ void updateText();
+
+ void showMarkersRouteOnMap(boolean adjustMap);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java
index 6b7923a1cf..317b8188be 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java
@@ -39,7 +39,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
MapActivity mapActivity = (MapActivity) getActivity();
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
- boolean nightMode = !getMyApplication().getSettings().isLightContent();
+ final boolean nightMode = !getMyApplication().getSettings().isLightContent();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_options_bottom_sheet_dialog, container);
@@ -157,10 +157,10 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, nightMode,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, nightMode,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java
index 58b7a92e57..6ee9925660 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java
@@ -39,7 +39,7 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
settings = getMyApplication().getSettings();
- boolean night = !settings.isLightContent();
+ final boolean night = !settings.isLightContent();
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_order_by_bottom_sheet_dialog, container);
@@ -99,10 +99,10 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java
index 0eb07e5415..05152e0588 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java
@@ -12,8 +12,8 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper;
-import android.util.Pair;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
@@ -21,6 +21,7 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageButton;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -45,42 +46,34 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapmarkers.PlanRouteOptionsBottomSheetDialogFragment.PlanRouteOptionsFragmentListener;
import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback;
import net.osmand.plus.mapmarkers.adapters.MapMarkersListAdapter;
-import net.osmand.plus.measurementtool.RecyclerViewFragment;
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment;
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment.SnapToRoadFragmentListener;
-import net.osmand.plus.routing.RouteCalculationParams;
-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;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
-import net.osmand.router.RouteCalculationProgress;
import net.osmand.util.MapUtils;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT;
public class PlanRouteFragment extends Fragment {
public static final String TAG = "PlanRouteFragment";
- private static final int MAX_DIST_FOR_SNAP_TO_ROAD = 500 * 1000; // 500 km
private MapMarkersHelper markersHelper;
+ private MarkersPlanRouteContext planRouteContext;
+
private MapMarkersListAdapter adapter;
private IconsCache iconsCache;
private PlanRouteToolbarController toolbarController;
- private ApplicationMode appMode;
+
private int previousMapPosition;
private int selectedCount = 0;
-
private int toolbarHeight;
+ private int closedListContainerHeight;
private boolean nightMode;
private boolean portrait;
@@ -89,24 +82,46 @@ public class PlanRouteFragment extends Fragment {
private View mainView;
private RecyclerView markersRv;
- private ImageView upDownIconIv;
- private TextView distanceTv;
- private TextView timeTv;
- private TextView countTv;
-
- private final Queue> snapToRoadPairsToCalculate = new ConcurrentLinkedQueue<>();
- private Map, List> snappedToRoadPoints;
- private TrkSegment snapTrkSegment = new TrkSegment();
- private RouteCalculationProgress calculationProgress;
- private int calculatedPairs;
- private boolean progressBarVisible;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final MapActivity mapActivity = getMapActivity();
markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
- snappedToRoadPoints = markersHelper.getSnappedToRoadPoints();
+ planRouteContext = markersHelper.getPlanRouteContext();
+ planRouteContext.setListener(new MarkersPlanRouteContext.PlanRouteProgressListener() {
+ @Override
+ public void showProgressBar() {
+ PlanRouteFragment.this.showProgressBar();
+ }
+
+ @Override
+ public void updateProgress(int progress) {
+ ((ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar)).setProgress(progress);
+ }
+
+ @Override
+ public void hideProgressBar() {
+ mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
+ planRouteContext.setProgressBarVisible(false);
+ }
+
+ @Override
+ public void refresh() {
+ adapter.notifyDataSetChanged();
+ mapActivity.refreshMap();
+ }
+
+ @Override
+ public void updateText() {
+ PlanRouteFragment.this.updateText();
+ }
+
+ @Override
+ public void showMarkersRouteOnMap(boolean adjustMap) {
+ PlanRouteFragment.this.showMarkersRouteOnMap(adjustMap);
+ }
+ });
// Handling screen rotation
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
@@ -114,14 +129,11 @@ public class PlanRouteFragment extends Fragment {
if (snapToRoadFragment != null) {
((SnapToRoadBottomSheetDialogFragment) snapToRoadFragment).setListener(createSnapToRoadFragmentListener());
}
- Fragment sortByFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG);
- if (sortByFragment != null) {
- ((PlanRouteOptionsBottomSheetDialogFragment) sortByFragment).setListener(createOptionsFragmentListener());
- }
- // If rotate the screen from landscape to portrait when the list of markers is displayed then
- // the RecyclerViewFragment will exist without view. This is necessary to remove it.
- if (!portrait) {
- hideMarkersListFragment();
+ Fragment optionsFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG);
+ if (optionsFragment != null) {
+ PlanRouteOptionsBottomSheetDialogFragment fragment = (PlanRouteOptionsBottomSheetDialogFragment) optionsFragment;
+ fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
+ fragment.setListener(createOptionsFragmentListener());
}
toolbarHeight = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
@@ -136,101 +148,106 @@ public class PlanRouteFragment extends Fragment {
View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route, null);
mainView = view.findViewById(R.id.main_view);
- AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
-
- distanceTv = (TextView) mainView.findViewById(R.id.markers_distance_text_view);
- timeTv = (TextView) mainView.findViewById(R.id.markers_time_text_view);
- countTv = (TextView) mainView.findViewById(R.id.markers_count_text_view);
enterPlanRouteMode();
View markersListContainer = mainView.findViewById(R.id.markers_list_container);
- if (portrait && markersListContainer != null) {
+ if (markersListContainer != null) {
markersListContainer.setBackgroundColor(backgroundColor);
}
- upDownIconIv = (ImageView) mainView.findViewById(R.id.up_down_icon);
- upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
- ((ImageView) mainView.findViewById(R.id.sort_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_list_sort));
-
- mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (!markersListOpened) {
- showMarkersList();
- } else {
- hideMarkersList();
- }
- }
- });
-
- mainView.findViewById(R.id.select_all_button).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- int activeMarkersCount = markersHelper.getMapMarkers().size();
- if (selectedCount == activeMarkersCount && markersHelper.isStartFromMyLocation()) {
- markersHelper.deselectAllActiveMarkers();
- markersHelper.setStartFromMyLocation(false);
- selectedCount = 0;
- } else {
- markersHelper.selectAllActiveMarkers();
- markersHelper.setStartFromMyLocation(true);
- selectedCount = activeMarkersCount;
- }
- adapter.calculateStartAndFinishPos();
- adapter.notifyDataSetChanged();
- updateSelectButton();
- recreateSnapTrkSegment();
- mapActivity.refreshMap();
- }
- });
-
- mainView.findViewById(R.id.sort_button).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Toast.makeText(mapActivity, "Sort", Toast.LENGTH_SHORT).show();
- }
- });
-
- mainView.findViewById(R.id.save_button).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Toast.makeText(mapActivity, "Save", Toast.LENGTH_SHORT).show();
- }
- });
-
- toolbarController = new PlanRouteToolbarController();
- toolbarController.setBackBtnIconIds(R.drawable.ic_action_mode_back, R.drawable.ic_action_mode_back);
- toolbarController.setTitle(getString(R.string.plan_route));
- toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (quit(false)) {
- MapMarkersDialogFragment.showInstance(mapActivity);
- }
- }
- });
- toolbarController.setSaveViewTextId(R.string.shared_string_options);
- toolbarController.setOnSaveViewClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
- fragment.setListener(createOptionsFragmentListener());
- fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
- }
- });
- mapActivity.showTopToolbar(toolbarController);
-
if (portrait) {
- markersRv = mainView.findViewById(R.id.markers_recycler_view);
+ AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
+
+ ((ImageView) mainView.findViewById(R.id.up_down_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
+
+ mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (!markersListOpened) {
+ showMarkersList();
+ } else {
+ hideMarkersList();
+ }
+ }
+ });
+
+ mainView.findViewById(R.id.select_all_button).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ selectAllOnClick();
+ updateSelectButton();
+ }
+ });
+
+ toolbarController = new PlanRouteToolbarController();
+ toolbarController.setBackBtnIconIds(R.drawable.ic_action_mode_back, R.drawable.ic_action_mode_back);
+ toolbarController.setTitle(getString(R.string.plan_route));
+ toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (quit(false)) {
+ MapMarkersDialogFragment.showInstance(mapActivity);
+ }
+ }
+ });
+ toolbarController.setSaveViewTextId(R.string.shared_string_options);
+ toolbarController.setOnSaveViewClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ optionsOnClick();
+ }
+ });
+ mapActivity.showTopToolbar(toolbarController);
+
+ final int screenH = AndroidUtils.getScreenHeight(mapActivity);
+ final int statusBarH = AndroidUtils.getStatusBarHeight(mapActivity);
+ final int navBarH = AndroidUtils.getNavBarHeight(mapActivity);
+ final int availableHeight = (screenH - statusBarH - navBarH) / 2;
+
+ mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ int upDownRowH = mainView.findViewById(R.id.up_down_row).getHeight();
+ closedListContainerHeight = availableHeight - upDownRowH;
+ View listContainer = mainView.findViewById(R.id.markers_list_container);
+ listContainer.getLayoutParams().height = closedListContainerHeight;
+ listContainer.requestLayout();
+
+ ViewTreeObserver obs = mainView.getViewTreeObserver();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ obs.removeOnGlobalLayoutListener(this);
+ } else {
+ obs.removeGlobalOnLayoutListener(this);
+ }
+ }
+ });
} else {
- markersRv = new RecyclerView(mapActivity);
+ Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.plan_route_toolbar);
+ toolbar.setNavigationIcon(getContentIcon(R.drawable.ic_arrow_back));
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (quit(false)) {
+ MapMarkersDialogFragment.showInstance(mapActivity);
+ }
+ }
+ });
+
+ mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ optionsOnClick();
+ }
+ });
}
+ markersRv = mainView.findViewById(R.id.markers_recycler_view);
+
adapter = new MapMarkersListAdapter(mapActivity);
adapter.setHasStableIds(true);
adapter.calculateStartAndFinishPos();
- adapter.setSnappedToRoadPoints(snappedToRoadPoints);
+ adapter.setSnappedToRoadPoints(planRouteContext.getSnappedToRoadPoints());
final ItemTouchHelper touchHelper = new ItemTouchHelper(new MapMarkersItemTouchHelperCallback(adapter));
touchHelper.attachToRecyclerView(markersRv);
adapter.setAdapterListener(new MapMarkersListAdapter.MapMarkersListAdapterListener() {
@@ -255,7 +272,7 @@ public class PlanRouteFragment extends Fragment {
adapter.calculateStartAndFinishPos();
adapter.notifyDataSetChanged();
updateSelectButton();
- recreateSnapTrkSegment();
+ planRouteContext.recreateSnapTrkSegment();
}
@Override
@@ -278,7 +295,7 @@ public class PlanRouteFragment extends Fragment {
// to avoid crash because of:
// java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
}
- recreateSnapTrkSegment();
+ planRouteContext.recreateSnapTrkSegment();
}
}
});
@@ -287,48 +304,34 @@ public class PlanRouteFragment extends Fragment {
markersRv.setClipToPadding(false);
markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
markersRv.setAdapter(adapter);
- markersRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
- super.onScrollStateChanged(recyclerView, newState);
- }
- });
- final int screenH = AndroidUtils.getScreenHeight(mapActivity);
- final int statusBarH = AndroidUtils.getStatusBarHeight(mapActivity);
- final int navBarH = AndroidUtils.getNavBarHeight(mapActivity);
- final int availableHeight = (screenH - statusBarH - navBarH) / 2;
-
- mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- if (portrait) {
- int upDownRowH = mainView.findViewById(R.id.up_down_row).getHeight();
- int buttonsRowH = mainView.findViewById(R.id.buttons_row).getHeight();
- int listContainerH = availableHeight - upDownRowH - buttonsRowH;
- View listContainer = mainView.findViewById(R.id.markers_list_container);
- listContainer.getLayoutParams().height = listContainerH;
- listContainer.requestLayout();
- }
-
- showMarkersList();
-
- ViewTreeObserver obs = mainView.getViewTreeObserver();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- obs.removeOnGlobalLayoutListener(this);
- } else {
- obs.removeGlobalOnLayoutListener(this);
- }
- }
- });
-
- if (progressBarVisible) {
+ if (planRouteContext.isProgressBarVisible()) {
showProgressBar();
}
return view;
}
+ private void selectAllOnClick() {
+ int activeMarkersCount = markersHelper.getMapMarkers().size();
+ if (selectedCount == activeMarkersCount && markersHelper.isStartFromMyLocation()) {
+ markersHelper.deselectAllActiveMarkers();
+ markersHelper.setStartFromMyLocation(false);
+ selectedCount = 0;
+ } else {
+ markersHelper.selectAllActiveMarkers();
+ markersHelper.setStartFromMyLocation(true);
+ selectedCount = activeMarkersCount;
+ }
+ adapter.calculateStartAndFinishPos();
+ adapter.notifyDataSetChanged();
+ planRouteContext.recreateSnapTrkSegment();
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity != null) {
+ mapActivity.refreshMap();
+ }
+ }
+
@Override
public void onDestroyView() {
super.onDestroyView();
@@ -367,11 +370,10 @@ public class PlanRouteFragment extends Fragment {
@Override
public void onApplicationModeItemClick(ApplicationMode mode) {
- if (appMode != null && appMode != mode) {
- appMode = mode;
- snappedToRoadPoints.clear();
- markersHelper.setSnappedMode(mode);
- recreateSnapTrkSegment();
+ if (planRouteContext.getSnappedMode() != mode) {
+ planRouteContext.getSnappedToRoadPoints().clear();
+ planRouteContext.setSnappedMode(mode);
+ planRouteContext.recreateSnapTrkSegment();
setupAppModesBtn();
}
}
@@ -383,6 +385,11 @@ public class PlanRouteFragment extends Fragment {
private MapActivity mapActivity = getMapActivity();
+ @Override
+ public void selectOnClick() {
+ selectAllOnClick();
+ }
+
@Override
public void navigateOnClick() {
if (mapActivity != null) {
@@ -393,7 +400,7 @@ public class PlanRouteFragment extends Fragment {
@Override
public void makeRoundTripOnClick() {
if (mapActivity != null) {
- Toast.makeText(mapActivity, "mare round trip", Toast.LENGTH_SHORT).show();
+ Toast.makeText(mapActivity, "make round trip", Toast.LENGTH_SHORT).show();
}
}
@@ -415,12 +422,20 @@ public class PlanRouteFragment extends Fragment {
markersHelper.reverseActiveMarkersOrder();
adapter.calculateStartAndFinishPos();
adapter.notifyDataSetChanged();
- recreateSnapTrkSegment();
+ planRouteContext.recreateSnapTrkSegment();
}
}
};
}
+ private void showProgressBar() {
+ ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar);
+ progressBar.setVisibility(View.VISIBLE);
+ progressBar.setMinimumHeight(0);
+ progressBar.setProgress(0);
+ planRouteContext.setProgressBarVisible(true);
+ }
+
private void enterPlanRouteMode() {
final MapActivity mapActivity = getMapActivity();
MapMarkersLayer markersLayer = getMapMarkersLayer();
@@ -448,13 +463,19 @@ public class PlanRouteFragment extends Fragment {
wasCollapseButtonVisible = false;
}
- if ((appMode = markersHelper.getSnappedMode()) == null) {
- appMode = ApplicationMode.DEFAULT;
+ if (planRouteContext.getSnappedMode() == null) {
+ planRouteContext.setSnappedMode(ApplicationMode.DEFAULT);
}
setupAppModesBtn();
+ OsmandMapTileView tileView = mapActivity.getMapView();
+ previousMapPosition = tileView.getMapPosition();
+ if (!portrait) {
+ tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
+ }
+
selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount();
- recreateSnapTrkSegment();
+ planRouteContext.recreateSnapTrkSegment();
mapActivity.refreshMap();
updateSelectButton();
}
@@ -462,10 +483,10 @@ public class PlanRouteFragment extends Fragment {
private void setupAppModesBtn() {
final MapActivity mapActivity = getMapActivity();
- if (mapActivity != null && appMode != null) {
+ if (mapActivity != null) {
final ImageButton appModesBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
appModesBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
- appModesBtn.setImageDrawable(getActiveIcon(appMode.getSmallIconDark()));
+ appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getSmallIconDark()));
appModesBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -475,6 +496,11 @@ public class PlanRouteFragment extends Fragment {
fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG);
}
});
+ if (!portrait) {
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) appModesBtn.getLayoutParams();
+ params.leftMargin = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_land_width);
+ appModesBtn.setLayoutParams(params);
+ }
appModesBtn.setVisibility(View.VISIBLE);
}
}
@@ -508,15 +534,33 @@ public class PlanRouteFragment extends Fragment {
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
- cancelSnapToRoad();
+ mapActivity.getMapView().setMapPosition(previousMapPosition);
+
+ planRouteContext.cancelSnapToRoad();
markersLayer.setRoute(null);
mapActivity.refreshMap();
}
}
+ private void optionsOnClick() {
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity != null) {
+ PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
+ fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
+ fragment.setListener(createOptionsFragmentListener());
+ fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
+ }
+ }
+
private void updateText() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
+ TextView distanceTv = (TextView) mainView.findViewById(R.id.markers_distance_text_view);
+ TextView timeTv = (TextView) mainView.findViewById(R.id.markers_time_text_view);
+ TextView countTv = (TextView) mainView.findViewById(R.id.markers_count_text_view);
+
+ ApplicationMode appMode = planRouteContext.getSnappedMode();
+ TrkSegment snapTrkSegment = planRouteContext.getSnapTrkSegment();
boolean defaultMode = appMode == ApplicationMode.DEFAULT;
float dist = 0;
@@ -539,10 +583,12 @@ public class PlanRouteFragment extends Fragment {
}
private void updateSelectButton() {
- if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) {
- ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all));
- } else {
- ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all));
+ if (portrait) {
+ if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) {
+ ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all));
+ } else {
+ ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all));
+ }
}
}
@@ -558,70 +604,29 @@ public class PlanRouteFragment extends Fragment {
}
}
+ //todo create one method
private void showMarkersList() {
MapActivity mapActivity = getMapActivity();
- MapMarkersLayer markersLayer = getMapMarkersLayer();
- if (mapActivity != null && markersLayer != null) {
+ if (mapActivity != null && portrait) {
markersListOpened = true;
- upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_down));
+ mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.GONE);
+ ((ImageView) mainView.findViewById(R.id.up_down_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_down));
View listContainer = mainView.findViewById(R.id.markers_list_container);
- if (portrait && listContainer != null) {
- listContainer.setVisibility(View.VISIBLE);
- } else {
- showMarkersListFragment();
+ if (listContainer != null) {
+ listContainer.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
}
- OsmandMapTileView tileView = mapActivity.getMapView();
- previousMapPosition = tileView.getMapPosition();
- if (!portrait) {
- tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
- }
- mapActivity.refreshMap();
}
}
private void hideMarkersList() {
MapActivity mapActivity = getMapActivity();
- MapMarkersLayer markersLayer = getMapMarkersLayer();
- if (mapActivity != null && markersLayer != null) {
+ if (mapActivity != null && portrait) {
markersListOpened = false;
- upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
+ mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.VISIBLE);
+ ((ImageView) mainView.findViewById(R.id.up_down_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
View listContainer = mainView.findViewById(R.id.markers_list_container);
- if (portrait && listContainer != null) {
- listContainer.setVisibility(View.GONE);
- } else {
- hideMarkersListFragment();
- }
- mapActivity.getMapView().setMapPosition(previousMapPosition);
- mapActivity.refreshMap();
- }
- }
-
- private void showMarkersListFragment() {
- MapActivity mapActivity = getMapActivity();
- if (mapActivity != null) {
- View upDownRow = mainView.findViewById(R.id.up_down_row);
- int screenHeight = AndroidUtils.getScreenHeight(mapActivity) - AndroidUtils.getStatusBarHeight(mapActivity);
- RecyclerViewFragment fragment = new RecyclerViewFragment();
- fragment.setRecyclerView(markersRv);
- fragment.setWidth(upDownRow.getWidth());
- fragment.setHeight(screenHeight - upDownRow.getHeight());
- mapActivity.getSupportFragmentManager().beginTransaction()
- .add(R.id.fragmentContainer, fragment, RecyclerViewFragment.TAG)
- .commitAllowingStateLoss();
- }
- }
-
- private void hideMarkersListFragment() {
- MapActivity mapActivity = getMapActivity();
- if (mapActivity != null) {
- try {
- FragmentManager manager = mapActivity.getSupportFragmentManager();
- Fragment fragment = manager.findFragmentByTag(RecyclerViewFragment.TAG);
- if (fragment != null) {
- manager.beginTransaction().remove(fragment).commitNowAllowingStateLoss();
- }
- } catch (Exception e) {
- // ignore
+ if (listContainer != null) {
+ listContainer.getLayoutParams().height = closedListContainerHeight;
}
}
}
@@ -629,9 +634,9 @@ public class PlanRouteFragment extends Fragment {
private void showMarkersRouteOnMap(boolean adjustMap) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
- mapActivity.getMapLayers().getMapMarkersLayer().setRoute(snapTrkSegment);
+ mapActivity.getMapLayers().getMapMarkersLayer().setRoute(planRouteContext.getSnapTrkSegment());
if (adjustMap) {
- showRouteOnMap(snapTrkSegment.points);
+ showRouteOnMap(planRouteContext.getSnapTrkSegment().points);
}
}
}
@@ -670,14 +675,14 @@ public class PlanRouteFragment extends Fragment {
if (portrait) {
tileBoxHeightPx = 3 * (tb.getPixHeight() - mainView.getHeight() - toolbarHeight) / 4;
} else {
- tileBoxWidthPx = tb.getPixWidth() - mainView.findViewById(R.id.up_down_row).getWidth();
+ tileBoxWidthPx = tb.getPixWidth() - mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_land_width);
}
mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, toolbarHeight * 3 / 2);
}
}
public boolean quit(boolean hideMarkersListFirst) {
- if (markersListOpened && hideMarkersListFirst) {
+ if (portrait && markersListOpened && hideMarkersListFirst) {
hideMarkersList();
return false;
} else {
@@ -687,18 +692,19 @@ public class PlanRouteFragment extends Fragment {
}
private void dismiss(MapActivity activity) {
- if (markersListOpened) {
+ if (portrait && markersListOpened) {
hideMarkersList();
}
+ planRouteContext.setFragmentShowed(false);
activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
}
- public static boolean showInstance(FragmentManager fragmentManager) {
+ public static boolean showInstance(FragmentManager fragmentManager, boolean portrait) {
try {
PlanRouteFragment fragment = new PlanRouteFragment();
fragment.setRetainInstance(true);
fragmentManager.beginTransaction()
- .add(R.id.bottomFragmentContainer, fragment, PlanRouteFragment.TAG)
+ .add(portrait ? R.id.bottomFragmentContainer : R.id.topFragmentContainer, fragment, PlanRouteFragment.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {
@@ -764,204 +770,11 @@ public class PlanRouteFragment extends Fragment {
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
adapter.calculateStartAndFinishPos();
adapter.notifyDataSetChanged();
- recreateSnapTrkSegment();
+ planRouteContext.recreateSnapTrkSegment();
}
}.execute();
}
- private void cancelSnapToRoad() {
- hideProgressBar();
- snapToRoadPairsToCalculate.clear();
- if (calculationProgress != null) {
- calculationProgress.isCancelled = true;
- }
- }
-
- private void scheduleRouteCalculateIfNotEmpty(List points) {
- MapActivity mapActivity = getMapActivity();
- if (mapActivity == null || points.isEmpty()) {
- return;
- }
- findPairsToCalculate(points);
- OsmandApplication app = mapActivity.getMyApplication();
- RoutingHelper routingHelper = app.getRoutingHelper();
- if (!snapToRoadPairsToCalculate.isEmpty() && !routingHelper.isRouteBeingCalculated()) {
- routingHelper.startRouteCalculationThread(getParams(app), true, true);
- app.runInUIThread(new Runnable() {
- @Override
- public void run() {
- showProgressBar();
- }
- });
- }
- }
-
- private void findPairsToCalculate(List points) {
- snapToRoadPairsToCalculate.clear();
- for (int i = 0; i < points.size() - 1; i++) {
- Pair pair = new Pair<>(points.get(i), points.get(i + 1));
- if (snappedToRoadPoints.get(pair) == null) {
- double dist = MapUtils.getDistance(pair.first.lat, pair.first.lon, pair.second.lat, pair.second.lon);
- if (dist < MAX_DIST_FOR_SNAP_TO_ROAD) {
- snapToRoadPairsToCalculate.add(pair);
- }
- }
- }
- }
-
- private void recreateSnapTrkSegment() {
- recreateSnapTrkSegment(true);
- }
-
- private void recreateSnapTrkSegment(boolean adjustMap) {
- snapTrkSegment.points.clear();
- List points = getPointsToCalculate();
- if (appMode == ApplicationMode.DEFAULT) {
- snapTrkSegment.points.addAll(points);
- } else if (points.size() > 1) {
- for (int i = 0; i < points.size() - 1; i++) {
- Pair pair = new Pair<>(points.get(i), points.get(i + 1));
- List pts = snappedToRoadPoints.get(pair);
- if (pts != null) {
- snapTrkSegment.points.addAll(pts);
- } else {
- scheduleRouteCalculateIfNotEmpty(points);
- snapTrkSegment.points.addAll(Arrays.asList(pair.first, pair.second));
- }
- }
- }
- showMarkersRouteOnMap(adjustMap);
- MapActivity mapActivity = getMapActivity();
- if (mapActivity != null) {
- mapActivity.getMyApplication().runInUIThread(new Runnable() {
- @Override
- public void run() {
- updateText();
- }
- });
- }
- }
-
- private List getPointsToCalculate() {
- List points = new LinkedList<>();
- MapActivity mapActivity = getMapActivity();
- if (mapActivity != null) {
- Location myLoc = mapActivity.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
- if (markersHelper.isStartFromMyLocation() && myLoc != null) {
- addWptPt(points, myLoc.getLatitude(), myLoc.getLongitude());
- }
- for (LatLon l : markersHelper.getSelectedMarkersLatLon()) {
- addWptPt(points, l.getLatitude(), l.getLongitude());
- }
- }
- return points;
- }
-
- private void addWptPt(List points, double lat, double lon) {
- WptPt pt = new WptPt();
- pt.lat = lat;
- pt.lon = lon;
- points.add(pt);
- }
-
- private void showProgressBar() {
- ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar);
- progressBar.setVisibility(View.VISIBLE);
- progressBar.setMinimumHeight(0);
- progressBar.setProgress(0);
- progressBarVisible = true;
- }
-
- private void updateProgress(int progress) {
- ((ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar)).setProgress(progress);
- }
-
- private void refresh() {
- MapActivity mapActivity = getMapActivity();
- if (mapActivity != null) {
- mapActivity.refreshMap();
- }
- }
-
- private void hideProgressBar() {
- mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
- progressBarVisible = false;
- }
-
- private RouteCalculationParams getParams(final OsmandApplication app) {
- final Pair currentPair = snapToRoadPairsToCalculate.poll();
-
- Location start = new Location("");
- start.setLatitude(currentPair.first.getLatitude());
- start.setLongitude(currentPair.first.getLongitude());
-
- LatLon end = new LatLon(currentPair.second.getLatitude(), currentPair.second.getLongitude());
-
- final RouteCalculationParams params = new RouteCalculationParams();
- params.inSnapToRoadMode = true;
- params.start = start;
- params.end = end;
- RoutingHelper.applyApplicationSettings(params, app.getSettings(), appMode);
- params.mode = appMode;
- params.ctx = app;
- params.calculationProgress = calculationProgress = new RouteCalculationProgress();
- params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
- @Override
- public void updateProgress(int progress) {
- int pairs = calculatedPairs + snapToRoadPairsToCalculate.size();
- if (pairs != 0) {
- int pairProgress = 100 / pairs;
- progress = calculatedPairs * pairProgress + progress / pairs;
- }
- PlanRouteFragment.this.updateProgress(progress);
- }
-
- @Override
- public void requestPrivateAccessRouting() {
-
- }
-
- @Override
- public void finish() {
- calculatedPairs = 0;
- }
- };
- params.resultListener = new RouteCalculationParams.RouteCalculationResultListener() {
- @Override
- public void onRouteCalculated(List locations) {
- ArrayList pts = new ArrayList<>(locations.size());
- for (Location loc : locations) {
- WptPt pt = new WptPt();
- pt.lat = loc.getLatitude();
- pt.lon = loc.getLongitude();
- pts.add(pt);
- }
- calculatedPairs++;
- snappedToRoadPoints.put(currentPair, pts);
- recreateSnapTrkSegment(false);
- app.runInUIThread(new Runnable() {
- @Override
- public void run() {
- adapter.notifyDataSetChanged();
- refresh();
- }
- });
- if (!snapToRoadPairsToCalculate.isEmpty()) {
- app.getRoutingHelper().startRouteCalculationThread(getParams(app), true, true);
- } else {
- app.runInUIThread(new Runnable() {
- @Override
- public void run() {
- hideProgressBar();
- }
- });
- }
- }
- };
-
- return params;
- }
-
private class PlanRouteToolbarController extends TopToolbarController {
PlanRouteToolbarController() {
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java
index fe8c8259c2..48ef2ffb51 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java
@@ -28,11 +28,16 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
private boolean portrait;
private boolean night;
private PlanRouteOptionsFragmentListener listener;
+ private boolean selectAll;
public void setListener(PlanRouteOptionsFragmentListener listener) {
this.listener = listener;
}
+ public void setSelectAll(boolean selectAll) {
+ this.selectAll = selectAll;
+ }
+
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -54,6 +59,23 @@ 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));
+ if (!portrait) {
+ ((ImageView) mainView.findViewById(R.id.select_icon))
+ .setImageDrawable(getContentIcon(selectAll ? R.drawable.ic_action_select_all : R.drawable.ic_action_deselect_all));
+
+ ((TextView) mainView.findViewById(R.id.select_title))
+ .setText(getString(selectAll ? R.string.shared_string_select_all : R.string.shared_string_deselect_all));
+
+ View selectRow = mainView.findViewById(R.id.select_row);
+ selectRow.setVisibility(View.VISIBLE);
+ selectRow.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ listener.selectOnClick();
+ dismiss();
+ }
+ });
+ }
mainView.findViewById(R.id.navigate_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -117,10 +139,10 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(getActivity(), 8)) {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
@@ -155,6 +177,8 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
interface PlanRouteOptionsFragmentListener {
+ void selectOnClick();
+
void navigateOnClick();
void makeRoundTripOnClick();
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java
index b1aa3d0c3a..284454f23e 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java
@@ -4,7 +4,6 @@ import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.format.DateFormat;
-import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -25,11 +24,7 @@ import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import java.io.File;
-import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.Locale;
-
-import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import static net.osmand.plus.helpers.GpxImportHelper.GPX_SUFFIX;
@@ -49,7 +44,7 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
MapActivity mapActivity = (MapActivity) getActivity();
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
- boolean nightMode = !getMyApplication().getSettings().isLightContent();
+ final boolean nightMode = !getMyApplication().getSettings().isLightContent();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_save_as_track_bottom_sheet_dialog, container);
@@ -126,10 +121,10 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, nightMode,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, nightMode,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java
index 059dbc7557..21d63045e3 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java
@@ -160,10 +160,10 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
- AndroidUtils.setBackground(getActivity(), mainView, false,
+ AndroidUtils.setBackground(getActivity(), mainView, night,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}