mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Rename isStarted to isServerStarted
This commit is contained in:
parent
5b76579022
commit
8e6edf9f65
@ -14,7 +14,7 @@ import java.util.Enumeration;
|
||||
|
||||
public class WebServerHelper {
|
||||
Context context;
|
||||
public static boolean isStarted;
|
||||
public static boolean isServerStarted;
|
||||
static int port;
|
||||
|
||||
public WebServerHelper(Context context) {
|
||||
@ -27,15 +27,15 @@ public class WebServerHelper {
|
||||
//2. Ask user to change port in settings if port is in use.
|
||||
//OR
|
||||
//Always use 8080 and when its not available then iterate this number.
|
||||
if (!isStarted && startAndroidWebServer()) {
|
||||
isStarted = true;
|
||||
if (!isServerStarted && startAndroidWebServer()) {
|
||||
isServerStarted = true;
|
||||
stateListener.serverStarted(getIpAddress() + ":" + port);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean stopAndroidWebServer(ServerStateListener stateListener) {
|
||||
if (isStarted) {
|
||||
isStarted = false;
|
||||
if (isServerStarted) {
|
||||
isServerStarted = false;
|
||||
stateListener.serverStopped();
|
||||
return true;
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class WebServerHelper {
|
||||
}
|
||||
|
||||
boolean startAndroidWebServer() {
|
||||
if (!isStarted) {
|
||||
if (!isServerStarted) {
|
||||
port = 8080;
|
||||
//Call to start server
|
||||
return true;
|
||||
|
@ -46,7 +46,7 @@ import org.kiwix.kiwixmobile.zim_manager.fileselect_view.ZimFileSelectFragment;
|
||||
|
||||
import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle;
|
||||
import static org.kiwix.kiwixmobile.webserver.WebServerHelper.getAddress;
|
||||
import static org.kiwix.kiwixmobile.webserver.WebServerHelper.isStarted;
|
||||
import static org.kiwix.kiwixmobile.webserver.WebServerHelper.isServerStarted;
|
||||
|
||||
public class ZimHostActivity extends AppCompatActivity implements
|
||||
ServerStateListener {
|
||||
@ -123,7 +123,7 @@ public class ZimHostActivity extends AppCompatActivity implements
|
||||
//if (isMobileDataEnabled(context)) {
|
||||
// mobileDataDialog();
|
||||
//} else {
|
||||
if (isStarted) {
|
||||
if (isServerStarted) {
|
||||
startService(ACTION_STOP_SERVER);
|
||||
} else {
|
||||
startHotspotDialog();
|
||||
@ -174,7 +174,7 @@ public class ZimHostActivity extends AppCompatActivity implements
|
||||
|
||||
@Override protected void onResume() {
|
||||
super.onResume();
|
||||
if (isStarted) {
|
||||
if (isServerStarted) {
|
||||
ip = getAddress();
|
||||
ip = ip.replaceAll("\n", "");
|
||||
serverTextView.setText(
|
||||
@ -378,14 +378,14 @@ public class ZimHostActivity extends AppCompatActivity implements
|
||||
serverTextView.setText(getString(R.string.server_started_message) + " " + ip);
|
||||
startServerButton.setText(getString(R.string.stop_server_label));
|
||||
startServerButton.setBackgroundColor(getResources().getColor(R.color.stopServer));
|
||||
isStarted = true;
|
||||
isServerStarted = true;
|
||||
}
|
||||
|
||||
@Override public void serverStopped() {
|
||||
serverTextView.setText(getString(R.string.server_textview_default_message));
|
||||
startServerButton.setText(getString(R.string.start_server_label));
|
||||
startServerButton.setBackgroundColor(getResources().getColor(R.color.greenTick));
|
||||
isStarted = false;
|
||||
isServerStarted = false;
|
||||
}
|
||||
|
||||
@Override public void hotspotTurnedOn(WifiConfiguration wifiConfiguration) {
|
||||
@ -461,7 +461,7 @@ public class ZimHostActivity extends AppCompatActivity implements
|
||||
|
||||
@Override protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if (isStarted) {
|
||||
if (isServerStarted) {
|
||||
outState.putString(IP_STATE_KEY, ip);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user