Fix customized settings update
This commit is contained in:
parent
d9900126a7
commit
5759601738
15 changed files with 152 additions and 115 deletions
|
@ -9,6 +9,8 @@ import android.support.v4.content.ContextCompat;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
|
@ -16,8 +18,6 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||
|
@ -53,9 +53,9 @@ public class MapMarkersHelper {
|
|||
public static final int BY_DISTANCE_DESC = 1;
|
||||
public static final int BY_DISTANCE_ASC = 2;
|
||||
public static final int BY_DATE_ADDED_DESC = 3;
|
||||
|
||||
|
||||
public static final int BY_DATE_ADDED_ASC = 4;
|
||||
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(MapMarkersHelper.class);
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
@ -64,7 +64,6 @@ public class MapMarkersHelper {
|
|||
}
|
||||
|
||||
private OsmandApplication ctx;
|
||||
private OsmandSettings settings;
|
||||
private MapMarkersDbHelper markersDbHelper;
|
||||
|
||||
private ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
|
@ -76,8 +75,6 @@ public class MapMarkersHelper {
|
|||
private List<MapMarkerChangedListener> listeners = new ArrayList<>();
|
||||
private Set<OnGroupSyncedListener> syncListeners = new HashSet<>();
|
||||
|
||||
private boolean startFromMyLocation;
|
||||
|
||||
private MarkersPlanRouteContext planRouteContext;
|
||||
|
||||
public List<MapMarker> getMapMarkers() {
|
||||
|
@ -93,12 +90,11 @@ public class MapMarkersHelper {
|
|||
}
|
||||
|
||||
public boolean isStartFromMyLocation() {
|
||||
return startFromMyLocation;
|
||||
return ctx.getSettings().ROUTE_MAP_MARKERS_START_MY_LOC.get();
|
||||
}
|
||||
|
||||
public void setStartFromMyLocation(boolean startFromMyLocation) {
|
||||
this.startFromMyLocation = startFromMyLocation;
|
||||
settings.ROUTE_MAP_MARKERS_START_MY_LOC.set(startFromMyLocation);
|
||||
ctx.getSettings().ROUTE_MAP_MARKERS_START_MY_LOC.set(startFromMyLocation);
|
||||
}
|
||||
|
||||
public MarkersPlanRouteContext getPlanRouteContext() {
|
||||
|
@ -107,10 +103,8 @@ public class MapMarkersHelper {
|
|||
|
||||
public MapMarkersHelper(OsmandApplication ctx) {
|
||||
this.ctx = ctx;
|
||||
settings = ctx.getSettings();
|
||||
markersDbHelper = ctx.getMapMarkersDbHelper();
|
||||
planRouteContext = new MarkersPlanRouteContext(ctx);
|
||||
startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get();
|
||||
markersDbHelper.removeDisabledGroups();
|
||||
loadMarkers();
|
||||
loadGroups();
|
||||
|
@ -616,7 +610,7 @@ public class MapMarkersHelper {
|
|||
|
||||
private List<MapMarker> getMarkers() {
|
||||
List<MapMarker> res = new ArrayList<>(mapMarkers);
|
||||
if (settings.KEEP_PASSED_MARKERS_ON_MAP.get()) {
|
||||
if (ctx.getSettings().KEEP_PASSED_MARKERS_ON_MAP.get()) {
|
||||
res.addAll(mapMarkersHistory);
|
||||
}
|
||||
return res;
|
||||
|
@ -883,7 +877,7 @@ public class MapMarkersHelper {
|
|||
@Nullable List<WptPt> wptPts,
|
||||
@Nullable List<String> mapObjNames) {
|
||||
if (points.size() > 0) {
|
||||
settings.SHOW_MAP_MARKERS.set(true);
|
||||
ctx.getSettings().SHOW_MAP_MARKERS.set(true);
|
||||
int colorIndex = -1;
|
||||
List<MapMarker> addedMarkers = new ArrayList<>();
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
|
|
|
@ -76,6 +76,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
private static final long LOCATION_TIMEOUT_TO_BE_STALE = 1000 * 60 * 2; // 2 minutes
|
||||
private static final long STALE_LOCATION_TIMEOUT_TO_BE_GONE = 1000 * 60 * 20; // 20 minutes
|
||||
|
||||
private static final long AGPS_TO_REDOWNLOAD = 16 * 60 * 60 * 1000; // 16 hours
|
||||
|
||||
private static final int REQUESTS_BEFORE_CHECK_LOCATION = 100;
|
||||
private AtomicInteger locationRequestsCounter = new AtomicInteger();
|
||||
private AtomicInteger staleLocationRequestsCounter = new AtomicInteger();
|
||||
|
@ -114,7 +116,6 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
private int currentScreenOrientation;
|
||||
|
||||
private OsmandApplication app;
|
||||
private OsmandSettings settings;
|
||||
|
||||
private NavigationInfo navigationInfo;
|
||||
private CurrentPositionHelper currentPositionHelper;
|
||||
|
@ -128,9 +129,6 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
private List<OsmAndCompassListener> compassListeners = new ArrayList<OsmAndLocationProvider.OsmAndCompassListener>();
|
||||
private Listener gpsStatusListener;
|
||||
private float[] mRotationM = new float[9];
|
||||
private OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS;
|
||||
private OsmandPreference<Boolean> USE_FILTER_FOR_COMPASS;
|
||||
private static final long AGPS_TO_REDOWNLOAD = 16 * 60 * 60 * 1000; // 16 hours
|
||||
|
||||
|
||||
public class SimulationProvider {
|
||||
|
@ -234,9 +232,6 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
public OsmAndLocationProvider(OsmandApplication app) {
|
||||
this.app = app;
|
||||
navigationInfo = new NavigationInfo(app);
|
||||
settings = app.getSettings();
|
||||
USE_MAGNETIC_FIELD_SENSOR_COMPASS = settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS;
|
||||
USE_FILTER_FOR_COMPASS = settings.USE_KALMAN_FILTER_FOR_COMPASS;
|
||||
currentPositionHelper = new CurrentPositionHelper(app);
|
||||
locationSimulation = new OsmAndLocationSimulation(app, this);
|
||||
addLocationListener(navigationInfo);
|
||||
|
@ -393,7 +388,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
} else if (!sensorRegistered && register) {
|
||||
Log.d(PlatformUtil.TAG, "Enable sensor"); //$NON-NLS-1$
|
||||
SensorManager sensorMgr = (SensorManager) app.getSystemService(Context.SENSOR_SERVICE);
|
||||
if (USE_MAGNETIC_FIELD_SENSOR_COMPASS.get()) {
|
||||
if (app.getSettings().USE_MAGNETIC_FIELD_SENSOR_COMPASS.get()) {
|
||||
Sensor s = sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
if (s == null || !sensorMgr.registerListener(this, s, SensorManager.SENSOR_DELAY_UI)) {
|
||||
Log.e(PlatformUtil.TAG, "Sensor accelerometer could not be enabled");
|
||||
|
@ -476,7 +471,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
default:
|
||||
return;
|
||||
}
|
||||
if (USE_MAGNETIC_FIELD_SENSOR_COMPASS.get()) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
if (settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS.get()) {
|
||||
if (mGravs != null && mGeoMags != null) {
|
||||
boolean success = SensorManager.getRotationMatrix(mRotationM, null, mGravs, mGeoMags);
|
||||
if (!success) {
|
||||
|
@ -495,7 +491,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
lastValSin = (float) Math.sin(valRad);
|
||||
lastValCos = (float) Math.cos(valRad);
|
||||
// lastHeadingCalcTime = System.currentTimeMillis();
|
||||
boolean filter = USE_FILTER_FOR_COMPASS.get(); //USE_MAGNETIC_FIELD_SENSOR_COMPASS.get();
|
||||
boolean filter = settings.USE_KALMAN_FILTER_FOR_COMPASS.get(); //USE_MAGNETIC_FIELD_SENSOR_COMPASS.get();
|
||||
if (filter) {
|
||||
filterCompassValue();
|
||||
} else {
|
||||
|
@ -806,9 +802,9 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
if (routingHelper.isFollowingMode()) {
|
||||
if (location == null || isPointAccurateForRouting(location)) {
|
||||
// Update routing position and get location for sticking mode
|
||||
updatedLocation = routingHelper.setCurrentLocation(location, settings.SNAP_TO_ROAD.get());
|
||||
updatedLocation = routingHelper.setCurrentLocation(location, app.getSettings().SNAP_TO_ROAD.get());
|
||||
}
|
||||
} else if(routingHelper.isRoutePlanningMode() && settings.getPointToStart() == null) {
|
||||
} else if(routingHelper.isRoutePlanningMode() && app.getSettings().getPointToStart() == null) {
|
||||
routingHelper.setCurrentLocation(location, false);
|
||||
} else if(getLocationSimulation().isRouteAnimating()) {
|
||||
routingHelper.setCurrentLocation(location, false);
|
||||
|
|
|
@ -291,7 +291,6 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
public void setOsmandSettings(OsmandSettings osmandSettings) {
|
||||
//android.os.Process.killProcess(android.os.Process.myPid());
|
||||
this.osmandSettings = osmandSettings;
|
||||
resourceManager.getRenderer().updateSettings();
|
||||
OsmandPlugin.initPlugins(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -1470,8 +1470,6 @@ public class OsmandSettings {
|
|||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<String> PREFERRED_LOCALE = new StringPreference("preferred_locale", "").makeGlobal();
|
||||
|
||||
public static final String TRANSPORT_STOPS_OVER_MAP = "transportStops";
|
||||
|
||||
public final OsmandPreference<String> MAP_PREFERRED_LOCALE = new StringPreference("map_preferred_locale", "").makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> MAP_TRANSLITERATE_NAMES = new BooleanPreference("map_transliterate_names", false).makeGlobal().cache();
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.OsmAndAppCustomization.OsmAndAppCustomizationListener;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -147,6 +148,16 @@ public class TargetPointsHelper {
|
|||
this.settings = ctx.getSettings();
|
||||
this.routingHelper = ctx.getRoutingHelper();
|
||||
readFromSettings();
|
||||
|
||||
OsmAndAppCustomizationListener customizationListener = new OsmAndAppCustomizationListener() {
|
||||
@Override
|
||||
public void onOsmAndSettingsCustomized() {
|
||||
settings = TargetPointsHelper.this.ctx.getSettings();
|
||||
readFromSettings();
|
||||
updateRouteAndRefresh(true);
|
||||
}
|
||||
};
|
||||
ctx.getAppCustomization().addListener(customizationListener);
|
||||
}
|
||||
|
||||
public void lookupAddessAll() {
|
||||
|
|
|
@ -10,7 +10,6 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.OsmandSettings.DayNightMode;
|
||||
import net.osmand.util.SunriseSunset;
|
||||
|
||||
|
@ -41,15 +40,13 @@ import android.location.LocationManager;
|
|||
* @author pavol.zibrita
|
||||
*/
|
||||
public class DayNightHelper implements SensorEventListener {
|
||||
|
||||
private static final Log log = PlatformUtil.getLog(DayNightHelper.class);
|
||||
|
||||
private final OsmandApplication osmandApplication;
|
||||
|
||||
private CommonPreference<DayNightMode> pref;
|
||||
|
||||
public DayNightHelper(OsmandApplication osmandApplication) {
|
||||
this.osmandApplication = osmandApplication;
|
||||
pref = osmandApplication.getSettings().DAYNIGHT_MODE;
|
||||
}
|
||||
|
||||
private DayNightHelper listener;
|
||||
|
@ -79,7 +76,7 @@ public class DayNightHelper implements SensorEventListener {
|
|||
}
|
||||
|
||||
public boolean isNightModeForProfile(ApplicationMode mode) {
|
||||
DayNightMode dayNightMode = pref.getModeValue(mode);
|
||||
DayNightMode dayNightMode = osmandApplication.getSettings().DAYNIGHT_MODE.getModeValue(mode);
|
||||
if (dayNightMode.isDay()) {
|
||||
return false;
|
||||
} else if (dayNightMode.isNight()) {
|
||||
|
@ -138,7 +135,7 @@ public class DayNightHelper implements SensorEventListener {
|
|||
|
||||
public void startSensorIfNeeded(StateChangedListener<Boolean> sensorStateListener) {
|
||||
this.sensorStateListener = sensorStateListener;
|
||||
DayNightMode dayNightMode = pref.get();
|
||||
DayNightMode dayNightMode = osmandApplication.getSettings().DAYNIGHT_MODE.get();
|
||||
if (listener == null && dayNightMode.isSensor()) {
|
||||
SensorManager mSensorManager = (SensorManager) osmandApplication.getSystemService(Context.SENSOR_SERVICE);
|
||||
Sensor mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
|
||||
|
|
|
@ -208,8 +208,6 @@ public class MapActivityLayers {
|
|||
public void updateLayers(OsmandMapTileView mapView) {
|
||||
OsmandSettings settings = getApplication().getSettings();
|
||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||
boolean showStops = settings.getCustomRenderBooleanProperty(OsmandSettings.TRANSPORT_STOPS_OVER_MAP).get();
|
||||
transportStopsLayer.setShowTransportStops(showStops);
|
||||
OsmandPlugin.refreshLayers(mapView, activity);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.os.PowerManager.WakeLock;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import net.osmand.plus.OsmAndAppCustomization.OsmAndAppCustomizationListener;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
|
@ -65,6 +66,16 @@ public class LockHelper implements SensorEventListener {
|
|||
unlockEvent();
|
||||
}
|
||||
};
|
||||
OsmAndAppCustomizationListener customizationListener = new OsmAndAppCustomizationListener() {
|
||||
@Override
|
||||
public void onOsmAndSettingsCustomized() {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
turnScreenOnEnabled = settings.TURN_SCREEN_ON_ENABLED;
|
||||
turnScreenOnTime = settings.TURN_SCREEN_ON_TIME_INT;
|
||||
turnScreenOnSensor = settings.TURN_SCREEN_ON_SENSOR;
|
||||
}
|
||||
};
|
||||
app.getAppCustomization().addListener(customizationListener);
|
||||
app.getRoutingHelper().getVoiceRouter().addVoiceMessageListener(voiceMessageListener);
|
||||
}
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
|
|||
}
|
||||
Object item = adapter.getItem(pos);
|
||||
if (item instanceof Location) {
|
||||
markersHelper.setStartFromMyLocation(!mapActivity.getMyApplication().getSettings().ROUTE_MAP_MARKERS_START_MY_LOC.get());
|
||||
markersHelper.setStartFromMyLocation(!markersHelper.isStartFromMyLocation());
|
||||
} else if (item instanceof MapMarker) {
|
||||
MapMarker marker = (MapMarker) item;
|
||||
selectedCount = marker.selected ? selectedCount - 1 : selectedCount + 1;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.plus.monitoring;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -24,23 +23,25 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class LiveMonitoringHelper {
|
||||
|
||||
protected Context ctx;
|
||||
private OsmandSettings settings;
|
||||
private long lastTimeUpdated;
|
||||
private LatLon lastPoint;
|
||||
public class LiveMonitoringHelper {
|
||||
|
||||
private final static Log log = PlatformUtil.getLog(LiveMonitoringHelper.class);
|
||||
|
||||
private OsmandApplication app;
|
||||
|
||||
private ConcurrentLinkedQueue<LiveMonitoringData> queue;
|
||||
|
||||
private LatLon lastPoint;
|
||||
private long lastTimeUpdated;
|
||||
private boolean started = false;
|
||||
|
||||
public LiveMonitoringHelper(Context ctx){
|
||||
this.ctx = ctx;
|
||||
settings = ((OsmandApplication) ctx.getApplicationContext()).getSettings();
|
||||
public LiveMonitoringHelper(OsmandApplication app) {
|
||||
this.app = app;
|
||||
queue = new ConcurrentLinkedQueue<>();
|
||||
}
|
||||
|
||||
public boolean isLiveMonitoringEnabled(){
|
||||
|
||||
public boolean isLiveMonitoringEnabled() {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
return settings.LIVE_MONITORING.get() && (settings.SAVE_TRACK_TO_GPX.get() || settings.SAVE_GLOBAL_TRACK_TO_GPX.get());
|
||||
}
|
||||
|
||||
|
@ -50,6 +51,7 @@ public class LiveMonitoringHelper {
|
|||
if (location != null && isLiveMonitoringEnabled()
|
||||
&& OsmAndLocationProvider.isNotSimulatedLocation(location)
|
||||
&& OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
if (locationTime - lastTimeUpdated > settings.LIVE_MONITORING_INTERVAL.get()) {
|
||||
record = true;
|
||||
}
|
||||
|
@ -112,10 +114,11 @@ public class LiveMonitoringHelper {
|
|||
@Override
|
||||
protected Void doInBackground(ConcurrentLinkedQueue<LiveMonitoringData>... concurrentLinkedQueues) {
|
||||
while (isLiveMonitoringEnabled()) {
|
||||
int maxSendInterval = app.getSettings().LIVE_MONITORING_MAX_INTERVAL_TO_SEND.get();
|
||||
for (ConcurrentLinkedQueue queue : concurrentLinkedQueues) {
|
||||
if (!queue.isEmpty()) {
|
||||
LiveMonitoringData data = (LiveMonitoringData) queue.peek();
|
||||
if (!(System.currentTimeMillis() - data.time > settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND.get())) {
|
||||
if (!(System.currentTimeMillis() - data.time > maxSendInterval)) {
|
||||
sendData(data);
|
||||
} else {
|
||||
queue.poll();
|
||||
|
@ -128,10 +131,52 @@ public class LiveMonitoringHelper {
|
|||
}
|
||||
|
||||
public void sendData(LiveMonitoringData data) {
|
||||
String st = settings.LIVE_MONITORING_URL.get();
|
||||
String urlStr = getLiveUrl(data);
|
||||
try {
|
||||
// Parse the URL and let the URI constructor handle proper encoding of special characters such as spaces
|
||||
URL url = new URL(urlStr);
|
||||
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
|
||||
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(),
|
||||
url.getPath(), url.getQuery(), url.getRef());
|
||||
|
||||
urlConnection.setConnectTimeout(15000);
|
||||
urlConnection.setReadTimeout(15000);
|
||||
|
||||
log.info("Monitor " + uri);
|
||||
|
||||
if (urlConnection.getResponseCode() / 100 != 2) {
|
||||
|
||||
String msg = urlConnection.getResponseCode() + " : " + //$NON-NLS-1$//$NON-NLS-2$
|
||||
urlConnection.getResponseMessage();
|
||||
log.error("Error sending monitor request: " + msg);
|
||||
} else {
|
||||
queue.poll();
|
||||
InputStream is = urlConnection.getInputStream();
|
||||
StringBuilder responseBody = new StringBuilder();
|
||||
if (is != null) {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8")); //$NON-NLS-1$
|
||||
String s;
|
||||
while ((s = in.readLine()) != null) {
|
||||
responseBody.append(s);
|
||||
responseBody.append("\n"); //$NON-NLS-1$
|
||||
}
|
||||
is.close();
|
||||
}
|
||||
log.info("Monitor response (" + urlConnection.getHeaderField("Content-Type") + "): " + responseBody.toString());
|
||||
}
|
||||
|
||||
urlConnection.disconnect();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Failed connect to " + urlStr + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getLiveUrl(LiveMonitoringData data) {
|
||||
String st = app.getSettings().LIVE_MONITORING_URL.get();
|
||||
List<String> prm = new ArrayList<String>();
|
||||
int maxLen = 0;
|
||||
for(int i = 0; i < 7; i++) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
boolean b = st.contains("{"+i+"}");
|
||||
if(b) {
|
||||
maxLen = i;
|
||||
|
@ -165,45 +210,6 @@ public class LiveMonitoringHelper {
|
|||
break;
|
||||
}
|
||||
}
|
||||
String urlStr = MessageFormat.format(st, prm.toArray());
|
||||
try {
|
||||
|
||||
// Parse the URL and let the URI constructor handle proper encoding of special characters such as spaces
|
||||
URL url = new URL(urlStr);
|
||||
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
|
||||
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(),
|
||||
url.getPath(), url.getQuery(), url.getRef());
|
||||
|
||||
urlConnection.setConnectTimeout(15000);
|
||||
urlConnection.setReadTimeout(15000);
|
||||
|
||||
log.info("Monitor " + uri);
|
||||
|
||||
if (urlConnection.getResponseCode()/100 != 2) {
|
||||
|
||||
String msg = urlConnection.getResponseCode() + " : " + //$NON-NLS-1$//$NON-NLS-2$
|
||||
urlConnection.getResponseMessage();
|
||||
log.error("Error sending monitor request: " + msg);
|
||||
} else {
|
||||
queue.poll();
|
||||
InputStream is = urlConnection.getInputStream();
|
||||
StringBuilder responseBody = new StringBuilder();
|
||||
if (is != null) {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8")); //$NON-NLS-1$
|
||||
String s;
|
||||
while ((s = in.readLine()) != null) {
|
||||
responseBody.append(s);
|
||||
responseBody.append("\n"); //$NON-NLS-1$
|
||||
}
|
||||
is.close();
|
||||
}
|
||||
log.info("Monitor response (" + urlConnection.getHeaderField("Content-Type") + "): " + responseBody.toString());
|
||||
}
|
||||
|
||||
urlConnection.disconnect();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Failed connect to " + urlStr + ": " + e.getMessage(), e);
|
||||
}
|
||||
return MessageFormat.format(st, prm.toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import net.osmand.data.QuadPointDouble;
|
|||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.map.MapTileDownloader;
|
||||
import net.osmand.plus.OsmAndAppCustomization.OsmAndAppCustomizationListener;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -121,6 +122,15 @@ public class MapRenderRepositories {
|
|||
this.renderer = new OsmandRenderer(context);
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
prefs = context.getSettings();
|
||||
|
||||
OsmAndAppCustomizationListener customizationListener = new OsmAndAppCustomizationListener() {
|
||||
@Override
|
||||
public void onOsmAndSettingsCustomized() {
|
||||
prefs = MapRenderRepositories.this.context.getSettings();
|
||||
clearCache();
|
||||
}
|
||||
};
|
||||
context.getAppCustomization().addListener(customizationListener);
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
|
@ -153,11 +163,6 @@ public class MapRenderRepositories {
|
|||
return prevBmpLocation;
|
||||
}
|
||||
|
||||
public void updateSettings() {
|
||||
prefs = context.getSettings();
|
||||
clearCache();
|
||||
}
|
||||
|
||||
public synchronized void closeConnection(String file) {
|
||||
LinkedHashMap<String, BinaryMapIndexReader> cpfiles = new LinkedHashMap<String, BinaryMapIndexReader>(files);
|
||||
BinaryMapIndexReader bmir = cpfiles.remove(file);
|
||||
|
|
|
@ -63,13 +63,11 @@ public class RoutingOptionsHelper {
|
|||
public static final String DRIVING_STYLE = "driving_style";
|
||||
|
||||
private OsmandApplication app;
|
||||
private OsmandSettings settings;
|
||||
|
||||
private Map<ApplicationMode, RouteMenuAppModes> modes = new HashMap<>();
|
||||
|
||||
public RoutingOptionsHelper(OsmandApplication application) {
|
||||
app = application;
|
||||
settings = app.getSettings();
|
||||
}
|
||||
|
||||
private void addRouteMenuAppModes(ApplicationMode am, List<String> routingParameters) {
|
||||
|
@ -104,6 +102,7 @@ public class RoutingOptionsHelper {
|
|||
}
|
||||
|
||||
public void switchMusic() {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
boolean mt = !settings.INTERRUPT_MUSIC.get();
|
||||
settings.INTERRUPT_MUSIC.set(mt);
|
||||
}
|
||||
|
@ -311,6 +310,7 @@ public class RoutingOptionsHelper {
|
|||
}
|
||||
|
||||
public void showLocalRoutingParameterGroupDialog(final LocalRoutingParameterGroup group, final MapActivity mapActivity, final OnClickListener listener) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
int i = 0;
|
||||
int selectedIndex = -1;
|
||||
|
@ -364,6 +364,7 @@ public class RoutingOptionsHelper {
|
|||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
int position = selectedPosition[0];
|
||||
if (position >= 0 && position < group.getRoutingParameters().size()) {
|
||||
for (int i = 0; i < group.getRoutingParameters().size(); i++) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmAndAppCustomization.OsmAndAppCustomizationListener;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -95,11 +96,19 @@ public class RoutingHelper {
|
|||
public RoutingHelper(OsmandApplication context){
|
||||
this.app = context;
|
||||
settings = context.getSettings();
|
||||
voiceRouter = new VoiceRouter(this, settings);
|
||||
voiceRouter = new VoiceRouter(this);
|
||||
provider = new RouteProvider();
|
||||
transportRoutingHelper = context.getTransportRoutingHelper();
|
||||
transportRoutingHelper.setRoutingHelper(this);
|
||||
setAppMode(settings.APPLICATION_MODE.get());
|
||||
|
||||
OsmAndAppCustomizationListener customizationListener = new OsmAndAppCustomizationListener() {
|
||||
@Override
|
||||
public void onOsmAndSettingsCustomized() {
|
||||
settings = app.getSettings();
|
||||
}
|
||||
};
|
||||
app.getAppCustomization().addListener(customizationListener);
|
||||
}
|
||||
|
||||
public TransportRoutingHelper getTransportRoutingHelper() {
|
||||
|
|
|
@ -8,6 +8,8 @@ import net.osmand.Location;
|
|||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmAndAppCustomization.OsmAndAppCustomizationListener;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||
|
@ -45,9 +47,11 @@ public class VoiceRouter {
|
|||
public static final String FROM_STREET_NAME = "fromStreetName";
|
||||
public static final String FROM_DEST = "fromDest";
|
||||
|
||||
protected final RoutingHelper router;
|
||||
protected static CommandPlayer player;
|
||||
protected final OsmandSettings settings;
|
||||
|
||||
protected final OsmandApplication app;
|
||||
protected final RoutingHelper router;
|
||||
protected OsmandSettings settings;
|
||||
|
||||
private static int currentStatus = STATUS_UNKNOWN;
|
||||
private static boolean playedAndArriveAtTarget = false;
|
||||
|
@ -83,9 +87,18 @@ public class VoiceRouter {
|
|||
|
||||
private List<WeakReference<VoiceMessageListener>> voiceMessageListeners = new ArrayList<>();
|
||||
|
||||
VoiceRouter(RoutingHelper router, final OsmandSettings settings) {
|
||||
VoiceRouter(RoutingHelper router) {
|
||||
this.router = router;
|
||||
this.settings = settings;
|
||||
this.app = router.getApplication();
|
||||
this.settings = app.getSettings();
|
||||
|
||||
OsmAndAppCustomizationListener customizationListener = new OsmAndAppCustomizationListener() {
|
||||
@Override
|
||||
public void onOsmAndSettingsCustomized() {
|
||||
settings = app.getSettings();
|
||||
}
|
||||
};
|
||||
app.getAppCustomization().addListener(customizationListener);
|
||||
}
|
||||
|
||||
public void setPlayer(CommandPlayer player) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.osmand.data.RotatedTileBox;
|
|||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.osm.edit.Way;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
|
@ -36,6 +37,9 @@ import java.util.List;
|
|||
import java.util.TreeSet;
|
||||
|
||||
public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||
|
||||
public static final String TRANSPORT_STOPS_OVER_MAP = "transportStops";
|
||||
|
||||
private static final int startZoom = 12;
|
||||
private static final int startZoomRoute = 10;
|
||||
|
||||
|
@ -53,13 +57,16 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
|||
private MapLayerData<List<TransportStop>> data;
|
||||
private TransportStopRoute stopRoute = null;
|
||||
|
||||
private boolean showTransportStops;
|
||||
private OsmandSettings.CommonPreference<Boolean> showTransportStops;
|
||||
|
||||
private Path path;
|
||||
private float backgroundIconHalfWidth;
|
||||
private float backgroundIconHalfHeight;
|
||||
|
||||
public TransportStopsLayer(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
||||
showTransportStops = settings.getCustomRenderBooleanProperty(TRANSPORT_STOPS_OVER_MAP).cache();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -168,14 +175,6 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
|||
this.stopRoute = route;
|
||||
}
|
||||
|
||||
public boolean isShowTransportStops() {
|
||||
return showTransportStops;
|
||||
}
|
||||
|
||||
public void setShowTransportStops(boolean showTransportStops) {
|
||||
this.showTransportStops = showTransportStops;
|
||||
}
|
||||
|
||||
private int getRadiusPoi(RotatedTileBox tb){
|
||||
final double zoom = tb.getZoom();
|
||||
int r;
|
||||
|
@ -227,7 +226,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
|||
}
|
||||
}
|
||||
|
||||
if (showTransportStops && tb.getZoom() >= startZoom && objects == null) {
|
||||
if (showTransportStops.get() && tb.getZoom() >= startZoom && objects == null) {
|
||||
data.queryNewData(tb);
|
||||
objects = data.getResults();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue