diff --git a/README.md b/README.md index 2894b1d3d..7955ada15 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Overview -ArcGIS Maps SDK for Kotlin v200.3.0 samples. The `main` branch of this repository contains sample app modules for the latest available version of the [ArcGIS Maps SDK Android Kotlin](https://developers.arcgis.com/kotlin/). Samples released under older versions can be found through the [git tags](https://github.com/Esri/arcgis-maps-sdk-kotlin-samples/tags). Please read our [wiki](https://github.com/Esri/arcgis-maps-sdk-kotlin-samples/wiki) for help with working with this repository. +ArcGIS Maps SDK for Kotlin v200.4.0 samples. The `main` branch of this repository contains sample app modules for the latest available version of the [ArcGIS Maps SDK Android Kotlin](https://developers.arcgis.com/kotlin/). Samples released under older versions can be found through the [git tags](https://github.com/Esri/arcgis-maps-sdk-kotlin-samples/tags). Please read our [wiki](https://github.com/Esri/arcgis-maps-sdk-kotlin-samples/wiki) for help with working with this repository. ## Prerequisites diff --git a/add-dynamic-entity-layer/README.md b/add-dynamic-entity-layer/README.md index d2ae6259a..8cbfdc7f6 100644 --- a/add-dynamic-entity-layer/README.md +++ b/add-dynamic-entity-layer/README.md @@ -38,8 +38,9 @@ This sample uses a [stream service](https://realtimegis2016.esri.com:6443/arcgis ## Additional information +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. More information about dynamic entities can be found in the [guide documentation](https://developers.arcgis.com/kotlin/real-time/work-with-dynamic-entities/). ## Tags -data, dynamic, entity, live, purge, real-time, service, stream, track +data, dynamic, entity, geoviewcompose, live, purge, real-time, service, stream, toolkit, track diff --git a/add-dynamic-entity-layer/README.metadata.json b/add-dynamic-entity-layer/README.metadata.json index fc7c41a10..286a0a468 100644 --- a/add-dynamic-entity-layer/README.metadata.json +++ b/add-dynamic-entity-layer/README.metadata.json @@ -10,11 +10,13 @@ "data", "dynamic", "entity", + "geoviewcompose", "live", "purge", "real-time", "service", "stream", + "toolkit", "track", "ArcGISStreamService", "DynamicEntity", @@ -36,7 +38,6 @@ "snippets": [ "src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/MainActivity.kt", "src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/BottomSheetContent.kt", - "src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/ComposeMapView.kt", "src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/MapViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/screens/MainScreen.kt" ], diff --git a/add-dynamic-entity-layer/build.gradle b/add-dynamic-entity-layer/build.gradle deleted file mode 100644 index 254bf5853..000000000 --- a/add-dynamic-entity-layer/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.adddynamicentitylayer" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.adddynamicentitylayer' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/add-dynamic-entity-layer/build.gradle.kts b/add-dynamic-entity-layer/build.gradle.kts new file mode 100644 index 000000000..edcdafaf3 --- /dev/null +++ b/add-dynamic-entity-layer/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.adddynamicentitylayer" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.adddynamicentitylayer" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/add-dynamic-entity-layer/proguard-rules.pro b/add-dynamic-entity-layer/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/add-dynamic-entity-layer/proguard-rules.pro +++ b/add-dynamic-entity-layer/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/MainActivity.kt b/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/MainActivity.kt index b8444a445..602ca410f 100644 --- a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/MainActivity.kt +++ b/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/MainActivity.kt @@ -47,8 +47,7 @@ class MainActivity : ComponentActivity() { color = MaterialTheme.colorScheme.background ) { MainScreen( - sampleName = getString(R.string.app_name), - application = application + sampleName = getString(R.string.app_name) ) } } diff --git a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/BottomSheetContent.kt b/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/BottomSheetContent.kt index b5c32ac01..d61bcbf47 100644 --- a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/BottomSheetContent.kt +++ b/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/BottomSheetContent.kt @@ -106,7 +106,6 @@ fun DynamicEntityLayerProperties( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween ) { - Text( text = "Previous Observations", style = SampleTypography.bodyLarge diff --git a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/ComposeMapView.kt b/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/ComposeMapView.kt deleted file mode 100644 index 73efcabbd..000000000 --- a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/ComposeMapView.kt +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.adddynamicentitylayer.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.MapView -import kotlinx.coroutines.launch - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun ComposeMapView( - modifier: Modifier = Modifier, - mapViewModel: MapViewModel -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // collect the latest state of the MapViewState - val mapViewState by mapViewModel.mapViewState.collectAsState() - // create and add MapView to the activity lifecycle - val mapView = createMapViewInstance(lifecycleOwner) - - // wrap the MapView as an AndroidView - AndroidView( - modifier = modifier, - factory = { mapView }, - // recomposes the MapView on changes in the MapViewState - update = { mapView -> - mapView.apply { - map = mapViewState.arcGISMap - setViewpoint(mapViewState.viewpoint) - } - } - ) - - // launch coroutine functions in the composition's CoroutineContext - LaunchedEffect(Unit) { - launch { - mapView.onSingleTapConfirmed.collect { - mapViewModel.dismissBottomSheet() - } - } - launch { - mapView.onPan.collect{ - mapViewModel.dismissBottomSheet() - } - } - } -} - -/** - * Create the MapView instance and add it to the Activity lifecycle - */ -@Composable -fun createMapViewInstance(lifecycleOwner: LifecycleOwner): MapView { - // create the MapView - val mapView = MapView(LocalContext.current) - // add the side effects for MapView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(mapView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(mapView) - } - } - return mapView -} diff --git a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/MapViewModel.kt b/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/MapViewModel.kt index f26268939..db73dbdac 100644 --- a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/MapViewModel.kt +++ b/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/MapViewModel.kt @@ -17,6 +17,7 @@ package com.esri.arcgismaps.sample.adddynamicentitylayer.components import android.app.Application +import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.AndroidViewModel import com.arcgismaps.mapping.ArcGISMap @@ -27,7 +28,6 @@ import com.arcgismaps.realtime.ArcGISStreamService import com.arcgismaps.realtime.ArcGISStreamServiceFilter import com.esri.arcgismaps.sample.adddynamicentitylayer.R import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch class MapViewModel( @@ -38,14 +38,11 @@ class MapViewModel( // set the state of the switches and slider val trackLineCheckedState = mutableStateOf(false) val prevObservationCheckedState = mutableStateOf(false) - val trackSliderValue = mutableStateOf(5f) + val trackSliderValue = mutableFloatStateOf(5f) // flag to show or dismiss the bottom sheet val isBottomSheetVisible = mutableStateOf(false) - // set the MapView mutable stateflow - val mapViewState = MutableStateFlow(MapViewState()) - // create ArcGIS Stream Service private val streamService = ArcGISStreamService(application.getString(R.string.stream_service_url)) @@ -56,6 +53,11 @@ class MapViewModel( // layer displaying the dynamic entities on the map private val dynamicEntityLayer: DynamicEntityLayer + // define ArcGIS map using Streets basemap + val map = ArcGISMap(BasemapStyle.ArcGISStreets).apply { + initialViewpoint = Viewpoint(40.559691, -111.869001, 150000.0) + } + /** * set the data source for the dynamic entity layer. */ @@ -70,7 +72,7 @@ class MapViewModel( dynamicEntityLayer = DynamicEntityLayer(streamService) // add the dynamic entity layer to the map's operational layers - mapViewState.value.arcGISMap.operationalLayers.add(dynamicEntityLayer) + map.operationalLayers.add(dynamicEntityLayer) } // disconnects the stream service @@ -112,9 +114,9 @@ class MapViewModel( // to set the maximum number of observations displayed per track fun setObservations(sliderValue: Float) { - trackSliderValue.value = sliderValue + trackSliderValue.floatValue = sliderValue dynamicEntityLayer.trackDisplayProperties.maximumObservations = - trackSliderValue.value.toInt() + trackSliderValue.floatValue.toInt() } // remove all dynamic entity observations from the in-memory data cache as well as from the map @@ -125,10 +127,3 @@ class MapViewModel( } } -/** - * Data class that represents the MapView state - */ -data class MapViewState( - var arcGISMap: ArcGISMap = ArcGISMap(BasemapStyle.ArcGISStreets), - var viewpoint: Viewpoint = Viewpoint(40.559691, -111.869001, 150000.0) -) diff --git a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/screens/MainScreen.kt b/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/screens/MainScreen.kt index 307933ae3..c16009c41 100644 --- a/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/screens/MainScreen.kt +++ b/add-dynamic-entity-layer/src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/screens/MainScreen.kt @@ -34,8 +34,9 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp -import com.esri.arcgismaps.sample.adddynamicentitylayer.components.ComposeMapView +import com.arcgismaps.toolkit.geoviewcompose.MapView import com.esri.arcgismaps.sample.adddynamicentitylayer.components.DynamicEntityLayerProperties import com.esri.arcgismaps.sample.adddynamicentitylayer.components.MapViewModel import com.esri.arcgismaps.sample.sampleslib.components.BottomSheet @@ -45,9 +46,11 @@ import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { /// coroutineScope that will be cancelled when this call leaves the composition val sampleCoroutineScope = rememberCoroutineScope() + // get the application context + val application = LocalContext.current.applicationContext as Application // create a ViewModel to handle MapView interactions val mapViewModel = remember { MapViewModel(application, sampleCoroutineScope) } @@ -64,11 +67,13 @@ fun MainScreen(sampleName: String, application: Application) { .padding(it) ) { // composable function that wraps the MapView - ComposeMapView( + MapView( modifier = Modifier .fillMaxSize() .weight(1f), - mapViewModel = mapViewModel + arcGISMap = mapViewModel.map, + onSingleTapConfirmed = { mapViewModel.dismissBottomSheet() }, + onPan = { mapViewModel.dismissBottomSheet() } ) Row( modifier = Modifier @@ -103,7 +108,7 @@ fun MainScreen(sampleName: String, application: Application) { onPurgeAllObservations = mapViewModel::purgeAllObservations, isTrackLineVisible = mapViewModel.trackLineCheckedState.value, isPrevObservationsVisible = mapViewModel.prevObservationCheckedState.value, - observationsPerTrack = mapViewModel.trackSliderValue.value, + observationsPerTrack = mapViewModel.trackSliderValue.floatValue, onDismiss = { mapViewModel.dismissBottomSheet() } ) } diff --git a/add-feature-layers/build.gradle b/add-feature-layers/build.gradle deleted file mode 100644 index 3314c4361..000000000 --- a/add-feature-layers/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.addfeaturelayers" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.addfeaturelayers' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation "androidx.appcompat:appcompat:$appcompatVersion" - implementation project(path: ':samples-lib') -} diff --git a/add-feature-layers/build.gradle.kts b/add-feature-layers/build.gradle.kts new file mode 100644 index 000000000..c2b5c393c --- /dev/null +++ b/add-feature-layers/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.addfeaturelayers" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.addfeaturelayers" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.androidx.appcompat) + implementation(project(":samples-lib")) +} diff --git a/add-feature-layers/proguard-rules.pro b/add-feature-layers/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/add-feature-layers/proguard-rules.pro +++ b/add-feature-layers/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/add-feature-layers/src/main/java/com/esri/arcgismaps/sample/addfeaturelayers/MainActivity.kt b/add-feature-layers/src/main/java/com/esri/arcgismaps/sample/addfeaturelayers/MainActivity.kt index ba3f1c2b6..40595117e 100644 --- a/add-feature-layers/src/main/java/com/esri/arcgismaps/sample/addfeaturelayers/MainActivity.kt +++ b/add-feature-layers/src/main/java/com/esri/arcgismaps/sample/addfeaturelayers/MainActivity.kt @@ -223,7 +223,7 @@ class MainActivity : AppCompatActivity() { // click listener when feature layer source is selected setOnItemClickListener { _, _, i, _ -> // get the selected feature layer source - val selectedSource = FeatureLayerSource.values().find { it.menuPosition == i } + val selectedSource = FeatureLayerSource.entries.find { it.menuPosition == i } // check if the same feature is selected if (previousSource != null && (previousSource == selectedSource)) { // same feature layer selected, return diff --git a/add-features-with-contingent-values/build.gradle b/add-features-with-contingent-values/build.gradle deleted file mode 100644 index 77c1a6599..000000000 --- a/add-features-with-contingent-values/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.addfeatureswithcontingentvalues" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.addfeatureswithcontingentvalues' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') - implementation 'androidx.appcompat:appcompat:1.5.1' -} diff --git a/add-features-with-contingent-values/build.gradle.kts b/add-features-with-contingent-values/build.gradle.kts new file mode 100644 index 000000000..246aaa3dc --- /dev/null +++ b/add-features-with-contingent-values/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.addfeatureswithcontingentvalues" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.addfeatureswithcontingentvalues" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.androidx.appcompat) + implementation(project(":samples-lib")) +} diff --git a/add-features-with-contingent-values/proguard-rules.pro b/add-features-with-contingent-values/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/add-features-with-contingent-values/proguard-rules.pro +++ b/add-features-with-contingent-values/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/add-features-with-contingent-values/src/main/java/com/esri/arcgismaps/sample/addfeatureswithcontingentvalues/MainActivity.kt b/add-features-with-contingent-values/src/main/java/com/esri/arcgismaps/sample/addfeatureswithcontingentvalues/MainActivity.kt index fbc5fb2dd..1302830a3 100644 --- a/add-features-with-contingent-values/src/main/java/com/esri/arcgismaps/sample/addfeatureswithcontingentvalues/MainActivity.kt +++ b/add-features-with-contingent-values/src/main/java/com/esri/arcgismaps/sample/addfeatureswithcontingentvalues/MainActivity.kt @@ -188,7 +188,7 @@ class MainActivity : AppCompatActivity() { // call get on the future to get the result val featureResultList = featureQueryResult?.toList() - if (featureResultList != null && featureResultList.isNotEmpty()) { + if (!featureResultList.isNullOrEmpty()) { // create list of graphics for each query result val graphics = featureResultList.map { createGraphic(it) } // add the graphics to the graphics overlay diff --git a/add-scene-layer-with-elevation/README.md b/add-scene-layer-with-elevation/README.md index 3dddcbf81..54c8c70b9 100644 --- a/add-scene-layer-with-elevation/README.md +++ b/add-scene-layer-with-elevation/README.md @@ -27,8 +27,12 @@ Run the sample to display a scene service with an `ArcGISSceneLayer`. Pan and zo ## About the data -The scene launches with a northward view of the city of Brest, France. A 3D scene layer representing buildings (some textured) is used as an example. +The scene launches with a northward view of the city of Brest, France ([SceneServer](https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer)). A 3D scene layer representing buildings (some textured) is used as an example. + +## Additional information + +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable SceneView. ## Tags -3D, layer, scene +3D, geoviewcompose, layer, scene diff --git a/add-scene-layer-with-elevation/README.metadata.json b/add-scene-layer-with-elevation/README.metadata.json index 5dd9d7edb..4903b9db1 100644 --- a/add-scene-layer-with-elevation/README.metadata.json +++ b/add-scene-layer-with-elevation/README.metadata.json @@ -8,6 +8,7 @@ ], "keywords": [ "3D", + "geoviewcompose", "layer", "scene", "ArcGISScene", @@ -23,7 +24,6 @@ ], "snippets": [ "src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/components/ComposeSceneView.kt", "src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/components/SceneViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/screens/MainScreen.kt" ], diff --git a/add-scene-layer-with-elevation/add-scene-layer-with-elevation.png b/add-scene-layer-with-elevation/add-scene-layer-with-elevation.png index abfbd2feb..a5f13a6c3 100644 Binary files a/add-scene-layer-with-elevation/add-scene-layer-with-elevation.png and b/add-scene-layer-with-elevation/add-scene-layer-with-elevation.png differ diff --git a/add-scene-layer-with-elevation/build.gradle b/add-scene-layer-with-elevation/build.gradle deleted file mode 100644 index 947b59f57..000000000 --- a/add-scene-layer-with-elevation/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.addscenelayerwithelevation" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.addscenelayerwithelevation' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/add-scene-layer-with-elevation/build.gradle.kts b/add-scene-layer-with-elevation/build.gradle.kts new file mode 100644 index 000000000..577274a01 --- /dev/null +++ b/add-scene-layer-with-elevation/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.addscenelayerwithelevation" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.addscenelayerwithelevation" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/add-scene-layer-with-elevation/proguard-rules.pro b/add-scene-layer-with-elevation/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/add-scene-layer-with-elevation/proguard-rules.pro +++ b/add-scene-layer-with-elevation/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/MainActivity.kt b/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/MainActivity.kt index 7c5dee9e7..8b4f559f0 100644 --- a/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/MainActivity.kt +++ b/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/MainActivity.kt @@ -44,13 +44,8 @@ class MainActivity : ComponentActivity() { @Composable private fun SceneLayerWithElevationApp() { - Surface( - color = MaterialTheme.colorScheme.background - ) { - MainScreen( - sampleName = getString(R.string.app_name), - application = application - ) + Surface(color = MaterialTheme.colorScheme.background) { + MainScreen(sampleName = getString(R.string.app_name)) } } } diff --git a/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/components/ComposeSceneView.kt b/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/components/ComposeSceneView.kt deleted file mode 100644 index 93cd39e83..000000000 --- a/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/components/ComposeSceneView.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.addscenelayerwithelevation.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.SceneView - -/** - * Wraps the SceneView in a Composable function. - */ -@Composable -fun ComposeSceneView( - modifier: Modifier = Modifier, - sceneViewModel: SceneViewModel -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // collect the latest state of the SceneViewState - val sceneViewState = sceneViewModel.sceneViewState - // create and add SceneView to the activity lifecycle - val sceneView = createSceneViewInstance(lifecycleOwner) - - // wrap the SceneView as an AndroidView - AndroidView( - modifier = modifier, - factory = { sceneView }, - // recomposes the SceneView on changes in the SceneViewState - update = { sceneView -> - sceneView.apply { - scene = sceneViewState.arcGISScene - setViewpointCamera(sceneViewState.camera) - } - } - ) -} - -/** - * Create the SceneView instance and add it to the Activity lifecycle - */ -@Composable -fun createSceneViewInstance(lifecycleOwner: LifecycleOwner): SceneView { - // create the SceneView - val sceneView = SceneView(LocalContext.current) - // add the side effects for SceneView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(sceneView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(sceneView) - } - } - return sceneView -} diff --git a/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/components/SceneViewModel.kt b/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/components/SceneViewModel.kt index 6ca5b36fb..df71197e8 100644 --- a/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/components/SceneViewModel.kt +++ b/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/components/SceneViewModel.kt @@ -18,29 +18,41 @@ package com.esri.arcgismaps.sample.addscenelayerwithelevation.components import android.app.Application import androidx.lifecycle.AndroidViewModel +import com.arcgismaps.geometry.Point import com.arcgismaps.mapping.ArcGISScene import com.arcgismaps.mapping.BasemapStyle +import com.arcgismaps.mapping.Viewpoint import com.arcgismaps.mapping.layers.ArcGISSceneLayer import com.arcgismaps.mapping.view.Camera import com.esri.arcgismaps.sample.addscenelayerwithelevation.R class SceneViewModel(application: Application) : AndroidViewModel(application) { - // set the SceneView state - val sceneViewState = SceneViewState() + + private val initLocation = Point( + x = 48.378, + y = -4.494 + ) + + // create a camera position for the scene + private val camera: Camera = Camera( + latitude = 48.378, + longitude = -4.494, + altitude = 200.0, + heading = 345.0, + pitch = 65.0, + roll = 0.0 + ) + // the scene used to display on the SceneView + val scene: ArcGISScene = ArcGISScene(BasemapStyle.ArcGISTopographic).apply { + initialViewpoint = Viewpoint(initLocation,camera) + } // add a scene layer to the ArcGISScene init { // create a scene layer from a scene service for viewing buildings val sceneLayer = ArcGISSceneLayer(application.getString(R.string.brest_buildings)) // add the scene layer to the scene's operational layer - sceneViewState.arcGISScene.operationalLayers.add(sceneLayer) + scene.operationalLayers.add(sceneLayer) } } -/** - * Data class that represents the SceneView state - */ -class SceneViewState( - val arcGISScene: ArcGISScene = ArcGISScene(BasemapStyle.ArcGISTopographic), - val camera: Camera = Camera(48.378, -4.494, 200.0, 345.0, 65.0, 0.0) -) diff --git a/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/screens/MainScreen.kt b/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/screens/MainScreen.kt index b38e859ee..66f238dca 100644 --- a/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/screens/MainScreen.kt +++ b/add-scene-layer-with-elevation/src/main/java/com/esri/arcgismaps/sample/addscenelayerwithelevation/screens/MainScreen.kt @@ -23,7 +23,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import com.esri.arcgismaps.sample.addscenelayerwithelevation.components.ComposeSceneView +import androidx.compose.ui.platform.LocalContext +import com.arcgismaps.toolkit.geoviewcompose.SceneView import com.esri.arcgismaps.sample.addscenelayerwithelevation.components.SceneViewModel import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar @@ -31,7 +32,9 @@ import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { + // get the application context + val application = LocalContext.current.applicationContext as Application // create a ViewModel to handle SceneView interactions val sceneViewModel = SceneViewModel(application) @@ -44,10 +47,9 @@ fun MainScreen(sampleName: String, application: Application) { .padding(it) ) { // composable function that wraps the SceneView - ComposeSceneView( - modifier = Modifier - .fillMaxSize(), - sceneViewModel = sceneViewModel + SceneView( + modifier = Modifier.fillMaxSize(), + arcGISScene = sceneViewModel.scene ) } } diff --git a/add-web-tiled-layer/build.gradle b/add-web-tiled-layer/build.gradle deleted file mode 100644 index ff80b36b0..000000000 --- a/add-web-tiled-layer/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.addwebtiledlayer" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.addwebtiledlayer' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/add-web-tiled-layer/build.gradle.kts b/add-web-tiled-layer/build.gradle.kts new file mode 100644 index 000000000..cf655622b --- /dev/null +++ b/add-web-tiled-layer/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.addwebtiledlayer" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.addwebtiledlayer" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/add-web-tiled-layer/proguard-rules.pro b/add-web-tiled-layer/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/add-web-tiled-layer/proguard-rules.pro +++ b/add-web-tiled-layer/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/add-wms-layer/build.gradle b/add-wms-layer/build.gradle deleted file mode 100644 index 536746ebe..000000000 --- a/add-wms-layer/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.addwmslayer" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.addwmslayer' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/add-wms-layer/build.gradle.kts b/add-wms-layer/build.gradle.kts new file mode 100644 index 000000000..313bc605c --- /dev/null +++ b/add-wms-layer/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.addwmslayer" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.addwmslayer" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/add-wms-layer/proguard-rules.pro b/add-wms-layer/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/add-wms-layer/proguard-rules.pro +++ b/add-wms-layer/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/analyze-hotspots/README.md b/analyze-hotspots/README.md index 316aeaafe..df7f298cc 100644 --- a/analyze-hotspots/README.md +++ b/analyze-hotspots/README.md @@ -28,6 +28,10 @@ Tap on Analyze, and select a date from the "FROM" DatePicker and "TO" DatePicker * GeoprocessingResult * GeoprocessingTask +## Additional information + +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. + ## Tags -analysis, density, geoprocessing, hot spots, hotspots +analysis, density, geoprocessing, geoviewcompose, hot spots, hotspots, toolkit diff --git a/analyze-hotspots/README.metadata.json b/analyze-hotspots/README.metadata.json index 3fe5afb6d..8f2463927 100644 --- a/analyze-hotspots/README.metadata.json +++ b/analyze-hotspots/README.metadata.json @@ -10,8 +10,10 @@ "analysis", "density", "geoprocessing", + "geoviewcompose", "hot spots", "hotspots", + "toolkit", "GeoprocessingJob", "GeoprocessingParameters", "GeoprocessingResult", @@ -27,7 +29,6 @@ ], "snippets": [ "src/main/java/com/esri/arcgismaps/sample/analyzehotspots/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/analyzehotspots/components/ComposeMapView.kt", "src/main/java/com/esri/arcgismaps/sample/analyzehotspots/components/MapViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/analyzehotspots/screens/BottomAppContent.kt", "src/main/java/com/esri/arcgismaps/sample/analyzehotspots/screens/BottomSheetScreen.kt", diff --git a/analyze-hotspots/build.gradle b/analyze-hotspots/build.gradle deleted file mode 100644 index 9823f87c4..000000000 --- a/analyze-hotspots/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.analyzehotspots" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.analyzehotspots' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/analyze-hotspots/build.gradle.kts b/analyze-hotspots/build.gradle.kts new file mode 100644 index 000000000..6d6aa87c8 --- /dev/null +++ b/analyze-hotspots/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.analyzehotspots" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.analyzehotspots" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/analyze-hotspots/proguard-rules.pro b/analyze-hotspots/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/analyze-hotspots/proguard-rules.pro +++ b/analyze-hotspots/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/MainActivity.kt b/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/MainActivity.kt index 47ae750e1..b976e78e6 100644 --- a/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/MainActivity.kt +++ b/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/MainActivity.kt @@ -48,8 +48,7 @@ class MainActivity : ComponentActivity() { color = MaterialTheme.colorScheme.background ) { MainScreen( - sampleName = getString(R.string.app_name), - application = application + sampleName = getString(R.string.app_name) ) } } diff --git a/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/components/ComposeMapView.kt b/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/components/ComposeMapView.kt deleted file mode 100644 index 029168867..000000000 --- a/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/components/ComposeMapView.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.analyzehotspots.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.MapView -import com.arcgismaps.mapping.view.SingleTapConfirmedEvent -import kotlinx.coroutines.launch - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun ComposeMapView( - modifier: Modifier = Modifier, - mapViewModel: MapViewModel, - onSingleTap: (SingleTapConfirmedEvent) -> Unit = {} -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // get an instance of the ViewModel's MapViewState - val mapViewState = mapViewModel.mapViewState - // create and add MapView to the activity lifecycle - val mapView = createMapViewInstance(lifecycleOwner) - - // wrap the MapView as an AndroidView - AndroidView( - modifier = modifier, - factory = { mapView }, - // recomposes the MapView on changes in the MapViewState - update = { mapView -> - mapView.apply { - map = mapViewState.arcGISMap - setViewpoint(mapViewState.viewpoint) - } - } - ) - - // launch coroutine functions in the composition's CoroutineContext - LaunchedEffect(Unit) { - launch { - mapView.onSingleTapConfirmed.collect { - onSingleTap(it) - } - } - } -} - -/** - * Create the MapView instance and add it to the Activity lifecycle - */ -@Composable -fun createMapViewInstance(lifecycleOwner: LifecycleOwner): MapView { - // create the MapView - val mapView = MapView(LocalContext.current) - // add the side effects for MapView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(mapView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(mapView) - } - } - return mapView -} diff --git a/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/components/MapViewModel.kt b/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/components/MapViewModel.kt index 87ce6afaa..1de877c3a 100644 --- a/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/components/MapViewModel.kt +++ b/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/components/MapViewModel.kt @@ -19,8 +19,8 @@ package com.esri.arcgismaps.sample.analyzehotspots.components import android.app.Application import android.util.Log import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue import androidx.lifecycle.AndroidViewModel import com.arcgismaps.geometry.Point import com.arcgismaps.geometry.SpatialReference @@ -45,8 +45,8 @@ class MapViewModel( private val application: Application, private val sampleCoroutineScope: CoroutineScope, ) : AndroidViewModel(application) { - // set the MapView state - val mapViewState = MapViewState() + // create a map using the topographic basemap style + val map: ArcGISMap by mutableStateOf(ArcGISMap(BasemapStyle.ArcGISTopographic)) // create a ViewModel to handle dialog interactions val messageDialogVM: MessageDialogViewModel = MessageDialogViewModel() @@ -55,11 +55,20 @@ class MapViewModel( val showJobProgressDialog = mutableStateOf(false) // determinate job progress percentage - val geoprocessingJobProgress = mutableStateOf(0) + val geoprocessingJobProgress = mutableIntStateOf(0) // job used to run the geoprocessing task on a service private var geoprocessingJob: GeoprocessingJob? = null + init { + map.apply { + // Set the map's initialViewpoint + initialViewpoint = Viewpoint( + center = Point(-13671170.0, 5693633.0, SpatialReference(wkid = 3857)), + scale = 1e5 + ) + } + } /** * Creates a [geoprocessingJob] with the default [GeoprocessingParameters] * and a custom query date range between [fromDate] & [toDate] @@ -69,7 +78,7 @@ class MapViewModel( toDate: String, ) { // a map image layer might be generated, clear previous results - mapViewState.arcGISMap.operationalLayers.clear() + map.operationalLayers.clear() // create and load geoprocessing task val geoprocessingTask = GeoprocessingTask(application.getString(R.string.service_url)) @@ -110,8 +119,8 @@ class MapViewModel( sampleCoroutineScope.launch { geoprocessingJob.progress.collect { progress -> // updates the job progress dialog - geoprocessingJobProgress.value = progress - Log.i("Progress", "geoprocessingJobProgress: ${geoprocessingJobProgress.value}") + geoprocessingJobProgress.intValue = progress + Log.i("Progress", "geoprocessingJobProgress: ${geoprocessingJobProgress.intValue}") } } // get the result of the job on completion @@ -128,7 +137,7 @@ class MapViewModel( } ?: return messageDialogVM.showMessageDialog("Result map image layer is null") // add new layer to map - mapViewState.arcGISMap.operationalLayers.add(hotspotMapImageLayer) + map.operationalLayers.add(hotspotMapImageLayer) }.onFailure { throwable -> messageDialogVM.showMessageDialog( title = throwable.message.toString(), @@ -155,14 +164,3 @@ class MapViewModel( return date.format(formatter) } } - -/** - * Class that represents the MapView's current state - */ -class MapViewState { - var arcGISMap: ArcGISMap by mutableStateOf(ArcGISMap(BasemapStyle.ArcGISTopographic)) - var viewpoint: Viewpoint = Viewpoint( - center = Point(-13671170.0, 5693633.0, SpatialReference(wkid = 3857)), - scale = 1e5 - ) -} diff --git a/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/screens/MainScreen.kt b/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/screens/MainScreen.kt index 0a4451bb5..77e09360e 100644 --- a/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/screens/MainScreen.kt +++ b/analyze-hotspots/src/main/java/com/esri/arcgismaps/sample/analyzehotspots/screens/MainScreen.kt @@ -25,7 +25,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import com.esri.arcgismaps.sample.analyzehotspots.components.ComposeMapView +import androidx.compose.ui.platform.LocalContext +import com.arcgismaps.toolkit.geoviewcompose.MapView import com.esri.arcgismaps.sample.analyzehotspots.components.MapViewModel import com.esri.arcgismaps.sample.sampleslib.components.JobLoadingDialog import com.esri.arcgismaps.sample.sampleslib.components.MessageDialog @@ -36,21 +37,26 @@ import kotlinx.coroutines.launch * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { // coroutineScope that will be cancelled when this call leaves the composition val sampleCoroutineScope = rememberCoroutineScope() + // get the application property that will be used to construct MapViewModel + val sampleApplication = LocalContext.current.applicationContext as Application // create a ViewModel to handle MapView interactions - val mapViewModel = remember { MapViewModel(application, sampleCoroutineScope) } + val mapViewModel = remember { MapViewModel(sampleApplication, sampleCoroutineScope) } Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, content = { // sample app content layout - Column(modifier = Modifier.fillMaxSize().padding(it)) { - // composable function that wraps the MapView - ComposeMapView( - modifier = Modifier.fillMaxSize().weight(1f), - mapViewModel = mapViewModel + Column(modifier = Modifier + .fillMaxSize() + .padding(it)) { + MapView( + modifier = Modifier + .fillMaxSize() + .weight(1f), + arcGISMap = mapViewModel.map ) // bottom layout with a button to display analyze hotspot options BottomAppContent( @@ -83,7 +89,7 @@ fun MainScreen(sampleName: String, application: Application) { if (mapViewModel.showJobProgressDialog.value) { JobLoadingDialog( title = "Analyzing hotspots...", - progress = mapViewModel.geoprocessingJobProgress.value, + progress = mapViewModel.geoprocessingJobProgress.intValue, cancelJobRequest = { mapViewModel.cancelGeoprocessingJob() } ) } diff --git a/analyze-network-with-subnetwork-trace/build.gradle b/analyze-network-with-subnetwork-trace/build.gradle deleted file mode 100644 index 7254b4ff9..000000000 --- a/analyze-network-with-subnetwork-trace/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.analyzenetworkwithsubnetworktrace" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.analyzenetworkwithsubnetworktrace' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/analyze-network-with-subnetwork-trace/build.gradle.kts b/analyze-network-with-subnetwork-trace/build.gradle.kts new file mode 100644 index 000000000..0b592241f --- /dev/null +++ b/analyze-network-with-subnetwork-trace/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.analyzenetworkwithsubnetworktrace" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.analyzenetworkwithsubnetworktrace" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/analyze-network-with-subnetwork-trace/proguard-rules.pro b/analyze-network-with-subnetwork-trace/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/analyze-network-with-subnetwork-trace/proguard-rules.pro +++ b/analyze-network-with-subnetwork-trace/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/apply-dictionary-renderer-to-feature-layer/build.gradle b/apply-dictionary-renderer-to-feature-layer/build.gradle deleted file mode 100644 index 14c751578..000000000 --- a/apply-dictionary-renderer-to-feature-layer/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.applydictionaryrenderertofeaturelayer" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.applydictionaryrenderertofeaturelayer' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/apply-dictionary-renderer-to-feature-layer/build.gradle.kts b/apply-dictionary-renderer-to-feature-layer/build.gradle.kts new file mode 100644 index 000000000..a37785d83 --- /dev/null +++ b/apply-dictionary-renderer-to-feature-layer/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.applydictionaryrenderertofeaturelayer" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.applydictionaryrenderertofeaturelayer" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/apply-dictionary-renderer-to-feature-layer/proguard-rules.pro b/apply-dictionary-renderer-to-feature-layer/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/apply-dictionary-renderer-to-feature-layer/proguard-rules.pro +++ b/apply-dictionary-renderer-to-feature-layer/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/apply-function-to-raster-from-service/build.gradle b/apply-function-to-raster-from-service/build.gradle deleted file mode 100644 index 2aee6a9a7..000000000 --- a/apply-function-to-raster-from-service/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.applyfunctiontorasterfromservice" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.applyfunctiontorasterfromservice' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/apply-function-to-raster-from-service/build.gradle.kts b/apply-function-to-raster-from-service/build.gradle.kts new file mode 100644 index 000000000..9d2c890ce --- /dev/null +++ b/apply-function-to-raster-from-service/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.applyfunctiontorasterfromservice" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.applyfunctiontorasterfromservice" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/apply-function-to-raster-from-service/proguard-rules.pro b/apply-function-to-raster-from-service/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/apply-function-to-raster-from-service/proguard-rules.pro +++ b/apply-function-to-raster-from-service/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/apply-function-to-raster-from-service/src/main/java/com/esri/arcgismaps/sample/applyfunctiontorasterfromservice/MainActivity.kt b/apply-function-to-raster-from-service/src/main/java/com/esri/arcgismaps/sample/applyfunctiontorasterfromservice/MainActivity.kt index c800d32b2..56bc6c5ce 100644 --- a/apply-function-to-raster-from-service/src/main/java/com/esri/arcgismaps/sample/applyfunctiontorasterfromservice/MainActivity.kt +++ b/apply-function-to-raster-from-service/src/main/java/com/esri/arcgismaps/sample/applyfunctiontorasterfromservice/MainActivity.kt @@ -18,7 +18,6 @@ package com.esri.arcgismaps.sample.applyfunctiontorasterfromservice import android.os.Bundle import android.util.Log -import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.lifecycle.lifecycleScope diff --git a/authenticate-with-oauth/build.gradle b/authenticate-with-oauth/build.gradle deleted file mode 100644 index ba076cdbc..000000000 --- a/authenticate-with-oauth/build.gradle +++ /dev/null @@ -1,41 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.authenticatewithoauth" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.authenticatewithoauth' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation "androidx.activity:activity-ktx:$ktxActivityExt" - implementation "androidx.fragment:fragment-ktx:$ktxFragmentsExt" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-livedata-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.browser:browser:$androidBrowserVersion" - implementation project(path: ':samples-lib') -} diff --git a/authenticate-with-oauth/build.gradle.kts b/authenticate-with-oauth/build.gradle.kts new file mode 100644 index 000000000..6dfc6d064 --- /dev/null +++ b/authenticate-with-oauth/build.gradle.kts @@ -0,0 +1,43 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.authenticatewithoauth" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.authenticatewithoauth" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.androidx.activity.ktx) + implementation(libs.androidx.fragment.ktx) + implementation(libs.androidx.lifecycle.viewmodel.ktx) + implementation(libs.androidx.lifecycle.livedata.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.browser) + implementation(project(":samples-lib")) +} diff --git a/authenticate-with-oauth/proguard-rules.pro b/authenticate-with-oauth/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/authenticate-with-oauth/proguard-rules.pro +++ b/authenticate-with-oauth/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/browse-building-floors/build.gradle b/browse-building-floors/build.gradle deleted file mode 100644 index 0114820cf..000000000 --- a/browse-building-floors/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.browsebuildingfloors" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.browsebuildingfloors' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/browse-building-floors/build.gradle.kts b/browse-building-floors/build.gradle.kts new file mode 100644 index 000000000..970e24e42 --- /dev/null +++ b/browse-building-floors/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.browsebuildingfloors" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.browsebuildingfloors" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/browse-building-floors/proguard-rules.pro b/browse-building-floors/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/browse-building-floors/proguard-rules.pro +++ b/browse-building-floors/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 53355116a..000000000 --- a/build.gradle +++ /dev/null @@ -1,51 +0,0 @@ -apply from: 'version.gradle' - -buildscript { - apply from: 'version.gradle' - repositories { - google() - mavenCentral() - } - dependencies { - classpath "com.android.tools.build:gradle:$gradleVersion" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - } -} - -subprojects { - afterEvaluate { project -> - if (project.hasProperty("dependencies")) { - dependencies { - implementation "androidx.appcompat:appcompat:$appcompatVersion" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" - implementation "com.esri:arcgis-maps-kotlin:$arcgisVersion" - implementation "androidx.multidex:multidex:$multidexVersion" - } - } - project.android { - compileOptions { - sourceCompatibility rootProject.ext.javaVersion - targetCompatibility rootProject.ext.javaVersion - } - defaultConfig { - multiDexEnabled true - } - packagingOptions { - exclude 'META-INF/DEPENDENCIES' - } - kotlinOptions { - jvmTarget = "17" - } - } - } -} - -task apiKey { - def apiKeyFile = new File("${System.properties.getProperty("user.home")}/.gradle/gradle.properties") - if (!apiKeyFile.exists()) { - print("Go to " + new URL("https://developers.arcgis.com/dashboard/") + " to get an API key.") - print("Add your API Key to ${System.properties.getProperty("user.home")}\\.gradle\\gradle.properties.") - String apiKeyFileContents = "API_KEY = " - apiKeyFile.write(apiKeyFileContents) - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..3e9a0b38f --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,61 @@ +import com.android.build.gradle.BaseExtension +import java.net.URL + +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath("com.android.tools.build:gradle:${libs.versions.gradleVersion.get()}") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlinVersion.get()}") + } +} + +subprojects { + afterEvaluate { + if (hasProperty("dependencies")) { + dependencies { + val implementation by configurations + implementation(libs.androidx.appcompat) + implementation(libs.stdlib.jdk8) + implementation(libs.arcgis.maps.kotlin) + implementation(libs.androidx.multidex) + } + } + + extensions.findByType(BaseExtension::class)?.let { android -> + android.compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + android.defaultConfig { + multiDexEnabled = true + } + android.packagingOptions { + resources { + excludes.add("META-INF/DEPENDENCIES") + } + } + } + + tasks.withType { + kotlinOptions { + jvmTarget = "17" + } + } + + } +} + +tasks.register("apiKey") { + doLast { + val apiKeyFile = File("${System.getProperty("user.home")}/.gradle/gradle.properties") + if (!apiKeyFile.exists()) { + print("Go to ${URL("https://developers.arcgis.com/dashboard/")} to get an API key.") + print("Add your API Key to ${System.getProperty("user.home")}\\.gradle\\gradle.properties.") + val apiKeyFileContents = "API_KEY = " + apiKeyFile.writeText(apiKeyFileContents) + } + } +} diff --git a/change-camera-controller/build.gradle b/change-camera-controller/build.gradle deleted file mode 100644 index 218bcfd5f..000000000 --- a/change-camera-controller/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.changecameracontroller" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.changecameracontroller' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/change-camera-controller/build.gradle.kts b/change-camera-controller/build.gradle.kts new file mode 100644 index 000000000..3f1d4ea30 --- /dev/null +++ b/change-camera-controller/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.changecameracontroller" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.changecameracontroller" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/change-camera-controller/proguard-rules.pro b/change-camera-controller/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/change-camera-controller/proguard-rules.pro +++ b/change-camera-controller/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/change-camera-controller/src/main/java/com/esri/arcgismaps/sample/changecameracontroller/MainActivity.kt b/change-camera-controller/src/main/java/com/esri/arcgismaps/sample/changecameracontroller/MainActivity.kt index e8d32b396..8a028d9c3 100644 --- a/change-camera-controller/src/main/java/com/esri/arcgismaps/sample/changecameracontroller/MainActivity.kt +++ b/change-camera-controller/src/main/java/com/esri/arcgismaps/sample/changecameracontroller/MainActivity.kt @@ -263,7 +263,7 @@ enum class CameraControllerMode(val displayName: String) { * Returns a List containing the [displayName] property of this enum type. * */ fun getValuesByDisplayName(): List { - return values().map { cameraControllerMode -> + return entries.map { cameraControllerMode -> cameraControllerMode.displayName } } @@ -272,7 +272,7 @@ enum class CameraControllerMode(val displayName: String) { * Returns the enum constant of this type with the specified [displayName] property. */ fun getValue(displayName: String): CameraControllerMode { - return values().first { + return entries.first { it.displayName == displayName } } diff --git a/change-viewpoint/build.gradle b/change-viewpoint/build.gradle deleted file mode 100644 index f9bbfff17..000000000 --- a/change-viewpoint/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.changeviewpoint" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.changeviewpoint' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/change-viewpoint/build.gradle.kts b/change-viewpoint/build.gradle.kts new file mode 100644 index 000000000..f269a21dd --- /dev/null +++ b/change-viewpoint/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.changeviewpoint" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.changeviewpoint" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/change-viewpoint/proguard-rules.pro b/change-viewpoint/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/change-viewpoint/proguard-rules.pro +++ b/change-viewpoint/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/clip-geometry/build.gradle b/clip-geometry/build.gradle deleted file mode 100644 index 5f92489fc..000000000 --- a/clip-geometry/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.clipgeometry" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.clipgeometry' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/clip-geometry/build.gradle.kts b/clip-geometry/build.gradle.kts new file mode 100644 index 000000000..85a5f8e8e --- /dev/null +++ b/clip-geometry/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.clipgeometry" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.clipgeometry" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/clip-geometry/proguard-rules.pro b/clip-geometry/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/clip-geometry/proguard-rules.pro +++ b/clip-geometry/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/clip-geometry/src/main/java/com/esri/arcgismaps/sample/clipgeometry/MainActivity.kt b/clip-geometry/src/main/java/com/esri/arcgismaps/sample/clipgeometry/MainActivity.kt index dba9eb6d5..b1e808551 100644 --- a/clip-geometry/src/main/java/com/esri/arcgismaps/sample/clipgeometry/MainActivity.kt +++ b/clip-geometry/src/main/java/com/esri/arcgismaps/sample/clipgeometry/MainActivity.kt @@ -17,7 +17,6 @@ package com.esri.arcgismaps.sample.clipgeometry import android.os.Bundle -import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import com.arcgismaps.ApiKey diff --git a/create-convex-hull-around-points/build.gradle b/create-convex-hull-around-points/build.gradle deleted file mode 100644 index 48f1fffb6..000000000 --- a/create-convex-hull-around-points/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.createconvexhullaroundpoints" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.createconvexhullaroundpoints' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/create-convex-hull-around-points/build.gradle.kts b/create-convex-hull-around-points/build.gradle.kts new file mode 100644 index 000000000..a8be150df --- /dev/null +++ b/create-convex-hull-around-points/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.createconvexhullaroundpoints" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.createconvexhullaroundpoints" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/create-convex-hull-around-points/proguard-rules.pro b/create-convex-hull-around-points/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/create-convex-hull-around-points/proguard-rules.pro +++ b/create-convex-hull-around-points/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/create-mobile-geodatabase/build.gradle b/create-mobile-geodatabase/build.gradle deleted file mode 100644 index 4e61ce5de..000000000 --- a/create-mobile-geodatabase/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.createmobilegeodatabase" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.createmobilegeodatabase' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/create-mobile-geodatabase/build.gradle.kts b/create-mobile-geodatabase/build.gradle.kts new file mode 100644 index 000000000..9024d10be --- /dev/null +++ b/create-mobile-geodatabase/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.createmobilegeodatabase" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.createmobilegeodatabase" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/create-mobile-geodatabase/proguard-rules.pro b/create-mobile-geodatabase/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/create-mobile-geodatabase/proguard-rules.pro +++ b/create-mobile-geodatabase/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/create-planar-and-geodetic-buffers/build.gradle b/create-planar-and-geodetic-buffers/build.gradle deleted file mode 100644 index e2819092c..000000000 --- a/create-planar-and-geodetic-buffers/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.createplanarandgeodeticbuffers" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.createplanarandgeodeticbuffers' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/create-planar-and-geodetic-buffers/build.gradle.kts b/create-planar-and-geodetic-buffers/build.gradle.kts new file mode 100644 index 000000000..c9038f54c --- /dev/null +++ b/create-planar-and-geodetic-buffers/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.createplanarandgeodeticbuffers" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.createplanarandgeodeticbuffers" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/create-planar-and-geodetic-buffers/proguard-rules.pro b/create-planar-and-geodetic-buffers/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/create-planar-and-geodetic-buffers/proguard-rules.pro +++ b/create-planar-and-geodetic-buffers/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/cut-geometry/build.gradle b/cut-geometry/build.gradle deleted file mode 100644 index 3a1a559ad..000000000 --- a/cut-geometry/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.cutgeometry" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.cutgeometry' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/cut-geometry/build.gradle.kts b/cut-geometry/build.gradle.kts new file mode 100644 index 000000000..14ff2d0ac --- /dev/null +++ b/cut-geometry/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.cutgeometry" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.cutgeometry" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/cut-geometry/proguard-rules.pro b/cut-geometry/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/cut-geometry/proguard-rules.pro +++ b/cut-geometry/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/cut-geometry/src/main/java/com/esri/arcgismaps/sample/cutgeometry/MainActivity.kt b/cut-geometry/src/main/java/com/esri/arcgismaps/sample/cutgeometry/MainActivity.kt index 86ee05fe5..55fede4fb 100644 --- a/cut-geometry/src/main/java/com/esri/arcgismaps/sample/cutgeometry/MainActivity.kt +++ b/cut-geometry/src/main/java/com/esri/arcgismaps/sample/cutgeometry/MainActivity.kt @@ -17,7 +17,6 @@ package com.esri.arcgismaps.sample.cutgeometry import android.os.Bundle -import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import com.arcgismaps.ApiKey diff --git a/display-points-using-clustering-feature-reduction/.gitignore b/display-clusters/.gitignore similarity index 100% rename from display-points-using-clustering-feature-reduction/.gitignore rename to display-clusters/.gitignore diff --git a/display-points-using-clustering-feature-reduction/README.md b/display-clusters/README.md similarity index 87% rename from display-points-using-clustering-feature-reduction/README.md rename to display-clusters/README.md index e36314279..c8c93b6b3 100644 --- a/display-points-using-clustering-feature-reduction/README.md +++ b/display-clusters/README.md @@ -1,12 +1,12 @@ -# Display points using clustering feature reduction +# Display clusters Display a web map with a point feature layer that has feature reduction enabled to aggregate points into clusters. Map displaying the feature layer with feature reduction property enabled by default: -![Feature reduction map](display-points-using-clustering-feature-reduction.png) +![Feature reduction map](display-clusters.png) Popup message displaying the cluster details: -![Cluster details popup](display-points-using-clustering-feature-reduction-popup.png) +![Cluster details popup](display-clusters-popup.png) ## Use case @@ -40,6 +40,10 @@ Pan and zoom the map to view how clustering is dynamically updated. Disable clus This sample uses a [web map](https://www.arcgis.com/home/item.html?id=8916d50c44c746c1aafae001552bad23) that displays the Esri [Global Power Plants](https://www.arcgis.com/home/item.html?id=eb54b44c65b846cca12914b87b315169) feature layer with feature reduction enabled. When enabled, the aggregate features symbology shows the color of the most common power plant type, and a size relative to the average plant capacity of the cluster. +## Additional information + +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. + ## Tags -aggregate, bin, cluster, group, merge, normalize, reduce, summarize +aggregate, bin, cluster, geoviewcompose, group, merge, normalize, reduce, summarize, toolkit diff --git a/display-clusters/README.metadata.json b/display-clusters/README.metadata.json new file mode 100644 index 000000000..89793881d --- /dev/null +++ b/display-clusters/README.metadata.json @@ -0,0 +1,49 @@ +{ + "category": "Visualization", + "description": "Display a web map with a point feature layer that has feature reduction enabled to aggregate points into clusters.", + "formal_name": "DisplayClusters", + "ignore": false, + "images": [ + "display-clusters.png", + "display-clusters-popup.png" + ], + "keywords": [ + "aggregate", + "bin", + "cluster", + "geoviewcompose", + "group", + "merge", + "normalize", + "reduce", + "summarize", + "toolkit", + "FeatureLayer", + "FeatureReduction", + "IdentifyLayerResult", + "Popup", + "PopupElement", + "PopupField", + "Portal", + "PortalItem" + ], + "language": "kotlin", + "redirect_from": ["/kotlin/sample-code/display-points-using-clustering-feature-reduction/"], + "relevant_apis": [ + "FeatureLayer", + "FeatureReduction", + "IdentifyLayerResult", + "Popup", + "PopupElement", + "PopupField", + "Portal", + "PortalItem" + ], + "snippets": [ + "src/main/java/com/esri/arcgismaps/sample/displayclusters/MainActivity.kt", + "src/main/java/com/esri/arcgismaps/sample/displayclusters/components/ClusterInfoContent.kt", + "src/main/java/com/esri/arcgismaps/sample/displayclusters/components/MapViewModel.kt", + "src/main/java/com/esri/arcgismaps/sample/displayclusters/screens/MainScreen.kt" + ], + "title": "Display clusters" +} diff --git a/display-clusters/build.gradle.kts b/display-clusters/build.gradle.kts new file mode 100644 index 000000000..ef83b8376 --- /dev/null +++ b/display-clusters/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.displayclusters" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.displayclusters" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/display-clusters/display-clusters-popup.png b/display-clusters/display-clusters-popup.png new file mode 100644 index 000000000..63f52b599 Binary files /dev/null and b/display-clusters/display-clusters-popup.png differ diff --git a/display-clusters/display-clusters.png b/display-clusters/display-clusters.png new file mode 100644 index 000000000..37a99a6c4 Binary files /dev/null and b/display-clusters/display-clusters.png differ diff --git a/display-points-using-clustering-feature-reduction/proguard-rules.pro b/display-clusters/proguard-rules.pro similarity index 94% rename from display-points-using-clustering-feature-reduction/proguard-rules.pro rename to display-clusters/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/display-points-using-clustering-feature-reduction/proguard-rules.pro +++ b/display-clusters/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/display-points-using-clustering-feature-reduction/src/main/AndroidManifest.xml b/display-clusters/src/main/AndroidManifest.xml similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/AndroidManifest.xml rename to display-clusters/src/main/AndroidManifest.xml diff --git a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/MainActivity.kt b/display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/MainActivity.kt similarity index 85% rename from display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/MainActivity.kt rename to display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/MainActivity.kt index 5e1d71dca..1d507ca55 100644 --- a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/MainActivity.kt +++ b/display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/MainActivity.kt @@ -14,7 +14,7 @@ * */ -package com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction +package com.esri.arcgismaps.sample.displayclusters import android.os.Bundle import androidx.activity.ComponentActivity @@ -25,7 +25,7 @@ import androidx.compose.runtime.Composable import com.arcgismaps.ApiKey import com.arcgismaps.ArcGISEnvironment import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme -import com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction.screens.MainScreen +import com.esri.arcgismaps.sample.displayclusters.screens.MainScreen class MainActivity : ComponentActivity() { @@ -48,8 +48,7 @@ class MainActivity : ComponentActivity() { color = MaterialTheme.colorScheme.background ) { MainScreen( - sampleName = getString(R.string.app_name), - application = application + sampleName = getString(R.string.app_name) ) } } diff --git a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/ClusterInfoContent.kt b/display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/components/ClusterInfoContent.kt similarity index 96% rename from display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/ClusterInfoContent.kt rename to display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/components/ClusterInfoContent.kt index b021b2bed..533cb9ea5 100644 --- a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/ClusterInfoContent.kt +++ b/display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/components/ClusterInfoContent.kt @@ -14,7 +14,7 @@ * */ -package com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction.components +package com.esri.arcgismaps.sample.displayclusters.components import android.content.res.Configuration import androidx.compose.foundation.background @@ -72,7 +72,7 @@ fun ClusterInfoContent( } } - LazyColumn() { + LazyColumn { items(clusterInfoList.size) { index -> Divider( modifier = Modifier.padding(horizontal = 12.dp), diff --git a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/MapViewModel.kt b/display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/components/MapViewModel.kt similarity index 86% rename from display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/MapViewModel.kt rename to display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/components/MapViewModel.kt index 61bd5dfff..bf3fb4866 100644 --- a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/MapViewModel.kt +++ b/display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/components/MapViewModel.kt @@ -14,7 +14,7 @@ * */ -package com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction.components +package com.esri.arcgismaps.sample.displayclusters.components import android.app.Application import android.graphics.Typeface @@ -31,6 +31,7 @@ import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextDecoration +import androidx.compose.ui.unit.dp import androidx.core.text.HtmlCompat import androidx.lifecycle.AndroidViewModel import com.arcgismaps.LoadStatus @@ -42,19 +43,18 @@ import com.arcgismaps.mapping.layers.FeatureLayer import com.arcgismaps.mapping.popup.FieldsPopupElement import com.arcgismaps.mapping.popup.TextPopupElement import com.arcgismaps.mapping.view.IdentifyLayerResult +import com.arcgismaps.mapping.view.SingleTapConfirmedEvent import com.arcgismaps.portal.Portal -import com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction.R +import com.arcgismaps.toolkit.geoviewcompose.MapViewProxy +import com.esri.arcgismaps.sample.displayclusters.R import com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModel import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch class MapViewModel( application: Application, private val sampleCoroutineScope: CoroutineScope ) : AndroidViewModel(application) { - // set the MapView mutable stateflow - val mapViewState = MutableStateFlow(MapViewState()) // create a ViewModel to handle dialog interactions val messageDialogVM: MessageDialogViewModel = MessageDialogViewModel() @@ -74,6 +74,13 @@ class MapViewModel( // the title of the popup result val popupTitle = mutableStateOf("") + // create a MapViewProxy that the view model will use to identify features in the MapView. + // this also needs to be passed to the composable MapView() function. + val mapViewProxy = MapViewProxy() + + // define ArcGIS map using Night Navigation basemap + var map = ArcGISMap(BasemapStyle.ArcGISNavigationNight) + init { // show loading dialog to indicate that the map is loading showLoadingDialog.value = true @@ -82,11 +89,13 @@ class MapViewModel( Portal(application.getString(R.string.portal_url)), "8916d50c44c746c1aafae001552bad23" ) - // set the map to be displayed in the layout's MapView - mapViewState.value.arcGISMap = ArcGISMap(portalItem) + // set the map to be displayed in the layout's MapView and set it's initialViewpoint + map = ArcGISMap(portalItem).apply { + initialViewpoint = Viewpoint(39.8, -98.6, 10e7) + } sampleCoroutineScope.launch { - mapViewState.value.arcGISMap.load().onSuccess { + map.load().onSuccess { showLoadingDialog.value = false } } @@ -96,7 +105,6 @@ class MapViewModel( `* Toggle the FeatureLayer's featureReduction property */ fun toggleFeatureReduction() { - val map = mapViewState.value.arcGISMap isFeatureReductionEnabled.value = !isFeatureReductionEnabled.value if (map.loadStatus.value == LoadStatus.Loaded) { map.operationalLayers.forEach { layer -> @@ -111,10 +119,22 @@ class MapViewModel( } } + /** + * Identifies the tapped screen coordinate in the provided [singleTapConfirmedEvent] + */ + fun identify(singleTapConfirmedEvent: SingleTapConfirmedEvent) { + sampleCoroutineScope.launch { + dismissBottomSheet() + // call identifyLayers when a tap event occurs + val identifyResult = mapViewProxy.identifyLayers(singleTapConfirmedEvent.screenCoordinate, 3.dp) + handleIdentifyResult(identifyResult) + } + } + /** * Identify the feature layer results and display the resulting popup element information */ - fun handleIdentifyResult(result: Result>) { + private fun handleIdentifyResult(result: Result>) { sampleCoroutineScope.launch { result.onSuccess { identifyResultList -> // initialize the string for each tap event resulting in a new identifyResultList @@ -229,10 +249,3 @@ class MapViewModel( } } -/** - * Class that represents the MapView state - */ -data class MapViewState( - var arcGISMap: ArcGISMap = ArcGISMap(BasemapStyle.ArcGISNavigationNight), - val viewpoint: Viewpoint = Viewpoint(39.8, -98.6, 10e7) -) diff --git a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/screens/MainScreen.kt b/display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/screens/MainScreen.kt similarity index 85% rename from display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/screens/MainScreen.kt rename to display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/screens/MainScreen.kt index 35761a5a9..02550cc51 100644 --- a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/screens/MainScreen.kt +++ b/display-clusters/src/main/java/com/esri/arcgismaps/sample/displayclusters/screens/MainScreen.kt @@ -14,7 +14,7 @@ * */ -package com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction.screens +package com.esri.arcgismaps.sample.displayclusters.screens import android.app.Application import androidx.compose.foundation.layout.Arrangement @@ -31,10 +31,11 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp -import com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction.components.ClusterInfoContent -import com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction.components.ComposeMapView -import com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction.components.MapViewModel +import com.arcgismaps.toolkit.geoviewcompose.MapView +import com.esri.arcgismaps.sample.displayclusters.components.ClusterInfoContent +import com.esri.arcgismaps.sample.displayclusters.components.MapViewModel import com.esri.arcgismaps.sample.sampleslib.components.BottomSheet import com.esri.arcgismaps.sample.sampleslib.components.LoadingDialog import com.esri.arcgismaps.sample.sampleslib.components.MessageDialog @@ -45,10 +46,12 @@ import com.esri.arcgismaps.sample.sampleslib.theme.SampleTypography * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { // coroutineScope that will be cancelled when this call leaves the composition val sampleCoroutineScope = rememberCoroutineScope() + // get the application context + val application = LocalContext.current.applicationContext as Application // create a ViewModel to handle MapView interactions val mapViewModel = remember { MapViewModel(application, sampleCoroutineScope) } @@ -62,12 +65,14 @@ fun MainScreen(sampleName: String, application: Application) { horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { - // composable function that wraps the MapView - ComposeMapView( + MapView( modifier = Modifier .fillMaxSize() .weight(1f), - mapViewModel = mapViewModel + arcGISMap = mapViewModel.map, + mapViewProxy = mapViewModel.mapViewProxy, + onSingleTapConfirmed = mapViewModel::identify, + onPan = { mapViewModel.dismissBottomSheet() } ) // Button to enable/disable featureReduction property Row( diff --git a/display-points-using-clustering-feature-reduction/src/main/res/drawable-v24/ic_launcher_foreground.xml b/display-clusters/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to display-clusters/src/main/res/drawable-v24/ic_launcher_foreground.xml diff --git a/display-points-using-clustering-feature-reduction/src/main/res/drawable/ic_launcher_background.xml b/display-clusters/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/drawable/ic_launcher_background.xml rename to display-clusters/src/main/res/drawable/ic_launcher_background.xml diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/display-clusters/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to display-clusters/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/display-clusters/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to display-clusters/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-hdpi/ic_launcher.png b/display-clusters/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-hdpi/ic_launcher.png rename to display-clusters/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-hdpi/ic_launcher_round.png b/display-clusters/src/main/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-hdpi/ic_launcher_round.png rename to display-clusters/src/main/res/mipmap-hdpi/ic_launcher_round.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-mdpi/ic_launcher.png b/display-clusters/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-mdpi/ic_launcher.png rename to display-clusters/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-mdpi/ic_launcher_round.png b/display-clusters/src/main/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-mdpi/ic_launcher_round.png rename to display-clusters/src/main/res/mipmap-mdpi/ic_launcher_round.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-xhdpi/ic_launcher.png b/display-clusters/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-xhdpi/ic_launcher.png rename to display-clusters/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/display-clusters/src/main/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-xhdpi/ic_launcher_round.png rename to display-clusters/src/main/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-xxhdpi/ic_launcher.png b/display-clusters/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to display-clusters/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/display-clusters/src/main/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-xxhdpi/ic_launcher_round.png rename to display-clusters/src/main/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/display-clusters/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to display-clusters/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/display-clusters/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from display-points-using-clustering-feature-reduction/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png rename to display-clusters/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/display-points-using-clustering-feature-reduction/src/main/res/values/strings.xml b/display-clusters/src/main/res/values/strings.xml similarity index 50% rename from display-points-using-clustering-feature-reduction/src/main/res/values/strings.xml rename to display-clusters/src/main/res/values/strings.xml index ed09fca70..d0352fc1e 100644 --- a/display-points-using-clustering-feature-reduction/src/main/res/values/strings.xml +++ b/display-clusters/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ - Display points using clustering feature reduction + Display clusters https://www.arcgis.com/ diff --git a/display-composable-mapview/README.md b/display-composable-mapview/README.md index dfcebf4bf..650df0d44 100644 --- a/display-composable-mapview/README.md +++ b/display-composable-mapview/README.md @@ -19,7 +19,7 @@ Run the sample to view the map. Pan and zoom to navigate the map. 3. Set its `Modifier` to define the MapView layout parameters 4. Use its `factory` parameter to provide context and create `MapView(context)` 5. Add the `MapView` to the lifecycle observer -6. Add the composable content to the Activity using `setContent { }` +6. Add the composable content to the Activity using `setContent { }` ## Relevant API @@ -27,6 +27,10 @@ Run the sample to view the map. Pan and zoom to navigate the map. * BasemapStyle * MapView +## Additional information + +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. + ## Tags -basemap, compose, jetpack, map +basemap, compose, geoviewcompose, jetpack, map, toolkit diff --git a/display-composable-mapview/README.metadata.json b/display-composable-mapview/README.metadata.json index 3082f0881..3c0815f18 100644 --- a/display-composable-mapview/README.metadata.json +++ b/display-composable-mapview/README.metadata.json @@ -9,8 +9,10 @@ "keywords": [ "basemap", "compose", + "geoviewcompose", "jetpack", "map", + "toolkit", "ArcGISMap", "BasemapStyle", "MapView" @@ -23,9 +25,7 @@ "MapView" ], "snippets": [ - "src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MapViewWithCompose.kt", - "src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/theme/Theme.kt" + "src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MainActivity.kt" ], "title": "Display Composable MapView" } diff --git a/display-composable-mapview/build.gradle b/display-composable-mapview/build.gradle deleted file mode 100644 index e89b6d229..000000000 --- a/display-composable-mapview/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.displaycomposablemapview" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.displaycomposablemapview' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/display-composable-mapview/build.gradle.kts b/display-composable-mapview/build.gradle.kts new file mode 100644 index 000000000..4a3921c15 --- /dev/null +++ b/display-composable-mapview/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.displaycomposablemapview" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.displaycomposablemapview" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/display-composable-mapview/proguard-rules.pro b/display-composable-mapview/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/display-composable-mapview/proguard-rules.pro +++ b/display-composable-mapview/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/display-composable-mapview/src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MainActivity.kt b/display-composable-mapview/src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MainActivity.kt index 4931af98c..7e214d9f6 100644 --- a/display-composable-mapview/src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MainActivity.kt +++ b/display-composable-mapview/src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MainActivity.kt @@ -19,26 +19,17 @@ package com.esri.arcgismaps.sample.displaycomposablemapview import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import com.arcgismaps.ApiKey import com.arcgismaps.ArcGISEnvironment import com.arcgismaps.mapping.ArcGISMap import com.arcgismaps.mapping.BasemapStyle -import com.arcgismaps.mapping.Viewpoint +import com.arcgismaps.toolkit.geoviewcompose.MapView import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme class MainActivity : ComponentActivity() { - private val viewpointAmerica = Viewpoint(39.8, -98.6, 10e7) - private val viewpointAsia = Viewpoint(39.8, 98.6, 10e7) - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // authentication with an API key or named user is @@ -47,27 +38,12 @@ class MainActivity : ComponentActivity() { setContent { SampleAppTheme { - Column( + // create a map with a navigation night basemap style + val map = ArcGISMap(BasemapStyle.ArcGISNavigationNight) + MapView( modifier = Modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally - ) { - // a mutable/immutable state is computed by remember to store its value during - // initial composition, and updates the composition on the state value change - var viewpoint by remember { mutableStateOf(viewpointAmerica) } - val map by remember { mutableStateOf(ArcGISMap(BasemapStyle.ArcGISNavigationNight)) } - - // Composable function that wraps the MapView - MapViewWithCompose( - arcGISMap = map, - viewpoint = viewpoint, - // lambda to retrieve the MapView's onSingleTapConfirmed - onSingleTap = { - // swap between America and Asia viewpoints - viewpoint = - if (viewpoint == viewpointAmerica) viewpointAsia else viewpointAmerica - } - ) - } + arcGISMap = map + ) } } } diff --git a/display-composable-mapview/src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MapViewWithCompose.kt b/display-composable-mapview/src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MapViewWithCompose.kt deleted file mode 100644 index af9ec0509..000000000 --- a/display-composable-mapview/src/main/java/com/esri/arcgismaps/sample/displaycomposablemapview/MapViewWithCompose.kt +++ /dev/null @@ -1,54 +0,0 @@ -package com.esri.arcgismaps.sample.displaycomposablemapview - -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.lifecycleScope -import com.arcgismaps.geometry.Point -import com.arcgismaps.mapping.ArcGISMap -import com.arcgismaps.mapping.Viewpoint -import com.arcgismaps.mapping.view.MapView -import kotlinx.coroutines.launch - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun MapViewWithCompose( - arcGISMap: ArcGISMap, - viewpoint: Viewpoint, - onSingleTap: (mapPoint: Point?) -> Unit = {}, -) { - val lifecycleOwner = LocalLifecycleOwner.current - AndroidView( - // modifiers are used to set layout parameters - modifier = Modifier.fillMaxSize(), - // the factory parameter provides a context to create a classic Android view - // called when the composable is created, but not when it's recomposed - factory = { context -> - MapView(context).also { mapView -> - // add the MapView to the lifecycle observer - lifecycleOwner.lifecycle.addObserver(mapView) - // set the map - mapView.map = arcGISMap - // launch a coroutine to collect map taps - lifecycleOwner.lifecycleScope.launch { - mapView.onSingleTapConfirmed.collect { - onSingleTap(it.mapPoint) - } - } - } - }, - - // update block runs every time this view is recomposed which only occurs - // when a `State` or `MutableState` parameter is changed. - update = { view -> // view is automatically cast to a MapView - view.map = arcGISMap // called only if the arcGISMap parameter is changes - lifecycleOwner.lifecycleScope.launch { - view.setViewpointAnimated(viewpoint) // called only if the viewpoint parameter is changes - } - } - ) -} diff --git a/display-device-location-with-nmea-data-sources/build.gradle b/display-device-location-with-nmea-data-sources/build.gradle deleted file mode 100644 index 8a5156141..000000000 --- a/display-device-location-with-nmea-data-sources/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.displaydevicelocationwithnmeadatasources" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.displaydevicelocationwithnmeadatasources' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation 'androidx.appcompat:appcompat:1.5.1' - implementation project(path: ':samples-lib') -} diff --git a/display-device-location-with-nmea-data-sources/build.gradle.kts b/display-device-location-with-nmea-data-sources/build.gradle.kts new file mode 100644 index 000000000..1c8d60d70 --- /dev/null +++ b/display-device-location-with-nmea-data-sources/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.displaydevicelocationwithnmeadatasources" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.displaydevicelocationwithnmeadatasources" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.androidx.appcompat) + implementation(project(":samples-lib")) +} diff --git a/display-device-location-with-nmea-data-sources/proguard-rules.pro b/display-device-location-with-nmea-data-sources/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/display-device-location-with-nmea-data-sources/proguard-rules.pro +++ b/display-device-location-with-nmea-data-sources/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/display-dimensions/build.gradle b/display-dimensions/build.gradle deleted file mode 100644 index fcb35e2d2..000000000 --- a/display-dimensions/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.displaydimensions" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.displaydimensions' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation "androidx.appcompat:appcompat:$appcompatVersion" - implementation project(path: ':samples-lib') -} diff --git a/display-dimensions/build.gradle.kts b/display-dimensions/build.gradle.kts new file mode 100644 index 000000000..75ff23e82 --- /dev/null +++ b/display-dimensions/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.displaydimensions" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.displaydimensions" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.androidx.appcompat) + implementation(project(":samples-lib")) +} diff --git a/display-dimensions/proguard-rules.pro b/display-dimensions/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/display-dimensions/proguard-rules.pro +++ b/display-dimensions/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/display-map-from-mobile-map-package/build.gradle b/display-map-from-mobile-map-package/build.gradle deleted file mode 100644 index 92dc7391f..000000000 --- a/display-map-from-mobile-map-package/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.displaymapfrommobilemappackage" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.displaymapfrommobilemappackage' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - // this lib handles data provisioning for samples which use local data - implementation project(path: ':samples-lib') -} diff --git a/display-map-from-mobile-map-package/build.gradle.kts b/display-map-from-mobile-map-package/build.gradle.kts new file mode 100644 index 000000000..deee869e3 --- /dev/null +++ b/display-map-from-mobile-map-package/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.displaymapfrommobilemappackage" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.displaymapfrommobilemappackage" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/display-map-from-mobile-map-package/proguard-rules.pro b/display-map-from-mobile-map-package/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/display-map-from-mobile-map-package/proguard-rules.pro +++ b/display-map-from-mobile-map-package/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/display-map/build.gradle b/display-map/build.gradle deleted file mode 100644 index 877421716..000000000 --- a/display-map/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.displaymap" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.displaymap' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/display-map/build.gradle.kts b/display-map/build.gradle.kts new file mode 100644 index 000000000..a9fc7d09d --- /dev/null +++ b/display-map/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.displaymap" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.displaymap" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/display-map/proguard-rules.pro b/display-map/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/display-map/proguard-rules.pro +++ b/display-map/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/display-points-using-clustering-feature-reduction/README.metadata.json b/display-points-using-clustering-feature-reduction/README.metadata.json deleted file mode 100644 index 3a9cdd383..000000000 --- a/display-points-using-clustering-feature-reduction/README.metadata.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "category": "Visualization", - "description": "Display a web map with a point feature layer that has feature reduction enabled to aggregate points into clusters.", - "formal_name": "DisplayPointsUsingClusteringFeatureReduction", - "ignore": false, - "images": [ - "display-points-using-clustering-feature-reduction.png", - "display-points-using-clustering-feature-reduction-popup.png" - ], - "keywords": [ - "aggregate", - "bin", - "cluster", - "group", - "merge", - "normalize", - "reduce", - "summarize", - "FeatureLayer", - "FeatureReduction", - "IdentifyLayerResult", - "Popup", - "PopupElement", - "PopupField", - "Portal", - "PortalItem" - ], - "language": "kotlin", - "redirect_from": "", - "relevant_apis": [ - "FeatureLayer", - "FeatureReduction", - "IdentifyLayerResult", - "Popup", - "PopupElement", - "PopupField", - "Portal", - "PortalItem" - ], - "snippets": [ - "src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/ClusterInfoContent.kt", - "src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/ComposeMapView.kt", - "src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/MapViewModel.kt", - "src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/screens/MainScreen.kt" - ], - "title": "Display points using clustering feature reduction" -} diff --git a/display-points-using-clustering-feature-reduction/build.gradle b/display-points-using-clustering-feature-reduction/build.gradle deleted file mode 100644 index 1e324c88a..000000000 --- a/display-points-using-clustering-feature-reduction/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/display-points-using-clustering-feature-reduction/display-points-using-clustering-feature-reduction-popup.png b/display-points-using-clustering-feature-reduction/display-points-using-clustering-feature-reduction-popup.png deleted file mode 100644 index 835469f58..000000000 Binary files a/display-points-using-clustering-feature-reduction/display-points-using-clustering-feature-reduction-popup.png and /dev/null differ diff --git a/display-points-using-clustering-feature-reduction/display-points-using-clustering-feature-reduction.png b/display-points-using-clustering-feature-reduction/display-points-using-clustering-feature-reduction.png deleted file mode 100644 index 5ce450116..000000000 Binary files a/display-points-using-clustering-feature-reduction/display-points-using-clustering-feature-reduction.png and /dev/null differ diff --git a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/ComposeMapView.kt b/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/ComposeMapView.kt deleted file mode 100644 index 759f38519..000000000 --- a/display-points-using-clustering-feature-reduction/src/main/java/com/esri/arcgismaps/sample/displaypointsusingclusteringfeaturereduction/components/ComposeMapView.kt +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.displaypointsusingclusteringfeaturereduction.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.MapView -import kotlinx.coroutines.launch - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun ComposeMapView( - modifier: Modifier = Modifier, - mapViewModel: MapViewModel -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // collect the latest state of the MapViewState - val mapViewState by mapViewModel.mapViewState.collectAsState() - // create and add MapView to the activity lifecycle - val mapView = createMapViewInstance(lifecycleOwner) - - // wrap the MapView as an AndroidView - AndroidView( - modifier = modifier, - factory = { mapView }, - // recomposes the MapView on changes in the MapViewState - update = { mapView -> - mapView.apply { - map = mapViewState.arcGISMap - setViewpoint(mapViewState.viewpoint) - } - } - ) - - // launch coroutine functions in the composition's CoroutineContext - LaunchedEffect(Unit) { - launch { - mapView.onSingleTapConfirmed.collect { - mapViewModel.dismissBottomSheet() - // call identifyLayers when a tap event occurs - val identifyResult = mapView.identifyLayers(it.screenCoordinate, 3.0, false) - mapViewModel.handleIdentifyResult(identifyResult) - } - } - launch { - mapView.onPan.collect{ - mapViewModel.dismissBottomSheet() - } - } - } -} - -/** - * Create the MapView instance and add it to the Activity lifecycle - */ -@Composable -fun createMapViewInstance(lifecycleOwner: LifecycleOwner): MapView { - // create the MapView - val mapView = MapView(LocalContext.current) - // add the side effects for MapView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(mapView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(mapView) - } - } - return mapView -} diff --git a/display-scene-from-mobile-scene-package/README.md b/display-scene-from-mobile-scene-package/README.md index 6c0f5bb0a..bccd62502 100644 --- a/display-scene-from-mobile-scene-package/README.md +++ b/display-scene-from-mobile-scene-package/README.md @@ -27,6 +27,10 @@ This sample takes a mobile scene package that was created in ArcGIS Pro, and dis * MobileScenePackage * SceneView +## Additional information + +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable SceneView. + ## Tags -3d, mobile scene package, mspk, offline, scene +3d, geoviewcompose, mobile scene package, mspk, offline, scene diff --git a/display-scene-from-mobile-scene-package/README.metadata.json b/display-scene-from-mobile-scene-package/README.metadata.json index a95f19e53..5d732fdd0 100644 --- a/display-scene-from-mobile-scene-package/README.metadata.json +++ b/display-scene-from-mobile-scene-package/README.metadata.json @@ -8,6 +8,7 @@ ], "keywords": [ "3d", + "geoviewcompose", "mobile scene package", "mspk", "offline", @@ -26,7 +27,6 @@ "snippets": [ "src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/DownloadActivity.kt", "src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/components/ComposeSceneView.kt", "src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/components/SceneViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/screens/MainScreen.kt" ], diff --git a/display-scene-from-mobile-scene-package/build.gradle b/display-scene-from-mobile-scene-package/build.gradle deleted file mode 100644 index f581f00a6..000000000 --- a/display-scene-from-mobile-scene-package/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.displayscenefrommobilescenepackage" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.displayscenefrommobilescenepackage' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/display-scene-from-mobile-scene-package/build.gradle.kts b/display-scene-from-mobile-scene-package/build.gradle.kts new file mode 100644 index 000000000..f9da5e2d2 --- /dev/null +++ b/display-scene-from-mobile-scene-package/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.displayscenefrommobilescenepackage" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.displayscenefrommobilescenepackage" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/display-scene-from-mobile-scene-package/proguard-rules.pro b/display-scene-from-mobile-scene-package/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/display-scene-from-mobile-scene-package/proguard-rules.pro +++ b/display-scene-from-mobile-scene-package/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/MainActivity.kt b/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/MainActivity.kt index 12187d756..48a800e18 100644 --- a/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/MainActivity.kt +++ b/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/MainActivity.kt @@ -44,13 +44,8 @@ class MainActivity : ComponentActivity() { @Composable private fun DisplaySceneFromMobileScenePackageApp() { - Surface( - color = MaterialTheme.colorScheme.background - ) { - MainScreen( - sampleName = getString(R.string.app_name), - application = application - ) + Surface(color = MaterialTheme.colorScheme.background) { + MainScreen(sampleName = getString(R.string.app_name)) } } } diff --git a/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/components/ComposeSceneView.kt b/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/components/ComposeSceneView.kt deleted file mode 100644 index f566fe1d7..000000000 --- a/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/components/ComposeSceneView.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.displayscenefrommobilescenepackage.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.SceneView - -/** - * Wraps the SceneView in a Composable function. - */ -@Composable -fun ComposeSceneView( - modifier: Modifier = Modifier, - sceneViewModel: SceneViewModel -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - - // collect the latest state of the SceneView from the package - val sceneViewState by sceneViewModel.firstScene.collectAsState() - - // create and add SceneView to the activity lifecycle - val sceneView = createSceneViewInstance(lifecycleOwner) - - // wrap the SceneView as an AndroidView - AndroidView( - modifier = modifier, - factory = { sceneView }, - // recomposes the SceneView on changes in sceneViewState - update = { sceneView -> - sceneView.scene = sceneViewState - } - ) -} - -/** - * Create the SceneView instance and add it to the Activity lifecycle - */ -@Composable -fun createSceneViewInstance(lifecycleOwner: LifecycleOwner): SceneView { - // create the SceneView - val sceneView = SceneView(LocalContext.current) - // add the side effects for SceneView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(sceneView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(sceneView) - } - } - return sceneView -} diff --git a/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/components/SceneViewModel.kt b/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/components/SceneViewModel.kt index 6a0a3f8ce..02d3f6c2c 100644 --- a/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/components/SceneViewModel.kt +++ b/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/components/SceneViewModel.kt @@ -17,15 +17,16 @@ package com.esri.arcgismaps.sample.displayscenefrommobilescenepackage.components import android.app.Application +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue import androidx.lifecycle.AndroidViewModel import com.arcgismaps.mapping.ArcGISScene +import com.arcgismaps.mapping.BasemapStyle import com.arcgismaps.mapping.MobileScenePackage import com.esri.arcgismaps.sample.displayscenefrommobilescenepackage.R import com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModel import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import java.io.File @@ -34,11 +35,8 @@ class SceneViewModel( private val sampleCoroutineScope: CoroutineScope ) : AndroidViewModel(application) { - // create a mutable state holder for the first scene - private val _firstScene = MutableStateFlow(null) - - // expose a read-only state flow for observing changes to the first scene - val firstScene: StateFlow = _firstScene.asStateFlow() + // create a base scene to be used to load the mobile scene package + var scene by mutableStateOf(ArcGISScene(BasemapStyle.ArcGISStreets)) // create a ViewModel to handle dialog interactions val messageDialogVM: MessageDialogViewModel = MessageDialogViewModel() @@ -64,7 +62,7 @@ class SceneViewModel( // load the mobile scene package mobileScenePackage.load().onSuccess { // update the mutable state holder with the first scene from the MobileScenePackage - _firstScene.value = mobileScenePackage.scenes.first() + scene = mobileScenePackage.scenes.first() }.onFailure { error -> // show the message dialog and pass the error message to be displayed in the dialog messageDialogVM.showMessageDialog(error.message.toString(), error.cause.toString()) diff --git a/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/screens/MainScreen.kt b/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/screens/MainScreen.kt index 0d4d5fdd1..28236e658 100644 --- a/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/screens/MainScreen.kt +++ b/display-scene-from-mobile-scene-package/src/main/java/com/esri/arcgismaps/sample/displayscenefrommobilescenepackage/screens/MainScreen.kt @@ -25,7 +25,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import com.esri.arcgismaps.sample.displayscenefrommobilescenepackage.components.ComposeSceneView +import androidx.compose.ui.platform.LocalContext +import com.arcgismaps.toolkit.geoviewcompose.SceneView import com.esri.arcgismaps.sample.displayscenefrommobilescenepackage.components.SceneViewModel import com.esri.arcgismaps.sample.sampleslib.components.MessageDialog import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar @@ -34,9 +35,11 @@ import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { // create a ViewModel to handle SceneView interactions val sampleCoroutineScope = rememberCoroutineScope() + // get the application context + val application = LocalContext.current.applicationContext as Application val sceneViewModel = remember { SceneViewModel(application, sampleCoroutineScope) } Scaffold( @@ -48,9 +51,9 @@ fun MainScreen(sampleName: String, application: Application) { .padding(it) ) { // composable function that wraps the SceneView - ComposeSceneView( + SceneView( modifier = Modifier.fillMaxSize(), - sceneViewModel = sceneViewModel + arcGISScene = sceneViewModel.scene ) // display a dialog if the sample encounters an error sceneViewModel.messageDialogVM.apply { diff --git a/display-scene/build.gradle b/display-scene/build.gradle deleted file mode 100644 index e71e8484e..000000000 --- a/display-scene/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.displayscene" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.displayscene' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/display-scene/build.gradle.kts b/display-scene/build.gradle.kts new file mode 100644 index 000000000..69367856e --- /dev/null +++ b/display-scene/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.displayscene" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.displayscene" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/display-scene/proguard-rules.pro b/display-scene/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/display-scene/proguard-rules.pro +++ b/display-scene/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/download-vector-tiles-to-local-cache/build.gradle b/download-vector-tiles-to-local-cache/build.gradle deleted file mode 100644 index 155b8134b..000000000 --- a/download-vector-tiles-to-local-cache/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.downloadvectortilestolocalcache" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.downloadvectortilestolocalcache' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/download-vector-tiles-to-local-cache/build.gradle.kts b/download-vector-tiles-to-local-cache/build.gradle.kts new file mode 100644 index 000000000..8ae706194 --- /dev/null +++ b/download-vector-tiles-to-local-cache/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.downloadvectortilestolocalcache" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.downloadvectortilestolocalcache" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/download-vector-tiles-to-local-cache/proguard-rules.pro b/download-vector-tiles-to-local-cache/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/download-vector-tiles-to-local-cache/proguard-rules.pro +++ b/download-vector-tiles-to-local-cache/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/edit-feature-attachments/build.gradle b/edit-feature-attachments/build.gradle deleted file mode 100644 index 7e0dae3f5..000000000 --- a/edit-feature-attachments/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.editfeatureattachments" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.editfeatureattachments' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation project(path: ':samples-lib') -} diff --git a/edit-feature-attachments/build.gradle.kts b/edit-feature-attachments/build.gradle.kts new file mode 100644 index 000000000..2656a685f --- /dev/null +++ b/edit-feature-attachments/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.editfeatureattachments" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.editfeatureattachments" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.android.material) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.constraintlayout) + implementation(project(":samples-lib")) +} diff --git a/edit-feature-attachments/proguard-rules.pro b/edit-feature-attachments/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/edit-feature-attachments/proguard-rules.pro +++ b/edit-feature-attachments/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/find-address-with-reverse-geocode/build.gradle b/find-address-with-reverse-geocode/build.gradle deleted file mode 100644 index 171a82e0b..000000000 --- a/find-address-with-reverse-geocode/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.findaddresswithreversegeocode" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.findaddresswithreversegeocode' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/find-address-with-reverse-geocode/build.gradle.kts b/find-address-with-reverse-geocode/build.gradle.kts new file mode 100644 index 000000000..861468512 --- /dev/null +++ b/find-address-with-reverse-geocode/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.findaddresswithreversegeocode" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.findaddresswithreversegeocode" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.android.material) + implementation(libs.androidx.constraintlayout) + implementation(project(":samples-lib")) +} diff --git a/find-address-with-reverse-geocode/proguard-rules.pro b/find-address-with-reverse-geocode/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/find-address-with-reverse-geocode/proguard-rules.pro +++ b/find-address-with-reverse-geocode/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/find-nearest-vertex/build.gradle b/find-nearest-vertex/build.gradle deleted file mode 100644 index 7a3b5df6b..000000000 --- a/find-nearest-vertex/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.findnearestvertex" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.findnearestvertex' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/find-nearest-vertex/build.gradle.kts b/find-nearest-vertex/build.gradle.kts new file mode 100644 index 000000000..f64dc37c1 --- /dev/null +++ b/find-nearest-vertex/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.findnearestvertex" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.findnearestvertex" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/find-nearest-vertex/proguard-rules.pro b/find-nearest-vertex/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/find-nearest-vertex/proguard-rules.pro +++ b/find-nearest-vertex/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/find-route-around-barriers/build.gradle b/find-route-around-barriers/build.gradle deleted file mode 100644 index 173c0ae27..000000000 --- a/find-route-around-barriers/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.findroutearoundbarriers" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.findroutearoundbarriers' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/find-route-around-barriers/build.gradle.kts b/find-route-around-barriers/build.gradle.kts new file mode 100644 index 000000000..9abbceb6d --- /dev/null +++ b/find-route-around-barriers/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.findroutearoundbarriers" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.findroutearoundbarriers" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/find-route-around-barriers/proguard-rules.pro b/find-route-around-barriers/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/find-route-around-barriers/proguard-rules.pro +++ b/find-route-around-barriers/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/find-route-in-transport-network/build.gradle b/find-route-in-transport-network/build.gradle deleted file mode 100644 index c4e99d0c3..000000000 --- a/find-route-in-transport-network/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.findrouteintransportnetwork" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.findrouteintransportnetwork' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation "androidx.appcompat:appcompat:$appcompatVersion" - implementation project(path: ':samples-lib') -} diff --git a/find-route-in-transport-network/build.gradle.kts b/find-route-in-transport-network/build.gradle.kts new file mode 100644 index 000000000..ebc955632 --- /dev/null +++ b/find-route-in-transport-network/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.findrouteintransportnetwork" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.findrouteintransportnetwork" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.androidx.appcompat) + implementation(project(":samples-lib")) +} diff --git a/find-route-in-transport-network/proguard-rules.pro b/find-route-in-transport-network/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/find-route-in-transport-network/proguard-rules.pro +++ b/find-route-in-transport-network/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/find-route/build.gradle b/find-route/build.gradle deleted file mode 100644 index 54644c096..000000000 --- a/find-route/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.findroute" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.findroute' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0' - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/find-route/build.gradle.kts b/find-route/build.gradle.kts new file mode 100644 index 000000000..66701dce3 --- /dev/null +++ b/find-route/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.findroute" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.findroute" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.androidx.coordinatorlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/find-route/proguard-rules.pro b/find-route/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/find-route/proguard-rules.pro +++ b/find-route/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/generate-geodatabase-replica-from-feature-service/build.gradle b/generate-geodatabase-replica-from-feature-service/build.gradle deleted file mode 100644 index dcb9f3c4d..000000000 --- a/generate-geodatabase-replica-from-feature-service/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.generategeodatabasereplicafromfeatureservice" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.generategeodatabasereplicafromfeatureservice' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/generate-geodatabase-replica-from-feature-service/build.gradle.kts b/generate-geodatabase-replica-from-feature-service/build.gradle.kts new file mode 100644 index 000000000..636a317e7 --- /dev/null +++ b/generate-geodatabase-replica-from-feature-service/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.generategeodatabasereplicafromfeatureservice" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.generategeodatabasereplicafromfeatureservice" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/generate-geodatabase-replica-from-feature-service/proguard-rules.pro b/generate-geodatabase-replica-from-feature-service/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/generate-geodatabase-replica-from-feature-service/proguard-rules.pro +++ b/generate-geodatabase-replica-from-feature-service/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/generate-offline-map-using-android-jetpack-workmanager/build.gradle b/generate-offline-map-using-android-jetpack-workmanager/build.gradle deleted file mode 100644 index 160747712..000000000 --- a/generate-offline-map-using-android-jetpack-workmanager/build.gradle +++ /dev/null @@ -1,38 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.generateofflinemapusingandroidjetpackworkmanager" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.generateofflinemapusingandroidjetpackworkmanager' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') - implementation "androidx.work:work-runtime-ktx:$workVersion" - implementation "androidx.lifecycle:lifecycle-livedata-ktx:$ktxLifecycle" -} diff --git a/generate-offline-map-using-android-jetpack-workmanager/build.gradle.kts b/generate-offline-map-using-android-jetpack-workmanager/build.gradle.kts new file mode 100644 index 000000000..8a759e9a6 --- /dev/null +++ b/generate-offline-map-using-android-jetpack-workmanager/build.gradle.kts @@ -0,0 +1,40 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.generateofflinemapusingandroidjetpackworkmanager" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.generateofflinemapusingandroidjetpackworkmanager" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) + implementation(libs.androidx.work.runtime.ktx) + implementation(libs.androidx.lifecycle.livedata.ktx) +} diff --git a/generate-offline-map-using-android-jetpack-workmanager/proguard-rules.pro b/generate-offline-map-using-android-jetpack-workmanager/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/generate-offline-map-using-android-jetpack-workmanager/proguard-rules.pro +++ b/generate-offline-map-using-android-jetpack-workmanager/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/generate-offline-map-using-android-jetpack-workmanager/src/main/AndroidManifest.xml b/generate-offline-map-using-android-jetpack-workmanager/src/main/AndroidManifest.xml index 6b0207c4f..58bd69d5e 100644 --- a/generate-offline-map-using-android-jetpack-workmanager/src/main/AndroidManifest.xml +++ b/generate-offline-map-using-android-jetpack-workmanager/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ + + diff --git a/generate-offline-map-using-android-jetpack-workmanager/src/main/java/com/esri/arcgismaps/sample/generateofflinemapusingandroidjetpackworkmanager/OfflineJobWorker.kt b/generate-offline-map-using-android-jetpack-workmanager/src/main/java/com/esri/arcgismaps/sample/generateofflinemapusingandroidjetpackworkmanager/OfflineJobWorker.kt index 72ac9bbfb..612031944 100644 --- a/generate-offline-map-using-android-jetpack-workmanager/src/main/java/com/esri/arcgismaps/sample/generateofflinemapusingandroidjetpackworkmanager/OfflineJobWorker.kt +++ b/generate-offline-map-using-android-jetpack-workmanager/src/main/java/com/esri/arcgismaps/sample/generateofflinemapusingandroidjetpackworkmanager/OfflineJobWorker.kt @@ -18,6 +18,8 @@ package com.esri.arcgismaps.sample.generateofflinemapusingandroidjetpackworkmanager import android.content.Context +import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC +import android.os.Build import android.util.Log import androidx.work.CoroutineWorker import androidx.work.WorkerParameters @@ -59,10 +61,18 @@ class OfflineJobWorker(private val context: Context, params: WorkerParameters) : */ private fun createForegroundInfo(progress: Int): ForegroundInfo { // create a ForegroundInfo using the notificationId and a new progress notification - return ForegroundInfo( - notificationId, - workerNotification.createProgressNotification(progress) - ) + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + ForegroundInfo( + notificationId, + workerNotification.createProgressNotification(progress), + FOREGROUND_SERVICE_TYPE_DATA_SYNC + ) + } else { + ForegroundInfo( + notificationId, + workerNotification.createProgressNotification(progress) + ) + } } override suspend fun doWork(): Result { diff --git a/generate-offline-map/build.gradle b/generate-offline-map/build.gradle deleted file mode 100644 index edef9c317..000000000 --- a/generate-offline-map/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.generateofflinemap" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.generateofflinemap' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/generate-offline-map/build.gradle.kts b/generate-offline-map/build.gradle.kts new file mode 100644 index 000000000..8291eb91c --- /dev/null +++ b/generate-offline-map/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.generateofflinemap" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.generateofflinemap" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/generate-offline-map/proguard-rules.pro b/generate-offline-map/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/generate-offline-map/proguard-rules.pro +++ b/generate-offline-map/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/geocode-offline/build.gradle b/geocode-offline/build.gradle deleted file mode 100644 index f1c988367..000000000 --- a/geocode-offline/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.geocodeoffline" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.geocodeoffline' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') - implementation 'androidx.appcompat:appcompat:1.5.1' -} diff --git a/geocode-offline/build.gradle.kts b/geocode-offline/build.gradle.kts new file mode 100644 index 000000000..e76341bff --- /dev/null +++ b/geocode-offline/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.geocodeoffline" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.geocodeoffline" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.androidx.appcompat) + implementation(project(":samples-lib")) +} diff --git a/geocode-offline/proguard-rules.pro b/geocode-offline/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/geocode-offline/proguard-rules.pro +++ b/geocode-offline/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..725b01978 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,65 @@ +[versions] +# ArcGIS Maps SDK for Kotlin version +arcgisMapsKotlinVersion = "200.4.0" +# ArcGIS Maps SDK for Kotlin Toolkit version +arcgisToolkitVersion = "200.4.0" +# SDK versions +compileSdk = "34" +minSdk = "26" +targetSdk = "34" +versionCode = "2004000" +versionName = "200.4.0" +# Kotlin versions +kotlinVersion = "1.9.21" +ktxLifecycle = "2.6.2" +ktxFragmentsExt = "1.6.2" +ktxActivityExt = "1.8.2" +ktxAndroidCore = "1.12.0" +kotlinCompilerExt = "1.5.6" +# Compose versions +composeActivityVersion = "1.7.1" +composeBOM = "2023.10.01" +# Library versions +appcompatVersion = "1.6.1" +commonsIoVersion = "2.11.0" +constraintLayoutVersion = "2.1.4" +coordinateLayoutVersion = "1.2.0" +workVersion = "2.7.1" +multidexVersion = "2.0.1" +materialVersion = "1.7.0" +androidBrowserVersion = "1.7.0" +# Plugin versions +gradleVersion = "8.2.0" + +[plugins] +android-application = { id = "com.android.application", version.ref = "gradleVersion" } +android-library = { id = "com.android.library", version.ref = "gradleVersion" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" } + +[libraries] +android-material = { group = "com.google.android.material", name = "material", version.ref = "materialVersion"} +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompatVersion"} +androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "composeActivityVersion"} +androidx-activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "ktxActivityExt"} +androidx-browser = { group = "androidx.browser", name = "browser", version.ref = "androidBrowserVersion"} +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBOM"} +androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" } +androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" } +androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintLayoutVersion"} +androidx-coordinatorlayout = { group = "androidx.coordinatorlayout", name = "coordinatorlayout", version.ref = "coordinateLayoutVersion"} +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "ktxAndroidCore"} +androidx-fragment-ktx = { group = "androidx.fragment", name = "fragment-ktx", version.ref = "ktxFragmentsExt" } +androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "ktxLifecycle"} +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "ktxLifecycle"} +androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "ktxLifecycle"} +androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "ktxLifecycle"} +androidx-multidex = { group = "androidx.multidex", name = "multidex", version.ref = "multidexVersion"} +androidx-work-runtime-ktx = { group = "androidx.work", name = "work-runtime-ktx", version.ref = "workVersion" } +arcgis-maps-kotlin = { group = "com.esri", name = "arcgis-maps-kotlin", version.ref = "arcgisMapsKotlinVersion"} +arcgis-maps-kotlin-toolkit-bom = { group = "com.esri", name = "arcgis-maps-kotlin-toolkit-bom", version.ref = "arcgisToolkitVersion"} +arcgis-maps-kotlin-toolkit-authentication = { group = "com.esri", name = "arcgis-maps-kotlin-toolkit-authentication" } +arcgis-maps-kotlin-toolkit-geoview-compose = { group = "com.esri", name = "arcgis-maps-kotlin-toolkit-geoview-compose" } +commons-io = { group = "commons-io", name = "commons-io", version.ref = "commonsIoVersion" } +stdlib-jdk8 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlinVersion"} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 49e9a889d..d1f09ebe6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Aug 21 14:16:03 PDT 2023 +#Wed Mar 27 09:39:37 PDT 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/identify-layer-features/README.md b/identify-layer-features/README.md index 816e71b8d..1f1c9764f 100644 --- a/identify-layer-features/README.md +++ b/identify-layer-features/README.md @@ -26,8 +26,9 @@ Tap to identify features. A bottom text banner will show all layers with feature ## Additional information +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. The GeoView supports two methods of identify: `identifyLayer`, which identifies features within a specific layer and `identifyLayers`, which identifies features for all layers in the current view. ## Tags -identify, recursion, recursive, sublayers +geoviewcompose, identify, recursion, recursive, sublayers, toolkit diff --git a/identify-layer-features/README.metadata.json b/identify-layer-features/README.metadata.json index 8a0b8d3a1..613b0dfb1 100644 --- a/identify-layer-features/README.metadata.json +++ b/identify-layer-features/README.metadata.json @@ -7,10 +7,12 @@ "identify-layer-features.png" ], "keywords": [ + "geoviewcompose", "identify", "recursion", "recursive", "sublayers", + "toolkit", "IdentifyLayerResult", "IdentifyLayerResult.sublayerResults", "LayerContent" @@ -24,7 +26,6 @@ ], "snippets": [ "src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/ComposeMapView.kt", "src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/MapViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/screens/MainScreen.kt" ], diff --git a/identify-layer-features/build.gradle b/identify-layer-features/build.gradle deleted file mode 100644 index 2a368331a..000000000 --- a/identify-layer-features/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.identifylayerfeatures" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.identifylayerfeatures' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/identify-layer-features/build.gradle.kts b/identify-layer-features/build.gradle.kts new file mode 100644 index 000000000..fc1bbbf5e --- /dev/null +++ b/identify-layer-features/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.identifylayerfeatures" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.identifylayerfeatures" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/identify-layer-features/proguard-rules.pro b/identify-layer-features/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/identify-layer-features/proguard-rules.pro +++ b/identify-layer-features/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/MainActivity.kt b/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/MainActivity.kt index 8b43d63dc..ac4844fa4 100644 --- a/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/MainActivity.kt +++ b/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/MainActivity.kt @@ -48,8 +48,7 @@ class MainActivity : ComponentActivity() { color = MaterialTheme.colorScheme.background ) { MainScreen( - sampleName = getString(R.string.app_name), - application = application + sampleName = getString(R.string.app_name) ) } } diff --git a/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/ComposeMapView.kt b/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/ComposeMapView.kt deleted file mode 100644 index 7bec430bb..000000000 --- a/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/ComposeMapView.kt +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.identifylayerfeatures.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.MapView - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun ComposeMapView( - modifier: Modifier = Modifier, - mapViewModel: MapViewModel -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // collect the latest state of the MapViewState - val mapViewState by mapViewModel.mapViewState.collectAsState() - // create and add MapView to the activity lifecycle - val mapView = createMapViewInstance(lifecycleOwner) - - // wrap the MapView as an AndroidView - AndroidView( - modifier = modifier, - factory = { mapView }, - // recomposes the MapView on changes in the MapViewState - update = { mapView -> - mapView.apply { - map = mapViewState.arcGISMap - setViewpoint(mapViewState.viewpoint) - } - } - ) - - // launch coroutine functions in the composition's CoroutineContext - LaunchedEffect(Unit) { - mapView.onSingleTapConfirmed.collect { - // call identifyLayers when a tap event occurs - val identifyResult = mapView.identifyLayers( - screenCoordinate = it.screenCoordinate, - tolerance = 12.0, - returnPopupsOnly = false, - maximumResults = 10 - ) - mapViewModel.handleIdentifyResult(identifyResult) - } - } -} - -/** - * Create the MapView instance and add it to the Activity lifecycle - */ -@Composable -fun createMapViewInstance(lifecycleOwner: LifecycleOwner): MapView { - // create the MapView - val mapView = MapView(LocalContext.current) - // add the side effects for MapView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(mapView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(mapView) - } - } - return mapView -} diff --git a/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/MapViewModel.kt b/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/MapViewModel.kt index e1b216712..308afd984 100644 --- a/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/MapViewModel.kt +++ b/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/components/MapViewModel.kt @@ -18,28 +18,33 @@ package com.esri.arcgismaps.sample.identifylayerfeatures.components import android.app.Application import androidx.compose.runtime.mutableStateOf +import androidx.compose.ui.unit.dp import androidx.lifecycle.AndroidViewModel import com.arcgismaps.data.ServiceFeatureTable -import com.arcgismaps.geometry.Point -import com.arcgismaps.geometry.SpatialReference import com.arcgismaps.mapping.ArcGISMap import com.arcgismaps.mapping.BasemapStyle import com.arcgismaps.mapping.Viewpoint import com.arcgismaps.mapping.layers.ArcGISMapImageLayer import com.arcgismaps.mapping.layers.FeatureLayer.Companion.createWithFeatureTable import com.arcgismaps.mapping.view.IdentifyLayerResult +import com.arcgismaps.mapping.view.SingleTapConfirmedEvent +import com.arcgismaps.toolkit.geoviewcompose.MapViewProxy import com.esri.arcgismaps.sample.identifylayerfeatures.R import com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModel import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch class MapViewModel( application: Application, private val sampleCoroutineScope: CoroutineScope ) : AndroidViewModel(application) { - // set the MapView mutable stateflow - val mapViewState = MutableStateFlow(MapViewState()) + + // create a map using the topographic basemap style + val map: ArcGISMap = ArcGISMap(BasemapStyle.ArcGISTopographic) + + // create a mapViewProxy that will be used to identify features in the MapView + // should also be passed to the composable MapView this mapViewProxy is associated with + val mapViewProxy = MapViewProxy() // create a ViewModel to handle dialog interactions val messageDialogVM: MessageDialogViewModel = MessageDialogViewModel() @@ -66,21 +71,19 @@ class MapViewModel( } } - // create a topographic map - val map = ArcGISMap(BasemapStyle.ArcGISTopographic).apply { - // add world cities layer - operationalLayers.add(mapImageLayer) - // add damaged property data - operationalLayers.add(featureLayer) + // add the world cities layer with and the damaged properties feature layer + map.apply { + // set initial Viewpoint to North America + initialViewpoint = Viewpoint(39.8, -98.6, 5e7) + operationalLayers.addAll(listOf(mapImageLayer, featureLayer)) } - // assign the map to the map view - mapViewState.value.arcGISMap = map + } /** * Identify the feature layer results and display the resulting information */ - fun handleIdentifyResult(result: Result>) { + private fun handleIdentifyResult(result: Result>) { sampleCoroutineScope.launch { result.onSuccess { identifyResultList -> val message = StringBuilder() @@ -129,19 +132,20 @@ class MapViewModel( } return subLayerGeoElementCount + result.geoElements.size } -} -/** - * Data class that represents the MapView state - */ -data class MapViewState( - var arcGISMap: ArcGISMap = ArcGISMap(BasemapStyle.ArcGISNavigationNight), - var viewpoint: Viewpoint = Viewpoint( - center = Point( - x = -10977012.785807, - y = 4514257.550369, - spatialReference = SpatialReference(wkid = 3857) - ), - scale = 68015210.0 - ) -) + /** + * Identifies the tapped screen coordinate in the provided [singleTapConfirmedEvent] + */ + fun identify(singleTapConfirmedEvent: SingleTapConfirmedEvent) { + sampleCoroutineScope.launch { + // identify the layers on the tapped coordinate + val identifyResult = mapViewProxy.identifyLayers( + screenCoordinate = singleTapConfirmedEvent.screenCoordinate, + tolerance = 12.dp, + maximumResults = 10 + ) + // use the layer result to display feature information + handleIdentifyResult(identifyResult) + } + } +} diff --git a/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/screens/MainScreen.kt b/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/screens/MainScreen.kt index e81ad166d..1f3633a7b 100644 --- a/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/screens/MainScreen.kt +++ b/identify-layer-features/src/main/java/com/esri/arcgismaps/sample/identifylayerfeatures/screens/MainScreen.kt @@ -29,8 +29,9 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp -import com.esri.arcgismaps.sample.identifylayerfeatures.components.ComposeMapView +import com.arcgismaps.toolkit.geoviewcompose.MapView import com.esri.arcgismaps.sample.identifylayerfeatures.components.MapViewModel import com.esri.arcgismaps.sample.sampleslib.components.MessageDialog import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar @@ -39,11 +40,15 @@ import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { // coroutineScope that will be cancelled when this call leaves the composition val sampleCoroutineScope = rememberCoroutineScope() + // get the application property that will be used to construct MapViewModel + val sampleApplication = LocalContext.current.applicationContext as Application // create a ViewModel to handle MapView interactions - val mapViewModel = remember { MapViewModel(application, sampleCoroutineScope) } + val mapViewModel = remember { MapViewModel(sampleApplication, sampleCoroutineScope) } + // create a Viewpoint + Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, @@ -53,13 +58,14 @@ fun MainScreen(sampleName: String, application: Application) { .fillMaxSize() .padding(it) ) { - // composable function that wraps the MapView - ComposeMapView( + MapView( modifier = Modifier .fillMaxSize() .weight(1f) .animateContentSize(), - mapViewModel = mapViewModel + arcGISMap = mapViewModel.map, + mapViewProxy = mapViewModel.mapViewProxy, + onSingleTapConfirmed = mapViewModel::identify ) // Bottom text to display the identify results Row( diff --git a/manage-operational-layers/README.md b/manage-operational-layers/README.md index 65fa9f210..cc09bdbf9 100644 --- a/manage-operational-layers/README.md +++ b/manage-operational-layers/README.md @@ -27,8 +27,9 @@ When the app starts, the display lists of operational layers and any removed lay ## Additional information +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. You cannot add the same layer to the map multiple times or add the same layer to multiple maps. Instead, clone the layer with `layer.clone()` before duplicating. ## Tags -add, delete, layer, map, remove +add, delete, geoviewcompose, layer, map, remove, toolkit diff --git a/manage-operational-layers/README.metadata.json b/manage-operational-layers/README.metadata.json index 7bebd151d..d130bd64f 100644 --- a/manage-operational-layers/README.metadata.json +++ b/manage-operational-layers/README.metadata.json @@ -9,9 +9,11 @@ "keywords": [ "add", "delete", + "geoviewcompose", "layer", "map", "remove", + "toolkit", "ArcGISMap", "ArcGISMapImageLayer", "LayerList" @@ -25,7 +27,6 @@ ], "snippets": [ "src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/components/ComposeMapView.kt", "src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/components/MapViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/screens/LayersList.kt", "src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/screens/MainScreen.kt" diff --git a/manage-operational-layers/build.gradle b/manage-operational-layers/build.gradle deleted file mode 100644 index c97c0c70e..000000000 --- a/manage-operational-layers/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.manageoperationallayers" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.manageoperationallayers' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/manage-operational-layers/build.gradle.kts b/manage-operational-layers/build.gradle.kts new file mode 100644 index 000000000..0ca9e0a7f --- /dev/null +++ b/manage-operational-layers/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.manageoperationallayers" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.manageoperationallayers" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/manage-operational-layers/proguard-rules.pro b/manage-operational-layers/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/manage-operational-layers/proguard-rules.pro +++ b/manage-operational-layers/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/MainActivity.kt b/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/MainActivity.kt index a6486fc76..d97c91028 100644 --- a/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/MainActivity.kt +++ b/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/MainActivity.kt @@ -48,8 +48,7 @@ class MainActivity : ComponentActivity() { color = MaterialTheme.colorScheme.background ) { MainScreen( - sampleName = getString(R.string.app_name), - application = application + sampleName = getString(R.string.app_name) ) } } diff --git a/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/components/ComposeMapView.kt b/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/components/ComposeMapView.kt deleted file mode 100644 index 9c534c42d..000000000 --- a/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/components/ComposeMapView.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.manageoperationallayers.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.MapView - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun ComposeMapView( - modifier: Modifier = Modifier, - mapViewModel: MapViewModel -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // get the instance of the MapView state - val mapViewState = mapViewModel.mapViewState - // create and add MapView to the activity lifecycle - val mapView = createMapViewInstance(lifecycleOwner) - - // wrap the MapView as an AndroidView - AndroidView( - modifier = modifier, - factory = { mapView }, - // recomposes the MapView on changes in the MapViewState - update = { mapView -> - mapView.apply { - map = mapViewState.arcGISMap - setViewpoint(mapViewState.viewpoint) - } - } - ) -} - -/** - * Create the MapView instance and add it to the Activity lifecycle - */ -@Composable -fun createMapViewInstance(lifecycleOwner: LifecycleOwner): MapView { - // create the MapView - val mapView = MapView(LocalContext.current) - // add the side effects for MapView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(mapView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(mapView) - } - } - return mapView -} diff --git a/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/components/MapViewModel.kt b/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/components/MapViewModel.kt index 5520b74a5..b003eb943 100644 --- a/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/components/MapViewModel.kt +++ b/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/components/MapViewModel.kt @@ -17,10 +17,7 @@ package com.esri.arcgismaps.sample.manageoperationallayers.components import android.app.Application -import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateListOf -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue import androidx.lifecycle.AndroidViewModel import com.arcgismaps.mapping.ArcGISMap import com.arcgismaps.mapping.BasemapStyle @@ -33,8 +30,8 @@ class MapViewModel( application: Application ) : AndroidViewModel(application) { - // get an instance of the MapView state - val mapViewState = MapViewState() + // create an ArcGISMap + val arcGISMap: ArcGISMap = ArcGISMap(BasemapStyle.ArcGISTopographic) // a list of the active map image layer names var activateLayerNames = mutableStateListOf() @@ -65,7 +62,8 @@ class MapViewModel( ) // add the layers to the map's operational layers - mapViewState.arcGISMap.apply { + arcGISMap.apply { + initialViewpoint = Viewpoint(39.8, -98.6, 5e7) operationalLayers.addAll( listOf( imageLayerElevation, @@ -81,7 +79,7 @@ class MapViewModel( */ fun moveLayerUp(layerName: String) { // get a copy of the operational layers - val operationalLayers = mapViewState.arcGISMap.operationalLayers.toMutableList() + val operationalLayers = arcGISMap.operationalLayers.toMutableList() // if move up on the first item is selected, then return if (operationalLayers.first().name == layerName) { return @@ -96,7 +94,7 @@ class MapViewModel( addAll(operationalLayers.map { layer -> layer.name }) } // update the operational layers - mapViewState.arcGISMap.operationalLayers.apply { + arcGISMap.operationalLayers.apply { clear() addAll(operationalLayers) } @@ -107,7 +105,7 @@ class MapViewModel( */ fun moveLayerDown(layerName: String) { // get a copy of the operational layers - val operationalLayers = mapViewState.arcGISMap.operationalLayers.toMutableList() + val operationalLayers = arcGISMap.operationalLayers.toMutableList() // if move down on the last item is selected, then return if (operationalLayers.last().name == layerName) { return @@ -122,7 +120,7 @@ class MapViewModel( addAll(operationalLayers.map { layer -> layer.name }) } // update the operational layers - mapViewState.arcGISMap.operationalLayers.apply { + arcGISMap.operationalLayers.apply { clear() addAll(operationalLayers) } @@ -132,7 +130,7 @@ class MapViewModel( * Removes [layerName] from map and adds it to the list of [inactiveLayers]. */ fun removeLayerFromMap(layerName: String) { - mapViewState.arcGISMap.operationalLayers.apply { + arcGISMap.operationalLayers.apply { val layerIndex = indexOf(find { it.name == layerName }) inactiveLayers.add(get(layerIndex)) removeAt(layerIndex) @@ -146,22 +144,13 @@ class MapViewModel( fun addLayerToMap(layerName: String) { inactiveLayers.apply { val layerIndex = indexOf(find { it.name == layerName }) - mapViewState.arcGISMap.operationalLayers.add(get(layerIndex)) + arcGISMap.operationalLayers.add(get(layerIndex)) activateLayerNames.add(get(layerIndex).name) removeAt(layerIndex) } } } - -/** - * Class that represents the MapView state - */ -class MapViewState { - val arcGISMap: ArcGISMap = ArcGISMap(BasemapStyle.ArcGISTopographic) - val viewpoint: Viewpoint = Viewpoint(39.8, -98.6, 5e7) -} - /** * Extension function to swap two values of a mutable list. */ diff --git a/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/screens/MainScreen.kt b/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/screens/MainScreen.kt index 43f433bde..0d51f3467 100644 --- a/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/screens/MainScreen.kt +++ b/manage-operational-layers/src/main/java/com/esri/arcgismaps/sample/manageoperationallayers/screens/MainScreen.kt @@ -23,7 +23,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import com.esri.arcgismaps.sample.manageoperationallayers.components.ComposeMapView +import androidx.compose.ui.platform.LocalContext +import com.arcgismaps.toolkit.geoviewcompose.MapView import com.esri.arcgismaps.sample.manageoperationallayers.components.MapViewModel import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar @@ -31,9 +32,9 @@ import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { // create a ViewModel to handle MapView interactions - val mapViewModel = MapViewModel(application) + val mapViewModel = MapViewModel(LocalContext.current.applicationContext as Application) Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, @@ -41,10 +42,9 @@ fun MainScreen(sampleName: String, application: Application) { Column( modifier = Modifier.fillMaxSize().padding(it) ) { - // composable function that wraps the MapView - ComposeMapView( + MapView( modifier = Modifier.fillMaxSize().weight(1f), - mapViewModel = mapViewModel, + arcGISMap = mapViewModel.arcGISMap ) LayersList( activateLayerNames = mapViewModel.activateLayerNames, diff --git a/navigate-route/build.gradle b/navigate-route/build.gradle deleted file mode 100644 index cdb7e9adc..000000000 --- a/navigate-route/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.navigateroute" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.navigateroute' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/navigate-route/build.gradle.kts b/navigate-route/build.gradle.kts new file mode 100644 index 000000000..0b646c585 --- /dev/null +++ b/navigate-route/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.navigateroute" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.navigateroute" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/navigate-route/proguard-rules.pro b/navigate-route/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/navigate-route/proguard-rules.pro +++ b/navigate-route/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/play-kml-tour/build.gradle b/play-kml-tour/build.gradle deleted file mode 100644 index 9b31854a3..000000000 --- a/play-kml-tour/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.playkmltour" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.playkmltour' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation "androidx.appcompat:appcompat:$appcompatVersion" - implementation project(path: ':samples-lib') -} diff --git a/play-kml-tour/build.gradle.kts b/play-kml-tour/build.gradle.kts new file mode 100644 index 000000000..acb69f7fe --- /dev/null +++ b/play-kml-tour/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.playkmltour" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.playkmltour" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.androidx.appcompat) + implementation(project(":samples-lib")) +} diff --git a/play-kml-tour/proguard-rules.pro b/play-kml-tour/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/play-kml-tour/proguard-rules.pro +++ b/play-kml-tour/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/project-geometry/build.gradle b/project-geometry/build.gradle deleted file mode 100644 index f4bc838ce..000000000 --- a/project-geometry/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.projectgeometry" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.projectgeometry' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/project-geometry/build.gradle.kts b/project-geometry/build.gradle.kts new file mode 100644 index 000000000..6e4f41c03 --- /dev/null +++ b/project-geometry/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.projectgeometry" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.projectgeometry" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/project-geometry/proguard-rules.pro b/project-geometry/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/project-geometry/proguard-rules.pro +++ b/project-geometry/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/query-feature-table/README.md b/query-feature-table/README.md index 6267c55f9..521394257 100644 --- a/query-feature-table/README.md +++ b/query-feature-table/README.md @@ -30,6 +30,10 @@ Input the name of a U.S. state into the text field. When you click the search ic This sample uses U.S. State polygon features from the [USA 2016 Daytime Population](https://www.arcgis.com/home/item.html?id=f01f0eda766344e29f42031e7bfb7d04) feature service. +## Additional information + +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. + ## Tags -query, search +geoviewcompose, query, search, toolkit diff --git a/query-feature-table/README.metadata.json b/query-feature-table/README.metadata.json index 9dd8b7a4d..fb13a5153 100644 --- a/query-feature-table/README.metadata.json +++ b/query-feature-table/README.metadata.json @@ -7,8 +7,10 @@ "query-feature-table.png" ], "keywords": [ + "geoviewcompose", "query", "search", + "toolkit", "FeatureLayer", "FeatureQueryResult", "QueryParameters", @@ -24,7 +26,6 @@ ], "snippets": [ "src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/ComposeMapView.kt", "src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/MainScreen.kt", "src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/SearchBar.kt" diff --git a/query-feature-table/build.gradle b/query-feature-table/build.gradle deleted file mode 100644 index fd3bccaaa..000000000 --- a/query-feature-table/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.queryfeaturetable" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.queryfeaturetable' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/query-feature-table/build.gradle.kts b/query-feature-table/build.gradle.kts new file mode 100644 index 000000000..dcb034a7f --- /dev/null +++ b/query-feature-table/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.queryfeaturetable" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.queryfeaturetable" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/query-feature-table/proguard-rules.pro b/query-feature-table/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/query-feature-table/proguard-rules.pro +++ b/query-feature-table/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/MainActivity.kt b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/MainActivity.kt index f70086ffe..c1938f4b4 100644 --- a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/MainActivity.kt +++ b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/MainActivity.kt @@ -48,8 +48,7 @@ class MainActivity : ComponentActivity() { color = MaterialTheme.colorScheme.background ) { MainScreen( - sampleName = getString(R.string.app_name), - application = application + sampleName = getString(R.string.app_name) ) } } diff --git a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/ComposeMapView.kt b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/ComposeMapView.kt deleted file mode 100644 index f4b8e8178..000000000 --- a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/ComposeMapView.kt +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.queryfeaturetable.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.lifecycleScope -import com.arcgismaps.mapping.view.MapView -import kotlinx.coroutines.launch - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun ComposeMapView( - modifier: Modifier = Modifier, - mapViewModel: MapViewModel -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // get an instance of the MapView state - val mapViewState = mapViewModel.mapViewState - // create and add MapView to the activity lifecycle - val mapView = createMapViewInstance(lifecycleOwner) - - // wrap the MapView as an AndroidView - AndroidView( - modifier = modifier, - factory = { mapView }, - // recomposes the MapView on changes in the MapViewState - update = { mapView -> - mapView.apply { - map = mapViewState.arcGISMap - setViewpoint(mapViewState.initialViewpoint) - lifecycleOwner.lifecycleScope.launch { - mapViewState.stateGeometry?.let { setViewpointGeometry(it, 20.0) } - } - } - } - ) -} - -/** - * Create the MapView instance and add it to the Activity lifecycle - */ -@Composable -fun createMapViewInstance(lifecycleOwner: LifecycleOwner): MapView { - // create the MapView - val mapView = MapView(LocalContext.current) - // add the side effects for MapView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(mapView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(mapView) - } - } - return mapView -} diff --git a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt index 02f653538..8051ff1c5 100644 --- a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt +++ b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/components/MapViewModel.kt @@ -25,7 +25,6 @@ import com.arcgismaps.Color import com.arcgismaps.data.FeatureQueryResult import com.arcgismaps.data.QueryParameters import com.arcgismaps.data.ServiceFeatureTable -import com.arcgismaps.geometry.Geometry import com.arcgismaps.geometry.Point import com.arcgismaps.geometry.SpatialReference import com.arcgismaps.mapping.ArcGISMap @@ -37,6 +36,7 @@ import com.arcgismaps.mapping.symbology.SimpleFillSymbolStyle import com.arcgismaps.mapping.symbology.SimpleLineSymbol import com.arcgismaps.mapping.symbology.SimpleLineSymbolStyle import com.arcgismaps.mapping.symbology.SimpleRenderer +import com.arcgismaps.toolkit.geoviewcompose.MapViewProxy import com.esri.arcgismaps.sample.queryfeaturetable.R import com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModel import kotlinx.coroutines.CoroutineScope @@ -44,13 +44,10 @@ import kotlinx.coroutines.launch import java.util.Locale class MapViewModel( - private val application: Application, + application: Application, private val sampleCoroutineScope: CoroutineScope ) : AndroidViewModel(application) { - // get an instance of the MapView state - val mapViewState = MapViewState() - // create a ViewModel to handle dialog interactions val messageDialogVM: MessageDialogViewModel = MessageDialogViewModel() @@ -64,6 +61,17 @@ class MapViewModel( FeatureLayer.createWithFeatureTable(serviceFeatureTable) } + // map used to display the feature layer + val map = ArcGISMap(BasemapStyle.ArcGISTopographic) + + private var usaViewpoint = Viewpoint( + center = Point(-11e6, 5e6, SpatialReference.webMercator()), + scale = 1e8 + ) + + // create a MapViewProxy to handle MapView operations + var mapViewProxy by mutableStateOf(MapViewProxy()) + init { // use symbols to show U.S. states with a black outline and yellow fill val lineSymbol = SimpleLineSymbol( @@ -77,6 +85,7 @@ class MapViewModel( outline = lineSymbol ) + // set featurelayer properties featureLayer.apply { // set renderer for the feature layer renderer = SimpleRenderer(fillSymbol) @@ -84,7 +93,10 @@ class MapViewModel( maxScale = 10000.0 } // add the feature layer to the map's operational layers - mapViewState.arcGISMap.operationalLayers.add(featureLayer) + map.apply { + initialViewpoint = usaViewpoint + operationalLayers.add(featureLayer) + } } /** @@ -113,28 +125,11 @@ class MapViewModel( // get the extent of the first feature in the result to zoom to val envelope = feature.geometry?.extent ?: return@launch messageDialogVM.showMessageDialog("Error retrieving geometry extent") - // update the map view to set the viewpoint to the state geometry - mapViewState.stateGeometry = envelope + // update the map's viewpoint to the feature's geometry + mapViewProxy.setViewpointGeometry(envelope) } else { messageDialogVM.showMessageDialog("No states found with name: $searchQuery") } } } } - -/** - * Class that represents the MapView state - */ -class MapViewState { - // map used to display the feature layer - var arcGISMap: ArcGISMap by mutableStateOf(ArcGISMap(BasemapStyle.ArcGISTopographic)) - - // geometry of the queried state - var stateGeometry: Geometry? by mutableStateOf(null) - - // set an initial viewpoint over the USA - val initialViewpoint: Viewpoint = Viewpoint( - center = Point(-11e6, 5e6, SpatialReference.webMercator()), - scale = 1e8 - ) -} diff --git a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/MainScreen.kt b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/MainScreen.kt index 8ab3b3253..7d25fb53c 100644 --- a/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/MainScreen.kt +++ b/query-feature-table/src/main/java/com/esri/arcgismaps/sample/queryfeaturetable/screens/MainScreen.kt @@ -26,7 +26,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import com.esri.arcgismaps.sample.queryfeaturetable.components.ComposeMapView +import androidx.compose.ui.platform.LocalContext +import com.arcgismaps.toolkit.geoviewcompose.MapView import com.esri.arcgismaps.sample.queryfeaturetable.components.MapViewModel import com.esri.arcgismaps.sample.sampleslib.components.MessageDialog import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar @@ -35,20 +36,27 @@ import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { // coroutineScope that will be cancelled when this call leaves the composition val sampleCoroutineScope = rememberCoroutineScope() + // get the application context + val application = LocalContext.current.applicationContext as Application // create a ViewModel to handle MapView interactions val mapViewModel = remember { MapViewModel(application, sampleCoroutineScope) } Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, content = { - Column(modifier = Modifier.fillMaxSize().padding(it)) { + Column(modifier = Modifier + .fillMaxSize() + .padding(it)) { // composable function that wraps the MapView - ComposeMapView( - modifier = Modifier.fillMaxWidth().weight(1f), - mapViewModel = mapViewModel + MapView( + modifier = Modifier + .fillMaxWidth() + .weight(1f), + arcGISMap = mapViewModel.map, + mapViewProxy = mapViewModel.mapViewProxy ) SearchBar( modifier = Modifier.fillMaxWidth(), diff --git a/query-features-with-arcade-expression/build.gradle b/query-features-with-arcade-expression/build.gradle deleted file mode 100644 index 95220cddd..000000000 --- a/query-features-with-arcade-expression/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.queryfeatureswitharcadeexpression" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.queryfeatureswitharcadeexpression' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/query-features-with-arcade-expression/build.gradle.kts b/query-features-with-arcade-expression/build.gradle.kts new file mode 100644 index 000000000..d524e8465 --- /dev/null +++ b/query-features-with-arcade-expression/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.queryfeatureswitharcadeexpression" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.queryfeatureswitharcadeexpression" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/query-features-with-arcade-expression/proguard-rules.pro b/query-features-with-arcade-expression/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/query-features-with-arcade-expression/proguard-rules.pro +++ b/query-features-with-arcade-expression/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/render-multilayer-symbols/build.gradle b/render-multilayer-symbols/build.gradle deleted file mode 100644 index b22314f43..000000000 --- a/render-multilayer-symbols/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.rendermultilayersymbols" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.rendermultilayersymbols' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/render-multilayer-symbols/build.gradle.kts b/render-multilayer-symbols/build.gradle.kts new file mode 100644 index 000000000..c85164204 --- /dev/null +++ b/render-multilayer-symbols/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.rendermultilayersymbols" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.rendermultilayersymbols" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/render-multilayer-symbols/proguard-rules.pro b/render-multilayer-symbols/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/render-multilayer-symbols/proguard-rules.pro +++ b/render-multilayer-symbols/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/samples-lib/build.gradle b/samples-lib/build.gradle deleted file mode 100644 index a875c628a..000000000 --- a/samples-lib/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - consumerProguardFiles "consumer-rules.pro" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.sampleslib' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation "commons-io:commons-io:2.11.0" - - // lib dependencies for samples using Jetpack Compose - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" -} diff --git a/samples-lib/build.gradle.kts b/samples-lib/build.gradle.kts new file mode 100644 index 000000000..5bf54b61f --- /dev/null +++ b/samples-lib/build.gradle.kts @@ -0,0 +1,50 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + minSdk = libs.versions.minSdk.get().toInt() + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.sampleslib" +} + +dependencies { + // lib dependencies from rootProject build.gradle + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.commons.io) + // lib dependencies for samples using Jetpack Compose + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) +} + diff --git a/samples-lib/proguard-rules.pro b/samples-lib/proguard-rules.pro index 481bb4348..ff59496d8 100644 --- a/samples-lib/proguard-rules.pro +++ b/samples-lib/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/samples-lib/src/main/java/com/esri/arcgismaps/sample/sampleslib/DownloaderActivity.kt b/samples-lib/src/main/java/com/esri/arcgismaps/sample/sampleslib/DownloaderActivity.kt index 75935db8d..68fbe8e0d 100644 --- a/samples-lib/src/main/java/com/esri/arcgismaps/sample/sampleslib/DownloaderActivity.kt +++ b/samples-lib/src/main/java/com/esri/arcgismaps/sample/sampleslib/DownloaderActivity.kt @@ -33,7 +33,6 @@ import com.google.android.material.progressindicator.LinearProgressIndicator import com.google.android.material.snackbar.Snackbar import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.flatMapMerge @@ -49,7 +48,7 @@ import java.util.zip.ZipEntry import java.util.zip.ZipInputStream import kotlin.math.roundToInt -@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class) +@OptIn(ExperimentalCoroutinesApi::class) abstract class DownloaderActivity : AppCompatActivity() { /** diff --git a/samples-lib/src/main/java/com/esri/arcgismaps/sample/sampleslib/components/BottomSheet.kt b/samples-lib/src/main/java/com/esri/arcgismaps/sample/sampleslib/components/BottomSheet.kt index fa2e5985f..6e8648d14 100644 --- a/samples-lib/src/main/java/com/esri/arcgismaps/sample/sampleslib/components/BottomSheet.kt +++ b/samples-lib/src/main/java/com/esri/arcgismaps/sample/sampleslib/components/BottomSheet.kt @@ -35,7 +35,7 @@ import androidx.compose.ui.Modifier @Composable fun BottomSheet( isVisible: Boolean, - bottomSheetContent: @Composable() () -> Unit + bottomSheetContent: @Composable () -> Unit ) { BoxWithConstraints( modifier = Modifier.fillMaxSize() diff --git a/search-with-geocode/build.gradle b/search-with-geocode/build.gradle deleted file mode 100644 index cf8e3d084..000000000 --- a/search-with-geocode/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.searchwithgeocode" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.searchwithgeocode' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/search-with-geocode/build.gradle.kts b/search-with-geocode/build.gradle.kts new file mode 100644 index 000000000..a5b5979bb --- /dev/null +++ b/search-with-geocode/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.searchwithgeocode" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.searchwithgeocode" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/search-with-geocode/proguard-rules.pro b/search-with-geocode/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/search-with-geocode/proguard-rules.pro +++ b/search-with-geocode/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/search-with-geocode/src/main/java/com/esri/arcgismaps/sample/searchwithgeocode/MainActivity.kt b/search-with-geocode/src/main/java/com/esri/arcgismaps/sample/searchwithgeocode/MainActivity.kt index 8d9d1c484..ff823fd9d 100644 --- a/search-with-geocode/src/main/java/com/esri/arcgismaps/sample/searchwithgeocode/MainActivity.kt +++ b/search-with-geocode/src/main/java/com/esri/arcgismaps/sample/searchwithgeocode/MainActivity.kt @@ -47,7 +47,6 @@ import com.arcgismaps.mapping.view.ScreenCoordinate import com.arcgismaps.tasks.geocode.GeocodeParameters import com.arcgismaps.tasks.geocode.GeocodeResult import com.arcgismaps.tasks.geocode.LocatorTask -import com.arcgismaps.tasks.geocode.SuggestResult import com.esri.arcgismaps.sample.searchwithgeocode.databinding.ActivityMainBinding import com.google.android.material.snackbar.Snackbar import com.google.android.material.switchmaterial.SwitchMaterial @@ -170,7 +169,7 @@ class MainActivity : AppCompatActivity() { // add each address suggestion to a new row for ((key, result) in suggestResults.withIndex()) { - var suggestionCursor = simpleCursorAdapter.cursor as MatrixCursor + val suggestionCursor = simpleCursorAdapter.cursor as MatrixCursor suggestionCursor.addRow(arrayOf(key, result.label)) } // notify the adapter when the data updates, so the view can refresh itself diff --git a/select-features-in-feature-layer/build.gradle b/select-features-in-feature-layer/build.gradle deleted file mode 100644 index f81d71422..000000000 --- a/select-features-in-feature-layer/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.selectfeaturesinfeaturelayer" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.selectfeaturesinfeaturelayer' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/select-features-in-feature-layer/build.gradle.kts b/select-features-in-feature-layer/build.gradle.kts new file mode 100644 index 000000000..67163138b --- /dev/null +++ b/select-features-in-feature-layer/build.gradle.kts @@ -0,0 +1,37 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.selectfeaturesinfeaturelayer" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.selectfeaturesinfeaturelayer" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/select-features-in-feature-layer/proguard-rules.pro b/select-features-in-feature-layer/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/select-features-in-feature-layer/proguard-rules.pro +++ b/select-features-in-feature-layer/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/set-max-extent/build.gradle b/set-max-extent/build.gradle deleted file mode 100644 index bf92fae98..000000000 --- a/set-max-extent/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.setmaxextent" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.setmaxextent' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/set-max-extent/build.gradle.kts b/set-max-extent/build.gradle.kts new file mode 100644 index 000000000..98a7e8632 --- /dev/null +++ b/set-max-extent/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.setmaxextent" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.setmaxextent" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/set-max-extent/proguard-rules.pro b/set-max-extent/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/set-max-extent/proguard-rules.pro +++ b/set-max-extent/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/set-up-location-driven-geotriggers/build.gradle b/set-up-location-driven-geotriggers/build.gradle deleted file mode 100644 index 9ca238199..000000000 --- a/set-up-location-driven-geotriggers/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.setuplocationdrivengeotriggers" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.setuplocationdrivengeotriggers' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/set-up-location-driven-geotriggers/build.gradle.kts b/set-up-location-driven-geotriggers/build.gradle.kts new file mode 100644 index 000000000..7ddfc8d63 --- /dev/null +++ b/set-up-location-driven-geotriggers/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.setuplocationdrivengeotriggers" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.setuplocationdrivengeotriggers" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/set-up-location-driven-geotriggers/proguard-rules.pro b/set-up-location-driven-geotriggers/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/set-up-location-driven-geotriggers/proguard-rules.pro +++ b/set-up-location-driven-geotriggers/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/set-viewpoint-rotation/build.gradle b/set-viewpoint-rotation/build.gradle deleted file mode 100644 index 93c40943f..000000000 --- a/set-viewpoint-rotation/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.setviewpointrotation" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.setviewpointrotation' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/set-viewpoint-rotation/build.gradle.kts b/set-viewpoint-rotation/build.gradle.kts new file mode 100644 index 000000000..a3c62a8af --- /dev/null +++ b/set-viewpoint-rotation/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.setviewpointrotation" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.setviewpointrotation" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/set-viewpoint-rotation/proguard-rules.pro b/set-viewpoint-rotation/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/set-viewpoint-rotation/proguard-rules.pro +++ b/set-viewpoint-rotation/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/settings.gradle b/settings.gradle.kts similarity index 51% rename from settings.gradle rename to settings.gradle.kts index 71a54f2df..929411bac 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -6,17 +6,18 @@ pluginManagement { } } dependencyResolutionManagement { + @Suppress("UnstableApiUsage") repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + @Suppress("UnstableApiUsage") repositories { google() mavenCentral() - maven { url 'https://esri.jfrog.io/artifactory/arcgis' } + maven { url = uri("https://esri.jfrog.io/artifactory/arcgis") } } } -// dynamically include all samples -rootDir.listFiles().each { - if (it.directory && new File(it, 'build.gradle').exists()) { - include ":${it.name}" +rootDir.listFiles()?.forEach { + if (it.isDirectory && File(it, "build.gradle.kts").exists()) { + include(":${it.name}") } } diff --git a/show-callout/build.gradle b/show-callout/build.gradle deleted file mode 100644 index acdf36f1f..000000000 --- a/show-callout/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showcallout" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.showcallout' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/show-callout/build.gradle.kts b/show-callout/build.gradle.kts new file mode 100644 index 000000000..ee2d6d6aa --- /dev/null +++ b/show-callout/build.gradle.kts @@ -0,0 +1,51 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showcallout" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.showcallout" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) +} diff --git a/show-callout/proguard-rules.pro b/show-callout/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-callout/proguard-rules.pro +++ b/show-callout/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-coordinates-in-multiple-formats/README.md b/show-coordinates-in-multiple-formats/README.md index ec4d846ab..8c5dea6f7 100644 --- a/show-coordinates-in-multiple-formats/README.md +++ b/show-coordinates-in-multiple-formats/README.md @@ -24,6 +24,10 @@ Tap on the map to see a marker with the tapped location's coordinate formatted i * CoordinateFormatter.LatitudeLongitudeFormat * CoordinateFormatter.UtmConversionMode +## Additional information + +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. + ## Tags -convert, coordinate, decimal degrees, degree minutes seconds, format, latitude, longitude, USNG, UTM +convert, coordinate, decimal degrees, degree minutes seconds, format, geoviewcompose, latitude, longitude, toolkit, USNG, UTM diff --git a/show-coordinates-in-multiple-formats/README.metadata.json b/show-coordinates-in-multiple-formats/README.metadata.json index a7d84439b..e3af54d48 100644 --- a/show-coordinates-in-multiple-formats/README.metadata.json +++ b/show-coordinates-in-multiple-formats/README.metadata.json @@ -14,8 +14,10 @@ "decimal degrees", "degree minutes seconds", "format", + "geoviewcompose", "latitude", "longitude", + "toolkit", "CoordinateFormatter", "CoordinateFormatter.LatitudeLongitudeFormat", "CoordinateFormatter.UtmConversionMode" @@ -29,7 +31,6 @@ ], "snippets": [ "src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/components/ComposeMapView.kt", "src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/components/MapViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/screens/CoordinatesLayout.kt", "src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/screens/MainScreen.kt" diff --git a/show-coordinates-in-multiple-formats/build.gradle b/show-coordinates-in-multiple-formats/build.gradle deleted file mode 100644 index 883bd6517..000000000 --- a/show-coordinates-in-multiple-formats/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showcoordinatesinmultipleformats" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.showcoordinatesinmultipleformats' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/show-coordinates-in-multiple-formats/build.gradle.kts b/show-coordinates-in-multiple-formats/build.gradle.kts new file mode 100644 index 000000000..3871724f4 --- /dev/null +++ b/show-coordinates-in-multiple-formats/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showcoordinatesinmultipleformats" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.showcoordinatesinmultipleformats" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/show-coordinates-in-multiple-formats/proguard-rules.pro b/show-coordinates-in-multiple-formats/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-coordinates-in-multiple-formats/proguard-rules.pro +++ b/show-coordinates-in-multiple-formats/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/components/ComposeMapView.kt b/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/components/ComposeMapView.kt deleted file mode 100644 index f91491bf4..000000000 --- a/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/components/ComposeMapView.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.showcoordinatesinmultipleformats.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.MapView -import com.arcgismaps.mapping.view.SingleTapConfirmedEvent -import kotlinx.coroutines.launch - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun ComposeMapView( - modifier: Modifier = Modifier, - mapViewModel: MapViewModel, - onSingleTap: (SingleTapConfirmedEvent) -> Unit = {} -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // get an instance of the ViewModel's MapViewState - val mapViewState = mapViewModel.mapViewState - // create and add MapView to the activity lifecycle - val mapView = createMapViewInstance(lifecycleOwner) - - // wrap the MapView as an AndroidView - AndroidView( - modifier = modifier, - factory = { mapView }, - // recomposes the MapView on changes in the MapViewState - update = { mapView -> - mapView.apply { - map = mapViewState.arcGISMap - mapView.graphicsOverlays.clear() - mapView.graphicsOverlays.add(mapViewState.graphicsOverlay) - } - } - ) - - // launch coroutine functions in the composition's CoroutineContext - LaunchedEffect(Unit) { - launch { - mapView.onSingleTapConfirmed.collect { - onSingleTap(it) - } - } - } -} - -/** - * Create the MapView instance and add it to the Activity lifecycle - */ -@Composable -fun createMapViewInstance(lifecycleOwner: LifecycleOwner): MapView { - // create the MapView - val mapView = MapView(LocalContext.current) - // add the side effects for MapView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(mapView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(mapView) - } - } - return mapView -} diff --git a/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/components/MapViewModel.kt b/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/components/MapViewModel.kt index f87589128..4869b23c1 100644 --- a/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/components/MapViewModel.kt +++ b/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/components/MapViewModel.kt @@ -27,20 +27,12 @@ import com.arcgismaps.geometry.LatitudeLongitudeFormat import com.arcgismaps.geometry.Point import com.arcgismaps.geometry.SpatialReference import com.arcgismaps.geometry.UtmConversionMode -import com.arcgismaps.mapping.ArcGISMap -import com.arcgismaps.mapping.Basemap -import com.arcgismaps.mapping.BasemapStyle -import com.arcgismaps.mapping.layers.ArcGISTiledLayer import com.arcgismaps.mapping.symbology.SimpleMarkerSymbol import com.arcgismaps.mapping.symbology.SimpleMarkerSymbolStyle import com.arcgismaps.mapping.view.Graphic -import com.arcgismaps.mapping.view.GraphicsOverlay import com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModel -import com.esri.arcgismaps.sample.showcoordinatesinmultipleformats.R class MapViewModel(application: Application) : AndroidViewModel(application) { - // set the MapView state - val mapViewState = MapViewState() var decimalDegrees by mutableStateOf("") private set @@ -53,10 +45,13 @@ class MapViewModel(application: Application) : AndroidViewModel(application) { var usng by mutableStateOf("") private set + // create a ViewModel to handle dialog interactions + val messageDialogVM: MessageDialogViewModel = MessageDialogViewModel() + // set up a graphic to indicate where the coordinates relate to, with an initial location - private val initialPoint = Point(0.0, 0.0, SpatialReference.wgs84()) + val initialPoint = Point(0.0, 0.0, SpatialReference.wgs84()) - private val coordinateLocation = Graphic( + val coordinateLocationGraphic = Graphic( geometry = initialPoint, symbol = SimpleMarkerSymbol( style = SimpleMarkerSymbolStyle.Cross, @@ -65,42 +60,12 @@ class MapViewModel(application: Application) : AndroidViewModel(application) { ) ) - // create a ViewModel to handle dialog interactions - val messageDialogVM: MessageDialogViewModel = MessageDialogViewModel() - - init { - // create a map that has the WGS 84 coordinate system and set this into the map - val basemapLayer = ArcGISTiledLayer(application.getString(R.string.basemap_url)) - val map = ArcGISMap(Basemap(basemapLayer)) - mapViewState.arcGISMap = map - mapViewState.graphicsOverlay.graphics.add(coordinateLocation) - - // update the coordinate notations using the initial point - toCoordinateNotationFromPoint(initialPoint) - } - - /** - * Updates the tapped graphic and coordinate notations using the [tappedPoint] - */ - fun onMapTapped(tappedPoint: Point?) { - if (tappedPoint != null) { - // update the tapped location graphic - coordinateLocation.geometry = tappedPoint - mapViewState.graphicsOverlay.graphics.apply { - clear() - add(coordinateLocation) - } - // update the coordinate notations using the tapped point - toCoordinateNotationFromPoint(tappedPoint) - } - } - /** * Uses CoordinateFormatter to update the UI with coordinate notation strings based on the * given [newLocation] point to convert to coordinate notations */ - private fun toCoordinateNotationFromPoint(newLocation: Point) { - coordinateLocation.geometry = newLocation + fun toCoordinateNotationFromPoint(newLocation: Point) { + coordinateLocationGraphic.geometry = newLocation // use CoordinateFormatter to convert to Latitude Longitude, formatted as Decimal Degrees decimalDegrees = CoordinateFormatter.toLatitudeLongitudeOrNull( point = newLocation, @@ -206,11 +171,3 @@ class MapViewModel(application: Application) : AndroidViewModel(application) { usng = inputString } } - -/** - * Class that represents the MapView's current state - */ -class MapViewState { - var arcGISMap: ArcGISMap by mutableStateOf(ArcGISMap(BasemapStyle.ArcGISNavigationNight)) - var graphicsOverlay: GraphicsOverlay by mutableStateOf(GraphicsOverlay()) -} diff --git a/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/screens/MainScreen.kt b/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/screens/MainScreen.kt index 037cefe92..d2b9bbcb5 100644 --- a/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/screens/MainScreen.kt +++ b/show-coordinates-in-multiple-formats/src/main/java/com/esri/arcgismaps/sample/showcoordinatesinmultipleformats/screens/MainScreen.kt @@ -21,11 +21,18 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.lifecycle.viewmodel.compose.viewModel +import com.arcgismaps.mapping.ArcGISMap +import com.arcgismaps.mapping.Basemap +import com.arcgismaps.mapping.layers.ArcGISTiledLayer +import com.arcgismaps.mapping.view.GraphicsOverlay +import com.arcgismaps.toolkit.geoviewcompose.MapView import com.esri.arcgismaps.sample.sampleslib.components.MessageDialog import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar -import com.esri.arcgismaps.sample.showcoordinatesinmultipleformats.components.ComposeMapView +import com.esri.arcgismaps.sample.showcoordinatesinmultipleformats.R import com.esri.arcgismaps.sample.showcoordinatesinmultipleformats.components.MapViewModel /** @@ -35,21 +42,45 @@ import com.esri.arcgismaps.sample.showcoordinatesinmultipleformats.components.Ma fun MainScreen(sampleName: String) { // create a ViewModel to handle MapView interactions val mapViewModel: MapViewModel = viewModel() + // create a map that has the WGS 84 coordinate system and set this into the map + val basemapLayer = ArcGISTiledLayer(LocalContext.current.applicationContext.getString(R.string.basemap_url)) + val arcGISMap = ArcGISMap(Basemap(basemapLayer)) + // graphics overlay to display a graphics of the coordinate location + val graphicsOverlay = GraphicsOverlay().apply { + graphics.add(mapViewModel.coordinateLocationGraphic) + } + // the collection of graphics overlays used by the MapView + val graphicsOverlays = remember { listOf(graphicsOverlay) } + // update the coordinate notations using the initial point + mapViewModel.toCoordinateNotationFromPoint(mapViewModel.initialPoint) Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, content = { Column( - modifier = Modifier.fillMaxSize().padding(it) + modifier = Modifier + .fillMaxSize() + .padding(it) ) { // layout to display the coordinate text fields. CoordinatesLayout(mapViewModel = mapViewModel) - // composable function that wraps the MapView - ComposeMapView( + MapView( modifier = Modifier.fillMaxSize(), - mapViewModel = mapViewModel, - onSingleTap = { singleTapConfirmedEvent -> - mapViewModel.onMapTapped(singleTapConfirmedEvent.mapPoint) + arcGISMap = arcGISMap, + graphicsOverlays = graphicsOverlays, + onSingleTapConfirmed = { singleTapConfirmedEvent -> + // retrieve the map point on MapView tapped + val tappedPoint = singleTapConfirmedEvent.mapPoint + if (tappedPoint != null) { + // update the tapped location graphic + mapViewModel.coordinateLocationGraphic.geometry = tappedPoint + graphicsOverlay.graphics.apply { + clear() + add(mapViewModel.coordinateLocationGraphic) + } + // update the coordinate notations using the tapped point + mapViewModel.toCoordinateNotationFromPoint(tappedPoint) + } } ) diff --git a/show-device-location-using-indoor-positioning/build.gradle b/show-device-location-using-indoor-positioning/build.gradle deleted file mode 100644 index 58df1ece5..000000000 --- a/show-device-location-using-indoor-positioning/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showdevicelocationusingindoorpositioning" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.showdevicelocationusingindoorpositioning' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/show-device-location-using-indoor-positioning/build.gradle.kts b/show-device-location-using-indoor-positioning/build.gradle.kts new file mode 100644 index 000000000..e5612342b --- /dev/null +++ b/show-device-location-using-indoor-positioning/build.gradle.kts @@ -0,0 +1,37 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showdevicelocationusingindoorpositioning" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.showdevicelocationusingindoorpositioning" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/show-device-location-using-indoor-positioning/proguard-rules.pro b/show-device-location-using-indoor-positioning/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-device-location-using-indoor-positioning/proguard-rules.pro +++ b/show-device-location-using-indoor-positioning/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-device-location/build.gradle b/show-device-location/build.gradle deleted file mode 100644 index f69994f52..000000000 --- a/show-device-location/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showdevicelocation" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.showdevicelocation' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/show-device-location/build.gradle.kts b/show-device-location/build.gradle.kts new file mode 100644 index 000000000..b4684c302 --- /dev/null +++ b/show-device-location/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showdevicelocation" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.showdevicelocation" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/show-device-location/proguard-rules.pro b/show-device-location/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-device-location/proguard-rules.pro +++ b/show-device-location/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-geodesic-path-between-two-points/build.gradle b/show-geodesic-path-between-two-points/build.gradle deleted file mode 100644 index 16cc82052..000000000 --- a/show-geodesic-path-between-two-points/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showgeodesicpathbetweentwopoints" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.showgeodesicpathbetweentwopoints' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/show-geodesic-path-between-two-points/build.gradle.kts b/show-geodesic-path-between-two-points/build.gradle.kts new file mode 100644 index 000000000..7574f23f5 --- /dev/null +++ b/show-geodesic-path-between-two-points/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showgeodesicpathbetweentwopoints" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.showgeodesicpathbetweentwopoints" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/show-geodesic-path-between-two-points/proguard-rules.pro b/show-geodesic-path-between-two-points/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-geodesic-path-between-two-points/proguard-rules.pro +++ b/show-geodesic-path-between-two-points/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-grid/build.gradle b/show-grid/build.gradle deleted file mode 100644 index f3eaef5a4..000000000 --- a/show-grid/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showgrid" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.showgrid' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/show-grid/build.gradle.kts b/show-grid/build.gradle.kts new file mode 100644 index 000000000..e6465a3d9 --- /dev/null +++ b/show-grid/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showgrid" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.showgrid" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/show-grid/proguard-rules.pro b/show-grid/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-grid/proguard-rules.pro +++ b/show-grid/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-labels-on-layer/build.gradle b/show-labels-on-layer/build.gradle deleted file mode 100644 index 6f7c2d7b7..000000000 --- a/show-labels-on-layer/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showlabelsonlayer" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.showlabelsonlayer' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/show-labels-on-layer/build.gradle.kts b/show-labels-on-layer/build.gradle.kts new file mode 100644 index 000000000..478620740 --- /dev/null +++ b/show-labels-on-layer/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showlabelsonlayer" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.showlabelsonlayer" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/show-labels-on-layer/proguard-rules.pro b/show-labels-on-layer/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-labels-on-layer/proguard-rules.pro +++ b/show-labels-on-layer/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-location-history/README.md b/show-location-history/README.md index 38a02e0e0..5e4681624 100644 --- a/show-location-history/README.md +++ b/show-location-history/README.md @@ -17,7 +17,7 @@ Tap anywhere on the screen to start tracking your location, which will appear as 1. Create a graphics overlay to show each point and another graphics overlay to display the route polyline. 2. Create a `SimulatedLocationDataSource` and initialize it with a polyline. Start the `SimulatedLocationDataSource` to begin receiving location updates. 3. Use `LocationChanged` on the `simulatedLocationDataSource` to get location updates. -4. On location updates, store that location, display the location as a point on the map, and recreate the route polyline.:q +4. On location updates, store that location, display the location as a point on the map, and recreate the route polyline. ## Relevant API diff --git a/show-location-history/build.gradle b/show-location-history/build.gradle deleted file mode 100644 index 19c4a24ee..000000000 --- a/show-location-history/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showlocationhistory" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.showlocationhistory' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/show-location-history/build.gradle.kts b/show-location-history/build.gradle.kts new file mode 100644 index 000000000..c0fdf4a72 --- /dev/null +++ b/show-location-history/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showlocationhistory" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.showlocationhistory" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/show-location-history/proguard-rules.pro b/show-location-history/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-location-history/proguard-rules.pro +++ b/show-location-history/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-magnifier/README.md b/show-magnifier/README.md index ec7f16628..cf2cc102c 100644 --- a/show-magnifier/README.md +++ b/show-magnifier/README.md @@ -22,13 +22,13 @@ Tap and hold on the map to show a magnifier, then drag across the map to move th * ArcGISMap * MapView -* MapView.interactionOptions.allowMagnifierToPan * MapView.interactionOptions.isMagnifierEnabled ## Additional information -This sample only works on a device with a touch screen. The magnifier will not appear via a mouse click. +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. +It only works on a device with a touch screen. The magnifier will not appear via a mouse click. ## Tags -magnify, map, zoom +geoviewcompose, magnify, map, toolkit, zoom diff --git a/show-magnifier/README.metadata.json b/show-magnifier/README.metadata.json index d41c5fcea..44d2f3be7 100644 --- a/show-magnifier/README.metadata.json +++ b/show-magnifier/README.metadata.json @@ -7,12 +7,13 @@ "show-magnifier.png" ], "keywords": [ + "geoviewcompose", "magnify", "map", + "toolkit", "zoom", "ArcGISMap", "MapView", - "MapView.interactionOptions.allowMagnifierToPan", "MapView.interactionOptions.isMagnifierEnabled" ], "language": "kotlin", @@ -20,13 +21,10 @@ "relevant_apis": [ "ArcGISMap", "MapView", - "MapView.interactionOptions.allowMagnifierToPan", "MapView.interactionOptions.isMagnifierEnabled" ], "snippets": [ "src/main/java/com/esri/arcgismaps/sample/showmagnifier/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/showmagnifier/components/ComposeMapView.kt", - "src/main/java/com/esri/arcgismaps/sample/showmagnifier/components/MapViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/showmagnifier/screens/MainScreen.kt" ], "title": "Show magnifier" diff --git a/show-magnifier/build.gradle b/show-magnifier/build.gradle deleted file mode 100644 index 3274d5df6..000000000 --- a/show-magnifier/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showmagnifier" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.showmagnifier' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/show-magnifier/build.gradle.kts b/show-magnifier/build.gradle.kts new file mode 100644 index 000000000..bd2845d89 --- /dev/null +++ b/show-magnifier/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showmagnifier" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.showmagnifier" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/show-magnifier/proguard-rules.pro b/show-magnifier/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-magnifier/proguard-rules.pro +++ b/show-magnifier/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/MainActivity.kt b/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/MainActivity.kt index a0b665732..2c8416c74 100644 --- a/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/MainActivity.kt +++ b/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/MainActivity.kt @@ -48,8 +48,7 @@ class MainActivity : ComponentActivity() { color = MaterialTheme.colorScheme.background ) { MainScreen( - sampleName = getString(R.string.app_name), - application = application + sampleName = getString(R.string.app_name) ) } } diff --git a/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/components/ComposeMapView.kt b/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/components/ComposeMapView.kt deleted file mode 100644 index 66e95e015..000000000 --- a/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/components/ComposeMapView.kt +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.showmagnifier.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.MapView - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun ComposeMapView( - modifier: Modifier = Modifier, - mapViewModel: MapViewModel -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // get an instance of the MapView state - val mapViewState = mapViewModel.mapViewState - // create and add MapView to the activity lifecycle - val mapView = createMapViewInstance(lifecycleOwner) - - // wrap the MapView as an AndroidView - AndroidView( - modifier = modifier, - factory = { mapView }, - // recomposes the MapView on changes in the MapViewState - update = { mapView -> - mapView.apply { - map = mapViewState.arcGISMap - setViewpoint(mapViewState.viewpoint) - // set the MapView's interaction options using the MapViewState - mapViewState.interactionOptions.apply { - interactionOptions.isMagnifierEnabled = isMagnifierEnabled - interactionOptions.allowMagnifierToPan = allowMagnifierToPan - } - } - } - ) -} - -/** - * Create the MapView instance and add it to the Activity lifecycle - */ -@Composable -fun createMapViewInstance(lifecycleOwner: LifecycleOwner): MapView { - // create the MapView - val mapView = MapView(LocalContext.current) - // add the side effects for MapView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(mapView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(mapView) - } - } - return mapView -} diff --git a/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/components/MapViewModel.kt b/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/components/MapViewModel.kt deleted file mode 100644 index f92e11575..000000000 --- a/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/components/MapViewModel.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.showmagnifier.components - -import android.app.Application -import androidx.lifecycle.AndroidViewModel -import com.arcgismaps.mapping.ArcGISMap -import com.arcgismaps.mapping.BasemapStyle -import com.arcgismaps.mapping.Viewpoint -import com.arcgismaps.mapping.view.MapViewInteractionOptions - -class MapViewModel(application: Application) : AndroidViewModel(application) { - // get an instance of the MapView state - val mapViewState = MapViewState() -} - -/** - * Class that represents the MapView's current state - */ -class MapViewState { - val arcGISMap: ArcGISMap = ArcGISMap(BasemapStyle.ArcGISTopographic) - val viewpoint: Viewpoint = Viewpoint(34.056295, -117.195800, 1000000.0) - // setting `isMagnifierEnabled` property to true. `allowMagnifierToPan` by default is true - val interactionOptions: MapViewInteractionOptions = MapViewInteractionOptions( - isMagnifierEnabled = true - ) -} - diff --git a/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/screens/MainScreen.kt b/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/screens/MainScreen.kt index e60eb1b7f..a86edfd1d 100644 --- a/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/screens/MainScreen.kt +++ b/show-magnifier/src/main/java/com/esri/arcgismaps/sample/showmagnifier/screens/MainScreen.kt @@ -16,35 +16,37 @@ package com.esri.arcgismaps.sample.showmagnifier.screens -import android.app.Application -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import com.arcgismaps.mapping.ArcGISMap +import com.arcgismaps.mapping.BasemapStyle +import com.arcgismaps.mapping.Viewpoint +import com.arcgismaps.mapping.view.MapViewInteractionOptions +import com.arcgismaps.toolkit.geoviewcompose.MapView import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar -import com.esri.arcgismaps.sample.showmagnifier.components.ComposeMapView -import com.esri.arcgismaps.sample.showmagnifier.components.MapViewModel /** * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { - // create a ViewModel to handle MapView interactions - var mapViewModel = MapViewModel(application) +fun MainScreen(sampleName: String) { + // Create an ArcGISMap and Viewpoint + val californiaViewpoint = Viewpoint(34.056295, -117.195800, 1000000.0) + val arcGISMap = ArcGISMap(BasemapStyle.ArcGISTopographic).apply { + initialViewpoint = californiaViewpoint + } Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, content = { - Column(modifier = Modifier.fillMaxSize().padding(it)) { - // composable function that wraps the MapView - ComposeMapView( - modifier = Modifier.fillMaxSize().weight(1f), - mapViewModel = mapViewModel, - ) - } + MapView( + modifier = Modifier.fillMaxSize().padding(it), + arcGISMap = arcGISMap, + mapViewInteractionOptions = MapViewInteractionOptions(isMagnifierEnabled = true) + ) } ) } diff --git a/show-portal-user-info/build.gradle b/show-portal-user-info/build.gradle deleted file mode 100644 index f9ce23f71..000000000 --- a/show-portal-user-info/build.gradle +++ /dev/null @@ -1,52 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showportaluserinfo" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.showportaluserinfo' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation "androidx.browser:browser:$androidBrowserVersion" - implementation project(path: ':samples-lib') - // Toolkit dependencies - implementation(platform("com.esri:arcgis-maps-kotlin-toolkit-bom:$arcgisToolkitVersion")) - implementation('com.esri:arcgis-maps-kotlin-toolkit-authentication') -} diff --git a/show-portal-user-info/build.gradle.kts b/show-portal-user-info/build.gradle.kts new file mode 100644 index 000000000..5a8653458 --- /dev/null +++ b/show-portal-user-info/build.gradle.kts @@ -0,0 +1,55 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showportaluserinfo" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.showportaluserinfo" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(libs.androidx.browser) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.authentication) +} diff --git a/show-portal-user-info/proguard-rules.pro b/show-portal-user-info/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-portal-user-info/proguard-rules.pro +++ b/show-portal-user-info/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-result-of-spatial-operations/build.gradle b/show-result-of-spatial-operations/build.gradle deleted file mode 100644 index 2a9f587df..000000000 --- a/show-result-of-spatial-operations/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showresultofspatialoperations" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.showresultofspatialoperations' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/show-result-of-spatial-operations/build.gradle.kts b/show-result-of-spatial-operations/build.gradle.kts new file mode 100644 index 000000000..23cace956 --- /dev/null +++ b/show-result-of-spatial-operations/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showresultofspatialoperations" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.showresultofspatialoperations" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/show-result-of-spatial-operations/proguard-rules.pro b/show-result-of-spatial-operations/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-result-of-spatial-operations/proguard-rules.pro +++ b/show-result-of-spatial-operations/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-result-of-spatial-operations/src/main/java/com/esri/arcgismaps/sample/showresultofspatialoperations/MainActivity.kt b/show-result-of-spatial-operations/src/main/java/com/esri/arcgismaps/sample/showresultofspatialoperations/MainActivity.kt index dc703ae52..49f8427c0 100644 --- a/show-result-of-spatial-operations/src/main/java/com/esri/arcgismaps/sample/showresultofspatialoperations/MainActivity.kt +++ b/show-result-of-spatial-operations/src/main/java/com/esri/arcgismaps/sample/showresultofspatialoperations/MainActivity.kt @@ -116,11 +116,9 @@ class MainActivity : AppCompatActivity() { createPolygons() // center the map view on the input geometries - val envelope = GeometryEngine.union(inputPolygon1, inputPolygon2)?.extent - if (envelope != null) { - lifecycleScope.launch { - mapView.setViewpointGeometry(envelope, 20.0) - } + val envelope = GeometryEngine.union(inputPolygon1, inputPolygon2).extent + lifecycleScope.launch { + mapView.setViewpointGeometry(envelope, 20.0) } } @@ -130,7 +128,7 @@ class MainActivity : AppCompatActivity() { // create a result geometry of the spatial operation var resultGeometry: Geometry? = null // get the selected operation - when (SpatialOperation.values().find { it.menuPosition == position }) { + when (SpatialOperation.entries.find { it.menuPosition == position }) { SpatialOperation.NO_OPERATION -> { /* No operation needed */ } SpatialOperation.INTERSECTION -> { diff --git a/show-result-of-spatial-relationships/build.gradle b/show-result-of-spatial-relationships/build.gradle deleted file mode 100644 index 594ffa863..000000000 --- a/show-result-of-spatial-relationships/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showresultofspatialrelationships" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.showresultofspatialrelationships' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/show-result-of-spatial-relationships/build.gradle.kts b/show-result-of-spatial-relationships/build.gradle.kts new file mode 100644 index 000000000..efcf7eeac --- /dev/null +++ b/show-result-of-spatial-relationships/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showresultofspatialrelationships" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.showresultofspatialrelationships" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/show-result-of-spatial-relationships/proguard-rules.pro b/show-result-of-spatial-relationships/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-result-of-spatial-relationships/proguard-rules.pro +++ b/show-result-of-spatial-relationships/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-viewshed-from-point-in-scene/README.md b/show-viewshed-from-point-in-scene/README.md index 9a440c263..44f8e8344 100644 --- a/show-viewshed-from-point-in-scene/README.md +++ b/show-viewshed-from-point-in-scene/README.md @@ -29,6 +29,10 @@ Use the sliders to change the properties (heading, pitch, etc.), of the viewshed The scene shows a [buildings layer in Brest, France](https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer/layers/0) hosted on ArcGIS Online. +## Additional information + +This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable SceneView. + ## Tags -3D, frustum, scene, viewshed, visibility analysis +3D, frustum, geoviewcompose, scene, viewshed, visibility analysis diff --git a/show-viewshed-from-point-in-scene/README.metadata.json b/show-viewshed-from-point-in-scene/README.metadata.json index 103949e5d..a12924506 100644 --- a/show-viewshed-from-point-in-scene/README.metadata.json +++ b/show-viewshed-from-point-in-scene/README.metadata.json @@ -9,6 +9,7 @@ "keywords": [ "3D", "frustum", + "geoviewcompose", "scene", "viewshed", "visibility analysis", @@ -29,7 +30,6 @@ ], "snippets": [ "src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/MainActivity.kt", - "src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/components/ComposeSceneView.kt", "src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/components/SceneViewModel.kt", "src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/MainScreen.kt", "src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/ViewshedOptionsScreen.kt", diff --git a/show-viewshed-from-point-in-scene/build.gradle b/show-viewshed-from-point-in-scene/build.gradle deleted file mode 100644 index abe995f07..000000000 --- a/show-viewshed-from-point-in-scene/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.showviewshedfrompointinscene" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - compose = true - buildConfig = true - } - composeOptions { - kotlinCompilerExtensionVersion = "$kotlinCompilerExt" - } - - namespace 'com.esri.arcgismaps.sample.showviewshedfrompointinscene' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.core:core-ktx:$ktxAndroidCore" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle" - implementation "androidx.activity:activity-compose:$composeActivityVersion" - // Jetpack Compose Bill of Materials - implementation platform("androidx.compose:compose-bom:$composeBOM") - // Jetpack Compose dependencies - implementation "androidx.compose.ui:ui" - implementation "androidx.compose.material3:material3" - implementation "androidx.compose.ui:ui-tooling" - implementation "androidx.compose.ui:ui-tooling-preview" - implementation project(path: ':samples-lib') -} diff --git a/show-viewshed-from-point-in-scene/build.gradle.kts b/show-viewshed-from-point-in-scene/build.gradle.kts new file mode 100644 index 000000000..f54df5bc0 --- /dev/null +++ b/show-viewshed-from-point-in-scene/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.showviewshedfrompointinscene" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() + } + + namespace = "com.esri.arcgismaps.sample.showviewshedfrompointinscene" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(libs.androidx.activity.compose) + // Jetpack Compose Bill of Materials + implementation(platform(libs.androidx.compose.bom)) + // Jetpack Compose dependencies + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(project(":samples-lib")) + // Toolkit dependencies + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) +} diff --git a/show-viewshed-from-point-in-scene/proguard-rules.pro b/show-viewshed-from-point-in-scene/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/show-viewshed-from-point-in-scene/proguard-rules.pro +++ b/show-viewshed-from-point-in-scene/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/MainActivity.kt b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/MainActivity.kt index 0b2841b47..751772870 100644 --- a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/MainActivity.kt +++ b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/MainActivity.kt @@ -44,13 +44,8 @@ class MainActivity : ComponentActivity() { @Composable private fun ViewshedLocationApp() { - Surface( - color = MaterialTheme.colorScheme.background - ) { - MainScreen( - sampleName = getString(R.string.app_name), - application = application - ) + Surface(color = MaterialTheme.colorScheme.background) { + MainScreen(sampleName = getString(R.string.app_name)) } } } diff --git a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/components/ComposeSceneView.kt b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/components/ComposeSceneView.kt deleted file mode 100644 index 8cdb68c9c..000000000 --- a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/components/ComposeSceneView.kt +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.showviewshedfrompointinscene.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.SceneView - -/** - * Wraps the SceneView in a Composable function. - */ -@Composable -fun ComposeSceneView( - modifier: Modifier = Modifier, - sceneViewModel: SceneViewModel -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // collect the latest state of the SceneViewState - val sceneViewState = sceneViewModel.sceneViewState - // create and add SceneView to the activity lifecycle - val sceneView = createSceneViewInstance(lifecycleOwner) - - // wrap the SceneView as an AndroidView - AndroidView( - modifier = modifier, - factory = { sceneView }, - // recomposes the SceneView on changes in the SceneViewState - update = { sceneView -> - sceneView.apply { - scene = sceneViewState.arcGISScene - setViewpointCamera(sceneViewState.camera) - cameraController = sceneViewState.cameraController - analysisOverlays.clear() - analysisOverlays.add(sceneViewState.analysisOverlay) - } - } - ) -} - -/** - * Create the SceneView instance and add it to the Activity lifecycle - */ -@Composable -fun createSceneViewInstance(lifecycleOwner: LifecycleOwner): SceneView { - // create the SceneView - val sceneView = SceneView(LocalContext.current) - // add the side effects for SceneView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(sceneView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(sceneView) - } - } - return sceneView -} diff --git a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/components/SceneViewModel.kt b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/components/SceneViewModel.kt index 2f62bd781..2f8b526ae 100644 --- a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/components/SceneViewModel.kt +++ b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/components/SceneViewModel.kt @@ -27,6 +27,7 @@ import com.arcgismaps.mapping.ArcGISScene import com.arcgismaps.mapping.ArcGISTiledElevationSource import com.arcgismaps.mapping.BasemapStyle import com.arcgismaps.mapping.Surface +import com.arcgismaps.mapping.Viewpoint import com.arcgismaps.mapping.layers.ArcGISSceneLayer import com.arcgismaps.mapping.view.AnalysisOverlay import com.arcgismaps.mapping.view.Camera @@ -34,12 +35,9 @@ import com.arcgismaps.mapping.view.OrbitLocationCameraController import com.esri.arcgismaps.sample.showviewshedfrompointinscene.R class SceneViewModel(private val application: Application) : AndroidViewModel(application) { - // set the SceneView mutable stateflow - val sceneViewState = SceneViewState() - - private var viewShed: LocationViewshed // initialize location viewshed parameters + private var viewShed: LocationViewshed private val initHeading = 82.0 private val initPitch = 60.0 private val initHorizontalAngle = 75.0 @@ -47,6 +45,26 @@ class SceneViewModel(private val application: Application) : AndroidViewModel(ap private val initMinDistance = 0.0 private val initMaxDistance = 1500.0 + private val initLocation = Point( + x = -4.50, + y = 48.4, + z = 1000.0 + ) + private val camera = Camera( + lookAtPoint = initLocation, + distance = 20000000.0, + heading = 0.0, + pitch = 55.0, + roll = 0.0 + ) + val cameraController = OrbitLocationCameraController( + targetPoint = initLocation, + distance = 5000.0 + ) + var scene by mutableStateOf(ArcGISScene(BasemapStyle.ArcGISNavigationNight)) + var analysisOverlay by mutableStateOf(AnalysisOverlay()) + + init { // create a surface for elevation data val surface = Surface().apply { @@ -54,8 +72,7 @@ class SceneViewModel(private val application: Application) : AndroidViewModel(ap } // create a layer of buildings - val buildingsSceneLayer = - ArcGISSceneLayer(application.getString(R.string.buildings_layer)) + val buildingsSceneLayer = ArcGISSceneLayer(application.getString(R.string.buildings_layer)) // create a scene and add imagery basemap, elevation surface, and buildings layer to it val buildingsScene = ArcGISScene(BasemapStyle.ArcGISImagery).apply { @@ -77,14 +94,15 @@ class SceneViewModel(private val application: Application) : AndroidViewModel(ap frustumOutlineVisible = true } - sceneViewState.apply { - // add the buildings scene to the sceneView - arcGISScene = buildingsScene - // add the viewshed to the analysisOverlay of the scene view - analysisOverlay.apply { - analyses.add(viewShed) - isVisible = true - } + // add the buildings scene to the sceneView + scene = buildingsScene.apply { + baseSurface = surface + initialViewpoint = Viewpoint(initLocation, camera) + } + // add the viewshed to the analysisOverlay of the scene view + analysisOverlay.apply { + analyses.add(viewShed) + isVisible = true } } @@ -122,15 +140,3 @@ class SceneViewModel(private val application: Application) : AndroidViewModel(ap } } -/** - * Data class that represents the SceneView state - */ -class SceneViewState { - var arcGISScene: ArcGISScene by mutableStateOf(ArcGISScene(BasemapStyle.ArcGISNavigationNight)) - private val initLocation = Point(-4.50, 48.4, 1000.0) - val camera: Camera = Camera(initLocation, 20000000.0, 0.0, 55.0, 0.0) - val cameraController: OrbitLocationCameraController = - OrbitLocationCameraController(initLocation, 5000.0) - var analysisOverlay: AnalysisOverlay by mutableStateOf(AnalysisOverlay()) -} - diff --git a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/MainScreen.kt b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/MainScreen.kt index df6bcab3f..cee6dd0c3 100644 --- a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/MainScreen.kt +++ b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/MainScreen.kt @@ -24,15 +24,18 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import com.arcgismaps.toolkit.geoviewcompose.SceneView import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar -import com.esri.arcgismaps.sample.showviewshedfrompointinscene.components.ComposeSceneView import com.esri.arcgismaps.sample.showviewshedfrompointinscene.components.SceneViewModel /** * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { + // get the application context + val application = LocalContext.current.applicationContext as Application // create a ViewModel to handle SceneView interactions val sceneViewModel = SceneViewModel(application) @@ -46,9 +49,13 @@ fun MainScreen(sampleName: String, application: Application) { .padding(it) ) { // composable function that wraps the SceneView - ComposeSceneView( - modifier = Modifier.fillMaxSize().weight(1f), - sceneViewModel = sceneViewModel + SceneView( + modifier = Modifier + .fillMaxSize() + .weight(1f), + arcGISScene = sceneViewModel.scene, + cameraController = sceneViewModel.cameraController, + analysisOverlays = listOf(sceneViewModel.analysisOverlay) ) // display list of options to modify viewshed properties ViewshedOptionsScreen( diff --git a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/ViewshedOptionsScreen.kt b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/ViewshedOptionsScreen.kt index dbd44d735..58863007c 100644 --- a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/ViewshedOptionsScreen.kt +++ b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/ViewshedOptionsScreen.kt @@ -45,7 +45,7 @@ fun ViewshedOptionsScreen( isFrustumVisible: (Boolean) -> Unit = {}, isAnalysisVisible: (Boolean) -> Unit = {} ) { - Column() { + Column { // sliders HeadingSlider(onHeadingChanged) PitchSlider(onPitchChanged) @@ -65,7 +65,7 @@ fun ViewshedOptionsScreen( private fun HeadingSlider(onHeadingChanged: (Float) -> Unit) { ViewshedSlider( title = "Heading", - intialSliderValue = 82f, + initialSliderValue = 82f, sliderRangeValue = 0f..360f, functionChanged = onHeadingChanged ) @@ -75,7 +75,7 @@ private fun HeadingSlider(onHeadingChanged: (Float) -> Unit) { private fun PitchSlider(onPitchChanged: (Float) -> Unit) { ViewshedSlider( title = "Pitch", - intialSliderValue = 60f, + initialSliderValue = 60f, sliderRangeValue = 0f..180f, functionChanged = onPitchChanged ) @@ -85,7 +85,7 @@ private fun PitchSlider(onPitchChanged: (Float) -> Unit) { private fun HorizontalAngleSlider(onHorizontalAngleChanged: (Float) -> Unit) { ViewshedSlider( title = "Horizontal Angle", - intialSliderValue = 75f, + initialSliderValue = 75f, sliderRangeValue = 1f..120f, functionChanged = onHorizontalAngleChanged ) @@ -95,7 +95,7 @@ private fun HorizontalAngleSlider(onHorizontalAngleChanged: (Float) -> Unit) { private fun VerticalAngleSlider(onVerticalAngleChanged: (Float) -> Unit) { ViewshedSlider( title = "Vertical Angle", - intialSliderValue = 90f, + initialSliderValue = 90f, sliderRangeValue = 1f..120f, functionChanged = onVerticalAngleChanged ) @@ -105,7 +105,7 @@ private fun VerticalAngleSlider(onVerticalAngleChanged: (Float) -> Unit) { private fun MinimumDistanceSlider(onMinDistanceChanged: (Float) -> Unit) { ViewshedSlider( title = "Minimum Distance", - intialSliderValue = 0f, + initialSliderValue = 0f, sliderRangeValue = 0f..8999f, functionChanged = onMinDistanceChanged ) @@ -115,7 +115,7 @@ private fun MinimumDistanceSlider(onMinDistanceChanged: (Float) -> Unit) { private fun MaximumDistanceSlider(onMaxDistanceChanged: (Float) -> Unit) { ViewshedSlider( title = "Maximum Distance", - intialSliderValue = 1500f, + initialSliderValue = 1500f, sliderRangeValue = 0f..9999f, functionChanged = onMaxDistanceChanged ) diff --git a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/ViewshedSlider.kt b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/ViewshedSlider.kt index 3feed0b73..5259713c2 100644 --- a/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/ViewshedSlider.kt +++ b/show-viewshed-from-point-in-scene/src/main/java/com/esri/arcgismaps/sample/showviewshedfrompointinscene/screens/ViewshedSlider.kt @@ -8,7 +8,7 @@ import androidx.compose.material3.Slider import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier @@ -20,12 +20,12 @@ import androidx.compose.ui.unit.dp @Composable fun ViewshedSlider( title: String, - intialSliderValue: Float, + initialSliderValue: Float, sliderRangeValue: ClosedFloatingPointRange, functionChanged: (Float) -> Unit ) { var sliderValue by remember { - mutableStateOf(intialSliderValue) + mutableFloatStateOf(initialSliderValue) } Row { Text( diff --git a/sketch-on-map/build.gradle b/sketch-on-map/build.gradle deleted file mode 100644 index e82dacbc8..000000000 --- a/sketch-on-map/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.sketchonmap" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.sketchonmap' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation project(path: ':samples-lib') -} diff --git a/sketch-on-map/build.gradle.kts b/sketch-on-map/build.gradle.kts new file mode 100644 index 000000000..7f82f5712 --- /dev/null +++ b/sketch-on-map/build.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.sketchonmap" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.sketchonmap" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(project(":samples-lib")) +} diff --git a/sketch-on-map/proguard-rules.pro b/sketch-on-map/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/sketch-on-map/proguard-rules.pro +++ b/sketch-on-map/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/style-graphics-with-renderer/build.gradle b/style-graphics-with-renderer/build.gradle deleted file mode 100644 index c36d18c73..000000000 --- a/style-graphics-with-renderer/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.stylegraphicswithrenderer" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.stylegraphicswithrenderer' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation project(path: ':samples-lib') -} diff --git a/style-graphics-with-renderer/build.gradle.kts b/style-graphics-with-renderer/build.gradle.kts new file mode 100644 index 000000000..7ade9ea90 --- /dev/null +++ b/style-graphics-with-renderer/build.gradle.kts @@ -0,0 +1,37 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.stylegraphicswithrenderer" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.stylegraphicswithrenderer" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(project(":samples-lib")) +} diff --git a/style-graphics-with-renderer/proguard-rules.pro b/style-graphics-with-renderer/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/style-graphics-with-renderer/proguard-rules.pro +++ b/style-graphics-with-renderer/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/style-graphics-with-symbols/build.gradle b/style-graphics-with-symbols/build.gradle deleted file mode 100644 index 0d6c84a97..000000000 --- a/style-graphics-with-symbols/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - - defaultConfig { - applicationId "com.esri.arcgismaps.sample.stylegraphicswithsymbols" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - buildConfigField("String", "API_KEY", API_KEY) - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding true - buildConfig = true - } - - namespace 'com.esri.arcgismaps.sample.stylegraphicswithsymbols' -} - -dependencies { - // lib dependencies from rootProject build.gradle - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation project(path: ':samples-lib') -} diff --git a/style-graphics-with-symbols/build.gradle.kts b/style-graphics-with-symbols/build.gradle.kts new file mode 100644 index 000000000..15e84d2cd --- /dev/null +++ b/style-graphics-with-symbols/build.gradle.kts @@ -0,0 +1,37 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.esri.arcgismaps.sample.stylegraphicswithsymbols" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + dataBinding = true + buildConfig = true + } + + namespace = "com.esri.arcgismaps.sample.stylegraphicswithsymbols" +} + +dependencies { + // lib dependencies from rootProject build.gradle.kts + implementation(libs.androidx.constraintlayout) + implementation(project(":samples-lib")) +} diff --git a/style-graphics-with-symbols/proguard-rules.pro b/style-graphics-with-symbols/proguard-rules.pro index f1b424510..2f9dc5a47 100644 --- a/style-graphics-with-symbols/proguard-rules.pro +++ b/style-graphics-with-symbols/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/tools/NewModuleScript.jar b/tools/NewModuleScript.jar index 8ad3f37b9..d479fb9a5 100644 Binary files a/tools/NewModuleScript.jar and b/tools/NewModuleScript.jar differ diff --git a/tools/NewModuleScript/ComposeMapViewTemplate.kt b/tools/NewModuleScript/ComposeMapViewTemplate.kt deleted file mode 100644 index 61feabc16..000000000 --- a/tools/NewModuleScript/ComposeMapViewTemplate.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 2023 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.esri.arcgismaps.sample.displaycomposablemapview.components - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.viewinterop.AndroidView -import androidx.lifecycle.LifecycleOwner -import com.arcgismaps.mapping.view.MapView -import com.arcgismaps.mapping.view.SingleTapConfirmedEvent -import kotlinx.coroutines.launch - -/** - * Wraps the MapView in a Composable function. - */ -@Composable -fun ComposeMapView( - modifier: Modifier = Modifier, - mapViewModel: MapViewModel, - onSingleTap: (SingleTapConfirmedEvent) -> Unit = {} -) { - // get an instance of the current lifecycle owner - val lifecycleOwner = LocalLifecycleOwner.current - // collect the latest state of the MapViewState - val mapViewState by mapViewModel.mapViewState.collectAsState() - // create and add MapView to the activity lifecycle - val mapView = createMapViewInstance(lifecycleOwner) - - // wrap the MapView as an AndroidView - AndroidView( - modifier = modifier, - factory = { mapView }, - // recomposes the MapView on changes in the MapViewState - update = { mapView -> - mapView.apply { - map = mapViewState.arcGISMap - setViewpoint(mapViewState.viewpoint) - } - } - ) - - // launch coroutine functions in the composition's CoroutineContext - LaunchedEffect(Unit) { - launch { - mapView.onSingleTapConfirmed.collect { - onSingleTap(it) - } - } - } -} - -/** - * Create the MapView instance and add it to the Activity lifecycle - */ -@Composable -fun createMapViewInstance(lifecycleOwner: LifecycleOwner): MapView { - // create the MapView - val mapView = MapView(LocalContext.current) - // add the side effects for MapView composition - DisposableEffect(lifecycleOwner) { - lifecycleOwner.lifecycle.addObserver(mapView) - onDispose { - lifecycleOwner.lifecycle.removeObserver(mapView) - } - } - return mapView -} diff --git a/tools/NewModuleScript/MainActivityTemplate.kt b/tools/NewModuleScript/MainActivityTemplate.kt index e7b6ae342..a6efcd0c3 100644 --- a/tools/NewModuleScript/MainActivityTemplate.kt +++ b/tools/NewModuleScript/MainActivityTemplate.kt @@ -48,8 +48,7 @@ class MainActivity : ComponentActivity() { color = MaterialTheme.colorScheme.background ) { MainScreen( - sampleName = getString(R.string.app_name), - application = application + sampleName = getString(R.string.app_name) ) } } diff --git a/tools/NewModuleScript/MainScreenTemplate.kt b/tools/NewModuleScript/MainScreenTemplate.kt index 8aeaadb2e..268cc9da1 100644 --- a/tools/NewModuleScript/MainScreenTemplate.kt +++ b/tools/NewModuleScript/MainScreenTemplate.kt @@ -17,13 +17,18 @@ package com.esri.arcgismaps.sample.displaycomposablemapview.screens import android.app.Application -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import com.esri.arcgismaps.sample.displaycomposablemapview.components.ComposeMapView +import androidx.compose.ui.platform.LocalContext +import com.arcgismaps.mapping.ArcGISMap +import com.arcgismaps.mapping.BasemapStyle +import com.arcgismaps.toolkit.geoviewcompose.MapView import com.esri.arcgismaps.sample.displaycomposablemapview.components.MapViewModel import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar @@ -31,27 +36,26 @@ import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar * Main screen layout for the sample app */ @Composable -fun MainScreen(sampleName: String, application: Application) { +fun MainScreen(sampleName: String) { + val application = LocalContext.current.applicationContext as Application // create a ViewModel to handle MapView interactions val mapViewModel = MapViewModel(application) + val arcGISMap by remember { + mutableStateOf(ArcGISMap(BasemapStyle.ArcGISNavigationNight).apply { + initialViewpoint = mapViewModel.viewpoint.value + }) + } Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, content = { - Column( - modifier = Modifier - .fillMaxSize() - .padding(it) - ) { - // composable function that wraps the MapView - ComposeMapView( - modifier = Modifier.fillMaxSize(), - mapViewModel = mapViewModel, - onSingleTap = { - mapViewModel.changeBasemap() - } - ) - } + MapView( + modifier = Modifier.fillMaxSize().padding(it), + arcGISMap = arcGISMap, + onSingleTapConfirmed = { + mapViewModel.changeBasemap() + } + ) } ) } diff --git a/tools/NewModuleScript/MapViewModelTemplate.kt b/tools/NewModuleScript/MapViewModelTemplate.kt index 36f3e9bd3..1f314f1f1 100644 --- a/tools/NewModuleScript/MapViewModelTemplate.kt +++ b/tools/NewModuleScript/MapViewModelTemplate.kt @@ -17,36 +17,19 @@ package com.esri.arcgismaps.sample.displaycomposablemapview.components import android.app.Application +import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.AndroidViewModel -import com.arcgismaps.mapping.ArcGISMap -import com.arcgismaps.mapping.BasemapStyle import com.arcgismaps.mapping.Viewpoint -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.update class MapViewModel(application: Application) : AndroidViewModel(application) { - // set the MapView mutable stateflow - val mapViewState = MutableStateFlow(MapViewState()) - + private val viewpointAmerica = Viewpoint(39.8, -98.6, 10e7) + private val viewpointAsia = Viewpoint(39.8, 98.6, 10e7) + var viewpoint = mutableStateOf(viewpointAmerica) /** * Switch between two basemaps */ fun changeBasemap() { - val newArcGISMap: ArcGISMap = - if (mapViewState.value.arcGISMap.basemap.value?.name.equals("ArcGIS:NavigationNight")) { - ArcGISMap(BasemapStyle.ArcGISStreets) - } else { - ArcGISMap(BasemapStyle.ArcGISNavigationNight) - } - mapViewState.update { it.copy(arcGISMap = newArcGISMap) } + viewpoint.value = + if (viewpoint.value == viewpointAmerica) viewpointAsia else viewpointAmerica } } - - -/** - * Data class that represents the MapView state - */ -data class MapViewState( // This would change based on each sample implementation - var arcGISMap: ArcGISMap = ArcGISMap(BasemapStyle.ArcGISNavigationNight), - var viewpoint: Viewpoint = Viewpoint(39.8, -98.6, 10e7) -) diff --git a/tools/NewModuleScript/README.md b/tools/NewModuleScript/README.md index ba6682295..920ff76eb 100644 --- a/tools/NewModuleScript/README.md +++ b/tools/NewModuleScript/README.md @@ -17,4 +17,4 @@ The script uses the sample `Display Map` as a template to create a new sample. H ## How to use the script -Refer to the `README.md` at `arcgis-maps-sdk-kotlin-samples/tools/` +Refer to the `README.md` at `arcgis-maps-sdk-kotlin-samples/tools/`. diff --git a/tools/NewModuleScript/build.gradle b/tools/NewModuleScript/build.gradle deleted file mode 100644 index 949f83a8e..000000000 --- a/tools/NewModuleScript/build.gradle +++ /dev/null @@ -1,22 +0,0 @@ -plugins { - id 'java' -} - -group 'org.example' -version '1.0-SNAPSHOT' - -repositories { - mavenCentral() -} - -dependencies { - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' - - // https://mvnrepository.com/artifact/commons-io/commons-io - implementation group: 'commons-io', name: 'commons-io', version: '2.6' -} - -test { - useJUnitPlatform() -} \ No newline at end of file diff --git a/tools/NewModuleScript/build.gradle.kts b/tools/NewModuleScript/build.gradle.kts new file mode 100644 index 000000000..979592649 --- /dev/null +++ b/tools/NewModuleScript/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + java +} + +group = "org.example" +version = "1.0-SNAPSHOT" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0") + + // https://mvnrepository.com/artifact/commons-io/commons-io + implementation("commons-io:commons-io:2.6") +} + +tasks.test { + useJUnitPlatform() +} diff --git a/tools/NewModuleScript/settings.gradle b/tools/NewModuleScript/settings.gradle deleted file mode 100644 index 1cdf096bd..000000000 --- a/tools/NewModuleScript/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'NewModuleScript' - diff --git a/tools/NewModuleScript/settings.gradle.kts b/tools/NewModuleScript/settings.gradle.kts new file mode 100644 index 000000000..60b39dd73 --- /dev/null +++ b/tools/NewModuleScript/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "NewModuleScript" diff --git a/tools/NewModuleScript/src/main/java/ScriptMain.java b/tools/NewModuleScript/src/main/java/ScriptMain.java index 781fbc681..accdea380 100644 --- a/tools/NewModuleScript/src/main/java/ScriptMain.java +++ b/tools/NewModuleScript/src/main/java/ScriptMain.java @@ -99,7 +99,6 @@ private void createFilesAndFolders() { // Copy Kotlin template files to new sample File mainActivityTemplate = new File(samplesRepoPath + "/tools/NewModuleScript/MainActivityTemplate.kt"); - File composeMapViewTemplate = new File(samplesRepoPath + "/tools/NewModuleScript/ComposeMapViewTemplate.kt"); File mapViewModelTemplate = new File(samplesRepoPath + "/tools/NewModuleScript/MapViewModelTemplate.kt"); File mainScreenTemplate = new File(samplesRepoPath + "/tools/NewModuleScript/MainScreenTemplate.kt"); @@ -109,20 +108,17 @@ private void createFilesAndFolders() { Path source = Paths.get(packageDirectory+"/MainActivityTemplate.kt"); Files.move(source, source.resolveSibling("MainActivity.kt")); - File composeComponentsDir = new File(packageDirectory + "/components"); - composeComponentsDir.mkdirs(); - FileUtils.copyFileToDirectory(composeMapViewTemplate, composeComponentsDir); - source = Paths.get(composeComponentsDir+"/ComposeMapViewTemplate.kt"); - Files.move(source, source.resolveSibling("ComposeMapView.kt")); + File componentsDir = new File(packageDirectory + "/components"); + componentsDir.mkdirs(); - FileUtils.copyFileToDirectory(mapViewModelTemplate, composeComponentsDir); - source = Paths.get(composeComponentsDir+"/MapViewModelTemplate.kt"); + FileUtils.copyFileToDirectory(mapViewModelTemplate, componentsDir); + source = Paths.get(componentsDir+"/MapViewModelTemplate.kt"); Files.move(source, source.resolveSibling("MapViewModel.kt")); - composeComponentsDir = new File(packageDirectory + "/screens"); - composeComponentsDir.mkdirs(); - FileUtils.copyFileToDirectory(mainScreenTemplate, composeComponentsDir); - source = Paths.get(composeComponentsDir+"/MainScreenTemplate.kt"); + componentsDir = new File(packageDirectory + "/screens"); + componentsDir.mkdirs(); + FileUtils.copyFileToDirectory(mainScreenTemplate, componentsDir); + source = Paths.get(componentsDir+"/MainScreenTemplate.kt"); Files.move(source, source.resolveSibling("MainScreen.kt")); } catch (IOException e) { e.printStackTrace(); @@ -143,7 +139,7 @@ private void exitProgram(Exception e){ /** * Updates the content in the copied files to reflect the name of the sample - * Eg. README.md, build.gradle, MainActivity.kt, etc. + * Eg. README.md, build.gradle.kts, MainActivity.kt, etc. */ private void updateSampleContent() { @@ -165,8 +161,8 @@ private void updateSampleContent() { exitProgram(e); } - //Update build.gradle - file = new File(samplesRepoPath + "/" + sampleWithHyphen + "/build.gradle"); + //Update build.gradle.kts + file = new File(samplesRepoPath + "/" + sampleWithHyphen + "/build.gradle.kts"); try { String fileContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8); fileContent = fileContent.replace("sample.displaycomposablemapview", "sample." + sampleWithoutSpaces); @@ -201,18 +197,6 @@ private void updateSampleContent() { exitProgram(e); } - //Update ComposeMapView.kt - file = new File(samplesRepoPath + "/" + sampleWithHyphen + "/src/main/java/com/esri/arcgismaps/sample/"+sampleWithoutSpaces+"/components/ComposeMapView.kt"); - try { - String fileContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - fileContent = fileContent.replace("Copyright 2023", "Copyright " + Calendar.getInstance().get(Calendar.YEAR)); - fileContent = fileContent.replace("sample.displaycomposablemapview", "sample." + sampleWithoutSpaces); - FileUtils.write(file,fileContent, StandardCharsets.UTF_8); - } catch (IOException e) { - e.printStackTrace(); - exitProgram(e); - } - //Update MapViewModel.kt file = new File(samplesRepoPath + "/" + sampleWithHyphen + "/src/main/java/com/esri/arcgismaps/sample/"+sampleWithoutSpaces+"/components/MapViewModel.kt"); try { diff --git a/tools/README.md b/tools/README.md index 1e1f39fd2..fa41ff167 100644 --- a/tools/README.md +++ b/tools/README.md @@ -29,3 +29,18 @@ Example: **Note:** The script will generate all the `gradle`, `src` and `res` files needed for a new sample. You will have to reload `gradle` manually for Android Studio to implement the changes. To do this run: - File -> Sync Project with Gradle Files + +### How to build a new script + +To build a new `NewModuleSript.jar` using IntelliJ IDEA: + + - Open `NewModuleScript` as the project in the IDE. + - In IDE, go to `File` -> `Project Structure` -> `Artifacts`. + - Add a new artifact of type `JAR` from module with dependencies. + - Select `NewModuleScript.main` as `Module`. + - Select `ScriptMain` as `Main Class`. + - Click `OK`. + - Click `Apply` and `OK`. + - In IDE, go to `Build` -> `Build Artifacts`, select `NewModuleScript.main:jar` and click `Rebuild`. + - The `.jar` file will be generated in the `out` directory of the project. + - Move the `.jar` file to the `tools` directory of the repository. Rename it to `NewModuleScript.jar`. \ No newline at end of file diff --git a/version.gradle b/version.gradle deleted file mode 100644 index fc2be58e0..000000000 --- a/version.gradle +++ /dev/null @@ -1,34 +0,0 @@ -ext { - // ArcGIS Maps SDK for Kotlin version - arcgisVersion = '200.3.0' - // ArcGIS Maps SDK for Kotlin Toolkit version - arcgisToolkitVersion = '200.3.0' - // SDK versions - compileSdkVersion = 33 - minSdkVersion = 26 - targetSdkVersion = 33 - versionCode = 2003000 - versionName = '200.3.0' - // Kotlin versions - kotlinVersion = '1.9.10' - ktxLifecycle = '2.5.1' - ktxFragmentsExt = '1.6.1' - ktxActivityExt = '1.7.2' - ktxAndroidCore = '1.10.1' - kotlinCompilerExt = '1.5.3' - // Compose versions - composeActivityVersion = '1.7.1' - composeBOM = '2023.05.01' - // Library versions - appcompatVersion = '1.6.1' - constraintLayoutVersion = '2.1.4' - workVersion = '2.7.1' - multidexVersion = '2.0.1' - materialVersion = '1.7.0' - recyclerViewVersion = '1.1.0' - androidBrowserVersion = '1.5.0' - // Plugin versions - gradleVersion = '8.1.1' - // Java version - javaVersion = 1.17 -}