Skip to content

Samples project: Code cleanup #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ build/
Icon?
ehthumbs.db
Thumbs.db
*.salive
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.activity.enableEdgeToEdge
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import com.esri.arcgismaps.kotlin.sampleviewer.BuildConfig
import com.esri.arcgismaps.kotlin.sampleviewer.R
import com.esri.arcgismaps.kotlin.sampleviewer.ui.components.SampleViewerTopAppBar
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
import androidx.core.net.toUri

/**
* Showcase information about the application.
Expand Down Expand Up @@ -213,7 +214,7 @@ private fun PoweredBySection() {
.clickable {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/Esri/arcgis-runtime-toolkit-android")
"https://github.com/Esri/arcgis-runtime-toolkit-android".toUri()
)
context.startActivity(intent)
},
Expand Down Expand Up @@ -242,7 +243,7 @@ private fun PoweredBySection() {
.clickable {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://developers.arcgis.com/kotlin/")
"https://developers.arcgis.com/kotlin/".toUri()
)
context.startActivity(intent)
},
Expand Down Expand Up @@ -308,7 +309,7 @@ private fun EsriCommunitySection() {
.clickable {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://community.esri.com/t5/kotlin-maps-sdk-questions/bd-p/kotlin-maps-sdk-questions")
"https://community.esri.com/t5/kotlin-maps-sdk-questions/bd-p/kotlin-maps-sdk-questions".toUri()
)
context.startActivity(intent)
}
Expand Down Expand Up @@ -376,7 +377,7 @@ fun AcknowledgementsDialog(onDismissRequest: () -> Unit) {
OutlinedButton(onClick = {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/showdownjs/showdown/blob/master/LICENSE")
"https://github.com/showdownjs/showdown/blob/master/LICENSE".toUri()
)
context.startActivity(intent)
}) {
Expand All @@ -385,7 +386,7 @@ fun AcknowledgementsDialog(onDismissRequest: () -> Unit) {
OutlinedButton(onClick = {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/highlightjs/highlight.js/blob/main/LICENSE")
"https://github.com/highlightjs/highlight.js/blob/main/LICENSE".toUri()
)
context.startActivity(intent)
}) {
Expand All @@ -406,7 +407,7 @@ private fun GithubSection() {
.clickable {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/Esri/arcgis-maps-sdk-kotlin-samples")
"https://github.com/Esri/arcgis-maps-sdk-kotlin-samples".toUri()
)
context.startActivity(intent)
}
Expand Down Expand Up @@ -460,7 +461,7 @@ private fun ApiDetailsSection() {
.clickable {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://developers.arcgis.com/kotlin/api-reference/")
"https://developers.arcgis.com/kotlin/api-reference/".toUri()
)
context.startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.esri.arcgismaps.kotlin.sampleviewer.ui.screens.sampleList

import android.content.Intent
import android.net.Uri
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -46,6 +45,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.lifecycle.viewmodel.compose.viewModel
import com.esri.arcgismaps.kotlin.sampleviewer.R
import com.esri.arcgismaps.kotlin.sampleviewer.model.DefaultSampleInfoRepository
Expand Down Expand Up @@ -132,7 +132,7 @@ fun ListOfSamplesScreen(
sample.metadata.title
.replace(" ", "-")
.lowercase(Locale.getDefault())
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
val intent = Intent(Intent.ACTION_VIEW, url.toUri())
context.startActivity(intent)
}
),
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]

# ArcGIS Maps SDK for Kotlin version
arcgisMapsKotlinVersion = "200.7.0-4541"
arcgisMapsKotlinVersion = "200.7.0-4549"

### Android versions
androidGradlePlugin = "8.7.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ abstract class DownloaderActivity : AppCompatActivity() {
// dismiss provision dialog question dialog
dialog.dismiss()
// set to should download
downloadRequiredContinuation.resume(true, null)
downloadRequiredContinuation.resume(true) { _, _, _ -> }
}
// if user taps "Continue" with existing folder
provisionQuestionDialog.setPositiveButton("Continue") { dialog, _ ->
// dismiss the provision question dialog
dialog.dismiss()
// set to should not download
downloadRequiredContinuation.resume(false, null)
downloadRequiredContinuation.resume(false) { _, _, _ -> }
}
}
// if folder does not exist, ask for download permission
Expand All @@ -145,7 +145,7 @@ abstract class DownloaderActivity : AppCompatActivity() {
// dismiss provision dialog
dialog.dismiss()
// set to should download
downloadRequiredContinuation.resume(true, null)
downloadRequiredContinuation.resume(true) { _, _, _ -> }
}
provisionQuestionDialog.setNegativeButton("Exit") { dialog, _ ->
dialog.dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class MessageDialogViewModel : ViewModel() {
fun showMessageDialog(exception: ArcGISException) {
showMessageDialog(
title = exception.message,
description = exception.additionalMessage.toString() + "\n" + exception.cause
description = exception.additionalInformation.toString() + "\n" + exception.cause.toString()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class AddRasterFromFileViewModel(application: Application) : AndroidViewModel(ap
val mapViewProxy = MapViewProxy()

// create a raster
val raster = Raster.createWithPath(provisionPath +
private val raster = Raster.createWithPath(provisionPath +
File.separator + "raster-file" + File.separator + "Shasta.tif")

// create a raster layer
val rasterLayer = RasterLayer(raster)
private val rasterLayer = RasterLayer(raster)

val arcGISMap = ArcGISMap(BasemapStyle.ArcGISImagery).apply {
operationalLayers.add(rasterLayer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
android:name=".DownloadActivity"
android:exported="true"
android:label="@string/apply_dictionary_renderer_to_feature_layer_app_name">


<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<resources>
<string name="augment_reality_to_show_tabletop_scene_app_name">Augment reality to show tabletop scene</string>
<string name="arcore_not_installed_screen_message">Google Play Services for AR must be installed to run this app.</string>
<string name="initialization_status">Initialization status: %1$s</string>
<string name="detect_planes_overlay">Move your phone around to detect planes…</string>
<string name="lat_lon">Lat: %1$s, Lon: %2$s</string>
<string name="tap_scene_overlay">Tap on a plane to place the scene</string>
<string name="initializing_overlay">Setting up AR…</string>
<string name="failed_to_initialize_overlay">Failed to initialize: %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import com.arcgismaps.mapping.symbology.SimpleLineSymbol
import com.arcgismaps.mapping.symbology.SimpleLineSymbolStyle
import com.arcgismaps.mapping.view.Graphic
import com.arcgismaps.mapping.view.GraphicsOverlay
import com.arcgismaps.toolkit.geoviewcompose.MapViewProxy
import com.esri.arcgismaps.sample.clipgeometry.R
import com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModel
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CreateSymbolStylesFromWebStylesViewModel(application: Application) : Andro
}

// Create a feature layer from a service
val featureLayer =
private val featureLayer =
FeatureLayer.createWithFeatureTable(ServiceFeatureTable("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/LA_County_Points_of_Interest/FeatureServer/0"))
.apply {
// Set the unique value renderer on the feature layer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
android:name=".DownloadActivity"
android:exported="true"
android:label="@string/display_device_location_with_nmea_data_sources_app_name">


<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".MainActivity"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import kotlinx.coroutines.launch
class DisplayWebSceneFromPortalItemViewModel(application: Application) : AndroidViewModel(application) {

// Create a portal
val portal = Portal("https://www.arcgis.com/")
private val portal = Portal("https://www.arcgis.com/")

// Create a portal item
val portalItem = PortalItem(portal, "31874da8a16d45bfbc1273422f772270")
private val portalItem = PortalItem(portal, "31874da8a16d45bfbc1273422f772270")

// Create a scene from the portal item
val arcGISScene = ArcGISScene(portalItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class DownloadPreplannedMapAreaViewModel(application: Application) : AndroidView
}

// Create a portal to ArcGIS Online
val portal = Portal("https://www.arcgis.com")
private val portal = Portal("https://www.arcgis.com")

// create a portal item using the portal and the item id of a map service
val portalItem = PortalItem(portal, "acc027394bc84c2fb04d1ed317aac674")
private val portalItem = PortalItem(portal, "acc027394bc84c2fb04d1ed317aac674")

private val offlineMapTask = OfflineMapTask(portalItem)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.launch
import java.io.File
import java.io.FileOutputStream
import androidx.core.graphics.drawable.toDrawable

class MainActivity : AppCompatActivity() {

Expand Down Expand Up @@ -205,10 +206,7 @@ class MainActivity : AppCompatActivity() {
// fetch the attachment data
attachment.fetchData().onSuccess {
// create a drawable from InputStream, then create the Bitmap
val bitmapDrawable = BitmapDrawable(
resources,
BitmapFactory.decodeByteArray(it, 0, it.size)
)
val bitmapDrawable = BitmapFactory.decodeByteArray(it, 0, it.size).toDrawable(resources)
// create a file output stream using the attachment file
FileOutputStream(file).use { imageOutputStream ->
// compress the bitmap to PNG format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class FindNearestVertexViewModel(application: Application) : AndroidViewModel(ap
private val statePlaneCaliforniaZone5SpatialReference = SpatialReference(2229)

// create a portal
val portal = Portal("https://arcgisruntime.maps.arcgis.com")
private val portal = Portal("https://arcgisruntime.maps.arcgis.com")

// get the USA States Generalized Boundaries layer from the portal using its ID
val portalItem =
private val portalItem =
PortalItem(
portal = portal,
itemId = "8c2d6d7df8fa4142b0a1211c8dd66903"
Expand Down Expand Up @@ -102,7 +102,7 @@ class FindNearestVertexViewModel(application: Application) : AndroidViewModel(ap
)

// create a polygon geometry
val polygon = PolygonBuilder(statePlaneCaliforniaZone5SpatialReference) {
private val polygon = PolygonBuilder(statePlaneCaliforniaZone5SpatialReference) {
addPoint(Point(x = 6627416.41469281, y = 1804532.53233782))
addPoint(Point(x = 6669147.89779046, y = 2479145.16609522))
addPoint(Point(x = 7265673.02678292, y = 2484254.50442408))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
android:name=".DownloadActivity"
android:exported="true"
android:label="@string/find_route_in_transport_network_app_name">


<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".MainActivity"
Expand Down
1 change: 0 additions & 1 deletion samples/find-route/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
<string name="find_route_app_name">Find route</string>
<string name="directions">Directions</string>
<string name="collapse_directions">Collapse directions</string>
<string name="display_directions_button">Display Directions button</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources>
<string name="generate_geodatabase_replica_from_feature_service_app_name">Generate geodatabase replica from feature service</string>
<string name="generate_button_text">Generate</string>
<string name="dialog_title">Generating geodatabase replica...</string>
<string name="dialog_title">Generating geodatabase replica</string>
<string name="reset_map">Reset map</string>
</resources>

This file was deleted.

Loading
Loading