You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-47Lines changed: 39 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,9 +49,9 @@ The library has the following requirements:
49
49
### Tested WearOS versions and devices
50
50
The library has been tested in the following WearOS versions:
51
51
52
-
-**Wear OS 2.33** (Android 9 - API 28):
52
+
-**WearOS 2.33** (Android 9 - API 28):
53
53
- TicWatch Pro 3 GPS
54
-
-**Wear OS 3.5** (Android 11 - API 30):
54
+
-**WearOS 3.5** (Android 11 - API 30):
55
55
- TicWatch Pro 3 GPS
56
56
- TicWatch Pro 5
57
57
-**WearOS 4** (Android 13 - API 33):
@@ -118,50 +118,45 @@ Before going deeper with the data collection, we have to talk about permissions.
118
118
#### Permissions
119
119
In order to access to the data of the heart rate and the GPS sensors, the user
120
120
has to grant some permissions. The library handles this situation (i.e., when permissions are required), and
121
-
launches a notification to warn the user that some permissions need to be granted. However, we **do not**
122
-
provide a mechanism to ask the permissions, we delegate that task on the developer. Why? To customise the
123
-
way the permissions are required. In other words, the developer has to provide a class reference of an
124
-
activity for requesting permissions using the [`PermissionsManager.setPermissionsActivity()`](#permissionsmanager). There are two
125
-
ways of requesting permissions:
126
-
127
-
- If the data collection is started using the paired smartphone, the permissions will be automatically requested. You have to do nothing!
128
-
- If the data collection is started from the smartphone, you should check that the necessary permissions are granted using the [`PermissionsManager.launchPermissionsRequestIfNeeded()`](#permissionsmanager)
129
-
130
-
and the library
131
-
will start that activity when any permission is required and the user taps into the notification warning.
132
-
133
-
We have tried to make it easy for you to implement that activity:
134
-
- You can obtain the list of the permissions that are required and also to request them using the [`PermissionsManager`](#permissionsmanager) API.
135
-
- After the user grants or denies a permission, you have to tell the smartphone that which permissions
136
-
have been granted and which ones not using the [`PermissionsResultClient`](#permissionsresultclient).
137
-
Remember: the smartphone is the one that starts the data collection, including the request for permissions.
121
+
launches a notification to warn the user that some permissions need to be granted. We can differentiate
122
+
two main steps in the process:
123
+
124
+
1. Check if permissions are required:
125
+
- If the data collection is started using the paired smartphone, the check is automatic. You have to do nothing!
126
+
- If the data collection is started using the smartphone, you need to do the check using the [`PermissionsManager.launchPermissionsRequestIfNeeded()`](#permissionsmanager) method.
127
+
2. Request the required permissions: the library handles mostly of the process by you, but you still have to do execute some steps:
128
+
- Create an Activity: it will be used by the library to request the permissions. This will allow you to define a UI where some information can be given prior to the permissions request.
129
+
- In your activity:
130
+
- Create an instance of the [`PermissionsRequestHandler`](#permissionsrequesthandler) class.
131
+
- Provide a callback using the [`PermissionsRequestHandler.onPermissionsResult()`]() method. The callback will be called with the result of the request, which can be used to update the UI. After 1 second, the activity will close.
132
+
- Override the `Activity.onRequestPermissionsResult` and inside it, call [`PermissionsRequestHandler.handleResult()`](#permissionsrequesthandler).
133
+
- Call the method [`PermissionsRequestHandler.handleRequest()`](#permissionsrequesthandler) to start the permission request.
134
+
- Inject the Activity to the library using the [`PermissionsManager.setPermissionsActivity()`](#permissionsmanager) method.
138
135
136
+
139
137
Here you can see an example of an activity for requesting permissions:
|`permissionsToRequestFromIntent(Intent intent)`|`ArrayList<String>`| Permissions to request in the custom request permissions activity. |
305
-
|`specialPermissionsToRequestFromIntent(Intent intent)`|`ArrayList<String>`| Special permissions to request in the custom request permissions activity. |
306
-
|`launchRequiredPermissionsRequest(Activity activity)`|`void`| Launch the permissions activity to request the required permission to post notifications (only WearOS 4+). |
307
-
|`launchPermissionsRequestIfNeeded(Activity activity, ArrayList<String> permissions)`|`boolean`| Launch the permissions activity to request the specified permissions. Call this method to request the permissions for a specified sensor. Returns `true` if the permissions activity has been launched. |
308
-
|`permissionsToBeRequested(Context context, ArrayList<String> required)`|`ArrayList<String>`| Returns the permissions that need to be requested (internal use only). |
309
-
|`requestPermissions(Activity activity, ArrayList<String> permissions)`|`void`| Request the specified permissions previously obtained from `permissionsToRequestFromIntent`. You should call this method in your custom request permissions activity. |
310
302
|`setPermissionsActivity(Context context, Class<?> permissionsActivity)`|`void`| Sets up the class that will be used for requesting permissions. You should call this method in your MainActivity class once your app has started. |
311
-
|`getPermissionsActivity(Context context)`|`Class<?>`| Gets the class that will be used for requesting permissions. |
|`sendPermissionsSuccessfulResponse(Intent intent)`|`void`| Indicates to the smartphone that all requested permissions have been granted |
318
-
|`sendPermissionsFailureResponse(Intent intent, String failureReason)`|`void`| Indicates to the smartphone that some requested permissions have not been granted. It includes a message to indicate which permission/s was/were not granted (`failureReason`). |
|`handleRequest()`|`void`| Starts the workflow to request permissions. Call inside your permissions activity. |
309
+
|`handleResult(int requestCode, String[] permissions, int[] grantResults)`|`void`| Call inside the overrided `onRequestPermissionsResult` of your permissions activity. |
310
+
|`onPermissionsResult(PermissionsResult permissionsResult)`|`void`| Inject a `PermissionsResult` callback. The callback will be called with `True` if all required permissions were granted, `False` otherwise. |
0 commit comments