Dialog to turn on hotspot manually for API<26

This commit is contained in:
Adeel Zafar 2019-08-02 01:21:07 +05:00
parent bf46fe28b1
commit be95e23c05
2 changed files with 24 additions and 0 deletions

View File

@ -959,6 +959,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
toggleHotspot(); toggleHotspot();
} else { } else {
//TO DO: show Dialog() + within that add check mobile Data check later. //TO DO: show Dialog() + within that add check mobile Data check later.
startHotspotDialog();
} }
} }
default: default:
@ -1109,6 +1110,25 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
this.startService(serviceIntent); 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() { private void mobileDataDialog() {
if (Build.VERSION.SDK_INT < VERSION_CODES.O) { if (Build.VERSION.SDK_INT < VERSION_CODES.O) {
AlertDialog.Builder builder = new AlertDialog.Builder(this, dialogStyle()); AlertDialog.Builder builder = new AlertDialog.Builder(this, dialogStyle());

View File

@ -34,6 +34,10 @@
<string name="mobile_data_enabled">Warning: Mobile data enabled</string> <string name="mobile_data_enabled">Warning: Mobile data enabled</string>
<string name="mobile_data_message">You\'re about to turn on your wifi hotspot. This feature can work without data usage.</string> <string name="mobile_data_message">You\'re about to turn on your wifi hotspot. This feature can work without data usage.</string>
<string name="mobile_data_message_confirmation">Do you want to disable your data?</string> <string name="mobile_data_message_confirmation">Do you want to disable your data?</string>
<string name="hotspot_dialog_title">Turn on your hotspot</string>
<string name="hotspot_dialog_message">In order for this feature to work you need to turn on your hotspot first.</string>
<string name="hotspot_dialog_neutral_button">YES, IVE TURNED IT ON</string>
<string name="hotspot_dialog_positive_button">Okay</string>
<string name="sample_ip_address">http://000.000.000.000</string> <string name="sample_ip_address">http://000.000.000.000</string>
<string name="server_started_title">Server started</string> <string name="server_started_title">Server started</string>
<string name="server_started_message">Enter this ip address into your browser to access the server</string> <string name="server_started_message">Enter this ip address into your browser to access the server</string>