From 378916012f26ac8f4004d5840e45bacef5bd159f Mon Sep 17 00:00:00 2001 From: Adeel Zafar Date: Sat, 10 Aug 2019 08:20:53 +0500 Subject: [PATCH] Refactor turn on hotspot manually dialog Add go to settings button Remove okay string from string.xml Refactor title and message of dialog --- .../webserver/ZimHostActivity.java | 20 +++++++++++-------- app/src/main/res/values/strings.xml | 5 ++--- 2 files changed, 14 insertions(+), 11 deletions(-) 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 06b8a699b..7bc6acf2c 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostActivity.java @@ -315,7 +315,8 @@ public class ZimHostActivity extends AppCompatActivity implements void startHotspotDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this, dialogStyle()); - builder.setPositiveButton(getString(R.string.hotspot_dialog_positive_button), (dialog, id) -> { + builder.setPositiveButton(getString(R.string.go_to_wifi_settings_label), (dialog, id) -> { + setupWifiSettingsIntent(); }); builder.setNeutralButton(getString(R.string.hotspot_dialog_neutral_button), (dialog, id) -> { @@ -415,6 +416,15 @@ public class ZimHostActivity extends AppCompatActivity implements dialog.show(); } + private void setupWifiSettingsIntent() { + final Intent intent = new Intent(Intent.ACTION_MAIN, null); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + final ComponentName cn = + new ComponentName("com.android.settings", "com.android.settings.TetherSettings"); + intent.setComponent(cn); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } @Override public void hotspotFailed() { //Show a dialog to turn off default hotspot @@ -422,13 +432,7 @@ public class ZimHostActivity extends AppCompatActivity implements builder.setPositiveButton(getString(R.string.go_to_wifi_settings_label), (dialog, id) -> { //Open wifi settings intent - final Intent intent = new Intent(Intent.ACTION_MAIN, null); - intent.addCategory(Intent.CATEGORY_LAUNCHER); - final ComponentName cn = - new ComponentName("com.android.settings", "com.android.settings.TetherSettings"); - intent.setComponent(cn); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); + setupWifiSettingsIntent(); }); builder.setTitle(this.getString(R.string.hotspot_failed_title)); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6ac592425..da57f96c9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -41,10 +41,9 @@ 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. + Turn on your WIFI hotspot + In order for this feature to work you need to turn on your WIFI hotspot first. YES, I’VE TURNED IT ON - Okay http://000.000.000.000 Start server Stop server