Skip to content

Commit

Permalink
Release v200.1.0 (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham7109 authored Apr 19, 2023
1 parent ccd500f commit 2b8ddb4
Show file tree
Hide file tree
Showing 1,004 changed files with 26,002 additions and 610 deletions.
43 changes: 29 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,59 @@
# ArcGIS Maps SDK Kotlin Samples

# Overview
ArcGIS Maps SDK for Kotlin v200.0.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.
## Overview

ArcGIS Maps SDK for Kotlin v200.1.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

# Prerequisites
* The samples are building with `compileSdkVersion 33`
* [Android Studio](http://developer.android.com/sdk/index.html)
* [An ArcGIS Developers API key](https://developers.arcgis.com/kotlin/get-started/#3-get-an-api-key)

## Developer Instructions
Please read our [developer instructions wiki page](https://github.com/Esri/arcgis-maps-sdk-kotlin-samples/wiki/dev-instructions) to set up your developer environment with Android Studio. Instructions include forking and cloning the repository for those new to Git.

Please read our [developer instructions wiki page](https://github.com/Esri/arcgis-maps-sdk-kotlin-samples/wiki/Developer-Instructions) to set up your developer environment with Android Studio. Instructions include forking and cloning the repository for those new to Git.

Once the project is cloned to disk you can import into Android Studio:

* From the Welcome to Android Studio screen, click the **Open** button. (If you're already inside a project, click **File > Open** in the menu bar instead.)
* Navigate to the **arcgis-maps-sdk-kotlin-samples/** folder and click **OK**.

## Accessing Esri location services

Accessing Esri location services, including basemaps, routing, and geocoding, requires authentication using either an API Key or an ArcGIS identity:
1. API key: A permanent key that gives your application access to Esri location services. Visit your [ArcGIS Developers Dashboard](https://developers.arcgis.com/dashboard) to create a new API key or access an existing API key.

The Android samples in this repository have been structured to use an API key, set once, which will run in all samples. Set your API key in the `gradle.properties` file located in the `/.gradle` folder within your home directory (`/Users/<user_name>/.gradle/gradle.properties`). The API_KEY property should contain quotes around the key itself: `API_KEY = "YOUR_API_KEY"`

2. ArcGIS identity: An ArcGIS named user account that is a member of an organization in ArcGIS Online or ArcGIS Enterprise.
### API key

A permanent key that gives your application access to Esri location services. Visit your [ArcGIS Developers Dashboard](https://developers.arcgis.com/dashboard) to create a new API key or access an existing API key.
The Android samples in this repository have been structured to use an API key, set once, which will run in all samples.
Set your API key in the `gradle.properties` file located in the `/.gradle` folder within your home directory.
The API_KEY property should contain quotes around the key itself:
```gradle
API_KEY = "YOUR_API_KEY" // path: /Users/<user_name>/.gradle/gradle.properties
```

### ArcGIS identity

An ArcGIS named user account that is a member of an organization in ArcGIS Online or ArcGIS Enterprise.

## Run a sample
Once you have set up your developer environment you can run any sample from within Android Studio by selecting the app module from the **Edit Configurations** drop down and clicking the **Run** button from the toolbar.

Once you have set up your developer environment you can run any sample from within Android Studio by selecting the app module from the **Edit Configurations** drop down and clicking the **Run** button from the toolbar.

### Build/Run sample from Gradle

You can execute all the build tasks using the [Gradle Wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) command line tool. It's available as a batch file for Windows (gradlew.bat) and a shell script for Linux/Mac (gradlew.sh) and it is accessible from the root of the project.

- Build a debug APK
* Build a debug APK

```
$ ./gradlew assembleDebug
```

- Run the app
* Install the app on the device

**Device**
```
```adb
adb -d install path/to/sample.apk
```

Expand All @@ -53,8 +67,8 @@ Do you have something to [contribute](.github/CONTRIBUTING.md)? Send a pull requ

Have a problem running one of the samples in this repo? Does the sample not work on a specific device? Have questions about how the code in this repo is working? Want to request a specific sample? In that case, [submit a new issue](https://github.com/Esri/arcgis-maps-sdk-kotlin-samples/issues).


## Contributing

Anyone and everyone is welcome to [contribute](.github/CONTRIBUTING.md). We do accept pull requests.

1. Get Involved
Expand All @@ -65,6 +79,7 @@ Anyone and everyone is welcome to [contribute](.github/CONTRIBUTING.md). We do a
Please see our [guidelines for contributing doc](https://github.com/Esri/contributing/blob/master/README.md)

## Licensing

Copyright 2022 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
Expand Down
3 changes: 1 addition & 2 deletions add-feature-layers/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
</activity>
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,13 @@ import com.arcgismaps.mapping.BasemapStyle
import com.arcgismaps.mapping.Viewpoint
import com.arcgismaps.mapping.layers.FeatureLayer
import com.arcgismaps.portal.Portal
import com.arcgismaps.portal.PortalItem
import com.arcgismaps.mapping.PortalItem
import com.esri.arcgismaps.sample.addfeaturelayers.databinding.ActivityMainBinding
import kotlinx.coroutines.launch
import java.io.File


class MainActivity : AppCompatActivity() {

private val TAG = MainActivity::class.java.simpleName

// set up data binding for the activity
private val activityMainBinding: ActivityMainBinding by lazy {
DataBindingUtil.setContentView(this, R.layout.activity_main)
Expand Down Expand Up @@ -102,7 +99,7 @@ class MainActivity : AppCompatActivity() {
val serviceFeatureTable =
ServiceFeatureTable(resources.getString(R.string.sample_service_url))
// create a feature layer with the feature table
val featureLayer = FeatureLayer(serviceFeatureTable)
val featureLayer = FeatureLayer.createWithFeatureTable(serviceFeatureTable)
val viewpoint = Viewpoint(41.70, -88.20, 120000.0)
// set the feature layer on the map
setFeatureLayer(featureLayer, viewpoint)
Expand All @@ -119,7 +116,7 @@ class MainActivity : AppCompatActivity() {
val portalItem = PortalItem(portal, "1759fd3e8a324358a0c58d9a687a8578")
portalItem.load().onSuccess {
// create the feature layer with the item
val featureLayer = FeatureLayer(portalItem)
val featureLayer = FeatureLayer.createWithItem(portalItem)
// set the viewpoint to Portland, Oregon
val viewpoint = Viewpoint(45.5266, -122.6219, 2500.0)
// set the feature layer on the map
Expand Down Expand Up @@ -147,7 +144,7 @@ class MainActivity : AppCompatActivity() {
return
}
// create a feature layer with the feature table
val featureLayer = FeatureLayer(geodatabaseFeatureTable)
val featureLayer = FeatureLayer.createWithFeatureTable(geodatabaseFeatureTable)
// set the viewpoint to Malibu, California
val viewpoint = Viewpoint(34.0772, -118.7989, 600000.0)
// set the feature layer on the map
Expand All @@ -170,7 +167,7 @@ class MainActivity : AppCompatActivity() {
// get the first feature table in the geopackage
val geoPackageFeatureTable = geoPackage.geoPackageFeatureTables.first()
// create a feature layer with the feature table
val featureLayer = FeatureLayer(geoPackageFeatureTable)
val featureLayer = FeatureLayer.createWithFeatureTable(geoPackageFeatureTable)
// set the viewpoint to Denver, CO
val viewpoint = Viewpoint(39.7294, -104.8319, 500000.0)
// set the feature layer on the map
Expand All @@ -193,7 +190,7 @@ class MainActivity : AppCompatActivity() {
val shapeFileTable = ShapefileFeatureTable(file.path)
shapeFileTable.load().onSuccess {
// create a feature layer for the shapefile feature table
val featureLayer = FeatureLayer(shapeFileTable)
val featureLayer = FeatureLayer.createWithFeatureTable(shapeFileTable)
// set the viewpoint to Scotland
val viewpoint = Viewpoint(56.641344, -3.889066, 6000000.0)
// set the feature layer on the map
Expand All @@ -205,7 +202,7 @@ class MainActivity : AppCompatActivity() {

private fun showError(message: String) {
Toast.makeText(this@MainActivity, message, Toast.LENGTH_SHORT).show()
Log.e(TAG, message)
Log.e(localClassName, message)
}

/**
Expand Down
6 changes: 0 additions & 6 deletions add-feature-layers/src/main/res/values/colors.xml

This file was deleted.

11 changes: 0 additions & 11 deletions add-feature-layers/src/main/res/values/styles.xml

This file was deleted.

1 change: 1 addition & 0 deletions add-features-with-contingent-values/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
55 changes: 55 additions & 0 deletions add-features-with-contingent-values/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Add features with contingent values

Create and add features whose attribute values satisfy a predefined set of contingencies.

![Add features with contingent values](add-features-with-contingent-values.png)

## Use case

Contingent values are a data design feature that allow you to make values in one field dependent on values in another field. Your choice for a value on one field further constrains the domain values that can be placed on another field. In this way, contingent values enforce data integrity by applying additional constraints to reduce the number of valid field inputs.

For example, a field crew working in a sensitive habitat area may be required to stay a certain distance away from occupied bird nests, but the size of that exclusion area differs depending on the bird's level of protection according to presiding laws. Surveyors can add points of bird nests in the work area and their selection of the size of the exclusion area will be contingent on the values in other attribute fields.

## How to use the sample

Tap on the map to add a feature symbolizing a bird's nest. Then choose values describing the nest's status, protection, and buffer size. Notice how different values are available depending on the values of preceding fields. Once the contingent values are validated, tap "Done" to add the feature to the map.

## How it works

1. Create and load the `Geodatabase` from the mobile geodatabase location on file.
2. Load the first `GeodatabaseFeatureTable`.
3. Load the `ContingentValuesDefinition` from the feature table.
4. Create a new `FeatureLayer` from the feature table and add it to the map.
5. Create a new `ArcGISFeature` using `GeodatabaseFeatureTable.createFeature()`
6. Get the first field by name using `ArcGISFeatureTable.fields.find{ }`.
7. Then get the `Field.domain` as an `CodedValueDomain`.
8. Get the coded value domain's `codedValues` to get an array of `CodedValue`'s.
9. After selecting a value from the initial coded values for the first field, retrieve the remaining valid contingent values for each field as you select the values for the attributes.
i. Get the `ContingentValueResult`s by using `ArcGISFeatureTable.getContingentValues(ArcGISFeature, "field_name")` with the feature and the target field by name.
ii. Get an array of valid `ContingentValues` from `ContingentValuesResult.contingentValuesByFieldGroup` dictionary with the name of the relevant field group.
iii. Iterate through the array of valid contingent values to create an array of `ContingentCodedValue` names or the minimum and maximum values of a `ContingentRangeValue` depending on the type of `ContingentValue` returned.
10. Validate the feature's contingent values by using `validateContingencyConstraints(feature)` with the current feature. If the resulting array is empty, the selected values are valid.

## Relevant API

* ArcGISFeatureTable
* CodedValue
* CodedValueDomain
* ContingencyConstraintViolation
* ContingentCodedValue
* ContingentRangeValue
* ContingentValuesDefinition
* ContingentValuesResult

## About the data

This sample uses the [Contingent values birds nests](https://arcgis.com/home/item.html?id=e12b54ea799f4606a2712157cf9f6e41) mobile geodatabase and the [Fillmore topographic map](https://arcgis.com/home/item.html?id=b5106355f1634b8996e634c04b6a930a) vector tile package for the basemap.
The mobile geodatabase contains birds nests in the Fillmore area, defined with contingent values. Each feature contains information about its status, protection, and buffer size.

## Additional information

Learn more about contingent values and how to utilize them on the [ArcGIS Pro documentation](https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/contingent-values.htm).

## Tags

coded values, contingent values, feature table, geodatabase
42 changes: 42 additions & 0 deletions add-features-with-contingent-values/README.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"category": "Edit and Manage Data",
"description": "Create and add features whose attribute values satisfy a predefined set of contingencies.",
"formal_name": "AddFeaturesWithContingentValues",
"ignore": false,
"images": [
"add-features-with-contingent-values.png"
],
"keywords": [
"coded values",
"contingent values",
"feature table",
"geodatabase",
"ArcGISFeatureTable",
"CodedValue",
"CodedValueDomain",
"ContingencyConstraintViolation",
"ContingentCodedValue",
"ContingentRangeValue",
"ContingentValuesDefinition",
"ContingentValuesResult"
],
"language": "kotlin",
"redirect_from": [
"/android/latest/sample-code/add-features-with-contingent-values.htm"
],
"relevant_apis": [
"ArcGISFeatureTable",
"CodedValue",
"CodedValueDomain",
"ContingencyConstraintViolation",
"ContingentCodedValue",
"ContingentRangeValue",
"ContingentValuesDefinition",
"ContingentValuesResult"
],
"snippets": [
"src/main/java/com/esri/arcgismaps/sample/addfeatureswithcontingentvalues/MainActivity.kt",
"src/main/java/com/esri/arcgismaps/sample/addfeatureswithcontingentvalues/DownloadActivity.kt"
],
"title": "Add features with contingent values"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions add-features-with-contingent-values/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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
}

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'
}
21 changes: 21 additions & 0 deletions add-features-with-contingent-values/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
35 changes: 35 additions & 0 deletions add-features-with-contingent-values/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".DownloadActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>

</manifest>
Loading

0 comments on commit 2b8ddb4

Please sign in to comment.