Skip to content

Commit

Permalink
Merge pull request #3 from makeen-project/main
Browse files Browse the repository at this point in the history
[Extended team WIP] Update dependencies
  • Loading branch information
ejboucher authored Jul 17, 2024
2 parents 371fd6c + d42f35e commit 2807e81
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 24 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: build

on:
workflow_dispatch:
pull_request:
branches: [main]

concurrency:
# cancel jobs on PRs only
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checking out branch
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Create empty custom.properties
working-directory: ./quick-start
run: touch custom.properties

- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
build-root-directory: ./quick-start

- name: Make gradlew executable
working-directory: ./quick-start
run: chmod +x ./gradlew

- name: Build with Gradle
working-directory: ./quick-start
run: ./gradlew build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.idea
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This repository contains a set of sample applications for Amazon Location Servic
## List of sample apps

- [Use the Amazon Location Mobile Tracking SDK with geofences](tracking-with-geofence-notifications)
- [Use the Amazon Location Quick start application](quick-start)

## Security

Expand Down
Binary file modified quick-start/README.md
Binary file not shown.
14 changes: 3 additions & 11 deletions quick-start/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
minSdk = 21
targetSdk = 34
versionCode = 1
versionName = "1.0"
versionName = "1.0.0"

buildConfigField("String", "IDENTITY_POOL_ID", "\"${customConfig.getProperty("IDENTITY_POOL_ID")}\"")
buildConfigField("String", "TRACKER_NAME", "\"${customConfig.getProperty("TRACKER_NAME")}\"")
Expand Down Expand Up @@ -75,16 +75,8 @@ dependencies {
implementation(libs.org.maplibre.gl)
implementation(libs.com.squareup.okhttp3)
implementation(libs.location)
if (findProject(":authSdk") != null) {
implementation(project(mapOf("path" to ":authSdk")))
} else {
implementation(libs.auth)
}
if (findProject(":trackingSdk") != null) {
implementation(project(mapOf("path" to ":trackingSdk")))
} else {
implementation(libs.tracking)
}
implementation(libs.auth)
implementation(libs.tracking)
testImplementation(libs.mockk)
testImplementation(libs.mockito.core)
androidTestImplementation(libs.androidx.uiautomator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class MainActivity : ComponentActivity(), OnMapReadyCallback, MapLibreMap.OnCame
mainViewModel.enableLocationComponent(this)
}
if (mainViewModel.isLocationTrackingForegroundActive) {
mainViewModel.stopTrackingForeground()
mainViewModel.stopTrackingForeground(applicationContext)
} else {
mainViewModel.setLiveTracking()
mainViewModel.startTrackingForeground(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ class MainViewModel : ViewModel() {
/**
* Unsubscribes from location updates and updates the UI button text accordingly.
*/
fun stopTrackingForeground() {
fun stopTrackingForeground(context: Context) {
if (checkLocationPermission(context)) return
isLocationTrackingForegroundActive = false
locationTracker?.stop()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Constants {
const val SERVICE_NAME = "geo"
const val TRACKER_LINE_SOURCE = "tracker_line_source"
const val TRACKER_LINE_LAYER = "tracker_line_layer"
const val FREQUENCY = 3000L
const val FREQUENCY = 1000L
const val ACCURACY = Priority.PRIORITY_HIGH_ACCURACY
const val LATENCY = 1000L
const val WAIT_FOR_ACCURATE_LOCATION = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package com.amazon.androidquickstartapp.utils
import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.location.Location
import android.location.LocationListener
import android.location.LocationManager
import android.os.Looper
import androidx.annotation.RequiresPermission
import androidx.core.app.ActivityCompat
Expand All @@ -16,6 +19,7 @@ import com.amazon.androidquickstartapp.utils.Constants.WAIT_FOR_ACCURATE_LOCATIO
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.LocationCallback
import com.google.android.gms.location.LocationRequest
import com.google.android.gms.location.LocationResult
import com.google.android.gms.location.LocationServices
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand All @@ -37,10 +41,15 @@ import org.maplibre.geojson.Feature
import org.maplibre.geojson.FeatureCollection
import org.maplibre.geojson.LineString
import org.maplibre.geojson.Point
import software.amazon.location.tracking.config.SdkConfig.MIN_DISTANCE
import software.amazon.location.tracking.util.Helper

class MapHelper {
private var fusedLocationClient: FusedLocationProviderClient? = null
private var locationManager: LocationManager? = null
private val coroutineScope = CoroutineScope(Dispatchers.Default)
private val helper = Helper()

fun enableLocationComponent(
it: Style,
context: Context,
Expand All @@ -66,7 +75,12 @@ class MapHelper {
locationComponent?.isLocationComponentEnabled = true
locationComponent?.cameraMode = CameraMode.TRACKING
locationComponent?.renderMode = RenderMode.NORMAL
fusedLocationClient = LocationServices.getFusedLocationProviderClient(context)

if (helper.isGooglePlayServicesAvailable(context)) {
fusedLocationClient = LocationServices.getFusedLocationProviderClient(context)
} else {
locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager
}
initLocationEngine(object : LocationCallback() {})
}

Expand Down Expand Up @@ -149,6 +163,15 @@ class MapHelper {

@RequiresPermission(anyOf = [Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION])
private fun initLocationEngine(locationCallback: LocationCallback) {
if (fusedLocationClient != null) {
initLocationEngineWithFusedLocationClient(locationCallback)
} else {
initLocationEngineWithLocationManager(locationCallback)
}
}

@RequiresPermission(anyOf = [Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION])
private fun initLocationEngineWithFusedLocationClient(locationCallback: LocationCallback) {
coroutineScope.launch {
fusedLocationClient?.locationAvailability?.addOnSuccessListener {
if (!it.isLocationAvailable) {
Expand All @@ -164,8 +187,29 @@ class MapHelper {
locationCallback,
Looper.getMainLooper(),
)
}
}
}

@RequiresPermission(anyOf = [Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION])
private fun initLocationEngineWithLocationManager(locationCallback: LocationCallback) {
coroutineScope.launch {
val locationListener = object : LocationListener {
override fun onLocationChanged(location: Location) {
val locationResult = LocationResult.create(arrayListOf(location))
locationCallback.onLocationResult(locationResult)
}

override fun onProviderEnabled(provider: String) {}
override fun onProviderDisabled(provider: String) {}
}
locationManager?.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
FREQUENCY,
MIN_DISTANCE,
locationListener,
Looper.getMainLooper()
)
}
}
}
4 changes: 2 additions & 2 deletions quick-start/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ maplibre = "11.0.0-pre5"
mockitoCore = "4.7.0"
mockk = "1.13.10"
okhttp = "4.9.2"
auth = "0.2.4"
playServicesLocation = "21.2.0"
tracking = "0.2.4"
auth = "0.2.5"
tracking = "0.2.5"
uiautomator = "2.3.0"

[libraries]
Expand Down
4 changes: 0 additions & 4 deletions quick-start/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@ dependencyResolutionManagement {

rootProject.name = "AndroidQuickStartApp"
include(":app")
include(":trackingSdk")
project(":trackingSdk").projectDir = file("./trackingSdk/library")
include(":authSdk")
project(":authSdk").projectDir = file("./authSdk/library")

4 changes: 2 additions & 2 deletions tracking-with-geofence-notifications/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Additional documentation for this sample application is available from the [Amaz
Create a `custom.properties` file in your project directory and input the following lines, replacing placeholders with actual values:

```properties
MQTT_END_POINT=xxxxxxxxxxxxx-xxx.xxx.us-east-1.amazonaws.com
MQTT_END_POINT=xxxxxxxxxxxxx-xxx.xxx.<MY-AWS-REGION>.amazonaws.com
POLICY_NAME=xxxxxxxxx
GEOFENCE_COLLECTION_NAME=xxxxxxxxxxxxxxxxx
TOPIC_TRACKER=xxxxxxxxxx
Expand Down Expand Up @@ -52,7 +52,7 @@ These filters help in optimizing the location tracking to suit different use cas

```properties
DEFAULT_TRACKER_NAME=xxxxxxx
TEST_POOL_ID=us-east-1:xxxxxxxxxxxxxxxxxxxxxxxxxx
TEST_POOL_ID=<MY-AWS-REGION>:xxxxxxxxxxxxxxxxxxxxxxxxxx
TEST_MAP_NAME=xxxxxxxxxxxxxxxxxxx
```

Expand Down
2 changes: 1 addition & 1 deletion tracking-with-geofence-notifications/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
minSdk = 21
targetSdk = 34
versionCode = 1
versionName = "1.0"
versionName = "1.0.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down

0 comments on commit 2807e81

Please sign in to comment.