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
3a1d532d
Commit
3a1d532d
authored
Dec 27, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inject app context and add listener
parent
25d27da0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
23 deletions
+55
-23
SignupFragment.kt
...rocket/android/authentication/signup/ui/SignupFragment.kt
+55
-23
No files found.
app/src/main/java/chat/rocket/android/authentication/signup/ui/SignupFragment.kt
View file @
3a1d532d
package
chat.rocket.android.authentication.signup.ui
import
DrawableHelper
import
android.
app.ProgressDialog
import
android.
content.Context
import
android.os.Build
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.text.style.ClickableSpan
import
android.view.*
import
android.widget.Toast
import
chat.rocket.android.R
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.authentication.signup.presentation.SignupPresenter
import
chat.rocket.android.authentication.signup.presentation.SignupView
import
chat.rocket.android.helper.AnimationHelper
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.helper.TextHelper
import
chat.rocket.android.util.setVisibility
import
chat.rocket.android.util.textContent
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.fragment_authentication_sign_up.*
import
javax.inject.Inject
class
SignupFragment
:
Fragment
(),
SignupView
{
@Inject
lateinit
var
presenter
:
SignupPresenter
lateinit
var
serverUrl
:
String
@Inject
lateinit
var
appContext
:
Context
private
val
layoutListener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
if
(
KeyboardHelper
.
isSoftKeyboardShown
(
constraint_layout
.
rootView
))
{
text_new_user_agreement
.
visibility
=
View
.
GONE
text_new_user_agreement
.
setVisibility
(
false
)
}
else
{
text_new_user_agreement
.
visibility
=
View
.
VISIBLE
text_new_user_agreement
.
setVisibility
(
true
)
}
}
// TODO delete
lateinit
var
serverUrl
:
String
companion
object
{
private
const
val
SERVER_URL
=
"server_url"
...
...
@@ -58,7 +63,9 @@ class SignupFragment : Fragment(), SignupView {
tintEditTextDrawableStart
()
}
setupGlobalLayoutListener
()
constraint_layout
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
layoutListener
)
setUpNewUserAgreementListener
()
button_sign_up
.
setOnClickListener
{
presenter
.
signup
(
text_name
,
text_username
,
text_password
,
text_email
)
...
...
@@ -70,13 +77,14 @@ class SignupFragment : Fragment(), SignupView {
constraint_layout
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
layoutListener
)
}
override
fun
showLoading
()
{
view_loading
.
setVisibility
(
true
)
enableUserInput
(
false
)
view_loading
.
show
()
}
override
fun
hideLoading
()
{
view_loading
.
setVisibility
(
false
)
view_loading
.
hide
()
enableUserInput
(
true
)
}
override
fun
showMessage
(
message
:
String
)
{
...
...
@@ -84,26 +92,50 @@ class SignupFragment : Fragment(), SignupView {
}
override
fun
shakeView
(
viewToShake
:
View
)
{
AnimationHelper
.
vibrate
(
viewToShake
.
c
ontext
)
AnimationHelper
.
vibrate
SmartPhone
(
appC
ontext
)
AnimationHelper
.
shakeView
(
viewToShake
)
viewToShake
.
requestFocus
()
}
private
fun
tintEditTextDrawableStart
()
{
activity
?.
applicationContext
?.
apply
{
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_person_black_24dp
,
this
)
val
atDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_at_black_24dp
,
this
)
val
lockDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_lock_black_24dp
,
this
)
val
emailDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_email_black_24dp
,
this
)
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_person_black_24dp
,
appContext
)
val
atDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_at_black_24dp
,
appContext
)
val
lockDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_lock_black_24dp
,
appContext
)
val
emailDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_email_black_24dp
,
appContext
)
val
drawables
=
arrayOf
(
personDrawable
,
atDrawable
,
lockDrawable
,
emailDrawable
)
DrawableHelper
.
wrapDrawables
(
drawables
)
DrawableHelper
.
tintDrawables
(
drawables
,
this
,
R
.
color
.
colorDrawableTintGrey
)
DrawableHelper
.
tintDrawables
(
drawables
,
appContext
,
R
.
color
.
colorDrawableTintGrey
)
DrawableHelper
.
compoundDrawables
(
arrayOf
(
text_name
,
text_username
,
text_password
,
text_email
),
drawables
)
}
private
fun
setUpNewUserAgreementListener
()
{
val
termsOfService
=
getString
(
R
.
string
.
action_terms_of_service
)
val
privacyPolicy
=
getString
(
R
.
string
.
action_privacy_policy
)
val
newUserAgreement
=
String
.
format
(
getString
(
R
.
string
.
msg_new_user_agreement
),
termsOfService
,
privacyPolicy
)
text_new_user_agreement
.
text
=
newUserAgreement
val
termsOfServiceListener
=
object
:
ClickableSpan
()
{
override
fun
onClick
(
view
:
View
)
{
presenter
.
termsOfService
()
}
}
private
fun
setupGlobalLayoutListener
()
{
constraint_layout
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
layoutListener
)
val
privacyPolicyListener
=
object
:
ClickableSpan
()
{
override
fun
onClick
(
view
:
View
)
{
presenter
.
privacyPolicy
()
}
}
TextHelper
.
addLink
(
text_new_user_agreement
,
arrayOf
(
termsOfService
,
privacyPolicy
),
arrayOf
(
termsOfServiceListener
,
privacyPolicyListener
))
}
private
fun
enableUserInput
(
value
:
Boolean
)
{
button_sign_up
.
isEnabled
=
value
text_name
.
isEnabled
=
value
text_username
.
isEnabled
=
value
text_password
.
isEnabled
=
value
text_email
.
isEnabled
=
value
}
}
\ No newline at end of file
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