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
b3fe7461
Commit
b3fe7461
authored
Dec 27, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix merge conflict.
parent
d054236a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
22 deletions
+70
-22
AuthenticationNavigator.kt
...id/authentication/presentation/AuthenticationNavigator.kt
+15
-1
SignupFragment.kt
...rocket/android/authentication/signup/ui/SignupFragment.kt
+55
-21
No files found.
app/src/main/java/chat/rocket/android/authentication/presentation/AuthenticationNavigator.kt
View file @
b3fe7461
package
chat.rocket.android.authentication.presentation
import
android.content.Context
import
android.content.Intent
import
chat.rocket.android.R
import
chat.rocket.android.chatrooms.ui.MainActivity
import
chat.rocket.android.authentication.ui.AuthenticationActivity
import
chat.rocket.android.app.MainActivity
import
chat.rocket.android.authentication.login.ui.LoginFragment
import
chat.rocket.android.authentication.signup.ui.SignupFragment
import
chat.rocket.android.authentication.twofactor.ui.TwoFAFragment
import
chat.rocket.android.authentication.ui.AuthenticationActivity
import
chat.rocket.android.util.addFragmentBackStack
import
chat.rocket.android.webview.webViewIntent
class
AuthenticationNavigator
(
internal
val
activity
:
AuthenticationActivity
)
{
class
AuthenticationNavigator
(
internal
val
activity
:
AuthenticationActivity
,
internal
val
context
:
Context
)
{
var
currentServer
:
String
?
=
null
fun
toLogin
(
server
:
String
)
{
...
...
@@ -33,6 +37,16 @@ class AuthenticationNavigator(internal val activity: AuthenticationActivity) {
}
}
fun
toTermsOfService
()
{
val
webPageUrl
=
currentServer
+
"/terms-of-service"
activity
.
startActivity
(
context
.
webViewIntent
(
webPageUrl
))
}
fun
toPrivacyPolicy
()
{
val
webPageUrl
=
currentServer
+
"/privacy-policy"
activity
.
startActivity
(
context
.
webViewIntent
(
webPageUrl
))
}
fun
toChatList
()
{
val
chatList
=
Intent
(
activity
,
MainActivity
::
class
.
java
).
apply
{
//TODO any parameter to pass
...
...
app/src/main/java/chat/rocket/android/authentication/signup/ui/SignupFragment.kt
View file @
b3fe7461
package
chat.rocket.android.authentication.signup.ui
import
DrawableHelper
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
...
...
@@ -11,6 +13,7 @@ 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
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.fragment_authentication_sign_up.*
...
...
@@ -18,15 +21,19 @@ 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"
...
...
@@ -56,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
)
...
...
@@ -68,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
)
{
...
...
@@ -82,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
drawables
=
arrayOf
(
personDrawable
,
atDrawable
,
lockDrawable
,
emailDrawable
)
DrawableHelper
.
wrapDrawables
(
drawables
)
DrawableHelper
.
tintDrawables
(
drawables
,
this
,
R
.
color
.
colorDrawableTintGrey
)
DrawableHelper
.
compoundDrawables
(
arrayOf
(
text_name
,
text_username
,
text_password
,
text_email
),
drawables
)
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
,
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
()
}
}
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
setupGlobalLayoutListener
()
{
constraint_layout
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
layoutListener
)
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