Handle the interruption of the permission request
This commit is contained in:
parent
291509580c
commit
9bb7b295d9
1 changed files with 32 additions and 30 deletions
|
@ -1660,41 +1660,43 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull final int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull final int[] grantResults) {
|
||||||
OsmandPlugin.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
if (grantResults.length > 0) {
|
||||||
|
OsmandPlugin.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
MapControlsLayer mcl = mapView.getLayerByClass(MapControlsLayer.class);
|
MapControlsLayer mcl = mapView.getLayerByClass(MapControlsLayer.class);
|
||||||
if (mcl != null) {
|
if (mcl != null) {
|
||||||
mcl.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
mcl.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
|
if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
|
||||||
&& grantResults.length > 0 && permissions.length > 0
|
&& grantResults.length > 0 && permissions.length > 0
|
||||||
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
|
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
|
||||||
permissionAsked = true;
|
permissionAsked = true;
|
||||||
permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||||
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION
|
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION
|
||||||
&& grantResults.length > 0 && permissions.length > 0
|
&& grantResults.length > 0 && permissions.length > 0
|
||||||
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
|
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
|
||||||
|
|
||||||
new Timer().schedule(new TimerTask() {
|
new Timer().schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
|
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
|
||||||
if (wizardFragment != null) {
|
if (wizardFragment != null) {
|
||||||
wizardFragment.processStoragePermission(grantResults[0] == PackageManager.PERMISSION_GRANTED);
|
wizardFragment.processStoragePermission(grantResults[0] == PackageManager.PERMISSION_GRANTED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}, 1);
|
||||||
}, 1);
|
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_LOCATION_PERMISSION) {
|
||||||
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_LOCATION_PERMISSION) {
|
new Timer().schedule(new TimerTask() {
|
||||||
new Timer().schedule(new TimerTask() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
|
||||||
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
|
if (wizardFragment != null) {
|
||||||
if (wizardFragment != null) {
|
wizardFragment.processLocationPermission(grantResults[0] == PackageManager.PERMISSION_GRANTED);
|
||||||
wizardFragment.processLocationPermission(grantResults[0] == PackageManager.PERMISSION_GRANTED);
|
}
|
||||||
}
|
}
|
||||||
}
|
}, 1);
|
||||||
}, 1);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
Loading…
Reference in a new issue