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
18e83a4b
Commit
18e83a4b
authored
Nov 19, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Observe room changes to the current channel
parent
946b42be
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
15 deletions
+29
-15
ChatRoomFragmentModule.kt
...chat/rocket/android/chatroom/di/ChatRoomFragmentModule.kt
+4
-2
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+2
-4
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+3
-1
RoomUiModelMapper.kt
...hat/rocket/android/chatrooms/adapter/RoomUiModelMapper.kt
+15
-5
RoomUiModel.kt
...hat/rocket/android/chatrooms/adapter/model/RoomUiModel.kt
+1
-1
ChatRoomsFragmentModule.kt
...at/rocket/android/chatrooms/di/ChatRoomsFragmentModule.kt
+4
-2
No files found.
app/src/main/java/chat/rocket/android/chatroom/di/ChatRoomFragmentModule.kt
View file @
18e83a4b
...
@@ -13,6 +13,7 @@ import chat.rocket.android.db.DatabaseManagerFactory
...
@@ -13,6 +13,7 @@ import chat.rocket.android.db.DatabaseManagerFactory
import
chat.rocket.android.db.UserDao
import
chat.rocket.android.db.UserDao
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetCurrentUserInteractor
import
chat.rocket.android.server.domain.GetCurrentUserInteractor
import
chat.rocket.android.server.domain.PermissionsInteractor
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.domain.TokenRepository
import
dagger.Module
import
dagger.Module
...
@@ -69,8 +70,9 @@ class ChatRoomFragmentModule {
...
@@ -69,8 +70,9 @@ class ChatRoomFragmentModule {
context
:
Application
,
context
:
Application
,
repository
:
SettingsRepository
,
repository
:
SettingsRepository
,
userInteractor
:
GetCurrentUserInteractor
,
userInteractor
:
GetCurrentUserInteractor
,
@Named
(
"currentServer"
)
serverUrl
:
String
@Named
(
"currentServer"
)
serverUrl
:
String
,
permissionsInteractor
:
PermissionsInteractor
):
RoomUiModelMapper
{
):
RoomUiModelMapper
{
return
RoomUiModelMapper
(
context
,
repository
.
get
(
serverUrl
),
userInteractor
,
serverUrl
)
return
RoomUiModelMapper
(
context
,
repository
.
get
(
serverUrl
),
userInteractor
,
serverUrl
,
permissionsInteractor
)
}
}
}
}
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
18e83a4b
...
@@ -38,7 +38,6 @@ import chat.rocket.android.server.infraestructure.state
...
@@ -38,7 +38,6 @@ import chat.rocket.android.server.infraestructure.state
import
chat.rocket.android.util.extension.getByteArray
import
chat.rocket.android.util.extension.getByteArray
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.extensions.exhaustive
import
chat.rocket.android.util.retryIO
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.RoomType
...
@@ -142,7 +141,6 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -142,7 +141,6 @@ class ChatRoomPresenter @Inject constructor(
val
canModerate
=
isOwnerOrMod
()
val
canModerate
=
isOwnerOrMod
()
// Can post anyway if has the 'post-readonly' permission on server.
// Can post anyway if has the 'post-readonly' permission on server.
val
room
=
dbManager
.
getRoom
(
roomId
)
val
room
=
dbManager
.
getRoom
(
roomId
)
val
canPost
=
canModerate
||
permissions
.
canPostToReadOnlyChannels
()
room
?.
let
{
room
?.
let
{
chatIsBroadcast
=
it
.
chatRoom
.
broadcast
?:
false
chatIsBroadcast
=
it
.
chatRoom
.
broadcast
?:
false
val
roomUiModel
=
roomMapper
.
map
(
it
,
true
)
val
roomUiModel
=
roomMapper
.
map
(
it
,
true
)
...
@@ -150,7 +148,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -150,7 +148,7 @@ class ChatRoomPresenter @Inject constructor(
view
.
onRoomUpdated
(
roomUiModel
=
roomUiModel
.
copy
(
view
.
onRoomUpdated
(
roomUiModel
=
roomUiModel
.
copy
(
broadcast
=
chatIsBroadcast
,
broadcast
=
chatIsBroadcast
,
canModerate
=
canModerate
,
canModerate
=
canModerate
,
canPost
=
canPost
writable
=
roomUiModel
.
writable
||
canModerate
))
))
}
}
}
}
...
@@ -1010,7 +1008,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1010,7 +1008,7 @@ class ChatRoomPresenter @Inject constructor(
val
canPost
=
permissions
.
canPostToReadOnlyChannels
()
val
canPost
=
permissions
.
canPostToReadOnlyChannels
()
dbManager
.
getRoom
(
chatRoomId
)
?.
let
{
dbManager
.
getRoom
(
chatRoomId
)
?.
let
{
val
roomUiModel
=
roomMapper
.
map
(
it
,
true
).
copy
(
val
roomUiModel
=
roomMapper
.
map
(
it
,
true
).
copy
(
canPost
=
canPost
)
writable
=
canPost
)
view
.
onJoined
(
roomUiModel
=
roomUiModel
)
view
.
onJoined
(
roomUiModel
=
roomUiModel
)
view
.
onRoomUpdated
(
roomUiModel
=
roomUiModel
)
view
.
onRoomUpdated
(
roomUiModel
=
roomUiModel
)
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
18e83a4b
...
@@ -767,7 +767,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -767,7 +767,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
private
fun
setupMessageComposer
(
roomUiModel
:
RoomUiModel
)
{
private
fun
setupMessageComposer
(
roomUiModel
:
RoomUiModel
)
{
if
(
isReadOnly
&&
!
roomUiModel
.
canPost
)
{
if
(
isReadOnly
||
!
roomUiModel
.
writable
)
{
text_room_is_read_only
.
isVisible
=
true
text_room_is_read_only
.
isVisible
=
true
input_container
.
isVisible
=
false
input_container
.
isVisible
=
false
text_room_is_read_only
.
setText
(
text_room_is_read_only
.
setText
(
...
@@ -783,6 +783,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -783,6 +783,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
button_join_chat
.
isVisible
=
true
button_join_chat
.
isVisible
=
true
button_join_chat
.
setOnClickListener
{
presenter
.
joinChat
(
chatRoomId
)
}
button_join_chat
.
setOnClickListener
{
presenter
.
joinChat
(
chatRoomId
)
}
}
else
{
}
else
{
input_container
.
isVisible
=
true
text_room_is_read_only
.
isVisible
=
false
button_send
.
isVisible
=
false
button_send
.
isVisible
=
false
button_show_attachment_options
.
alpha
=
1f
button_show_attachment_options
.
alpha
=
1f
button_show_attachment_options
.
isVisible
=
true
button_show_attachment_options
.
isVisible
=
true
...
...
app/src/main/java/chat/rocket/android/chatrooms/adapter/RoomUiModelMapper.kt
View file @
18e83a4b
...
@@ -9,6 +9,7 @@ import chat.rocket.android.R
...
@@ -9,6 +9,7 @@ import chat.rocket.android.R
import
chat.rocket.android.chatrooms.adapter.model.RoomUiModel
import
chat.rocket.android.chatrooms.adapter.model.RoomUiModel
import
chat.rocket.android.db.model.ChatRoom
import
chat.rocket.android.db.model.ChatRoom
import
chat.rocket.android.server.domain.GetCurrentUserInteractor
import
chat.rocket.android.server.domain.GetCurrentUserInteractor
import
chat.rocket.android.server.domain.PermissionsInteractor
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.showLastMessage
import
chat.rocket.android.server.domain.showLastMessage
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.server.domain.useRealName
...
@@ -28,7 +29,8 @@ class RoomUiModelMapper(
...
@@ -28,7 +29,8 @@ class RoomUiModelMapper(
private
val
context
:
Application
,
private
val
context
:
Application
,
private
val
settings
:
PublicSettings
,
private
val
settings
:
PublicSettings
,
private
val
userInteractor
:
GetCurrentUserInteractor
,
private
val
userInteractor
:
GetCurrentUserInteractor
,
private
val
serverUrl
:
String
private
val
serverUrl
:
String
,
private
val
permissions
:
PermissionsInteractor
)
{
)
{
private
val
nameUnreadColor
=
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorPrimaryText
)
private
val
nameUnreadColor
=
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorPrimaryText
)
private
val
nameColor
=
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorSecondaryText
)
private
val
nameColor
=
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorSecondaryText
)
...
@@ -95,12 +97,13 @@ class RoomUiModelMapper(
...
@@ -95,12 +97,13 @@ class RoomUiModelMapper(
avatar
=
serverUrl
.
avatarUrl
(
name
!!
,
isGroupOrChannel
=
true
),
avatar
=
serverUrl
.
avatarUrl
(
name
!!
,
isGroupOrChannel
=
true
),
lastMessage
=
if
(
showLastMessage
)
{
mapLastMessage
(
lastMessage
?.
sender
?.
id
,
lastMessage
?.
sender
?.
username
,
lastMessage
=
if
(
showLastMessage
)
{
mapLastMessage
(
lastMessage
?.
sender
?.
id
,
lastMessage
?.
sender
?.
username
,
lastMessage
?.
sender
?.
name
,
lastMessage
?.
message
,
lastMessage
?.
sender
?.
name
,
lastMessage
?.
message
,
isDirectMessage
=
type
is
RoomType
.
DirectMessage
)}
else
{
null
}
isDirectMessage
=
type
is
RoomType
.
DirectMessage
)}
else
{
null
},
muted
=
muted
.
orEmpty
(),
writable
=
isChannelWritable
(
muted
)
)
)
}
}
}
}
@Synchronized
fun
map
(
chatRoom
:
ChatRoom
,
showLastMessage
:
Boolean
=
true
):
RoomUiModel
{
fun
map
(
chatRoom
:
ChatRoom
,
showLastMessage
:
Boolean
=
true
):
RoomUiModel
{
return
with
(
chatRoom
.
chatRoom
)
{
return
with
(
chatRoom
.
chatRoom
)
{
val
isUnread
=
alert
||
unread
>
0
val
isUnread
=
alert
||
unread
>
0
...
@@ -132,11 +135,18 @@ class RoomUiModelMapper(
...
@@ -132,11 +135,18 @@ class RoomUiModelMapper(
alert
=
isUnread
,
alert
=
isUnread
,
lastMessage
=
lastMessageMarkdown
,
lastMessage
=
lastMessageMarkdown
,
status
=
status
,
status
=
status
,
username
=
if
(
type
is
RoomType
.
DirectMessage
)
name
else
null
username
=
if
(
type
is
RoomType
.
DirectMessage
)
name
else
null
,
muted
=
muted
.
orEmpty
(),
writable
=
isChannelWritable
(
muted
)
)
)
}
}
}
}
private
fun
isChannelWritable
(
muted
:
List
<
String
>?):
Boolean
{
val
canWriteToReadOnlyChannels
=
permissions
.
canPostToReadOnlyChannels
()
return
canWriteToReadOnlyChannels
||
!
muted
.
orEmpty
().
contains
(
currentUser
?.
username
)
}
private
fun
roomType
(
type
:
String
):
String
{
private
fun
roomType
(
type
:
String
):
String
{
val
resources
=
context
.
resources
val
resources
=
context
.
resources
return
when
(
type
)
{
return
when
(
type
)
{
...
@@ -204,4 +214,4 @@ class RoomUiModelMapper(
...
@@ -204,4 +214,4 @@ class RoomUiModelMapper(
}
}
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/adapter/model/RoomUiModel.kt
View file @
18e83a4b
...
@@ -17,6 +17,6 @@ data class RoomUiModel(
...
@@ -17,6 +17,6 @@ data class RoomUiModel(
val
username
:
String
?
=
null
,
val
username
:
String
?
=
null
,
val
broadcast
:
Boolean
=
false
,
val
broadcast
:
Boolean
=
false
,
val
canModerate
:
Boolean
=
false
,
val
canModerate
:
Boolean
=
false
,
val
canPost
:
Boolean
=
true
,
val
writable
:
Boolean
=
true
,
val
muted
:
List
<
String
>
=
emptyList
()
val
muted
:
List
<
String
>
=
emptyList
()
)
)
app/src/main/java/chat/rocket/android/chatrooms/di/ChatRoomsFragmentModule.kt
View file @
18e83a4b
...
@@ -12,6 +12,7 @@ import chat.rocket.android.db.DatabaseManager
...
@@ -12,6 +12,7 @@ import chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.UserDao
import
chat.rocket.android.db.UserDao
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.GetCurrentUserInteractor
import
chat.rocket.android.server.domain.GetCurrentUserInteractor
import
chat.rocket.android.server.domain.PermissionsInteractor
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.domain.TokenRepository
...
@@ -88,9 +89,10 @@ class ChatRoomsFragmentModule {
...
@@ -88,9 +89,10 @@ class ChatRoomsFragmentModule {
context
:
Application
,
context
:
Application
,
repository
:
SettingsRepository
,
repository
:
SettingsRepository
,
userInteractor
:
GetCurrentUserInteractor
,
userInteractor
:
GetCurrentUserInteractor
,
@Named
(
"currentServer"
)
serverUrl
:
String
@Named
(
"currentServer"
)
serverUrl
:
String
,
permissionsInteractor
:
PermissionsInteractor
):
RoomUiModelMapper
{
):
RoomUiModelMapper
{
return
RoomUiModelMapper
(
context
,
repository
.
get
(
serverUrl
),
userInteractor
,
serverUrl
)
return
RoomUiModelMapper
(
context
,
repository
.
get
(
serverUrl
),
userInteractor
,
serverUrl
,
permissionsInteractor
)
}
}
@Provides
@Provides
...
...
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