Skip to content

Commit 2c1d7ad

Browse files
authored
Support LocationDisplay (#160)
* add location display micro app * add location permissions * add support for location display * screen to start/stop a location display * fix typo * show error message if location display fails to start * add AppBar and auto pan mode options * fix type of key * improve doc * add readme * adjust screen shot size * adjust screen shot size * set MapView properties in the update callback * use by remember for mutable state * set error message when LDS fails to start when toggling switch * fix doc references to composable Map
1 parent fa1e0e9 commit 2c1d7ad

File tree

35 files changed

+1164
-4
lines changed

35 files changed

+1164
-4
lines changed

Diff for: microapps/LocationDisplayApp/.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

Diff for: microapps/LocationDisplayApp/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Location Display Micro-app
2+
3+
This micro-app demonstrates the use of `LocationDisplay` with a composable `Map`.
4+
5+
![Screenshot](screenshot.png)
6+
7+
## Usage
8+
9+
The application starts with a `LocationDisplay` set up and started. Use the switch in the app bar to start/stop the location display.
10+
Use the overflow action button in the app bar to choose between different `LocationDisplayAutoPanMode` options.
11+
12+
For more information on the composable `Map` component and how it works, see it's [Readme](../../toolkit/geo-compose/README.md).

Diff for: microapps/LocationDisplayApp/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: microapps/LocationDisplayApp/app/build.gradle.kts

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
*
3+
* Copyright 2023 Esri
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
plugins {
20+
id("com.android.application")
21+
id("org.jetbrains.kotlin.android")
22+
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
23+
}
24+
25+
secrets {
26+
// this file doesn't contain secrets, it just provides defaults which can be committed into git.
27+
defaultPropertiesFileName = "secrets.defaults.properties"
28+
}
29+
30+
android {
31+
namespace = "com.arcgismaps.toolkit.locationdisplayapp"
32+
compileSdk = libs.versions.compileSdk.get().toInt()
33+
34+
defaultConfig {
35+
applicationId ="com.arcgismaps.toolkit.locationdisplayapp"
36+
minSdk = libs.versions.minSdk.get().toInt()
37+
targetSdk = libs.versions.compileSdk.get().toInt()
38+
versionCode = 1
39+
versionName = "1.0"
40+
41+
testInstrumentationRunner ="androidx.test.runner.AndroidJUnitRunner"
42+
vectorDrawables {
43+
useSupportLibrary = true
44+
}
45+
}
46+
47+
buildTypes {
48+
release {
49+
isMinifyEnabled = false
50+
//proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"),("proguard-rules.pro"
51+
}
52+
}
53+
compileOptions {
54+
sourceCompatibility = JavaVersion.VERSION_1_8
55+
targetCompatibility = JavaVersion.VERSION_1_8
56+
}
57+
kotlinOptions {
58+
jvmTarget = "1.8"
59+
}
60+
@Suppress("UnstableApiUsage")
61+
buildFeatures {
62+
compose = true
63+
buildConfig = true
64+
}
65+
66+
composeOptions {
67+
kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get()
68+
}
69+
packaging {
70+
resources {
71+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
72+
}
73+
}
74+
}
75+
76+
// context receivers are not experimental anymore, but AS thinks they are.
77+
//https://youtrack.jetbrains.com/issue/KTIJ-21063
78+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).all {
79+
kotlinOptions.freeCompilerArgs += "-Xcontext-receivers"
80+
}
81+
82+
dependencies {
83+
implementation(project(":geo-compose"))
84+
implementation(arcgis.mapsSdk)
85+
implementation(libs.bundles.composeCore)
86+
implementation(libs.bundles.core)
87+
implementation(libs.androidx.lifecycle.runtime.ktx)
88+
implementation(libs.androidx.activity.compose)
89+
implementation(libs.androidx.lifecycle.viewmodel.compose)
90+
testImplementation(libs.bundles.unitTest)
91+
androidTestImplementation(libs.bundles.composeTest)
92+
debugImplementation(libs.bundles.debug)
93+
}

Diff for: microapps/LocationDisplayApp/app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
*
3+
* Copyright 2023 Esri
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package com.arcgismaps.toolkit.locationdisplayapp
20+
21+
import androidx.test.ext.junit.runners.AndroidJUnit4
22+
import androidx.test.platform.app.InstrumentationRegistry
23+
import org.junit.Assert.*
24+
import org.junit.Test
25+
import org.junit.runner.RunWith
26+
27+
/**
28+
* Instrumented test, which will execute on an Android device.
29+
*
30+
* See [testing documentation](http://d.android.com/tools/testing).
31+
*/
32+
@RunWith(AndroidJUnit4::class)
33+
class ExampleInstrumentedTest {
34+
@Test
35+
fun useAppContext() {
36+
// Context of the app under test.
37+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
38+
assertEquals("com.arcgismaps.toolkit.locationdisplayapp", appContext.packageName)
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~
4+
~ Copyright 2023 Esri
5+
~
6+
~ Licensed under the Apache License, Version 2.0 (the "License");
7+
~ you may not use this file except in compliance with the License.
8+
~ You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
~
18+
-->
19+
20+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
21+
xmlns:tools="http://schemas.android.com/tools">
22+
23+
<uses-permission android:name="android.permission.INTERNET" />
24+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
25+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
26+
27+
<application
28+
android:allowBackup="true"
29+
android:dataExtractionRules="@xml/data_extraction_rules"
30+
android:fullBackupContent="@xml/backup_rules"
31+
android:icon="@mipmap/ic_launcher"
32+
android:label="@string/app_name"
33+
android:roundIcon="@mipmap/ic_launcher_round"
34+
android:supportsRtl="true"
35+
android:theme="@style/Theme.LocationDisplayApp"
36+
tools:targetApi="31">
37+
<activity
38+
android:name=".MainActivity"
39+
android:exported="true"
40+
android:theme="@style/Theme.LocationDisplayApp">
41+
<intent-filter>
42+
<action android:name="android.intent.action.MAIN" />
43+
44+
<category android:name="android.intent.category.LAUNCHER" />
45+
</intent-filter>
46+
</activity>
47+
</application>
48+
49+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
*
3+
* Copyright 2023 Esri
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package com.arcgismaps.toolkit.locationdisplayapp
20+
21+
import android.os.Bundle
22+
import androidx.activity.ComponentActivity
23+
import androidx.activity.compose.setContent
24+
import androidx.compose.runtime.Composable
25+
import androidx.compose.ui.tooling.preview.Preview
26+
import com.arcgismaps.ApiKey
27+
import com.arcgismaps.ArcGISEnvironment
28+
import com.arcgismaps.toolkit.locationdisplayapp.screens.MainScreen
29+
import com.arcgismaps.toolkit.locationdisplayapp.ui.theme.LocationDisplayAppTheme
30+
31+
class MainActivity : ComponentActivity() {
32+
override fun onCreate(savedInstanceState: Bundle?) {
33+
super.onCreate(savedInstanceState)
34+
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.API_KEY)
35+
36+
setContent {
37+
LocationDisplayAppTheme {
38+
LocationDisplayApp()
39+
}
40+
}
41+
}
42+
}
43+
44+
@Composable
45+
fun LocationDisplayApp() {
46+
MainScreen()
47+
}
48+
49+
@Preview(showBackground = true)
50+
@Composable
51+
fun AppPreview() {
52+
LocationDisplayAppTheme {
53+
LocationDisplayApp()
54+
}
55+
}

0 commit comments

Comments
 (0)