Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Retrofit Geofencing #302

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Retrofit Geofencing #302

wants to merge 3 commits into from

Conversation

adaext
Copy link

@adaext adaext commented Sep 20, 2022

Upgrade the Gradle and SDK to the latest version and add tristate support for location permission.

Copy link
Contributor

@jdkoren jdkoren left a comment

Choose a reason for hiding this comment

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

@adaext In MainActivity.java the indent size changed from 4 spaces to 2 spaces, which doesn't match the format of the other files. The resulting diff is very large and doesn't reflect the changes specific to this PR. Can you please reset the indent to 4 spaces and reformat the file?

@adaext
Copy link
Author

adaext commented Sep 21, 2022

@adaext In MainActivity.java the indent size changed from 4 spaces to 2 spaces, which doesn't match the format of the other files. The resulting diff is very large and doesn't reflect the changes specific to this PR. Can you please reset the indent to 4 spaces and reformat the file?

Ok, thanks.

Copy link
Contributor

@marcelpinto marcelpinto left a comment

Choose a reason for hiding this comment

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

I have some concerns on the permissions best practices that would be great to solve.

[Optional] since you are formatting the code, could you update the sample code style?

  • Do not use Hungarian notation
  • Use ViewBinding instead

// Request permission. It's possible this can be auto answered if device policy
// sets the permission in a given state or the user denied the permission
// previously and checked "Never ask again".
ActivityCompat.requestPermissions(
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using registerForActivityResult with Permission Contract

https://developer.android.com/training/permissions/requesting#allow-system-manage-request-code

// previously and checked "Never ask again".
ActivityCompat.requestPermissions(
MainActivity.this,
new String[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not allowed since Android 11.

You should first request COARSE + FINE and then BACKGROUND separately

https://developer.android.com/about/versions/11/privacy/location#request-background-location-separately

// Return a GeofencingRequest.
return builder.build();
}
@Override
Copy link
Contributor

Choose a reason for hiding this comment

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

This goes against the best practices. I understand for the sample might be okay, but I would consider moving this logic under a button/CTA in the screen.

R.string.permission_denied_explanation,
R.string.settings,
view -> {
// Build intent that displays the App settings screen.
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK showing the app details in system settings isn't a pattern we recommend for developers.

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

Successfully merging this pull request may close these issues.

3 participants