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
87ec4725
Unverified
Commit
87ec4725
authored
Jul 27, 2018
by
Lucio Maciel
Committed by
GitHub
Jul 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1554 from RocketChat/improvement/more-idiomatic-kotlin
[IMPROVEMENT] More idiomatic kotlin
parents
f14c561a
98414a20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
76 deletions
+27
-76
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+27
-76
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
87ec4725
...
@@ -507,9 +507,7 @@ class LoginPresenter @Inject constructor(
...
@@ -507,9 +507,7 @@ class LoginPresenter @Inject constructor(
private
fun
getServiceMap
(
private
fun
getServiceMap
(
listMap
:
List
<
Map
<
String
,
Any
>>,
listMap
:
List
<
Map
<
String
,
Any
>>,
serviceName
:
String
serviceName
:
String
):
Map
<
String
,
Any
>?
{
):
Map
<
String
,
Any
>?
=
listMap
.
find
{
map
->
map
.
containsValue
(
serviceName
)
}
return
listMap
.
find
{
map
->
map
.
containsValue
(
serviceName
)
}
}
/**
/**
* Returns the OAuth client ID of a [serviceMap].
* Returns the OAuth client ID of a [serviceMap].
...
@@ -519,83 +517,56 @@ class LoginPresenter @Inject constructor(
...
@@ -519,83 +517,56 @@ class LoginPresenter @Inject constructor(
* @param serviceMap The service map to get the OAuth client ID.
* @param serviceMap The service map to get the OAuth client ID.
* @return The OAuth client ID or null otherwise.
* @return The OAuth client ID or null otherwise.
*/
*/
private
fun
getOauthClientId
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
{
private
fun
getOauthClientId
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
=
return
try
{
serviceMap
[
"clientId"
]
as
?
String
?:
serviceMap
[
"appId"
]
as
?
String
serviceMap
[
"clientId"
]
as
String
?:
serviceMap
[
"appId"
]
as
String
}
catch
(
exception
:
ClassCastException
)
{
null
}
}
/**
/**
* Returns a custom OAuth service list.
* Returns a custom OAuth service list.
*
*
* @return A custom OAuth service list, otherwise an empty list if there is no custom OAuth service.
* @return A custom OAuth service list, otherwise an empty list if there is no custom OAuth service.
*/
*/
private
fun
getCustomOauthServices
(
listMap
:
List
<
Map
<
String
,
Any
>>):
List
<
Map
<
String
,
Any
>>
{
private
fun
getCustomOauthServices
(
listMap
:
List
<
Map
<
String
,
Any
>>):
List
<
Map
<
String
,
Any
>>
=
return
listMap
.
filter
{
map
->
map
[
"custom"
]
==
true
}
listMap
.
filter
{
map
->
map
[
"custom"
]
==
true
}
}
/** Returns the custom OAuth service host.
/** Returns the custom OAuth service host.
*
*
* @param serviceMap The service map to get the custom OAuth service host.
* @param serviceMap The service map to get the custom OAuth service host.
* @return The custom OAuth service host, otherwise null.
* @return The custom OAuth service host, otherwise null.
*/
*/
private
fun
getCustomOauthHost
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
{
private
fun
getCustomOauthHost
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
=
return
try
{
serviceMap
[
"serverURL"
]
as
?
String
serviceMap
[
"serverURL"
]
as
String
}
catch
(
exception
:
ClassCastException
)
{
null
}
}
/** Returns the custom OAuth service authorize path.
/** Returns the custom OAuth service authorize path.
*
*
* @param serviceMap The service map to get the custom OAuth service authorize path.
* @param serviceMap The service map to get the custom OAuth service authorize path.
* @return The custom OAuth service authorize path, otherwise null.
* @return The custom OAuth service authorize path, otherwise null.
*/
*/
private
fun
getCustomOauthAuthorizePath
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
{
private
fun
getCustomOauthAuthorizePath
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
=
return
try
{
serviceMap
[
"authorizePath"
]
as
?
String
serviceMap
[
"authorizePath"
]
as
String
}
catch
(
exception
:
ClassCastException
)
{
null
}
}
/** Returns the custom OAuth service scope.
/** Returns the custom OAuth service scope.
*
*
* @param serviceMap The service map to get the custom OAuth service scope.
* @param serviceMap The service map to get the custom OAuth service scope.
* @return The custom OAuth service scope, otherwise null.
* @return The custom OAuth service scope, otherwise null.
*/
*/
private
fun
getCustomOauthScope
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
{
private
fun
getCustomOauthScope
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
=
return
try
{
serviceMap
[
"scope"
]
as
?
String
serviceMap
[
"scope"
]
as
String
}
catch
(
exception
:
ClassCastException
)
{
null
}
}
/** Returns the text of the custom OAuth service.
/** Returns the text of the custom OAuth service.
*
*
* @param serviceMap The service map to get the text of the custom OAuth service.
* @param serviceMap The service map to get the text of the custom OAuth service.
* @return The text of the custom OAuth service, otherwise null.
* @return The text of the custom OAuth service, otherwise null.
*/
*/
private
fun
getCustomOauthServiceName
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
{
private
fun
getCustomOauthServiceName
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
=
return
try
{
serviceMap
[
"service"
]
as
?
String
serviceMap
[
"service"
]
as
String
}
catch
(
exception
:
ClassCastException
)
{
null
}
}
/**
/**
* Returns a SAML OAuth service list.
* Returns a SAML OAuth service list.
*
*
* @return A SAML service list, otherwise an empty list if there is no SAML OAuth service.
* @return A SAML service list, otherwise an empty list if there is no SAML OAuth service.
*/
*/
private
fun
getSamlServices
(
listMap
:
List
<
Map
<
String
,
Any
>>):
List
<
Map
<
String
,
Any
>>
{
private
fun
getSamlServices
(
listMap
:
List
<
Map
<
String
,
Any
>>):
List
<
Map
<
String
,
Any
>>
=
return
listMap
.
filter
{
map
->
map
[
"service"
]
==
"saml"
}
listMap
.
filter
{
map
->
map
[
"service"
]
==
"saml"
}
}
/**
/**
* Returns the SAML provider.
* Returns the SAML provider.
...
@@ -603,13 +574,8 @@ class LoginPresenter @Inject constructor(
...
@@ -603,13 +574,8 @@ class LoginPresenter @Inject constructor(
* @param serviceMap The service map to provider from.
* @param serviceMap The service map to provider from.
* @return The SAML provider, otherwise null.
* @return The SAML provider, otherwise null.
*/
*/
private
fun
getSamlProvider
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
{
private
fun
getSamlProvider
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
=
return
try
{
(
serviceMap
[
"clientConfig"
]
as
Map
<*,
*>)[
"provider"
]
as
?
String
(
serviceMap
[
"clientConfig"
]
as
Map
<*,
*>)[
"provider"
]
as
String
}
catch
(
exception
:
ClassCastException
)
{
null
}
}
/**
/**
* Returns the text of the SAML service.
* Returns the text of the SAML service.
...
@@ -617,13 +583,8 @@ class LoginPresenter @Inject constructor(
...
@@ -617,13 +583,8 @@ class LoginPresenter @Inject constructor(
* @param serviceMap The service map to get the text of the SAML service.
* @param serviceMap The service map to get the text of the SAML service.
* @return The text of the SAML service, otherwise null.
* @return The text of the SAML service, otherwise null.
*/
*/
private
fun
getSamlServiceName
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
{
private
fun
getSamlServiceName
(
serviceMap
:
Map
<
String
,
Any
>):
String
?
=
return
try
{
serviceMap
[
"buttonLabelText"
]
as
?
String
serviceMap
[
"buttonLabelText"
]
as
String
}
catch
(
exception
:
ClassCastException
)
{
null
}
}
/**
/**
* Returns the text color of the service name.
* Returns the text color of the service name.
...
@@ -632,13 +593,8 @@ class LoginPresenter @Inject constructor(
...
@@ -632,13 +593,8 @@ class LoginPresenter @Inject constructor(
* @param serviceMap The service map to get the text color from.
* @param serviceMap The service map to get the text color from.
* @return The text color of the service (custom OAuth or SAML), otherwise null.
* @return The text color of the service (custom OAuth or SAML), otherwise null.
*/
*/
private
fun
getServiceNameColorForCustomOauthOrSaml
(
serviceMap
:
Map
<
String
,
Any
>):
Int
?
{
private
fun
getServiceNameColorForCustomOauthOrSaml
(
serviceMap
:
Map
<
String
,
Any
>):
Int
?
=
return
try
{
(
serviceMap
[
"buttonLabelColor"
]
as
?
String
)
?.
parseColor
()
(
serviceMap
[
"buttonLabelColor"
]
as
String
).
parseColor
()
}
catch
(
exception
:
ClassCastException
)
{
null
}
}
/**
/**
* Returns the button color of the service name.
* Returns the button color of the service name.
...
@@ -647,13 +603,8 @@ class LoginPresenter @Inject constructor(
...
@@ -647,13 +603,8 @@ class LoginPresenter @Inject constructor(
* @param serviceMap The service map to get the button color from.
* @param serviceMap The service map to get the button color from.
* @return The button color of the service (custom OAuth or SAML), otherwise null.
* @return The button color of the service (custom OAuth or SAML), otherwise null.
*/
*/
private
fun
getServiceButtonColor
(
serviceMap
:
Map
<
String
,
Any
>):
Int
?
{
private
fun
getServiceButtonColor
(
serviceMap
:
Map
<
String
,
Any
>):
Int
?
=
return
try
{
(
serviceMap
[
"buttonColor"
]
as
?
String
)
?.
parseColor
()
(
serviceMap
[
"buttonColor"
]
as
String
).
parseColor
()
}
catch
(
exception
:
ClassCastException
)
{
null
}
}
private
suspend
fun
saveAccount
(
username
:
String
)
{
private
suspend
fun
saveAccount
(
username
:
String
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
val
icon
=
settings
.
favicon
()
?.
let
{
...
...
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