Skip to content

Commit fd4349e

Browse files
authored
Merge pull request #20 from icerockdev/develop
Release 0.3.2
2 parents 8851dee + d6d0e4c commit fd4349e

File tree

25 files changed

+407
-79
lines changed

25 files changed

+407
-79
lines changed

.github/workflows/compilation-check.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ name: KMP library compilation check
33
on:
44
pull_request:
55
branches:
6-
- master
7-
- develop
6+
- master
7+
- develop
88

99
jobs:
10-
build:
10+
test:
1111
runs-on: macOS-latest
1212

1313
steps:
14-
- uses: actions/checkout@v1
15-
- name: Set up JDK 1.8
16-
uses: actions/setup-java@v1
17-
with:
18-
java-version: 1.8
19-
- name: Check build
20-
run: ./gradlew build publishToMavenLocal
14+
- uses: actions/checkout@v1
15+
- name: Set up JDK 1.8
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 1.8
19+
- name: Check runtime
20+
run: ./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosX64
21+
- name: Install pods
22+
run: cd sample/ios-app && pod install
23+
- name: build ios sample
24+
run: cd sample/ios-app && xcodebuild -scheme TestProj -workspace TestProj.xcworkspace -configuration Debug build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO

.github/workflows/publish.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,44 @@
1-
name: KMP library publish
1+
name: Create release
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version'
8+
default: '0.1.0'
9+
required: true
610

