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
ada461e5
Commit
ada461e5
authored
Dec 10, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add rxKotlin dependency and update LoginPresenter and LoginFragment to
"kotlinized" it better
parent
69bb6a50
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
41 deletions
+50
-41
build.gradle
android-ddp/build.gradle
+1
-0
build.gradle
app/build.gradle
+1
-0
LoginFragment.kt
...at/rocket/android/fragment/server_config/LoginFragment.kt
+21
-23
LoginPresenter.kt
...t/rocket/android/fragment/server_config/LoginPresenter.kt
+22
-17
dependencies.gradle
dependencies.gradle
+3
-1
build.gradle
persistence-realm/build.gradle
+1
-0
build.gradle
rocket-chat-core/build.gradle
+1
-0
No files found.
android-ddp/build.gradle
View file @
ada461e5
...
...
@@ -24,6 +24,7 @@ dependencies {
api
project
(
':log-wrapper'
)
implementation
extraDependencies
.
okHTTP
implementation
extraDependencies
.
rxJava
implementation
extraDependencies
.
rxKotlin
implementation
extraDependencies
.
boltTask
implementation
supportDependencies
.
annotation
}
\ No newline at end of file
app/build.gradle
View file @
ada461e5
...
...
@@ -113,6 +113,7 @@ dependencies {
api
project
(
':persistence-realm'
)
implementation
extraDependencies
.
okHTTP
implementation
extraDependencies
.
rxJava
implementation
extraDependencies
.
rxKotlin
implementation
extraDependencies
.
boltTask
implementation
supportDependencies
.
multidex
implementation
supportDependencies
.
designSupportLibrary
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginFragment.kt
View file @
ada461e5
...
...
@@ -7,9 +7,6 @@ import android.support.v4.app.Fragment
import
android.view.View
import
android.widget.Button
import
android.widget.TextView
import
java.util.HashMap
import
chat.rocket.android.R
import
chat.rocket.android.api.MethodCallHelper
import
chat.rocket.android.layouthelper.oauth.OAuthProviderInfo
...
...
@@ -17,17 +14,18 @@ import chat.rocket.android.log.RCLog
import
chat.rocket.core.models.LoginServiceConfiguration
import
chat.rocket.persistence.realm.repositories.RealmLoginServiceConfigurationRepository
import
chat.rocket.persistence.realm.repositories.RealmPublicSettingRepository
import
java.util.*
/**
* Login screen.
*/
class
LoginFragment
:
AbstractServerConfigFragment
(),
LoginContract
.
View
{
private
var
presenter
:
LoginContract
.
Presenter
?
=
null
private
var
container
:
ConstraintLayout
?
=
null
private
var
waitingView
:
View
?
=
null
private
var
txtUsername
:
TextView
?
=
null
private
var
txtPasswd
:
TextView
?
=
null
private
lateinit
var
presenter
:
LoginContract
.
Presenter
private
lateinit
var
container
:
ConstraintLayout
private
lateinit
var
waitingView
:
View
private
lateinit
var
txtUsername
:
TextView
private
lateinit
var
txtPasswd
:
TextView
override
fun
getLayout
():
Int
{
return
R
.
layout
.
fragment_login
...
...
@@ -52,22 +50,22 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
txtPasswd
=
rootView
.
findViewById
(
R
.
id
.
editor_passwd
)
waitingView
=
rootView
.
findViewById
(
R
.
id
.
waiting
)
btnEmail
.
setOnClickListener
{
view
->
presenter
!!
.
login
(
txtUsername
!!
.
text
.
toString
(),
txtPasswd
!!
.
text
.
toString
())
}
btnEmail
.
setOnClickListener
{
view
->
presenter
.
login
(
txtUsername
.
text
.
toString
(),
txtPasswd
.
text
.
toString
())
}
btnUserRegistration
.
setOnClickListener
{
view
->
UserRegistrationDialogFragment
.
create
(
hostname
,
txtUsername
!!
.
text
.
toString
(),
txtPasswd
!!
.
text
.
toString
())
UserRegistrationDialogFragment
.
create
(
hostname
,
txtUsername
.
text
.
toString
(),
txtPasswd
.
text
.
toString
())
.
show
(
fragmentManager
!!
,
"UserRegistrationDialogFragment"
)
}
}
override
fun
showLoader
()
{
container
!!
.
visibility
=
View
.
GONE
waitingView
!!
.
visibility
=
View
.
VISIBLE
container
.
visibility
=
View
.
GONE
waitingView
.
visibility
=
View
.
VISIBLE
}
override
fun
hideLoader
()
{
waitingView
!!
.
visibility
=
View
.
GONE
container
!!
.
visibility
=
View
.
VISIBLE
waitingView
.
visibility
=
View
.
GONE
container
.
visibility
=
View
.
VISIBLE
}
override
fun
showError
(
message
:
String
)
{
...
...
@@ -84,9 +82,9 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
for
(
authProvider
in
loginServiceList
)
{
for
(
info
in
OAuthProviderInfo
.
LIST
)
{
if
(
!
supportedMap
[
info
.
serviceName
]
&&
info
.
serviceName
==
authProvider
.
service
)
{
if
(
supportedMap
[
info
.
serviceName
]
==
false
&&
info
.
serviceName
==
authProvider
.
service
)
{
supportedMap
.
put
(
info
.
serviceName
,
true
)
viewMap
[
info
.
serviceName
].
setOnClickListener
{
view
->
viewMap
[
info
.
serviceName
]
?
.
setOnClickListener
{
view
->
var
fragment
:
Fragment
?
=
null
try
{
fragment
=
info
.
fragmentClass
.
newInstance
()
...
...
@@ -94,38 +92,38 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
RCLog
.
w
(
exception
,
"failed to build new Fragment"
)
}
if
(
fragment
!=
null
)
{
fragment
?.
let
{
val
args
=
Bundle
()
args
.
putString
(
"hostname"
,
hostname
)
fragment
.
arguments
=
args
showFragmentWithBackStack
(
fragment
)
}
}
viewMap
[
info
.
serviceName
].
setVisibility
(
View
.
VISIBLE
)
viewMap
[
info
.
serviceName
]
?
.
setVisibility
(
View
.
VISIBLE
)
}
}
}
for
(
info
in
OAuthProviderInfo
.
LIST
)
{
if
(
!
supportedMap
[
info
.
serviceName
]
)
{
viewMap
[
info
.
serviceName
].
setVisibility
(
View
.
GONE
)
if
(
supportedMap
[
info
.
serviceName
]
==
false
)
{
viewMap
[
info
.
serviceName
]
?
.
setVisibility
(
View
.
GONE
)
}
}
}
override
fun
showTwoStepAuth
()
{
showFragmentWithBackStack
(
TwoStepAuthFragment
.
create
(
hostname
,
txtUsername
!!
.
text
.
toString
(),
txtPasswd
!!
.
text
.
toString
()
hostname
,
txtUsername
.
text
.
toString
(),
txtPasswd
.
text
.
toString
()
))
}
override
fun
onResume
()
{
super
.
onResume
()
presenter
!!
.
bindView
(
this
)
presenter
.
bindView
(
this
)
}
override
fun
onPause
()
{
presenter
!!
.
release
()
presenter
.
release
()
super
.
onPause
()
}
}
app/src/main/java/chat/rocket/android/fragment/server_config/LoginPresenter.kt
View file @
ada461e5
package
chat.rocket.android.fragment.server_config
import
com.hadisatrio.optional.Optional
import
bolts.Continuation
import
bolts.Task
import
chat.rocket.android.BackgroundLooper
import
chat.rocket.android.api.MethodCallHelper
...
...
@@ -13,7 +12,9 @@ import chat.rocket.core.PublicSettingsConstants
import
chat.rocket.core.models.PublicSetting
import
chat.rocket.core.repositories.LoginServiceConfigurationRepository
import
chat.rocket.core.repositories.PublicSettingRepository
import
com.hadisatrio.optional.Optional
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.rxkotlin.subscribeBy
class
LoginPresenter
(
private
val
loginServiceConfigurationRepository
:
LoginServiceConfigurationRepository
,
private
val
publicSettingRepository
:
PublicSettingRepository
,
...
...
@@ -36,9 +37,9 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
publicSettingRepository
.
getById
(
PublicSettingsConstants
.
LDAP
.
ENABLE
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
{
publicSettingOptional
->
doLogin
(
username
,
password
,
publicSettingOptional
)
},
Consumer
<
Throwable
>
{
Logger
.
report
(
it
)
}
.
subscribe
By
(
onSuccess
=
{
publicSettingOptional
->
doLogin
(
username
,
password
,
publicSettingOptional
)
},
onError
=
{
Logger
.
report
(
it
)
}
)
)
}
...
...
@@ -48,28 +49,32 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
loginServiceConfigurationRepository
.
all
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
{
loginServiceConfigurations
->
view
.
showLoginServices
(
loginServiceConfigurations
)
},
Consumer
<
Throwable
>
{
Logger
.
report
(
it
)
}
.
subscribe
By
(
onNext
=
{
loginServiceConfigurations
->
view
.
showLoginServices
(
loginServiceConfigurations
)
},
onError
=
{
Logger
.
report
(
it
)
}
)
)
}
private
fun
doLogin
(
username
:
String
,
password
:
String
,
optional
:
Optional
<
PublicSetting
>)
{
call
(
username
,
password
,
optional
)
.
continueWith
<
Any
>({
task
->
if
(
task
.
isFaulted
())
{
view
.
hideLoader
()
.
continueWith
(
object
:
Continuation
<
Void
,
Any
?>
{
override
fun
then
(
task
:
Task
<
Void
>?):
Any
?
{
if
(
task
!=
null
&&
task
.
isFaulted
())
{
view
.
hideLoader
()
val
error
=
task
.
getError
()
val
error
=
task
.
getError
()
if
(
error
is
TwoStepAuthException
)
{
view
.
showTwoStepAuth
()
}
else
{
view
.
showError
(
error
.
message
)
error
?.
let
{
if
(
error
is
TwoStepAuthException
)
{
view
.
showTwoStepAuth
()
}
else
{
view
.
showError
(
error
.
message
)
}
}
}
return
null
}
null
},
Task
.
UI_THREAD_EXECUTOR
)
}
...
...
dependencies.gradle
View file @
ada461e5
...
...
@@ -6,6 +6,7 @@ ext {
kotlinVersion
=
"1.2.0"
okHttpVersion
=
"3.9.0"
rxbindingVersion
=
'2.0.0'
rxJavaVersion
=
"2.1.0"
supportDependencies
=
[
designSupportLibrary:
"com.android.support:design:${supportLibraryVersion}"
,
...
...
@@ -19,7 +20,8 @@ ext {
extraDependencies
=
[
okHTTP
:
"com.squareup.okhttp3:okhttp:${okHttpVersion}"
,
rxJava
:
"io.reactivex.rxjava2:rxjava:2.1.0"
,
rxJava
:
"io.reactivex.rxjava2:rxjava:${rxJavaVersion}"
,
rxKotlin
:
"io.reactivex.rxjava2:rxkotlin:${rxJavaVersion}"
,
boltTask
:
"com.parse.bolts:bolts-tasks:1.4.0"
,
rxAndroid
:
"io.reactivex.rxjava2:rxandroid:2.0.1"
,
textDrawable
:
"com.github.rocketchat:textdrawable:1.0.2"
,
...
...
persistence-realm/build.gradle
View file @
ada461e5
...
...
@@ -33,6 +33,7 @@ dependencies {
api
project
(
':log-wrapper'
)
api
project
(
':rocket-chat-core'
)
implementation
extraDependencies
.
rxJava
implementation
extraDependencies
.
rxKotlin
implementation
extraDependencies
.
boltTask
implementation
supportDependencies
.
annotation
implementation
supportDependencies
.
designSupportLibrary
...
...
rocket-chat-core/build.gradle
View file @
ada461e5
...
...
@@ -4,6 +4,7 @@ apply plugin: 'java'
dependencies
{
compile
extraDependencies
.
rxJava
compile
extraDependencies
.
rxKotlin
compile
extraDependencies
.
optional
compile
"org.jetbrains.kotlin:kotlin-stdlib-jre8:$rootProject.ext.kotlinVersion"
compile
'com.google.code.findbugs:jsr305:3.0.2'
...
...
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