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
To do that the QuickEditor needs an authorization token to perform requests on behalf of the user. There are two ways for that:
15
+
## Overview
16
+
17
+
The `:gravatar-quickeditor` module provides a fully featured component that allows the user to modify their Gravatar profile information, including their avatar and "About" details, without leaving your app.
18
+
19
+
The Quick Editor's functionality can be tailored using `QuickEditorScopeOption` to define what the user can edit. This allows for a focused experience depending on the desired interaction:
20
+
***`QuickEditorScopeOption.avatarPicker()`**: Launches the Quick Editor focused solely on avatar management. Users can select an existing image, upload a new one, or remove their current Gravatar through a streamlined interface. This scope is ideal when you only need to offer avatar editing capabilities.
21
+
***`QuickEditorScopeOption.aboutEditor()`**: This option presents the Quick Editor with tools to modify the user's "About" profile section. This typically includes details such as their display name, full name, pronouns, a public description or bio, and current location.
22
+
***`QuickEditorScopeOption.avatarPickerAndAboutEditor()`**: For a comprehensive profile editing experience, this combined scope allows users to modify both their avatar and their "About Me" details. The Quick Editor will provide a way to navigate between the avatar editing and "About" sections seamlessly without needing to close and re-launch the component.
23
+
24
+
For all of this to be possible, the QuickEditor needs an authorization token to perform requests on behalf of the user.
Quick Editor scopes were already briefly described in the Overview section, but here is a more detailed explanation of each scope option:
182
+
183
+
### `QuickEditorScopeOption.avatarPicker()`
184
+
185
+
This scope option focuses solely on avatar management. When using this option, the Quick Editor will present a user interface that allows users to:
186
+
- Select an avatar from the uploaded images.
187
+
- Upload an existing image from their device or take a new one.
188
+
- Remove their current Gravatar avatar.
189
+
- Modify the Alt Text for the avatar.
190
+
- Modify the rating of the avatar.
191
+
- Download any of the already uploaded avatars.
192
+
193
+
**AvatarPicker** scope is configured via `AvatarPickerConfiguration` class. Currently it supports one parameter: `AvatarPickerContentLayout` that defines how the user's avatar will be displayed. It can be either `Horizontal` or `Vertical`. The default value is `Horizontal`.
194
+
195
+
Here's an example of how to configure the `AvatarPicker` scope:
This scope option allows users to edit their "About" section in Gravatar. To check the currently supported fields, refer to the [AboutInputField](https://github.com/Automattic/Gravatar-SDK-Android/blob/adam/GRA-128/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/editor/AboutInputField.kt) class.
218
+
219
+
In order to configure the `AboutEditor` scope, you can use the `AboutEditorConfiguration` class. This class allows you to specify which fields should be editable by the user.
220
+
221
+
Here's an example of how to configure the `AboutEditor` scope:
This scope option combines both the avatar management and "About" section editing functionalities. It allows users to seamlessly switch between editing their avatar and updating their profile information without needing to close and reopen the Quick Editor.
247
+
248
+
To configure the `AvatarPickerAndAboutEditor` scope, you can use the `AvatarPickerAndAboutEditorConfiguration` class. It takes all the parameters from both `AvatarPickerConfiguration` and `AboutEditorConfiguration`, allowing you to define how the avatar picker and the "About" editor should behave.
249
+
On top of that it allows you to define the initial page that will be displayed when the Quick Editor is launched. The initial page can be either `AvatarPicker` or `AboutEditor`.
250
+
251
+
Here's an example of how to configure the `AvatarPickerAndAboutEditor` scope:
When using the Quick Editor, you need to provide an `updateHandler` that will be called when the user makes changes to their profile. This allows you to handle updates in your app, such as refreshing the UI or saving changes to a local database.
277
+
278
+
Each invocation of the `updateHandler` will provide a [QuickEditorUpdateType](https://github.com/Automattic/Gravatar-SDK-Android/blob/trunk/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/editor/UpdateHandler.kt) that indicates what type of update was made. It can be either `AvatarPickerResult` or `AboutEditorResult`, depending on whether the user changed their avatar or their "About" section.
279
+
280
+
Here's an example of how to implement the `updateHandler`:
281
+
282
+
```kotlin
283
+
GravatarQuickEditorBottomSheet(
284
+
...
285
+
updateHandler = { updateType ->
286
+
when (updateType) {
287
+
isAvatarPickerResult-> {
288
+
// Handle avatar update
289
+
}
290
+
isAboutEditorResult-> {
291
+
// Handle about section update
292
+
}
293
+
}
294
+
},
295
+
)
296
+
```
297
+
298
+
## Activity/Fragment compatibility
159
299
160
-
Gravatar SDK is built with Compose but we do provide some helper functions to launch the Quick Editor from an Activity or Fragment. Here's an example an Activity:
300
+
Gravatar SDK is built with Compose but we do provide some helper functions to launch the Quick Editor from an Activity or Fragment. Here's an example from an Activity:
161
301
162
302
```kotlin
163
303
GravatarQuickEditor.show(
@@ -172,13 +312,13 @@ GravatarQuickEditor.show(
172
312
)
173
313
```
174
314
175
-
###Cache busting
315
+
## Cache busting
176
316
177
317
When an avatar is modified, the change is applied immediately, but it may take a few seconds to propagate through the Gravatar servers. As a result, requesting the avatar quickly using the usual URL might sometimes return the previous avatar.
178
318
179
319
To ensure you receive the updated avatar after a change, you can use a cache buster. Our SDK provides methods to assist you in this process.
180
320
181
-
####Using AvatarUrl
321
+
### Using AvatarUrl
182
322
183
323
The `AvatarUrl` method accepts an optional parameter that we'll add as a cache buster:
184
324
@@ -188,7 +328,7 @@ public fun url(cacheBuster: String? = null): URL
188
328
189
329
You can use any string as a cache buster, but ensure that you don't repeat the value when you want to refresh the avatar. A timestamp is a good example of a unique cache buster.
190
330
191
-
####Using the Avatar UI Component
331
+
### Using the Avatar UI Component
192
332
193
333
If you're using our UI Avatar component, you can simply enable the `forceRefresh` parameter when you want to use the cache buster. We'll manage everything for you, updating the cache buster in every recomposition while the `forceRefresh` parameter remains true.
194
334
@@ -203,7 +343,7 @@ public fun Avatar(
203
343
)
204
344
```
205
345
206
-
By setting `forceRefresh` to true, you ensure that the avatar is always fetched with the latest changes.
346
+
By setting `forceRefresh` to true, you ensure that the avatar is always fetched with the latest changes. Although this will result in a new avatar, it must be used carefully as the image will be refreshed on each recomposition, which may not be ideal for performance.
207
347
208
348
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
349
@@ -216,7 +356,7 @@ public fun Avatar(
216
356
)
217
357
```
218
358
219
-
###Android Permissions
359
+
## Android Permissions
220
360
221
361
The Quick Editor module requires certain permissions to function correctly. Below is a table listing the permissions and the reasons why they are needed:
222
362
@@ -227,7 +367,7 @@ The Quick Editor module requires certain permissions to function correctly. Belo
227
367
228
368
If you use the same permission with different configurations, you might end up with conflicts.
229
369
230
-
###Version migrations
370
+
## Version migrations
231
371
232
372
When updating the SDK, you might need to migrate your code to the new version. Here is the list of all the migrations:
0 commit comments