Skip to content

Commit 1726f81

Browse files
Clean up the README.md file to focus on 3rd party devs (#606)
* Extract SDK's technical details from the readme.md * Add Features/Installation/Documentation sections to the README.md * Replace groovy examples with Kotlin script syntax
1 parent 9600cf1 commit 1726f81

File tree

3 files changed

+231
-203
lines changed

3 files changed

+231
-203
lines changed

README.md

+23-189
Original file line numberDiff line numberDiff line change
@@ -15,212 +15,46 @@ If you're also looking to integrate Gravatar in your iOS app, check out our [Gra
1515
<img src="docs/images/profile_light_demo.png" />
1616
</p>
1717

18-
## Getting started
19-
Hi there! If you're here because you want to integrate the Gravatar SDK into your Android application, please take a look at our [Get Started guide](/docs/get-started/get-started.md). You'll find a quick overview of how to get an API key and use the library in your projects.
18+
## Features
2019

21-
## Architecture
20+
- Ready-to-use asynchronous services for Gravatar REST API based on Kotlin Coroutines.
21+
- Avatar URL calculator based on email and several query options.
22+
- Display a profile view or an avatar through ready-to-use Jetpack Compose UI components.
23+
- QuickEditor: This customizable sheet allows you to manage your avatar and Gravatar profile. You can select an existing avatar or upload a new one, and it provides a summary of your Gravatar profile.
2224

23-
This project contains the source code for the Gravatar SDK library and a demo app. The demo app aims to achieve two different goals. On the one hand, it demonstrates how to use the Gravatar SDK library. On the other hand it serves as a testbed for the library.
25+
## Installation
2426

25-
### Gravatar SDK Architecture
26-
27-
The SDK is still in its early stages, but we can identify the following modules:
28-
29-
#### Gravatar (Core)
30-
31-
The core functionality of the Gravatar SDK library. It provides a set of classes and methods to interact with the Gravatar API.
32-
33-
- [**Gravatar API clients**](gravatar/src/main/java/com/gravatar/services): A set of classes and methods to interact with the Gravatar API. It's responsible for handling the network requests and parsing the responses.
34-
- **Gravatar Utils**: A set of utility classes and methods to handle the Gravatar URLs, the Gravatar profile, etc.
35-
36-
#### Gravatar UI
37-
38-
A set of UI components to display the Gravatar images, profiles or information in general. Those components are implemented in Jetpack Compose and can contain logic to interact with the Gravatar API client.
39-
40-
- [**Gravatar UI components**](gravatar-ui/src/main/java/com/gravatar/ui): A set of UI components to display the Gravatar images, profiles or information in general. Those components are implemented in Jetpack Compose and can contain logic to interact with the Gravatar API client.
41-
42-
#### QuickEditor
43-
44-
The QuickEditor module contains tools and UI components to quickly edit the Gravatar profile.
45-
46-
### Dependency Injection
47-
48-
We decided to go with a manual injection basically for two main reasons:
49-
50-
- We avoid adding a new project dependency and possible conflicts while integrating the SDK.
51-
- The expected size and complexity of the SDK allow manual injection without too much trouble.
52-
53-
If you need to inject classes, you can use the [GravatarSdkContainer](gravatar/src/main/java/com/gravatar/di/container/GravatarSdkContainer.kt) class as the entry point. This class is responsible for all the DI in the SDK.
54-
55-
## Tests
56-
57-
Run unit tests on your machine via the following command:
58-
59-
```sh
60-
./gradlew test
61-
```
62-
63-
## Screenshot Tests
64-
65-
We use [Roborazzi](https://github.com/takahirom/roborazzi) to take screenshots of the UI components. The screenshots are stored in the [`screenshotsTests` directory](gravatar-ui/screenshotTests/roborazzi/). To regenerate the screenshots, run the following command:
66-
67-
```sh
68-
./gradlew :gravatar-ui:recordRoborazziDebug -Pscreenshot
69-
```
70-
71-
To compare the screenshots, run the following command:
72-
73-
```sh
74-
./gradlew :gravatar-ui:verifyRoborazziDebug -Pscreenshot
75-
```
76-
77-
## Coding Style
78-
79-
We use [Ktlint](https://pinterest.github.io/ktlint) to enforce a consistent coding style. It
80-
is integrated into the project as a Gradle plugin using
81-
the [jlleitschuh/ktlint-gradle](https://github.com/jlleitschuh/ktlint-gradle) wrapper.
82-
83-
⚠️**Please make sure that _ktlintCheck_ is happy with your changes before submitting a PR.**
84-
85-
Check the style of the whole project or just the desired module (library or demo app) with the
86-
following commands:
87-
88-
```sh
89-
./gradlew ktlintCheck
90-
./gradlew :gravatar:ktlintCheck
91-
./gradlew :gravatar-ui:ktlintCheck
92-
./gradlew :quickeditor:ktlintCheck
93-
./gradlew :app:ktlintCheck
94-
```
95-
96-
You can also try to let Ktlint fix the code style issues. Just use:
97-
98-
```sh
99-
./gradlew ktlintFormat
100-
./gradlew :gravatar:ktlintFormat
101-
./gradlew :gravatar-ui:ktlintFormat
102-
./gradlew :quickeditor:ktlintFormat
103-
./gradlew :app:ktlintFormat
104-
```
105-
106-
## Code static analysis
107-
108-
We use [Detekt](https://github.com/detekt/detekt) to perform static code analysis. You can run
109-
Detekt via a gradle command:
110-
111-
```sh
112-
./gradlew detekt
113-
./gradlew :gravatar:detekt
114-
./gradlew :gravatar-ui:detekt
115-
./gradlew :quickeditor:detekt
116-
./gradlew :app:detekt
117-
```
118-
119-
## Explicit API mode
120-
121-
[Explicit API mode](https://kotlinlang.org/docs/whatsnew14.html#explicit-api-mode-for-library-authors) is enabled in strict mode for the
122-
library. This means that the compiler performs additional checks that help make the library's API clearer and more consistent.
123-
124-
Those errors will force us to take care of the visibility modifiers in order to limit the public classes/methods of the API to the minimum
125-
required.
126-
127-
By default, **Android Studio** will show a warning, `Redundant visibility modifier`.
128-
129-
<img width="400" alt="Redundant visibility modifier" src="docs/images/redundant_visibility_modifier_warning.png">
130-
131-
You can remove the warning by changing the setting for this project
132-
in: `Settings` -> `Editor` -> `Inspections` -> `Kotlin` -> `Redundant Constructors` -> `Redundant visibility modifier`.
133-
134-
## Generating API code from OpenApi definitions
135-
136-
We use [OpenAPI Generator](https://openapi-generator.tech/) to generate the API code from the OpenAPI definitions.
137-
138-
The SDK project has integrated the OpenAPI Generator Gradle plugin to generate the API code from the OpenAPI definitions. The plugin is
139-
configured in the `build.gradle.kts` file.
140-
141-
The OpenAPI definitions are located in the `openapi` directory. In the same directory, you can find the `templates` directory, which contains
142-
the custom templates used by the OpenAPI Generator to generate the code that the Gravatar library needs. You can obtain the default templates by running the following command:
143-
144-
```sh
145-
openapi-generator author template -g kotlin --library jvm-okhttp4
146-
```
147-
148-
The [OpenAPI Generator documentation](https://openapi-generator.tech/docs/templating) provides more information about the templates.
149-
150-
The generator's output folder is the `build` directory. However, as we don't need all the generated files, the Gradle task has been modified to move only the desired code to the `gravatar` module. In addition, the
151-
last step of the task is to format the generated code with [Ktlint](README.md#coding-style).
152-
153-
<span style="color:red">**Important:**</span> Do not manually modify the `com.gravatar.api` folder. The OpenAPI Generator will overwrite it.
154-
155-
To regerate the code you can use the following gradlew task:
156-
157-
```sh
158-
./gradlew :gravatar:openApiGenerate
159-
```
160-
161-
## Publishing
162-
163-
All new versions are published in the Maven Central repository.
164-
165-
Older versions (<=2.3.1) were published to the Automattic's S3 instance via [`publish-to-s3`](https://github.com/Automattic/publish-to-s3-gradle-plugin) Gradle plugin.
166-
167-
The published version is calculated depending on the Git context, in this order:
168-
- if there's a tag, version is `<tag name>`
169-
- if there's a PR, version is `<pr number>-<commit hash>`
170-
- else `<branch name>-<commit hash>`
171-
172-
To use the repository, it's needed to add the custom repository:
173-
174-
```groovy
175-
repositories {
176-
maven {
177-
url "https://a8c-libs.s3.amazonaws.com/android"
178-
}
179-
}
27+
To add the Gravatar SDK to your project, you can use the following Gradle dependency:
18028

29+
```kotlin
18130
dependencies {
182-
implementation ("com.gravatar:gravatar:<version>")
31+
implementation("com.gravatar:gravatar:<version>")
18332
// OR
184-
implementation ("com.gravatar:gravatar-ui:<version>")
33+
implementation("com.gravatar:gravatar-ui:<version>")
18534
// OR
186-
implementation ("com.gravatar:gravatar-quickeditor:<version>")
35+
implementation("com.gravatar:gravatar-quickeditor:<version>")
18736
}
18837
```
18938

190-
## Generating the API documentation
191-
192-
We're using [kdoc](https://kotlinlang.org/docs/kotlin-doc.html) to document the library's code. [Dokka](https://kotlinlang.org/docs/dokka-introduction.html) has been setup to generate html documentation from kdoc. To generate the HTML docs in `docs/dokka/`, run the following command:
39+
Additionally, if you're using version 2.3.1 or older of the SDK, you need to add custom Gradle repository:
19340

194-
```sh
195-
./gradlew dokkaHtmlMultiModule
41+
```kotlin
42+
repositories {
43+
maven {
44+
url = uri("https://a8c-libs.s3.amazonaws.com/android")
45+
}
46+
}
19647
```
19748

198-
Here is the most recent release of the [Gravatar-SDK-Android API documentation generated by Dokka](https://automattic.github.io/Gravatar-SDK-Android/current/index.html).
199-
200-
201-
## Translations
202-
203-
Gravatar Android SDK uses [GlotPress](https://translate.wordpress.com/projects/gravatar/gravatar-android-sdk/) to translate strings in the project.
204-
This includes two modules with `strings.xml` files: `:gravatar-ui` and `:gravatar-quickeditor`.
205-
206-
To fetch the latest translation run:
207-
208-
209-
```sh
210-
bundle exec fastlane download_translations skip_commit:true|false
211-
```
49+
For further details on how to integrate in your own app please take a look at our [Get Started guide](/docs/get-started/get-started.md). You'll find a quick overview of how to get an API key and use the library in your projects.
21250

213-
If `skip_commit`is set to `false` it will automatically create a new commit with the new translations.
214-
If you wish to check the changes first set it to `true` and commit the changes yourself.
51+
## Documentation
21552

216-
## Release process
53+
You can find the full API documentation [here](https://automattic.github.io/Gravatar-SDK-Android/current/index.html).
21754

218-
We're following [Semantic Versioning](https://semver.org/) for the releases. Here is the process to create a new release:
55+
## For Maintainers
21956

220-
1. Make sure the latest translations are commited the repository. See [Translations](#Translations)
221-
2. Pull the `trunk` branch and tag the git commit with the version number: `git tag -a x.x.x -m "Release x.x.x"`
222-
3. Push the new tag: `git push --tags`.
223-
4. Go to the [GitHub releases page](https://github.com/Automattic/Gravatar-SDK-Android/releases) and create a new release with the tag name and the release notes.
57+
If you're contributing to or maintaining this project, check out [SDK's technical details](/docs/sdk-technical-details/sdk-techincal-details.md).
22458

22559
## Contributing
22660

docs/get-started/get-started.md

+18-14
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@ First step is to add the maven repositories to the file where you manage your th
2222

2323
### Add the Gravatar dependencies to your project
2424

25-
```groovy
26-
repositories {
27-
maven {
28-
url "https://a8c-libs.s3.amazonaws.com/android"
29-
}
25+
```kotlin
26+
dependencies {
27+
implementation("com.gravatar:gravatar:<version>")
28+
implementation("com.gravatar:gravatar-ui:<version>")
29+
implementation("com.gravatar:gravatar-quickeditor:<version>")
3030
}
3131
```
3232

33-
```groovy
34-
dependencies {
35-
implementation ("com.gravatar:gravatar:<version>")
36-
implementation ("com.gravatar:gravatar-ui:<version>")
37-
implementation ("com.gravatar:gravatar-quickeditor:<version>")
33+
Additionally, if you're using version 2.3.1 or older of the SDK, you need to add custom Gradle repository:
34+
35+
```kotlin
36+
repositories {
37+
maven {
38+
url = uri("https://a8c-libs.s3.amazonaws.com/android")
39+
}
3840
}
3941
```
4042

@@ -50,13 +52,15 @@ gravatar.api.key = REPLACE_ME
5052

5153
Then update your gradle file to read the API key from the `local.properties` file and put it in the generated `BuildConfig` class:
5254

53-
```groovy
55+
```kotlin
5456
android {
5557
buildFeatures.buildConfig = true
5658

57-
val properties = Properties()
58-
properties.load(FileInputStream(project.rootProject.file("local.properties")))
59-
buildConfigField("String", "GRAVATAR_API_KEY", "\"${properties["gravatar.api.key"]}\"")
59+
defaultConfig {
60+
val properties = Properties()
61+
properties.load(FileInputStream(project.rootProject.file("local.properties")))
62+
buildConfigField("String", "GRAVATAR_API_KEY", "\"${properties["gravatar.api.key"]}\"")
63+
}
6064
}
6165
```
6266

0 commit comments

Comments
 (0)