Skip to content

Commit 07e53ed

Browse files
committed
Add production key support and display build info in settings
1 parent 02714a7 commit 07e53ed

File tree

4 files changed

+210
-95
lines changed

4 files changed

+210
-95
lines changed

app/build.gradle.kts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,72 @@ android {
3030

3131
//return empty key in case something goes wrong
3232
val reAPIKey = properties.getProperty("ROBOTEVENTS_API_KEY") ?: ""
33+
val key0 = properties.getProperty("key0") ?: ""
34+
val key1 = properties.getProperty("key1") ?: ""
35+
val key2 = properties.getProperty("key2") ?: ""
36+
val key3 = properties.getProperty("key3") ?: ""
37+
val key4 = properties.getProperty("key4") ?: ""
38+
val key5 = properties.getProperty("key5") ?: ""
39+
val key6 = properties.getProperty("key6") ?: ""
40+
val key7 = properties.getProperty("key7") ?: ""
41+
val key8 = properties.getProperty("key8") ?: ""
42+
val key9 = properties.getProperty("key9") ?: ""
3343

3444
buildConfigField(
3545
type = "String",
3646
name = "ROBOTEVENTS_API_KEY",
3747
value = reAPIKey
3848
)
49+
buildConfigField(
50+
type = "String",
51+
name = "key0",
52+
value = key0
53+
)
54+
buildConfigField(
55+
type = "String",
56+
name = "key1",
57+
value = key1
58+
)
59+
buildConfigField(
60+
type = "String",
61+
name = "key2",
62+
value = key2
63+
)
64+
buildConfigField(
65+
type = "String",
66+
name = "key3",
67+
value = key3
68+
)
69+
buildConfigField(
70+
type = "String",
71+
name = "key4",
72+
value = key4
73+
)
74+
buildConfigField(
75+
type = "String",
76+
name = "key5",
77+
value = key5
78+
)
79+
buildConfigField(
80+
type = "String",
81+
name = "key6",
82+
value = key6
83+
)
84+
buildConfigField(
85+
type = "String",
86+
name = "key7",
87+
value = key7
88+
)
89+
buildConfigField(
90+
type = "String",
91+
name = "key8",
92+
value = key8
93+
)
94+
buildConfigField(
95+
type = "String",
96+
name = "key9",
97+
value = key9
98+
)
3999
}
40100

41101
buildTypes {

app/src/main/java/com/sunkensplashstudios/VRCRoboScout/LookupView.kt

Lines changed: 93 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -684,109 +684,111 @@ fun EventLookup(lookupViewModel: LookupViewModel, navController: NavController)
684684
} else {
685685
Spacer(Modifier.height(60.dp))
686686
}
687-
Column(
688-
verticalArrangement = Arrangement.SpaceBetween,
689-
modifier = Modifier
690-
.verticalScroll(rememberScrollState())
691-
.weight(1f, false)
692-
) {
693-
Card(
694-
modifier = Modifier.padding(10.dp),
695-
colors = CardColors(
696-
containerColor = MaterialTheme.colorScheme.surfaceContainer.copy(alpha = 0.5f),
697-
disabledContainerColor = Color.Unspecified.copy(alpha = 0.5f),
698-
contentColor = MaterialTheme.colorScheme.onSurface,
699-
disabledContentColor = Color.Unspecified
700-
)
687+
if (lookupViewModel.events.value.isNotEmpty()) {
688+
Column(
689+
verticalArrangement = Arrangement.SpaceBetween,
690+
modifier = Modifier
691+
.verticalScroll(rememberScrollState())
692+
.weight(1f, false)
701693
) {
702-
Column(
703-
modifier = Modifier.padding(horizontal = 5.dp, vertical = 5.dp)
694+
Card(
695+
modifier = Modifier.padding(10.dp),
696+
colors = CardColors(
697+
containerColor = MaterialTheme.colorScheme.surfaceContainer.copy(alpha = 0.5f),
698+
disabledContainerColor = Color.Unspecified.copy(alpha = 0.5f),
699+
contentColor = MaterialTheme.colorScheme.onSurface,
700+
disabledContentColor = Color.Unspecified
701+
)
704702
) {
705-
lookupViewModel.events.value.forEach { event ->
706-
Row(
707-
verticalAlignment = Alignment.CenterVertically
708-
) {
709-
Column(
710-
verticalArrangement = Arrangement.SpaceBetween,
711-
modifier = Modifier
712-
.padding(5.dp)
713-
.clickable {
714-
navController.navigate(EventViewDestination(event))
715-
}
703+
Column(
704+
modifier = Modifier.padding(horizontal = 5.dp, vertical = 5.dp)
705+
) {
706+
lookupViewModel.events.value.forEach { event ->
707+
Row(
708+
verticalAlignment = Alignment.CenterVertically
716709
) {
717-
Row {
718-
Text(
719-
event.name,
720-
maxLines = 1,
721-
overflow = TextOverflow.Ellipsis
722-
)
723-
}
724-
Row {
725-
Text(
726-
event.location.toString(),
727-
fontSize = 13.sp
728-
)
729-
Spacer(modifier = Modifier.weight(1.0f))
730-
Text(
731-
RoboScoutAPI.formatDate(event.startDate),
732-
fontSize = 13.sp
733-
)
710+
Column(
711+
verticalArrangement = Arrangement.SpaceBetween,
712+
modifier = Modifier
713+
.padding(5.dp)
714+
.clickable {
715+
navController.navigate(EventViewDestination(event))
716+
}
717+
) {
718+
Row {
719+
Text(
720+
event.name,
721+
maxLines = 1,
722+
overflow = TextOverflow.Ellipsis
723+
)
724+
}
725+
Row {
726+
Text(
727+
event.location.toString(),
728+
fontSize = 13.sp
729+
)
730+
Spacer(modifier = Modifier.weight(1.0f))
731+
Text(
732+
RoboScoutAPI.formatDate(event.startDate),
733+
fontSize = 13.sp
734+
)
735+
}
734736
}
735737
}
736-
}
737-
if (lookupViewModel.events.value.indexOf(event) != lookupViewModel.events.value.size - 1) {
738-
HorizontalDivider(
739-
thickness = 0.5.dp,
740-
color = MaterialTheme.colorScheme.secondary.copy(alpha = 0.1f),
741-
)
738+
if (lookupViewModel.events.value.indexOf(event) != lookupViewModel.events.value.size - 1) {
739+
HorizontalDivider(
740+
thickness = 0.5.dp,
741+
color = MaterialTheme.colorScheme.secondary.copy(alpha = 0.1f),
742+
)
743+
}
742744
}
743745
}
744746
}
745747
}
746-
}
747-
Row(
748-
horizontalArrangement = Arrangement.Center,
749-
verticalAlignment = Alignment.CenterVertically,
750-
modifier = Modifier
751-
.padding(horizontal = 20.dp)
752-
.fillMaxWidth()
753-
) {
754-
IconButton(
755-
enabled = lookupViewModel.page.value != 1,
756-
onClick = {
757-
lookupViewModel.page.value -= 1
758-
lookupViewModel.fetchEvents(
759-
name = lookupViewModel.eventName.value,
760-
page = lookupViewModel.page.value
748+
Row(
749+
horizontalArrangement = Arrangement.Center,
750+
verticalAlignment = Alignment.CenterVertically,
751+
modifier = Modifier
752+
.padding(horizontal = 20.dp)
753+
.fillMaxWidth()
754+
) {
755+
IconButton(
756+
enabled = lookupViewModel.page.value != 1,
757+
onClick = {
758+
lookupViewModel.page.value -= 1
759+
lookupViewModel.fetchEvents(
760+
name = lookupViewModel.eventName.value,
761+
page = lookupViewModel.page.value
762+
)
763+
}) {
764+
Icon(
765+
Icons.AutoMirrored.Filled.ArrowBackIos,
766+
contentDescription = "Previous Page",
767+
modifier = Modifier.size(30.dp),
768+
tint = if (lookupViewModel.page.value != 1) MaterialTheme.colorScheme.button else Color.Gray
761769
)
762-
}) {
763-
Icon(
764-
Icons.AutoMirrored.Filled.ArrowBackIos,
765-
contentDescription = "Previous Page",
766-
modifier = Modifier.size(30.dp),
767-
tint = if (lookupViewModel.page.value != 1) MaterialTheme.colorScheme.button else Color.Gray
770+
}
771+
Text(
772+
"${lookupViewModel.page.value}",
773+
modifier = Modifier.padding(horizontal = 20.dp),
774+
fontSize = 25.sp
768775
)
769-
}
770-
Text(
771-
"${lookupViewModel.page.value}",
772-
modifier = Modifier.padding(horizontal = 20.dp),
773-
fontSize = 25.sp
774-
)
775-
IconButton(
776-
enabled = lookupViewModel.events.value.size == 20,
777-
onClick = {
778-
lookupViewModel.page.value += 1
779-
lookupViewModel.fetchEvents(
780-
name = lookupViewModel.eventName.value,
781-
page = lookupViewModel.page.value
776+
IconButton(
777+
enabled = lookupViewModel.events.value.size == 20,
778+
onClick = {
779+
lookupViewModel.page.value += 1
780+
lookupViewModel.fetchEvents(
781+
name = lookupViewModel.eventName.value,
782+
page = lookupViewModel.page.value
783+
)
784+
}) {
785+
Icon(
786+
Icons.AutoMirrored.Filled.ArrowForwardIos,
787+
contentDescription = "Next Page",
788+
modifier = Modifier.size(30.dp),
789+
tint = if (lookupViewModel.events.value.size == 20) MaterialTheme.colorScheme.button else Color.Gray
782790
)
783-
}) {
784-
Icon(
785-
Icons.AutoMirrored.Filled.ArrowForwardIos,
786-
contentDescription = "Next Page",
787-
modifier = Modifier.size(30.dp),
788-
tint = if (lookupViewModel.events.value.size == 20) MaterialTheme.colorScheme.button else Color.Gray
789-
)
791+
}
790792
}
791793
}
792794
}

app/src/main/java/com/sunkensplashstudios/VRCRoboScout/RoboScoutAPI.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,25 @@ class RoboScoutAPI {
172172
}
173173

174174
fun roboteventsAccessKey(): String {
175-
return BuildConfig.ROBOTEVENTS_API_KEY
175+
if (BuildConfig.DEBUG) {
176+
return BuildConfig.ROBOTEVENTS_API_KEY
177+
}
178+
else {
179+
val key = (0..9).random()
180+
return when (key) {
181+
0 -> BuildConfig.key0
182+
1 -> BuildConfig.key1
183+
2 -> BuildConfig.key2
184+
3 -> BuildConfig.key3
185+
4 -> BuildConfig.key4
186+
5 -> BuildConfig.key5
187+
6 -> BuildConfig.key6
188+
7 -> BuildConfig.key7
189+
8 -> BuildConfig.key8
190+
9 -> BuildConfig.key9
191+
else -> ""
192+
}
193+
}
176194
}
177195

178196
fun roboteventsDate(date: String, localize: Boolean): Date? {

app/src/main/java/com/sunkensplashstudios/VRCRoboScout/SettingsView.kt

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ import androidx.compose.ui.unit.dp
4141
import androidx.compose.ui.unit.sp
4242
import androidx.navigation.NavController
4343
import com.ramcosta.composedestinations.annotation.Destination
44-
import com.sunkensplashstudios.VRCRoboScout.ui.theme.*
45-
44+
import com.sunkensplashstudios.VRCRoboScout.ui.theme.button
45+
import com.sunkensplashstudios.VRCRoboScout.ui.theme.onTopContainer
46+
import com.sunkensplashstudios.VRCRoboScout.ui.theme.topContainer
4647
import io.mhssn.colorpicker.ColorPickerDialog
4748
import io.mhssn.colorpicker.ColorPickerType
4849

@@ -92,7 +93,6 @@ fun SettingsView(navController: NavController) {
9293
val localContext = LocalContext.current
9394
val userSettings = UserSettings(localContext)
9495

95-
// Top Bar Color (MaterialTheme.colorScheme.topContainer)
9696
Row(
9797
modifier = Modifier.padding(vertical = 10.dp)
9898
) {
@@ -330,6 +330,41 @@ fun SettingsView(navController: NavController) {
330330
}
331331
}
332332
}
333+
Spacer(modifier = Modifier.height(10.dp))
334+
Text(
335+
"DEVELOPER",
336+
modifier = Modifier.padding(horizontal = 20.dp),
337+
fontSize = 13.sp,
338+
color = Color.Gray
339+
)
340+
Card(
341+
modifier = Modifier.padding(horizontal = 10.dp, vertical = 2.dp),
342+
colors = CardColors(
343+
containerColor = MaterialTheme.colorScheme.surfaceContainer.copy(alpha = 0.5f),
344+
disabledContainerColor = Color.Unspecified.copy(alpha = 0.5f),
345+
contentColor = MaterialTheme.colorScheme.onSurface,
346+
disabledContentColor = Color.Unspecified
347+
)
348+
) {
349+
Column(
350+
verticalArrangement = Arrangement.spacedBy(0.dp),
351+
modifier = Modifier.padding(horizontal = 10.dp)
352+
) {
353+
Row(
354+
modifier = Modifier.padding(vertical = 10.dp)
355+
) {
356+
Text("Version", modifier = Modifier.weight(1f))
357+
Text("${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})${if (BuildConfig.DEBUG) " (DEBUG)" else ""}")
358+
}
359+
}
360+
}
361+
Spacer(modifier = Modifier.height(10.dp))
362+
Text(
363+
"DEVELOPED BY TEAMS ACE 229V AND JELLY 2733J",
364+
modifier = Modifier.padding(horizontal = 20.dp),
365+
fontSize = 13.sp,
366+
color = Color.Gray
367+
)
333368
}
334369
}
335370
}

0 commit comments

Comments
 (0)