small changes

This commit is contained in:
simon 2020-09-07 12:08:57 +03:00
parent cdde9f3960
commit b4d4e79b6a
5 changed files with 13 additions and 13 deletions

View file

@ -13,19 +13,19 @@
android:textAlignment="center" android:textAlignment="center"
android:autoLink="web" android:autoLink="web"
android:textColor="@color/color_white" android:textColor="@color/color_white"
android:text="@string/click_button_to_start_server" android:text="@string/start_web_server"
android:gravity="center_horizontal"/> android:gravity="center_horizontal"/>
<Button <Button
android:id="@+id/server_start_button" android:id="@+id/server_start_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/global_start"/> android:text="@string/shared_string_start"/>
<Button <Button
android:id="@+id/server_stop_button" android:id="@+id/server_stop_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/global_stop"/> android:text="@string/shared_string_stop"/>
</LinearLayout> </LinearLayout>

View file

@ -11,10 +11,10 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="global_start">Start</string> <string name="shared_string_stop">Stop</string>
<string name="global_stop">Stop</string> <string name="shared_string_start">Start</string>
<string name="click_button_to_start_server">Click button to start server</string> <string name="start_web_server">Start web server</string>
<string name="click_button_to_stop_server">Click second button to deactivate server</string> <string name="stop_web_server">Stop web server</string>
<string name="web_server">Web server</string> <string name="web_server">Web server</string>
<string name="shared_string_redo">Redo</string> <string name="shared_string_redo">Redo</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>

View file

@ -25,8 +25,9 @@ public class OsmAndHttpServer extends NanoHTTPD{
private OsmandApplication application; private OsmandApplication application;
private MapActivity mapActivity; private MapActivity mapActivity;
public OsmAndHttpServer() throws IOException { public OsmAndHttpServer(OsmandApplication application) throws IOException {
super(HOSTNAME, PORT); super(HOSTNAME, PORT);
this.application = application;
start(NanoHTTPD.SOCKET_READ_TIMEOUT, false); start(NanoHTTPD.SOCKET_READ_TIMEOUT, false);
registerEndpoints(); registerEndpoints();
} }
@ -46,7 +47,7 @@ public class OsmAndHttpServer extends NanoHTTPD{
public Response serve(IHTTPSession session) { public Response serve(IHTTPSession session) {
String uri = session.getUri(); String uri = session.getUri();
if (uri.equals("/")) { if (uri.equals("/")) {
return getStatic("/go.html"); return getStatic("/index.html");
} }
if (isApiUrl(uri)) { if (isApiUrl(uri)) {
return routeApi(session); return routeApi(session);

View file

@ -41,7 +41,7 @@ public class ServerFragment extends BaseOsmAndFragment {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (!initialized) { if (!initialized) {
updateTextView(getString(R.string.click_button_to_stop_server)); updateTextView(getString(R.string.stop_web_server));
initServer(); initServer();
} }
} }
@ -49,7 +49,7 @@ public class ServerFragment extends BaseOsmAndFragment {
view.findViewById(R.id.server_stop_button).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.server_stop_button).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
updateTextView(getString(R.string.click_button_to_start_server)); updateTextView(getString(R.string.start_web_server));
deInitServer(); deInitServer();
} }
}); });
@ -86,8 +86,7 @@ public class ServerFragment extends BaseOsmAndFragment {
TrafficStats.setThreadStatsTag(THREAD_ID); TrafficStats.setThreadStatsTag(THREAD_ID);
OsmAndHttpServer.HOSTNAME = getDeviceAddress(); OsmAndHttpServer.HOSTNAME = getDeviceAddress();
try { try {
server = new OsmAndHttpServer(); server = new OsmAndHttpServer(getMyApplication());
server.setApplication((OsmandApplication) getMyApplication());
server.setActivity(this.getActivity()); server.setActivity(this.getActivity());
initialized = true; initialized = true;
updateTextView("Server started at: http://" + getDeviceAddress() + ":" + OsmAndHttpServer.PORT); updateTextView("Server started at: http://" + getDeviceAddress() + ":" + OsmAndHttpServer.PORT);