From a1b35317a3ca08ea98ff9a209a8d201c6363083f Mon Sep 17 00:00:00 2001 From: Adeel Zafar Date: Fri, 9 Aug 2019 20:14:56 +0500 Subject: [PATCH] Add ProgressDialog for turning on webserver --- .../kiwixmobile/webserver/ZimHostActivity.java | 13 +++++++++++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 14 insertions(+) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java index 2e923522f..082ee5750 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java @@ -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(); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ef8d877c8..3aadb9526 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -32,6 +32,7 @@ Pass : 8080 Select the files you wish to host on the server + Starting server Start server You can now start the server using this ip address and port no. Warning: Mobile data enabled