Alexey Kulish 2016-01-30 13:23:09 +03:00
parent 70366e6b76
commit a14fd90eab
7 changed files with 58 additions and 34 deletions

View file

@ -143,6 +143,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
private AppInitializeListener initListener; private AppInitializeListener initListener;
private IMapDownloaderCallback downloaderCallback; private IMapDownloaderCallback downloaderCallback;
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
private boolean drawerDisabled;
private Notification getNotification() { private Notification getNotification() {
Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity()); Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity());
@ -1034,13 +1035,19 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
} }
public void disableDrawer() { public void disableDrawer() {
drawerDisabled = true;
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
} }
public void enableDrawer() { public void enableDrawer() {
drawerDisabled = false;
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
} }
public boolean isDrawerDisabled() {
return drawerDisabled;
}
public void closeDrawer() { public void closeDrawer() {
drawerLayout.closeDrawer(Gravity.LEFT); drawerLayout.closeDrawer(Gravity.LEFT);
} }

View file

@ -416,9 +416,7 @@ public class MapActivityActions implements DialogProvider {
app.getRoutingHelper().setFollowingMode(false); app.getRoutingHelper().setFollowingMode(false);
app.getRoutingHelper().setRoutePlanningMode(true); app.getRoutingHelper().setRoutePlanningMode(true);
// reset start point // reset start point
if (targets.getPointToStart() == null) { targets.setStartPoint(from, false, fromName);
targets.setStartPoint(from, false, fromName);
}
// then set gpx // then set gpx
setGPXRouteParams(gpxFile); setGPXRouteParams(gpxFile);
// then update start and destination point // then update start and destination point

View file

@ -168,7 +168,9 @@ public class FailSafeFuntions {
app.getSettings().FOLLOW_THE_GPX_ROUTE.set(null); app.getSettings().FOLLOW_THE_GPX_ROUTE.set(null);
} }
routingHelper.setGpxParams(gpxRoute); routingHelper.setGpxParams(gpxRoute);
app.getTargetPointsHelper().setStartPoint(null, false, null); if (app.getTargetPointsHelper().getPointToStart() == null) {
app.getTargetPointsHelper().setStartPoint(null, false, null);
}
app.getSettings().FOLLOW_THE_ROUTE.set(true); app.getSettings().FOLLOW_THE_ROUTE.set(true);
routingHelper.setFollowingMode(true); routingHelper.setFollowingMode(true);
app.getTargetPointsHelper().updateRouteAndRefresh(true); app.getTargetPointsHelper().updateRouteAndRefresh(true);

View file

@ -1,6 +1,7 @@
package net.osmand.plus.base; package net.osmand.plus.base;
import java.util.List; import android.content.Context;
import android.view.WindowManager;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.StateChangedListener; import net.osmand.StateChangedListener;
@ -16,7 +17,6 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AutoZoomMap; import net.osmand.plus.OsmandSettings.AutoZoomMap;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
@ -24,8 +24,8 @@ import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.content.Context;
import android.view.WindowManager; import java.util.List;
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener, IRouteInformationListener { public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener, IRouteInformationListener {
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4; private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
@ -272,7 +272,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
app.runMessageInUIThreadAndCancelPrevious(AUTO_FOLLOW_MSG_ID, new Runnable() { app.runMessageInUIThreadAndCancelPrevious(AUTO_FOLLOW_MSG_ID, new Runnable() {
@Override @Override
public void run() { public void run() {
if (mapView != null && !isMapLinkedToLocation()) { if (mapView != null && !isMapLinkedToLocation() && contextMenu == null) {
app.showToastMessage(R.string.auto_follow_location_enabled); app.showToastMessage(R.string.auto_follow_location_enabled);
backToLocationImpl(); backToLocationImpl();
} }
@ -285,9 +285,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
} }
public void setMapLinkedToLocation(boolean isMapLinkedToLocation) { public void setMapLinkedToLocation(boolean isMapLinkedToLocation) {
if(!isMapLinkedToLocation){ if (!isMapLinkedToLocation) {
int autoFollow = settings.AUTO_FOLLOW_ROUTE.get(); int autoFollow = settings.AUTO_FOLLOW_ROUTE.get();
if(autoFollow > 0 && app.getRoutingHelper().isFollowingMode() && !routePlanningMode){ if (autoFollow > 0 && app.getRoutingHelper().isFollowingMode() && !routePlanningMode) {
backToLocationWithDelay(autoFollow); backToLocationWithDelay(autoFollow);
} }
} }

View file

@ -95,6 +95,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
private boolean nightMode; private boolean nightMode;
private boolean centered; private boolean centered;
private boolean initLayout = true; private boolean initLayout = true;
private boolean wasDrawerDisabled;
private float skipHalfScreenStateLimit; private float skipHalfScreenStateLimit;
@ -657,14 +658,21 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
return; return;
} }
screenOrientation = DashLocationFragment.getScreenOrientation(getActivity()); screenOrientation = DashLocationFragment.getScreenOrientation(getActivity());
if (menu.displayDistanceDirection()) { getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu);
getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu); getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false);
wasDrawerDisabled = getMapActivity().isDrawerDisabled();
if (!wasDrawerDisabled) {
getMapActivity().disableDrawer();
} }
} }
@Override @Override
public void onPause() { public void onPause() {
getMapActivity().getMapViewTrackingUtilities().setContextMenu(null); getMapActivity().getMapViewTrackingUtilities().setContextMenu(null);
getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false);
if (!wasDrawerDisabled) {
getMapActivity().enableDrawer();
}
super.onPause(); super.onPause();
} }

View file

@ -24,29 +24,30 @@ public class TargetPointMenuController extends MenuController {
final int intermediatePointsCount = targetPointsHelper.getIntermediatePoints().size(); final int intermediatePointsCount = targetPointsHelper.getIntermediatePoints().size();
RoutingHelper routingHelper = getMapActivity().getMyApplication().getRoutingHelper(); RoutingHelper routingHelper = getMapActivity().getMyApplication().getRoutingHelper();
final boolean nav = routingHelper.isRoutePlanningMode() || routingHelper.isFollowingMode(); final boolean nav = routingHelper.isRoutePlanningMode() || routingHelper.isFollowingMode();
if (!targetPoint.start) { leftTitleButtonController = new TitleButtonController() {
leftTitleButtonController = new TitleButtonController() { @Override
@Override public void buttonPressed() {
public void buttonPressed() { TargetPoint tp = getTargetPoint();
TargetPoint tp = getTargetPoint(); if (tp.start) {
if (tp.intermediate) { getMapActivity().getMyApplication().getTargetPointsHelper().clearStartPoint(true);
targetPointsHelper.removeWayPoint(true, tp.index); } else if (tp.intermediate) {
} else { targetPointsHelper.removeWayPoint(true, tp.index);
targetPointsHelper.removeWayPoint(true, -1); } else {
} targetPointsHelper.removeWayPoint(true, -1);
getMapActivity().getContextMenu().close(); }
if (nav && intermediatePointsCount == 0) { getMapActivity().getContextMenu().close();
getMapActivity().getMapActions().stopNavigationWithoutConfirm(); if (nav && intermediatePointsCount == 0 && !tp.start) {
} getMapActivity().getMapActions().stopNavigationWithoutConfirm();
getMapActivity().getMyApplication().getTargetPointsHelper().clearStartPoint(false);
} }
};
if (nav && intermediatePointsCount == 0) {
leftTitleButtonController.caption = getMapActivity().getString(R.string.cancel_navigation);
leftTitleButtonController.leftIconId = R.drawable.ic_action_remove_dark;
} else {
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_remove);
leftTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
} }
};
if (nav && intermediatePointsCount == 0 && !targetPoint.start) {
leftTitleButtonController.caption = getMapActivity().getString(R.string.cancel_navigation);
leftTitleButtonController.leftIconId = R.drawable.ic_action_remove_dark;
} else {
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_remove);
leftTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
} }
} }

View file

@ -37,6 +37,7 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
private ArrayAdapter<MenuObject> listAdapter; private ArrayAdapter<MenuObject> listAdapter;
private MapMultiSelectionMenu menu; private MapMultiSelectionMenu menu;
private boolean dismissing = false; private boolean dismissing = false;
private boolean wasDrawerDisabled;
@Nullable @Nullable
@Override @Override
@ -67,6 +68,10 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
wasDrawerDisabled = menu.getMapActivity().isDrawerDisabled();
if (!wasDrawerDisabled) {
menu.getMapActivity().disableDrawer();
}
menu.getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false); menu.getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false);
menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(false); menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(false);
} }
@ -79,6 +84,9 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
} }
menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(true); menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(true);
menu.getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true); menu.getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true);
if (!wasDrawerDisabled) {
menu.getMapActivity().enableDrawer();
}
} }
public static void showInstance(final MapActivity mapActivity) { public static void showInstance(final MapActivity mapActivity) {