Skip to content

Commit

Permalink
Merge branch 'v.next' into nour/edit-and-sync-features-with-feature-s…
Browse files Browse the repository at this point in the history
…ervice-compose
  • Loading branch information
NourdotSiwar authored Jul 29, 2024
2 parents b5b3422 + b4a5bd3 commit 6f04e8d
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PR to add a new Kotlin sample _"SAMPLE_NAME"_ in `SAMPLE_CATEGORY` category.
## Links and Data
<!--
Sample Epic: `runtime/kotlin/issues/ISSUE_NUMBER`
- a [vTest](https://runtime-kotlin.esri.com/view/all/job/vtest/job/sampleviewer/) Job for this PR has been run
- [ ] link:
-->
## What To Review
<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.arcgismaps.LicenseKey
import com.esri.arcgismaps.sample.configurebasemapstyleparameters.screens.MainScreen
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.rounded.Close
import androidx.compose.material3.Divider
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -215,7 +215,7 @@ private fun ClusterControlsBottomSheet(
Text("Current map scale:")
Text("1:$mapScale")
}
Divider(Modifier.padding(vertical = 12.dp, horizontal = 8.dp))
HorizontalDivider(Modifier.padding(vertical = 12.dp, horizontal = 8.dp))
Text(
"Clustering properties:",
style = MaterialTheme.typography.titleMedium
Expand Down Expand Up @@ -282,7 +282,7 @@ private fun ClusterRadiusControls(
})
// show a divider between dropdown menu options
if (index < clusterRadiusOptions.lastIndex) {
Divider()
HorizontalDivider()
}
}
}
Expand Down Expand Up @@ -336,7 +336,7 @@ private fun ClusterMaxScaleControls(
})
// show a divider between dropdown menu options
if (index < clusterMaxScaleOptions.lastIndex) {
Divider()
HorizontalDivider()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import com.esri.arcgismaps.sample.createplanarandgeodeticbuffers.databinding.Act
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.slider.Slider
import kotlinx.coroutines.launch
import java.util.Locale

class MainActivity : AppCompatActivity() {

Expand Down Expand Up @@ -163,10 +164,10 @@ class MainActivity : AppCompatActivity() {
bufferSlider.value = bufferInMiles

// set initial buffer text
bufferValue.text = String.format("%d miles", bufferSlider.value.toInt())
bufferValue.text = String.format(Locale.getDefault(),"%d miles", bufferSlider.value.toInt())
bufferSlider.addOnChangeListener { _, value, _ ->
// update buffer text value on slider change
bufferValue.text = String.format("%d miles", value.toInt())
bufferValue.text = String.format(Locale.getDefault(),"%d miles", value.toInt())
bufferInMiles = value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.launch
import java.util.Locale

class AttachmentsBottomSheet(
context: MainActivity,
Expand All @@ -32,8 +33,8 @@ class AttachmentsBottomSheet(

bottomSheetBinding.apply {
// set the selected feature's information
damageStatus.text = String.format("Damage type: %s", damageType)
numberOfAttachments.text = String.format("Number of attachments: %d", attachments.size)
damageStatus.text = String.format(Locale.getDefault(),"Damage type: %s", damageType)
numberOfAttachments.text = String.format(Locale.getDefault(),"Number of attachments: %d", attachments.size)
// get the adapter to display the list of attachments
listView.adapter = AttachmentsAdapter(context, attachments)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
style="?attr/materialButtonOutlinedStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="reset"
android:text="@string/add_attachment"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.arcgismaps.Color
import com.arcgismaps.data.Geodatabase
import com.arcgismaps.data.ServiceFeatureTable
import com.arcgismaps.geometry.Envelope
import com.arcgismaps.geometry.SpatialReference
import com.arcgismaps.mapping.ArcGISMap
Expand Down Expand Up @@ -76,8 +77,20 @@ class MainActivity : AppCompatActivity() {
getExternalFilesDir(null)?.path + getString(R.string.portland_trees_geodatabase_file)
}

// keep track of the geodatabase replica generated by the feature service
private var geodatabase: Geodatabase? = null

private val downloadArea: Graphic = Graphic()

// create a Trees FeatureLayer using the first layer of the ServiceFeatureTable
private val featureLayer: FeatureLayer by lazy {
FeatureLayer.createWithFeatureTable(
featureTable = ServiceFeatureTable(
uri = application.getString(R.string.feature_server_url) + "/0"
)
)
}

// creates a graphic overlay
private val graphicsOverlay: GraphicsOverlay = GraphicsOverlay()

Expand All @@ -90,7 +103,9 @@ class MainActivity : AppCompatActivity() {
lifecycle.addObserver(mapView)

// create and add a map with a Topographic basemap style
val map = ArcGISMap(BasemapStyle.ArcGISTopographic)
val map = ArcGISMap(BasemapStyle.ArcGISTopographic).apply {
operationalLayers.add(featureLayer)
}
// set the max map extents to that of the feature service
// representing portland area
map.maxExtent = Envelope(
Expand Down Expand Up @@ -125,6 +140,10 @@ class MainActivity : AppCompatActivity() {
graphicsOverlay.graphics.clear()
// add the download boundary
graphicsOverlay.graphics.add(downloadArea)
// add back the feature layer
map.operationalLayers.add(featureLayer)
// close the current geodatabase, if a replica was already generated
geodatabase?.close()
// show generate button
generateButton.isEnabled = true
resetButton.isEnabled = false
Expand Down Expand Up @@ -224,7 +243,7 @@ class MainActivity : AppCompatActivity() {
progress.collect { value ->
// update the progress bar and progress text
progressDialog.progressBar.progress = value
progressDialog.progressTextView.text = "$value%"
progressDialog.progressTextView.text = value.toString()
}
}
// start the generateGeodatabase job
Expand Down Expand Up @@ -252,24 +271,28 @@ class MainActivity : AppCompatActivity() {
}

/**
* Loads the [geodatabase] and renders the feature layers on to the [map]
* Loads the [replicaGeodatabase] and renders the feature layers on to the [map]
*/
private suspend fun loadGeodatabase(geodatabase: Geodatabase, map: ArcGISMap) {
private suspend fun loadGeodatabase(replicaGeodatabase: Geodatabase, map: ArcGISMap) {
// clear any layers already on the map
map.operationalLayers.clear()
// clear all symbols drawn
graphicsOverlay.graphics.clear()

// load the geodatabase
geodatabase.load().onFailure {
replicaGeodatabase.load().onFailure {
// if the load failed, show the error and return
showError("Error loading geodatabase")
return
}

// add all of the geodatabase feature tables to the map as feature layers
map.operationalLayers += geodatabase.featureTables.map { featureTable ->
map.operationalLayers += replicaGeodatabase.featureTables.map { featureTable ->
FeatureLayer.createWithFeatureTable(featureTable)
}

// keep track of the geodatabase to close it before generating a new replica
geodatabase = replicaGeodatabase
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.esri.arcgismaps.sample.generateofflinemapusingandroidjetpackworkmanager

import android.annotation.SuppressLint
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
Expand Down Expand Up @@ -98,6 +99,7 @@ class WorkerNotification(
* Creates and posts a new status notification with the [message] and dismisses any ongoing
* progress notifications
*/
@SuppressLint("MissingPermission")
fun showStatusNotification(message: String) {
// build using the default notification builder with the status message
val notification = getDefaultNotificationBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
android:layout_height="wrap_content"
android:enabled="false"
android:text="@string/reset_map"
android:onClick="resetButtonClick"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/takeMapOfflineButton"
app:layout_constraintHorizontal_bias="0.5"
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ktxLifecycle = "2.7.0"
ktxFragmentsExt = "1.6.2"
ktxActivityExt = "1.9.0"
ktxAndroidCore = "1.13.0"
kotlinCompilerExt = "1.5.11"
kotlinCompilerExt = "1.5.12"
# Compose versions
composeActivityVersion = "1.9.0"
composeBOM = "2024.04.01"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.launch
import com.esri.arcgismaps.sample.sampleslib.*
import java.time.Instant
import java.util.concurrent.atomic.AtomicBoolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.arcgismaps.mapping.view.MapView
import com.esri.arcgismaps.sample.projectgeometry.databinding.ActivityMainBinding
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.launch
import java.util.Locale

class MainActivity : AppCompatActivity() {

Expand Down Expand Up @@ -150,4 +151,4 @@ class MainActivity : AppCompatActivity() {
* a float-precision formatted string suitable for display
*/
private fun Point.toDisplayFormat() =
"${String.format("%.5f", x)}, ${String.format("%.5f", y)}"
"${String.format(Locale.getDefault(),"%.5f", x)}, ${String.format(Locale.getDefault(),"%.5f", y)}"
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
Expand All @@ -37,7 +38,7 @@ fun BottomSheet(
isVisible: Boolean,
bottomSheetContent: @Composable () -> Unit
) {
BoxWithConstraints(
Box(
modifier = Modifier.fillMaxSize()
) {
AnimatedVisibility(
Expand Down
2 changes: 1 addition & 1 deletion samples-lib/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<string name="already_provisioned">This device has already been provisioned with the requisite data for this
sample.
</string>
<string name="downloading_data">Downloading data...</string>
<string name="downloading_data">Downloading data</string>
<string name="cancel">Cancel</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import com.arcgismaps.mapping.view.MapViewInteractionOptions
import com.arcgismaps.toolkit.geoviewcompose.MapView
import com.esri.arcgismaps.sample.sampleslib.components.BottomSheet
import com.esri.arcgismaps.sample.sampleslib.components.MessageDialog
Expand Down

0 comments on commit 6f04e8d

Please sign in to comment.