Skip to content

Commit 1a51cde

Browse files
authored
Compose Sample Viewer - Audit (#240)
2 parents 30e67db + b17c093 commit 1a51cde

34 files changed

+1245
-1141
lines changed

app/build.gradle.kts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,11 @@ android {
4848
}
4949
isMinifyEnabled = false
5050
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
51+
// If signing.properties file not found, gradle will build an unsigned APK.
52+
// For release builds, provide the required "signingPropsFilePath" for a signed APK, using:
53+
// ./gradlew assembleRelease -PsigningPropsFilePath=absolute-file-path/signing.properties
5154
if (signingPropsFile.exists())
5255
signingConfig = signingConfigs.getByName("esriSignature")
53-
else {
54-
Log.e(
55-
tag = "GradleSigningException",
56-
message = "signing.properties file not found: ${signingPropsFile.absolutePath}, this will build an unsigned APK.\n" +
57-
"Please provide the required \"signingPropsFilePath\" for a signed APK, using:\n" +
58-
"./gradlew assembleRelease -PsigningPropsFilePath=absolute-file-path/signing.properties"
59-
)
60-
}
61-
6256
}
6357
}
6458

@@ -83,6 +77,8 @@ dependencies {
8377
implementation(libs.androidx.datastore.preferences)
8478
implementation(libs.androidx.room.runtime)
8579
implementation(libs.androidx.room.ktx)
80+
implementation(libs.coil.compose)
81+
implementation(libs.coil.network.http)
8682
annotationProcessor(libs.androidx.room.compiler)
8783
ksp(libs.androidx.room.compiler)
8884
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

5+
<uses-permission android:name="android.permission.INTERNET" />
6+
57
<application
68
android:allowBackup="true"
79
android:dataExtractionRules="@xml/data_extraction_rules"
@@ -15,7 +17,6 @@
1517
<activity
1618
android:name=".MainActivity"
1719
android:exported="true"
18-
android:label="@string/app_name"
1920
android:theme="@style/AppTheme">
2021
<intent-filter>
2122
<action android:name="android.intent.action.MAIN" />

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

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
1+
/* Copyright 2024 Esri
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
117
package com.esri.arcgismaps.kotlin.sampleviewer
218

319
import android.os.Bundle
420
import androidx.activity.ComponentActivity
521
import androidx.activity.compose.setContent
622
import androidx.activity.enableEdgeToEdge
7-
import androidx.compose.foundation.isSystemInDarkTheme
823
import androidx.compose.material3.MaterialTheme
924
import androidx.compose.material3.Surface
25+
import androidx.compose.runtime.CompositionLocalProvider
1026
import androidx.compose.runtime.LaunchedEffect
11-
import androidx.compose.runtime.SideEffect
12-
import androidx.compose.ui.graphics.Color
1327
import androidx.compose.ui.platform.LocalContext
1428
import androidx.lifecycle.lifecycleScope
29+
import androidx.navigation.compose.rememberNavController
1530
import com.esri.arcgismaps.kotlin.sampleviewer.model.DefaultSampleInfoRepository
31+
import com.esri.arcgismaps.kotlin.sampleviewer.navigation.LocalNavController
1632
import com.esri.arcgismaps.kotlin.sampleviewer.navigation.NavGraph
1733
import com.esri.arcgismaps.kotlin.sampleviewer.ui.theme.SampleAppTheme
18-
import com.google.accompanist.systemuicontroller.rememberSystemUiController
19-
import kotlinx.coroutines.MainScope
2034
import kotlinx.coroutines.launch
2135

2236
class MainActivity : ComponentActivity() {
@@ -25,26 +39,19 @@ class MainActivity : ComponentActivity() {
2539
enableEdgeToEdge()
2640
setContent {
2741
setContent {
28-
2942
val context = LocalContext.current
3043
LaunchedEffect(Unit) {
3144
lifecycleScope.launch {
3245
DefaultSampleInfoRepository.load(context)
3346
}
3447
}
3548

36-
// Control color of navigation bar when user changes theme
37-
val isSystemInDarkMode = isSystemInDarkTheme()
38-
val systemUiController = rememberSystemUiController()
39-
SideEffect {
40-
systemUiController.setNavigationBarColor(
41-
color = if (isSystemInDarkMode) Color.Black else Color.White,
42-
darkIcons = true
43-
)
44-
}
45-
4649
SampleAppTheme {
47-
Surface(color = MaterialTheme.colorScheme.background) { NavGraph() }
50+
Surface(color = MaterialTheme.colorScheme.background) {
51+
CompositionLocalProvider(value = LocalNavController provides rememberNavController()) {
52+
NavGraph()
53+
}
54+
}
4855
}
4956
}
5057
}
Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,93 @@
1+
/* Copyright 2024 Esri
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
117
package com.esri.arcgismaps.kotlin.sampleviewer.model
218

19+
import com.esri.arcgismaps.kotlin.sampleviewer.R
20+
321
/**
4-
* This data class is used to hold information in each CardItem in home screen
22+
* Represents a sample category.
523
*/
624
data class Category(
725
val title: SampleCategory,
826
val icon: Int,
9-
val backgroundImage: Int,
10-
)
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/CodeFile.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
/* Copyright 2024 Esri
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
117
package com.esri.arcgismaps.kotlin.sampleviewer.model
218

319
import kotlinx.serialization.Serializable
420

521
/**
6-
* A data class to hold information about the code files for each sample
22+
* Represents a single code file in a sample.
723
*/
824
@Serializable
925
data class CodeFile(

0 commit comments

Comments
 (0)