-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from stadiamaps/feat/android/google-play
feat: google play services extensions
- Loading branch information
Showing
17 changed files
with
232 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,5 @@ plugins { | |
|
||
allprojects { | ||
group = "com.stadiamaps.ferrostar" | ||
version = "0.11.0" | ||
version = "0.12.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import com.vanniktech.maven.publish.AndroidMultiVariantLibrary | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
|
||
plugins { | ||
alias libs.plugins.androidLibrary | ||
alias libs.plugins.jetbrainsKotlinAndroid | ||
alias libs.plugins.ktfmt | ||
alias libs.plugins.mavenPublish | ||
} | ||
|
||
android { | ||
namespace 'com.stadiamaps.ferrostar.googleplayservices' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
minSdk 25 | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
coreLibraryDesugaringEnabled true | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
// For as long as we support API 25; once we can raise support to 26, all is fine | ||
coreLibraryDesugaring libs.desugar.jdk.libs | ||
|
||
implementation libs.androidx.ktx | ||
implementation libs.androidx.appcompat | ||
implementation libs.material | ||
|
||
implementation project(':core') | ||
implementation libs.play.services.location | ||
|
||
testImplementation libs.junit | ||
androidTestImplementation libs.androidx.test.junit | ||
androidTestImplementation libs.androidx.test.espresso | ||
} | ||
|
||
mavenPublishing { | ||
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) | ||
signAllPublications() | ||
|
||
configure(new AndroidMultiVariantLibrary(true, true)) | ||
|
||
apply from: "${rootProject.projectDir}/common-pom.gradle" | ||
|
||
pom { | ||
name = "Ferrostar Google Play Services" | ||
description = "Ferrostar components that rely on Google Play Services" | ||
commonPomConfig(it, true) | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
22 changes: 22 additions & 0 deletions
22
...c/androidTest/java/com/stadiamaps/ferrostar/googleplayservices/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.stadiamaps.ferrostar.googleplayservices | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.stadiamaps.ferrostar.googleplayservices.test", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
64 changes: 64 additions & 0 deletions
64
...rvices/src/main/java/com/stadiamaps/ferrostar/googleplayservices/FusedLocationProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.stadiamaps.ferrostar.googleplayservices | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.os.Looper | ||
import android.util.Log | ||
import com.google.android.gms.location.FusedLocationProviderClient | ||
import com.google.android.gms.location.LocationListener | ||
import com.google.android.gms.location.LocationRequest | ||
import com.google.android.gms.location.LocationServices | ||
import com.google.android.gms.location.Priority | ||
import com.stadiamaps.ferrostar.core.LocationProvider | ||
import com.stadiamaps.ferrostar.core.LocationUpdateListener | ||
import com.stadiamaps.ferrostar.core.toUserLocation | ||
import java.util.concurrent.Executor | ||
import uniffi.ferrostar.Heading | ||
import uniffi.ferrostar.UserLocation | ||
|
||
class FusedLocationProvider( | ||
context: Context, | ||
private val fusedLocationProviderClient: FusedLocationProviderClient = | ||
LocationServices.getFusedLocationProviderClient(context) | ||
) : LocationProvider { | ||
|
||
companion object { | ||
private const val TAG = "FusedLocationProvider" | ||
} | ||
|
||
override var lastLocation: UserLocation? = null | ||
private set | ||
|
||
override var lastHeading: Heading? = null | ||
private set | ||
|
||
private val listeners: MutableMap<LocationUpdateListener, LocationListener> = mutableMapOf() | ||
|
||
@SuppressLint("MissingPermission") | ||
override fun addListener(listener: LocationUpdateListener, executor: Executor) { | ||
Log.d(TAG, "Adding listener") | ||
if (listeners.contains(listener)) { | ||
Log.d(TAG, "Listener already added") | ||
return | ||
} | ||
|
||
val locationListener = LocationListener { newLocation -> | ||
listener.onLocationUpdated(newLocation.toUserLocation()) | ||
} | ||
listeners[listener] = locationListener | ||
|
||
val locationRequest = | ||
LocationRequest.Builder(1000L).setPriority(Priority.PRIORITY_HIGH_ACCURACY).build() | ||
|
||
fusedLocationProviderClient.requestLocationUpdates( | ||
locationRequest, locationListener, Looper.getMainLooper()) | ||
} | ||
|
||
override fun removeListener(listener: LocationUpdateListener) { | ||
val activeListener = listeners.remove(listener) | ||
|
||
if (activeListener != null) { | ||
fusedLocationProviderClient.removeLocationUpdates(activeListener) | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...lay-services/src/test/java/com/stadiamaps/ferrostar/googleplayservices/ExampleUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.stadiamaps.ferrostar.googleplayservices | ||
|
||
import org.junit.Assert.* | ||
import org.junit.Test | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ include ':core' | |
include ':composeui' | ||
include ':demo-app' | ||
include ':maplibreui' | ||
include ':google-play-services' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
"CatMe0w <[email protected]> (https://github.com/CatMe0w)", | ||
"Luke Seelenbinder <[email protected]>" | ||
], | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"license": "BSD-3-Clause", | ||
"type": "module", | ||
"main": "./dist/ferrostar-webcomponents.js", | ||
|