Skip to content

Commit d9826f4

Browse files
committed
fix: handle quota validation on big unit conversions
1 parent 3dcc9e9 commit d9826f4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/createspace/CreateSpaceDialogFragment.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,16 @@ class CreateSpaceDialogFragment : DialogFragment() {
130130

131131
return when {
132132
spaceQuota.isEmpty() -> getString(R.string.create_space_dialog_quota_empty_error)
133-
spaceQuota.toDouble() == MIN_SPACE_QUOTA_GB -> getString(R.string.create_space_dialog_quota_zero_error)
134-
spaceQuota.toDouble() > MAX_SPACE_QUOTA_GB -> getString(R.string.create_space_dialog_quota_too_large_error)
133+
spaceQuota.toDouble() == MIN_SPACE_QUOTA_LIMIT -> getString(R.string.create_space_dialog_quota_zero_error)
134+
spaceQuota.toDouble() > MAX_SPACE_QUOTA_LIMIT -> getString(R.string.create_space_dialog_quota_too_large_error)
135135
else -> null
136136
}
137137
}
138138

139139
private fun updateUI() {
140140
val nameError = validateName(binding.createSpaceDialogNameValue.text.toString())
141-
val quotaError = validateQuota(binding.createSpaceDialogQuotaValue.text.toString())
141+
val quotaValue = convertToBytes(binding.createSpaceDialogQuotaValue.text.toString(), binding.createSpaceDialogQuotaUnitLabel.text.toString())
142+
val quotaError = validateQuota(quotaValue.toString())
142143
val noErrors = nameError == null && quotaError == null
143144

144145
val colorButton = if (noErrors) {
@@ -179,8 +180,8 @@ class CreateSpaceDialogFragment : DialogFragment() {
179180
private const val ARG_CAN_EDIT_SPACE_QUOTA = "CAN_EDIT_SPACE_QUOTA"
180181
private const val ARG_CURRENT_SPACE = "CURRENT_SPACE"
181182
private const val FORBIDDEN_CHARACTERS = """[/\\.:?*"'><|]"""
182-
private const val MIN_SPACE_QUOTA_GB = 0.0
183-
private const val MAX_SPACE_QUOTA_GB = 1_000_000.0
183+
private const val MIN_SPACE_QUOTA_LIMIT = 0.0
184+
private const val MAX_SPACE_QUOTA_LIMIT = 1_000_000_000_000_000.0
184185
private const val B_MULTIPLIER = 1L
185186
private const val KB_MULTIPLIER = 1_000L
186187
private const val MB_MULTIPLIER = 1_000_000L

0 commit comments

Comments
 (0)