Skip to content

Commit

Permalink
Don't allow masked appearance for string number widget
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Jun 20, 2024
1 parent 1c555e0 commit 686ab8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.javarosa.core.model.Constants
import org.javarosa.form.api.FormEntryPrompt
import org.odk.collect.android.dynamicpreload.ExternalDataUtil
import org.odk.collect.androidshared.utils.ScreenUtils
import java.lang.Exception

object Appearances {
// Date appearances
Expand Down Expand Up @@ -196,6 +195,8 @@ object Appearances {
@JvmStatic
fun isMasked(prompt: FormEntryPrompt): Boolean {
val appearance = getSanitizedAppearanceHint(prompt)
return appearance.contains(MASKED) && prompt.dataType == Constants.DATATYPE_TEXT
return appearance.contains(MASKED) &&
!appearance.contains(NUMBERS) &&
prompt.dataType == Constants.DATATYPE_TEXT
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,11 @@ class AppearancesTest {
whenever(formEntryPrompt.dataType).thenReturn(Constants.DATATYPE_DECIMAL)
assertFalse(Appearances.isMasked(formEntryPrompt))
}

@Test
fun `isMasked returns false when 'masked' appearance is found for text questions with 'numbers' appearance`() {
whenever(formEntryPrompt.dataType).thenReturn(Constants.DATATYPE_TEXT)
whenever(formEntryPrompt.appearanceHint).thenReturn("masked numbers")
assertFalse(Appearances.isMasked(formEntryPrompt))
}
}

0 comments on commit 686ab8f

Please sign in to comment.