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
076d4bfa
Commit
076d4bfa
authored
Dec 28, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'layout/finishing-authentication-screens' into feature/show-chat-list-using-sdk
parents
a73bfc85
b5e6e327
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
74 additions
and
37 deletions
+74
-37
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+20
-15
LoginView.kt
...et/android/authentication/login/presentation/LoginView.kt
+2
-1
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+4
-0
ServerPresenter.kt
...oid/authentication/server/presentation/ServerPresenter.kt
+2
-4
ServerView.kt
.../android/authentication/server/presentation/ServerView.kt
+2
-1
ServerFragment.kt
...rocket/android/authentication/server/ui/ServerFragment.kt
+5
-1
SignupPresenter.kt
...oid/authentication/signup/presentation/SignupPresenter.kt
+18
-13
SignupView.kt
.../android/authentication/signup/presentation/SignupView.kt
+2
-1
SignupFragment.kt
...rocket/android/authentication/signup/ui/SignupFragment.kt
+4
-0
TwoFAView.kt
...ndroid/authentication/twofactor/presentation/TwoFAView.kt
+2
-1
TwoFAFragment.kt
...cket/android/authentication/twofactor/ui/TwoFAFragment.kt
+4
-0
InternetView.kt
.../java/chat/rocket/android/core/behaviours/InternetView.kt
+6
-0
LoadingView.kt
...n/java/chat/rocket/android/core/behaviours/LoadingView.kt
+2
-0
MessageView.kt
...n/java/chat/rocket/android/core/behaviours/MessageView.kt
+1
-0
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
076d4bfa
...
...
@@ -2,6 +2,7 @@ package chat.rocket.android.authentication.login.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.RocketChatException
import
chat.rocket.common.RocketChatTwoFactorException
...
...
@@ -26,24 +27,28 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
else
->
{
launchUI
(
strategy
)
{
view
.
showLoading
()
try
{
val
token
=
client
.
login
(
usernameOrEmail
,
password
)
Timber
.
d
(
"Created token: $token"
)
navigator
.
toChatList
()
}
catch
(
rocketChatException
:
RocketChatException
)
{
when
(
rocketChatException
)
{
is
RocketChatTwoFactorException
->
{
navigator
.
toTwoFA
(
navigator
.
currentServer
!!
,
usernameOrEmail
,
password
)
}
else
->
{
val
errorMessage
=
rocketChatException
.
message
if
(
errorMessage
!=
null
)
{
view
.
showMessage
(
errorMessage
)
if
(
NetworkHelper
.
hasInternetAccess
())
{
try
{
val
token
=
client
.
login
(
usernameOrEmail
,
password
)
Timber
.
d
(
"Created token: $token"
)
navigator
.
toChatList
()
}
catch
(
rocketChatException
:
RocketChatException
)
{
when
(
rocketChatException
)
{
is
RocketChatTwoFactorException
->
{
navigator
.
toTwoFA
(
navigator
.
currentServer
!!
,
usernameOrEmail
,
password
)
}
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/login/presentation/LoginView.kt
View file @
076d4bfa
package
chat.rocket.android.authentication.login.presentation
import
chat.rocket.android.core.behaviours.InternetView
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
LoginView
:
LoadingView
,
MessageView
{
interface
LoginView
:
LoadingView
,
MessageView
,
InternetView
{
/**
* Shows the oauth view if the server settings allow the login via social accounts.
...
...
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
076d4bfa
...
...
@@ -182,6 +182,10 @@ class LoginFragment : Fragment(), LoginView {
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
showNoInternetConnection
()
{
Toast
.
makeText
(
activity
,
getString
(
R
.
string
.
msg_no_internet_connection
),
Toast
.
LENGTH_SHORT
).
show
()
}
private
fun
tintEditTextDrawableStart
()
{
activity
?.
applicationContext
?.
apply
{
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_assignment_ind_black_24dp
,
this
)
...
...
app/src/main/java/chat/rocket/android/authentication/server/presentation/ServerPresenter.kt
View file @
076d4bfa
package
chat.rocket.android.authentication.server.presentation
import
android.content.Context
import
chat.rocket.android.R
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.NetworkHelper
...
...
@@ -14,7 +12,7 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
private
val
navigator
:
AuthenticationNavigator
)
{
@Inject
lateinit
var
client
:
RocketChatClient
fun
connect
(
context
:
Context
,
server
:
String
)
{
fun
connect
(
server
:
String
)
{
launchUI
(
strategy
)
{
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
...
...
@@ -25,7 +23,7 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
view
.
hideLoading
()
navigator
.
toLogin
(
server
)
}
else
{
view
.
show
Message
(
context
.
getString
(
R
.
string
.
msg_no_internet_connection
)
)
view
.
show
NoInternetConnection
(
)
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/server/presentation/ServerView.kt
View file @
076d4bfa
package
chat.rocket.android.authentication.server.presentation
import
chat.rocket.android.core.behaviours.InternetView
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
ServerView
:
LoadingView
,
MessageView
\ No newline at end of file
interface
ServerView
:
LoadingView
,
MessageView
,
InternetView
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/server/ui/ServerFragment.kt
View file @
076d4bfa
...
...
@@ -43,7 +43,7 @@ class ServerFragment : Fragment(), ServerView {
activity
?.
applicationContext
?.
apply
{
button_connect
.
setOnClickListener
{
val
url
=
text_server_url
.
textContent
.
ifEmpty
(
text_server_url
.
hintContent
)
presenter
.
connect
(
t
his
,
t
ext_server_protocol
.
textContent
+
url
)
presenter
.
connect
(
text_server_protocol
.
textContent
+
url
)
}
}
}
...
...
@@ -68,4 +68,8 @@ class ServerFragment : Fragment(), ServerView {
override
fun
showMessage
(
message
:
String
)
{
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
showNoInternetConnection
()
{
Toast
.
makeText
(
activity
,
getString
(
R
.
string
.
msg_no_internet_connection
),
Toast
.
LENGTH_SHORT
).
show
()
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/signup/presentation/SignupPresenter.kt
View file @
076d4bfa
...
...
@@ -2,6 +2,7 @@ package chat.rocket.android.authentication.signup.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.RocketChatException
import
chat.rocket.core.RocketChatClient
...
...
@@ -31,22 +32,26 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
}
else
->
{
launchUI
(
strategy
)
{
view
.
showLoading
()
try
{
val
user
=
client
.
signup
(
email
,
name
,
username
,
password
)
Timber
.
d
(
"Created user: $user"
)
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
try
{
val
user
=
client
.
signup
(
email
,
name
,
username
,
password
)
Timber
.
d
(
"Created user: $user"
)
val
token
=
client
.
login
(
username
,
password
)
Timber
.
d
(
"Logged in. Token: $token"
)
val
token
=
client
.
login
(
username
,
password
)
Timber
.
d
(
"Logged in. Token: $token"
)
navigator
.
toChatList
()
}
catch
(
ex
:
RocketChatException
)
{
val
errorMessage
=
ex
.
message
if
(
errorMessage
!=
null
)
{
view
.
showMessage
(
errorMessage
)
navigator
.
toChatList
()
}
catch
(
ex
:
RocketChatException
)
{
val
errorMessage
=
ex
.
message
if
(
errorMessage
!=
null
)
{
view
.
showMessage
(
errorMessage
)
}
}
finally
{
view
.
hideLoading
()
}
}
finally
{
view
.
hideLoading
()
}
else
{
view
.
showNoInternetConnection
()
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/signup/presentation/SignupView.kt
View file @
076d4bfa
package
chat.rocket.android.authentication.signup.presentation
import
chat.rocket.android.core.behaviours.InternetView
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
SignupView
:
LoadingView
,
MessageView
{
interface
SignupView
:
LoadingView
,
MessageView
,
InternetView
{
/**
* Alerts the user about a blank name.
...
...
app/src/main/java/chat/rocket/android/authentication/signup/ui/SignupFragment.kt
View file @
076d4bfa
...
...
@@ -116,6 +116,10 @@ class SignupFragment : Fragment(), SignupView {
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
showNoInternetConnection
()
{
Toast
.
makeText
(
activity
,
getString
(
R
.
string
.
msg_no_internet_connection
),
Toast
.
LENGTH_SHORT
).
show
()
}
private
fun
tintEditTextDrawableStart
()
{
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_person_black_24dp
,
appContext
)
val
atDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_at_black_24dp
,
appContext
)
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/presentation/TwoFAView.kt
View file @
076d4bfa
package
chat.rocket.android.authentication.twofactor.presentation
import
chat.rocket.android.core.behaviours.InternetView
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
TwoFAView
:
LoadingView
,
MessageView
{
interface
TwoFAView
:
LoadingView
,
MessageView
,
InternetView
{
/**
* Alerts the user about a blank two factor authentication code.
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/ui/TwoFAFragment.kt
View file @
076d4bfa
...
...
@@ -84,6 +84,10 @@ class TwoFAFragment : Fragment(), TwoFAView {
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
showNoInternetConnection
()
{
Toast
.
makeText
(
activity
,
getString
(
R
.
string
.
msg_no_internet_connection
),
Toast
.
LENGTH_SHORT
).
show
()
}
private
fun
tintEditTextDrawableStart
()
{
activity
?.
applicationContext
?.
apply
{
val
lockDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_vpn_key_black_24dp
,
this
)
...
...
app/src/main/java/chat/rocket/android/core/behaviours/InternetView.kt
0 → 100644
View file @
076d4bfa
package
chat.rocket.android.core.behaviours
interface
InternetView
{
fun
showNoInternetConnection
()
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/core/behaviours/LoadingView.kt
View file @
076d4bfa
package
chat.rocket.android.core.behaviours
interface
LoadingView
{
fun
showLoading
()
fun
hideLoading
()
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/core/behaviours/MessageView.kt
View file @
076d4bfa
package
chat.rocket.android.core.behaviours
interface
MessageView
{
fun
showMessage
(
message
:
String
)
}
\ No newline at end of file
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