Show distance and direction from cached location in context menu
This commit is contained in:
parent
b3eec3aace
commit
7dc6d1f42c
2 changed files with 22 additions and 7 deletions
|
@ -12,6 +12,7 @@ import android.view.View;
|
|||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
|
@ -25,6 +26,7 @@ import net.osmand.plus.GPXUtilities.WptPt;
|
|||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -290,9 +292,17 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
@Nullable PointDescription pointDescription,
|
||||
@Nullable Object object,
|
||||
boolean update, boolean restorePrevious) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
|
||||
if (myLocation == null) {
|
||||
myLocation = mapActivity.getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
Location loc = app.getLocationProvider().getLastKnownLocation();
|
||||
if (loc == null) {
|
||||
loc = app.getLocationProvider().getLastStaleKnownLocation();
|
||||
cachedMyLocation = loc != null;
|
||||
}
|
||||
if (loc != null) {
|
||||
myLocation = new LatLon(loc.getLatitude(), loc.getLongitude());
|
||||
}
|
||||
}
|
||||
|
||||
if (!update && isVisible()) {
|
||||
|
@ -350,9 +360,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
mapActivity.refreshMap();
|
||||
|
||||
if (object instanceof MapMarker) {
|
||||
mapActivity.getMyApplication().getMapMarkersHelper().addListener(this);
|
||||
app.getMapMarkersHelper().addListener(this);
|
||||
} else if (object instanceof TargetPoint) {
|
||||
mapActivity.getMyApplication().getTargetPointsHelper().addPointListener(this);
|
||||
app.getTargetPointsHelper().addPointListener(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -419,6 +429,12 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
init(latLon, pointDescription, object);
|
||||
}
|
||||
|
||||
public void onFragmentResume() {
|
||||
if (active && displayDistanceDirection() && myLocation != null) {
|
||||
updateLocation(false, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean navigateInPedestrianMode() {
|
||||
if (menuController != null) {
|
||||
return menuController.navigateInPedestrianMode();
|
||||
|
|
|
@ -33,7 +33,6 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadPoint;
|
||||
|
@ -48,8 +47,8 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
|||
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.TransportStopsLayer;
|
||||
|
@ -928,6 +927,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
((View) parent).addOnLayoutChangeListener(containerLayoutListener);
|
||||
}
|
||||
menu.updateControlsVisibility(true);
|
||||
menu.onFragmentResume();
|
||||
getMapActivity().getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
|
||||
}
|
||||
|
||||
|
@ -1221,8 +1221,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
OsmandApplication app = getMyApplication();
|
||||
if (app != null && view != null) {
|
||||
View compassView = view.findViewById(R.id.compass_layout);
|
||||
Location ll = app.getLocationProvider().getLastKnownLocation();
|
||||
if (ll != null && menu.displayDistanceDirection() && menu.getCurrentMenuState() != MenuState.FULL_SCREEN) {
|
||||
if (menu.getMyLocation() != null && menu.displayDistanceDirection() && menu.getCurrentMenuState() != MenuState.FULL_SCREEN) {
|
||||
updateDistanceDirection();
|
||||
compassView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue