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
0161e7c7
Commit
0161e7c7
authored
Apr 09, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the check for internet connection.
parent
48d1e77a
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
121 additions
and
210 deletions
+121
-210
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+45
-50
LoginView.kt
...et/android/authentication/login/presentation/LoginView.kt
+1
-2
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+0
-4
RegisterUsernamePresenter.kt
...egisterusername/presentation/RegisterUsernamePresenter.kt
+19
-24
RegisterUsernameView.kt
...ion/registerusername/presentation/RegisterUsernameView.kt
+1
-2
RegisterUsernameFragment.kt
...ntication/registerusername/ui/RegisterUsernameFragment.kt
+0
-4
ServerPresenter.kt
...oid/authentication/server/presentation/ServerPresenter.kt
+12
-17
ServerView.kt
.../android/authentication/server/presentation/ServerView.kt
+1
-2
ServerFragment.kt
...rocket/android/authentication/server/ui/ServerFragment.kt
+0
-4
SignupPresenter.kt
...oid/authentication/signup/presentation/SignupPresenter.kt
+19
-25
SignupView.kt
.../android/authentication/signup/presentation/SignupView.kt
+1
-2
SignupFragment.kt
...rocket/android/authentication/signup/ui/SignupFragment.kt
+0
-4
TwoFAPresenter.kt
...d/authentication/twofactor/presentation/TwoFAPresenter.kt
+21
-26
TwoFAView.kt
...ndroid/authentication/twofactor/presentation/TwoFAView.kt
+1
-2
TwoFAFragment.kt
...cket/android/authentication/twofactor/ui/TwoFAFragment.kt
+0
-2
InternetView.kt
.../java/chat/rocket/android/core/behaviours/InternetView.kt
+0
-6
NetworkHelper.kt
...src/main/java/chat/rocket/android/helper/NetworkHelper.kt
+0
-31
strings.xml
app/src/main/res/values-hi-rIN/strings.xml
+0
-1
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+0
-1
strings.xml
app/src/main/res/values/strings.xml
+0
-1
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
0161e7c7
...
...
@@ -2,7 +2,6 @@ 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.helper.OauthHelper
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.*
...
...
@@ -190,7 +189,6 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
private
fun
doAuthentication
(
loginType
:
Int
)
{
launchUI
(
strategy
)
{
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
disableUserInput
()
view
.
showLoading
()
try
{
...
...
@@ -246,9 +244,6 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
view
.
hideLoading
()
view
.
enableUserInput
()
}
}
else
{
view
.
showNoInternetConnection
()
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginView.kt
View file @
0161e7c7
package
chat.rocket.android.authentication.login.presentation
import
chat.rocket.android.authentication.server.presentation.VersionCheckView
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
,
InternetView
,
VersionCheckView
{
interface
LoginView
:
LoadingView
,
MessageView
,
VersionCheckView
{
/**
* Shows the form view (i.e the username/email and password fields) if it is enabled by the server settings.
...
...
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
0161e7c7
...
...
@@ -105,10 +105,6 @@ class LoginFragment : Fragment(), LoginView {
view_loading
.
setVisible
(
false
)
}
override
fun
showNoInternetConnection
()
{
showMessage
(
R
.
string
.
msg_no_internet_connection
)
}
override
fun
showMessage
(
resId
:
Int
)
{
showToast
(
resId
)
}
...
...
app/src/main/java/chat/rocket/android/authentication/registerusername/presentation/RegisterUsernamePresenter.kt
View file @
0161e7c7
...
...
@@ -2,7 +2,6 @@ package chat.rocket.android.authentication.registerusername.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.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.model.Account
...
...
@@ -40,7 +39,6 @@ class RegisterUsernamePresenter @Inject constructor(
view
.
alertBlankUsername
()
}
else
{
launchUI
(
strategy
)
{
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
try
{
val
me
=
retryIO
(
"updateOwnBasicInformation(username = $username)"
)
{
...
...
@@ -62,9 +60,6 @@ class RegisterUsernamePresenter @Inject constructor(
}
finally
{
view
.
hideLoading
()
}
}
else
{
view
.
showNoInternetConnection
()
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/registerusername/presentation/RegisterUsernameView.kt
View file @
0161e7c7
package
chat.rocket.android.authentication.registerusername.presentation
import
chat.rocket.android.core.behaviours.InternetView
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
RegisterUsernameView
:
LoadingView
,
MessageView
,
InternetView
{
interface
RegisterUsernameView
:
LoadingView
,
MessageView
{
/**
* Alerts the user about a blank username.
...
...
app/src/main/java/chat/rocket/android/authentication/registerusername/ui/RegisterUsernameFragment.kt
View file @
0161e7c7
...
...
@@ -85,10 +85,6 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView {
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
override
fun
showNoInternetConnection
()
{
showMessage
(
getString
(
R
.
string
.
msg_no_internet_connection
))
}
private
fun
tintEditTextDrawableStart
()
{
activity
?.
apply
{
val
atDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_at_black_24dp
,
this
)
...
...
app/src/main/java/chat/rocket/android/authentication/server/presentation/ServerPresenter.kt
View file @
0161e7c7
...
...
@@ -2,7 +2,6 @@ package chat.rocket.android.authentication.server.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.server.domain.GetAccountsInteractor
import
chat.rocket.android.server.domain.RefreshSettingsInteractor
import
chat.rocket.android.server.domain.SaveCurrentServerInteractor
...
...
@@ -29,7 +28,6 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
return
@launchUI
}
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
try
{
refreshSettingsInteractor
.
refresh
(
server
)
...
...
@@ -44,9 +42,6 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
}
finally
{
view
.
hideLoading
()
}
}
else
{
view
.
showNoInternetConnection
()
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/server/presentation/ServerView.kt
View file @
0161e7c7
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
,
InternetView
{
interface
ServerView
:
LoadingView
,
MessageView
{
/**
* Shows an invalid server URL message.
...
...
app/src/main/java/chat/rocket/android/authentication/server/ui/ServerFragment.kt
View file @
0161e7c7
...
...
@@ -68,10 +68,6 @@ class ServerFragment : Fragment(), ServerView {
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
override
fun
showNoInternetConnection
()
{
showMessage
(
getString
(
R
.
string
.
msg_no_internet_connection
))
}
private
fun
enableUserInput
(
value
:
Boolean
)
{
button_connect
.
isEnabled
=
value
text_server_url
.
isEnabled
=
value
...
...
app/src/main/java/chat/rocket/android/authentication/signup/presentation/SignupPresenter.kt
View file @
0161e7c7
...
...
@@ -2,7 +2,6 @@ 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.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.model.Account
...
...
@@ -57,9 +56,7 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
else
->
{
val
client
=
factory
.
create
(
server
)
launchUI
(
strategy
)
{
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
try
{
// TODO This function returns a user so should we save it?
retryIO
(
"signup"
)
{
client
.
signup
(
email
,
name
,
username
,
password
)
}
...
...
@@ -80,9 +77,6 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
view
.
hideLoading
()
}
}
else
{
view
.
showNoInternetConnection
()
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/signup/presentation/SignupView.kt
View file @
0161e7c7
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
,
InternetView
{
interface
SignupView
:
LoadingView
,
MessageView
{
/**
* Alerts the user about a blank name.
...
...
app/src/main/java/chat/rocket/android/authentication/signup/ui/SignupFragment.kt
View file @
0161e7c7
...
...
@@ -109,10 +109,6 @@ class SignupFragment : Fragment(), SignupView {
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
override
fun
showNoInternetConnection
()
{
Toast
.
makeText
(
activity
,
getString
(
R
.
string
.
msg_no_internet_connection
),
Toast
.
LENGTH_SHORT
).
show
()
}
private
fun
tintEditTextDrawableStart
()
{
activity
?.
apply
{
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_person_black_24dp
,
this
)
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/presentation/TwoFAPresenter.kt
View file @
0161e7c7
...
...
@@ -2,7 +2,6 @@ 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.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.model.Account
...
...
@@ -48,7 +47,6 @@ class TwoFAPresenter @Inject constructor(private val view: TwoFAView,
else
->
{
launchUI
(
strategy
)
{
val
client
=
factory
.
create
(
server
)
if
(
NetworkHelper
.
hasInternetAccess
())
{
view
.
showLoading
()
try
{
// The token is saved via the client TokenProvider
...
...
@@ -73,9 +71,6 @@ class TwoFAPresenter @Inject constructor(private val view: TwoFAView,
}
finally
{
view
.
hideLoading
()
}
}
else
{
view
.
showNoInternetConnection
()
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/presentation/TwoFAView.kt
View file @
0161e7c7
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
,
InternetView
{
interface
TwoFAView
:
LoadingView
,
MessageView
{
/**
* Alerts the user about a blank Two Factor Authentication code.
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/ui/TwoFAFragment.kt
View file @
0161e7c7
...
...
@@ -91,8 +91,6 @@ class TwoFAFragment : Fragment(), TwoFAView {
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
override
fun
showNoInternetConnection
()
=
showMessage
(
getString
(
R
.
string
.
msg_no_internet_connection
))
private
fun
tintEditTextDrawableStart
()
{
activity
?.
apply
{
val
lockDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_vpn_key_black_24dp
,
this
)
...
...
app/src/main/java/chat/rocket/android/core/behaviours/InternetView.kt
deleted
100644 → 0
View file @
48d1e77a
package
chat.rocket.android.core.behaviours
interface
InternetView
{
fun
showNoInternetConnection
()
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/helper/NetworkHelper.kt
deleted
100644 → 0
View file @
48d1e77a
package
chat.rocket.android.helper
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.withContext
import
java.io.IOException
import
java.net.InetSocketAddress
import
java.net.Socket
object
NetworkHelper
{
/**
* Checks whether there is internet access.
*
* The original author of this code is Levit and you can see his answer here: https://stackoverflow.com/a/27312494/4744263
*
* @return true if there is internet access, false otherwise.
*/
suspend
fun
hasInternetAccess
():
Boolean
=
withContext
(
CommonPool
)
{
try
{
val
socket
=
Socket
()
val
inetSocketAddress
=
InetSocketAddress
(
"8.8.8.8"
,
53
)
socket
.
connect
(
inetSocketAddress
,
1500
)
socket
.
close
()
true
}
catch
(
e
:
IOException
)
{
false
}
}
}
\ No newline at end of file
app/src/main/res/values-hi-rIN/strings.xml
View file @
0161e7c7
...
...
@@ -41,7 +41,6 @@
</string-array>
<!-- Regular information messages -->
<string
name=
"msg_no_internet_connection"
>
कोई इंटरनेट कनेक्शन नहीं है
</string>
<string
name=
"msg_generic_error"
>
क्षमा करें, एक त्रुटि हुई है, कृपया पुनः प्रयास करें
</string>
<string
name=
"msg_no_data_to_display"
>
डेटा प्रदर्शित करने के लिए उपलब्ध नहीं हैं
</string>
<string
name=
"msg_profile_update_successfully"
>
प्रोफ़ाइल सफलतापूर्वक अपडेट हो गया है
</string>
...
...
app/src/main/res/values-pt-rBR/strings.xml
View file @
0161e7c7
...
...
@@ -41,7 +41,6 @@
</string-array>
<!-- Regular information messages -->
<string
name=
"msg_no_internet_connection"
>
Sem conexão à internet
</string>
<string
name=
"msg_generic_error"
>
Desculpe, ocorreu um erro, tente novamente
</string>
<string
name=
"msg_no_data_to_display"
>
Nenhum dado para exibir
</string>
<string
name=
"msg_profile_update_successfully"
>
Perfil atualizado com sucesso
</string>
...
...
app/src/main/res/values/strings.xml
View file @
0161e7c7
...
...
@@ -42,7 +42,6 @@
</string-array>
<!-- Regular information messages -->
<string
name=
"msg_no_internet_connection"
>
No internet connection
</string>
<string
name=
"msg_generic_error"
>
Sorry, an error has occurred, please try again
</string>
<string
name=
"msg_no_data_to_display"
>
No data to display
</string>
<string
name=
"msg_profile_update_successfully"
>
Profile update successfully
</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