Server started successfully dialog

This commit is contained in:
Adeel Zafar 2019-07-26 18:44:38 +05:00
parent 48d9978f6a
commit e15f398f9f
2 changed files with 21 additions and 1 deletions

View File

@ -2,6 +2,8 @@ package org.kiwix.kiwixmobile.webserver;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Handler;
import android.text.InputFilter;
import android.text.InputType;
import android.util.Log;
@ -17,6 +19,8 @@ import java.net.SocketException;
import java.util.Enumeration;
import org.kiwix.kiwixmobile.R;
import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle;
public class WebServerHelper {
private Context context;
private TextView textViewIpAccess;
@ -63,7 +67,7 @@ public class WebServerHelper {
public void onClick(DialogInterface dialog, int whichButton) {
if (!isStarted && startAndroidWebServer()) {
isStarted = true;
editTextPort.setEnabled(false);
serverStartedDialog();
}
}
});
@ -145,4 +149,18 @@ public class WebServerHelper {
Log.v("DANG", "Returning : " + "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();
}
}

View File

@ -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_confirmation">Do you want to disable your data?</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_fileinvalid">Error: The selected file is not a valid ZIM file.</string>
<string name="error_articleurlnotfound">Error: Loading article (Url: %1$s) failed.</string>