diff --git a/quick-start/README.md b/quick-start/README.md index 3143956..82a6354 100644 Binary files a/quick-start/README.md and b/quick-start/README.md differ diff --git a/quick-start/app/build.gradle.kts b/quick-start/app/build.gradle.kts index 1c7a556..7363096 100644 --- a/quick-start/app/build.gradle.kts +++ b/quick-start/app/build.gradle.kts @@ -17,11 +17,11 @@ android { versionCode = 1 versionName = "1.0.0" + buildConfigField("String", "API_KEY_REGION", "\"${customConfig.getProperty("API_KEY_REGION")}\"") + buildConfigField("String", "API_KEY", "\"${customConfig.getProperty("API_KEY")}\"") buildConfigField("String", "IDENTITY_POOL_ID", "\"${customConfig.getProperty("IDENTITY_POOL_ID")}\"") buildConfigField("String", "TRACKER_NAME", "\"${customConfig.getProperty("TRACKER_NAME")}\"") - buildConfigField("String", "REGION", "\"${customConfig.getProperty("REGION")}\"") - buildConfigField("String", "PLACE_INDEX", "\"${customConfig.getProperty("PLACE_INDEX")}\"") - buildConfigField("String", "MAP_NAME", "\"${customConfig.getProperty("MAP_NAME")}\"") + buildConfigField("String", "MAP_STYLE", "\"${customConfig.getProperty("MAP_STYLE")}\"") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true @@ -49,7 +49,7 @@ android { buildConfig = true } composeOptions { - kotlinCompilerExtensionVersion = "1.5.1" + kotlinCompilerExtensionVersion = "1.5.7" } packaging { resources { @@ -74,9 +74,9 @@ dependencies { implementation(libs.androidx.material3) implementation(libs.org.maplibre.gl) implementation(libs.com.squareup.okhttp3) - implementation(libs.location) implementation(libs.auth) implementation(libs.tracking) + implementation(libs.geoplaces) testImplementation(libs.mockk) testImplementation(libs.mockito.core) androidTestImplementation(libs.androidx.uiautomator) diff --git a/quick-start/app/src/main/java/com/amazon/androidquickstartapp/MainActivity.kt b/quick-start/app/src/main/java/com/amazon/androidquickstartapp/MainActivity.kt index 6b6de5b..5af1753 100644 --- a/quick-start/app/src/main/java/com/amazon/androidquickstartapp/MainActivity.kt +++ b/quick-start/app/src/main/java/com/amazon/androidquickstartapp/MainActivity.kt @@ -21,7 +21,6 @@ import com.amazon.androidquickstartapp.ui.theme.AndroidQuickStartAppTheme import com.amazon.androidquickstartapp.ui.view.MapLoadScreen import com.amazon.androidquickstartapp.ui.viewModel.MainViewModel import com.amazon.androidquickstartapp.utils.Constants.REVERSE_GEO_THRESH_HOLD -import com.amazon.androidquickstartapp.utils.Constants.SERVICE_NAME import com.amazon.androidquickstartapp.utils.Constants.TRACKER_LINE_LAYER import com.amazon.androidquickstartapp.utils.Constants.TRACKER_LINE_SOURCE import com.amazon.androidquickstartapp.utils.Constants.TRACKING_FREQUENCY_MILLIS @@ -31,17 +30,13 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch -import okhttp3.OkHttpClient import org.maplibre.android.MapLibre import org.maplibre.android.camera.CameraPosition import org.maplibre.android.geometry.LatLng import org.maplibre.android.maps.MapLibreMap import org.maplibre.android.maps.OnMapReadyCallback import org.maplibre.android.maps.Style -import org.maplibre.android.module.http.HttpRequestUtil import org.maplibre.geojson.Point -import software.amazon.location.auth.AuthHelper -import software.amazon.location.auth.AwsSignerInterceptor import software.amazon.location.tracking.aws.LocationTrackingCallback import software.amazon.location.tracking.config.LocationTrackerConfig import software.amazon.location.tracking.database.LocationEntry @@ -52,7 +47,6 @@ import software.amazon.location.tracking.util.TrackingSdkLogLevel class MainActivity : ComponentActivity(), OnMapReadyCallback, MapLibreMap.OnCameraIdleListener, MapLibreMap.OnCameraMoveStartedListener { - private lateinit var authHelper: AuthHelper private val mainViewModel: MainViewModel by viewModels() private val coroutineScope = MainScope() private var isRequestingForTracking = false @@ -249,21 +243,9 @@ class MainActivity : ComponentActivity(), OnMapReadyCallback, MapLibreMap.OnCame private fun signInUser() { coroutineScope.launch { if (mainViewModel.checkValidations(this@MainActivity)) return@launch - authHelper = AuthHelper(applicationContext) - mainViewModel.initializeLocationCredentialsProvider(authHelper) + mainViewModel.initializeLocationCredentialsProvider(applicationContext) mainViewModel.authenticated = true - mainViewModel.locationCredentialsProvider?.let { - HttpRequestUtil.setOkHttpClient( - OkHttpClient.Builder() - .addInterceptor( - AwsSignerInterceptor( - SERVICE_NAME, - mainViewModel.region, - it - ) - ) - .build() - ) + mainViewModel.trackerCredentialsProvider?.let { val config = LocationTrackerConfig( trackerName = mainViewModel.trackerName, logLevel = TrackingSdkLogLevel.DEBUG, @@ -280,12 +262,7 @@ class MainActivity : ComponentActivity(), OnMapReadyCallback, MapLibreMap.OnCame override fun onMapReady(map: MapLibreMap) { mainViewModel.mapLibreMap = map - map.setStyle( - Style.Builder() - .fromUri( - "https://maps.geo.${mainViewModel.region}.amazonaws.com/maps/v0/maps/${mainViewModel.mapName}/style-descriptor" - ), - ) { + map.setStyle(Style.Builder().fromUri(getMapUrl())) { map.uiSettings.isAttributionEnabled = true map.uiSettings.isLogoEnabled = false map.uiSettings.attributionGravity = Gravity.BOTTOM or Gravity.END @@ -308,6 +285,9 @@ class MainActivity : ComponentActivity(), OnMapReadyCallback, MapLibreMap.OnCame } } + private fun getMapUrl() = + "https://maps.geo.${BuildConfig.API_KEY_REGION}.amazonaws.com/v2/styles/${mainViewModel.mapStyle}/descriptor?key=${BuildConfig.API_KEY}" + private fun getLabelFromPosition(latLng: LatLng) { CoroutineScope(Dispatchers.IO).launch { val label = mainViewModel.reverseGeocode( diff --git a/quick-start/app/src/main/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModel.kt b/quick-start/app/src/main/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModel.kt index 710f18d..ed2d7b2 100644 --- a/quick-start/app/src/main/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModel.kt +++ b/quick-start/app/src/main/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModel.kt @@ -13,9 +13,14 @@ import androidx.compose.runtime.setValue import androidx.core.app.ActivityCompat import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import aws.sdk.kotlin.services.location.model.LocationException +import aws.sdk.kotlin.runtime.auth.credentials.StaticCredentialsProvider +import aws.sdk.kotlin.services.geoplaces.GeoPlacesClient +import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials +import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider +import aws.smithy.kotlin.runtime.net.url.Url import com.amazon.androidquickstartapp.BuildConfig import com.amazon.androidquickstartapp.R +import com.amazon.androidquickstartapp.utils.AmazonPlacesClient import com.amazon.androidquickstartapp.utils.Constants import com.amazon.androidquickstartapp.utils.Helper import com.amazon.androidquickstartapp.utils.MapHelper @@ -26,7 +31,6 @@ import org.maplibre.android.location.LocationComponent import org.maplibre.android.location.OnLocationCameraTransitionListener import org.maplibre.android.location.modes.CameraMode import org.maplibre.android.maps.MapLibreMap -import com.amazon.androidquickstartapp.utils.AmazonLocationClient import kotlinx.coroutines.async import software.amazon.location.auth.AuthHelper import software.amazon.location.auth.LocationCredentialsProvider @@ -36,11 +40,12 @@ import software.amazon.location.tracking.config.LocationTrackerConfig class MainViewModel : ViewModel() { var locationTracker: LocationTracker? = null - var locationCredentialsProvider: LocationCredentialsProvider? = null + var trackerCredentialsProvider: LocationCredentialsProvider? = null + private var placesCredentialsProvider: LocationCredentialsProvider? = null var authenticated by mutableStateOf(false) - var mapName by mutableStateOf(BuildConfig.MAP_NAME) - var region by mutableStateOf(BuildConfig.REGION) - var indexName by mutableStateOf(BuildConfig.PLACE_INDEX) + var mapStyle by mutableStateOf(BuildConfig.MAP_STYLE) + var apiKeyRegion by mutableStateOf(BuildConfig.API_KEY_REGION) + var apiKey by mutableStateOf(BuildConfig.API_KEY) var identityPoolId by mutableStateOf(BuildConfig.IDENTITY_POOL_ID) var trackerName by mutableStateOf(BuildConfig.TRACKER_NAME) var label by mutableStateOf("") @@ -52,10 +57,15 @@ class MainViewModel : ViewModel() { var helper = Helper() var mapHelper = MapHelper() var layerSize: Int = 0 + var getPlaceClient: GeoPlacesClient ?= null + var amazonPlacesClient: AmazonPlacesClient ?= null - suspend fun initializeLocationCredentialsProvider(authHelper: AuthHelper) { - locationCredentialsProvider = viewModelScope.async { - authHelper.authenticateWithCognitoIdentityPool(identityPoolId) + suspend fun initializeLocationCredentialsProvider(context: Context) { + trackerCredentialsProvider = viewModelScope.async { + AuthHelper.withCognitoIdentityPool(identityPoolId, context) + }.await() + placesCredentialsProvider = viewModelScope.async { + AuthHelper.withApiKey(apiKey, apiKeyRegion, context) }.await() } @@ -71,23 +81,22 @@ class MainViewModel : ViewModel() { suspend fun reverseGeocode(latLng: LatLng): String? { try { - val amazonLocationClient = - locationCredentialsProvider?.getLocationClient()?.let { AmazonLocationClient(it) } - val response = amazonLocationClient?.reverseGeocode( - indexName, + if (getPlaceClient == null || amazonPlacesClient == null) { + placesCredentialsProvider?.let { + getPlaceClient = + GeoPlacesClient(it.getGeoPlacesClientConfig()) + amazonPlacesClient = AmazonPlacesClient(getPlaceClient) + } + } + val response = amazonPlacesClient?.reverseGeocode( latLng.longitude, latLng.latitude, mLanguage = "en", mMaxResults = 1 ) - return response?.results?.firstOrNull()?.place?.label + return response?.resultItems?.firstOrNull()?.title } catch (e: Exception) { - if (e is LocationException && e.message.contains("expired")) { - viewModelScope.launch { - locationCredentialsProvider?.refresh() - } - } e.printStackTrace() return "" } @@ -147,19 +156,20 @@ class MainViewModel : ViewModel() { ) return true } - if (mapName.isEmpty()) { - helper.showToast(context.getString(R.string.error_please_enter_map_name), context) + if (mapStyle.isEmpty()) { + helper.showToast(context.getString(R.string.error_please_enter_map_style), context) return true } - if (region.isEmpty()) { + if (apiKeyRegion.isEmpty()) { helper.showToast(context.getString(R.string.error_please_enter_region), context) return true } - if (indexName.isEmpty()) { - helper.showToast( - context.getString(R.string.error_please_enter_place_index), - context - ) + if (apiKey.isEmpty()) { + helper.showToast(context.getString(R.string.error_please_enter_api_key), context) + return true + } + if (trackerName.isEmpty()) { + helper.showToast(context.getString(R.string.error_please_enter_tracker_name), context) return true } return false diff --git a/quick-start/app/src/main/java/com/amazon/androidquickstartapp/utils/AmazonLocationClient.kt b/quick-start/app/src/main/java/com/amazon/androidquickstartapp/utils/AmazonPlacesClient.kt similarity index 50% rename from quick-start/app/src/main/java/com/amazon/androidquickstartapp/utils/AmazonLocationClient.kt rename to quick-start/app/src/main/java/com/amazon/androidquickstartapp/utils/AmazonPlacesClient.kt index eb6f7c4..dd96077 100644 --- a/quick-start/app/src/main/java/com/amazon/androidquickstartapp/utils/AmazonLocationClient.kt +++ b/quick-start/app/src/main/java/com/amazon/androidquickstartapp/utils/AmazonPlacesClient.kt @@ -1,23 +1,23 @@ package com.amazon.androidquickstartapp.utils -import aws.sdk.kotlin.services.location.LocationClient -import aws.sdk.kotlin.services.location.model.SearchPlaceIndexForPositionRequest -import aws.sdk.kotlin.services.location.model.SearchPlaceIndexForPositionResponse +import aws.sdk.kotlin.services.geoplaces.GeoPlacesClient +import aws.sdk.kotlin.services.geoplaces.model.ReverseGeocodeRequest +import aws.sdk.kotlin.services.geoplaces.model.ReverseGeocodeResponse +import com.amazon.androidquickstartapp.BuildConfig /** * Provides methods to interact with the Amazon Location service. * - * @property locationClient An instance of LocationClient used for making requests to the Amazon Location service. + * @property geoPlacesClient An instance of LocationClient used for making requests to the Amazon Location service. */ -class AmazonLocationClient( - private val locationClient: LocationClient +class AmazonPlacesClient( + private val geoPlacesClient: GeoPlacesClient? ) { /** * Reverse geocodes a location specified by longitude and latitude coordinates. * - * @param placeIndexName The name of the place index resource to use for the reverse geocoding request. * @param longitude The longitude of the location to reverse geocode. * @param latitude The latitude of the location to reverse geocode. * @param mLanguage The language to use for the reverse geocoding results. @@ -25,20 +25,19 @@ class AmazonLocationClient( * @return A response containing the reverse geocoding results. */ suspend fun reverseGeocode( - placeIndexName: String, longitude: Double, latitude: Double, mLanguage: String, mMaxResults: Int - ): SearchPlaceIndexForPositionResponse { - val request = SearchPlaceIndexForPositionRequest { - indexName = placeIndexName - position = listOf(longitude, latitude) + ): ReverseGeocodeResponse? { + val request = ReverseGeocodeRequest { maxResults = mMaxResults language = mLanguage + key = BuildConfig.API_KEY + queryPosition = listOf(longitude, latitude) } - val response = locationClient.searchPlaceIndexForPosition(request) + val response = geoPlacesClient?.reverseGeocode(request) return response } } diff --git a/quick-start/app/src/main/res/values/strings.xml b/quick-start/app/src/main/res/values/strings.xml index 333caa4..c352567 100644 --- a/quick-start/app/src/main/res/values/strings.xml +++ b/quick-start/app/src/main/res/values/strings.xml @@ -6,9 +6,10 @@ Region Place index name Please enter identity pool id - Please enter map name - Please enter region - Please enter place index name + Please enter map style + Please enter API Key region + Please enter API Key + Please enter Tracker Name Permission Required Open Settings Cancel diff --git a/quick-start/app/src/test/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModelReverseGeocodeTest.kt b/quick-start/app/src/test/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModelReverseGeocodeTest.kt index 5d43e0e..1ffec1a 100644 --- a/quick-start/app/src/test/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModelReverseGeocodeTest.kt +++ b/quick-start/app/src/test/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModelReverseGeocodeTest.kt @@ -1,13 +1,14 @@ package com.amazon.androidquickstartapp.ui.viewModel import android.content.Context -import aws.sdk.kotlin.services.location.LocationClient -import aws.sdk.kotlin.services.location.model.Place -import aws.sdk.kotlin.services.location.model.SearchForPositionResult -import aws.sdk.kotlin.services.location.model.SearchPlaceIndexForPositionResponse +import aws.sdk.kotlin.services.geoplaces.GeoPlacesClient +import aws.sdk.kotlin.services.geoplaces.model.Address +import aws.sdk.kotlin.services.geoplaces.model.PlaceType +import aws.sdk.kotlin.services.geoplaces.model.ReverseGeocodeResponse +import aws.sdk.kotlin.services.geoplaces.model.ReverseGeocodeResultItem +import com.amazon.androidquickstartapp.utils.AmazonPlacesClient import com.amazon.androidquickstartapp.utils.Constants.EXPECTED_LABEL import io.mockk.coEvery - import io.mockk.mockk import io.mockk.mockkConstructor import junit.framework.TestCase.assertEquals @@ -16,7 +17,6 @@ import org.junit.Before import org.junit.Test import org.maplibre.android.geometry.LatLng import org.mockito.Mock -import com.amazon.androidquickstartapp.utils.AmazonLocationClient import software.amazon.location.auth.LocationCredentialsProvider @@ -25,7 +25,7 @@ class MainViewModelReverseGeocodeTest { private lateinit var viewModel: MainViewModel @Mock - private lateinit var locationCredentialsProvider: LocationCredentialsProvider + private lateinit var geoPlacesClient: GeoPlacesClient @Mock lateinit var context: Context @@ -33,30 +33,30 @@ class MainViewModelReverseGeocodeTest { @Before fun setUp() { context = mockk(relaxed = true) - locationCredentialsProvider = mockk() + geoPlacesClient = mockk() viewModel = MainViewModel() mockkConstructor(LocationCredentialsProvider::class) - mockkConstructor(AmazonLocationClient::class) + mockkConstructor(AmazonPlacesClient::class) } @Test fun `test reverseGeocode`() { - val mockAmazonLocationClient = mockk() - coEvery { - locationCredentialsProvider.getLocationClient() - } returns mockAmazonLocationClient - val searchPlaceIndexForPositionResponse = SearchPlaceIndexForPositionResponse.invoke { - results = listOf(SearchForPositionResult.invoke { - distance = 20.0 + val mockAmazonLocationClient = mockk() + viewModel.getPlaceClient = geoPlacesClient + viewModel.amazonPlacesClient = mockAmazonLocationClient + val reverseGeocodeResponse = ReverseGeocodeResponse { + resultItems = listOf(ReverseGeocodeResultItem { + distance = 20L placeId = "11" - place = Place.invoke { + title = "test" + placeType = PlaceType.Block + address = Address { label = EXPECTED_LABEL } }) - summary = null + pricingBucket = "test" } - viewModel.locationCredentialsProvider = locationCredentialsProvider - coEvery { mockAmazonLocationClient.searchPlaceIndexForPosition(any()) } returns searchPlaceIndexForPositionResponse + coEvery { mockAmazonLocationClient.reverseGeocode(any(), any(), any(), any()) } returns reverseGeocodeResponse val latLng = LatLng(37.7749, -122.4194) runBlocking { diff --git a/quick-start/app/src/test/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModelValidationTest.kt b/quick-start/app/src/test/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModelValidationTest.kt index 619632a..0f1aeab 100644 --- a/quick-start/app/src/test/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModelValidationTest.kt +++ b/quick-start/app/src/test/java/com/amazon/androidquickstartapp/ui/viewModel/MainViewModelValidationTest.kt @@ -2,9 +2,10 @@ package com.amazon.androidquickstartapp.ui.viewModel import android.content.Context import com.amazon.androidquickstartapp.utils.Constants.IDENTITY_POOL_ID -import com.amazon.androidquickstartapp.utils.Constants.INDEX_NAME -import com.amazon.androidquickstartapp.utils.Constants.MAP_NAME -import com.amazon.androidquickstartapp.utils.Constants.REGION +import com.amazon.androidquickstartapp.utils.Constants.MAP_STYLE +import com.amazon.androidquickstartapp.utils.Constants.API_KEY_REGION +import com.amazon.androidquickstartapp.utils.Constants.API_KEY +import com.amazon.androidquickstartapp.utils.Constants.TRACKER_NAME import com.amazon.androidquickstartapp.utils.Helper import io.mockk.every import io.mockk.just @@ -38,20 +39,22 @@ class MainViewModelValidationTest { fun `test checkValidations when all fields are empty`() { every { mockHelper.showToast(any(), any()) } just runs viewModel.identityPoolId = "" - viewModel.mapName = "" - viewModel.region = "" - viewModel.indexName = "" + viewModel.mapStyle = "" + viewModel.apiKey = "" + viewModel.apiKeyRegion = "" + viewModel.trackerName = "" assertEquals(true, viewModel.checkValidations(context)) } @Test - fun `test checkValidations when mapName is empty`() { + fun `test checkValidations when mapStyle is empty`() { every { mockHelper.showToast(any(), any()) } just runs viewModel.identityPoolId = IDENTITY_POOL_ID - viewModel.mapName = "" - viewModel.region = REGION - viewModel.indexName = INDEX_NAME + viewModel.mapStyle = "" + viewModel.apiKeyRegion = API_KEY_REGION + viewModel.apiKey = API_KEY + viewModel.trackerName = TRACKER_NAME assertEquals(true, viewModel.checkValidations(context)) } @@ -59,9 +62,10 @@ class MainViewModelValidationTest { @Test fun `test checkValidations when all fields are not empty`() { viewModel.identityPoolId = IDENTITY_POOL_ID - viewModel.mapName = MAP_NAME - viewModel.region = REGION - viewModel.indexName = INDEX_NAME + viewModel.mapStyle = MAP_STYLE + viewModel.apiKeyRegion = API_KEY_REGION + viewModel.apiKey = API_KEY + viewModel.trackerName = TRACKER_NAME assertEquals(false, viewModel.checkValidations(context)) } diff --git a/quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/AmazonLocationClientTest.kt b/quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/AmazonPlacesClientTest.kt similarity index 83% rename from quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/AmazonLocationClientTest.kt rename to quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/AmazonPlacesClientTest.kt index ccd31a2..ee0534c 100644 --- a/quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/AmazonLocationClientTest.kt +++ b/quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/AmazonPlacesClientTest.kt @@ -2,7 +2,7 @@ package com.amazon.androidquickstartapp.utils import android.content.Context -import aws.sdk.kotlin.services.location.LocationClient +import aws.sdk.kotlin.services.geoplaces.GeoPlacesClient import io.mockk.every import io.mockk.just import io.mockk.mockk @@ -17,11 +17,11 @@ import org.junit.Test import software.amazon.location.auth.EncryptedSharedPreferences import software.amazon.location.auth.utils.Constants -class AmazonLocationClientTest { +class AmazonPlacesClientTest { private lateinit var context: Context - private lateinit var mockLocationClient: LocationClient - private lateinit var amazonLocationClient: AmazonLocationClient + private lateinit var mockLocationClient: GeoPlacesClient + private lateinit var amazonLocationClient: AmazonPlacesClient private val coroutineScope = CoroutineScope(Dispatchers.IO) @Before fun setUp() { @@ -43,9 +43,9 @@ class AmazonLocationClientTest { every { anyConstructed().get(Constants.SECRET_KEY) } returns "test" every { anyConstructed().get(Constants.SESSION_TOKEN) } returns "test" every { anyConstructed().get(Constants.EXPIRATION) } returns "11111" - amazonLocationClient = AmazonLocationClient(mockLocationClient) + amazonLocationClient = AmazonPlacesClient(mockLocationClient) coroutineScope.launch { - amazonLocationClient.reverseGeocode("indexName", 0.0, 0.0, "en", 10) + amazonLocationClient.reverseGeocode(23.151, 27.262, "en", 10) assertNotNull(amazonLocationClient) } } diff --git a/quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/Constants.kt b/quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/Constants.kt index 6e0f8bb..a536b89 100644 --- a/quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/Constants.kt +++ b/quick-start/app/src/test/java/com/amazon/androidquickstartapp/utils/Constants.kt @@ -2,8 +2,9 @@ package com.amazon.androidquickstartapp.utils object Constants { const val EXPECTED_LABEL = "test" - const val IDENTITY_POOL_ID = "dummyPoolId" - const val REGION = "dummyRegion" - const val MAP_NAME = "dummyMapName" - const val INDEX_NAME = "dummyIndexName" + const val IDENTITY_POOL_ID = "testPoolId" + const val API_KEY_REGION = "testRegion" + const val API_KEY = "testApiKey" + const val MAP_STYLE = "testMapStyle" + const val TRACKER_NAME = "testTrackerName" } \ No newline at end of file diff --git a/quick-start/gradle/libs.versions.toml b/quick-start/gradle/libs.versions.toml index 6fc5ded..d8d0952 100644 --- a/quick-start/gradle/libs.versions.toml +++ b/quick-start/gradle/libs.versions.toml @@ -1,26 +1,27 @@ [versions] -agp = "8.3.0" -kotlin = "1.9.0" -coreKtx = "1.12.0" +agp = "8.3.2" +geoplaces = "1.3.65" +kotlin = "1.9.21" +coreKtx = "1.13.1" junit = "4.13.2" -junitVersion = "1.1.5" -espressoCore = "3.5.1" -lifecycleRuntimeKtx = "2.7.0" -activityCompose = "1.8.2" -composeBom = "2023.08.00" -location = "1.2.21" -maplibre = "11.0.0-pre5" -mockitoCore = "4.7.0" -mockk = "1.13.10" -okhttp = "4.9.2" -playServicesLocation = "21.2.0" -auth = "0.2.5" -tracking = "0.2.5" +junitVersion = "1.2.1" +espressoCore = "3.6.1" +lifecycleRuntimeKtx = "2.8.7" +activityCompose = "1.9.3" +composeBom = "2024.10.01" +maplibre = "11.5.2" +mockitoCore = "5.14.2" +mockk = "1.13.13" +okhttp = "4.12.0" +playServicesLocation = "21.3.0" +auth = "1.1.0" +tracking = "1.0.0" uiautomator = "2.3.0" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } androidx-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "uiautomator" } +geoplaces = { module = "aws.sdk.kotlin:geoplaces", version.ref = "geoplaces" } junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } @@ -34,7 +35,6 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } androidx-material3 = { group = "androidx.compose.material3", name = "material3" } -location = { module = "aws.sdk.kotlin:location", version.ref = "location" } mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockitoCore" } mockk = { module = "io.mockk:mockk", version.ref = "mockk" } org-maplibre-gl = { group = "org.maplibre.gl", name = "android-sdk", version.ref = "maplibre" } diff --git a/quick-start/gradlew b/quick-start/gradlew old mode 100644 new mode 100755 diff --git a/quick-start/settings.gradle.kts b/quick-start/settings.gradle.kts index 40f98fe..7a4047c 100644 --- a/quick-start/settings.gradle.kts +++ b/quick-start/settings.gradle.kts @@ -21,4 +21,3 @@ dependencyResolutionManagement { rootProject.name = "AndroidQuickStartApp" include(":app") - \ No newline at end of file diff --git a/tracking-with-geofence-notifications/README.MD b/tracking-with-geofence-notifications/README.MD index 45194a6..954c506 100644 --- a/tracking-with-geofence-notifications/README.MD +++ b/tracking-with-geofence-notifications/README.MD @@ -53,12 +53,16 @@ These filters help in optimizing the location tracking to suit different use cas ```properties DEFAULT_TRACKER_NAME=xxxxxxx TEST_POOL_ID=:xxxxxxxxxxxxxxxxxxxxxxxxxx - TEST_MAP_NAME=xxxxxxxxxxxxxxxxxxx + TEST_MAP_STYLE=xxxxxxxxxxxxxxxxxxx + TEST_API_KEY=xx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + TEST_API_KEY_REGION= ``` - **DEFAULT_TRACKER_NAME**: The name of the tracker resource in Amazon Location Service used for tracking location updates. - **TEST_POOL_ID**: Your AWS Cognito Identity Pool ID used for authenticating users. - - **TEST_MAP_NAME**: The name of the map resource in the Amazon Location Service you want to use to display the map. + - **TEST_MAP_STYLE**: The style name of the map resource in the Amazon Location Service you want to use to display the map. + - **TEST_API_KEY**: Your api key used for authenticating users to access maps, routes and places. + - **TEST_API_KEY_REGION**: Your api key AWS region. 2. Create and run the emulator of the latest Android version or plug in the real Android device. 3. Now open the `DefaultFlowSuite` file located inside the `androidTest` directory and click on the play button. diff --git a/tracking-with-geofence-notifications/app/build.gradle.kts b/tracking-with-geofence-notifications/app/build.gradle.kts index d5a7d28..3340182 100644 --- a/tracking-with-geofence-notifications/app/build.gradle.kts +++ b/tracking-with-geofence-notifications/app/build.gradle.kts @@ -27,7 +27,9 @@ android { buildConfigField("String", "TOPIC_TRACKER", "\"${customConfig.getProperty("TOPIC_TRACKER")}\"") buildConfigField("String", "DEFAULT_TRACKER_NAME", "\"${customConfig.getProperty("DEFAULT_TRACKER_NAME")}\"") buildConfigField("String", "TEST_POOL_ID", "\"${customConfig.getProperty("TEST_POOL_ID")}\"") - buildConfigField("String", "TEST_MAP_NAME", "\"${customConfig.getProperty("TEST_MAP_NAME")}\"") + buildConfigField("String", "TEST_MAP_STYLE", "\"${customConfig.getProperty("TEST_MAP_STYLE")}\"") + buildConfigField("String", "TEST_API_KEY_REGION", "\"${customConfig.getProperty("TEST_API_KEY_REGION")}\"") + buildConfigField("String", "TEST_API_KEY", "\"${customConfig.getProperty("TEST_API_KEY")}\"") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -52,7 +54,7 @@ android { buildConfig = true } composeOptions { - kotlinCompilerExtensionVersion = "1.5.1" + kotlinCompilerExtensionVersion = "1.5.7" } packaging { resources { @@ -63,39 +65,31 @@ android { dependencies { - implementation("androidx.core:core-ktx:1.12.0") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") - implementation("androidx.activity:activity-compose:1.8.2") - implementation(platform("androidx.compose:compose-bom:2023.08.00")) + implementation("androidx.core:core-ktx:1.13.1") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7") + implementation("androidx.activity:activity-compose:1.9.3") + implementation(platform("androidx.compose:compose-bom:2024.10.01")) implementation("androidx.compose.ui:ui") implementation("androidx.compose.ui:ui-graphics") implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.compose.material3:material3") implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1") - implementation("com.google.android.gms:play-services-location:21.1.0") - implementation("org.maplibre.gl:android-sdk:11.0.0-pre5") + implementation("com.google.android.gms:play-services-location:21.3.0") + implementation("org.maplibre.gl:android-sdk:11.5.2") implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("aws.sdk.kotlin:cognitoidentity:1.2.21") + implementation("aws.sdk.kotlin:cognitoidentity:1.3.65") implementation("com.amazonaws:aws-iot-device-sdk-java:1.3.9") - implementation("aws.sdk.kotlin:iot:1.2.28") - implementation("aws.sdk.kotlin:location:1.2.21") - androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.6.5") - debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.5") + implementation("aws.sdk.kotlin:iot:1.3.29") + implementation("aws.sdk.kotlin:location:1.3.65") + androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.5") + debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.5") androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0") - if (findProject(":authSdk") != null) { - implementation(project(mapOf("path" to ":authSdk"))) - } else { - implementation("software.amazon.location:auth:0.2.4") - } - if (findProject(":trackingSdk") != null) { - implementation(project(mapOf("path" to ":trackingSdk"))) - } else { - implementation("software.amazon.location:tracking:0.2.4") - } + implementation("software.amazon.location:auth:1.1.0") + implementation("software.amazon.location:tracking:1.0.0") testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.5") - androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") - androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00")) + androidTestImplementation("androidx.test.ext:junit:1.2.1") + androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") + androidTestImplementation(platform("androidx.compose:compose-bom:2024.10.01")) androidTestImplementation("androidx.compose.ui:ui-test-junit4") debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") diff --git a/tracking-with-geofence-notifications/app/src/androidTest/java/software/amazon/location/sample/util/ConstantTest.kt b/tracking-with-geofence-notifications/app/src/androidTest/java/software/amazon/location/sample/util/ConstantTest.kt index 53d4d98..a541737 100644 --- a/tracking-with-geofence-notifications/app/src/androidTest/java/software/amazon/location/sample/util/ConstantTest.kt +++ b/tracking-with-geofence-notifications/app/src/androidTest/java/software/amazon/location/sample/util/ConstantTest.kt @@ -13,8 +13,10 @@ const val ALLOW = "Allow" const val ALLOW_CAPS = "ALLOW" const val SIGN_IN = "Sign In" const val IDENTITY_POOL_ID = "Identity Pool ID" +const val API_KEY = "API key" +const val API_KEY_REGION = "API key Region" const val TRACKER_NAME = "Tracker name" -const val MAP_NAME = "Map name" +const val MAP_STYLE = "Map style" const val BTN_SIGN_IN = "btn_sign_in" const val SWITCH_TIME_FILTER = "switch_time_filter" const val TEXT_TIME_FILTER = "text_time_filter" diff --git a/tracking-with-geofence-notifications/app/src/androidTest/java/software/amazon/location/sample/util/Utils.kt b/tracking-with-geofence-notifications/app/src/androidTest/java/software/amazon/location/sample/util/Utils.kt index c27a0a2..b002b55 100644 --- a/tracking-with-geofence-notifications/app/src/androidTest/java/software/amazon/location/sample/util/Utils.kt +++ b/tracking-with-geofence-notifications/app/src/androidTest/java/software/amazon/location/sample/util/Utils.kt @@ -21,12 +21,18 @@ fun signIn(composeTestRule: AndroidComposeTestRuleConfig section Log in to access configuration settings Please enter identity pool id + Please enter api key + Please enter region for api key Time filter Distance filter Accuracy filter meter second Tracker name - Map name + API key Region + API key + Map style Please enter tracker name - Please enter map name + Please enter map style \ No newline at end of file diff --git a/tracking-with-geofence-notifications/build.gradle.kts b/tracking-with-geofence-notifications/build.gradle.kts index cfba85f..80fa765 100644 --- a/tracking-with-geofence-notifications/build.gradle.kts +++ b/tracking-with-geofence-notifications/build.gradle.kts @@ -1,5 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.2.2" apply false - id("org.jetbrains.kotlin.android") version "1.9.0" apply false + id("com.android.application") version "8.3.2" apply false + id("org.jetbrains.kotlin.android") version "1.9.21" apply false } \ No newline at end of file diff --git a/tracking-with-geofence-notifications/gradle/wrapper/gradle-wrapper.properties b/tracking-with-geofence-notifications/gradle/wrapper/gradle-wrapper.properties index e065248..97c2ff2 100644 --- a/tracking-with-geofence-notifications/gradle/wrapper/gradle-wrapper.properties +++ b/tracking-with-geofence-notifications/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Jan 29 17:17:35 MSK 2024 +#Thu Oct 31 18:35:14 CDT 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/tracking-with-geofence-notifications/settings.gradle.kts b/tracking-with-geofence-notifications/settings.gradle.kts index ede0e04..5dbaa9a 100644 --- a/tracking-with-geofence-notifications/settings.gradle.kts +++ b/tracking-with-geofence-notifications/settings.gradle.kts @@ -14,8 +14,4 @@ dependencyResolutionManagement { } rootProject.name = "Amazon Location Sample App" -include(":app") -include(":trackingSdk") -project(":trackingSdk").projectDir = file("./trackingSdk/library") -include(":authSdk") -project(":authSdk").projectDir = file("./authSdk/library") \ No newline at end of file +include(":app") \ No newline at end of file diff --git a/tracking-with-geofence-notifications/template.properties b/tracking-with-geofence-notifications/template.properties index c237122..05a11d7 100644 --- a/tracking-with-geofence-notifications/template.properties +++ b/tracking-with-geofence-notifications/template.properties @@ -4,4 +4,6 @@ GEOFENCE_COLLECTION_NAME= TOPIC_TRACKER= DEFAULT_TRACKER_NAME= TEST_POOL_ID= -TEST_MAP_NAME= \ No newline at end of file +TEST_MAP_STYLE= +TEST_API_KEY= +TEST_API_KEY_REGION= \ No newline at end of file