Add dialog showing hotspot details for versions <O

This commit is contained in:
Adeel Zafar 2019-07-06 18:17:42 +05:00
parent ecf134a632
commit 35ed0e079d
3 changed files with 21 additions and 6 deletions

View File

@ -185,7 +185,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
public static boolean refresh;
public static boolean wifiOnly;
public static boolean nightMode;
private WifiHotspotManager wifiHotspotManager;
private static WifiHotspotManager wifiHotspotManager;
private static Uri KIWIX_LOCAL_MARKET_URI;
private static Uri KIWIX_BROWSER_MARKET_URI;
private final ArrayList<String> bookmarks = new ArrayList<>();
@ -1099,6 +1099,10 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
}
}
public static void startHotspotDetails() {
wifiHotspotManager.hotspotDetailsDialog();
}
private void startService(String ACTION) {
serviceIntent.setAction(ACTION);
this.startService(serviceIntent);

View File

@ -23,6 +23,7 @@ import static org.kiwix.kiwixmobile.main.MainActivity.ACTION_TURN_OFF_AFTER_O;
import static org.kiwix.kiwixmobile.main.MainActivity.ACTION_TURN_OFF_BEFORE_O;
import static org.kiwix.kiwixmobile.main.MainActivity.ACTION_TURN_ON_AFTER_O;
import static org.kiwix.kiwixmobile.main.MainActivity.ACTION_TURN_ON_BEFORE_O;
import static org.kiwix.kiwixmobile.main.MainActivity.startHotspotDetails;
public class HotspotService extends Service {
private static final int HOTSPOT_NOTIFICATION_ID = 666;
@ -57,6 +58,8 @@ public class HotspotService extends Service {
switch (intent.getAction()) {
case ACTION_TURN_ON_BEFORE_O:
if (hotspotManager.setWifiEnabled(null, true)) {
Log.v("DANG", "INSIDE");
startHotspotDetails();
updateNotification(getString(R.string.hotspot_running), true);
}
break;

View File

@ -179,7 +179,7 @@ public class WifiHotspotManager {
}
}
private void hotspotDetailsDialog() {
public void hotspotDetailsDialog() {
Log.v("DANG", "Coming hotspot details dialog :4");
@ -189,10 +189,18 @@ public class WifiHotspotManager {
//Do nothing
});
builder.setTitle(context.getString(R.string.hotspot_turned_on));
builder.setMessage(
context.getString(R.string.hotspot_details_message) + "\n" + context.getString(
R.string.hotspot_ssid_label) + " " + currentConfig.SSID + "\n" + context.getString(
R.string.hotspot_pass_label) + " " + currentConfig.preSharedKey);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setMessage(
context.getString(R.string.hotspot_details_message) + "\n" + context.getString(
R.string.hotspot_ssid_label) + " " + currentConfig.SSID + "\n" + context.getString(
R.string.hotspot_pass_label) + " " + currentConfig.preSharedKey);
} else {
currentConfig = getWifiApConfiguration();
builder.setMessage(
context.getString(R.string.hotspot_details_message) + "\n" + context.getString(
R.string.hotspot_ssid_label) + " " + currentConfig.SSID + "\n" + context.getString(
R.string.hotspot_pass_label) + " " + currentConfig.preSharedKey);
}
AlertDialog dialog = builder.create();
dialog.show();
Log.v("DANG", "Coming end of hotspot details dialog :5");