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
c9399aa4
Commit
c9399aa4
authored
Dec 22, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete ProgressDialog (in favor of our custom indicator). Override functions.
parent
e041b5b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
67 deletions
+55
-67
SignupFragment.kt
...rocket/android/authentication/signup/ui/SignupFragment.kt
+31
-39
TwoFAFragment.kt
...cket/android/authentication/twofactor/ui/TwoFAFragment.kt
+24
-28
No files found.
app/src/main/java/chat/rocket/android/authentication/signup/ui/SignupFragment.kt
View file @
c9399aa4
...
@@ -11,12 +11,23 @@ import chat.rocket.android.R
...
@@ -11,12 +11,23 @@ import chat.rocket.android.R
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.authentication.signup.presentation.SignupPresenter
import
chat.rocket.android.authentication.signup.presentation.SignupPresenter
import
chat.rocket.android.authentication.signup.presentation.SignupView
import
chat.rocket.android.authentication.signup.presentation.SignupView
import
chat.rocket.android.helper.AnimationHelper
import
chat.rocket.android.util.setVisibility
import
chat.rocket.android.util.textContent
import
chat.rocket.android.util.textContent
import
dagger.android.support.AndroidSupportInjection
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.fragment_authentication_sign_up.*
import
kotlinx.android.synthetic.main.fragment_authentication_sign_up.*
import
javax.inject.Inject
import
javax.inject.Inject
class
SignupFragment
:
Fragment
(),
SignupView
{
class
SignupFragment
:
Fragment
(),
SignupView
{
@Inject
lateinit
var
presenter
:
SignupPresenter
lateinit
var
serverUrl
:
String
private
val
layoutListener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
if
(
KeyboardHelper
.
isSoftKeyboardShown
(
constraint_layout
.
rootView
))
{
text_new_user_agreement
.
visibility
=
View
.
GONE
}
else
{
text_new_user_agreement
.
visibility
=
View
.
VISIBLE
}
}
companion
object
{
companion
object
{
private
const
val
SERVER_URL
=
"server_url"
private
const
val
SERVER_URL
=
"server_url"
...
@@ -28,11 +39,6 @@ class SignupFragment : Fragment(), SignupView {
...
@@ -28,11 +39,6 @@ class SignupFragment : Fragment(), SignupView {
}
}
}
}
@Inject
lateinit
var
presenter
:
SignupPresenter
var
progress
:
ProgressDialog
?
=
null
lateinit
var
serverUrl
:
String
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
...
@@ -55,18 +61,31 @@ class SignupFragment : Fragment(), SignupView {
...
@@ -55,18 +61,31 @@ class SignupFragment : Fragment(), SignupView {
setupGlobalLayoutListener
()
setupGlobalLayoutListener
()
button_sign_up
.
setOnClickListener
{
button_sign_up
.
setOnClickListener
{
val
email
=
text_email
.
textContent
presenter
.
signup
(
text_name
,
text_email
,
text_username
,
text_password
)
val
name
=
text_name
.
textContent
val
username
=
text_username
.
textContent
val
password
=
text_password
.
textContent
presenter
.
signup
(
email
,
name
,
username
,
password
)
}
}
}
}
override
fun
onDestroyView
()
{
override
fun
onDestroyView
()
{
constraint_layout
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
layoutListener
)
super
.
onDestroyView
()
super
.
onDestroyView
()
constraint_layout
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
layoutListener
)
}
override
fun
showLoading
()
{
view_loading
.
setVisibility
(
true
)
}
override
fun
hideLoading
()
{
view_loading
.
setVisibility
(
false
)
}
override
fun
showMessage
(
message
:
String
)
{
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
shakeView
(
viewToShake
:
View
)
{
AnimationHelper
.
vibrate
(
viewToShake
.
context
)
AnimationHelper
.
shakeView
(
viewToShake
)
}
}
private
fun
tintEditTextDrawableStart
()
{
private
fun
tintEditTextDrawableStart
()
{
...
@@ -86,31 +105,4 @@ class SignupFragment : Fragment(), SignupView {
...
@@ -86,31 +105,4 @@ class SignupFragment : Fragment(), SignupView {
private
fun
setupGlobalLayoutListener
()
{
private
fun
setupGlobalLayoutListener
()
{
constraint_layout
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
layoutListener
)
constraint_layout
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
layoutListener
)
}
}
val
layoutListener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
if
(
KeyboardHelper
.
isSoftKeyboardShown
(
constraint_layout
.
rootView
))
{
text_new_user_agreement
.
visibility
=
View
.
GONE
}
else
{
text_new_user_agreement
.
visibility
=
View
.
VISIBLE
}
}
override
fun
showLoading
()
{
// TODO - change for a proper progress indicator
progress
=
ProgressDialog
.
show
(
activity
,
"Authenticating"
,
"Registering user"
,
true
,
true
)
}
override
fun
hideLoading
()
{
progress
?.
apply
{
cancel
()
}
progress
=
null
}
override
fun
onSignupError
(
message
:
String
?)
{
// TODO - show a proper error message
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_LONG
).
show
()
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/authentication/twofactor/ui/TwoFAFragment.kt
View file @
c9399aa4
package
chat.rocket.android.authentication.twofactor.ui
package
chat.rocket.android.authentication.twofactor.ui
import
DrawableHelper
import
DrawableHelper
import
android.app.ProgressDialog
import
android.os.Build
import
android.os.Build
import
android.os.Bundle
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v4.app.Fragment
...
@@ -13,12 +12,18 @@ import android.widget.Toast
...
@@ -13,12 +12,18 @@ import android.widget.Toast
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.authentication.twofactor.presentation.TwoFAPresenter
import
chat.rocket.android.authentication.twofactor.presentation.TwoFAPresenter
import
chat.rocket.android.authentication.twofactor.presentation.TwoFAView
import
chat.rocket.android.authentication.twofactor.presentation.TwoFAView
import
chat.rocket.android.helper.AnimationHelper
import
chat.rocket.android.util.setVisibility
import
chat.rocket.android.util.textContent
import
chat.rocket.android.util.textContent
import
dagger.android.support.AndroidSupportInjection
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.fragment_authentication_two_fa.*
import
kotlinx.android.synthetic.main.fragment_authentication_two_fa.*
import
javax.inject.Inject
import
javax.inject.Inject
class
TwoFAFragment
:
Fragment
(),
TwoFAView
{
class
TwoFAFragment
:
Fragment
(),
TwoFAView
{
@Inject
lateinit
var
presenter
:
TwoFAPresenter
lateinit
var
serverUrl
:
String
lateinit
var
username
:
String
lateinit
var
password
:
String
companion
object
{
companion
object
{
private
const
val
SERVER_URL
=
"server_url"
private
const
val
SERVER_URL
=
"server_url"
...
@@ -34,14 +39,6 @@ class TwoFAFragment : Fragment(), TwoFAView {
...
@@ -34,14 +39,6 @@ class TwoFAFragment : Fragment(), TwoFAView {
}
}
}
}
var
progress
:
ProgressDialog
?
=
null
lateinit
var
serverUrl
:
String
lateinit
var
username
:
String
lateinit
var
password
:
String
@Inject
lateinit
var
presenter
:
TwoFAPresenter
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
...
@@ -64,10 +61,27 @@ class TwoFAFragment : Fragment(), TwoFAView {
...
@@ -64,10 +61,27 @@ class TwoFAFragment : Fragment(), TwoFAView {
}
}
button_log_in
.
setOnClickListener
{
button_log_in
.
setOnClickListener
{
presenter
.
authenticate
(
username
,
password
,
text_two_factor_auth
.
textContent
)
presenter
.
authenticate
(
username
,
password
,
text_two_factor_auth
)
}
}
}
}
override
fun
showLoading
()
{
view_loading
.
setVisibility
(
true
)
}
override
fun
hideLoading
()
{
view_loading
.
setVisibility
(
false
)
}
override
fun
showMessage
(
message
:
String
)
{
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
shakeView
(
viewToShake
:
View
)
{
AnimationHelper
.
vibrate
(
viewToShake
.
context
)
AnimationHelper
.
shakeView
(
viewToShake
)
}
private
fun
tintEditTextDrawableStart
()
{
private
fun
tintEditTextDrawableStart
()
{
activity
?.
applicationContext
?.
apply
{
activity
?.
applicationContext
?.
apply
{
val
lockDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_vpn_key_black_24dp
,
this
)
val
lockDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_vpn_key_black_24dp
,
this
)
...
@@ -77,22 +91,4 @@ class TwoFAFragment : Fragment(), TwoFAView {
...
@@ -77,22 +91,4 @@ class TwoFAFragment : Fragment(), TwoFAView {
DrawableHelper
.
compoundDrawable
(
text_two_factor_auth
,
lockDrawable
)
DrawableHelper
.
compoundDrawable
(
text_two_factor_auth
,
lockDrawable
)
}
}
}
}
override
fun
showLoading
()
{
// TODO - change for a proper progress indicator
progress
=
ProgressDialog
.
show
(
activity
,
"Authenticating"
,
"Verifying user credentials"
,
true
,
true
)
}
override
fun
hideLoading
()
{
progress
?.
apply
{
cancel
()
}
progress
=
null
}
override
fun
showMessage
(
message
:
String
)
{
// TODO - show a proper error message
Toast
.
makeText
(
activity
,
message
,
Toast
.
LENGTH_LONG
).
show
()
}
}
}
\ 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