Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict symptom name input to 1 line, trim whitespaces #193

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/src/main/java/com/mensinator/app/PeriodDatabaseHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ class PeriodDatabaseHelper(context: Context) :

override fun createNewSymptom(symptomName: String) {
val db = writableDatabase
val trimmedSymptomName = symptomName.trim()
val values = ContentValues().apply {
put(COLUMN_SYMPTOM_NAME, symptomName) // Set the symptom name
put(COLUMN_SYMPTOM_NAME, trimmedSymptomName) // Set the symptom name
put(COLUMN_SYMPTOM_ACTIVE, 1) // Set the active column to 1 (true)
}
// Insert the new symptom into the symptoms table
Expand Down Expand Up @@ -796,8 +797,9 @@ class PeriodDatabaseHelper(context: Context) :

override fun renameSymptom(symptomId: Int, newName: String) {
val db = writableDatabase
val trimmedSymptomName = newName.trim()
val contentValues = ContentValues().apply {
put("symptom_name", newName)
put("symptom_name", trimmedSymptomName)
}
db.update("symptoms", contentValues, "id = ?", arrayOf(symptomId.toString()))

Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/com/mensinator/app/SymptomDialogs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ fun CreateNewSymptomDialog(
//value = symptomKey?.let { stringResource(id = it) } ?: "Not Found",
value = symptomName,
onValueChange = { symptomName = it },
label = { Text(stringResource(R.string.symptom_name_label)) }
label = { Text(stringResource(R.string.symptom_name_label)) },
singleLine = true,
)
},
)
Expand Down Expand Up @@ -178,7 +179,8 @@ fun RenameSymptomDialog(
TextField(
value = newName,
onValueChange = { newName = it },
label = { Text(stringResource(R.string.symptom_name_label)) }
label = { Text(stringResource(R.string.symptom_name_label)) },
singleLine = true,
)
}
},
Expand Down