From be95e23c055b7bc18d050790edd763d5dd1fae85 Mon Sep 17 00:00:00 2001 From: Adeel Zafar Date: Fri, 2 Aug 2019 01:21:07 +0500 Subject: [PATCH] Dialog to turn on hotspot manually for API<26 --- .../kiwix/kiwixmobile/main/MainActivity.java | 20 +++++++++++++++++++ app/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/MainActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/main/MainActivity.java index aaf10bd3a..82333f75d 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/main/MainActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/main/MainActivity.java @@ -959,6 +959,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback, toggleHotspot(); } else { //TO DO: show Dialog() + within that add check mobile Data check later. + startHotspotDialog(); } } default: @@ -1109,6 +1110,25 @@ public class MainActivity extends BaseActivity implements WebViewCallback, this.startService(serviceIntent); } + //Advice user to turn on hotspot manually for API<26 + private void startHotspotDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(this, dialogStyle()); + + builder.setPositiveButton(getString(R.string.hotspot_dialog_positive_button), (dialog, id) -> { + }); + + builder.setNeutralButton(getString(R.string.hotspot_dialog_neutral_button), (dialog, id) -> { + //TO DO: START SERVER WITHIN THE SERVICE. + }); + + builder.setTitle(getString(R.string.hotspot_dialog_title)); + builder.setMessage( + getString(R.string.hotspot_dialog_message) + ); + AlertDialog dialog = builder.create(); + dialog.show(); + } + private void mobileDataDialog() { if (Build.VERSION.SDK_INT < VERSION_CODES.O) { AlertDialog.Builder builder = new AlertDialog.Builder(this, dialogStyle()); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dd7894bf8..1a3fe09be 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -34,6 +34,10 @@ Warning: Mobile data enabled You\'re about to turn on your wifi hotspot. This feature can work without data usage. Do you want to disable your data? + Turn on your hotspot + In order for this feature to work you need to turn on your hotspot first. + YES, I’VE TURNED IT ON + Okay http://000.000.000.000 Server started Enter this ip address into your browser to access the server