Migration: Single permissions class
In an effort to simplify the permissions system of rook-sdk we decided to move and merge all current types of
permissions from RookStepsPermissions
, RookYesterdaySyncPermissions
and RookHealthPermissionsManager
in a single
class: RookPermissionsManager
. This new class will also have new functionality like broadcasted request results
The permissions were merged into 2 categories:
Android permissions:
- POST_NOTIFICATIONS
- ACTIVITY_RECOGNITION
- FOREGROUND_SERVICE
- FOREGROUND_SERVICE_HEALTH
These permissions are used to track and upload steps data (RookStepsManager) or to extract and upload Health Connect data (RookYesterdaySync).
Health Connect permissions:
- READ_SLEEP
- READ_STEPS
- READ_DISTANCE
- READ_FLOORS_CLIMBED
- READ_ELEVATION_GAINED
- READ_OXYGEN_SATURATION
- READ_VO2_MAX
- READ_TOTAL_CALORIES_BURNED
- READ_ACTIVE_CALORIES_BURNED
- READ_HEART_RATE
- READ_RESTING_HEART_RATE
- READ_HEART_RATE_VARIABILITY
- READ_EXERCISE
- READ_SPEED
- READ_WEIGHT
- READ_HEIGHT
- READ_BLOOD_GLUCOSE
- READ_BLOOD_PRESSURE
- READ_HYDRATION
- READ_BODY_TEMPERATURE
- READ_RESPIRATORY_RATE
- READ_NUTRITION
- READ_MENSTRUATION
- READ_POWER
These permissions are used to extract Health Connect data manually (RookSummaryManager, RookEventManager) or automatically (RookYesterdaySync).
Migration process
Next you will find a mapping of each class/function to its corresponding replacement.
RookStepsPermissions
Deprecated | Replace with this |
---|---|
RookStepsPermissions.isAvailable(context: Context): Boolean | RookStepsManager.isAvailable(context: Context): Boolean |
RookStepsPermissions.hasPermissions(context: Context): Boolean | RookPermissionsManager.checkAndroidPermissions(context: Context): Boolean |
RookStepsPermissions.shouldRequestPermissions(activity: Activity): Boolean | RookPermissionsManager.shouldRequestAndroidPermissions(activity: Activity): Boolean |
RookStepsPermissions.requestPermissions(context: Context) | RookPermissionsManager.requestAndroidPermissions(context: Context): RequestPermissionsStatus |
RookYesterdaySyncPermissions
Deprecated | Replace with this |
---|---|
RookYesterdaySyncPermissions.hasAndroidPermissions(context: Context): Boolean | RookPermissionsManager.checkAndroidPermissions(context: Context): Boolean |
RookYesterdaySyncPermissions.shouldRequestAndroidPermissions(activity: Activity): Boolean | RookPermissionsManager.shouldRequestAndroidPermissions(activity: Activity): Boolean |
RookYesterdaySyncPermissions.requestAndroidPermissions(context: Context) | RookPermissionsManager.requestAndroidPermissions(context: Context): RequestPermissionsStatus |
RookYesterdaySyncPermissions.hasHealthConnectPermissions(context: Context): Boolean | RookPermissionsManager.checkHealthConnectPermissions(context: Context): Result<Boolean> |
RookYesterdaySyncPermissions.requestHealthConnectPermissions(context: Context): Result<Unit> | RookPermissionsManager.requestHealthConnectPermissions(context: Context): Result<RequestPermissionsStatus> |
RookHealthPermissionsManager
Deprecated | Replace with this |
---|---|
rookHealthPermissionsManager.openHealthConnectSettings(): Result<Unit> | rookPermissionsManager.openHealthConnectSettings(): Result<Unit> |
rookHealthPermissionsManager.checkPermissions(): Result<Boolean> | rookPermissionsManager.checkHealthConnectPermissions(): Result<Boolean> |
rookHealthPermissionsManager.requestPermissions(): Result<Unit> | rookPermissionsManager.requestHealthConnectPermissions(): Result<RequestPermissionsStatus> |
RookHealthPermissionsManager.checkAvailability(context: Context): HealthConnectAvailability | RookPermissionsManager.checkHealthConnectAvailability(context: Context): HealthConnectAvailability |
RookHealthPermissionsManager.registerPermissionsRequestLauncher(componentActivity, onFinished) | RookPermissionsManager.registerPermissionsRequestLauncher(componentActivity, onFinished) |
RookHealthPermissionsManager.registerPermissionsRequestLauncher(fragment, onFinished) | RookPermissionsManager.registerPermissionsRequestLauncher(fragment, onFinished) |
RookHealthPermissionsManager.unregisterPermissionsRequestLauncher() | RookPermissionsManager.unregisterPermissionsRequestLauncher() |
RookHealthPermissionsManager.launchPermissionsRequest() | RookPermissionsManager.launchPermissionsRequest() |