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
feafda0f
Commit
feafda0f
authored
Apr 02, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add server version checking logic
parent
b6b86885
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
0 deletions
+73
-0
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+62
-0
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+2
-0
VersionInfo.kt
app/src/main/java/chat/rocket/android/util/VersionInfo.kt
+9
-0
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
feafda0f
...
@@ -9,6 +9,7 @@ import chat.rocket.android.infrastructure.LocalRepository
...
@@ -9,6 +9,7 @@ import chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.model.Account
import
chat.rocket.android.server.domain.model.Account
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.VersionInfo
import
chat.rocket.android.util.extensions.*
import
chat.rocket.android.util.extensions.*
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.Token
import
chat.rocket.common.model.Token
...
@@ -53,6 +54,7 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
...
@@ -53,6 +54,7 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
setupUserRegistrationView
()
setupUserRegistrationView
()
setupCasView
()
setupCasView
()
setupOauthServicesView
()
setupOauthServicesView
()
checkServerInfo
()
}
}
fun
authenticateWithUserAndPassword
(
usernameOrEmail
:
String
,
password
:
String
)
{
fun
authenticateWithUserAndPassword
(
usernameOrEmail
:
String
,
password
:
String
)
{
...
@@ -262,4 +264,64 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
...
@@ -262,4 +264,64 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
val
account
=
Account
(
currentServer
,
icon
,
logo
,
me
.
username
!!
,
thumb
)
val
account
=
Account
(
currentServer
,
icon
,
logo
,
me
.
username
!!
,
thumb
)
saveAccountInteractor
.
save
(
account
)
saveAccountInteractor
.
save
(
account
)
}
}
private
fun
checkServerInfo
()
{
launchUI
(
strategy
)
{
val
serverInfo
=
client
.
serverInfo
()
val
isNiceVersion
=
isRequiredVersionOk
(
serverInfo
.
version
)
if
(
isNiceVersion
)
{
Timber
.
i
(
"Your version is nice! (Requires: 0.62.0, Yours: ${serverInfo.version})"
)
}
else
{
Timber
.
i
(
"Oops. Looks like your server is out-of-date! Please, upgrade your server for a better experience!"
)
}
}
}
private
fun
isRequiredVersionOk
(
version
:
String
):
Boolean
{
val
required
=
getVersionDistilled
(
"0.62.0"
)
val
thisVersion
=
getVersionDistilled
(
version
)
with
(
thisVersion
)
{
if
(
major
<
required
.
major
)
{
return
false
}
else
if
(
major
>
required
.
major
)
{
return
true
}
if
(
minor
<
required
.
minor
)
{
return
false
}
else
if
(
minor
>
required
.
minor
)
{
return
true
}
return
update
>=
required
.
update
}
}
private
fun
getVersionDistilled
(
version
:
String
):
VersionInfo
{
var
split
=
version
.
split
(
"-"
)
if
(
split
.
isEmpty
())
{
return
VersionInfo
(
0
,
0
,
0
,
null
,
"0.0.0"
)
}
val
ver
=
split
[
0
]
var
release
:
String
?
=
null
if
(
split
.
size
>
1
)
{
release
=
split
[
1
]
}
split
=
ver
.
split
(
"."
)
val
major
=
getVersionNumber
(
split
,
0
)
val
minor
=
getVersionNumber
(
split
,
1
)
val
update
=
getVersionNumber
(
split
,
2
)
return
VersionInfo
(
major
=
major
,
minor
=
minor
,
update
=
update
,
release
=
release
,
full
=
version
)
}
private
fun
getVersionNumber
(
split
:
List
<
String
>,
index
:
Int
):
Int
{
return
try
{
split
.
getOrNull
(
index
)
?.
toInt
()
?:
0
}
catch
(
ex
:
NumberFormatException
)
{
0
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
feafda0f
...
@@ -354,6 +354,7 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
...
@@ -354,6 +354,7 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
room
.
description
,
room
.
description
,
room
.
announcement
,
room
.
announcement
,
default
,
default
,
favorite
,
open
,
open
,
alert
,
alert
,
unread
,
unread
,
...
@@ -386,6 +387,7 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
...
@@ -386,6 +387,7 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
description
,
description
,
announcement
,
announcement
,
subscription
.
isDefault
,
subscription
.
isDefault
,
favorite
,
subscription
.
open
,
subscription
.
open
,
subscription
.
alert
,
subscription
.
alert
,
subscription
.
unread
,
subscription
.
unread
,
...
...
app/src/main/java/chat/rocket/android/util/VersionInfo.kt
0 → 100644
View file @
feafda0f
package
chat.rocket.android.util
data class
VersionInfo
(
val
major
:
Int
,
val
minor
:
Int
,
val
update
:
Int
=
0
,
val
release
:
String
?,
val
full
:
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