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: docs/get-started/usage-quickeditor.md
+26-64Lines changed: 26 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,23 +6,20 @@ To do that the QuickEditor needs an authorization token to perform requests on b
6
6
7
7
### 1. Let the Quick Editor handle the OAuth flow
8
8
9
-
#### 1.1 Using you own activity with `android:launchMode="singleTask"` (Recommended)
10
-
11
9
Quick Editor can handle the heavy lifting of running the full OAuth flow, so you don't have to do that. We will still need a few things from you.
12
10
First, you have to go to [OAuth docs](https://docs.gravatar.com/oauth/) and create your Application. Define the `Redirect URLs`.
13
11
14
12
> Keep in mind that you need to use the `https` scheme. Internally, QuickEditor uses Implicit OAuth flow (`response_type=token`) and for security reasons, the server doesn't allow custom URL schemes.
15
13
16
14
For the sake of this example let's assume the redirect URL is `https://yourhost.com/redirect-url`.
17
15
18
-
In your `AndroidManifest.xml` you need to add an `<intent-filter>` and the `android:launchMode="singleTask"` to the activity that will
19
-
launch the Quick Editor (or the last/main activity depending on your app architecture). This is important because the Quick Editor will be waiting for the `onNewIntent()` callback to handle OAuth redirection.
16
+
In your `AndroidManifest.xml` you need to setup `GravatarOAuthActivity` by adding the `<activity>` tag.
17
+
This Activity is launched by the Quick Editor when starting the OAuth flow and it handles the redirect URL to retrieve the token.
With the provided `clientId` and the `redirectUrl` Quick Editor can launch and handle the full OAuth flow. Once obtained the token will be stored in an encrypted Data Store.
66
+
With the provided `clientId` and the `redirectUrl` Quick Editor will launch and handle the full OAuth flow. Once obtained, the token will be stored in an encrypted Data Store.
70
67
This token will be later used in subsequent Quick Editor launches to make the user experience more seamless by not having to go through the OAuth flow each time.
71
68
72
69
When the user logs out form the app, make sure to run:
@@ -75,61 +72,6 @@ When the user logs out form the app, make sure to run:
75
72
GravatarQuickEditor.logout(Email("{USER_EMAIL}"))
76
73
```
77
74
78
-
#### 1.2 Using the provided activity
79
-
80
-
If using an activity with `android:launchMode="singleTask"` is not an option, you can use the provided activity. With this option, you don't need to modify how your activities are set up.
81
-
82
-
You need to add the provided activity to your `AndroidManifest.xml`:
_Note the important difference here: the `tools:node="merge"` attribute. This is necessary to merge the intent filter with the one defined in the library._
105
-
106
-
The `GravatarQuickEditorActivity` defines an Activity Result contract that you can use to launch the Quick Editor and handle the result. Here's an example of how you can use it:
It's important to note that using the `GravatarQuickEditorActivity` you'll only receive the result of the Quick Editor when it's dismissed not instantly as with using the `@Composable` component from your `singleTask` activity (see [Section 1.1](#11-using-you-own-activity-with-androidlaunchmodesingletask-recommended)).
130
-
131
-
In the `demo-app` you can find a detailed implementation showing how to use the provided activity. See `QuickEditorTestActivity`.
132
-
133
75
#### Exclude Data Store files from Android backup (optional, but recommended)
134
76
135
77
Data Store files are subject to Android backups. Encrypted files from the backup won't work when restored on a different device so we have to exclude those files.
@@ -253,7 +195,7 @@ If you're using our UI Avatar component, you can simply enable the `forceRefresh
253
195
```kotlin
254
196
@Composable
255
197
publicfunAvatar(
256
-
profile:Profile,
198
+
state:ComponentState<Profile>,
257
199
size:Dp,
258
200
modifier:Modifier = Modifier,
259
201
avatarQueryOptions:AvatarQueryOptions? = null,
@@ -263,6 +205,17 @@ public fun Avatar(
263
205
264
206
By setting `forceRefresh` to true, you ensure that the avatar is always fetched with the latest changes.
265
207
208
+
If you want a more fine-grained control with the `Avatar` component you can use the version that takes the URL as a parameter and pass the URL with the cacheBuster value created with the `AvatarUrl` class.
209
+
210
+
```kotlin
211
+
@Composable
212
+
publicfunAvatar(
213
+
state:ComponentState<String>,
214
+
size:Dp,
215
+
modifier:Modifier = Modifier,
216
+
)
217
+
```
218
+
266
219
### Android Permissions
267
220
268
221
The Quick Editor module requires certain permissions to function correctly. Below is a table listing the permissions and the reasons why they are needed:
@@ -273,3 +226,12 @@ The Quick Editor module requires certain permissions to function correctly. Belo
273
226
|`WRITE_EXTERNAL_STORAGE`| Allows the app to save images to the device storage on Android 9 and lower via Download Manager. |
274
227
275
228
If you use the same permission with different configurations, you might end up with conflicts.
229
+
230
+
### Version migrations
231
+
232
+
When updating the SDK, you might need to migrate your code to the new version. Here is the list of all the migrations:
In version 2.3.0, the `GravatarOAuthActivity` was introduced to handle OAuth authentication with Gravatar.
6
+
This means you no longer need to set up your Activity with the `launchMode=singleTask` to handle the `onNewIntent` method for OAuth redirection.
7
+
8
+
The Quick Editor will still work if you won't change it but it's highly recommended to migrate to the new `GravatarOAuthActivity` as this behavior will be removed in the future.
9
+
10
+
### Steps to Migrate
11
+
12
+
1.**Remove the extra config from you own Activity**:
13
+
If you have previously added this to you AndroidManifest.xml:
0 commit comments