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