Commit 90400688 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Add hard keyboard listener and EditTexts listeners to hide/show the social...

Add hard keyboard listener and EditTexts listeners to hide/show the social accounts when the user tap the EditText views/keyboard is shown
parent 31b58807
...@@ -2,6 +2,7 @@ package chat.rocket.android.app ...@@ -2,6 +2,7 @@ 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
...@@ -20,9 +21,15 @@ class AuthenticationLoginFragment : Fragment() { ...@@ -20,9 +21,15 @@ class AuthenticationLoginFragment : Fragment() {
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) tintEditTextDrawableStart()
tintEditTextDrawableStart() setupEditTextListener()
} }
override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig)
if (KeyboardHelper.isHardKeyboardShown(newConfig)) hideSocialAccountsAndSignUpMsgViews()
else showSocialAccountsAndSignUpMsgViews()
} }
private fun tintEditTextDrawableStart() { private fun tintEditTextDrawableStart() {
...@@ -34,6 +41,32 @@ class AuthenticationLoginFragment : Fragment() { ...@@ -34,6 +41,32 @@ class AuthenticationLoginFragment : Fragment() {
val drawables = arrayOf(personDrawable, lockDrawable) val drawables = arrayOf(personDrawable, lockDrawable)
DrawableHelper.wrapDrawables(drawables) DrawableHelper.wrapDrawables(drawables)
DrawableHelper.tintDrawables(drawables, context, R.color.colorDrawableTintGrey) DrawableHelper.tintDrawables(drawables, context, R.color.colorDrawableTintGrey)
DrawableHelper.compoundDrawables(arrayOf(text_username, text_password), drawables) DrawableHelper.compoundDrawables(arrayOf(text_username_or_email, text_password), drawables)
}
private fun setupEditTextListener() {
text_username_or_email.viewTreeObserver.addOnGlobalLayoutListener({
if (KeyboardHelper.isSoftKeyboardShown(text_username_or_email.rootView)) hideSocialAccountsAndSignUpMsgViews()
else showSocialAccountsAndSignUpMsgViews()
})
text_password.viewTreeObserver.addOnGlobalLayoutListener({
if (KeyboardHelper.isSoftKeyboardShown(text_username_or_email.rootView)) hideSocialAccountsAndSignUpMsgViews()
else showSocialAccountsAndSignUpMsgViews()
})
}
private fun hideSocialAccountsAndSignUpMsgViews() {
social_accounts_container.visibility = View.GONE
text_new_in_rocket_chat.visibility = View.GONE
button_fab.visibility = View.GONE
button_log_in.visibility = View.VISIBLE
}
private fun showSocialAccountsAndSignUpMsgViews() {
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
} }
} }
\ 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