diff --git a/app/src/main/java/com/scouting/app/view/settings/MatchTypeDialog.kt b/app/src/main/java/com/scouting/app/view/settings/MatchTypeDialog.kt
new file mode 100644
index 0000000..746849a
--- /dev/null
+++ b/app/src/main/java/com/scouting/app/view/settings/MatchTypeDialog.kt
@@ -0,0 +1,69 @@
+package com.scouting.app.view.settings
+
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.input.TextFieldValue
+import androidx.compose.ui.unit.dp
+import com.scouting.app.R
+import com.scouting.app.components.BasicInputField
+import com.scouting.app.components.DialogScaffold
+import com.scouting.app.components.SmallButton
+import com.scouting.app.viewmodel.SettingsViewModel
+
+@Composable
+fun MatchTypeDialog(viewModel: SettingsViewModel) {
+ if (!viewModel.showingMatchTypeDialog) {
+ return
+ }
+ DialogScaffold(icon = painterResource(id = R.drawable.ic_edit_pen),
+ contentDescription = stringResource(R.string.ic_edit_pen_content_desc),
+ title = stringResource(id = R.string.settings_choose_match_type_dialog_title),
+ onDismissRequest = {
+ viewModel.apply {
+ showingMatchTypeDialog = false
+ restoreMatchType()
+ }
+ }
+ ) {
+ Column {
+ BasicInputField(
+ icon = painterResource(id = R.drawable.ic_edit_pen),
+ contentDescription = stringResource(id = R.string.ic_edit_pen_content_desc),
+ hint = stringResource(id = R.string.settings_choose_match_type_dialog_input_title),
+ textFieldValue = viewModel.matchType,
+ onValueChange = { value ->
+ viewModel.apply {
+ matchType = value
+ }
+ },
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(25.dp)
+ )
+ SmallButton(
+ text = stringResource(id = R.string.home_page_device_edit_dialog_save_button),
+ icon = painterResource(id = R.drawable.ic_checkmark_outline),
+ contentDescription = stringResource(id = R.string.ic_checkmark_outline_content_desc),
+ onClick = {
+ viewModel.apply {
+ showingMatchTypeDialog = false
+ applyMatchTypeChange(matchType.text)
+ // Reset text field value
+ matchType = TextFieldValue(matchType.text)
+ }
+ },
+ color = MaterialTheme.colorScheme.secondary,
+ modifier = Modifier
+ .align(Alignment.CenterHorizontally)
+ .padding(bottom = 25.dp)
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/scouting/app/view/settings/SettingsView.kt b/app/src/main/java/com/scouting/app/view/settings/SettingsView.kt
index f626bcb..96fe020 100644
--- a/app/src/main/java/com/scouting/app/view/settings/SettingsView.kt
+++ b/app/src/main/java/com/scouting/app/view/settings/SettingsView.kt
@@ -239,6 +239,21 @@ fun SettingsView(
},
modifier = Modifier.padding(top = 50.dp)
)
+ SettingsPreference(
+ title = stringResource(id = R.string.settings_choose_match_type_title),
+ endContent = {
+ MediumButton(
+ text = viewModel.matchType.text,
+ onClick = {
+ viewModel.apply {
+ showingMatchTypeDialog = true
+ }
+ },
+ color = NeutralGrayLight
+ )
+ },
+ modifier = Modifier.padding(top = 50.dp)
+ )
SettingsDivider(modifier = Modifier.padding(vertical = 50.dp))
SettingsPreference(
title = stringResource(id = R.string.settings_choose_default_template_pit_title),
@@ -283,6 +298,7 @@ fun SettingsView(
}
}
FileNameDialog(viewModel)
+ MatchTypeDialog(viewModel)
DevicePositionDialog(viewModel)
CompetitionModeDialog(viewModel)
}
diff --git a/app/src/main/java/com/scouting/app/viewmodel/ScoutingViewModel.kt b/app/src/main/java/com/scouting/app/viewmodel/ScoutingViewModel.kt
index 34e8678..f00f246 100644
--- a/app/src/main/java/com/scouting/app/viewmodel/ScoutingViewModel.kt
+++ b/app/src/main/java/com/scouting/app/viewmodel/ScoutingViewModel.kt
@@ -137,9 +137,8 @@ class ScoutingViewModel : ViewModel() {
* template.
*/
fun saveScoutingDataToFile(context: MainActivity) {
- var csvRowDraft = ""
+ val csvRowDraft = StringBuilder()
val templateType = if (scoutingType == PIT) "PIT" else "MATCH"
- val specialColumnName = if (scoutingType == PIT) "name" else "match"
val contentResolver = context.contentResolver
val itemList = if (scoutingType == PIT) {
pitListItems
@@ -149,22 +148,26 @@ class ScoutingViewModel : ViewModel() {
val tabletName = preferences.decodeString("DEVICE_ALLIANCE_POSITION", "RED") + "-" +
preferences.decodeInt("DEVICE_ROBOT_POSITION", 1).toString()
- val csvHeaderRow = "device,scout,$specialColumnName,team," + saveKeyOrderList!!.joinToString(",")
+ val matchType = preferences.decodeString("MATCH_TYPE", "NONE")
+ val csvHeaderRow = if (scoutingType == PIT) {
+ "device,scout,name,team," + saveKeyOrderList!!.joinToString(",")
+ } else {
+ "device,scout,match,match-type,team," + saveKeyOrderList!!.joinToString(",")
+ }
- // Add device name, scout name, match number and team number
- // OR if pit scouting add team name in place of match number
- csvRowDraft += "$tabletName,${scoutName.text},${
+ csvRowDraft.append(
if (scoutingType == PIT) {
- currentTeamNameMonitoring.text
+ "$tabletName,${scoutName.text},${currentTeamNameMonitoring.text},${currentTeamNumberMonitoring.text},"
} else {
- currentMatchMonitoring.text
+ "$tabletName,${scoutName.text},${currentMatchMonitoring.text},$matchType,${currentTeamNumberMonitoring.text},"
}
- },${currentTeamNumberMonitoring.text},"
+ )
+
// Append ordered, user-inputted match data
- csvRowDraft += saveKeyOrderList!!.joinToString(",") { key ->
+ csvRowDraft.append(saveKeyOrderList!!.joinToString(",") { key ->
itemList.findItemValueWithKey(key).toString().quoteForCSV()
- }
+ })
val userSelectedOutputFileName = preferences.decodeString(
"DEFAULT_OUTPUT_FILE_NAME_$templateType",
diff --git a/app/src/main/java/com/scouting/app/viewmodel/SettingsViewModel.kt b/app/src/main/java/com/scouting/app/viewmodel/SettingsViewModel.kt
index 931bbe3..49adf35 100644
--- a/app/src/main/java/com/scouting/app/viewmodel/SettingsViewModel.kt
+++ b/app/src/main/java/com/scouting/app/viewmodel/SettingsViewModel.kt
@@ -24,6 +24,8 @@ class SettingsViewModel : ViewModel() {
var defaultPitTemplateFileName by mutableStateOf("NONE")
var defaultPitOutputFileName by mutableStateOf(TextFieldValue("output-pit.csv"))
+ var matchType by mutableStateOf(TextFieldValue("NONE"))
+
var competitionScheduleFileName by mutableStateOf("NONE")
var pitScheduleFileName by mutableStateOf("NONE")
var deviceAlliancePosition by mutableStateOf(RED)
@@ -35,6 +37,7 @@ class SettingsViewModel : ViewModel() {
var scheduledScoutingModeType by mutableStateOf(MATCH)
var showingFileNameDialog by mutableStateOf(false)
+ var showingMatchTypeDialog by mutableStateOf(false)
var showingDevicePositionDialog by mutableStateOf(false)
var showingScheduledScoutingModeDialog by mutableStateOf(false)
@@ -63,6 +66,9 @@ class SettingsViewModel : ViewModel() {
defaultPitOutputFileName = TextFieldValue(
File(decodeString("DEFAULT_OUTPUT_FILE_NAME_PIT", "output-pit.csv")!!).name
)
+ matchType = TextFieldValue(
+ decodeString("MATCH_TYPE", matchType.text)!!
+ )
competitionMode = decodeBool("COMPETITION_MODE", false)
pitScoutingMode = decodeBool("PIT_SCOUTING_MODE", false)
}
@@ -181,6 +187,20 @@ class SettingsViewModel : ViewModel() {
)
}
+ /**
+ * Save the new match type to MMKV
+ */
+ fun applyMatchTypeChange(matchType: String) {
+ preferences.encode("MATCH_TYPE", matchType)
+ }
+
+ /**
+ * Resets the matchType to what's on MMKV
+ */
+ fun restoreMatchType() {
+ matchType = TextFieldValue(preferences.decodeString("MATCH_TYPE", "NONE")!!)
+ }
+
/**
* Make sure that when a user enters a new file name that it ends with
* ".csv", otherwise add it before saving
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4dd142e..72f0fd6 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -157,6 +157,9 @@
Pit output file name
File name
Default output file name
+ Match type
+ Match type
+ Match type
Device position
Competition schedule
Pit scouting schedule