Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
6c49a9fb
Commit
6c49a9fb
authored
Jan 02, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add strings to alert the user about an invalid TwoFA code.
parent
30cf2a14
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
16 deletions
+43
-16
TwoFAPresenter.kt
...d/authentication/twofactor/presentation/TwoFAPresenter.kt
+21
-13
TwoFAView.kt
...ndroid/authentication/twofactor/presentation/TwoFAView.kt
+6
-1
TwoFAFragment.kt
...cket/android/authentication/twofactor/ui/TwoFAFragment.kt
+14
-2
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+1
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/authentication/twofactor/presentation/TwoFAPresenter.kt
View file @
6c49a9fb
...
...
@@ -2,11 +2,12 @@ package chat.rocket.android.authentication.twofactor.presentation
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.NetworkHelper
import
chat.rocket.android.util.launchUI
import
chat.rocket.common.RocketChatAuthException
import
chat.rocket.common.RocketChatException
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.login
import
timber.log.Timber
import
javax.inject.Inject
class
TwoFAPresenter
@Inject
constructor
(
private
val
view
:
TwoFAView
,
...
...
@@ -20,19 +21,26 @@ class TwoFAPresenter @Inject constructor(private val view: TwoFAView,
view
.
alertBlankTwoFactorAuthenticationCode
()
}
else
{
launchUI
(
strategy
)
{
view
.
showLoading
()
try
{
val
token
=
client
.
login
(
usernameOrEmail
,
password
,
twoFactorAuthenticationCode
)
Timber
.
d
(
"Created token: $token"
)
// Todo Salve token?.
navigator
.
toChatList
()
}
catch
(
ex
:
RocketChatException
)
{
val
errorMessage
=
ex
.
message
if
(
errorMessage
!=
null
)
{
view
.
showMessage
(
errorMessage
)
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
try
{
val
token
=
client
.
login
(
usernameOrEmail
,
password
,
twoFactorAuthenticationCode
)
// TODO Salve token?
navigator
.
toChatList
()
}
catch
(
rocketChatException
:
RocketChatException
)
{
if
(
rocketChatException
is
RocketChatAuthException
)
{
view
.
alertInvalidTwoFactorAuthenticationCode
()
}
else
{
val
errorMessage
=
rocketChatException
.
message
if
(
errorMessage
!=
null
)
{
view
.
showMessage
(
errorMessage
)
}
}
}
finally
{
view
.
hideLoading
()
}
}
finally
{
view
.
hideLoading
()
}
else
{
view
.
showNoInternetConnection
()
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/presentation/TwoFAView.kt
View file @
6c49a9fb
...
...
@@ -7,7 +7,12 @@ import chat.rocket.android.core.behaviours.MessageView
interface
TwoFAView
:
LoadingView
,
MessageView
,
InternetView
{
/**
* Alerts the user about a blank
two factor a
uthentication code.
* Alerts the user about a blank
Two Factor A
uthentication code.
*/
fun
alertBlankTwoFactorAuthenticationCode
()
/**
* Alerts the user about an invalid inputted Two Factor Authentication code.
*/
fun
alertInvalidTwoFactorAuthenticationCode
()
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/twofactor/ui/TwoFAFragment.kt
View file @
6c49a9fb
...
...
@@ -72,12 +72,19 @@ class TwoFAFragment : Fragment(), TwoFAView {
AnimationHelper
.
shakeView
(
text_two_factor_auth
)
}
override
fun
alertInvalidTwoFactorAuthenticationCode
()
{
showMessage
(
getString
(
R
.
string
.
msg_invalid_2fa_code
))
}
override
fun
showLoading
()
{
view_loading
.
setVisibility
(
true
)
enableUserInput
(
false
)
view_loading
.
show
()
}
override
fun
hideLoading
()
{
view_loading
.
setVisibility
(
false
)
view_loading
.
hide
()
enableUserInput
(
true
)
}
override
fun
showMessage
(
message
:
String
)
{
...
...
@@ -85,7 +92,7 @@ class TwoFAFragment : Fragment(), TwoFAView {
}
override
fun
showNoInternetConnection
()
{
Toast
.
makeText
(
activity
,
getString
(
R
.
string
.
msg_no_internet_connection
),
Toast
.
LENGTH_SHORT
).
show
(
)
showMessage
(
getString
(
R
.
string
.
msg_no_internet_connection
)
)
}
private
fun
tintEditTextDrawableStart
()
{
...
...
@@ -97,4 +104,9 @@ class TwoFAFragment : Fragment(), TwoFAView {
DrawableHelper
.
compoundDrawable
(
text_two_factor_auth
,
lockDrawable
)
}
}
private
fun
enableUserInput
(
value
:
Boolean
)
{
button_log_in
.
isEnabled
=
value
text_two_factor_auth
.
isEnabled
=
value
}
}
\ No newline at end of file
app/src/main/res/values-pt-rBR/strings.xml
View file @
6c49a9fb
...
...
@@ -23,6 +23,7 @@
<string
name=
"msg_new_to_rocket_chat"
>
Novo no Rocket Chat? %1$s
</string>
<string
name=
"msg_new_user_agreement"
>
Ao proceder você concorda com nossos %1$s e %2$s
</string>
<string
name=
"msg_2fa_code"
>
Código 2FA
</string>
<string
name=
"msg_invalid_2fa_code"
>
Código 2FA inválido
</string>
<string
name=
"msg_yesterday"
>
ontem
</string>
<string
name=
"msg_message"
>
Messagem
</string>
<string
name=
"msg_content_description_log_in_using_facebook"
>
Fazer login através do Facebook
</string>
...
...
app/src/main/res/values/strings.xml
View file @
6c49a9fb
...
...
@@ -24,6 +24,7 @@
<string
name=
"msg_new_to_rocket_chat"
>
New to Rocket Chat? %1$s
</string>
<string
name=
"msg_new_user_agreement"
>
By proceeding you are agreeing to our\n%1$s and %2$s
</string>
<string
name=
"msg_2fa_code"
>
2FA Code
</string>
<string
name=
"msg_invalid_2fa_code"
>
Invalid 2FA Code
</string>
<string
name=
"msg_more_than_ninety_nine_unread_messages"
translatable=
"false"
>
99+
</string>
<string
name=
"msg_yesterday"
>
Yesterday
</string>
<string
name=
"msg_message"
>
Message
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment