Add ProgressDialog for turning on webserver

This commit is contained in:
Adeel Zafar 2019-08-09 20:14:56 +05:00
parent 05d7546c9c
commit a1b35317a3
2 changed files with 14 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package org.kiwix.kiwixmobile.webserver;
import android.Manifest;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@ -321,10 +322,15 @@ public class ZimHostActivity extends AppCompatActivity implements
//TO DO: START SERVER WITHIN THE SERVICE.
//Adding a handler because sometimes hotspot can take time to turn on.
//TO DO: Add a progress dialog instead of handler
ProgressDialog progressDialog =
ProgressDialog.show(this, getString(R.string.progress_dialog_starting_server), "",
true);
progressDialog.show();
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
startService(ACTION_START_SERVER);
}
}, 7000);
@ -380,11 +386,18 @@ public class ZimHostActivity extends AppCompatActivity implements
//Show an alert dialog for hotspot details
AlertDialog.Builder builder = new AlertDialog.Builder(this, dialogStyle());
ProgressDialog progressDialog =
ProgressDialog.show(this, getString(R.string.progress_dialog_starting_server), "",
true);
progressDialog.show();
builder.setPositiveButton(android.R.string.ok, (dialog, id) -> {
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
startService(ACTION_START_SERVER);
//webServerHelper.startServerHelper();
}

View File

@ -32,6 +32,7 @@
<string name="hotspot_pass_label">Pass : </string>
<string name="port_hint">8080</string>
<string name="server_textview_default_message">Select the files you wish to host on the server</string>
<string name="progress_dialog_starting_server">Starting server</string>
<string name="start_server_dialog_title">Start server</string>
<string name="start_server_dialog_message">You can now start the server using this ip address and port no.</string>
<string name="mobile_data_enabled">Warning: Mobile data enabled</string>