Skip to content

#3732 - Nearby Tab Accessible Without Location Permission #4259

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

Merged
merged 5 commits into from
Feb 26, 2021

Conversation

Pratham2305
Copy link
Contributor

Description (required)

Fixes #3732

What changes did you make and why?

Summary :

Nearby tab initially show a zoom-out map, which will be zoomed to the user's location if permission granted, and if not then still a zoom-out map will be shown with "Search this Area" enabled.

Major Changes:

Added a function that will set the Tower of London as the camera position on completely zoomed-out map, instead of going back to the contribution tab, if the user denies the location permission and also enabled the "Search this Area" button.

Changed the functionality of recenter button when permission is denied, as it is of no use if the user's location is unknown. and also disable the disappearing of the permission alertbox by clicking outside the box which is causing the empty map problem.

Tests performed (required)
Tested betaDebug on Pixel 3 with API level 29.

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, it works well!

But one major thing: I think the app should remember the user's choice. Consider this scenario:

  1. User opens the app
  2. User refuses to give location permission
  3. User closes the app
  4. Next day, user opens the app again
  5. User is asked for permission again

I think that step 5 makes the app too insisting, users will complain that the app creepily tries to get location permission every time despite the user refusing each time.

Would you mind persisting the user's choice? Sorry for the additional work.

@Pratham2305
Copy link
Contributor Author

@nicolas-raoul I have made the changes now it will remember the user choice, and the user can enable its location by clicking the recenter button.

}
presenter.onMapReady();
registerUnregisterLocationListener(false);
if(!applicationKvStore.getBoolean("NotDisplayLocationPermissionAlertBox", false) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind calling it DoNotAskForLocationPermission? If that sounds OK to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, Changed!

@nicolas-raoul
Copy link
Member

It works great!

Now actually the main activity's insistence on getting that permission becomes apparent...
I mean, the contribution activity asks for permission every time. It is far from the original issue, but do you want to fix that too? Either as a separate issue, or in the same pull request as it should probably use the same preference (we can assume that someone who refuses to give location permission for Nearby also refuses to give location permission for Contributions).

Thanks a lot!

@Pratham2305
Copy link
Contributor Author

Okay! I will make the changes in this PR only.

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
I just tried your PR.
Permission is only asked when opening the Nearby tab for the first time. The "near place" notification in Contributions only appears after Nearby has been accessed at least once. It is a bit different from the previous behavior, but I think it makes sense, and avoids asking for permission the first time the user opens the app. It also makes it more likely that the user will accept to give that permission, as it is asked when the user opens the "Nearby" tab.

Everyone: A last thing that I am not sure about is the case convention for new kvstore keys, should it be DoNotAskForLocationPermission or do_not_ask_for_location_permission or something else, and should the string be store somewhere, such as CommonsApplication.java?

@@ -451,6 +451,7 @@ private void checkPermissionsAndShowNearbyCardView() {
onLocationPermissionGranted();
} else if (shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)
&& store.getBoolean("displayLocationPermissionForCardView", true)
&& !store.getBoolean("DoNotAskForLocationPermission", false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked our repository and seems like we don't have an accurate convention for naming stored variables. I think it should be in lower camel case (doNotAskForLocationPermission). The only exception in Google's Java style guide seems like CONSTANT_CASE to use underscore, which is not our case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood Nes, thanks so much! :-)

@neslihanturan
Copy link
Collaborator

, and should the string be store somewhere, such as CommonsApplication.java?

@nicolas-raoul we never store these strings in somewhere, I think we should keep to do same: not store, just hardcode it for now. However, I think it could be nice to have such an organization for future.

@@ -138,7 +138,8 @@ public void onPermissionRationaleShouldBeShown(PermissionRequest permission,
activity.getString(rationaleMessage),
activity.getString(android.R.string.ok),
activity.getString(android.R.string.cancel),
token::continuePermissionRequest, token::cancelPermissionRequest);
token::continuePermissionRequest, token::cancelPermissionRequest,
null,false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor: space after ,
Or how about this?

token::continuePermissionRequest,
token::cancelPermissionRequest,
null,
false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that looks better, I have made the changes!

@nicolas-raoul nicolas-raoul merged commit 630c2a5 into commons-app:master Feb 26, 2021
@misaochan
Copy link
Member

Thanks a lot @Pratham2305 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nearby Tab Accessible Without Location Permission
4 participants