richsmith / sexytopo

The SexyTopo cave surveying app for Android
GNU General Public License v3.0
29 stars 13 forks source link

Disable Rename Button While Station Name is Invalid #184

Closed olly closed 1 year ago

olly commented 1 year ago

Building upon #183, this PR aims to prevent inconsistency when renaming a station by preventing the "Rename" button from being pressed when the form is invalid.

Previously the rename station dialog had the potential to cause an issue on different view sizes, as it seems it only coincidentally prevented an invalid rename by covering the "Rename" button with the TextView error message. This PR disables the button when the station name is invalid.

The Form Concept

This PR introduces a new, abstract Form class, which currently is just responsible for grouping fields (although in this case the form only has a single field) and providing a structure for validating a form and firing callbacks.

A longer term vision might be to encapsulate each manual entry as a Form subclass, which can then be presented in a consistent manor (perhaps a full-screen dialog for phone-sized devices?), and also potentially encapsulate field labels & dynamically building the form views based on it's fields.

The Result

https://user-images.githubusercontent.com/630/189769748-d790610f-c5c9-4435-b097-b17735df8e53.mp4

Note: