mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 12:42:56 -04:00
Server started successfully dialog
This commit is contained in:
parent
48d9978f6a
commit
e15f398f9f
@ -2,6 +2,8 @@ package org.kiwix.kiwixmobile.webserver;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.InputFilter;
|
import android.text.InputFilter;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -17,6 +19,8 @@ import java.net.SocketException;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import org.kiwix.kiwixmobile.R;
|
import org.kiwix.kiwixmobile.R;
|
||||||
|
|
||||||
|
import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle;
|
||||||
|
|
||||||
public class WebServerHelper {
|
public class WebServerHelper {
|
||||||
private Context context;
|
private Context context;
|
||||||
private TextView textViewIpAccess;
|
private TextView textViewIpAccess;
|
||||||
@ -63,7 +67,7 @@ public class WebServerHelper {
|
|||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
if (!isStarted && startAndroidWebServer()) {
|
if (!isStarted && startAndroidWebServer()) {
|
||||||
isStarted = true;
|
isStarted = true;
|
||||||
editTextPort.setEnabled(false);
|
serverStartedDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -145,4 +149,18 @@ public class WebServerHelper {
|
|||||||
Log.v("DANG", "Returning : " + "http://" + ip);
|
Log.v("DANG", "Returning : " + "http://" + ip);
|
||||||
return "http://" + ip;
|
return "http://" + ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void serverStartedDialog() {
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context, dialogStyle());
|
||||||
|
WebServerHelper webServerHelper = new WebServerHelper(context);
|
||||||
|
builder.setPositiveButton(android.R.string.ok, (dialog, id) -> {
|
||||||
|
|
||||||
|
});
|
||||||
|
builder.setTitle(context.getString(R.string.server_started_title));
|
||||||
|
builder.setMessage(
|
||||||
|
context.getString(R.string.server_started_message) + "\n " + getIpAddress() + ":" + port);
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
<string name="mobile_data_message">You\'re about to turn on your wifi hotspot. This feature can work without data usage.</string>
|
<string name="mobile_data_message">You\'re about to turn on your wifi hotspot. This feature can work without data usage.</string>
|
||||||
<string name="mobile_data_message_confirmation">Do you want to disable your data?</string>
|
<string name="mobile_data_message_confirmation">Do you want to disable your data?</string>
|
||||||
<string name="sample_ip_address">http://000.000.000.000</string>
|
<string name="sample_ip_address">http://000.000.000.000</string>
|
||||||
|
<string name="server_started_title">Server started</string>
|
||||||
|
<string name="server_started_message">Enter this ip address into your browser to access the server</string>
|
||||||
<string name="error_filenotfound">Error: The selected ZIM file could not be found.</string>
|
<string name="error_filenotfound">Error: The selected ZIM file could not be found.</string>
|
||||||
<string name="error_fileinvalid">Error: The selected file is not a valid ZIM file.</string>
|
<string name="error_fileinvalid">Error: The selected file is not a valid ZIM file.</string>
|
||||||
<string name="error_articleurlnotfound">Error: Loading article (Url: %1$s) failed.</string>
|
<string name="error_articleurlnotfound">Error: Loading article (Url: %1$s) failed.</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user