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
56f1be87
Unverified
Commit
56f1be87
authored
Mar 06, 2018
by
Filipe de Lima Brito
Committed by
GitHub
Mar 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop-2.x' into develop-2.x
parents
03f3add2
e0d61fe1
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
65 additions
and
29 deletions
+65
-29
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+7
-7
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+7
-7
ProfilePresenter.kt
...t/rocket/android/profile/presentation/ProfilePresenter.kt
+8
-4
ProfileFragment.kt
...in/java/chat/rocket/android/profile/ui/ProfileFragment.kt
+23
-11
ic_link_black_24dp.xml
app/src/main/res/drawable/ic_link_black_24dp.xml
+10
-0
fragment_profile.xml
app/src/main/res/layout/fragment_profile.xml
+8
-0
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+1
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
56f1be87
...
...
@@ -148,11 +148,11 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
for
(
status
in
stateChannel
)
{
Timber
.
d
(
"Changing status to: $status"
)
when
(
status
)
{
State
.
Authenticating
->
Timber
.
d
(
"Authenticating"
)
State
.
Connected
->
{
is
State
.
Authenticating
->
Timber
.
d
(
"Authenticating"
)
is
State
.
Connected
->
{
Timber
.
d
(
"Connected"
)
subId
=
client
.
subscribeRoomMessages
(
roomId
)
{
Timber
.
d
(
"subscribe messages for $roomId: $
it
"
)
subId
=
client
.
subscribeRoomMessages
(
roomId
)
{
success
,
_
->
Timber
.
d
(
"subscribe messages for $roomId: $
success
"
)
}
}
}
...
...
@@ -161,10 +161,10 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
}
when
(
client
.
state
)
{
State
.
Connected
->
{
is
State
.
Connected
->
{
Timber
.
d
(
"Already connected"
)
subId
=
client
.
subscribeRoomMessages
(
roomId
)
{
Timber
.
d
(
"subscribe messages for $roomId: $
it
"
)
subId
=
client
.
subscribeRoomMessages
(
roomId
)
{
success
,
_
->
Timber
.
d
(
"subscribe messages for $roomId: $
success
"
)
}
}
else
->
client
.
connect
()
...
...
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
56f1be87
...
...
@@ -99,14 +99,14 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
for
(
status
in
stateChannel
)
{
Timber
.
d
(
"Changing status to: $status"
)
when
(
status
)
{
State
.
Authenticating
->
Timber
.
d
(
"Authenticating"
)
State
.
Connected
->
{
is
State
.
Authenticating
->
Timber
.
d
(
"Authenticating"
)
is
State
.
Connected
->
{
Timber
.
d
(
"Connected"
)
client
.
subscribeSubscriptions
{
Timber
.
d
(
"subscriptions: $
it
"
)
client
.
subscribeSubscriptions
{
success
,
_
->
Timber
.
d
(
"subscriptions: $
success
"
)
}
client
.
subscribeRooms
{
Timber
.
d
(
"rooms: $
it
"
)
client
.
subscribeRooms
{
success
,
_
->
Timber
.
d
(
"rooms: $
success
"
)
}
}
}
...
...
@@ -115,7 +115,7 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
}
when
(
client
.
state
)
{
State
.
Connected
->
{
is
State
.
Connected
->
{
Timber
.
d
(
"Already connected"
)
}
else
->
client
.
connect
()
...
...
app/src/main/java/chat/rocket/android/profile/presentation/ProfilePresenter.kt
View file @
56f1be87
...
...
@@ -9,6 +9,7 @@ import chat.rocket.common.RocketChatException
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.me
import
chat.rocket.core.internal.rest.setAvatar
import
chat.rocket.core.internal.rest.updateProfile
import
javax.inject.Inject
...
...
@@ -45,19 +46,22 @@ class ProfilePresenter @Inject constructor (private val view: ProfileView,
}
}
fun
updateUserProfile
(
email
:
String
,
name
:
String
,
username
:
String
)
{
fun
updateUserProfile
(
email
:
String
,
name
:
String
,
username
:
String
,
avatarUrl
:
String
=
""
)
{
launchUI
(
strategy
)
{
view
.
showLoading
()
try
{
client
.
updateProfile
(
myselfId
,
email
,
name
,
null
,
username
)
if
(
avatarUrl
!=
""
)
{
client
.
setAvatar
(
avatarUrl
)
}
val
user
=
client
.
updateProfile
(
myselfId
,
email
,
name
,
username
)
view
.
showProfileUpdateSuccessfullyMessage
()
loadUserProfile
()
}
catch
(
exception
:
RocketChatException
)
{
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
view
.
showGenericErrorMessage
()
}
}
finally
{
view
.
hideLoading
()
}
...
...
app/src/main/java/chat/rocket/android/profile/ui/ProfileFragment.kt
View file @
56f1be87
...
...
@@ -6,7 +6,6 @@ import android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v7.view.ActionMode
import
android.view.*
import
android.widget.Toast
import
chat.rocket.android.R
import
chat.rocket.android.main.ui.MainActivity
import
chat.rocket.android.profile.presentation.ProfilePresenter
...
...
@@ -24,6 +23,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
private
lateinit
var
currentName
:
String
private
lateinit
var
currentUsername
:
String
private
lateinit
var
currentEmail
:
String
private
lateinit
var
currentAvatar
:
String
private
var
actionMode
:
ActionMode
?
=
null
companion
object
{
...
...
@@ -54,10 +54,12 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
text_name
.
textContent
=
name
text_username
.
textContent
=
username
text_email
.
textContent
=
email
text_avatar_url
.
textContent
=
""
currentName
=
name
currentUsername
=
username
currentEmail
=
email
currentAvatar
=
avatarUrl
profile_container
.
setVisible
(
true
)
...
...
@@ -93,7 +95,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
override
fun
onActionItemClicked
(
mode
:
ActionMode
,
menuItem
:
MenuItem
):
Boolean
{
return
when
(
menuItem
.
itemId
)
{
R
.
id
.
action_profile
->
{
presenter
.
updateUserProfile
(
text_email
.
textContent
,
text_name
.
textContent
,
text_username
.
textContent
)
presenter
.
updateUserProfile
(
text_email
.
textContent
,
text_name
.
textContent
,
text_username
.
textContent
,
text_avatar_url
.
textContent
)
mode
.
finish
()
true
}
...
...
@@ -116,22 +118,31 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
val
personDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_person_black_24dp
,
this
)
val
atDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_at_black_24dp
,
this
)
val
emailDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_email_black_24dp
,
this
)
val
linkDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_link_black_24dp
,
this
)
val
drawables
=
arrayOf
(
personDrawable
,
atDrawable
,
emailDrawable
)
val
drawables
=
arrayOf
(
personDrawable
,
atDrawable
,
emailDrawable
,
linkDrawable
)
DrawableHelper
.
wrapDrawables
(
drawables
)
DrawableHelper
.
tintDrawables
(
drawables
,
this
,
R
.
color
.
colorDrawableTintGrey
)
DrawableHelper
.
compoundDrawables
(
arrayOf
(
text_name
,
text_username
,
text_email
),
drawables
)
DrawableHelper
.
compoundDrawables
(
arrayOf
(
text_name
,
text_username
,
text_email
,
text_avatar_url
),
drawables
)
}
}
private
fun
listenToChanges
()
{
Observables
.
combineLatest
(
text_name
.
asObservable
(),
text_username
.
asObservable
(),
text_email
.
asObservable
()).
subscribe
({
t
->
if
(
t
.
first
.
toString
()
!=
currentName
||
t
.
second
.
toString
()
!=
currentUsername
||
t
.
third
.
toString
()
!=
currentEmail
)
{
startActionMode
()
}
else
{
finishActionMode
()
}
})
Observables
.
combineLatest
(
text_name
.
asObservable
(),
text_username
.
asObservable
(),
text_email
.
asObservable
(),
text_avatar_url
.
asObservable
())
{
text_name
,
text_username
,
text_email
,
text_avatar_url
->
return
@combineLatest
(
text_name
.
toString
()
!=
currentName
||
text_username
.
toString
()
!=
currentUsername
||
text_email
.
toString
()
!=
currentEmail
||
(
text_avatar_url
.
toString
()
!=
""
&&
text_avatar_url
.
toString
()!=
currentAvatar
))
}.
subscribe
({
isValid
->
if
(
isValid
)
{
startActionMode
()
}
else
{
finishActionMode
()
}
})
}
private
fun
startActionMode
()
{
...
...
@@ -146,5 +157,6 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
text_name
.
isEnabled
=
value
text_username
.
isEnabled
=
value
text_email
.
isEnabled
=
value
text_avatar_url
.
isEnabled
=
value
}
}
app/src/main/res/drawable/ic_link_black_24dp.xml
0 → 100644
View file @
56f1be87
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"24.0"
android:viewportHeight=
"24.0"
>
<path
android:fillColor=
"#FF000000"
android:pathData=
"M3.9,12c0,-1.71 1.39,-3.1 3.1,-3.1h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-1.9L7,15.1c-1.71,0 -3.1,-1.39 -3.1,-3.1zM8,13h8v-2L8,11v2zM17,7h-4v1.9h4c1.71,0 3.1,1.39 3.1,3.1s-1.39,3.1 -3.1,3.1h-4L13,17h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5z"
/>
</vector>
app/src/main/res/layout/fragment_profile.xml
View file @
56f1be87
...
...
@@ -46,6 +46,14 @@
android:drawableStart=
"@drawable/ic_email_black_24dp"
android:hint=
"@string/msg_email"
android:inputType=
"textEmailAddress"
/>
<EditText
android:id=
"@+id/text_avatar_url"
style=
"@style/EditText.Profile"
android:layout_marginTop=
"16dp"
android:drawableStart=
"@drawable/ic_link_black_24dp"
android:hint=
"@string/msg_avatar_url"
android:inputType=
"text"
/>
</LinearLayout>
<com.wang.avi.AVLoadingIndicatorView
...
...
app/src/main/res/values-pt-rBR/strings.xml
View file @
56f1be87
...
...
@@ -37,6 +37,7 @@
<string
name=
"msg_password"
>
senha
</string>
<string
name=
"msg_name"
>
nome
</string>
<string
name=
"msg_email"
>
email
</string>
<string
name=
"msg_avatar_url"
>
URL do avatar
</string>
<string
name=
"msg_or_continue_using_social_accounts"
>
Ou continue através de contas sociais
</string>
<string
name=
"msg_new_user"
>
Novo usuário? %1$s
</string>
<string
name=
"msg_new_user_agreement"
>
Ao proceder você concorda com nossos %1$s e %2$s
</string>
...
...
app/src/main/res/values/strings.xml
View file @
56f1be87
...
...
@@ -38,6 +38,7 @@
<string
name=
"msg_password"
>
password
</string>
<string
name=
"msg_name"
>
name
</string>
<string
name=
"msg_email"
>
email
</string>
<string
name=
"msg_avatar_url"
>
avatar URL
</string>
<string
name=
"msg_or_continue_using_social_accounts"
>
Or continue using social accounts
</string>
<string
name=
"msg_new_user"
>
New user? %1$s
</string>
<string
name=
"msg_new_user_agreement"
>
By proceeding you are agreeing to our\n%1$s and %2$s
</string>
...
...
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