Skip to content

Commit 75c4a55

Browse files
authored
Merge pull request #126 from NordicPlayground/migration/agp2.6
Migration Nordic Gradle Plugins 2.6.1 and new documentation
2 parents f5d2cf7 + 6a15ab2 commit 75c4a55

File tree

351 files changed

+43643
-489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+43643
-489
lines changed

.github/workflows/deploy-to-nexus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
fetch-depth: 0
1414
- uses: actions/setup-java@v4
1515
with:
16-
distribution: 'corretto'
17-
java-version: '17'
16+
distribution: 'jetbrains'
17+
java-version: '21'
1818
- shell: bash
1919
env:
2020
# The following env variables are used by gradle/publish-module.gradle

README.md

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,25 @@
11
# Nordic Common Libraries for Android
2-
A libraries with Nordic's common code for Android apps.
3-
4-
## Theme
5-
6-
### Usage
7-
```groovy
8-
implementation 'no.nordicsemi.android.common:theme:<version>'
9-
```
10-
11-
### Content
12-
The library contains a few features which are necessary for theming Nordic Semiconductor apps:
13-
14-
* Color palette adopted to the new Material You
15-
* Typography
16-
* Nordic theme for dark and light mode
17-
* Abstract `NordicActivity` class which contain implementations for Nordic's splash screen animation.
18-
* `WizardStepComponent` for wizard-based app flow.
19-
* `CircularIcon` an icon with circular shape.
20-
* Other common views available for different projects.
21-
22-
## Permission
23-
24-
### Usage
25-
```groovy
26-
implementation 'no.nordicsemi.android.common:permission:<version>'
27-
```
28-
29-
### Content
30-
Classes and views related to managing permissions, including Bluetooth and Internet permissions.
312

32-
## Navigation
33-
34-
### Usage
35-
```groovy
36-
implementation 'no.nordicsemi.android.common:navigation:<version>'
37-
```
38-
39-
### Content
40-
Common navigation components for the app.
41-
42-
## UI Scanner
43-
44-
### Usage
45-
```groovy
46-
implementation 'no.nordicsemi.android.common:uiscanner:<version>'
47-
```
3+
A libraries with Nordic's common code for Android apps.
484

49-
### Content
50-
Common Bluetooth LE scanner screen.
5+
## Documentation
516

52-
## UI Logger
7+
The latest documentation can be found [here](https://nordicplayground.github.io/KAndroid-Common-Libraries/html/index.html).
538

54-
### Usage
55-
```groovy
56-
implementation 'no.nordicsemi.android.common:uilogger:<version>'
57-
```
9+
## Usage
5810

59-
### Content
60-
Common classes related with logging to nRF Logger app.
11+
To use this library, add the following to your `build.gradle` file:
6112

62-
## Analytics
63-
64-
### Usage
65-
```groovy
66-
implementation 'no.nordicsemi.android.common:analytics:<version>'
13+
```gradle
14+
dependencies {
15+
implementation 'no.nordicsemi.android.common:<module>:<version>'
16+
}
6717
```
6818

69-
### Content
70-
Common views and classes related with gathering analytics data.
71-
19+
## Sample app
7220

21+
Run the sample app to see and test most of the components from the library.
7322

23+
1. Clone the repository.
24+
2. Open the project in Android Studio.
25+
3. Run the `app` module on a connected device or emulator.

analytics/Module.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Module analytics
2+
3+
Set of classes related to Firebase Analytics.
4+
5+
## Configuration
6+
7+
Use of this module requires the following plugins to be applied in the app:
8+
```kotlin
9+
if (gradle.startParameter.taskRequests.toString().contains("Release")) {
10+
apply("com.google.gms.google-services")
11+
apply("com.google.firebase.crashlytics")
12+
}
13+
```
14+
and the _google-services.json_ file to be present in the app module.
15+
16+
Read [Firebase Setup](https://firebase.google.com/docs/android/setup) for more.
17+
18+
> **Note:**
19+
>
20+
> This package requires Hilt, as it's using Dependency Injection to provide the
21+
> [NordicAnalytics][no.nordicsemi.android.common.analytics.NordicAnalytics] class.
22+
23+
# Package no.nordicsemi.android.common.analytics
24+
25+
Main API for Nordic analytics. Contains set to methods to log events.
26+
27+
# Package no.nordicsemi.android.common.analytics.view
28+
29+
Set of common views used for enabling analytics in Nordic apps.

analytics/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ android {
5151
namespace = "no.nordicsemi.android.common.analytics"
5252
}
5353

54+
dokka {
55+
dokkaSourceSets.named("main") {
56+
includes.from("Module.md")
57+
}
58+
}
59+
5460
dependencies {
5561
implementation(project(":core"))
5662
implementation(project(":ui"))

analytics/module-rules.pro

Lines changed: 0 additions & 17 deletions
This file was deleted.

analytics/src/main/java/no/nordicsemi/android/common/analytics/NordicAnalytics.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
*/
3131

32+
@file:Suppress("unused")
33+
3234
package no.nordicsemi.android.common.analytics
3335

3436
import android.content.Context
@@ -45,14 +47,31 @@ import javax.inject.Singleton
4547

4648
private const val LOG_TAG = "ANALYTICS"
4749

50+
/**
51+
* This class is responsible for logging events to Firebase Analytics.
52+
*
53+
* Use Hilt injection to get an instance of this class.
54+
*/
4855
@Singleton
4956
class NordicAnalytics @Inject internal constructor(
5057
@ApplicationContext private val context: Context,
5158
private val repository: AnalyticsPermissionRepository,
5259
) {
60+
/**
61+
* A flow that emits the current Analytics permission data.
62+
*
63+
* @see AnalyticsPermissionData
64+
*/
5365
val permissionData = repository.permissionData
66+
5467
private val firebase by lazy { FirebaseAnalytics.getInstance(context) }
5568

69+
/**
70+
* Logs an event to Firebase Analytics, if the user has granted permission.
71+
*
72+
* @param name The name of the event. Should be between 1 and 40 characters long.
73+
* @param params Optional parameters to be sent with the event.
74+
*/
5675
fun logEvent(@Size(min = 1L, max = 40L) name: String, params: Bundle? = null) {
5776
runBlocking {
5877
repository.permissionData.firstOrNull()
@@ -64,6 +83,11 @@ class NordicAnalytics @Inject internal constructor(
6483
}
6584
}
6685

86+
/**
87+
* Sets whether analytics collection is enabled or disabled.
88+
*
89+
* @param isEnabled True to enable analytics collection, false to disable it.
90+
*/
6791
suspend fun setAnalyticsEnabled(isEnabled: Boolean) {
6892
if (isEnabled) {
6993
repository.onPermissionGranted()

analytics/src/main/java/no/nordicsemi/android/common/analytics/view/AnalyticsPermissionRequestDialog.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
*/
3131

32+
@file:Suppress("unused")
33+
3234
package no.nordicsemi.android.common.analytics.view
3335

3436
import androidx.compose.foundation.layout.fillMaxHeight

analytics/src/main/java/no/nordicsemi/android/common/analytics/view/AnalyticsPermissionSettingsSwitch.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
*/
3131

32+
@file:Suppress("unused")
33+
3234
package no.nordicsemi.android.common.analytics.view
3335

3436
import androidx.compose.foundation.clickable

build.gradle.kts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ plugins {
3232
alias(libs.plugins.android.library) apply false
3333
alias(libs.plugins.hilt) apply false
3434
alias(libs.plugins.kotlin.parcelize) apply false
35-
alias(libs.plugins.kotlin.dokka) apply false
3635
alias(libs.plugins.compose.compiler) apply false
3736

3837
// Nordic plugins are defined in https://github.com/NordicSemiconductor/Android-Gradle-Plugins
@@ -43,4 +42,18 @@ plugins {
4342
alias(libs.plugins.nordic.hilt) apply false
4443
alias(libs.plugins.nordic.nexus.android) apply false
4544
alias(libs.plugins.nordic.kotlin.android) apply false
45+
46+
// This plugin is used to generate Dokka documentation.
47+
alias(libs.plugins.kotlin.dokka) apply false
48+
// This applies Nordic look & feel to generated Dokka documentation.
49+
// https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/main/plugins/src/main/kotlin/NordicDokkaPlugin.kt
50+
alias(libs.plugins.nordic.dokka) apply true
4651
}
52+
53+
// Configure main Dokka page
54+
dokka {
55+
moduleName.set("Nordic Common Libraries")
56+
pluginsConfiguration.html {
57+
homepageLink.set("https://github.com/NordicPlayground/Android-Common-Libraries")
58+
}
59+
}

core/Module.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Module core
2+
3+
Common classes and interfaces used by other modules.
4+
5+
# Package no.nordicsemi.android.common.core
6+
7+
Common classes and interfaces used by other modules.

0 commit comments

Comments
 (0)