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
bc498fc2
Unverified
Commit
bc498fc2
authored
Dec 26, 2017
by
Leonardo Aramaki
Committed by
GitHub
Dec 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #655 from aniketsingh03/patch-4
[IMPROVEMENT] Adds error messages to login edit texts
parents
fcc9a2a5
2a281fa3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
26 deletions
+77
-26
LaunchUtil.java
app/src/main/java/chat/rocket/android/LaunchUtil.java
+25
-25
LoginContract.java
.../rocket/android/fragment/server_config/LoginContract.java
+4
-0
LoginFragment.kt
...at/rocket/android/fragment/server_config/LoginFragment.kt
+34
-0
LoginPresenter.kt
...t/rocket/android/fragment/server_config/LoginPresenter.kt
+14
-1
No files found.
app/src/main/java/chat/rocket/android/LaunchUtil.java
View file @
bc498fc2
app/src/main/java/chat/rocket/android/fragment/server_config/LoginContract.java
View file @
bc498fc2
...
...
@@ -13,6 +13,10 @@ public interface LoginContract {
void
hideLoader
();
void
showErrorInUsernameEditText
();
void
showErrorInPasswordEditText
();
void
showError
(
String
message
);
void
showLoginServices
(
List
<
LoginServiceConfiguration
>
loginServiceList
);
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginFragment.kt
View file @
bc498fc2
...
...
@@ -3,7 +3,9 @@ package chat.rocket.android.fragment.server_config
import
android.os.Bundle
import
android.support.constraint.ConstraintLayout
import
android.support.design.widget.Snackbar
import
android.support.design.widget.TextInputLayout
import
android.support.v4.app.Fragment
import
android.text.TextUtils
import
android.view.View
import
android.widget.Button
import
android.widget.TextView
...
...
@@ -14,8 +16,10 @@ 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
com.jakewharton.rxbinding2.widget.RxTextView
import
java.util.*
/**
* Login screen.
*/
...
...
@@ -26,6 +30,8 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
private
lateinit
var
waitingView
:
View
private
lateinit
var
txtUsername
:
TextView
private
lateinit
var
txtPasswd
:
TextView
private
lateinit
var
textInputUsername
:
TextInputLayout
private
lateinit
var
textInputPassword
:
TextInputLayout
override
fun
getLayout
():
Int
{
return
R
.
layout
.
fragment_login
...
...
@@ -48,6 +54,11 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
val
btnUserRegistration
=
rootView
.
findViewById
<
Button
>(
R
.
id
.
btn_user_registration
)
txtUsername
=
rootView
.
findViewById
(
R
.
id
.
editor_username
)
txtPasswd
=
rootView
.
findViewById
(
R
.
id
.
editor_passwd
)
textInputUsername
=
rootView
.
findViewById
(
R
.
id
.
text_input_username
)
textInputPassword
=
rootView
.
findViewById
(
R
.
id
.
text_input_passwd
)
setUpRxBinders
()
waitingView
=
rootView
.
findViewById
(
R
.
id
.
waiting
)
btnEmail
.
setOnClickListener
{
_
->
presenter
.
login
(
txtUsername
.
text
.
toString
(),
txtPasswd
.
text
.
toString
())
}
...
...
@@ -58,11 +69,34 @@ 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
()
{
container
.
visibility
=
View
.
GONE
waitingView
.
visibility
=
View
.
VISIBLE
}
override
fun
showErrorInUsernameEditText
()
{
textInputUsername
.
setErrorEnabled
(
true
);
textInputUsername
.
setError
(
"Enter a Username"
)
}
override
fun
showErrorInPasswordEditText
()
{
textInputPassword
.
setErrorEnabled
(
true
);
textInputPassword
.
setError
(
"Enter a Password"
)
}
override
fun
hideLoader
()
{
waitingView
.
visibility
=
View
.
GONE
container
.
visibility
=
View
.
VISIBLE
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginPresenter.kt
View file @
bc498fc2
...
...
@@ -31,6 +31,7 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
getLoginServices
()
}
override
fun
goBack
()
{
val
context
=
RocketChatApplication
.
getInstance
()
val
hostname
=
RocketChatCache
.
getSelectedServerHostname
()
...
...
@@ -43,7 +44,19 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
}
override
fun
login
(
username
:
String
,
password
:
String
)
{
if
(
TextUtils
.
isEmpty
(
username
)
||
TextUtils
.
isEmpty
(
password
))
{
//set error to edit texts
if
(
TextUtils
.
isEmpty
(
username
)
&&
TextUtils
.
isEmpty
(
password
))
{
view
.
showErrorInUsernameEditText
()
view
.
showErrorInPasswordEditText
()
return
}
if
(
TextUtils
.
isEmpty
(
username
))
{
view
.
showErrorInUsernameEditText
()
return
}
if
(
TextUtils
.
isEmpty
(
password
))
{
view
.
showErrorInPasswordEditText
()
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