still cleanup
This commit is contained in:
parent
1f8dbb7694
commit
2869cae3a0
7 changed files with 69 additions and 92 deletions
|
@ -2,8 +2,6 @@ package net.osmand.data;
|
||||||
|
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class RotatedTileBox {
|
public class RotatedTileBox {
|
||||||
|
|
||||||
/// primary fields
|
/// primary fields
|
||||||
|
|
|
@ -65,9 +65,7 @@
|
||||||
<meta-data android:name="com.sec.minimode.icon.landscape.normal" android:resource="@mipmap/icon" android:value="" />
|
<meta-data android:name="com.sec.minimode.icon.landscape.normal" android:resource="@mipmap/icon" android:value="" />
|
||||||
<activity android:name="net.osmand.plus.activities.HelpActivity" />
|
<activity android:name="net.osmand.plus.activities.HelpActivity" />
|
||||||
<activity android:name="net.osmand.plus.activities.ExitActivity" />
|
<activity android:name="net.osmand.plus.activities.ExitActivity" />
|
||||||
<activity android:name=".activities.ServerActivity"
|
<activity android:name=".activities.ServerActivity" />
|
||||||
android:label="@string/shared_string_settings"
|
|
||||||
android:configChanges="keyboardHidden|orientation" />
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
|
|
@ -1,51 +1,29 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
android:padding="10px">
|
android:padding="10px">
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/RelativeLayout03"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="20px"
|
|
||||||
android:layout_marginBottom="40px">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/TextView02"
|
android:id="@+id/server_status_textview"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:autoLink="web"
|
|
||||||
android:text="Click button to start server"></TextView>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/Button01"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/RelativeLayout03"
|
android:textAlignment="center"
|
||||||
android:layout_alignParentLeft="true"
|
android:autoLink="web"
|
||||||
android:layout_marginBottom="40px"
|
android:text="@string/click_button_to_start_server"
|
||||||
android:text="Start"></Button>
|
android:gravity="center_horizontal"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/Button03"
|
android:id="@+id/server_start_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/Button01"
|
android:text="@string/global_start"/>
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:text="Stop"></Button>
|
|
||||||
|
|
||||||
<TextView
|
<Button
|
||||||
android:id="@+id/textView1"
|
android:id="@+id/server_stop_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignRight="@+id/Button03"
|
android:text="@string/global_stop"/>
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:lines="14"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textSize="8dp" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</LinearLayout>
|
|
@ -11,6 +11,10 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="global_start">Start</string>
|
||||||
|
<string name="global_stop">Stop</string>
|
||||||
|
<string name="click_button_to_start_server">Click button to start server</string>
|
||||||
|
<string name="click_button_to_stop_server">Click second button to deactivate server</string>
|
||||||
<string name="web_server">Web server</string>
|
<string name="web_server">Web server</string>
|
||||||
<string name="one_point_error">Please add at least two points.</string>
|
<string name="one_point_error">Please add at least two points.</string>
|
||||||
<string name="shared_string_is_saved">is saved</string>
|
<string name="shared_string_is_saved">is saved</string>
|
||||||
|
|
|
@ -27,20 +27,20 @@ public class ServerActivity extends AppCompatActivity {
|
||||||
enableStrictMode();
|
enableStrictMode();
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.server_activity);
|
setContentView(R.layout.server_activity);
|
||||||
findViewById(R.id.Button01).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.server_start_button).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
updateTextView("Click second button to deactivate server");
|
updateTextView(getString(R.string.click_button_to_stop_server));
|
||||||
initServer();
|
initServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
findViewById(R.id.Button03).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.server_stop_button).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
updateTextView("Click first button to activate server");
|
updateTextView(getString(R.string.click_button_to_start_server));
|
||||||
deInitServer();
|
deInitServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class ServerActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
private void updateTextView(String text) {
|
private void updateTextView(String text) {
|
||||||
((TextView) findViewById(R.id.TextView02)).setText(text);
|
((TextView) findViewById(R.id.server_status_textview)).setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initServer() {
|
private void initServer() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import fi.iki.elonen.NanoHTTPD;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.server.endpoints.TileEndpoint;
|
import net.osmand.plus.server.endpoints.TileEndpoint;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -45,13 +46,17 @@ public class ApiRouter {
|
||||||
public NanoHTTPD.Response route(NanoHTTPD.IHTTPSession session) {
|
public NanoHTTPD.Response route(NanoHTTPD.IHTTPSession session) {
|
||||||
Log.d("SERVER", "URI: " + session.getUri());
|
Log.d("SERVER", "URI: " + session.getUri());
|
||||||
String 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/") ||
|
if (uri.contains("/scripts/") ||
|
||||||
uri.contains("/images/") ||
|
uri.contains("/images/") ||
|
||||||
uri.contains("/css/") ||
|
uri.contains("/css/") ||
|
||||||
uri.contains("/fonts/") ||
|
uri.contains("/fonts/") ||
|
||||||
uri.contains("/favicon.ico")
|
uri.contains("/favicon.ico")
|
||||||
) return getStatic(uri);
|
) {
|
||||||
|
return getStatic(uri);
|
||||||
|
}
|
||||||
if (isApiUrl(uri)) {
|
if (isApiUrl(uri)) {
|
||||||
return routeApi(session);
|
return routeApi(session);
|
||||||
} else {
|
} else {
|
||||||
|
@ -86,6 +91,7 @@ public class ApiRouter {
|
||||||
private NanoHTTPD.Response routeContent(NanoHTTPD.IHTTPSession session) {
|
private NanoHTTPD.Response routeContent(NanoHTTPD.IHTTPSession session) {
|
||||||
String url = session.getUri();
|
String url = session.getUri();
|
||||||
//add index page
|
//add index page
|
||||||
|
//return getStatic(session.getUri());
|
||||||
String responseText = getHtmlPage(url);
|
String responseText = getHtmlPage(url);
|
||||||
if (responseText != null) {
|
if (responseText != null) {
|
||||||
return newFixedLengthResponse(responseText);
|
return newFixedLengthResponse(responseText);
|
||||||
|
@ -126,6 +132,13 @@ public class ApiRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readHTMLFromFile(String filename) {
|
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();
|
StringBuilder sb = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
InputStream is = application.getAssets().open(FOLDER_NAME + filename);
|
InputStream is = application.getAssets().open(FOLDER_NAME + filename);
|
||||||
|
|
|
@ -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) {
|
if (tileBox.getPixHeight() == 0 || tileBox.getPixWidth() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -615,7 +615,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
additional.calculateFPS(start, end);
|
additional.calculateFPS(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshMapInternal(DrawSettings drawSettings) {
|
private void refreshMapInternal(DrawSettings drawSettings) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -868,20 +868,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
return currentViewport;
|
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() {
|
public float getDensity() {
|
||||||
return currentViewport.getDensity();
|
return currentViewport.getDensity();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue