Skip to content

Commit c440fce

Browse files
Merge pull request #4 from ionic-team/development
chore: prepare to release version `1.0.0`
2 parents 90126c8 + 9fc0c75 commit c440fce

51 files changed

Lines changed: 1360 additions & 497 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish Native Android Library
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
publish-android:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
packages: write
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: set up JDK 17
14+
uses: actions/setup-java@v4
15+
with:
16+
java-version: '17'
17+
distribution: 'adopt'
18+
- name: Grant execute permission for gradlew
19+
run: chmod +x ./gradlew
20+
- name: Grant execute permission for publishing script
21+
run: chmod +x ./scripts/publish-android.sh
22+
- name: Make local props
23+
run: |
24+
cat << EOF > "local.properties"
25+
ossrhUsername=${{ secrets.ANDROID_OSSRH_USERNAME }}
26+
ossrhPassword=${{ secrets.ANDROID_OSSRH_PASSWORD }}
27+
sonatypeStagingProfileId=${{ secrets.ANDROID_SONATYPE_STAGING_PROFILE_ID }}
28+
signing.keyId=${{ secrets.ANDROID_SIGNING_KEY_ID }}
29+
signing.password=${{ secrets.ANDROID_SIGNING_PASSWORD }}
30+
signing.key=${{ secrets.ANDROID_SIGNING_KEY }}
31+
EOF
32+
echo "local.properties file has been created successfully."
33+
- name: Run publish script
34+
working-directory: ./scripts
35+
run: ./publish-android.sh
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: GitHub Actions
1+
name: Run Unit Tests
22

33
on:
44
workflow_dispatch:
@@ -31,11 +31,12 @@ jobs:
3131
- name: Code Coverage
3232
run: bundle exec fastlane coverage
3333

34-
- name: Setup sonarqube
35-
uses: warchant/setup-sonar-scanner@v8
34+
# Commenting Sonarqube steps for now, until we are able to configure Sonarqube in Ionic repos
35+
#- name: Setup sonarqube
36+
# uses: warchant/setup-sonar-scanner@v8
3637

37-
- name: Send to Sonarcloud
38-
run: bundle exec fastlane sonarqube
39-
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38+
#- name: Send to Sonarcloud
39+
# run: bundle exec fastlane sonarqube
40+
# env:
41+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [1.0.0]
8+
9+
### 2025-01-20
10+
- Refactor: Rename library to `IONGeolocationLib`.
11+
12+
### 2025-01-08
13+
- Feat: Add workflows to run unit tests and release the library in Maven repo.
14+
15+
### 2025-01-07
16+
- Feat: Add implementation for whole library, including `getCurrentPosition`, `watchPosition`, and `clearWatch`.
17+
- Chore: Create repository.

docs/LICENSE renamed to LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 OutSystems
3+
Copyright (c) 2025 Ionic
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# ion-android-geolocation
2+
3+
The `ion-android-geolocation` is a library built using `Kotlin` that provides geolocation features for Android applications.
4+
5+
The `IONGLOCController` class provides the main features of the Library, which are:
6+
- obtaining the location/position of the device a single time;
7+
- adding a watch to obtain periodic location updates;
8+
- clearing/removing a previously added watch, turning off location updates.
9+
10+
11+
## Index
12+
13+
- [Motivation](#motivation)
14+
- [Usage](#usage)
15+
- [Methods](#methods)
16+
- [Obtain the current location of the device](#obtain-the-current-location-of-the-device)
17+
- [Add a watch for periodic location updates](#add-a-watch-for-periodic-location-updates)
18+
- [Clear a watch that was added previously](#clear-a-watch-that-was-added-previously)
19+
- [Troubleshooting](#troubleshooting)
20+
- [Contributing](#contributing)
21+
- [License](#license)
22+
- [Support](#support)
23+
24+
## Motivation
25+
26+
This library is used by the Geolocation Plugin for [OutSystems' Cordova Plugin](https://github.com/ionic-team/cordova-outsystems-geolocation) and [Ionic's Capacitor Plugin](https://github.com/ionic-team/outsystems-geolocation).
27+
28+
## Usage
29+
30+
In your app-level gradle file, import the `ion-android-geolocation` library like so:
31+
32+
```
33+
dependencies {
34+
implementation("io.ionic.libs:iongeolocation-android:1.0.0")
35+
}
36+
```
37+
38+
## Methods
39+
40+
As mentioned before, the library offers the `IONGLOCController` class that provides the following methods to interact with:
41+
42+
### Obtain the current location of the device
43+
44+
```kotlin
45+
suspend fun getCurrentPosition(
46+
activity: Activity,
47+
options: IONGLOCLocationOptions
48+
): Result<IONGLOCLocationResult>
49+
```
50+
51+
The method is composed of the following input parameters:
52+
- **activity**: the `Activity` from the app using the library to use when obtaining the location.
53+
- **options**: `IONGLOCLocationOptions` with the options with which to make the location request with (e.g. timeout).
54+
55+
The method returns a `Result` containing either an object of type `IONGLOCLocationResult`, which includes the geolocation data (e.g. latitide, longitude), or an exception that should be handled by the caller app.
56+
57+
### Add a watch for periodic location updates
58+
59+
```kotlin
60+
fun addWatch(
61+
activity: Activity,
62+
options: IONGLOCLocationOptions,
63+
watchId: String
64+
): Flow<Result<List<IONGLOCLocationResult>>>
65+
```
66+
67+
The method is composed of the following input parameters:
68+
- **activity**: the `Activity` from the app using the library to use when obtaining the location updates.
69+
- **options**: `IONGLOCLocationOptions` with the options with which to make the location updates request with (e.g. timeout).
70+
- **watchId**: a unique id identifying the watch to add, so that it can be removed later.
71+
72+
The method returns a Flow in which the location updates will be emitted to.
73+
74+
### Clear a watch that was added previously
75+
76+
```kotlin
77+
fun clearWatch(id: String): Boolean
78+
```
79+
80+
The method is composed of the following input parameters:
81+
- **id**: the `watchId` identigying the watch to remove.
82+
83+
The method returns a Boolean indicating if the watch was cleared or not (in case the watch isn't found).
84+
85+
## Troubleshooting
86+
87+
Common issues and solutions:
88+
89+
1. Location updates not received
90+
- Check that location permission is allowed on the device
91+
- Verify location services are enabled on the device
92+
- Ensure the necessary permissions are included in `AndroidManifest.xml`
93+
94+
2. Poor accuracy
95+
- Enable high accuracy mode
96+
- Ensure clear sky view
97+
- Wait for better GPS signal
98+
99+
## Contributing
100+
101+
1. Fork the repository
102+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
103+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
104+
4. Push to the branch (`git push origin feature/amazing-feature`)
105+
5. Open a Pull Request
106+
107+
## License
108+
109+
`ion-android-geolocation` is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
110+
111+
## Support
112+
113+
- Report issues on our [Issue Tracker](https://github.com/ionic-team/ion-android-geolocation/issues)

build.gradle

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,58 @@
11
buildscript {
2-
ext.kotlin_version = "1.5.21"
2+
ext.kotlin_version = "1.9.24"
33
ext.jacocoVersion = '0.8.7'
44
repositories {
55
google()
66
mavenCentral()
7+
maven {
8+
url = uri("https://plugins.gradle.org/m2/")
9+
}
710
}
811
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.1.2'
12+
if (System.getenv("SHOULD_PUBLISH") == "true") {
13+
classpath("io.github.gradle-nexus:publish-plugin:1.1.0")
14+
}
15+
classpath 'com.android.tools.build:gradle:8.2.2'
1016
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1117
classpath "org.jacoco:org.jacoco.core:$jacocoVersion"
1218
}
1319
}
1420

21+
plugins {
22+
id "org.sonarqube" version "3.5.0.2730"
23+
}
24+
25+
sonarqube {
26+
properties {
27+
property "sonar.projectKey", "OutSystems_IONGeolocationLib-Android"
28+
property "sonar.organization", "outsystemsrd"
29+
property "sonar.host.url", "https://sonarcloud.io"
30+
}
31+
}
32+
33+
if (System.getenv("SHOULD_PUBLISH") == "true") {
34+
apply plugin: "io.github.gradle-nexus.publish-plugin"
35+
apply from: file("./scripts/publish-root.gradle")
36+
}
37+
1538
apply plugin: "com.android.library"
1639
apply plugin: "kotlin-android"
1740
apply plugin: "jacoco"
1841

1942
android {
20-
compileSdk 32
43+
namespace "io.ionic.libs.iongeolocationlib"
44+
compileSdk 35
2145

2246
defaultConfig {
23-
minSdk 26
24-
targetSdk 32
47+
minSdk 23
48+
targetSdk 35
2549
versionCode 1
2650
versionName "1.0"
2751

2852
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
53+
vectorDrawables {
54+
useSupportLibrary true
55+
}
2956
}
3057

3158
buildTypes {
@@ -35,23 +62,23 @@ android {
3562
}
3663
}
3764
compileOptions {
38-
sourceCompatibility JavaVersion.VERSION_1_8
39-
targetCompatibility JavaVersion.VERSION_1_8
65+
sourceCompatibility JavaVersion.VERSION_17
66+
targetCompatibility JavaVersion.VERSION_17
4067
}
4168
kotlinOptions {
42-
jvmTarget = '1.8'
69+
jvmTarget = '17'
4370
}
4471

4572
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
4673

4774
reports {
48-
xml.enabled = true
49-
html.enabled = true
75+
xml.getRequired().set(true)
76+
html.getRequired().set(true)
5077
}
5178

5279
def fileFilter = ['**/BuildConfig.*', '**/Manifest*.*']
53-
def debugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/debugUnitTest", excludes: fileFilter)
54-
def mainSrc = "${project.projectDir}/src/main/java"
80+
def debugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/debug", excludes: fileFilter)
81+
def mainSrc = "${project.projectDir}/src/main/kotlin"
5582

5683
sourceDirectories.setFrom(files([mainSrc]))
5784
classDirectories.setFrom(files([debugTree]))
@@ -60,6 +87,24 @@ android {
6087
"outputs/code-coverage/connected/*coverage.ec"
6188
]))
6289
}
90+
91+
packaging {
92+
resources {
93+
excludes += '/META-INF/{AL2.0,LGPL2.1}'
94+
}
95+
}
96+
97+
testOptions {
98+
unitTests.returnDefaultValues = true
99+
}
100+
101+
lintOptions {
102+
abortOnError false
103+
}
104+
105+
publishing {
106+
singleVariant("release")
107+
}
63108
}
64109

65110
repositories {
@@ -68,12 +113,22 @@ repositories {
68113
}
69114

70115
dependencies {
116+
implementation 'androidx.core:core-ktx:1.13.1'
117+
118+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
119+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
120+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4'
121+
implementation 'com.google.android.gms:play-services-location:21.3.0'
122+
implementation 'com.google.android.gms:play-services-base:18.5.0'
123+
implementation 'androidx.activity:activity:1.6.0'
124+
implementation 'androidx.activity:activity-ktx:1.9.3'
71125

72-
implementation 'androidx.core:core-ktx:1.7.0'
73-
implementation 'androidx.appcompat:appcompat:1.4.1'
74-
implementation 'com.google.android.material:material:1.5.0'
75-
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
76126
testImplementation 'junit:junit:4.13.2'
77-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
78-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
127+
testImplementation 'io.mockk:mockk:1.13.4'
128+
testImplementation 'app.cash.turbine:turbine:1.2.0'
129+
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3'
79130
}
131+
132+
if (System.getenv("SHOULD_PUBLISH") == "true") {
133+
apply from: file("./scripts/publish-module.gradle")
134+
}

docs/CHANGELOG.md

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

0 commit comments

Comments
 (0)