Limit length of numerical habit units to 7

pull/2158/head
Quentin Hibon 4 months ago
parent 897a236501
commit 8f2402466d

@ -314,6 +314,10 @@ class EditHabitActivity : AppCompatActivity() {
binding.targetInput.error = getString(R.string.validation_cannot_be_blank) binding.targetInput.error = getString(R.string.validation_cannot_be_blank)
isValid = false isValid = false
} }
if (binding.unitInput.text.length > resources.getInteger(R.integer.unit_name_max_length)) {
binding.unitInput.error = getString(R.string.validation_unit_too_long)
isValid = false
}
} }
return isValid return isValid
} }

@ -167,6 +167,7 @@
android:id="@+id/unitInput" android:id="@+id/unitInput"
android:maxLines="1" android:maxLines="1"
android:ems="10" android:ems="10"
android:maxLength="@integer/unit_name_max_length"
android:hint="@string/measurable_units_example"/> android:hint="@string/measurable_units_example"/>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

@ -29,6 +29,9 @@
<string name="bugReportSubject">Bug Report - Loop Habit Tracker</string> <string name="bugReportSubject">Bug Report - Loop Habit Tracker</string>
<string name="syncBaseURL" formatted="false">https://sync.loophabits.org</string> <string name="syncBaseURL" formatted="false">https://sync.loophabits.org</string>
<!-- Maximum length for unit names in numerical habits -->
<integer name="unit_name_max_length">7</integer>
<string-array name="snooze_picker_names"> <string-array name="snooze_picker_names">
<item>@string/interval_15_minutes</item> <item>@string/interval_15_minutes</item>
<item>@string/interval_30_minutes</item> <item>@string/interval_30_minutes</item>

@ -235,4 +235,5 @@
<string name="pref_midnight_delay_description">Wait until 3:00 AM to show a new day. Useful if you typically go to sleep after midnight. Requires app restart.</string> <string name="pref_midnight_delay_description">Wait until 3:00 AM to show a new day. Useful if you typically go to sleep after midnight. Requires app restart.</string>
<string name="pref_animations_title">Disable animations</string> <string name="pref_animations_title">Disable animations</string>
<string name="pref_animations_description">Disable confetti animation after adding a checkmark.</string> <string name="pref_animations_description">Disable confetti animation after adding a checkmark.</string>
<string name="validation_unit_too_long">Unit name is too long.</string>
</resources> </resources>

Loading…
Cancel
Save