Commit 52dc2d5f authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Listen to root declareted view instead of EditText's.

parent 4483c295
...@@ -2,7 +2,6 @@ package chat.rocket.android.app ...@@ -2,7 +2,6 @@ package chat.rocket.android.app
import DrawableHelper import DrawableHelper
import android.app.Fragment import android.app.Fragment
import android.content.res.Configuration
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
...@@ -28,8 +27,8 @@ class AuthenticationLoginFragment : Fragment() { ...@@ -28,8 +27,8 @@ class AuthenticationLoginFragment : Fragment() {
// Just an example: if the server allow the login via social accounts (oauth authentication) then show the respective interface. // Just an example: if the server allow the login via social accounts (oauth authentication) then show the respective interface.
shouldShowOauthView(true) shouldShowOauthView(true)
// In this case we need to setup the text_username_or_email and text_password EditText to hide and show the oauth interface when the user touch the respective fields. // In this case we need to setup the layout to hide and show the oauth interface when the soft keyboard is shown (means that the user touched the text_username_or_email and text_password EditText).
setupEditTextListener() setupGlobalLayoutListener()
// Show the first three social account's ImageButton (REMARK: we must show at maximum *three* views) // Show the first three social account's ImageButton (REMARK: we must show at maximum *three* views)
showLoginUsingFacebookImageButton() showLoginUsingFacebookImageButton()
...@@ -55,23 +54,9 @@ class AuthenticationLoginFragment : Fragment() { ...@@ -55,23 +54,9 @@ class AuthenticationLoginFragment : Fragment() {
DrawableHelper.compoundDrawables(arrayOf(text_username_or_email, text_password), drawables) DrawableHelper.compoundDrawables(arrayOf(text_username_or_email, text_password), drawables)
} }
private fun setupEditTextListener() { private fun setupGlobalLayoutListener() {
text_username_or_email.viewTreeObserver.addOnGlobalLayoutListener({ scroll_view.viewTreeObserver.addOnGlobalLayoutListener({
if (KeyboardHelper.isSoftKeyboardShown(text_username_or_email.rootView)) { if (KeyboardHelper.isSoftKeyboardShown(scroll_view.rootView)) {
shouldShowOauthView(false)
shouldShowSignUpMsgView(false)
shouldShowLoginButton(true)
} else {
if (isEditTextNullOrBlank()) {
shouldShowOauthView(true)
shouldShowSignUpMsgView(true)
shouldShowLoginButton(false)
}
}
})
text_password.viewTreeObserver.addOnGlobalLayoutListener({
if (KeyboardHelper.isSoftKeyboardShown(text_password.rootView)) {
shouldShowOauthView(false) shouldShowOauthView(false)
shouldShowSignUpMsgView(false) shouldShowSignUpMsgView(false)
shouldShowLoginButton(true) shouldShowLoginButton(true)
......
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