Add location permissions

This commit is contained in:
Adeel Zafar 2019-05-31 17:18:09 +05:00
parent d04839f6ef
commit 8349f6d380
2 changed files with 13 additions and 0 deletions

View File

@ -241,6 +241,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
private CompatFindActionModeCallback compatCallback;
private TabsAdapter tabsAdapter;
private int currentWebViewIndex = 0;
private final int MY_PERMISSIONS_ACCESS_FINE_LOCATION = 102;
private File file;
private ActionMode actionMode = null;
private KiwixWebView tempForUndo;
@ -931,7 +932,16 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
case R.id.menu_wifi_hotspot:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
wifiHotspotManager.turnOnHotspot();
} else {
//Show rationale and request permission.
//No explanation needed; request the permission
ActivityCompat.requestPermissions(this,
new String[] { Manifest.permission.ACCESS_FINE_LOCATION },
MY_PERMISSIONS_ACCESS_FINE_LOCATION);
}
} else {
if (wifiHotspotManager.isWifiApEnabled()) {
wifiHotspotManager.setWifiEnabled(null, false);

View File

@ -22,6 +22,7 @@ public class WifiHotspotManager {
private WifiManager wifiManager;
private Context context;
private WifiManager.LocalOnlyHotspotReservation hotspotReservation;
private boolean oreoenabled = false;
public WifiHotspotManager(Context context) {
this.context = context;
@ -64,6 +65,7 @@ public class WifiHotspotManager {
public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) {
super.onStarted(reservation);
//hotspotReservation = reservation;
oreoenabled = true;
}
@Override
@ -85,6 +87,7 @@ public class WifiHotspotManager {
public void turnOffHotspot() {
if (hotspotReservation != null) {
hotspotReservation.close();
oreoenabled = false;
}
}