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

Droneshare login field validation and keyboard release #1422

Merged
merged 4 commits into from
Mar 4, 2015

Conversation

peterhinson
Copy link
Contributor

Adds basic validation to username, password, and email when registering/logging into Droneshare.

The validation is pretty simple: usernames must be >1 characters. Emails must be .. well, emails. Login/signup is prevented unless the fields validate, and an error icon with an informative message is appended to the invalid field.

Passwords are little more tricky- Droneshare requires at least 7 characters and 1 digit. This hasn't been enforced via account creation using their API however, so DroidPlanner users have been able to create arbitrary passwords. I've added the character and digit restrictions to signup, but allow logging in users to use passwords of any length.

While it's nice to have instant feedback on what you're doing wrong within the app, this creates independent validation rules on the client and server. In the long run, it seems like the server should be responsible for validation.

I also added a method to hide the keyboard after login/signup. If the user hadn't hidden it at time of login, it would stay on screen after loading the Droneshare dashboard.

This is my first contribution to DroidPlanner/Tower (hoorah), figured something harmless would be a good start. Please let me know if I'm stepping on any of your contrib guidelines! :)

…count creation - it'd occasionally persist after login screen was dismissed.
… message are added to fields missing values, login can only proceed once all fields have been entered.
…characters, with 1 digit. Login allows abritary passwords, since existing accounts might not meet this requirement.
@peterhinson peterhinson changed the title Droneshare login field validation and softinput hiding Droneshare login field validation and keyboard release Mar 4, 2015
}
}

public abstract class TextValidator implements TextWatcher {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TextValidator should be declared as a static inner class since it doesn't use any references from the parent class.

@m4gr3d
Copy link
Member

m4gr3d commented Mar 4, 2015

@peterhinson your PR looks great!
Should be good for merging once the issue mentioned above is fixed.

@peterhinson
Copy link
Contributor Author

@ne0fhyk you're quite right! Changed to static in 95d2594.

Really, TextValidator has nothing to do with the login fragment and could be reused elsewhere. I'm not familiar enough with the codebase to say whether it should be extracted to a utility class however.

@m4gr3d
Copy link
Member

m4gr3d commented Mar 4, 2015

@peterhinson These are usually placed in the org.droidplanner.android.utils package, although it's not a strict convention.
Thanks for the quick fix. I'll go ahead and merge the PR.

m4gr3d added a commit that referenced this pull request Mar 4, 2015
Droneshare login field validation and keyboard release
@m4gr3d m4gr3d merged commit 0b300f0 into DroidPlanner:master Mar 4, 2015
@peterhinson
Copy link
Contributor Author

Good to know. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants