Skip to content

Commit

Permalink
Merge pull request #3 from ionic-team/feat/RMET-3997/rename-lib
Browse files Browse the repository at this point in the history
chore: rename lib to `IONGeolocationLib-Android`
  • Loading branch information
alexgerardojacinto authored Jan 21, 2025
2 parents 1c097ac + cedb945 commit bf13ab5
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 127 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.0]

### 2025-01-20
- Refactor: Rename library to `IONGeolocationLib`.

### 2025-01-08
- Feat: Add workflows to run unit tests and release the library in Maven repo.

Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# OSGeolocationLib
# IONGeolocationLib

The `OSGeolocationLib-Android` is a library built using `Kotlin` that provides geolocation features for Android applications.
The `IONGeolocationLib-Android` is a library built using `Kotlin` that provides geolocation features for Android applications.

The `OSGLOCController` class provides the main features of the Library, which are:
The `IONGLOCController` class provides the main features of the Library, which are:
- obtaining the location/position of the device a single time;
- adding a watch to obtain periodic location updates;
- clearing/removing a previously added watch, turning off location updates.
Expand All @@ -27,46 +27,46 @@ This library is used by the Geolocation Plugin for [OutSystems' Cordova Plugin](

## Usage

In your app-level gradle file, import the `OSGeolocationLib` library like so:
In your app-level gradle file, import the `IONGeolocationLib` library like so:

```
dependencies {
implementation("io.ionic.libs:osgeolocation-android:1.0.0")
implementation("io.ionic.libs:iongeolocation-android:1.0.0")
}
```

## Methods

As mentioned before, the library offers the `OSGLOCController` class that provides the following methods to interact with:
As mentioned before, the library offers the `IONGLOCController` class that provides the following methods to interact with:

### Obtain the current location of the device

```kotlin
suspend fun getCurrentPosition(
activity: Activity,
options: OSGLOCLocationOptions
): Result<OSGLOCLocationResult>
options: IONGLOCLocationOptions
): Result<IONGLOCLocationResult>
```

The method is composed of the following input parameters:
- **activity**: the `Activity` from the app using the library to use when obtaining the location.
- **options**: `OSGLOCLocationOptions` with the options with which to make the location request with (e.g. timeout).
- **options**: `IONGLOCLocationOptions` with the options with which to make the location request with (e.g. timeout).

The method returns a `Result` containing either an object of type `OSGLOCLocationResult`, which includes the geolocation data (e.g. latitide, longitude), or an exception that should be handled by the caller app.
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.

### Add a watch for periodic location updates

```kotlin
fun addWatch(
activity: Activity,
options: OSGLOCLocationOptions,
options: IONGLOCLocationOptions,
watchId: String
): Flow<Result<List<OSGLOCLocationResult>>>
): Flow<Result<List<IONGLOCLocationResult>>>
```

The method is composed of the following input parameters:
- **activity**: the `Activity` from the app using the library to use when obtaining the location updates.
- **options**: `OSGLOCLocationOptions` with the options with which to make the location updates request with (e.g. timeout).
- **options**: `IONGLOCLocationOptions` with the options with which to make the location updates request with (e.g. timeout).
- **watchId**: a unique id identifying the watch to add, so that it can be removed later.

The method returns a Flow in which the location updates will be emitted to.
Expand Down Expand Up @@ -106,8 +106,8 @@ Common issues and solutions:

## License

`OSGeolocationLib` is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
`IONGeolocationLib` is available under the MIT license. See the [LICENSE](LICENSE) file for more info.

## Support

- Report issues on our [Issue Tracker](https://github.com/ionic-team/OSGeolocationLib-Android/issues)
- Report issues on our [Issue Tracker](https://github.com/ionic-team/IONGeolocationLib-Android/issues)
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

sonarqube {
properties {
property "sonar.projectKey", "OutSystems_OSGeolocationLib-Android"
property "sonar.projectKey", "OutSystems_IONGeolocationLib-Android"
property "sonar.organization", "outsystemsrd"
property "sonar.host.url", "https://sonarcloud.io"
}
Expand All @@ -40,7 +40,7 @@ apply plugin: "kotlin-android"
apply plugin: "jacoco"

android {
namespace "io.ionic.libs.osgeolocationlib"
namespace "io.ionic.libs.iongeolocationlib"
compileSdk 35

defaultConfig {
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("io.ionic.libs.osgeolocationlib") # e.g. com.krausefx.app
package_name("io.ionic.libs.iongeolocationlib") # e.g. com.krausefx.app
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

<modelVersion>4.0.0</modelVersion>
<groupId>io.ionic.libs</groupId>
<artifactId>osgeolocation-android</artifactId>
<artifactId>iongeolocation-android</artifactId>
<version>0.0.1</version>
</project>
2 changes: 1 addition & 1 deletion scripts/publish-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LOG_OUTPUT=./tmp/publish-android.txt
THE_VERSION=`sed -n 's/.*<version>\(.*\)<\/version>.*/\1/p' ../pom.xml`

# Get latest io.ionic:portals XML version info
PUBLISHED_URL="https://repo1.maven.org/maven2/io/ionic/libs/osgeolocation-android/maven-metadata.xml"
PUBLISHED_URL="https://repo1.maven.org/maven2/io/ionic/libs/iongeolocation-android/maven-metadata.xml"
PUBLISHED_DATA=$(curl -s $PUBLISHED_URL)
PUBLISHED_VERSION="$(perl -ne 'print and last if s/.*<latest>(.*)<\/latest>.*/\1/;' <<< $PUBLISHED_DATA)"

Expand Down
14 changes: 7 additions & 7 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ afterEvaluate {
release(MavenPublication) {
// Coordinates
groupId 'io.ionic.libs'
artifactId 'osgeolocation-android'
artifactId 'iongeolocation-android'
version LIB_VERSION

// Two artifacts, the `aar` (or `jar`) and the sources
Expand All @@ -36,13 +36,13 @@ afterEvaluate {

// POM Data
pom {
name = 'osgeolocation-android'
name = 'iongeolocation-android'
description = 'Geolocation Android Lib'
url = 'https://github.com/ionic-team/OSGeolocationLib-Android'
url = 'https://github.com/ionic-team/IONGeolocationLib-Android'
licenses {
license {
name = 'License'
url = 'https://github.com/ionic-team/OSGeolocationLib-Android/blob/main/LICENSE'
url = 'https://github.com/ionic-team/IONGeolocationLib-Android/blob/main/LICENSE'
}
}
developers {
Expand All @@ -54,9 +54,9 @@ afterEvaluate {

// Version Control Info
scm {
connection = 'scm:git:github.com:ionic-team/OSGeolocationLib-Android.git'
developerConnection = 'scm:git:ssh://github.com:ionic-team/OSGeolocationLib-Android.git'
url = 'https://github.com/ionic-team/OSGeolocationLib-Android/tree/main'
connection = 'scm:git:github.com:ionic-team/IONGeolocationLib-Android.git'
developerConnection = 'scm:git:ssh://github.com:ionic-team/IONGeolocationLib-Android.git'
url = 'https://github.com/ionic-team/IONGeolocationLib-Android/tree/main'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/publish-root.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ nexusPublishing {
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
repositoryDescription = 'OSGeolocation Android Lib v' + System.getenv('THE_VERSION')
repositoryDescription = 'IONGeolocation Android Lib v' + System.getenv('THE_VERSION')
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = "OSGeolocationLib"
rootProject.name = "IONGeolocationLib"
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Organization and project keys are displayed in the right sidebar of the project homepage
sonar.organization=outsystemsrd
sonar.projectKey=OutSystems_OSGeolocationLib-Android
sonar.projectKey=OutSystems_IONGeolocationLib-Android
sonar.host.url=https://sonarcloud.io

sonar.language=kotlin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.ionic.libs.osgeolocationlib.controller
package io.ionic.libs.iongeolocationlib.controller

import android.os.Build

/**
* Build config wrapper object
*/
internal object OSGLOCBuildConfig {
internal object IONGLOCBuildConfig {
fun getAndroidSdkVersionCode(): Int = Build.VERSION.SDK_INT
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.ionic.libs.osgeolocationlib.controller
package io.ionic.libs.iongeolocationlib.controller

import android.app.Activity
import android.content.Context
Expand All @@ -12,23 +12,23 @@ import androidx.core.location.LocationManagerCompat
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.LocationCallback
import com.google.android.gms.location.LocationResult
import io.ionic.libs.osgeolocationlib.model.OSGLOCException
import io.ionic.libs.osgeolocationlib.model.OSGLOCLocationOptions
import io.ionic.libs.osgeolocationlib.model.OSGLOCLocationResult
import io.ionic.libs.iongeolocationlib.model.IONGLOCException
import io.ionic.libs.iongeolocationlib.model.IONGLOCLocationOptions
import io.ionic.libs.iongeolocationlib.model.IONGLOCLocationResult
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.first

/**
* Entry point in OSGeolocationLib-Android
* Entry point in IONGeolocationLib-Android
*
*/
class OSGLOCController(
class IONGLOCController(
fusedLocationClient: FusedLocationProviderClient,
activityLauncher: ActivityResultLauncher<IntentSenderRequest>,
private val helper: OSGLOCServiceHelper = OSGLOCServiceHelper(
private val helper: IONGLOCServiceHelper = IONGLOCServiceHelper(
fusedLocationClient,
activityLauncher
)
Expand All @@ -41,13 +41,13 @@ class OSGLOCController(
* Obtains the device's location using FusedLocationProviderClient.
* Tries to obtain the last retrieved location, and then gets a fresh one if necessary.
* @param activity the Android activity from which the location request is being triggered
* @param options OSLocationOptions object with the options to obtain the location with (e.g. timeout)
* @return Result<OSLocationResult> object with either the location or an exception to be handled by the caller
* @param options IONGLOCLocationOptions object with the options to obtain the location with (e.g. timeout)
* @return Result<IONGLOCLocationResult> object with either the location or an exception to be handled by the caller
*/
suspend fun getCurrentPosition(
activity: Activity,
options: OSGLOCLocationOptions
): Result<OSGLOCLocationResult> {
options: IONGLOCLocationOptions
): Result<IONGLOCLocationResult> {
try {
val checkResult: Result<Unit> =
checkLocationPreconditions(activity, options, isSingleLocationRequest = true)
Expand Down Expand Up @@ -77,7 +77,7 @@ class OSGLOCController(
Result.success(Unit)
else
Result.failure(
OSGLOCException.OSGLOCRequestDeniedException(
IONGLOCException.IONGLOCRequestDeniedException(
message = "Request to enable location denied."
)
)
Expand All @@ -101,9 +101,9 @@ class OSGLOCController(
*/
fun addWatch(
activity: Activity,
options: OSGLOCLocationOptions,
options: IONGLOCLocationOptions,
watchId: String
): Flow<Result<List<OSGLOCLocationResult>>> = callbackFlow {
): Flow<Result<List<IONGLOCLocationResult>>> = callbackFlow {

try {
val checkResult: Result<Unit> =
Expand Down Expand Up @@ -152,13 +152,13 @@ class OSGLOCController(
*/
private suspend fun checkLocationPreconditions(
activity: Activity,
options: OSGLOCLocationOptions,
options: IONGLOCLocationOptions,
isSingleLocationRequest: Boolean
): Result<Unit> {
// check timeout
if (options.timeout <= 0) {
return Result.failure(
OSGLOCException.OSGLOCInvalidTimeoutException(
IONGLOCException.IONGLOCInvalidTimeoutException(
message = "Timeout needs to be a positive value."
)
)
Expand Down Expand Up @@ -226,19 +226,19 @@ class OSGLOCController(
* Extension function to convert Location object into OSLocationResult object
* @return OSLocationResult object
*/
private fun Location.toOSLocationResult(): OSGLOCLocationResult = OSGLOCLocationResult(
private fun Location.toOSLocationResult(): IONGLOCLocationResult = IONGLOCLocationResult(
latitude = this.latitude,
longitude = this.longitude,
altitude = this.altitude,
accuracy = this.accuracy,
altitudeAccuracy = if (OSGLOCBuildConfig.getAndroidSdkVersionCode() >= Build.VERSION_CODES.O) this.verticalAccuracyMeters else null,
altitudeAccuracy = if (IONGLOCBuildConfig.getAndroidSdkVersionCode() >= Build.VERSION_CODES.O) this.verticalAccuracyMeters else null,
heading = this.bearing,
speed = this.speed,
timestamp = this.time
)

companion object {
private const val LOG_TAG = "OSGeolocationController"
private const val LOG_TAG = "IONGeolocationController"
}

}
Loading

0 comments on commit bf13ab5

Please sign in to comment.