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
41e265b9
Commit
41e265b9
authored
Apr 02, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add recommended and minimum required version checks
parent
feafda0f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
6 deletions
+45
-6
build.gradle
app/build.gradle
+4
-0
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+23
-6
LoginView.kt
...et/android/authentication/login/presentation/LoginView.kt
+10
-0
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+8
-0
No files found.
app/build.gradle
View file @
41e265b9
...
@@ -30,12 +30,16 @@ android {
...
@@ -30,12 +30,16 @@ android {
buildTypes
{
buildTypes
{
release
{
release
{
buildConfigField
"String"
,
"REQUIRED_SERVER_VERSION"
,
'"0.62.0"'
buildConfigField
"String"
,
"RECOMMENDED_SERVER_VERSION"
,
'"0.63.0"'
signingConfig
signingConfigs
.
release
signingConfig
signingConfigs
.
release
minifyEnabled
false
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
debug
{
debug
{
buildConfigField
"String"
,
"REQUIRED_SERVER_VERSION"
,
'"0.62.0"'
buildConfigField
"String"
,
"RECOMMENDED_SERVER_VERSION"
,
'"0.63.0"'
applicationIdSuffix
".dev"
applicationIdSuffix
".dev"
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
41e265b9
package
chat.rocket.android.authentication.login.presentation
package
chat.rocket.android.authentication.login.presentation
import
chat.rocket.android.BuildConfig
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
...
@@ -268,17 +269,33 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
...
@@ -268,17 +269,33 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
private
fun
checkServerInfo
()
{
private
fun
checkServerInfo
()
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
val
serverInfo
=
client
.
serverInfo
()
val
serverInfo
=
client
.
serverInfo
()
val
isNiceVersion
=
isRequiredVersionOk
(
serverInfo
.
version
)
val
thisServerVersion
=
serverInfo
.
version
if
(
isNiceVersion
)
{
val
isRequiredVersion
=
isRequiredServerVersion
(
thisServerVersion
)
Timber
.
i
(
"Your version is nice! (Requires: 0.62.0, Yours: ${serverInfo.version})"
)
val
isRecommendedVersion
=
isRecommendedServerVersion
(
thisServerVersion
)
if
(
isRequiredVersion
)
{
if
(
isRecommendedVersion
)
{
view
.
alertNotRecommendedVersion
()
}
else
{
Timber
.
i
(
"Your version is nice! (Requires: 0.62.0, Yours: $thisServerVersion)"
)
}
}
else
{
}
else
{
Timber
.
i
(
"Oops. Looks like your server is out-of-date! Please, upgrade your server for a better experience!"
)
if
(!
isRecommendedVersion
)
{
view
.
blockAndAlertNotRequiredVersion
()
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
{
private
fun
isRequiredServerVersion
(
version
:
String
):
Boolean
{
val
required
=
getVersionDistilled
(
"0.62.0"
)
return
isMinimumVersion
(
version
,
getVersionDistilled
(
BuildConfig
.
REQUIRED_SERVER_VERSION
))
}
private
fun
isRecommendedServerVersion
(
version
:
String
):
Boolean
{
return
isMinimumVersion
(
version
,
getVersionDistilled
(
BuildConfig
.
RECOMMENDED_SERVER_VERSION
))
}
private
fun
isMinimumVersion
(
version
:
String
,
required
:
VersionInfo
):
Boolean
{
val
thisVersion
=
getVersionDistilled
(
version
)
val
thisVersion
=
getVersionDistilled
(
version
)
with
(
thisVersion
)
{
with
(
thisVersion
)
{
if
(
major
<
required
.
major
)
{
if
(
major
<
required
.
major
)
{
...
...
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginView.kt
View file @
41e265b9
...
@@ -186,4 +186,14 @@ interface LoginView : LoadingView, MessageView, InternetView {
...
@@ -186,4 +186,14 @@ interface LoginView : LoadingView, MessageView, InternetView {
* Alerts the user about a wrong inputted password.
* Alerts the user about a wrong inputted password.
*/
*/
fun
alertWrongPassword
()
fun
alertWrongPassword
()
/**
* Alerts the user about the server version not meeting the recommended server version.
*/
fun
alertNotRecommendedVersion
()
/**
* Block user to proceed and alert him due to server having an unsupported server version.
*/
fun
blockAndAlertNotRequiredVersion
()
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
41e265b9
...
@@ -289,6 +289,14 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -289,6 +289,14 @@ class LoginFragment : Fragment(), LoginView {
text_password
.
requestFocus
()
text_password
.
requestFocus
()
}
}
override
fun
alertNotRecommendedVersion
()
{
}
override
fun
blockAndAlertNotRequiredVersion
()
{
}
private
fun
showRemainingSocialAccountsView
()
{
private
fun
showRemainingSocialAccountsView
()
{
social_accounts_container
.
postDelayed
({
social_accounts_container
.
postDelayed
({
(
0
..
social_accounts_container
.
childCount
)
(
0
..
social_accounts_container
.
childCount
)
...
...
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