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
75b1baf1
Commit
75b1baf1
authored
Nov 21, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement user status switching.
parent
26615672
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
3 deletions
+37
-3
MethodCallHelper.java
...c/main/java/chat/rocket/android/api/MethodCallHelper.java
+8
-0
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+27
-2
MethodCall.java
...n/java/chat/rocket/android/model/internal/MethodCall.java
+2
-1
No files found.
app/src/main/java/chat/rocket/android/api/MethodCallHelper.java
View file @
75b1baf1
...
...
@@ -222,4 +222,12 @@ public class MethodCallHelper {
});
}
/**
* update user's status.
*/
public
Task
<
Void
>
setUserStatus
(
final
String
status
)
{
return
call
(
"UserPresence:setDefaultStatus"
,
TIMEOUT_MS
,
()
->
new
JSONArray
().
put
(
status
))
.
onSuccessTask
(
task
->
Task
.
forResult
(
null
));
}
}
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
75b1baf1
...
...
@@ -8,7 +8,9 @@ import android.widget.LinearLayout;
import
android.widget.TextView
;
import
chat.rocket.android.R
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.helper.LogcatIfError
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.layouthelper.chatroom.RoomListManager
;
import
chat.rocket.android.model.ServerConfig
;
...
...
@@ -65,7 +67,7 @@ public class SidebarMainFragment extends AbstractFragment {
currentUserObserver
=
realmHelper
.
createObjectObserver
(
realm
->
realm
.
where
(
User
.
class
).
isNotEmpty
(
"emails"
))
.
setOnUpdateListener
(
this
::
update
CurrentUser
);
.
setOnUpdateListener
(
this
::
onRender
CurrentUser
);
}
}
}
...
...
@@ -84,6 +86,7 @@ public class SidebarMainFragment extends AbstractFragment {
}
setupUserActionToggle
();
setupUserStatusButtons
();
roomListManager
=
new
RoomListManager
(
(
LinearLayout
)
rootView
.
findViewById
(
R
.
id
.
channels_container
),
...
...
@@ -107,7 +110,29 @@ public class SidebarMainFragment extends AbstractFragment {
.
subscribe
(
RxView
.
visibility
(
rootView
.
findViewById
(
R
.
id
.
user_action_outer_container
)));
}
private
void
updateCurrentUser
(
User
user
)
{
private
void
setupUserStatusButtons
()
{
rootView
.
findViewById
(
R
.
id
.
btn_status_online
).
setOnClickListener
(
view
->
{
updateCurrentUserStatus
(
User
.
STATUS_ONLINE
);
});
rootView
.
findViewById
(
R
.
id
.
btn_status_away
).
setOnClickListener
(
view
->
{
updateCurrentUserStatus
(
User
.
STATUS_AWAY
);
});
rootView
.
findViewById
(
R
.
id
.
btn_status_busy
).
setOnClickListener
(
view
->
{
updateCurrentUserStatus
(
User
.
STATUS_BUSY
);
});
rootView
.
findViewById
(
R
.
id
.
btn_status_invisible
).
setOnClickListener
(
view
->
{
updateCurrentUserStatus
(
User
.
STATUS_OFFLINE
);
});
}
private
void
updateCurrentUserStatus
(
String
status
)
{
if
(!
TextUtils
.
isEmpty
(
serverConfigId
))
{
new
MethodCallHelper
(
serverConfigId
).
setUserStatus
(
status
)
.
continueWith
(
new
LogcatIfError
());
}
}
private
void
onRenderCurrentUser
(
User
user
)
{
if
(
user
!=
null
&&
!
TextUtils
.
isEmpty
(
hostname
))
{
new
UserRenderer
(
getContext
(),
user
)
.
avatarInto
((
ImageView
)
rootView
.
findViewById
(
R
.
id
.
current_user_avatar
),
hostname
)
...
...
app/src/main/java/chat/rocket/android/model/internal/MethodCall.java
View file @
75b1baf1
...
...
@@ -115,8 +115,9 @@ public class MethodCall extends RealmObject {
String
resultJson
=
methodCall
.
getResultJson
();
if
(
TextUtils
.
isEmpty
(
resultJson
))
{
task
.
setResult
(
null
);
}
else
{
task
.
setResult
(
resultJson
);
}
task
.
setResult
(
resultJson
);
observer
.
unsub
();
remove
(
realmHelper
,
methodCall
.
getMethodCallId
()).
continueWith
(
new
LogcatIfError
());
}
else
if
(
syncstate
==
SyncState
.
FAILED
)
{
...
...
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