Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
73f0239695
3 changed files with 73 additions and 46 deletions
|
@ -1,5 +1,9 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import net.osmand.StateChangedListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
@ -8,9 +12,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.osmand.StateChangedListener;
|
||||
import android.content.Context;
|
||||
|
||||
|
||||
public class ApplicationMode {
|
||||
private static Map<String, Set<ApplicationMode>> widgets = new LinkedHashMap<String, Set<ApplicationMode>>();
|
||||
|
@ -99,8 +100,10 @@ public class ApplicationMode {
|
|||
}
|
||||
|
||||
public ApplicationModeBuilder carLocation(){
|
||||
applicationMode.bearingIcon = R.drawable.map_car_bearing;
|
||||
applicationMode.locationIcon = R.drawable.map_car_location;
|
||||
applicationMode.bearingIconDay = R.drawable.map_car_bearing;
|
||||
applicationMode.bearingIconNight = R.drawable.map_car_bearing_night;
|
||||
applicationMode.locationIconDay = R.drawable.map_car_location;
|
||||
applicationMode.locationIconNight = R.drawable.map_car_location_night;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -110,14 +113,18 @@ public class ApplicationMode {
|
|||
}
|
||||
|
||||
public ApplicationModeBuilder bicycleLocation(){
|
||||
applicationMode.bearingIcon = R.drawable.map_bicycle_bearing;
|
||||
applicationMode.locationIcon = R.drawable.map_bicycle_location;
|
||||
applicationMode.bearingIconDay = R.drawable.map_bicycle_bearing;
|
||||
applicationMode.bearingIconNight = R.drawable.map_bicycle_bearing_night;
|
||||
applicationMode.locationIconDay = R.drawable.map_bicycle_location;
|
||||
applicationMode.locationIconNight = R.drawable.map_bicycle_location_night;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApplicationModeBuilder defLocation(){
|
||||
applicationMode.bearingIcon = R.drawable.map_pedestrian_bearing;
|
||||
applicationMode.locationIcon = R.drawable.map_pedestrian_location;
|
||||
applicationMode.bearingIconDay = R.drawable.map_pedestrian_bearing;
|
||||
applicationMode.bearingIconNight = R.drawable.map_pedestrian_bearing_night;
|
||||
applicationMode.locationIconDay = R.drawable.map_pedestrian_location;
|
||||
applicationMode.locationIconNight = R.drawable.map_pedestrian_location_night;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -138,21 +145,6 @@ public class ApplicationMode {
|
|||
builder.applicationMode = new ApplicationMode(key, stringKey);
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final int key;
|
||||
private final String stringKey;
|
||||
|
||||
private ApplicationMode parent;
|
||||
private int iconId = R.drawable.ic_browse_map;
|
||||
private int smallIconDark = R.drawable.ic_world_globe_dark ;
|
||||
private float defaultSpeed = 10f;
|
||||
private int minDistanceForTurn = 50;
|
||||
private int arrivalDistance = 90;
|
||||
private int bearingIcon = R.drawable.map_pedestrian_bearing;
|
||||
private int locationIcon = R.drawable.map_pedestrian_location;
|
||||
private static StateChangedListener<String> listener;
|
||||
|
||||
private ApplicationMode(int key, String stringKey) {
|
||||
this.key = key;
|
||||
|
@ -240,12 +232,20 @@ public class ApplicationMode {
|
|||
return getDefaultSpeed() > 10;
|
||||
}
|
||||
|
||||
public int getResourceBearing() {
|
||||
return bearingIcon;
|
||||
public int getResourceBearingDay() {
|
||||
return bearingIconDay;
|
||||
}
|
||||
|
||||
public int getResourceBearingNight() {
|
||||
return bearingIconNight;
|
||||
}
|
||||
|
||||
public int getResourceLocation() {
|
||||
return locationIcon;
|
||||
public int getResourceLocationDay() {
|
||||
return locationIconDay;
|
||||
}
|
||||
|
||||
public int getResourceLocationNight() {
|
||||
return locationIconNight;
|
||||
}
|
||||
|
||||
public String getStringKey() {
|
||||
|
@ -292,8 +292,19 @@ public class ApplicationMode {
|
|||
public boolean isDerivedRoutingFrom(ApplicationMode mode) {
|
||||
return this == mode || getParent() == mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final int key;
|
||||
private final String stringKey;
|
||||
|
||||
private ApplicationMode parent;
|
||||
private int iconId = R.drawable.ic_browse_map;
|
||||
private int smallIconDark = R.drawable.ic_world_globe_dark ;
|
||||
private float defaultSpeed = 10f;
|
||||
private int minDistanceForTurn = 50;
|
||||
private int arrivalDistance = 90;
|
||||
private int bearingIconDay = R.drawable.map_pedestrian_bearing;
|
||||
private int bearingIconNight = R.drawable.map_pedestrian_bearing_night;
|
||||
private int locationIconDay = R.drawable.map_pedestrian_location;
|
||||
private int locationIconNight = R.drawable.map_pedestrian_location_night;
|
||||
private static StateChangedListener<String> listener;
|
||||
}
|
|
@ -38,6 +38,6 @@ public class MyLocationMenuController extends MenuController {
|
|||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
ApplicationMode appMode = getMapActivity().getMyApplication().getSettings().getApplicationMode();
|
||||
return getMapActivity().getResources().getDrawable(appMode.getResourceLocation());
|
||||
return getMapActivity().getResources().getDrawable(appMode.getResourceLocationDay());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
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;
|
||||
|
@ -17,9 +9,23 @@ import android.graphics.Paint.Style;
|
|||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
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 org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||
private static final Log LOG = PlatformUtil.getLog(PointLocationLayer.class);
|
||||
|
||||
protected final static int RADIUS = 7;
|
||||
protected final static float HEADING_ANGLE = 60;
|
||||
|
||||
|
@ -35,7 +41,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
private Bitmap locationIcon;
|
||||
private OsmAndLocationProvider locationProvider;
|
||||
private MapViewTrackingUtilities mapViewTrackingUtilities;
|
||||
private boolean nm;
|
||||
private boolean nm = false;
|
||||
|
||||
public PointLocationLayer(MapViewTrackingUtilities mv) {
|
||||
this.mapViewTrackingUtilities = mv;
|
||||
|
@ -62,7 +68,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
headingPaint.setAntiAlias(true);
|
||||
headingPaint.setStyle(Style.FILL);
|
||||
|
||||
checkAppMode(view.getSettings().getApplicationMode());
|
||||
checkAppMode(view.getSettings().getApplicationMode(), false, false);
|
||||
locationProvider = view.getApplication().getLocationProvider();
|
||||
}
|
||||
|
||||
|
@ -86,11 +92,14 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
}
|
||||
// draw
|
||||
boolean nm = nightMode != null && nightMode.isNightMode();
|
||||
boolean shouldForceUpdate = false;
|
||||
if(nm != this.nm) {
|
||||
this.nm = nm;
|
||||
area.setColor(view.getResources().getColor(!nm?R.color.pos_area : R.color.pos_area_night));
|
||||
headingPaint.setColor(view.getResources().getColor(!nm?R.color.pos_heading :R.color.pos_heading_night));
|
||||
shouldForceUpdate = true;
|
||||
}
|
||||
checkAppMode(view.getSettings().getApplicationMode(), nm, shouldForceUpdate);
|
||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
if(lastKnownLocation == null || view == null){
|
||||
return;
|
||||
|
@ -108,7 +117,6 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
}
|
||||
// draw bearing/direction/location
|
||||
if (isLocationVisible(box, lastKnownLocation)) {
|
||||
checkAppMode(view.getSettings().getApplicationMode());
|
||||
boolean isBearing = lastKnownLocation.hasBearing();
|
||||
|
||||
Float heading = locationProvider.getHeading();
|
||||
|
@ -138,11 +146,19 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
public void destroyLayer() {
|
||||
|
||||
}
|
||||
public void checkAppMode(ApplicationMode appMode) {
|
||||
if (appMode != this.appMode) {
|
||||
public void checkAppMode(ApplicationMode appMode, boolean nighMode, boolean force) {
|
||||
if (appMode != this.appMode || force) {
|
||||
this.appMode = appMode;
|
||||
bearingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getResourceBearing());
|
||||
locationIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getResourceLocation());
|
||||
|
||||
final int resourceBearingDay = appMode.getResourceBearingDay();
|
||||
final int resourceBearingNight = appMode.getResourceBearingNight();
|
||||
final int resourceBearing = nighMode ? resourceBearingNight : resourceBearingDay;
|
||||
bearingIcon = BitmapFactory.decodeResource(view.getResources(), resourceBearing);
|
||||
|
||||
final int resourceLocationDay = appMode.getResourceLocationDay();
|
||||
final int resourceLocationNight = appMode.getResourceLocationNight();
|
||||
final int resourceLocation = nighMode ? resourceLocationNight : resourceLocationDay;
|
||||
locationIcon = BitmapFactory.decodeResource(view.getResources(), resourceLocation);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue