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

Remove logs and update/add funcitons.

parent 6c49a9fb
......@@ -26,24 +26,21 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
}
else -> {
launchUI(strategy) {
view.showLoading()
if (NetworkHelper.hasInternetAccess()) {
view.showLoading()
try {
val token = client.login(usernameOrEmail, password)
Timber.d("Created token: $token")
// TODO Salve token?
navigator.toChatList()
} catch (rocketChatException: RocketChatException) {
when (rocketChatException) {
is RocketChatTwoFactorException -> {
if (rocketChatException is RocketChatTwoFactorException) {
navigator.toTwoFA(navigator.currentServer!!, usernameOrEmail, password)
}
else -> {
} else {
val errorMessage = rocketChatException.message
if (errorMessage != null) {
view.showMessage(errorMessage)
}
}
}
} finally {
view.hideLoading()
}
......
......@@ -27,13 +27,13 @@ class LoginFragment : Fragment(), LoginView {
private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener {
if (KeyboardHelper.isSoftKeyboardShown(scroll_view.rootView)) {
showOauthView(false)
showSignUpView(false)
showOauthView(false)
showLoginButton(true)
} else {
if (isEditTextEmpty()) {
showOauthView(true)
showSignUpView(true)
showOauthView(true)
showLoginButton(false)
}
}
......@@ -219,6 +219,10 @@ class LoginFragment : Fragment(), LoginView {
button_log_in.isEnabled = value
text_username_or_email.isEnabled = value
text_password.isEnabled = value
if (isEditTextEmpty()) {
showSignUpView(value)
showOauthView(value)
}
}
// Returns true if *all* EditTexts are empty.
......
......@@ -54,17 +54,16 @@ class ServerFragment : Fragment(), ServerView {
}
override fun showLoading() {
text_server_url.isEnabled = false
button_connect.isEnabled = false
view_loading.setVisibility(true)
enableUserInput(false)
view_loading.show()
}
override fun hideLoading() {
view_loading.setVisibility(false)
button_connect.isEnabled = true
text_server_url.isEnabled = true
view_loading.hide()
enableUserInput(true)
}
override fun showMessage(message: String) {
Toast.makeText(activity, message, Toast.LENGTH_SHORT).show()
}
......@@ -72,4 +71,9 @@ class ServerFragment : Fragment(), ServerView {
override fun showNoInternetConnection() {
Toast.makeText(activity, getString(R.string.msg_no_internet_connection), Toast.LENGTH_SHORT).show()
}
private fun enableUserInput(value: Boolean) {
button_connect.isEnabled = value
text_server_url.isEnabled = value
}
}
\ No newline at end of file
......@@ -36,14 +36,12 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
view.showLoading()
try {
val user = client.signup(email, name, username, password)
Timber.d("Created user: $user")
// TODO Salve user?
val token = client.login(username, password)
Timber.d("Logged in. Token: $token")
// TODO Salve token?
navigator.toChatList()
} catch (ex: RocketChatException) {
val errorMessage = ex.message
} catch (rocketChatException: RocketChatException) {
val errorMessage = rocketChatException.message
if (errorMessage != null) {
view.showMessage(errorMessage)
}
......
......@@ -77,7 +77,6 @@ class TwoFAFragment : Fragment(), TwoFAView {
}
override fun showLoading() {
view_loading.setVisibility(true)
enableUserInput(false)
view_loading.show()
}
......
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