-
Notifications
You must be signed in to change notification settings - Fork 120
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
Abstract the location engine from a specific provider #269
Conversation
This PR is ready is for a first round of feedback. The main goal of this PR is to create a new abstract In particular, this PR includes:
Still WIP, required next actions:
Related mapbox/mapbox-gl-native#4331. |
|
||
private final int REQUEST_PERMISSIONS_CODE = 0; | ||
|
||
private Activity activity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use weak references just in case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be possible to remove activity completely? it's used for 2 items: permissions granted checks and requesting permissions. Imo I think callers of those method won't mind passing an reference to the Activity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good so far.
|
||
/** | ||
* Created by antonio on 1/11/17. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cough cough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, sorry, fixed.
|
||
/** | ||
* Created by antonio on 1/11/17. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, small nits added
.build(); | ||
} | ||
|
||
public static LocationEngine getLocationEngine(Context context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
synchronised keyword for thread safety to avoid creating 2 instances?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, done.
.build(); | ||
} | ||
|
||
public static LocationEngine getLocationEngine(Context context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
synchronised keyword for thread safety to avoid creating 2 instances?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, done.
|
||
public interface PermissionsListener { | ||
|
||
void onExplanationNeeded(List<String> permissionsToExplain); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this method do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let the developer know that they need to provide an explanation to the user as indicated in the docs. Basically, it covers the ActivityCompat.shouldShowRequestPermissionRationale() == true
flow.
/** | ||
* Helps request permissions at runtime | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit enter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
|
||
private final int REQUEST_PERMISSIONS_CODE = 0; | ||
|
||
private Activity activity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be possible to remove activity completely? it's used for 2 items: permissions granted checks and requesting permissions. Imo I think callers of those method won't mind passing an reference to the Activity.
@cammace All comments addressed, care to 👍 / 👎 ? |
/cc: @cammace