Commit 417ea60f authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Check if all EditText's text are null or blank before showing the social...

Check if all EditText's text are null or blank before showing the social accounts and sign up msg view.
parent 90400688
...@@ -28,8 +28,13 @@ class AuthenticationLoginFragment : Fragment() { ...@@ -28,8 +28,13 @@ class AuthenticationLoginFragment : Fragment() {
override fun onConfigurationChanged(newConfig: Configuration?) { override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig) super.onConfigurationChanged(newConfig)
if (KeyboardHelper.isHardKeyboardShown(newConfig)) hideSocialAccountsAndSignUpMsgViews() if (KeyboardHelper.isHardKeyboardShown(newConfig)) {
else showSocialAccountsAndSignUpMsgViews() shouldShowSocialAccountsAndSignUpMsgViews(false)
} else {
if (isEditTextNullOrBlank()) {
shouldShowSocialAccountsAndSignUpMsgViews(true)
}
}
} }
private fun tintEditTextDrawableStart() { private fun tintEditTextDrawableStart() {
...@@ -46,27 +51,42 @@ class AuthenticationLoginFragment : Fragment() { ...@@ -46,27 +51,42 @@ class AuthenticationLoginFragment : Fragment() {
private fun setupEditTextListener() { private fun setupEditTextListener() {
text_username_or_email.viewTreeObserver.addOnGlobalLayoutListener({ text_username_or_email.viewTreeObserver.addOnGlobalLayoutListener({
if (KeyboardHelper.isSoftKeyboardShown(text_username_or_email.rootView)) hideSocialAccountsAndSignUpMsgViews() if (KeyboardHelper.isSoftKeyboardShown(text_username_or_email.rootView)) {
else showSocialAccountsAndSignUpMsgViews() shouldShowSocialAccountsAndSignUpMsgViews(false)
} else {
if (isEditTextNullOrBlank()) {
shouldShowSocialAccountsAndSignUpMsgViews(true)
}
}
}) })
text_password.viewTreeObserver.addOnGlobalLayoutListener({ text_password.viewTreeObserver.addOnGlobalLayoutListener({
if (KeyboardHelper.isSoftKeyboardShown(text_username_or_email.rootView)) hideSocialAccountsAndSignUpMsgViews() if (KeyboardHelper.isSoftKeyboardShown(text_username_or_email.rootView)) {
else showSocialAccountsAndSignUpMsgViews() shouldShowSocialAccountsAndSignUpMsgViews(false)
} else {
if (isEditTextNullOrBlank()) {
shouldShowSocialAccountsAndSignUpMsgViews(true)
}
}
}) })
} }
private fun hideSocialAccountsAndSignUpMsgViews() { private fun shouldShowSocialAccountsAndSignUpMsgViews(show: Boolean) {
if (show) {
social_accounts_container.visibility = View.VISIBLE
text_new_in_rocket_chat.visibility = View.VISIBLE
button_fab.visibility = View.VISIBLE
button_log_in.visibility = View.GONE
} else {
social_accounts_container.visibility = View.GONE social_accounts_container.visibility = View.GONE
text_new_in_rocket_chat.visibility = View.GONE text_new_in_rocket_chat.visibility = View.GONE
button_fab.visibility = View.GONE button_fab.visibility = View.GONE
button_log_in.visibility = View.VISIBLE button_log_in.visibility = View.VISIBLE
} }
}
private fun showSocialAccountsAndSignUpMsgViews() { // Returns true if *all* EditText are null or blank.
social_accounts_container.visibility = View.VISIBLE private fun isEditTextNullOrBlank(): Boolean {
text_new_in_rocket_chat.visibility = View.VISIBLE return text_username_or_email.text.isNullOrBlank() && text_password.text.isNullOrBlank()
button_fab.visibility = View.VISIBLE
button_log_in.visibility = View.GONE
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment