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
124340a7
Commit
124340a7
authored
Dec 24, 2017
by
Aniket
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implements rxbinders in edit text textwatchers
parent
79a1e5d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
60 deletions
+45
-60
LaunchUtil.java
app/src/main/java/chat/rocket/android/LaunchUtil.java
+25
-25
LoginFragment.kt
...at/rocket/android/fragment/server_config/LoginFragment.kt
+18
-32
LoginPresenter.kt
...t/rocket/android/fragment/server_config/LoginPresenter.kt
+2
-3
No files found.
app/src/main/java/chat/rocket/android/LaunchUtil.java
View file @
124340a7
...
@@ -12,31 +12,31 @@ import chat.rocket.android.activity.MainActivity;
...
@@ -12,31 +12,31 @@ import chat.rocket.android.activity.MainActivity;
*/
*/
public
class
LaunchUtil
{
public
class
LaunchUtil
{
/**
/**
* launch MainActivity with proper flags.
* launch MainActivity with proper flags.
*/
*/
public
static
void
showMainActivity
(
Context
context
)
{
public
static
void
showMainActivity
(
Context
context
)
{
Intent
intent
=
new
Intent
(
context
,
MainActivity
.
class
);
Intent
intent
=
new
Intent
(
context
,
MainActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
/**
/**
* launch AddServerActivity with proper flags.
* launch AddServerActivity with proper flags.
*/
*/
public
static
void
showAddServerActivity
(
Context
context
)
{
public
static
void
showAddServerActivity
(
Context
context
)
{
Intent
intent
=
new
Intent
(
context
,
AddServerActivity
.
class
);
Intent
intent
=
new
Intent
(
context
,
AddServerActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
/**
/**
* launch ServerConfigActivity with proper flags.
* launch ServerConfigActivity with proper flags.
*/
*/
public
static
void
showLoginActivity
(
Context
context
,
String
hostname
)
{
public
static
void
showLoginActivity
(
Context
context
,
String
hostname
)
{
Intent
intent
=
new
Intent
(
context
,
LoginActivity
.
class
);
Intent
intent
=
new
Intent
(
context
,
LoginActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
intent
.
putExtra
(
LoginActivity
.
KEY_HOSTNAME
,
hostname
);
intent
.
putExtra
(
LoginActivity
.
KEY_HOSTNAME
,
hostname
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
}
}
app/src/main/java/chat/rocket/android/fragment/server_config/LoginFragment.kt
View file @
124340a7
...
@@ -5,9 +5,7 @@ import android.support.constraint.ConstraintLayout
...
@@ -5,9 +5,7 @@ import android.support.constraint.ConstraintLayout
import
android.support.design.widget.Snackbar
import
android.support.design.widget.Snackbar
import
android.support.design.widget.TextInputLayout
import
android.support.design.widget.TextInputLayout
import
android.support.v4.app.Fragment
import
android.support.v4.app.Fragment
import
android.text.Editable
import
android.text.TextUtils
import
android.text.TextUtils
import
android.text.TextWatcher
import
android.view.View
import
android.view.View
import
android.widget.Button
import
android.widget.Button
import
android.widget.TextView
import
android.widget.TextView
...
@@ -18,8 +16,10 @@ import chat.rocket.android.log.RCLog
...
@@ -18,8 +16,10 @@ import chat.rocket.android.log.RCLog
import
chat.rocket.core.models.LoginServiceConfiguration
import
chat.rocket.core.models.LoginServiceConfiguration
import
chat.rocket.persistence.realm.repositories.RealmLoginServiceConfigurationRepository
import
chat.rocket.persistence.realm.repositories.RealmLoginServiceConfigurationRepository
import
chat.rocket.persistence.realm.repositories.RealmPublicSettingRepository
import
chat.rocket.persistence.realm.repositories.RealmPublicSettingRepository
import
com.jakewharton.rxbinding2.widget.RxTextView
import
java.util.*
import
java.util.*
/**
/**
* Login screen.
* Login screen.
*/
*/
...
@@ -57,35 +57,8 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
...
@@ -57,35 +57,8 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
textInputUsername
=
rootView
.
findViewById
(
R
.
id
.
text_input_username
)
textInputUsername
=
rootView
.
findViewById
(
R
.
id
.
text_input_username
)
textInputPassword
=
rootView
.
findViewById
(
R
.
id
.
text_input_passwd
)
textInputPassword
=
rootView
.
findViewById
(
R
.
id
.
text_input_passwd
)
//setting text change listeners to username and password edit texts
setUpRxBinders
()
txtUsername
.
addTextChangedListener
(
object
:
TextWatcher
{
override
fun
afterTextChanged
(
p0
:
Editable
?)
{
}
override
fun
beforeTextChanged
(
p0
:
CharSequence
?,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
}
override
fun
onTextChanged
(
p0
:
CharSequence
?,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
if
(!
TextUtils
.
isEmpty
(
txtUsername
.
text
.
toString
())
&&
textInputUsername
.
isErrorEnabled
)
textInputUsername
.
setErrorEnabled
(
false
)
}
})
txtPasswd
.
addTextChangedListener
(
object
:
TextWatcher
{
override
fun
afterTextChanged
(
p0
:
Editable
?)
{
}
override
fun
beforeTextChanged
(
p0
:
CharSequence
?,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
}
override
fun
onTextChanged
(
p0
:
CharSequence
?,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
if
(!
TextUtils
.
isEmpty
(
txtPasswd
.
text
.
toString
())
&&
textInputPassword
.
isErrorEnabled
)
textInputPassword
.
setErrorEnabled
(
false
)
}
})
waitingView
=
rootView
.
findViewById
(
R
.
id
.
waiting
)
waitingView
=
rootView
.
findViewById
(
R
.
id
.
waiting
)
btnEmail
.
setOnClickListener
{
_
->
presenter
.
login
(
txtUsername
.
text
.
toString
(),
txtPasswd
.
text
.
toString
())
}
btnEmail
.
setOnClickListener
{
_
->
presenter
.
login
(
txtUsername
.
text
.
toString
(),
txtPasswd
.
text
.
toString
())
}
...
@@ -96,17 +69,30 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
...
@@ -96,17 +69,30 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
}
}
}
}
fun
setUpRxBinders
()
{
RxTextView
.
textChanges
(
txtUsername
).
subscribe
{
text
->
if
(!
TextUtils
.
isEmpty
(
text
)
&&
textInputUsername
.
isErrorEnabled
)
textInputUsername
.
setErrorEnabled
(
false
)
}
RxTextView
.
textChanges
(
txtPasswd
).
subscribe
{
text
->
if
(!
TextUtils
.
isEmpty
(
text
)
&&
textInputPassword
.
isErrorEnabled
)
textInputPassword
.
setErrorEnabled
(
false
)
}
}
override
fun
showLoader
()
{
override
fun
showLoader
()
{
container
.
visibility
=
View
.
GONE
container
.
visibility
=
View
.
GONE
waitingView
.
visibility
=
View
.
VISIBLE
waitingView
.
visibility
=
View
.
VISIBLE
}
}
override
fun
showErrorInUsernameEditText
(){
override
fun
showErrorInUsernameEditText
()
{
textInputUsername
.
setErrorEnabled
(
true
);
textInputUsername
.
setErrorEnabled
(
true
);
textInputUsername
.
setError
(
"Enter a Username"
)
textInputUsername
.
setError
(
"Enter a Username"
)
}
}
override
fun
showErrorInPasswordEditText
(){
override
fun
showErrorInPasswordEditText
()
{
textInputPassword
.
setErrorEnabled
(
true
);
textInputPassword
.
setErrorEnabled
(
true
);
textInputPassword
.
setError
(
"Enter a Password"
)
textInputPassword
.
setError
(
"Enter a Password"
)
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginPresenter.kt
View file @
124340a7
...
@@ -32,7 +32,6 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
...
@@ -32,7 +32,6 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
}
}
override
fun
goBack
()
{
override
fun
goBack
()
{
val
context
=
RocketChatApplication
.
getInstance
()
val
context
=
RocketChatApplication
.
getInstance
()
val
hostname
=
RocketChatCache
.
getSelectedServerHostname
()
val
hostname
=
RocketChatCache
.
getSelectedServerHostname
()
...
@@ -47,7 +46,7 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
...
@@ -47,7 +46,7 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
override
fun
login
(
username
:
String
,
password
:
String
)
{
override
fun
login
(
username
:
String
,
password
:
String
)
{
//set error to edit texts
//set error to edit texts
if
(
TextUtils
.
isEmpty
(
username
)
&&
TextUtils
.
isEmpty
(
password
))
{
if
(
TextUtils
.
isEmpty
(
username
)
&&
TextUtils
.
isEmpty
(
password
))
{
view
.
showErrorInUsernameEditText
()
view
.
showErrorInUsernameEditText
()
view
.
showErrorInPasswordEditText
()
view
.
showErrorInPasswordEditText
()
return
return
...
@@ -56,7 +55,7 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
...
@@ -56,7 +55,7 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
view
.
showErrorInUsernameEditText
()
view
.
showErrorInUsernameEditText
()
return
return
}
}
if
(
TextUtils
.
isEmpty
(
password
)){
if
(
TextUtils
.
isEmpty
(
password
))
{
view
.
showErrorInPasswordEditText
()
view
.
showErrorInPasswordEditText
()
return
return
}
}
...
...
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