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
b5e6e327
Commit
b5e6e327
authored
Dec 28, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove context from presenter and create InternetView interface
parent
f5a13b4e
Changes
14
Show 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 @
b5e6e327
...
@@ -2,6 +2,7 @@ package chat.rocket.android.authentication.login.presentation
...
@@ -2,6 +2,7 @@ package chat.rocket.android.authentication.login.presentation
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.NetworkHelper
import
chat.rocket.android.util.launchUI
import
chat.rocket.android.util.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatTwoFactorException
import
chat.rocket.common.RocketChatTwoFactorException
...
@@ -26,6 +27,7 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
...
@@ -26,6 +27,7 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
else
->
{
else
->
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
view
.
showLoading
()
view
.
showLoading
()
if
(
NetworkHelper
.
hasInternetAccess
())
{
try
{
try
{
val
token
=
client
.
login
(
usernameOrEmail
,
password
)
val
token
=
client
.
login
(
usernameOrEmail
,
password
)
Timber
.
d
(
"Created token: $token"
)
Timber
.
d
(
"Created token: $token"
)
...
@@ -45,6 +47,9 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
...
@@ -45,6 +47,9 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
}
finally
{
}
finally
{
view
.
hideLoading
()
view
.
hideLoading
()
}
}
}
else
{
view
.
showNoInternetConnection
()
}
}
}
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginView.kt
View file @
b5e6e327
package
chat.rocket.android.authentication.login.presentation
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.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
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.
* 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 @
b5e6e327
...
@@ -182,6 +182,10 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -182,6 +182,10 @@ class LoginFragment : Fragment(), LoginView {
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
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
()
{
private
fun
tintEditTextDrawableStart
()
{
activity
?.
applicationContext
?.
apply
{
activity
?.
applicationContext
?.
apply
{
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_assignment_ind_black_24dp
,
this
)
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 @
b5e6e327
package
chat.rocket.android.authentication.server.presentation
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.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.NetworkHelper
import
chat.rocket.android.helper.NetworkHelper
...
@@ -14,7 +12,7 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
...
@@ -14,7 +12,7 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
private
val
navigator
:
AuthenticationNavigator
)
{
private
val
navigator
:
AuthenticationNavigator
)
{
@Inject
lateinit
var
client
:
RocketChatClient
@Inject
lateinit
var
client
:
RocketChatClient
fun
connect
(
context
:
Context
,
server
:
String
)
{
fun
connect
(
server
:
String
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
if
(
NetworkHelper
.
hasInternetAccess
())
{
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
view
.
showLoading
()
...
@@ -25,7 +23,7 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
...
@@ -25,7 +23,7 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
view
.
hideLoading
()
view
.
hideLoading
()
navigator
.
toLogin
(
server
)
navigator
.
toLogin
(
server
)
}
else
{
}
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 @
b5e6e327
package
chat.rocket.android.authentication.server.presentation
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.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.android.core.behaviours.MessageView
interface
ServerView
:
LoadingView
,
MessageView
interface
ServerView
:
LoadingView
,
MessageView
,
InternetView
\ No newline at end of file
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/server/ui/ServerFragment.kt
View file @
b5e6e327
...
@@ -43,7 +43,7 @@ class ServerFragment : Fragment(), ServerView {
...
@@ -43,7 +43,7 @@ class ServerFragment : Fragment(), ServerView {
activity
?.
applicationContext
?.
apply
{
activity
?.
applicationContext
?.
apply
{
button_connect
.
setOnClickListener
{
button_connect
.
setOnClickListener
{
val
url
=
text_server_url
.
textContent
.
ifEmpty
(
text_server_url
.
hintContent
)
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 {
...
@@ -68,4 +68,8 @@ class ServerFragment : Fragment(), ServerView {
override
fun
showMessage
(
message
:
String
)
{
override
fun
showMessage
(
message
:
String
)
{
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
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 @
b5e6e327
...
@@ -2,6 +2,7 @@ package chat.rocket.android.authentication.signup.presentation
...
@@ -2,6 +2,7 @@ package chat.rocket.android.authentication.signup.presentation
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.NetworkHelper
import
chat.rocket.android.util.launchUI
import
chat.rocket.android.util.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.RocketChatClient
...
@@ -31,6 +32,7 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
...
@@ -31,6 +32,7 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
}
}
else
->
{
else
->
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
view
.
showLoading
()
try
{
try
{
val
user
=
client
.
signup
(
email
,
name
,
username
,
password
)
val
user
=
client
.
signup
(
email
,
name
,
username
,
password
)
...
@@ -48,6 +50,9 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
...
@@ -48,6 +50,9 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
}
finally
{
}
finally
{
view
.
hideLoading
()
view
.
hideLoading
()
}
}
}
else
{
view
.
showNoInternetConnection
()
}
}
}
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/signup/presentation/SignupView.kt
View file @
b5e6e327
package
chat.rocket.android.authentication.signup.presentation
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.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.android.core.behaviours.MessageView
interface
SignupView
:
LoadingView
,
MessageView
{
interface
SignupView
:
LoadingView
,
MessageView
,
InternetView
{
/**
/**
* Alerts the user about a blank name.
* Alerts the user about a blank name.
...
...
app/src/main/java/chat/rocket/android/authentication/signup/ui/SignupFragment.kt
View file @
b5e6e327
...
@@ -116,6 +116,10 @@ class SignupFragment : Fragment(), SignupView {
...
@@ -116,6 +116,10 @@ class SignupFragment : Fragment(), SignupView {
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
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
()
{
private
fun
tintEditTextDrawableStart
()
{
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_person_black_24dp
,
appContext
)
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_person_black_24dp
,
appContext
)
val
atDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_at_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 @
b5e6e327
package
chat.rocket.android.authentication.twofactor.presentation
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.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
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.
* Alerts the user about a blank two factor authentication code.
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/ui/TwoFAFragment.kt
View file @
b5e6e327
...
@@ -84,6 +84,10 @@ class TwoFAFragment : Fragment(), TwoFAView {
...
@@ -84,6 +84,10 @@ class TwoFAFragment : Fragment(), TwoFAView {
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
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
()
{
private
fun
tintEditTextDrawableStart
()
{
activity
?.
applicationContext
?.
apply
{
activity
?.
applicationContext
?.
apply
{
val
lockDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_vpn_key_black_24dp
,
this
)
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 @
b5e6e327
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 @
b5e6e327
package
chat.rocket.android.core.behaviours
package
chat.rocket.android.core.behaviours
interface
LoadingView
{
interface
LoadingView
{
fun
showLoading
()
fun
showLoading
()
fun
hideLoading
()
fun
hideLoading
()
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/core/behaviours/MessageView.kt
View file @
b5e6e327
package
chat.rocket.android.core.behaviours
package
chat.rocket.android.core.behaviours
interface
MessageView
{
interface
MessageView
{
fun
showMessage
(
message
:
String
)
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