Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display warning in toast if background location is requested but location is turned off in settings #3427

Open
lognaturel opened this issue Oct 30, 2019 · 8 comments · May be fixed by #3575
Open
Assignees

Comments

@lognaturel
Copy link
Member

@lognaturel lognaturel commented Oct 30, 2019

Let the enumerator know if no location provider is available for a background location request. Forum user request.

BackgroundLocationManager.locationPermissionGranted does this for audit location requests but not for background location requests. This was not done for background location requests because locationClient.isLocationAvailable docs say Must be called <b>after</b> Location updates have been requested. In the case of background location requests, the setgeopoint action manages its own location client so BackgroundLocationManager doesn't request location updates. However, I don't think that the order is strictly necessary and we could call locationClient.isLocationAvailable. I believe the reason that requirement is there is to ensure the priority level is set before. It may not be relevant in this case.

@neilong31

This comment has been minimized.

Copy link

@neilong31 neilong31 commented Nov 2, 2019

Hello @lognaturel ! I'd love to try and work on this issue.

@lognaturel

This comment has been minimized.

Copy link
Member Author

@lognaturel lognaturel commented Nov 4, 2019

That would be wonderful, @neilong31! I'd recommend starting by making sure you understand the behavior of isLocationAvailable if it's called before location updates are requested. Is that actually a reasonable thing to do or not? You may also have ideas for alternate ways to find out whether location is available or not.

@neilong31

This comment has been minimized.

Copy link

@neilong31 neilong31 commented Nov 5, 2019

Thank you for a starting point! I'm looking through and trying to understand the behavior. I'll submit a PR detailing my logic.

@chidauri

This comment has been minimized.

Copy link
Collaborator

@chidauri chidauri commented Dec 28, 2019

Hello @lognaturel , I'd like to work on this issue, is this already being worked on?

I found something strange!

if (PermissionUtils.areLocationPermissionsGranted(this) != locationPermissionsPreviouslyGranted) {
backgroundLocationViewModel.locationPermissionChanged();
locationPermissionsPreviouslyGranted = !locationPermissionsPreviouslyGranted;
}

This block should only run when user has changed the location settings, right? In my case this runs even if i don't change settings, i checked with a Toast message and it is being displayed every time i open up the form entry.

@lognaturel

This comment has been minimized.

Copy link
Member Author

@lognaturel lognaturel commented Dec 28, 2019

Please go ahead and claim it, @chidauri.

locationPermissionsPreviouslyGranted is a field on the activity so it is set to false each time the activity is rebuilt. So indeed there will always be a permissions check on activity open. I believe that’s the intended flow but haven’t gone back to look at the details. You can verify that this makes sense and offer an alternative if you think it doesn’t. The field represents something more like “permissions known to have been granted during this form edit session” and perhaps you have an alternate name to suggest.

@chidauri

This comment has been minimized.

Copy link
Collaborator

@chidauri chidauri commented Dec 29, 2019

@lognaturel Hi, can you please point me to where are start-geopoint location requests handled?
Ps. I have made some changes regarding this issue and i tested it with disabling location myself and it shows a Toast message(which was expected), is there another way i can test this? should i open a PR?
Thanks :)

@chidauri

This comment has been minimized.

Copy link
Collaborator

@chidauri chidauri commented Dec 30, 2019

@chidauri chidauri linked a pull request that will close this issue Jan 7, 2020
3 of 3 tasks complete
@seadowg

This comment has been minimized.

Copy link
Member

@seadowg seadowg commented Jan 16, 2020

Was just looking through #3575. I'm a little confused around the issue description:

BackgroundLocationManager.locationPermissionGranted does this for audit location requests but not for background location requests.

Is that referring to the dialog that's shown when we return a BackgroundLocationMessage.PROVIDERS_DISABLED from locationPermissionGranted. That happens here in displayUIFor in FormEntryActivity as far as I can see:

if (backgroundLocationMessage == BackgroundLocationManager.BackgroundLocationMessage.PROVIDERS_DISABLED) {
    new LocationProvidersDisabledDialog().show(getSupportFragmentManager(), LocationProvidersDisabledDialog.LOCATION_PROVIDERS_DISABLED_DIALOG_TAG);
    return;
}

If that's right? If so should we be showing a dialog rather than a toast to keep it consistent? I wouldn't be surprised if I've massively misinterpreted all of this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.