mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Add location permissions
This commit is contained in:
parent
d04839f6ef
commit
8349f6d380
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user