Enable setting to show view angle by default, when there is no speed
This commit is contained in:
parent
b55a971f8a
commit
71625c67cc
7 changed files with 42 additions and 52 deletions
|
@ -15,7 +15,5 @@
|
|||
<CheckBoxPreference android:title="@string/snap_to_road" android:summary="@string/snap_to_road_descr" android:key="snap_to_road"></CheckBoxPreference>
|
||||
<Preference android:title="@string/show_warnings_title" android:summary="@string/show_warnings_descr" android:key="show_routing_alarms"/>
|
||||
<Preference android:title="@string/speak_title" android:summary="@string/speak_descr" android:key="speak_routing_alarms"/>
|
||||
<CheckBoxPreference android:summary="@string/use_compass_navigation_descr" android:title="@string/use_compass_navigation"
|
||||
android:key="use_compass_navigation"></CheckBoxPreference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -831,12 +831,12 @@ public class OsmandSettings {
|
|||
new IntPreference("map_screen_orientation", -1/*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/).makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<Boolean> SHOW_VIEW_ANGLE = new BooleanPreference("show_view_angle", false).makeProfile().cache();
|
||||
{
|
||||
SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.CAR, false);
|
||||
SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.BICYCLE, true);
|
||||
SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
|
||||
}
|
||||
// public final CommonPreference<Boolean> SHOW_VIEW_ANGLE = new BooleanPreference("show_view_angle", false).makeProfile().cache();
|
||||
// {
|
||||
// SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.CAR, false);
|
||||
// SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.BICYCLE, true);
|
||||
// SHOW_VIEW_ANGLE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
|
||||
// }
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
// seconds to auto_follow
|
||||
|
@ -1544,12 +1544,6 @@ public class OsmandSettings {
|
|||
};
|
||||
}.makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
//public final OsmandPreference<Boolean> USE_COMPASS_IN_NAVIGATION = new BooleanPreference("use_compass_navigation", true).makeProfile().cache();
|
||||
public final CommonPreference<Boolean> USE_COMPASS_IN_NAVIGATION = new BooleanPreference("use_compass_navigation", true).makeProfile().cache();
|
||||
{
|
||||
USE_COMPASS_IN_NAVIGATION.setModeDefaultValue(ApplicationMode.CAR, false);
|
||||
}
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<String> RENDERER = new StringPreference("renderer", RendererRegistry.DEFAULT_RENDER) {
|
||||
|
|
|
@ -136,7 +136,7 @@ public class MapActivityLayers {
|
|||
transportInfoLayer = new TransportInfoLayer(TransportRouteHelper.getInstance());
|
||||
mapView.addLayer(transportInfoLayer, 5.5f);
|
||||
// 6. point location layer
|
||||
locationLayer = new PointLocationLayer();
|
||||
locationLayer = new PointLocationLayer(activity.getMapViewTrackingUtilities());
|
||||
mapView.addLayer(locationLayer, 6);
|
||||
// 7. point navigation layer
|
||||
navigationLayer = new PointNavigationLayer(activity);
|
||||
|
|
|
@ -64,7 +64,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
|
||||
|
||||
registerBooleanPreference(settings.SNAP_TO_ROAD, screen);
|
||||
registerBooleanPreference(settings.USE_COMPASS_IN_NAVIGATION, screen);
|
||||
|
||||
Integer[] intValues = new Integer[] { 0, 5, 10, 15, 20, 25, 30, 45, 60, 90};
|
||||
entries = new String[intValues.length];
|
||||
|
|
|
@ -27,7 +27,6 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
|
||||
|
||||
private long lastTimeAutoZooming = 0;
|
||||
private long lastTimeSensorMapRotation = 0;
|
||||
private boolean sensorRegistered = false;
|
||||
private OsmandMapTileView mapView;
|
||||
private OsmandSettings settings;
|
||||
|
@ -36,6 +35,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
private boolean isMapLinkedToLocation = false;
|
||||
private boolean followingMode;
|
||||
private boolean routePlanningMode;
|
||||
private boolean showViewAngle = false;
|
||||
|
||||
public MapViewTrackingUtilities(OsmandApplication app){
|
||||
this.app = app;
|
||||
|
@ -75,7 +75,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
if (Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -val)) > 1) {
|
||||
mapView.setRotate(-val);
|
||||
}
|
||||
} else if (settings.SHOW_VIEW_ANGLE.get()) {
|
||||
} else if (showViewAngle) {
|
||||
mapView.refreshMap();
|
||||
}
|
||||
}
|
||||
|
@ -83,37 +83,27 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
showViewAngle = false;
|
||||
if (mapView != null) {
|
||||
if (isMapLinkedToLocation() && location != null) {
|
||||
if (settings.AUTO_ZOOM_MAP.get() != AutoZoomMap.NONE) {
|
||||
autozoom(location);
|
||||
}
|
||||
int currentMapRotation = settings.ROTATE_MAP.get();
|
||||
boolean enableCompass = false;
|
||||
boolean smallSpeed = !location.hasSpeed() || location.getSpeed() < 0.5;
|
||||
// boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get();
|
||||
showViewAngle = (!location.hasBearing() || smallSpeed);
|
||||
if (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
|
||||
boolean smallSpeed = !location.hasSpeed() || location.getSpeed() < 0.5;
|
||||
boolean fMode = app.getRoutingHelper().isFollowingMode();
|
||||
// boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get();
|
||||
enableCompass = (!location.hasBearing() || smallSpeed)
|
||||
&& fMode && settings.USE_COMPASS_IN_NAVIGATION.get();
|
||||
if (location.hasBearing() && !smallSpeed) {
|
||||
// special case when bearing equals to zero (we don't change anything)
|
||||
if (location.getBearing() != 0f) {
|
||||
mapView.setRotate(-location.getBearing());
|
||||
}
|
||||
} else if (enableCompass) {
|
||||
long now = System.currentTimeMillis();
|
||||
OsmAndLocationProvider provider = app.getLocationProvider();
|
||||
Float lastSensorRotation = provider.getHeading();
|
||||
if (lastSensorRotation != null && Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -lastSensorRotation)) > 15) {
|
||||
if (now - lastTimeSensorMapRotation > 3500) {
|
||||
lastTimeSensorMapRotation = now;
|
||||
mapView.setRotate(-lastSensorRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS) {
|
||||
showViewAngle = routePlanningMode; // disable compass rotation in that mode
|
||||
}
|
||||
registerUnregisterSensor(location, enableCompass);
|
||||
registerUnregisterSensor(location);
|
||||
mapView.setLatLon(location.getLatitude(), location.getLongitude());
|
||||
}
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
|
@ -127,6 +117,11 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
}
|
||||
|
||||
|
||||
public boolean isShowViewAngle() {
|
||||
|
||||
return showViewAngle;
|
||||
}
|
||||
|
||||
|
||||
public void switchToRoutePlanningMode() {
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
|
@ -146,13 +141,12 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
mapView.setMapPosition(settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING && !routePlanningMode ? OsmandSettings.BOTTOM_CONSTANT
|
||||
: OsmandSettings.CENTER_CONSTANT);
|
||||
}
|
||||
registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation(), false);
|
||||
registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation());
|
||||
}
|
||||
|
||||
private void registerUnregisterSensor(net.osmand.Location location, boolean overruleRegister) {
|
||||
boolean currentShowingAngle = settings.SHOW_VIEW_ANGLE.get();
|
||||
private void registerUnregisterSensor(net.osmand.Location location) {
|
||||
int currentMapRotation = settings.ROTATE_MAP.get();
|
||||
boolean registerCompassListener = overruleRegister || (currentShowingAngle && location != null)
|
||||
boolean registerCompassListener = (showViewAngle && location != null)
|
||||
|| (currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS && !routePlanningMode);
|
||||
// show point view only if gps enabled
|
||||
if(sensorRegistered != registerCompassListener) {
|
||||
|
@ -313,4 +307,5 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
public void routeWasCancelled() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.osmand.data.RotatedTileBox;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
|
@ -28,7 +29,12 @@ public class PointLocationLayer extends OsmandMapLayer {
|
|||
private Bitmap bearingIcon;
|
||||
private Bitmap locationIcon;
|
||||
private OsmAndLocationProvider locationProvider;
|
||||
private MapViewTrackingUtilities mapViewTrackingUtilities;
|
||||
private boolean nm;
|
||||
|
||||
public PointLocationLayer(MapViewTrackingUtilities mv) {
|
||||
this.mapViewTrackingUtilities = mv;
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
locationPaint = new Paint();
|
||||
|
@ -53,7 +59,6 @@ public class PointLocationLayer extends OsmandMapLayer {
|
|||
|
||||
checkAppMode(view.getSettings().getApplicationMode());
|
||||
locationProvider = view.getApplication().getLocationProvider();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,7 +70,7 @@ public class PointLocationLayer extends OsmandMapLayer {
|
|||
|
||||
|
||||
private RectF getHeadingRect(int locationX, int locationY){
|
||||
int rad = Math.min(3 * view.getWidth() / 8, 3 * view.getHeight() / 8);
|
||||
int rad = (int) (view.getDensity() * 25);
|
||||
return new RectF(locationX - rad, locationY - rad, locationX + rad, locationY + rad);
|
||||
}
|
||||
|
||||
|
@ -102,10 +107,9 @@ public class PointLocationLayer extends OsmandMapLayer {
|
|||
locationPaint);
|
||||
}
|
||||
Float heading = locationProvider.getHeading();
|
||||
if (heading != null && view.getSettings().SHOW_VIEW_ANGLE.get()) {
|
||||
if (heading != null && mapViewTrackingUtilities.isShowViewAngle()) {
|
||||
canvas.drawArc(getHeadingRect(locationX, locationY), heading - HEADING_ANGLE / 2 - 90, HEADING_ANGLE, true, headingPaint);
|
||||
}
|
||||
|
||||
if (isBearing) {
|
||||
float bearing = lastKnownLocation.getBearing();
|
||||
canvas.rotate(bearing - 90, locationX, locationY);
|
||||
|
|
|
@ -32,15 +32,15 @@ public class AppearanceWidgetsFactory {
|
|||
final OsmandMapTileView view = map.getMapView();
|
||||
|
||||
|
||||
final MapWidgetRegistry.MapWidgetRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(R.drawable.widget_viewing_direction, R.string.map_widget_view_direction,
|
||||
"viewDirection", view.getSettings().SHOW_VIEW_ANGLE);
|
||||
displayViewDirections.setStateChangeListener(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
view.getSettings().SHOW_VIEW_ANGLE.set(!view.getSettings().SHOW_VIEW_ANGLE.get());
|
||||
map.getMapViewTrackingUtilities().updateSettings();
|
||||
}
|
||||
});
|
||||
// final MapWidgetRegistry.MapWidgetRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(R.drawable.widget_viewing_direction, R.string.map_widget_view_direction,
|
||||
// "viewDirection", view.getSettings().SHOW_VIEW_ANGLE);
|
||||
// displayViewDirections.setStateChangeListener(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// view.getSettings().SHOW_VIEW_ANGLE.set(!view.getSettings().SHOW_VIEW_ANGLE.get());
|
||||
// map.getMapViewTrackingUtilities().updateSettings();
|
||||
// }
|
||||
// });
|
||||
|
||||
if (EXTRA_SETTINGS) {
|
||||
final MapWidgetRegistry.MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.string.map_widget_show_ruler,
|
||||
|
|
Loading…
Reference in a new issue