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
79a1e5d8
Commit
79a1e5d8
authored
Dec 23, 2017
by
Aniket
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds error texts to login edit texts
parent
6f80a3c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
1 deletion
+67
-1
LoginContract.java
.../rocket/android/fragment/server_config/LoginContract.java
+4
-0
LoginFragment.kt
...at/rocket/android/fragment/server_config/LoginFragment.kt
+48
-0
LoginPresenter.kt
...t/rocket/android/fragment/server_config/LoginPresenter.kt
+15
-1
No files found.
app/src/main/java/chat/rocket/android/fragment/server_config/LoginContract.java
View file @
79a1e5d8
...
@@ -13,6 +13,10 @@ public interface LoginContract {
...
@@ -13,6 +13,10 @@ public interface LoginContract {
void
hideLoader
();
void
hideLoader
();
void
showErrorInUsernameEditText
();
void
showErrorInPasswordEditText
();
void
showError
(
String
message
);
void
showError
(
String
message
);
void
showLoginServices
(
List
<
LoginServiceConfiguration
>
loginServiceList
);
void
showLoginServices
(
List
<
LoginServiceConfiguration
>
loginServiceList
);
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginFragment.kt
View file @
79a1e5d8
...
@@ -3,7 +3,11 @@ package chat.rocket.android.fragment.server_config
...
@@ -3,7 +3,11 @@ package chat.rocket.android.fragment.server_config
import
android.os.Bundle
import
android.os.Bundle
import
android.support.constraint.ConstraintLayout
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.v4.app.Fragment
import
android.support.v4.app.Fragment
import
android.text.Editable
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
...
@@ -26,6 +30,8 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
...
@@ -26,6 +30,8 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
private
lateinit
var
waitingView
:
View
private
lateinit
var
waitingView
:
View
private
lateinit
var
txtUsername
:
TextView
private
lateinit
var
txtUsername
:
TextView
private
lateinit
var
txtPasswd
:
TextView
private
lateinit
var
txtPasswd
:
TextView
private
lateinit
var
textInputUsername
:
TextInputLayout
private
lateinit
var
textInputPassword
:
TextInputLayout
override
fun
getLayout
():
Int
{
override
fun
getLayout
():
Int
{
return
R
.
layout
.
fragment_login
return
R
.
layout
.
fragment_login
...
@@ -48,6 +54,38 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
...
@@ -48,6 +54,38 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
val
btnUserRegistration
=
rootView
.
findViewById
<
Button
>(
R
.
id
.
btn_user_registration
)
val
btnUserRegistration
=
rootView
.
findViewById
<
Button
>(
R
.
id
.
btn_user_registration
)
txtUsername
=
rootView
.
findViewById
(
R
.
id
.
editor_username
)
txtUsername
=
rootView
.
findViewById
(
R
.
id
.
editor_username
)
txtPasswd
=
rootView
.
findViewById
(
R
.
id
.
editor_passwd
)
txtPasswd
=
rootView
.
findViewById
(
R
.
id
.
editor_passwd
)
textInputUsername
=
rootView
.
findViewById
(
R
.
id
.
text_input_username
)
textInputPassword
=
rootView
.
findViewById
(
R
.
id
.
text_input_passwd
)
//setting text change listeners to username and password edit texts
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
())
}
...
@@ -63,6 +101,16 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
...
@@ -63,6 +101,16 @@ class LoginFragment : AbstractServerConfigFragment(), LoginContract.View {
waitingView
.
visibility
=
View
.
VISIBLE
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
()
{
override
fun
hideLoader
()
{
waitingView
.
visibility
=
View
.
GONE
waitingView
.
visibility
=
View
.
GONE
container
.
visibility
=
View
.
VISIBLE
container
.
visibility
=
View
.
VISIBLE
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginPresenter.kt
View file @
79a1e5d8
...
@@ -31,6 +31,8 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
...
@@ -31,6 +31,8 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
getLoginServices
()
getLoginServices
()
}
}
override
fun
goBack
()
{
override
fun
goBack
()
{
val
context
=
RocketChatApplication
.
getInstance
()
val
context
=
RocketChatApplication
.
getInstance
()
val
hostname
=
RocketChatCache
.
getSelectedServerHostname
()
val
hostname
=
RocketChatCache
.
getSelectedServerHostname
()
...
@@ -43,7 +45,19 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
...
@@ -43,7 +45,19 @@ class LoginPresenter(private val loginServiceConfigurationRepository: LoginServi
}
}
override
fun
login
(
username
:
String
,
password
:
String
)
{
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
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