diff --git a/build.gradle.kts b/build.gradle.kts index 722701adf..a43592830 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,5 +22,17 @@ plugins { alias(libs.plugins.android.library) apply false alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.gradle.secrets) apply false - alias(libs.plugins.kotlin.serialization) apply false + alias(libs.plugins.kapt) apply false + alias(libs.plugins.ksp) apply false + alias(libs.plugins.hilt) apply false +} + +allprojects{ + // kapt compiler cannot figure out that it needs to target the same bytecode as kotlin and java compilers + // without this. Furthermore, KaptGenerateStubs is unresolved in module gradle. + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs::class).all { + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + } } diff --git a/gradle.properties b/gradle.properties index 1f59a6cd5..519c89007 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects @@ -39,6 +39,7 @@ kotlin.code.style=official # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true +#android.enableBuildConfigAsBytecode=true artifactoryUrl=https://olympus.esri.com/artifactory/arcgisruntime-snapshot-local artifactoryGroupId=com.esri artifactoryArtifactBaseId=arcgis-maps-kotlin-toolkit @@ -53,7 +54,5 @@ buildNumber=0000-snapshot ignoreBuildNumber=false # these versions define the dependency of the ArcGIS Maps SDK for Kotlin dependency # and are generally not overridden at the command line unless a special build is requested. -sdkVersionNumber=200.2.0 -sdkBuildNumber= - - +sdkVersionNumber=200.3.0 +sdkBuildNumber=4057 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dd4d536bc..97f8d40e3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,22 +2,30 @@ androidGradlePlugin = "8.1.1" androidxActivity = "1.5.1" androidXBrowser = "1.5.0" -androidxCompose = "1.3.0" +androidxCompose = "1.5.4" androidxComposeCompiler = "1.4.6" androidxCore = "1.9.0" androidxCoreTesting = "2.1.0" androidxEspresso = "3.4.0" +androidxHiltNavigationCompose = "1.0.0" androidxLifecycle = "2.3.1" androidxLifecycleRuntimeCompose = "2.6.0-beta01" +androidxMaterialIcons = "1.4.3" androidxTestExt = "1.1.2" androidxViewmodelCompose = "2.6.1" -compileSdk = "33" +androidxWindow = "1.2.0" +coil = "2.4.0" +compileSdk = "34" compose-material3 = "1.1.0" +compose-navigation = "2.7.5" +hilt = "2.44.2" +hiltExt = "1.0.0" junit = "4.13.2" kotlin = "1.8.20" -minSdk = "26" +ksp = "1.8.20-1.0.11" kotlinxCoroutinesTest = "1.6.3" -kotlinxSerializationJson = "1.5.0" +minSdk = "26" +room = "2.5.2" truth = "1.1.4" [libraries] @@ -28,29 +36,41 @@ androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = androidx-compose-ui = { group = "androidx.compose.ui", name = "ui", version.ref = "androidxCompose" } androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime", version.ref = "androidxCompose" } androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } +androidx-compose-navigation = { group = "androidx.navigation", name = "navigation-compose", version.ref = "compose-navigation" } androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics", version.ref = "androidxCompose" } androidx-compose-ui-test = { group = "androidx.compose.ui", name = "ui-test-junit4", version.ref = "androidxCompose" } androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "androidxCompose" } androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview", version.ref = "androidxCompose" } androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest", version.ref = "androidxCompose" } +androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "androidxLifecycle" } androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "androidxViewmodelCompose" } androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidxLifecycleRuntimeCompose"} androidx-test-ext = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "androidxTestExt" } androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidxEspresso" } +androidx-window-core = { group = "androidx.window", name = "window-core", version.ref = "androidxWindow" } +androidx-window = { group = "androidx.window", name = "window", version.ref = "androidxWindow" } +coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" } +hilt-android-core = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" } +hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" } +hilt-ext-compiler = { group = "androidx.hilt", name = "hilt-compiler", version.ref = "hiltExt" } +hilt-ext-work = { group = "androidx.hilt", name = "hilt-work", version.ref = "hiltExt" } junit = { group = "junit", name = "junit", version.ref = "junit" } -kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin"} -kotlinx-serialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinxSerializationJson" } -kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutinesTest" } +androidx-material-icons = { group = "androidx.compose.material", name = "material-icons-extended", version.ref = "androidxMaterialIcons"} +room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" } +room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" } +room-ext = { group = "androidx.room", name = "room-ktx", version.ref = "room" } truth = { group = "com.google.truth", name = "truth", version.ref = "truth" } [plugins] android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } +hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } +kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } gradle-secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version = "2.0.1"} -kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } [bundles] core = [ @@ -76,12 +96,6 @@ debug = [ "androidx-compose-ui-test-manifest" ] -serialization = [ - "kotlinx-serialization-core", - "kotlinx-serialization-json", - "kotlin-reflect" -] - unitTest = [ "junit", "kotlinx-coroutines-test", diff --git a/microapps/CompassApp/app/src/main/java/com/arcgismaps/toolkit/compassapp/screens/MainScreen.kt b/microapps/CompassApp/app/src/main/java/com/arcgismaps/toolkit/compassapp/screens/MainScreen.kt index b2c78cb0b..5c7b8e040 100644 --- a/microapps/CompassApp/app/src/main/java/com/arcgismaps/toolkit/compassapp/screens/MainScreen.kt +++ b/microapps/CompassApp/app/src/main/java/com/arcgismaps/toolkit/compassapp/screens/MainScreen.kt @@ -47,7 +47,7 @@ fun MainScreen() { // show a composable map using the mapViewModel ComposableMap( modifier = Modifier.fillMaxSize(), - mapInterface = mapViewModel + mapState = mapViewModel ) { Row(modifier = Modifier .height(IntrinsicSize.Max) diff --git a/microapps/CompassApp/app/src/main/java/com/arcgismaps/toolkit/compassapp/screens/MapViewModel.kt b/microapps/CompassApp/app/src/main/java/com/arcgismaps/toolkit/compassapp/screens/MapViewModel.kt index 0dc5305e6..a33d5bc6e 100644 --- a/microapps/CompassApp/app/src/main/java/com/arcgismaps/toolkit/compassapp/screens/MapViewModel.kt +++ b/microapps/CompassApp/app/src/main/java/com/arcgismaps/toolkit/compassapp/screens/MapViewModel.kt @@ -22,12 +22,12 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import com.arcgismaps.mapping.ArcGISMap import com.arcgismaps.toolkit.composablemap.MapInsets -import com.arcgismaps.toolkit.composablemap.MapInterface +import com.arcgismaps.toolkit.composablemap.MapState class MapViewModel( arcGISMap: ArcGISMap, mapInsets: MapInsets = MapInsets() -) : ViewModel(), MapInterface by MapInterface(arcGISMap, mapInsets) +) : ViewModel(), MapState by MapState(arcGISMap, mapInsets) class MapViewModelFactory( private val arcGISMap: ArcGISMap, diff --git a/microapps/FeatureEditorApp/.gitignore b/microapps/FeatureEditorApp/.gitignore new file mode 100644 index 000000000..aa724b770 --- /dev/null +++ b/microapps/FeatureEditorApp/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/microapps/FeatureEditorApp/README.md b/microapps/FeatureEditorApp/README.md new file mode 100644 index 000000000..45fd25303 --- /dev/null +++ b/microapps/FeatureEditorApp/README.md @@ -0,0 +1 @@ +# Feature Editor MicroApp diff --git a/microapps/FeatureEditorApp/app/.gitignore b/microapps/FeatureEditorApp/app/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/microapps/FeatureEditorApp/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/microapps/FeatureEditorApp/app/build.gradle.kts b/microapps/FeatureEditorApp/app/build.gradle.kts new file mode 100644 index 000000000..1097b962a --- /dev/null +++ b/microapps/FeatureEditorApp/app/build.gradle.kts @@ -0,0 +1,93 @@ +/* + * + * 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. + * + */ + +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") +} + +secrets { + defaultPropertiesFileName = "secrets.defaults.properties" +} + +android { + namespace = "com.arcgismaps.toolkit.featureeditorapp" + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId ="com.arcgismaps.toolkit.featureeditorapp" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.compileSdk.get().toInt() + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner ="androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = false + //proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"),("proguard-rules.pro" + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + @Suppress("UnstableApiUsage") + buildFeatures { + compose = true + buildConfig = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get() + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +//https://youtrack.jetbrains.com/issue/KTIJ-21063 +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).all { + kotlinOptions.freeCompilerArgs += "-Xcontext-receivers" +} + +dependencies { + implementation(project(":featureeditor")) + implementation(project(":featureforms")) + implementation(project(":composable-map")) + implementation(arcgis.mapsSdk) + implementation(libs.bundles.composeCore) + implementation(libs.bundles.core) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.lifecycle.viewmodel.compose) + testImplementation(libs.bundles.unitTest) + androidTestImplementation(libs.bundles.composeTest) + debugImplementation(libs.bundles.debug) +} diff --git a/microapps/FeatureEditorApp/app/proguard-rules.pro b/microapps/FeatureEditorApp/app/proguard-rules.pro new file mode 100644 index 000000000..f1b424510 --- /dev/null +++ b/microapps/FeatureEditorApp/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/microapps/FeatureEditorApp/app/src/main/AndroidManifest.xml b/microapps/FeatureEditorApp/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..294f68fee --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/AndroidManifest.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + diff --git a/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/MainActivity.kt b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/MainActivity.kt new file mode 100644 index 000000000..6759377d5 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/MainActivity.kt @@ -0,0 +1,64 @@ +/* + * + * 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.arcgismaps.toolkit.featureeditorapp + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.lifecycle.lifecycleScope +import com.arcgismaps.ArcGISEnvironment +import com.arcgismaps.httpcore.authentication.TokenCredential +import com.arcgismaps.mapping.ArcGISMap +import com.arcgismaps.toolkit.composablemap.MapState +import com.arcgismaps.toolkit.featureeditorapp.screens.FeatureEditorApp +import com.arcgismaps.toolkit.featureeditorapp.screens.FeatureEditorAppState +import com.arcgismaps.toolkit.featureeditorapp.ui.theme.FeatureEditorAppTheme +import kotlinx.coroutines.launch + +private const val WEB_MAP_URL = + "https://runtimecoretest.maps.arcgis.com/home/item.html?id=df0f27f83eee41b0afe4b6216f80b541" + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val state = FeatureEditorAppState() + + lifecycleScope.launch { + + ArcGISEnvironment.authenticationManager.arcGISCredentialStore.add( + TokenCredential.create( + WEB_MAP_URL, + BuildConfig.WEB_MAP_USERNAME, + BuildConfig.WEB_MAP_PASSWORD + ).getOrThrow() + ) + + val map = ArcGISMap(WEB_MAP_URL) + + state.setMap(map) + } + + setContent { + FeatureEditorAppTheme { + FeatureEditorApp(state) + } + } + } +} diff --git a/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/screens/FeatureEditorApp.kt b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/screens/FeatureEditorApp.kt new file mode 100644 index 000000000..7da288514 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/screens/FeatureEditorApp.kt @@ -0,0 +1,45 @@ +/* + * + * 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.arcgismaps.toolkit.featureeditorapp.screens + +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.arcgismaps.toolkit.composablemap.ComposableMap +import com.arcgismaps.toolkit.featureeditor.FeatureEditorView + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun FeatureEditorApp(state: FeatureEditorAppState) { + Scaffold(topBar = { TopAppBar(title = { Text("Feature Editor App") }) }) { + + FeatureEditorView( + featureEditorState = state.featureEditorState, + modifier = Modifier.padding(it) + ) { + // TODO: would be nice to set insets here so editor's stuff doesn't get in way of map content + ComposableMap(mapState = state) + } + + } +} diff --git a/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/screens/FeatureEditorAppState.kt b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/screens/FeatureEditorAppState.kt new file mode 100644 index 000000000..f77fec36f --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/screens/FeatureEditorAppState.kt @@ -0,0 +1,96 @@ +/* + * COPYRIGHT 1995-2023 ESRI + * + * TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL + * Unpublished material - all rights reserved under the + * Copyright Laws of the United States. + * + * For additional information, contact: + * Environmental Systems Research Institute, Inc. + * Attn: Contracts Dept + * 380 New York Street + * Redlands, California, USA 92373 + * + * email: contracts@esri.com + */ + +package com.arcgismaps.toolkit.featureeditorapp.screens + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.arcgismaps.data.ArcGISFeature +import com.arcgismaps.mapping.layers.FeatureLayer +import com.arcgismaps.mapping.view.MapView +import com.arcgismaps.mapping.view.SingleTapConfirmedEvent +import com.arcgismaps.mapping.view.geometryeditor.GeometryEditor +import com.arcgismaps.toolkit.composablemap.MapState +import com.arcgismaps.toolkit.featureeditor.FeatureEditor +import com.arcgismaps.toolkit.featureeditor.FeatureEditorState +import com.arcgismaps.toolkit.featureeditor.FinishState +import com.arcgismaps.toolkit.featureforms.FeatureFormState +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.CoroutineStart +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.launch + +class FeatureEditorAppState : ViewModel(), MapState by MapState() { + + // NOTE: has to be initialized here rather than in constructor so that we + // can access the viewmodel scope to pass to the editor + val featureEditorState: FeatureEditorState + + init { + val geoemetryEditor = GeometryEditor() + setGeometryEditor(geoemetryEditor) + featureEditorState = FeatureEditorState( + FeatureEditor(geoemetryEditor, viewModelScope), + FeatureFormState(), + viewModelScope, + ) + + viewModelScope.launch(start = CoroutineStart.UNDISPATCHED) { + featureEditorState.featureEditor.onFinish.collect { + when (it) { + is FinishState.Discarded -> {} // TODO: display a Snackbar + is FinishState.Stopped -> { + val table = it.feature.featureTable + if (table == null) { + // TODO: display something + return@collect + } + // TODO: handle errors here + // TODO: does can't update imply can add? + if (table.canUpdate(it.feature)) table.updateFeature(it.feature) + else table.addFeature(it.feature) + } + } + } + } + } + + context(MapView, CoroutineScope) override fun onSingleTapConfirmed(singleTapEvent: SingleTapConfirmedEvent) { + launch { + val identifyResult = identifyLayers( + screenCoordinate = singleTapEvent.screenCoordinate, + tolerance = 22.0, + returnPopupsOnly = false + ).getOrNull() ?: return@launch + + val selectedFeature = identifyResult.firstNotNullOfOrNull { result -> + result.geoElements.filterIsInstance() + .firstOrNull { feature -> + (feature.featureTable?.layer as? FeatureLayer)?.featureFormDefinition != null + } + } ?: return@launch + + selectedFeature.load().getOrNull() ?: return@launch + + featureEditorState.featureEditor.start(selectedFeature) + + // Wait until the editor is stopped again before allowing more tap events so that we don't accidentally + // restart the editor by clicking on a new feature. + featureEditorState.isStarted.first { isStarted -> !isStarted } + } + } +} diff --git a/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/ui/theme/Color.kt b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/ui/theme/Color.kt new file mode 100644 index 000000000..c1f5d476f --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/ui/theme/Color.kt @@ -0,0 +1,29 @@ +/* + * + * 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.arcgismaps.toolkit.featureeditorapp.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) diff --git a/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/ui/theme/Theme.kt b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/ui/theme/Theme.kt new file mode 100644 index 000000000..7dd4dc36b --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/ui/theme/Theme.kt @@ -0,0 +1,88 @@ +/* + * + * 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.arcgismaps.toolkit.featureeditorapp.ui.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowCompat + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun FeatureEditorAppTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + val view = LocalView.current + if (!view.isInEditMode) { + SideEffect { + val window = (view.context as Activity).window + window.statusBarColor = colorScheme.primary.toArgb() + WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme + } + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} diff --git a/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/ui/theme/Type.kt b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/ui/theme/Type.kt new file mode 100644 index 000000000..079ab32e0 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/java/com/arcgismaps/toolkit/featureeditorapp/ui/theme/Type.kt @@ -0,0 +1,52 @@ +/* + * + * 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.arcgismaps.toolkit.featureeditorapp.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) diff --git a/microapps/FeatureEditorApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/microapps/FeatureEditorApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 000000000..d4dc53e21 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + diff --git a/microapps/FeatureEditorApp/app/src/main/res/drawable/ic_launcher_background.xml b/microapps/FeatureEditorApp/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 000000000..4a1d1e128 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/microapps/FeatureEditorApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 000000000..9b6037130 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/microapps/FeatureEditorApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 000000000..9b6037130 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 000000000..c209e78ec Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 000000000..b2dfe3d1b Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 000000000..4f0f1d64e Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 000000000..62b611da0 Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 000000000..948a3070f Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 000000000..1b9a6956b Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 000000000..28d4b77f9 Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 000000000..9287f5083 Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 000000000..aa7d6427e Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 000000000..9126ae37c Binary files /dev/null and b/microapps/FeatureEditorApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/microapps/FeatureEditorApp/app/src/main/res/values/colors.xml b/microapps/FeatureEditorApp/app/src/main/res/values/colors.xml new file mode 100644 index 000000000..1ca186a31 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/res/values/colors.xml @@ -0,0 +1,28 @@ + + + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + diff --git a/microapps/FeatureEditorApp/app/src/main/res/values/strings.xml b/microapps/FeatureEditorApp/app/src/main/res/values/strings.xml new file mode 100644 index 000000000..e1b909fe6 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/res/values/strings.xml @@ -0,0 +1,21 @@ + + + + FeatureEditorApp + diff --git a/microapps/FeatureEditorApp/app/src/main/res/values/themes.xml b/microapps/FeatureEditorApp/app/src/main/res/values/themes.xml new file mode 100644 index 000000000..6f1ab3c15 --- /dev/null +++ b/microapps/FeatureEditorApp/app/src/main/res/values/themes.xml @@ -0,0 +1,23 @@ + + + + + +