Unverified Commit 42e3bdf9 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge pull request #987 from RocketChat/layout/remove-social-account-view

[LAYOUT] Remove social account view is there is no service available.
parents 420913be 12795148
...@@ -163,19 +163,19 @@ class LoginPresenter @Inject constructor(private val view: LoginView, ...@@ -163,19 +163,19 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
} }
if (totalSocialAccountsEnabled > 0) { if (totalSocialAccountsEnabled > 0) {
view.showOauthView() view.enableOauthView()
if (totalSocialAccountsEnabled > 3) { if (totalSocialAccountsEnabled > 3) {
view.setupFabListener() view.setupFabListener()
} }
} else { } else {
view.hideOauthView() view.disableOauthView()
} }
} else { } else {
view.hideOauthView() view.disableOauthView()
} }
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
Timber.e(exception) Timber.e(exception)
view.hideOauthView() view.disableOauthView()
} }
} }
} }
......
...@@ -72,18 +72,18 @@ interface LoginView : LoadingView, MessageView, InternetView { ...@@ -72,18 +72,18 @@ interface LoginView : LoadingView, MessageView, InternetView {
fun hideSignUpView() fun hideSignUpView()
/** /**
* Shows the oauth view if the login via social accounts is enabled by the server settings. * Enables and shows the oauth view if there is login via social accounts enabled by the server settings.
* *
* REMARK: We must show at maximum *three* social accounts views ([enableLoginByFacebook], [enableLoginByGithub], [enableLoginByGoogle], * REMARK: We must show at maximum *three* social accounts views ([enableLoginByFacebook], [enableLoginByGithub], [enableLoginByGoogle],
* [enableLoginByLinkedin], [enableLoginByMeteor], [enableLoginByTwitter] or [enableLoginByGitlab]) for the oauth view. * [enableLoginByLinkedin], [enableLoginByMeteor], [enableLoginByTwitter] or [enableLoginByGitlab]) for the oauth view.
* If the possibility of login via social accounts exceeds 3 different ways we should set up the FAB ([setupFabListener]) to show the remaining view(s). * If the possibility of login via social accounts exceeds 3 different ways we should set up the FAB ([setupFabListener]) to show the remaining view(s).
*/ */
fun showOauthView() fun enableOauthView()
/** /**
* Hides the oauth view. * Disables and hides the Oauth view if there is not login via social accounts enabled by the server settings.
*/ */
fun hideOauthView() fun disableOauthView()
/** /**
* Shows the login button. * Shows the login button.
......
...@@ -33,6 +33,7 @@ internal const val REQUEST_CODE_FOR_OAUTH = 2 ...@@ -33,6 +33,7 @@ internal const val REQUEST_CODE_FOR_OAUTH = 2
class LoginFragment : Fragment(), LoginView { class LoginFragment : Fragment(), LoginView {
@Inject lateinit var presenter: LoginPresenter @Inject lateinit var presenter: LoginPresenter
private var isOauthViewEnable = false
private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener { private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener {
areLoginOptionsNeeded() areLoginOptionsNeeded()
} }
...@@ -182,14 +183,15 @@ class LoginFragment : Fragment(), LoginView { ...@@ -182,14 +183,15 @@ class LoginFragment : Fragment(), LoginView {
text_new_to_rocket_chat.setVisible(false) text_new_to_rocket_chat.setVisible(false)
} }
override fun showOauthView() { override fun enableOauthView() {
isOauthViewEnable = true
showThreeSocialAccountsMethods() showThreeSocialAccountsMethods()
social_accounts_container.setVisible(true) social_accounts_container.setVisible(true)
} }
override fun hideOauthView() { override fun disableOauthView() {
isOauthViewEnable = false
social_accounts_container.setVisible(false) social_accounts_container.setVisible(false)
button_fab.setVisible(false)
} }
override fun showLoginButton() { override fun showLoginButton() {
...@@ -328,4 +330,17 @@ class LoginFragment : Fragment(), LoginView { ...@@ -328,4 +330,17 @@ class LoginFragment : Fragment(), LoginView {
.take(3) .take(3)
.forEach { it.setVisible(true) } .forEach { it.setVisible(true) }
} }
fun showOauthView() {
if (isOauthViewEnable) {
social_accounts_container.setVisible(true)
}
}
fun hideOauthView() {
if (isOauthViewEnable) {
social_accounts_container.setVisible(false)
button_fab.setVisible(false)
}
}
} }
\ 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