Refactor to support multi-package architecture #143
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR splits the multiple supported permissions across different packages, allowing users to only install the packages for the permissions they need. This comes with the upside that we won't reference unnecessary iOS libraries and we will no longer trigger AppStore Connect automated alerts. Even though those alerts can be disregarded, it feels wrong to do so, and they can be confusing (especially for newbie iOS devs like me!)
Fixes #103
Migration path
This PR introduces a breaking change, but it is pretty minimal. Developers must complete the following steps:
Permission.xxx
symbolsThis should be pretty painless, as Android Studio features context actions for both steps.
Code walkthrough
This refactor introduces evolves the existing concept of iOS pemission delegates into multiplatform permission delegates. A "permission delegate" is now an object that contains
platform-specific logic to request the permission and retrieve its state. For iOS, this is platform code calling iOS-specific APIs. For Android, this is simply a list of
Manifest.permission
values.The iOS code is pretty much untouched in this PR, as it already was structured in an isolated way. On the other hand, the Android code was moved from
PermissionsControllerImpl
into android-specific delegates.A permission now contains a reference to its platform-dependant delegate:
The
Permission
enum is transformed into an empty object, and each permission-specific package extends it to ease the migration path:Thank you @Alex009 for this brilliant suggestion!
Now, both Android's and iOS'
PermissionController
are not aware of which permissions exist anymore. Instead we pass aPermission
object which contains the delegate, and the controller interacts with the delegate to request the permission or retrieve its state.