PermissionTracker
An object that tracks granted permissions and obtains required ones as needed.
The permission model used by this class is very simple: all potentially needed permissions must be listed upfront. A subset of permissions required for the functionality of a particular "target" screen is checked when attempting to show that screen. If all permissions required by the target screen are granted, it is shown normally. Otherwise a missing permission screen is shown with prompts to grant permission. When user grants permissions, view is changed to show the target screen automatically.
To use this functionality, create this object when activity is created. Call updatePermissions in ComponentActivity.onCreate. Then simply wrap the UI of any target screen in PermissionCheck call.
Parameters
activity that hosts this object
a map from permission string to the text shown to the user to explain why that permission is necessary for this app
Functions
Ensure that the given set of permissions is granted and show the given content.
Reads all the permission states (granted or not) from the system.