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

Removes the social accounts if there is no OAuth service available.

parent 8685b5dd
......@@ -163,19 +163,19 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
}
if (totalSocialAccountsEnabled > 0) {
view.showOauthView()
view.enableOauthView()
if (totalSocialAccountsEnabled > 3) {
view.setupFabListener()
}
} else {
view.hideOauthView()
view.disableOauthView()
}
} else {
view.hideOauthView()
view.disableOauthView()
}
} catch (exception: RocketChatException) {
Timber.e(exception)
view.hideOauthView()
view.disableOauthView()
}
}
}
......
......@@ -72,18 +72,18 @@ interface LoginView : LoadingView, MessageView, InternetView {
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],
* [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).
*/
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.
......
......@@ -33,6 +33,7 @@ internal const val REQUEST_CODE_FOR_OAUTH = 2
class LoginFragment : Fragment(), LoginView {
@Inject lateinit var presenter: LoginPresenter
private var isOauthViewEnable = false
private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener {
areLoginOptionsNeeded()
}
......@@ -182,14 +183,15 @@ class LoginFragment : Fragment(), LoginView {
text_new_to_rocket_chat.setVisible(false)
}
override fun showOauthView() {
override fun enableOauthView() {
isOauthViewEnable = true
showThreeSocialAccountsMethods()
social_accounts_container.setVisible(true)
}
override fun hideOauthView() {
override fun disableOauthView() {
isOauthViewEnable = false
social_accounts_container.setVisible(false)
button_fab.setVisible(false)
}
override fun showLoginButton() {
......@@ -328,4 +330,17 @@ class LoginFragment : Fragment(), LoginView {
.take(3)
.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