711
jobs:
8-
build:
9-
runs-on: macOS-latest
10-
12+
publish:
13+
name: Publish library at mavenCentral
14+
runs-on: macos-latest
15+
env:
16+
OSSRH_USER: ${{ secrets.OSSRH_USER }}
17+
OSSRH_KEY: ${{ secrets.OSSRH_KEY }}
18+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEYID }}
19+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
20+
SIGNING_KEY: ${{ secrets.GPG_KEY_CONTENTS }}
1121
steps:
1222
- uses: actions/checkout@v1
1323
- name: Set up JDK 1.8
1424
uses: actions/setup-java@v1
1525
with:
1626
java-version: 1.8
1727
- name: Publish
18-
run: ./gradlew publishAllPublicationsToBintrayRepository -DBINTRAY_USER=${{ secrets.BINTRAY_USER }} -DBINTRAY_KEY=${{ secrets.BINTRAY_KEY }}
28+
run: ./gradlew publish
29+
release:
30+
name: Create release
31+
needs: publish
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Create Release
35+
id: create_release
36+
uses: actions/create-release@v1
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
with:
40+
commitish: ${{ github.ref }}
41+
tag_name: release/${{ github.event.inputs.version }}
42+
release_name: Release ${{ github.event.inputs.version }}
43+
body: "Will be filled later"
44+
draft: true

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
![moko-mvvm](https://user-images.githubusercontent.com/5010169/71337878-0e0d0f80-2580-11ea-8ac5-69a132334960.png)
2-
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://api.bintray.com/packages/icerockdev/moko/moko-geo/images/download.svg) ](https://bintray.com/icerockdev/moko/moko-geo/_latestVersion) ![kotlin-version](https://img.shields.io/badge/kotlin-1.4.21-orange)
2+
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/geo) ](https://repo1.maven.org/maven2/dev/icerock/moko/geo) ![kotlin-version](https://img.shields.io/badge/kotlin-1.4.31-orange)
33

44
# Mobile Kotlin geolocation module
55
This is a Kotlin Multiplatform library that provides geolocation to common code.
@@ -24,6 +24,7 @@ This is a Kotlin Multiplatform library that provides geolocation to common code.
2424
- iOS version 9.0+
2525

2626
## Versions
27+
### Bintray
2728
- kotlin 1.3.61
2829
- 0.1.0
2930
- 0.1.1
@@ -33,22 +34,25 @@ This is a Kotlin Multiplatform library that provides geolocation to common code.
3334
- 0.3.0
3435
- kotlin 1.4.21
3536
- 0.3.1
37+
### mavenCentral
38+
- kotlin 1.4.31
39+
- 0.3.2
3640

3741
## Installation
3842
root build.gradle
3943
```groovy
4044
allprojects {
4145
repositories {
42-
maven { url = "https://dl.bintray.com/icerockdev/moko" }
46+
mavenCentral()
4347
}
4448
}
4549
```
4650

4751
project build.gradle
4852
```groovy
4953
dependencies {
50-
commonMainApi("dev.icerock.moko:geo:0.3.1")
51-
androidMainImplementation("com.google.android.gms:play-services-location:17.0.0")
54+
commonMainApi("dev.icerock.moko:geo:0.3.2")
55+
androidMainImplementation("com.google.android.gms:play-services-location:18.0.0")
5256
}
5357
```
5458

build.gradle.kts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
allprojects {
66
repositories {
7+
mavenCentral()
78
google()
8-
jcenter()
99

10-
maven { url = uri("https://kotlin.bintray.com/kotlin") }
11-
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
12-
maven { url = uri("https://dl.bintray.com/icerockdev/moko") }
10+
jcenter {
11+
content {
12+
includeGroup("org.jetbrains.trove4j")
13+
includeGroup("org.jetbrains.kotlinx")
14+
}
15+
}
1316
}
1417

1518
plugins.withId(Deps.Plugins.androidLibrary.id) {

buildSrc/build.gradle.kts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
*/
44

55
plugins {
6-
id("org.jetbrains.kotlin.jvm") version("1.4.21")
6+
id("org.jetbrains.kotlin.jvm") version("1.4.31")
77
}
88

99
repositories {
10-
jcenter()
10+
mavenCentral()
1111
google()
1212

13-
maven { url = uri("https://dl.bintray.com/icerockdev/plugins") }
13+
jcenter {
14+
content {
15+
includeGroup("org.jetbrains.trove4j")
16+
}
17+
}
1418
}
1519

1620
dependencies {
17-
implementation("dev.icerock:mobile-multiplatform:0.9.0")
18-
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21")
19-
implementation("com.android.tools.build:gradle:4.0.1")
21+
implementation("dev.icerock:mobile-multiplatform:0.9.1")
22+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31")
23+
implementation("com.android.tools.build:gradle:4.1.1")
2024
}

buildSrc/src/main/kotlin/Deps.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
object Deps {
2-
private const val kotlinVersion = "1.4.21"
2+
private const val kotlinVersion = "1.4.31"
33

44
private const val androidAppCompatVersion = "1.1.0"
55
private const val materialDesignVersion = "1.0.0"
66
private const val androidLifecycleVersion = "2.1.0"
77
private const val androidCoreTestingVersion = "2.1.0"
8-
private const val playServicesLocationVersion = "16.0.0"
8+
private const val playServicesLocationVersion = "18.0.0"
99

10-
private const val detektVersion = "1.7.4"
10+
private const val detektVersion = "1.15.0"
1111

1212
private const val coroutinesVersion = "1.4.2"
13-
private const val mokoParcelizeVersion = "0.5.0"
14-
private const val mokoPermissionsVersion = "0.6.0"
15-
private const val mokoMvvmVersion = "0.8.1"
16-
const val mokoGeoVersion = "0.3.1"
13+
private const val mokoParcelizeVersion = "0.6.1"
14+
private const val mokoPermissionsVersion = "0.8.0"
15+
private const val mokoMvvmVersion = "0.9.2"
16+
const val mokoGeoVersion = "0.3.2"
1717

1818
object Android {
1919
const val compileSdk = 28
@@ -31,6 +31,7 @@ object Deps {
3131
val kotlinAndroidExtensions = GradlePlugin(id = "kotlin-android-extensions")
3232
val kotlinSerialization = GradlePlugin(id = "kotlin-serialization")
3333
val mavenPublish = GradlePlugin(id = "org.gradle.maven-publish")
34+
val signing = GradlePlugin(id = "signing")
3435

3536
val mobileMultiplatform = GradlePlugin(id = "dev.icerock.mobile.multiplatform")
3637
val iosFramework = GradlePlugin(id = "dev.icerock.mobile.multiplatform.ios-framework")

geo/build.gradle.kts

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
import java.util.Base64
6+
57
plugins {
68
plugin(Deps.Plugins.androidLibrary)
79
plugin(Deps.Plugins.kotlinMultiplatform)
810
plugin(Deps.Plugins.kotlinKapt)
911
plugin(Deps.Plugins.kotlinAndroidExtensions)
1012
plugin(Deps.Plugins.mobileMultiplatform)
1113
plugin(Deps.Plugins.mavenPublish)
14+
plugin(Deps.Plugins.signing)
1215
}
1316

1417
group = "dev.icerock.moko"
@@ -25,13 +28,60 @@ dependencies {
2528
androidMainImplementation(Deps.Libs.Android.playServicesLocation)
2629
}
2730

31+
val javadocJar by tasks.registering(Jar::class) {
32+
archiveClassifier.set("javadoc")
33+
}
34+
2835
publishing {
29-
repositories.maven("https://api.bintray.com/maven/icerockdev/moko/moko-geo/;publish=1") {
30-
name = "bintray"
36+
repositories.maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
37+
name = "OSSRH"
3138

3239
credentials {
33-
username = System.getProperty("BINTRAY_USER")
34-
password = System.getProperty("BINTRAY_KEY")
40+
username = System.getenv("OSSRH_USER")
41+
password = System.getenv("OSSRH_KEY")
42+
}
43+
}
44+
45+
publications.withType<MavenPublication> {
46+
// Stub javadoc.jar artifact
47+
artifact(javadocJar.get())
48+
49+
// Provide artifacts information requited by Maven Central
50+
pom {
51+
name.set("MOKO geo")
52+
description.set("Geolocation access for mobile (android & ios) Kotlin Multiplatform development")
53+
url.set("https://github.com/icerockdev/moko-geo")
54+
licenses {
55+
license {
56+
url.set("https://github.com/icerockdev/moko-geo/blob/master/LICENSE.md")
57+
}
58+
}
59+
60+
developers {
61+
developer {
62+
id.set("Alex009")
63+
name.set("Aleksey Mikhailov")
64+
email.set("aleksey.mikhailov@icerockdev.com")
65+
}
66+
}
67+
68+
scm {
69+
connection.set("scm:git:ssh://github.com/icerockdev/moko-geo.git")
70+
developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-geo.git")
71+
url.set("https://github.com/icerockdev/moko-geo")
72+
}
3573
}
3674
}
37-
}
75+
}
76+
77+
signing {
78+
val signingKeyId: String? = System.getenv("SIGNING_KEY_ID")
79+
val signingPassword: String? = System.getenv("SIGNING_PASSWORD")
80+
val signingKey: String? = System.getenv("SIGNING_KEY")?.let { base64Key ->
81+
String(Base64.getDecoder().decode(base64Key))
82+
}
83+
if (signingKeyId != null) {
84+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
85+
sign(publishing.publications)
86+
}
87+
}

geo/src/androidMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package dev.icerock.moko.geo
66

77
import android.content.Context
8+
import android.os.Build
89
import androidx.fragment.app.FragmentManager
910
import androidx.lifecycle.Lifecycle
1011
import androidx.lifecycle.LifecycleObserver
@@ -36,6 +37,7 @@ actual class LocationTracker(
3637
it.priority = priority
3738
}
3839
private val locationsChannel = Channel<LatLng>(Channel.BUFFERED)
40+
private val extendedLocationsChannel = Channel<ExtendedLocation>(Channel.BUFFERED)
3941
private val trackerScope = CoroutineScope(Dispatchers.Main)
4042

4143
fun bind(lifecycle: Lifecycle, context: Context, fragmentManager: FragmentManager) {
@@ -59,12 +61,54 @@ actual class LocationTracker(
5961
override fun onLocationResult(locationResult: LocationResult) {
6062
super.onLocationResult(locationResult)
6163

64+
val lastLocation = locationResult.lastLocation
65+
66+
val speedAccuracy = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) null
67+
else lastLocation.speedAccuracyMetersPerSecond.toDouble()
68+
69+
val bearingAccuracy = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) null
70+
else lastLocation.bearingAccuracyDegrees.toDouble()
71+
72+
val verticalAccuracy = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) null
73+
else lastLocation.verticalAccuracyMeters.toDouble()
74+
6275
val latLng = LatLng(
63-
locationResult.lastLocation.latitude,
64-
locationResult.lastLocation.longitude
76+
lastLocation.latitude,
77+
lastLocation.longitude
78+
)
79+
80+
val locationPoint = Location(
81+
coordinates = latLng,
82+
coordinatesAccuracyMeters = lastLocation.accuracy.toDouble()
83+
)
84+
85+
val speed = Speed(
86+
speedMps = lastLocation.speed.toDouble(),
87+
speedAccuracyMps = speedAccuracy
88+
)
89+
90+
val azimuth = Azimuth(
91+
azimuthDegrees = lastLocation.bearing.toDouble(),
92+
azimuthAccuracyDegrees = bearingAccuracy
93+
)
94+
95+
val altitude = Altitude(
96+
altitudeMeters = lastLocation.altitude,
97+
altitudeAccuracyMeters = verticalAccuracy
98+
)
99+
100+
val extendedLocation = ExtendedLocation(
101+
location = locationPoint,
102+
azimuth = azimuth,
103+
speed = speed,
104+
altitude = altitude,
105+
timestampMs = lastLocation.time
65106
)
66107

67-
trackerScope.launch { locationsChannel.send(latLng) }
108+
trackerScope.launch {
109+
extendedLocationsChannel.send(extendedLocation)
110+
locationsChannel.send(latLng)
111+
}
68112
}
69113

70114
actual suspend fun startTracking() {
@@ -93,4 +137,18 @@ actual class LocationTracker(
93137
awaitClose { job.cancel() }
94138
}
95139
}
140+
141+
actual fun getExtendedLocationsFlow(): Flow<ExtendedLocation> {
142+
return channelFlow {
143+
val sendChannel = channel
144+
val job = launch {
145+
while (isActive) {
146+
val extendedLocation = extendedLocationsChannel.receive()
147+
sendChannel.send(extendedLocation)
148+
}
149+
}
150+
151+
awaitClose { job.cancel() }
152+
}
153+
}
96154
}

0 commit comments

Comments
 (0)