Skip to content

Commit cd3984a

Browse files
authored
Audit changes (#241)
1 parent a5d0799 commit cd3984a

27 files changed

+592
-842
lines changed

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/MainActivity.kt

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@ import android.os.Bundle
2020
import androidx.activity.ComponentActivity
2121
import androidx.activity.compose.setContent
2222
import androidx.activity.enableEdgeToEdge
23-
import androidx.compose.foundation.isSystemInDarkTheme
2423
import androidx.compose.material3.MaterialTheme
2524
import androidx.compose.material3.Surface
25+
import androidx.compose.runtime.CompositionLocalProvider
2626
import androidx.compose.runtime.LaunchedEffect
27-
import androidx.compose.runtime.SideEffect
28-
import androidx.compose.ui.graphics.Color
2927
import androidx.compose.ui.platform.LocalContext
3028
import androidx.lifecycle.lifecycleScope
29+
import androidx.navigation.compose.rememberNavController
3130
import com.esri.arcgismaps.kotlin.sampleviewer.model.DefaultSampleInfoRepository
31+
import com.esri.arcgismaps.kotlin.sampleviewer.navigation.LocalNavController
3232
import com.esri.arcgismaps.kotlin.sampleviewer.navigation.NavGraph
3333
import com.esri.arcgismaps.kotlin.sampleviewer.ui.theme.SampleAppTheme
34-
import com.google.accompanist.systemuicontroller.rememberSystemUiController
3534
import kotlinx.coroutines.launch
3635

3736
class MainActivity : ComponentActivity() {
@@ -40,26 +39,19 @@ class MainActivity : ComponentActivity() {
4039
enableEdgeToEdge()
4140
setContent {
4241
setContent {
43-
4442
val context = LocalContext.current
4543
LaunchedEffect(Unit) {
4644
lifecycleScope.launch {
4745
DefaultSampleInfoRepository.load(context)
4846
}
4947
}
5048

51-
// Control color of navigation bar when user changes theme
52-
val isSystemInDarkMode = isSystemInDarkTheme()
53-
val systemUiController = rememberSystemUiController()
54-
SideEffect {
55-
systemUiController.setNavigationBarColor(
56-
color = if (isSystemInDarkMode) Color.Black else Color.White,
57-
darkIcons = true
58-
)
59-
}
60-
6149
SampleAppTheme {
62-
Surface(color = MaterialTheme.colorScheme.background) { NavGraph() }
50+
Surface(color = MaterialTheme.colorScheme.background) {
51+
CompositionLocalProvider(value = LocalNavController provides rememberNavController()) {
52+
NavGraph()
53+
}
54+
}
6355
}
6456
}
6557
}

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/model/Category.kt

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,78 @@
1616

1717
package com.esri.arcgismaps.kotlin.sampleviewer.model
1818

19+
import com.esri.arcgismaps.kotlin.sampleviewer.R
20+
1921
/**
2022
* Represents a sample category.
2123
*/
2224
data class Category(
2325
val title: SampleCategory,
2426
val icon: Int,
25-
val backgroundImage: Int,
26-
)
27+
val backgroundImage: Int
28+
) {
29+
companion object {
30+
val SAMPLE_CATEGORIES = listOf(
31+
Category(
32+
SampleCategory.ANALYSIS,
33+
R.drawable.ic_analysis,
34+
R.drawable.analysis_background,
35+
),
36+
Category(
37+
SampleCategory.AUGMENTED_REALITY,
38+
R.drawable.ic_augmented_reality,
39+
R.drawable.augmented_reality_background,
40+
),
41+
Category(
42+
SampleCategory.CLOUD_AND_PORTAL,
43+
R.drawable.ic_cloud,
44+
R.drawable.cloud_background,
45+
),
46+
Category(
47+
SampleCategory.EDIT_AND_MANAGE_DATA,
48+
R.drawable.ic_manage_data,
49+
R.drawable.manage_data_background,
50+
),
51+
Category(
52+
SampleCategory.LAYERS,
53+
R.drawable.ic_layers,
54+
R.drawable.layers_background,
55+
),
56+
Category(
57+
SampleCategory.MAPS,
58+
R.drawable.ic_map,
59+
R.drawable.maps_and_scenes_background,
60+
),
61+
Category(
62+
SampleCategory.ROUTING_AND_LOGISTICS,
63+
R.drawable.ic_routing_and_logistics,
64+
R.drawable.routing_and_logistics_background,
65+
),
66+
Category(
67+
SampleCategory.SCENES,
68+
R.drawable.ic_scenes,
69+
R.drawable.scenes_background,
70+
),
71+
Category(
72+
SampleCategory.SEARCH_AND_QUERY,
73+
R.drawable.ic_search_and_query,
74+
R.drawable.search_and_query_background,
75+
),
76+
Category(
77+
SampleCategory.UTILITY_NETWORKS,
78+
R.drawable.ic_utility,
79+
R.drawable.utility_background,
80+
),
81+
Category(
82+
SampleCategory.VISUALIZATION,
83+
R.drawable.ic_visualization,
84+
R.drawable.visualization_background,
85+
),
86+
Category(
87+
SampleCategory.FAVORITES,
88+
R.drawable.ic_favorite_selected,
89+
R.drawable.maps_and_scenes_background,
90+
),
91+
)
92+
}
93+
}

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/model/Sample.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,27 @@ data class Sample(
3838
var score: Double = 0.0
3939
) {
4040
companion object {
41+
val PREVIEW_INSTANCE = Sample(
42+
name = "Analyze hotspots",
43+
codeFiles = listOf(CodeFile("", "")),
44+
url = "",
45+
readMe = "",
46+
screenshotURL = "",
47+
metadata = SampleMetadata(
48+
description = "",
49+
formalName = "Analyze hotspots",
50+
ignore = false,
51+
imagePaths = listOf(""),
52+
keywords = listOf(""),
53+
relevantApis = listOf(""),
54+
codePaths = listOf(""),
55+
sampleCategory = SampleCategory.ANALYSIS,
56+
title = "Analyze hotspots"
57+
),
58+
isFavorite = false,
59+
mainActivity = ""
60+
)
61+
4162
/**
4263
* Returns a list of [CodeFile] objects for the given sample name.
4364
*/

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/model/SampleInfoRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ interface SampleInfoRepository {
2828
fun getSampleByName(sampleName: String): Sample
2929

3030
fun getAllSamples(): List<Sample>
31-
}
31+
}

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/model/SampleMetadata.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import kotlinx.serialization.SerialName
2020
import kotlinx.serialization.Serializable
2121

2222
/**
23-
* A data class to hold detailed information about the sample
23+
* A data class to hold detailed information about the [Sample]
2424
*/
2525
@Serializable
2626
data class SampleMetadata(

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/model/room/AppDatabase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class AppDatabase : RoomDatabase() {
4343
val instance = Room.databaseBuilder(
4444
context.applicationContext,
4545
AppDatabase::class.java,
46-
"app_database"
46+
"arcgis_maps_kotlin_samples_database"
4747
).build()
4848
INSTANCE = instance
4949
instance

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/model/room/Converters.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Converters {
5050
return relevantApiJsonString.let { json.decodeFromString(it) }
5151
}
5252

53-
// Converts Sample to SampleEntity in order to select certain relevant fields
53+
// Converts Sample to SampleEntity in order to select relevant fields
5454
fun convertToEntity(sample: Sample): SampleEntity {
5555
return SampleEntity(
5656
sampleName = sample.name,

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/model/room/OkapiBM25.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,28 @@ import kotlin.math.log
2828
class OkapiBM25 {
2929

3030
companion object {
31-
3231
/**
3332
* Calculates the OkapiBM25 score for a given column in an FTS4 table.
3433
*/
35-
fun score(matchinfo: Array<Int>, column: Int, b: Double = 0.75, k1: Double = 1.2): Double {
34+
fun score(matchInfo: Array<Int>, column: Int, b: Double = 0.75, k1: Double = 1.2): Double {
3635

3736
val pOffset = 0
3837
val cOffset = 1
3938
val nOffset = 2
4039
val aOffset = 3
4140

4241
// the number of matchable phrases in the query
43-
val termCount = matchinfo[pOffset]
42+
val termCount = matchInfo[pOffset]
4443
// the number of user defined columns in the FTS table
45-
val colCount = matchinfo[cOffset]
44+
val colCount = matchInfo[cOffset]
4645

4746
val lOffset = aOffset + colCount
4847
val xOffset = lOffset + colCount
4948

5049
// the number of rows in the FTS4 table
51-
val totalDocs = matchinfo[nOffset].toDouble()
52-
val avgLength = matchinfo[aOffset + column].toDouble()
53-
val docLength = matchinfo[lOffset + column].toDouble()
50+
val totalDocs = matchInfo[nOffset].toDouble()
51+
val avgLength = matchInfo[aOffset + column].toDouble()
52+
val docLength = matchInfo[lOffset + column].toDouble()
5453

5554
var score = 0.0
5655

@@ -59,9 +58,9 @@ class OkapiBM25 {
5958
val currentX = xOffset + (3 * (column + i * colCount))
6059

6160
// in the current row, the number of times the phrase appears in the column
62-
val termFrequency = matchinfo[currentX].toDouble()
61+
val termFrequency = matchInfo[currentX].toDouble()
6362
// the total number of rows in the FTS table for which the column contains at least one instance of the phrase.
64-
val docsWithTerm = matchinfo[currentX + 2].toDouble()
63+
val docsWithTerm = matchInfo[currentX + 2].toDouble()
6564

6665
val p = totalDocs - docsWithTerm + 0.5
6766
val q = docsWithTerm + 0.5

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/model/room/SampleDao.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import androidx.room.Insert
2222
import androidx.room.OnConflictStrategy
2323
import androidx.room.Query
2424

25-
2625
/**
2726
* Holds all operations that uses Room
2827
*/

app/src/main/java/com/esri/arcgismaps/kotlin/sampleviewer/model/room/SampleEntity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import com.esri.arcgismaps.kotlin.sampleviewer.model.CodeFile
2525

2626
/**
2727
* Define the structure of the Database records. The first column and the primary key is an integer
28-
* rowid, which is a requirement of FTS4 tables. The other columns are the fields of the [Sample]
28+
* rowid, which is a requirement of FTS4 tables. The other columns are the fields of the Sample
2929
* class.
3030
*/
3131
@Fts4

0 commit comments

Comments
 (0)