diff --git a/OsmAnd-java/src/main/java/net/osmand/data/RotatedTileBox.java b/OsmAnd-java/src/main/java/net/osmand/data/RotatedTileBox.java
index 477f985e1a..bd3452789b 100644
--- a/OsmAnd-java/src/main/java/net/osmand/data/RotatedTileBox.java
+++ b/OsmAnd-java/src/main/java/net/osmand/data/RotatedTileBox.java
@@ -2,8 +2,6 @@ package net.osmand.data;
import net.osmand.util.MapUtils;
-import java.util.Objects;
-
public class RotatedTileBox {
/// primary fields
@@ -124,11 +122,11 @@ public class RotatedTileBox {
public double getCenterTileX(){
return oxTile;
}
-
+
public int getCenter31X(){
return MapUtils.get31TileNumberX(lon);
}
-
+
public int getCenter31Y(){
return MapUtils.get31TileNumberY(lat);
}
@@ -191,7 +189,7 @@ public class RotatedTileBox {
float right = (float) MapUtils.getLongitudeFromTile(zoom, alignTile(tileBounds.right));
latLonBounds = new QuadRect(left, top, right, bottom);
}
-
+
private double alignTile(double tile) {
if(tile < 0) {
return 0;
@@ -234,7 +232,7 @@ public class RotatedTileBox {
double yTile = MapUtils.getTileNumberY(zoom, latitude);
return getPixXFromTile(xTile, yTile);
}
-
+
public float getPixXFromTile(double tileX, double tileY, float zoom) {
double pw = MapUtils.getPowZoom(zoom - this.zoom);
double xTile = tileX / pw;
@@ -261,7 +259,7 @@ public class RotatedTileBox {
double yTile = MapUtils.getTileNumberY(zoom, latitude);
return getPixYFromTile(xTile, yTile);
}
-
+
public float getPixYFromTile(double tileX, double tileY, float zoom) {
double pw = MapUtils.getPowZoom(zoom - this.zoom);
double xTile = (tileX / pw);
@@ -311,11 +309,11 @@ public class RotatedTileBox {
checkTileRectangleCalculated();
return latLonBounds;
}
-
+
public double getRotateCos() {
return rotateCos;
}
-
+
public double getRotateSin() {
return rotateSin;
}
@@ -363,7 +361,7 @@ public class RotatedTileBox {
public double getZoomAnimation() {
return zoomAnimation;
}
-
+
public double getZoomFloatPart() {
return zoomFloatPart;
}
@@ -374,7 +372,7 @@ public class RotatedTileBox {
this.zoom = zoom;
calculateDerivedFields();
}
-
+
public void setZoomAndAnimation(int zoom, double zoomAnimation) {
this.zoomAnimation = zoomAnimation;
this.zoom = zoom;
@@ -393,20 +391,20 @@ public class RotatedTileBox {
MapUtils.getLongitudeFromTile(zoom, alignTile(tileLT.x)));
}
-
+
public QuadPointDouble getLeftTopTile(double zoom) {
checkTileRectangleCalculated();
return new QuadPointDouble((tileLT.x * MapUtils.getPowZoom(zoom - this.zoom)),
(tileLT.y * MapUtils.getPowZoom(zoom - this.zoom)));
}
-
+
public QuadPointDouble getRightBottomTile(float zoom) {
checkTileRectangleCalculated();
return new QuadPointDouble((tileRB.x * MapUtils.getPowZoom(zoom - this.zoom)),
(tileRB.y * MapUtils.getPowZoom(zoom - this.zoom)));
}
-
+
private void checkTileRectangleCalculated() {
if(tileBounds == null){
@@ -424,7 +422,7 @@ public class RotatedTileBox {
this.mapDensity = mapDensity;
calculateDerivedFields();
}
-
+
public double getMapDensity() {
return mapDensity;
}
@@ -473,7 +471,7 @@ public class RotatedTileBox {
double ty = getPixYFromTile(qp.x, qp.y);
return tx >= 0 && tx <= pixWidth && ty >= 0 && ty <= pixHeight;
}
-
+
public boolean containsTilePoint(QuadPointDouble qp) {
double tx = getPixXFromTile(qp.x, qp.y);
double ty = getPixYFromTile(qp.x, qp.y);
@@ -485,7 +483,7 @@ public class RotatedTileBox {
double ty = getPixYFromLatLon(lat, lon);
return tx >= 0 && tx <= pixWidth && ty >= 0 && ty <= pixHeight;
}
-
+
public boolean containsLatLon(LatLon latLon) {
double tx = getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
double ty = getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
@@ -532,7 +530,7 @@ public class RotatedTileBox {
zoomSet = true;
return this;
}
-
+
public RotatedTileBoxBuilder setLocation(double lat, double lon) {
tb.lat = lat;
tb.lon = lon;
@@ -594,6 +592,6 @@ public class RotatedTileBox {
+ pixHeight + "]";
}
-
-
+
+
}
diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml
index db085436cd..1b0e648f6b 100644
--- a/OsmAnd/AndroidManifest.xml
+++ b/OsmAnd/AndroidManifest.xml
@@ -65,9 +65,7 @@
-
+
-
-
-
-
-
-
-
-
-
+
+ android:textAlignment="center"
+ android:autoLink="web"
+ android:text="@string/click_button_to_start_server"
+ android:gravity="center_horizontal"/>
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index d1f42491c4..61c159f342 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,6 +11,10 @@
Thx - Hardy
-->
+ Start
+ Stop
+ Click button to start server
+ Click second button to deactivate server
Web server
Please add at least two points.
is saved
diff --git a/OsmAnd/src/net/osmand/plus/activities/ServerActivity.java b/OsmAnd/src/net/osmand/plus/activities/ServerActivity.java
index 6630cb20c0..87a460ebf2 100644
--- a/OsmAnd/src/net/osmand/plus/activities/ServerActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/ServerActivity.java
@@ -27,20 +27,20 @@ public class ServerActivity extends AppCompatActivity {
enableStrictMode();
super.onCreate(savedInstanceState);
setContentView(R.layout.server_activity);
- findViewById(R.id.Button01).setOnClickListener(new View.OnClickListener() {
+ findViewById(R.id.server_start_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!initialized) {
- updateTextView("Click second button to deactivate server");
+ updateTextView(getString(R.string.click_button_to_stop_server));
initServer();
}
}
});
- findViewById(R.id.Button03).setOnClickListener(new View.OnClickListener() {
+ findViewById(R.id.server_stop_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (initialized) {
- updateTextView("Click first button to activate server");
+ updateTextView(getString(R.string.click_button_to_start_server));
deInitServer();
}
}
@@ -64,7 +64,7 @@ public class ServerActivity extends AppCompatActivity {
private void updateTextView(String text) {
- ((TextView) findViewById(R.id.TextView02)).setText(text);
+ ((TextView) findViewById(R.id.server_status_textview)).setText(text);
}
private void initServer() {
diff --git a/OsmAnd/src/net/osmand/plus/server/ApiRouter.java b/OsmAnd/src/net/osmand/plus/server/ApiRouter.java
index cdb056771c..8d16dedab6 100644
--- a/OsmAnd/src/net/osmand/plus/server/ApiRouter.java
+++ b/OsmAnd/src/net/osmand/plus/server/ApiRouter.java
@@ -6,6 +6,7 @@ import fi.iki.elonen.NanoHTTPD;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.server.endpoints.TileEndpoint;
+import net.osmand.util.Algorithms;
import java.io.BufferedReader;
import java.io.IOException;
@@ -45,13 +46,17 @@ public class ApiRouter {
public NanoHTTPD.Response route(NanoHTTPD.IHTTPSession session) {
Log.d("SERVER", "URI: " + session.getUri());
String uri = session.getUri();
- if (uri.equals("/")) return getStatic("/go.html");
+ if (uri.equals("/")) {
+ return getStatic("/go.html");
+ }
if (uri.contains("/scripts/") ||
uri.contains("/images/") ||
uri.contains("/css/") ||
uri.contains("/fonts/") ||
uri.contains("/favicon.ico")
- ) return getStatic(uri);
+ ) {
+ return getStatic(uri);
+ }
if (isApiUrl(uri)) {
return routeApi(session);
} else {
@@ -86,6 +91,7 @@ public class ApiRouter {
private NanoHTTPD.Response routeContent(NanoHTTPD.IHTTPSession session) {
String url = session.getUri();
//add index page
+ //return getStatic(session.getUri());
String responseText = getHtmlPage(url);
if (responseText != null) {
return newFixedLengthResponse(responseText);
@@ -126,6 +132,13 @@ public class ApiRouter {
}
private String readHTMLFromFile(String filename) {
+// try {
+// InputStream is = application.getAssets().open(FOLDER_NAME + filename);
+// return Algorithms.readFromInputStream(is,false).toString();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// return null;
StringBuilder sb = new StringBuilder();
try {
InputStream is = application.getAssets().open(FOLDER_NAME + filename);
diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java
index 62e05fd82c..6cf6810403 100644
--- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java
+++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java
@@ -578,7 +578,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
}
- public void refreshBaseMapInternal(RotatedTileBox tileBox, DrawSettings drawSettings) {
+ private void refreshBaseMapInternal(RotatedTileBox tileBox, DrawSettings drawSettings) {
if (tileBox.getPixHeight() == 0 || tileBox.getPixWidth() == 0) {
return;
}
@@ -615,7 +615,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
additional.calculateFPS(start, end);
}
- public void refreshMapInternal(DrawSettings drawSettings) {
+ private void refreshMapInternal(DrawSettings drawSettings) {
if (view == null) {
return;
}
@@ -868,20 +868,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
return currentViewport;
}
- public void setCurrentRotatedTileBox(net.osmand.data.RotatedTileBox tileBox) {
- float rx = (float) tileBox.getCenterPixelX() / tileBox.getPixWidth();
- float ry = (float) tileBox.getCenterPixelY() / tileBox.getPixHeight();
- if (mapPosition == OsmandSettings.BOTTOM_CONSTANT) {
- ry -= 0.35;
- }
- tileBox.setCenterLocation(rx, ry);
- LatLon screenCenter = tileBox.getLatLonFromPixel(tileBox.getPixWidth() / 2f, tileBox.getPixHeight() / 2f);
- mapRatioX = 0;
- mapRatioY = 0;
- setLatLon(screenCenter.getLatitude(), screenCenter.getLongitude());
- currentViewport = tileBox;
- }
-
public float getDensity() {
return currentViewport.getDensity();
}