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
c862cb9d
Commit
c862cb9d
authored
Apr 26, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the show more social account icon not showing,
Plus fix file indentation.
parent
9f49e746
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
43 deletions
+77
-43
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+76
-43
Ui.kt
app/src/main/java/chat/rocket/android/util/extensions/Ui.kt
+1
-0
No files found.
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
c862cb9d
...
@@ -2,7 +2,6 @@ package chat.rocket.android.authentication.login.ui
...
@@ -2,7 +2,6 @@ package chat.rocket.android.authentication.login.ui
import
DrawableHelper
import
DrawableHelper
import
android.app.Activity
import
android.app.Activity
import
android.app.AlertDialog
import
android.content.Intent
import
android.content.Intent
import
android.os.Build
import
android.os.Build
import
android.os.Bundle
import
android.os.Bundle
...
@@ -14,8 +13,8 @@ import android.view.ViewGroup
...
@@ -14,8 +13,8 @@ import android.view.ViewGroup
import
android.view.ViewTreeObserver
import
android.view.ViewTreeObserver
import
android.widget.ImageButton
import
android.widget.ImageButton
import
android.widget.ScrollView
import
android.widget.ScrollView
import
androidx.core.view.isVisible
import
androidx.core.view.postDelayed
import
androidx.core.view.postDelayed
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.authentication.domain.model.LoginDeepLinkInfo
import
chat.rocket.android.authentication.domain.model.LoginDeepLinkInfo
import
chat.rocket.android.authentication.login.presentation.LoginPresenter
import
chat.rocket.android.authentication.login.presentation.LoginPresenter
...
@@ -37,7 +36,8 @@ internal const val REQUEST_CODE_FOR_CAS = 1
...
@@ -37,7 +36,8 @@ internal const val REQUEST_CODE_FOR_CAS = 1
internal
const
val
REQUEST_CODE_FOR_OAUTH
=
2
internal
const
val
REQUEST_CODE_FOR_OAUTH
=
2
class
LoginFragment
:
Fragment
(),
LoginView
{
class
LoginFragment
:
Fragment
(),
LoginView
{
@Inject
lateinit
var
presenter
:
LoginPresenter
@Inject
lateinit
var
presenter
:
LoginPresenter
private
var
isOauthViewEnable
=
false
private
var
isOauthViewEnable
=
false
private
val
layoutListener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
private
val
layoutListener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
areLoginOptionsNeeded
()
areLoginOptionsNeeded
()
...
@@ -61,7 +61,11 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -61,7 +61,11 @@ class LoginFragment : Fragment(), LoginView {
deepLinkInfo
=
arguments
?.
getParcelable
(
DEEP_LINK_INFO
)
deepLinkInfo
=
arguments
?.
getParcelable
(
DEEP_LINK_INFO
)
}
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?
):
View
?
=
container
?.
inflate
(
R
.
layout
.
fragment_authentication_log_in
)
container
?.
inflate
(
R
.
layout
.
fragment_authentication_log_in
)
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
...
@@ -94,7 +98,10 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -94,7 +98,10 @@ class LoginFragment : Fragment(), LoginView {
}
}
}
else
if
(
requestCode
==
REQUEST_CODE_FOR_OAUTH
)
{
}
else
if
(
requestCode
==
REQUEST_CODE_FOR_OAUTH
)
{
data
?.
apply
{
data
?.
apply
{
presenter
.
authenticateWithOauth
(
getStringExtra
(
INTENT_OAUTH_CREDENTIAL_TOKEN
),
getStringExtra
(
INTENT_OAUTH_CREDENTIAL_SECRET
))
presenter
.
authenticateWithOauth
(
getStringExtra
(
INTENT_OAUTH_CREDENTIAL_TOKEN
),
getStringExtra
(
INTENT_OAUTH_CREDENTIAL_SECRET
)
)
}
}
}
}
}
}
...
@@ -102,25 +109,29 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -102,25 +109,29 @@ class LoginFragment : Fragment(), LoginView {
private
fun
tintEditTextDrawableStart
()
{
private
fun
tintEditTextDrawableStart
()
{
ui
{
ui
{
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_assignment_ind_black_24dp
,
it
)
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_assignment_ind_black_24dp
,
it
)
val
lockDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_lock_black_24dp
,
it
)
val
lockDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_lock_black_24dp
,
it
)
val
drawables
=
arrayOf
(
personDrawable
,
lockDrawable
)
val
drawables
=
arrayOf
(
personDrawable
,
lockDrawable
)
DrawableHelper
.
wrapDrawables
(
drawables
)
DrawableHelper
.
wrapDrawables
(
drawables
)
DrawableHelper
.
tintDrawables
(
drawables
,
it
,
R
.
color
.
colorDrawableTintGrey
)
DrawableHelper
.
tintDrawables
(
drawables
,
it
,
R
.
color
.
colorDrawableTintGrey
)
DrawableHelper
.
compoundDrawables
(
arrayOf
(
text_username_or_email
,
text_password
),
drawables
)
DrawableHelper
.
compoundDrawables
(
arrayOf
(
text_username_or_email
,
text_password
),
drawables
)
}
}
}
}
override
fun
showLoading
()
{
override
fun
showLoading
()
{
ui
{
ui
{
view_loading
.
setVisible
(
true
)
view_loading
.
isVisible
=
true
}
}
}
}
override
fun
hideLoading
()
{
override
fun
hideLoading
()
{
ui
{
ui
{
view_loading
.
setVisible
(
false
)
view_loading
.
isVisible
=
false
}
}
}
}
...
@@ -142,23 +153,25 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -142,23 +153,25 @@ class LoginFragment : Fragment(), LoginView {
override
fun
showFormView
()
{
override
fun
showFormView
()
{
ui
{
ui
{
text_username_or_email
.
setVisible
(
true
)
text_username_or_email
.
isVisible
=
true
text_password
.
setVisible
(
true
)
text_password
.
isVisible
=
true
}
}
}
}
override
fun
hideFormView
()
{
override
fun
hideFormView
()
{
ui
{
ui
{
text_username_or_email
.
setVisible
(
false
)
text_username_or_email
.
isVisible
=
false
text_password
.
setVisible
(
false
)
text_password
.
isVisible
=
false
}
}
}
}
override
fun
setupLoginButtonListener
()
{
override
fun
setupLoginButtonListener
()
{
ui
{
ui
{
button_log_in
.
setOnClickListener
{
button_log_in
.
setOnClickListener
{
presenter
.
authenticateWithUserAndPassword
(
text_username_or_email
.
textContent
,
presenter
.
authenticateWithUserAndPassword
(
text_password
.
textContent
)
text_username_or_email
.
textContent
,
text_password
.
textContent
)
}
}
}
}
}
}
...
@@ -181,21 +194,23 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -181,21 +194,23 @@ class LoginFragment : Fragment(), LoginView {
override
fun
showCasButton
()
{
override
fun
showCasButton
()
{
ui
{
ui
{
button_cas
.
setVisible
(
true
)
button_cas
.
isVisible
=
true
}
}
}
}
override
fun
hideCasButton
()
{
override
fun
hideCasButton
()
{
ui
{
ui
{
button_cas
.
setVisible
(
false
)
button_cas
.
isVisible
=
false
}
}
}
}
override
fun
setupCasButtonListener
(
casUrl
:
String
,
casToken
:
String
)
{
override
fun
setupCasButtonListener
(
casUrl
:
String
,
casToken
:
String
)
{
ui
{
activity
->
ui
{
activity
->
button_cas
.
setOnClickListener
{
button_cas
.
setOnClickListener
{
startActivityForResult
(
activity
.
casWebViewIntent
(
casUrl
,
casToken
),
startActivityForResult
(
REQUEST_CODE_FOR_CAS
)
activity
.
casWebViewIntent
(
casUrl
,
casToken
),
REQUEST_CODE_FOR_CAS
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
}
}
}
}
...
@@ -203,7 +218,7 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -203,7 +218,7 @@ class LoginFragment : Fragment(), LoginView {
override
fun
showSignUpView
()
{
override
fun
showSignUpView
()
{
ui
{
ui
{
text_new_to_rocket_chat
.
setVisible
(
true
)
text_new_to_rocket_chat
.
isVisible
=
true
}
}
}
}
...
@@ -224,7 +239,7 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -224,7 +239,7 @@ class LoginFragment : Fragment(), LoginView {
override
fun
hideSignUpView
()
{
override
fun
hideSignUpView
()
{
ui
{
ui
{
text_new_to_rocket_chat
.
setVisible
(
false
)
text_new_to_rocket_chat
.
isVisible
=
false
}
}
}
}
...
@@ -232,26 +247,26 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -232,26 +247,26 @@ class LoginFragment : Fragment(), LoginView {
ui
{
ui
{
isOauthViewEnable
=
true
isOauthViewEnable
=
true
showThreeSocialAccountsMethods
()
showThreeSocialAccountsMethods
()
social_accounts_container
.
setVisible
(
true
)
social_accounts_container
.
isVisible
=
true
}
}
}
}
override
fun
disableOauthView
()
{
override
fun
disableOauthView
()
{
ui
{
ui
{
isOauthViewEnable
=
false
isOauthViewEnable
=
false
social_accounts_container
.
setVisible
(
false
)
social_accounts_container
.
isVisible
=
false
}
}
}
}
override
fun
showLoginButton
()
{
override
fun
showLoginButton
()
{
ui
{
ui
{
button_log_in
.
setVisible
(
true
)
button_log_in
.
isVisible
=
true
}
}
}
}
override
fun
hideLoginButton
()
{
override
fun
hideLoginButton
()
{
ui
{
ui
{
button_log_in
.
setVisible
(
false
)
button_log_in
.
isVisible
=
false
}
}
}
}
...
@@ -264,7 +279,10 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -264,7 +279,10 @@ class LoginFragment : Fragment(), LoginView {
override
fun
setupFacebookButtonListener
(
facebookOauthUrl
:
String
,
state
:
String
)
{
override
fun
setupFacebookButtonListener
(
facebookOauthUrl
:
String
,
state
:
String
)
{
ui
{
activity
->
ui
{
activity
->
button_facebook
.
setOnClickListener
{
button_facebook
.
setOnClickListener
{
startActivityForResult
(
activity
.
oauthWebViewIntent
(
facebookOauthUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
startActivityForResult
(
activity
.
oauthWebViewIntent
(
facebookOauthUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
}
}
}
}
...
@@ -279,7 +297,10 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -279,7 +297,10 @@ class LoginFragment : Fragment(), LoginView {
override
fun
setupGithubButtonListener
(
githubUrl
:
String
,
state
:
String
)
{
override
fun
setupGithubButtonListener
(
githubUrl
:
String
,
state
:
String
)
{
ui
{
activity
->
ui
{
activity
->
button_github
.
setOnClickListener
{
button_github
.
setOnClickListener
{
startActivityForResult
(
activity
.
oauthWebViewIntent
(
githubUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
startActivityForResult
(
activity
.
oauthWebViewIntent
(
githubUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
}
}
}
}
...
@@ -291,11 +312,15 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -291,11 +312,15 @@ class LoginFragment : Fragment(), LoginView {
}
}
}
}
// TODO: Use custom tabs instead of web view. See https://github.com/RocketChat/Rocket.Chat.Android/issues/968
// TODO: Use custom tabs instead of web view.
// See https://github.com/RocketChat/Rocket.Chat.Android/issues/968
override
fun
setupGoogleButtonListener
(
googleUrl
:
String
,
state
:
String
)
{
override
fun
setupGoogleButtonListener
(
googleUrl
:
String
,
state
:
String
)
{
ui
{
activity
->
ui
{
activity
->
button_google
.
setOnClickListener
{
button_google
.
setOnClickListener
{
startActivityForResult
(
activity
.
oauthWebViewIntent
(
googleUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
startActivityForResult
(
activity
.
oauthWebViewIntent
(
googleUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
}
}
}
}
...
@@ -310,7 +335,10 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -310,7 +335,10 @@ class LoginFragment : Fragment(), LoginView {
override
fun
setupLinkedinButtonListener
(
linkedinUrl
:
String
,
state
:
String
)
{
override
fun
setupLinkedinButtonListener
(
linkedinUrl
:
String
,
state
:
String
)
{
ui
{
activity
->
ui
{
activity
->
button_linkedin
.
setOnClickListener
{
button_linkedin
.
setOnClickListener
{
startActivityForResult
(
activity
.
oauthWebViewIntent
(
linkedinUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
startActivityForResult
(
activity
.
oauthWebViewIntent
(
linkedinUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
}
}
}
}
...
@@ -337,7 +365,10 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -337,7 +365,10 @@ class LoginFragment : Fragment(), LoginView {
override
fun
setupGitlabButtonListener
(
gitlabUrl
:
String
,
state
:
String
)
{
override
fun
setupGitlabButtonListener
(
gitlabUrl
:
String
,
state
:
String
)
{
ui
{
activity
->
ui
{
activity
->
button_gitlab
.
setOnClickListener
{
button_gitlab
.
setOnClickListener
{
startActivityForResult
(
activity
.
oauthWebViewIntent
(
gitlabUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
startActivityForResult
(
activity
.
oauthWebViewIntent
(
gitlabUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
activity
.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
}
}
}
}
...
@@ -345,7 +376,7 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -345,7 +376,7 @@ class LoginFragment : Fragment(), LoginView {
override
fun
setupFabListener
()
{
override
fun
setupFabListener
()
{
ui
{
ui
{
button_fab
.
setVisible
(
true
)
button_fab
.
isVisible
=
true
button_fab
.
setOnClickListener
({
button_fab
.
setOnClickListener
({
button_fab
.
hide
()
button_fab
.
hide
()
showRemainingSocialAccountsView
()
showRemainingSocialAccountsView
()
...
@@ -355,8 +386,9 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -355,8 +386,9 @@ class LoginFragment : Fragment(), LoginView {
}
}
override
fun
setupGlobalListener
()
{
override
fun
setupGlobalListener
()
{
// We need to setup the layout to hide and show the oauth interface when the soft keyboard is shown
// We need to setup the layout to hide and show the oauth interface when the soft keyboard
// (means that the user touched the text_username_or_email or text_password EditText to fill that respective fields).
// is shown (which means that the user has touched the text_username_or_email or
// text_password EditText to fill that respective fields).
if
(!
isGlobalLayoutListenerSetUp
)
{
if
(!
isGlobalLayoutListenerSetUp
)
{
scroll_view
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
layoutListener
)
scroll_view
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
layoutListener
)
isGlobalLayoutListenerSetUp
=
true
isGlobalLayoutListenerSetUp
=
true
...
@@ -385,7 +417,7 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -385,7 +417,7 @@ class LoginFragment : Fragment(), LoginView {
(
0
..
social_accounts_container
.
childCount
)
(
0
..
social_accounts_container
.
childCount
)
.
mapNotNull
{
social_accounts_container
.
getChildAt
(
it
)
as
?
ImageButton
}
.
mapNotNull
{
social_accounts_container
.
getChildAt
(
it
)
as
?
ImageButton
}
.
filter
{
it
.
isClickable
}
.
filter
{
it
.
isClickable
}
.
forEach
{
it
.
setVisible
(
true
)
}
.
forEach
{
it
.
isVisible
=
true
}
}
}
}
}
}
}
...
@@ -422,19 +454,20 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -422,19 +454,20 @@ class LoginFragment : Fragment(), LoginView {
.
mapNotNull
{
social_accounts_container
.
getChildAt
(
it
)
as
?
ImageButton
}
.
mapNotNull
{
social_accounts_container
.
getChildAt
(
it
)
as
?
ImageButton
}
.
filter
{
it
.
isClickable
}
.
filter
{
it
.
isClickable
}
.
take
(
3
)
.
take
(
3
)
.
forEach
{
it
.
setVisible
(
true
)
}
.
forEach
{
it
.
isVisible
=
true
}
}
}
private
fun
showOauthView
()
{
private
fun
showOauthView
()
{
if
(
isOauthViewEnable
)
{
if
(
isOauthViewEnable
)
{
social_accounts_container
.
setVisible
(
true
)
social_accounts_container
.
isVisible
=
true
button_fab
.
isVisible
=
true
}
}
}
}
private
fun
hideOauthView
()
{
private
fun
hideOauthView
()
{
if
(
isOauthViewEnable
)
{
if
(
isOauthViewEnable
)
{
social_accounts_container
.
setVisible
(
false
)
social_accounts_container
.
isVisible
=
false
button_fab
.
setVisible
(
false
)
button_fab
.
isVisible
=
false
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/util/extensions/Ui.kt
View file @
c862cb9d
...
@@ -15,6 +15,7 @@ import android.view.inputmethod.InputMethodManager
...
@@ -15,6 +15,7 @@ import android.view.inputmethod.InputMethodManager
import
android.widget.Toast
import
android.widget.Toast
import
chat.rocket.android.R
import
chat.rocket.android.R
// TODO: Remove. Use KTX instead.
fun
View
.
setVisible
(
visible
:
Boolean
)
{
fun
View
.
setVisible
(
visible
:
Boolean
)
{
visibility
=
if
(
visible
)
{
visibility
=
if
(
visible
)
{
View
.
VISIBLE
View
.
VISIBLE
...
...
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