Commit 6d1cb1cf authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Merge branch 'develop' into new/redesign-authentication-views

parents 167491e2 2b9e7144
...@@ -17,12 +17,14 @@ import chat.rocket.android.server.domain.wideTile ...@@ -17,12 +17,14 @@ import chat.rocket.android.server.domain.wideTile
import chat.rocket.android.server.infraestructure.RocketChatClientFactory import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.util.extension.launchUI import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.avatarUrl import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.extensions.isEmail
import chat.rocket.android.util.extensions.serverLogoUrl import chat.rocket.android.util.extensions.serverLogoUrl
import chat.rocket.android.util.retryIO import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatAuthException import chat.rocket.common.RocketChatAuthException
import chat.rocket.common.RocketChatException import chat.rocket.common.RocketChatException
import chat.rocket.common.util.ifNull import chat.rocket.common.util.ifNull
import chat.rocket.core.internal.rest.login import chat.rocket.core.internal.rest.login
import chat.rocket.core.internal.rest.loginWithEmail
import chat.rocket.core.internal.rest.me import chat.rocket.core.internal.rest.me
import chat.rocket.core.model.Myself import chat.rocket.core.model.Myself
import javax.inject.Inject import javax.inject.Inject
...@@ -54,7 +56,15 @@ class TwoFAPresenter @Inject constructor( ...@@ -54,7 +56,15 @@ class TwoFAPresenter @Inject constructor(
try { try {
// The token is saved via the client TokenProvider // The token is saved via the client TokenProvider
val token = retryIO("login") { val token = retryIO("login") {
client.login(usernameOrEmail, password, twoFactorAuthenticationCode) if (usernameOrEmail.isEmail()) {
client.loginWithEmail(
usernameOrEmail,
password,
twoFactorAuthenticationCode
)
} else {
client.login(usernameOrEmail, password, twoFactorAuthenticationCode)
}
} }
val me = retryIO("me") { client.me() } val me = retryIO("me") { client.me() }
saveAccount(me) saveAccount(me)
...@@ -62,8 +72,7 @@ class TwoFAPresenter @Inject constructor( ...@@ -62,8 +72,7 @@ class TwoFAPresenter @Inject constructor(
tokenRepository.save(currentServer, token) tokenRepository.save(currentServer, token)
localRepository.save(LocalRepository.CURRENT_USERNAME_KEY, me.username) localRepository.save(LocalRepository.CURRENT_USERNAME_KEY, me.username)
analyticsManager.logLogin( analyticsManager.logLogin(
AuthenticationEvent.AuthenticationWithUserAndPassword, AuthenticationEvent.AuthenticationWithUserAndPassword, true
true
) )
navigator.toChatList() navigator.toChatList()
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
...@@ -71,8 +80,7 @@ class TwoFAPresenter @Inject constructor( ...@@ -71,8 +80,7 @@ class TwoFAPresenter @Inject constructor(
view.alertInvalidTwoFactorAuthenticationCode() view.alertInvalidTwoFactorAuthenticationCode()
} else { } else {
analyticsManager.logLogin( analyticsManager.logLogin(
AuthenticationEvent.AuthenticationWithUserAndPassword, AuthenticationEvent.AuthenticationWithUserAndPassword, false
false
) )
exception.message?.let { exception.message?.let {
view.showMessage(it) view.showMessage(it)
......
...@@ -321,10 +321,10 @@ class UiModelMapper @Inject constructor( ...@@ -321,10 +321,10 @@ class UiModelMapper @Inject constructor(
val dayMarkerText = DateTimeHelper.getFormattedDateForMessages(localDateTime, context) val dayMarkerText = DateTimeHelper.getFormattedDateForMessages(localDateTime, context)
ActionsAttachmentUiModel(attachmentUrl = url, title = title, ActionsAttachmentUiModel(attachmentUrl = url, title = title,
actions = actions, buttonAlignment = buttonAlignment, message = message, rawData = attachment, actions = actions, buttonAlignment = buttonAlignment, message = message, rawData = attachment,
messageId = message.id, reactions = getReactions(message), messageId = message.id, reactions = getReactions(message),
preview = message.copy(message = content.message), unread = message.unread, preview = message.copy(message = content.message), unread = message.unread,
showDayMarker = false, currentDayMarkerText = dayMarkerText) showDayMarker = false, currentDayMarkerText = dayMarkerText)
} }
} }
...@@ -580,7 +580,7 @@ class UiModelMapper @Inject constructor( ...@@ -580,7 +580,7 @@ class UiModelMapper @Inject constructor(
private fun getSystemMessage(message: Message): CharSequence { private fun getSystemMessage(message: Message): CharSequence {
val content = when (message.type) { val content = when (message.type) {
//TODO: Add implementation for Welcome type. //TODO: Add implementation for Welcome type.
is MessageType.MessageRemoved -> context.getString(R.string.message_removed) is MessageType.MessageRemoved -> context.getString(R.string.message_removed)
is MessageType.UserJoined -> context.getString(R.string.message_user_joined_channel) is MessageType.UserJoined -> context.getString(R.string.message_user_joined_channel)
is MessageType.UserLeft -> context.getString(R.string.message_user_left) is MessageType.UserLeft -> context.getString(R.string.message_user_left)
...@@ -592,6 +592,7 @@ class UiModelMapper @Inject constructor( ...@@ -592,6 +592,7 @@ class UiModelMapper @Inject constructor(
is MessageType.UserUnMuted -> context.getString(R.string.message_unmuted, message.message, message.sender?.username) is MessageType.UserUnMuted -> context.getString(R.string.message_unmuted, message.message, message.sender?.username)
is MessageType.SubscriptionRoleAdded -> context.getString(R.string.message_role_add, message.message, message.role, message.sender?.username) is MessageType.SubscriptionRoleAdded -> context.getString(R.string.message_role_add, message.message, message.role, message.sender?.username)
is MessageType.SubscriptionRoleRemoved -> context.getString(R.string.message_role_removed, message.message, message.role, message.sender?.username) is MessageType.SubscriptionRoleRemoved -> context.getString(R.string.message_role_removed, message.message, message.role, message.sender?.username)
is MessageType.RoomChangedPrivacy -> context.getString(R.string.message_room_changed_privacy, message.message, message.sender?.username)
else -> { else -> {
throw InvalidParameterException("Invalid message type: ${message.type}") throw InvalidParameterException("Invalid message type: ${message.type}")
} }
......
...@@ -301,4 +301,5 @@ ...@@ -301,4 +301,5 @@
<string name="notif_success_sending">Nachricht gesendet nach %1$s!</string> <string name="notif_success_sending">Nachricht gesendet nach %1$s!</string>
<string name="read_by">Gelesen von</string> <string name="read_by">Gelesen von</string>
<string name="message_information_title">Nachricht Information</string> <string name="message_information_title">Nachricht Information</string>
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string> <!--TODO - Add proper translation-->
</resources> </resources>
\ No newline at end of file
...@@ -304,5 +304,7 @@ ...@@ -304,5 +304,7 @@
<string name="msg_file_description">Descripción del archivo</string> <string name="msg_file_description">Descripción del archivo</string>
<string name="msg_send">Enviar</string> <string name="msg_send">Enviar</string>
<string name="msg_sent_attachment">Envió un archivo</string> <string name="msg_sent_attachment">Envió un archivo</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
</resources> </resources>
...@@ -306,4 +306,6 @@ ...@@ -306,4 +306,6 @@
<string name="message_information_title">Informations sur le message</string> <string name="message_information_title">Informations sur le message</string>
<string name="msg_log_out">Déconnecter…</string> <string name="msg_log_out">Déconnecter…</string>
<string name="msg_sent_attachment">Envoyé un fichier</string> <string name="msg_sent_attachment">Envoyé un fichier</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
</resources> </resources>
\ No newline at end of file
...@@ -306,4 +306,6 @@ ...@@ -306,4 +306,6 @@
<string name="read_by">द्वारा पढ़ें</string> <string name="read_by">द्वारा पढ़ें</string>
<string name="message_information_title">संदेश की जानकारी</string> <string name="message_information_title">संदेश की जानकारी</string>
<string name="msg_log_out">लॉग आउट कर रहा हूं…</string> <string name="msg_log_out">लॉग आउट कर रहा हूं…</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
</resources> </resources>
...@@ -307,4 +307,6 @@ ...@@ -307,4 +307,6 @@
<string name="notif_success_sending">メッセージは %1$s に送信されました!</string> <string name="notif_success_sending">メッセージは %1$s に送信されました!</string>
<string name="read_by">読者</string> <string name="read_by">読者</string>
<string name="message_information_title">メッセージ情報</string> <string name="message_information_title">メッセージ情報</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
</resources> </resources>
\ No newline at end of file
...@@ -304,4 +304,5 @@ ...@@ -304,4 +304,5 @@
<string name="message_information_title">Informações da mensagem</string> <string name="message_information_title">Informações da mensagem</string>
<string name="msg_log_out">Deslogando…</string> <string name="msg_log_out">Deslogando…</string>
<string name="msg_sent_attachment">Enviou um arquivo</string> <string name="msg_sent_attachment">Enviou um arquivo</string>
<string name="message_room_changed_privacy">O tipo da sala mudou para: %1$s por %2$s</string>
</resources> </resources>
...@@ -300,4 +300,6 @@ ...@@ -300,4 +300,6 @@
<string name="read_by">Прочитано</string> <string name="read_by">Прочитано</string>
<string name="message_information_title">Информация о прочтении</string> <string name="message_information_title">Информация о прочтении</string>
<string name="msg_log_out">Выходим…</string> <string name="msg_log_out">Выходим…</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
</resources> </resources>
...@@ -288,5 +288,7 @@ ...@@ -288,5 +288,7 @@
<string name="notif_success_sending">Mesaj %1$s\'a gönderildi!</string> <string name="notif_success_sending">Mesaj %1$s\'a gönderildi!</string>
<string name="read_by">ile oku</string> <string name="read_by">ile oku</string>
<string name="message_information_title">Mesaj bilgisi</string> <string name="message_information_title">Mesaj bilgisi</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
</resources> </resources>
...@@ -302,4 +302,6 @@ ...@@ -302,4 +302,6 @@
<string name="message_information_title">Інформація про прочитання</string> <string name="message_information_title">Інформація про прочитання</string>
<string name="msg_log_out">Виходимо…</string> <string name="msg_log_out">Виходимо…</string>
<string name="msg_sent_attachment">Долучення відправлено</string> <string name="msg_sent_attachment">Долучення відправлено</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
</resources> </resources>
...@@ -316,9 +316,7 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin ...@@ -316,9 +316,7 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="notif_success_sending">Message sent to %1$s!</string> <string name="notif_success_sending">Message sent to %1$s!</string>
<string name="read_by">Read by</string> <string name="read_by">Read by</string>
<string name="message_information_title">Message information</string> <string name="message_information_title">Message information</string>
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
<string name="foss" tools:ignore="MissingTranslation">(FOSS)</string> <string name="foss" tools:ignore="MissingTranslation">(FOSS)</string>
<!-- Community Server-->
</resources> </resources>
\ 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