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
12550250
Commit
12550250
authored
Jun 15, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat.Android into feature/create-channel
parents
60009b87
b3b80d2b
Changes
79
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
79 changed files
with
501 additions
and
501 deletions
+501
-501
build.gradle
app/build.gradle
+1
-0
TokenMapper.kt
...ket/android/authentication/infraestructure/TokenMapper.kt
+0
-11
AudioAttachmentViewHolder.kt
...ket/android/chatroom/adapter/AudioAttachmentViewHolder.kt
+3
-3
AuthorAttachmentViewHolder.kt
...et/android/chatroom/adapter/AuthorAttachmentViewHolder.kt
+3
-3
BaseViewHolder.kt
...va/chat/rocket/android/chatroom/adapter/BaseViewHolder.kt
+2
-2
ChatRoomAdapter.kt
...a/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
+28
-28
ColorAttachmentViewHolder.kt
...ket/android/chatroom/adapter/ColorAttachmentViewHolder.kt
+3
-3
CommandSuggestionsAdapter.kt
...ket/android/chatroom/adapter/CommandSuggestionsAdapter.kt
+2
-2
GenericFileAttachmentViewHolder.kt
...droid/chatroom/adapter/GenericFileAttachmentViewHolder.kt
+3
-5
ImageAttachmentViewHolder.kt
...ket/android/chatroom/adapter/ImageAttachmentViewHolder.kt
+3
-3
MessageAttachmentViewHolder.kt
...t/android/chatroom/adapter/MessageAttachmentViewHolder.kt
+3
-3
MessageReactionsAdapter.kt
...ocket/android/chatroom/adapter/MessageReactionsAdapter.kt
+5
-5
MessageReplyViewHolder.kt
...rocket/android/chatroom/adapter/MessageReplyViewHolder.kt
+3
-3
MessageViewHolder.kt
...chat/rocket/android/chatroom/adapter/MessageViewHolder.kt
+3
-4
PeopleSuggestionsAdapter.kt
...cket/android/chatroom/adapter/PeopleSuggestionsAdapter.kt
+4
-4
RoomSuggestionsAdapter.kt
...rocket/android/chatroom/adapter/RoomSuggestionsAdapter.kt
+2
-2
UrlPreviewViewHolder.kt
...t/rocket/android/chatroom/adapter/UrlPreviewViewHolder.kt
+3
-4
VideoAttachmentViewHolder.kt
...ket/android/chatroom/adapter/VideoAttachmentViewHolder.kt
+3
-3
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+20
-26
ChatRoomView.kt
...chat/rocket/android/chatroom/presentation/ChatRoomView.kt
+10
-10
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+42
-33
AudioAttachmentUiModel.kt
...rocket/android/chatroom/uimodel/AudioAttachmentUiModel.kt
+6
-6
AuthorAttachmentUiModel.kt
...ocket/android/chatroom/uimodel/AuthorAttachmentUiModel.kt
+6
-6
BaseAttachmentUiModel.kt
.../rocket/android/chatroom/uimodel/BaseAttachmentUiModel.kt
+5
-0
BaseFileAttachmentUiModel.kt
...ket/android/chatroom/uimodel/BaseFileAttachmentUiModel.kt
+6
-0
BaseMessageUiModel.kt
...hat/rocket/android/chatroom/uimodel/BaseMessageUiModel.kt
+2
-2
BaseUiModel.kt
.../java/chat/rocket/android/chatroom/uimodel/BaseUiModel.kt
+7
-7
ColorAttachmentUiModel.kt
...rocket/android/chatroom/uimodel/ColorAttachmentUiModel.kt
+24
-0
GenericFileAttachmentUiModel.kt
.../android/chatroom/uimodel/GenericFileAttachmentUiModel.kt
+6
-7
ImageAttachmentUiModel.kt
...rocket/android/chatroom/uimodel/ImageAttachmentUiModel.kt
+6
-6
MessageAttachmentUiModel.kt
...cket/android/chatroom/uimodel/MessageAttachmentUiModel.kt
+6
-6
MessageReplyUiModel.kt
...at/rocket/android/chatroom/uimodel/MessageReplyUiModel.kt
+20
-0
MessageUiModel.kt
...va/chat/rocket/android/chatroom/uimodel/MessageUiModel.kt
+26
-0
ReactionUiModel.kt
...a/chat/rocket/android/chatroom/uimodel/ReactionUiModel.kt
+2
-2
RoomUiModel.kt
.../java/chat/rocket/android/chatroom/uimodel/RoomUiModel.kt
+2
-2
UiModelMapper.kt
...ava/chat/rocket/android/chatroom/uimodel/UiModelMapper.kt
+47
-48
UrlPreviewUiModel.kt
...chat/rocket/android/chatroom/uimodel/UrlPreviewUiModel.kt
+6
-6
VideoAttachmentUiModel.kt
...rocket/android/chatroom/uimodel/VideoAttachmentUiModel.kt
+6
-6
ChatRoomSuggestionUiModel.kt
.../chatroom/uimodel/suggestion/ChatRoomSuggestionUiModel.kt
+9
-0
CommandSuggestionUiModel.kt
...d/chatroom/uimodel/suggestion/CommandSuggestionUiModel.kt
+7
-0
PeopleSuggestionUiModel.kt
...id/chatroom/uimodel/suggestion/PeopleSuggestionUiModel.kt
+17
-0
BaseAttachmentViewModel.kt
...ket/android/chatroom/viewmodel/BaseAttachmentViewModel.kt
+0
-5
ColorAttachmentViewModel.kt
...et/android/chatroom/viewmodel/ColorAttachmentViewModel.kt
+0
-24
MessageViewModel.kt
...hat/rocket/android/chatroom/viewmodel/MessageViewModel.kt
+0
-26
ChatRoomSuggestionViewModel.kt
...troom/viewmodel/suggestion/ChatRoomSuggestionViewModel.kt
+0
-9
CommandSuggestionViewModel.kt
...atroom/viewmodel/suggestion/CommandSuggestionViewModel.kt
+0
-7
PeopleSuggestionViewModel.kt
...hatroom/viewmodel/suggestion/PeopleSuggestionViewModel.kt
+0
-17
RoomItemHolder.kt
...a/chat/rocket/android/chatrooms/adapter/RoomItemHolder.kt
+2
-2
RoomUiModelMapper.kt
...hat/rocket/android/chatrooms/adapter/RoomUiModelMapper.kt
+9
-8
RoomUiModel.kt
...hat/rocket/android/chatrooms/adapter/model/RoomUiModel.kt
+1
-1
ChatRoomsFragmentModule.kt
...at/rocket/android/chatrooms/di/ChatRoomsFragmentModule.kt
+3
-3
ChatRoomsViewModel.kt
.../rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
+2
-3
ChatRoomsViewModelFactory.kt
.../android/chatrooms/viewmodel/ChatRoomsViewModelFactory.kt
+2
-2
FavoriteMessagesPresenter.kt
...avoritemessages/presentation/FavoriteMessagesPresenter.kt
+2
-2
FavoriteMessagesView.kt
...oid/favoritemessages/presentation/FavoriteMessagesView.kt
+2
-2
FavoriteMessagesFragment.kt
...t/android/favoritemessages/ui/FavoriteMessagesFragment.kt
+2
-2
FilesAdapter.kt
...in/java/chat/rocket/android/files/adapter/FilesAdapter.kt
+13
-13
FilesPresenter.kt
.../chat/rocket/android/files/presentation/FilesPresenter.kt
+15
-15
FilesView.kt
.../java/chat/rocket/android/files/presentation/FilesView.kt
+2
-2
FilesFragment.kt
...c/main/java/chat/rocket/android/files/ui/FilesFragment.kt
+3
-3
FileUiModel.kt
...ain/java/chat/rocket/android/files/uimodel/FileUiModel.kt
+2
-2
FileUiModelMapper.kt
...va/chat/rocket/android/files/uimodel/FileUiModelMapper.kt
+4
-4
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+21
-21
MainView.kt
...in/java/chat/rocket/android/main/presentation/MainView.kt
+3
-3
MainActivity.kt
...src/main/java/chat/rocket/android/main/ui/MainActivity.kt
+5
-5
NavHeaderUiModel.kt
...java/chat/rocket/android/main/uimodel/NavHeaderUiModel.kt
+2
-2
NavHeaderUiModelMapper.kt
...hat/rocket/android/main/uimodel/NavHeaderUiModelMapper.kt
+4
-4
MembersAdapter.kt
...ava/chat/rocket/android/members/adapter/MembersAdapter.kt
+10
-11
MembersPresenter.kt
...t/rocket/android/members/presentation/MembersPresenter.kt
+11
-11
MembersView.kt
...a/chat/rocket/android/members/presentation/MembersView.kt
+2
-2
MembersFragment.kt
...in/java/chat/rocket/android/members/ui/MembersFragment.kt
+3
-4
MemberUiModel.kt
...java/chat/rocket/android/members/uimodel/MemberUiModel.kt
+2
-2
MemberUiModelMapper.kt
...hat/rocket/android/members/uimodel/MemberUiModelMapper.kt
+4
-4
PinnedMessagesPresenter.kt
...id/pinnedmessages/presentation/PinnedMessagesPresenter.kt
+2
-3
PinnedMessagesView.kt
...android/pinnedmessages/presentation/PinnedMessagesView.kt
+2
-2
PinnedMessagesFragment.kt
...ocket/android/pinnedmessages/ui/PinnedMessagesFragment.kt
+2
-2
DataToDomain.kt
app/src/main/java/chat/rocket/android/util/DataToDomain.kt
+0
-5
DomainToViewModel.kt
...c/main/java/chat/rocket/android/util/DomainToViewModel.kt
+0
-5
dependencies.gradle
dependencies.gradle
+2
-2
No files found.
app/build.gradle
View file @
12550250
...
...
@@ -53,6 +53,7 @@ android {
packagingOptions
{
exclude
'META-INF/core.kotlin_module'
exclude
'META-INF/main.kotlin_module'
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/infraestructure/TokenMapper.kt
deleted
100644 → 0
View file @
60009b87
package
chat.rocket.android.authentication.infraestructure
import
chat.rocket.android.authentication.domain.model.TokenModel
import
chat.rocket.android.util.DataToDomain
import
chat.rocket.common.model.Token
object
TokenMapper
:
DataToDomain
<
Token
,
TokenModel
>
{
override
fun
translate
(
data
:
Token
):
TokenModel
{
return
TokenModel
(
data
.
userId
,
data
.
authToken
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/adapter/AudioAttachmentViewHolder.kt
View file @
12550250
package
chat.rocket.android.chatroom.adapter
import
android.view.View
import
chat.rocket.android.chatroom.
viewmodel.AudioAttachmentView
Model
import
chat.rocket.android.chatroom.
uimodel.AudioAttachmentUi
Model
import
chat.rocket.android.player.PlayerActivity
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.widget.emoji.EmojiReactionListener
...
...
@@ -10,7 +10,7 @@ import kotlinx.android.synthetic.main.message_attachment.view.*
class
AudioAttachmentViewHolder
(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
AudioAttachment
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
:
BaseViewHolder
<
AudioAttachment
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
init
{
with
(
itemView
)
{
...
...
@@ -20,7 +20,7 @@ class AudioAttachmentViewHolder(itemView: View,
}
}
override
fun
bindViews
(
data
:
AudioAttachment
View
Model
)
{
override
fun
bindViews
(
data
:
AudioAttachment
Ui
Model
)
{
with
(
itemView
)
{
file_name
.
text
=
data
.
attachmentTitle
audio_video_attachment
.
setOnClickListener
{
view
->
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/AuthorAttachmentViewHolder.kt
View file @
12550250
...
...
@@ -5,7 +5,7 @@ import android.net.Uri
import
android.view.View
import
androidx.core.view.isGone
import
androidx.core.view.isVisible
import
chat.rocket.android.chatroom.
viewmodel.AuthorAttachmentView
Model
import
chat.rocket.android.chatroom.
uimodel.AuthorAttachmentUi
Model
import
chat.rocket.android.util.extensions.content
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
chat.rocket.common.util.ifNull
...
...
@@ -14,7 +14,7 @@ import kotlinx.android.synthetic.main.item_author_attachment.view.*
class
AuthorAttachmentViewHolder
(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
AuthorAttachment
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
:
BaseViewHolder
<
AuthorAttachment
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
init
{
with
(
itemView
)
{
...
...
@@ -22,7 +22,7 @@ class AuthorAttachmentViewHolder(itemView: View,
}
}
override
fun
bindViews
(
data
:
AuthorAttachment
View
Model
)
{
override
fun
bindViews
(
data
:
AuthorAttachment
Ui
Model
)
{
with
(
itemView
)
{
data
.
icon
?.
let
{
icon
->
author_icon
.
isVisible
=
true
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/BaseViewHolder.kt
View file @
12550250
...
...
@@ -8,7 +8,7 @@ import androidx.core.view.children
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.ui.bottomsheet.BottomSheetMenu
import
chat.rocket.android.chatroom.ui.bottomsheet.adapter.ActionListAdapter
import
chat.rocket.android.chatroom.
viewmodel.BaseView
Model
import
chat.rocket.android.chatroom.
uimodel.BaseUi
Model
import
chat.rocket.android.widget.emoji.Emoji
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
chat.rocket.core.model.Message
...
...
@@ -18,7 +18,7 @@ import com.google.android.flexbox.FlexboxLayoutManager
import
ru.whalemare.sheetmenu.extension.inflate
import
ru.whalemare.sheetmenu.extension.toList
abstract
class
BaseViewHolder
<
T
:
Base
View
Model
<*>>(
abstract
class
BaseViewHolder
<
T
:
Base
Ui
Model
<*>>(
itemView
:
View
,
private
val
listener
:
ActionsListener
,
var
reactionListener
:
EmojiReactionListener
?
=
null
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
View file @
12550250
...
...
@@ -5,7 +5,7 @@ import android.view.MenuItem
import
android.view.ViewGroup
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.presentation.ChatRoomPresenter
import
chat.rocket.android.chatroom.
view
model.*
import
chat.rocket.android.chatroom.
ui
model.*
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
chat.rocket.core.model.Message
...
...
@@ -20,7 +20,7 @@ class ChatRoomAdapter(
private
val
enableActions
:
Boolean
=
true
,
private
val
reactionListener
:
EmojiReactionListener
?
=
null
)
:
RecyclerView
.
Adapter
<
BaseViewHolder
<*>>()
{
private
val
dataSet
=
ArrayList
<
Base
View
Model
<*>>()
private
val
dataSet
=
ArrayList
<
Base
Ui
Model
<*>>()
init
{
setHasStableIds
(
true
)
...
...
@@ -28,43 +28,43 @@ class ChatRoomAdapter(
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
BaseViewHolder
<
*
>
{
return
when
(
viewType
.
toViewType
())
{
Base
View
Model
.
ViewType
.
MESSAGE
->
{
Base
Ui
Model
.
ViewType
.
MESSAGE
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
item_message
)
MessageViewHolder
(
view
,
actionsListener
,
reactionListener
)
}
Base
View
Model
.
ViewType
.
IMAGE_ATTACHMENT
->
{
Base
Ui
Model
.
ViewType
.
IMAGE_ATTACHMENT
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
message_attachment
)
ImageAttachmentViewHolder
(
view
,
actionsListener
,
reactionListener
)
}
Base
View
Model
.
ViewType
.
AUDIO_ATTACHMENT
->
{
Base
Ui
Model
.
ViewType
.
AUDIO_ATTACHMENT
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
message_attachment
)
AudioAttachmentViewHolder
(
view
,
actionsListener
,
reactionListener
)
}
Base
View
Model
.
ViewType
.
VIDEO_ATTACHMENT
->
{
Base
Ui
Model
.
ViewType
.
VIDEO_ATTACHMENT
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
message_attachment
)
VideoAttachmentViewHolder
(
view
,
actionsListener
,
reactionListener
)
}
Base
View
Model
.
ViewType
.
URL_PREVIEW
->
{
Base
Ui
Model
.
ViewType
.
URL_PREVIEW
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
message_url_preview
)
UrlPreviewViewHolder
(
view
,
actionsListener
,
reactionListener
)
}
Base
View
Model
.
ViewType
.
MESSAGE_ATTACHMENT
->
{
Base
Ui
Model
.
ViewType
.
MESSAGE_ATTACHMENT
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
item_message_attachment
)
MessageAttachmentViewHolder
(
view
,
actionsListener
,
reactionListener
)
}
Base
View
Model
.
ViewType
.
AUTHOR_ATTACHMENT
->
{
Base
Ui
Model
.
ViewType
.
AUTHOR_ATTACHMENT
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
item_author_attachment
)
AuthorAttachmentViewHolder
(
view
,
actionsListener
,
reactionListener
)
}
Base
View
Model
.
ViewType
.
COLOR_ATTACHMENT
->
{
Base
Ui
Model
.
ViewType
.
COLOR_ATTACHMENT
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
item_color_attachment
)
ColorAttachmentViewHolder
(
view
,
actionsListener
,
reactionListener
)
}
Base
View
Model
.
ViewType
.
GENERIC_FILE_ATTACHMENT
->
{
Base
Ui
Model
.
ViewType
.
GENERIC_FILE_ATTACHMENT
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
item_file_attachment
)
GenericFileAttachmentViewHolder
(
view
,
actionsListener
,
reactionListener
)
}
Base
View
Model
.
ViewType
.
MESSAGE_REPLY
->
{
Base
Ui
Model
.
ViewType
.
MESSAGE_REPLY
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
item_message_reply
)
MessageReplyViewHolder
(
view
,
actionsListener
,
reactionListener
)
{
roomName
,
permalink
->
presenter
?.
openDirectMessage
(
roomName
,
permalink
)
...
...
@@ -104,45 +104,45 @@ class ChatRoomAdapter(
when
(
holder
)
{
is
MessageViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
Message
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
Message
Ui
Model
)
is
ImageAttachmentViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
ImageAttachment
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
ImageAttachment
Ui
Model
)
is
AudioAttachmentViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
AudioAttachment
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
AudioAttachment
Ui
Model
)
is
VideoAttachmentViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
VideoAttachment
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
VideoAttachment
Ui
Model
)
is
UrlPreviewViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
UrlPreview
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
UrlPreview
Ui
Model
)
is
MessageAttachmentViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
MessageAttachment
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
MessageAttachment
Ui
Model
)
is
AuthorAttachmentViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
AuthorAttachment
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
AuthorAttachment
Ui
Model
)
is
ColorAttachmentViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
ColorAttachment
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
ColorAttachment
Ui
Model
)
is
GenericFileAttachmentViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
GenericFileAttachment
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
GenericFileAttachment
Ui
Model
)
is
MessageReplyViewHolder
->
holder
.
bind
(
dataSet
[
position
]
as
MessageReply
View
Model
)
holder
.
bind
(
dataSet
[
position
]
as
MessageReply
Ui
Model
)
}
}
override
fun
getItemId
(
position
:
Int
):
Long
{
val
model
=
dataSet
[
position
]
return
when
(
model
)
{
is
Message
View
Model
->
model
.
messageId
.
hashCode
().
toLong
()
is
BaseFileAttachment
View
Model
->
model
.
id
is
AuthorAttachment
View
Model
->
model
.
id
is
Message
Ui
Model
->
model
.
messageId
.
hashCode
().
toLong
()
is
BaseFileAttachment
Ui
Model
->
model
.
id
is
AuthorAttachment
Ui
Model
->
model
.
id
else
->
return
position
.
toLong
()
}
}
fun
appendData
(
dataSet
:
List
<
Base
View
Model
<*
>>)
{
fun
appendData
(
dataSet
:
List
<
Base
Ui
Model
<*
>>)
{
val
previousDataSetSize
=
this
.
dataSet
.
size
this
.
dataSet
.
addAll
(
dataSet
)
notifyItemChanged
(
previousDataSetSize
,
dataSet
.
size
)
}
fun
prependData
(
dataSet
:
List
<
Base
View
Model
<*
>>)
{
fun
prependData
(
dataSet
:
List
<
Base
Ui
Model
<*
>>)
{
val
item
=
dataSet
.
indexOfFirst
{
newItem
->
this
.
dataSet
.
indexOfFirst
{
it
.
messageId
==
newItem
.
messageId
&&
it
.
viewType
==
newItem
.
viewType
}
>
-
1
}
...
...
@@ -162,7 +162,7 @@ class ChatRoomAdapter(
}
}
fun
updateItem
(
message
:
Base
View
Model
<
*
>)
{
fun
updateItem
(
message
:
Base
Ui
Model
<
*
>)
{
val
index
=
dataSet
.
indexOfLast
{
it
.
messageId
==
message
.
messageId
}
val
indexOfNext
=
dataSet
.
indexOfFirst
{
it
.
messageId
==
message
.
messageId
}
Timber
.
d
(
"index: $index"
)
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/ColorAttachmentViewHolder.kt
View file @
12550250
...
...
@@ -5,7 +5,7 @@ import androidx.core.content.ContextCompat
import
android.text.method.LinkMovementMethod
import
android.view.View
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.
viewmodel.ColorAttachmentView
Model
import
chat.rocket.android.chatroom.
uimodel.ColorAttachmentUi
Model
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
kotlinx.android.synthetic.main.item_color_attachment.view.*
...
...
@@ -13,7 +13,7 @@ import kotlinx.android.synthetic.main.item_color_attachment.view.*
class
ColorAttachmentViewHolder
(
itemView
:
View
,
listener
:
BaseViewHolder
.
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
ColorAttachment
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
:
BaseViewHolder
<
ColorAttachment
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
val
drawable
:
Drawable
?
=
ContextCompat
.
getDrawable
(
itemView
.
context
,
R
.
drawable
.
quote_vertical_bar
)
...
...
@@ -25,7 +25,7 @@ class ColorAttachmentViewHolder(itemView: View,
}
}
override
fun
bindViews
(
data
:
ColorAttachment
View
Model
)
{
override
fun
bindViews
(
data
:
ColorAttachment
Ui
Model
)
{
with
(
itemView
)
{
drawable
?.
let
{
quote_bar
.
background
=
drawable
.
mutate
().
apply
{
setTint
(
data
.
color
)
}
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/CommandSuggestionsAdapter.kt
View file @
12550250
...
...
@@ -6,7 +6,7 @@ import android.view.ViewGroup
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.CommandSuggestionsAdapter.CommandSuggestionsViewHolder
import
chat.rocket.android.chatroom.
viewmodel.suggestion.CommandSuggestionView
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.CommandSuggestionUi
Model
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
import
chat.rocket.android.widget.autocompletion.ui.BaseSuggestionViewHolder
import
chat.rocket.android.widget.autocompletion.ui.SuggestionsAdapter
...
...
@@ -23,7 +23,7 @@ class CommandSuggestionsAdapter : SuggestionsAdapter<CommandSuggestionsViewHolde
class
CommandSuggestionsViewHolder
(
view
:
View
)
:
BaseSuggestionViewHolder
(
view
)
{
override
fun
bind
(
item
:
SuggestionModel
,
itemClickListener
:
SuggestionsAdapter
.
ItemClickListener
?)
{
item
as
CommandSuggestion
View
Model
item
as
CommandSuggestion
Ui
Model
with
(
itemView
)
{
val
nameTextView
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
text_command_name
)
val
descriptionTextView
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
text_command_description
)
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/GenericFileAttachmentViewHolder.kt
View file @
12550250
package
chat.rocket.android.chatroom.adapter
import
android.content.Intent
import
android.net.Uri
import
android.view.View
import
androidx.core.net.toUri
import
chat.rocket.android.chatroom.
viewmodel.GenericFileAttachmentView
Model
import
chat.rocket.android.chatroom.
uimodel.GenericFileAttachmentUi
Model
import
chat.rocket.android.util.extensions.content
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
chat.rocket.common.util.ifNull
import
kotlinx.android.synthetic.main.item_file_attachment.view.*
class
GenericFileAttachmentViewHolder
(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
GenericFileAttachment
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
:
BaseViewHolder
<
GenericFileAttachment
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
init
{
with
(
itemView
)
{
...
...
@@ -21,7 +19,7 @@ class GenericFileAttachmentViewHolder(itemView: View,
}
}
override
fun
bindViews
(
data
:
GenericFileAttachment
View
Model
)
{
override
fun
bindViews
(
data
:
GenericFileAttachment
Ui
Model
)
{
with
(
itemView
)
{
text_file_name
.
content
=
data
.
attachmentTitle
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/ImageAttachmentViewHolder.kt
View file @
12550250
package
chat.rocket.android.chatroom.adapter
import
android.view.View
import
chat.rocket.android.chatroom.
viewmodel.ImageAttachmentView
Model
import
chat.rocket.android.chatroom.
uimodel.ImageAttachmentUi
Model
import
chat.rocket.android.helper.ImageHelper
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
com.facebook.drawee.backends.pipeline.Fresco
...
...
@@ -11,7 +11,7 @@ class ImageAttachmentViewHolder(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
ImageAttachment
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
)
:
BaseViewHolder
<
ImageAttachment
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
init
{
with
(
itemView
)
{
...
...
@@ -19,7 +19,7 @@ class ImageAttachmentViewHolder(
}
}
override
fun
bindViews
(
data
:
ImageAttachment
View
Model
)
{
override
fun
bindViews
(
data
:
ImageAttachment
Ui
Model
)
{
with
(
itemView
)
{
val
controller
=
Fresco
.
newDraweeControllerBuilder
().
apply
{
setUri
(
data
.
attachmentUrl
)
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/MessageAttachmentViewHolder.kt
View file @
12550250
...
...
@@ -2,7 +2,7 @@ package chat.rocket.android.chatroom.adapter
import
android.text.method.LinkMovementMethod
import
android.view.View
import
chat.rocket.android.chatroom.
viewmodel.MessageAttachmentView
Model
import
chat.rocket.android.chatroom.
uimodel.MessageAttachmentUi
Model
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
kotlinx.android.synthetic.main.item_message_attachment.view.*
...
...
@@ -10,7 +10,7 @@ class MessageAttachmentViewHolder(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
MessageAttachment
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
)
:
BaseViewHolder
<
MessageAttachment
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
init
{
with
(
itemView
)
{
...
...
@@ -19,7 +19,7 @@ class MessageAttachmentViewHolder(
}
}
override
fun
bindViews
(
data
:
MessageAttachment
View
Model
)
{
override
fun
bindViews
(
data
:
MessageAttachment
Ui
Model
)
{
with
(
itemView
)
{
text_message_time
.
text
=
data
.
time
text_sender
.
text
=
data
.
senderName
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/MessageReactionsAdapter.kt
View file @
12550250
...
...
@@ -7,7 +7,7 @@ import android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.
viewmodel.ReactionView
Model
import
chat.rocket.android.chatroom.
uimodel.ReactionUi
Model
import
chat.rocket.android.dagger.DaggerLocalComponent
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.widget.emoji.Emoji
...
...
@@ -23,7 +23,7 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
private
const
val
ADD_REACTION_VIEW_TYPE
=
1
}
private
val
reactions
=
CopyOnWriteArrayList
<
Reaction
View
Model
>()
private
val
reactions
=
CopyOnWriteArrayList
<
Reaction
Ui
Model
>()
var
listener
:
EmojiReactionListener
?
=
null
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
RecyclerView
.
ViewHolder
{
...
...
@@ -59,7 +59,7 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
return
REACTION_VIEW_TYPE
}
fun
addReactions
(
reactions
:
List
<
Reaction
View
Model
>)
{
fun
addReactions
(
reactions
:
List
<
Reaction
Ui
Model
>)
{
this
.
reactions
.
clear
()
this
.
reactions
.
addAllAbsent
(
reactions
)
notifyItemRangeInserted
(
0
,
reactions
.
size
)
...
...
@@ -78,7 +78,7 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
private
val
listener
:
EmojiReactionListener
?)
:
RecyclerView
.
ViewHolder
(
view
),
View
.
OnClickListener
{
@Inject
lateinit
var
localRepository
:
LocalRepository
@Volatile
lateinit
var
reaction
:
Reaction
View
Model
@Volatile
lateinit
var
reaction
:
Reaction
Ui
Model
@Volatile
var
clickHandled
=
false
...
...
@@ -89,7 +89,7 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
.
inject
(
this
)
}
fun
bind
(
reaction
:
Reaction
View
Model
)
{
fun
bind
(
reaction
:
Reaction
Ui
Model
)
{
clickHandled
=
false
this
.
reaction
=
reaction
with
(
itemView
)
{
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/MessageReplyViewHolder.kt
View file @
12550250
package
chat.rocket.android.chatroom.adapter
import
android.view.View
import
chat.rocket.android.chatroom.
viewmodel.MessageReplyView
Model
import
chat.rocket.android.chatroom.
uimodel.MessageReplyUi
Model
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
kotlinx.android.synthetic.main.item_message_reply.view.*
...
...
@@ -10,7 +10,7 @@ class MessageReplyViewHolder(
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
,
private
val
replyCallback
:
(
roomName
:
String
,
permalink
:
String
)
->
Unit
)
:
BaseViewHolder
<
MessageReply
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
)
:
BaseViewHolder
<
MessageReply
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
init
{
with
(
itemView
)
{
...
...
@@ -18,7 +18,7 @@ class MessageReplyViewHolder(
}
}
override
fun
bindViews
(
data
:
MessageReply
View
Model
)
{
override
fun
bindViews
(
data
:
MessageReply
Ui
Model
)
{
with
(
itemView
)
{
button_message_reply
.
setOnClickListener
{
with
(
data
.
rawData
)
{
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/MessageViewHolder.kt
View file @
12550250
...
...
@@ -4,8 +4,7 @@ import android.graphics.Color
import
android.text.method.LinkMovementMethod
import
android.view.View
import
androidx.core.view.isVisible
import
chat.rocket.android.chatroom.viewmodel.MessageViewModel
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.chatroom.uimodel.MessageUiModel
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
chat.rocket.core.model.isSystemMessage
import
kotlinx.android.synthetic.main.avatar.view.*
...
...
@@ -15,7 +14,7 @@ class MessageViewHolder(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
Message
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
)
:
BaseViewHolder
<
Message
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
init
{
with
(
itemView
)
{
...
...
@@ -24,7 +23,7 @@ class MessageViewHolder(
}
}
override
fun
bindViews
(
data
:
Message
View
Model
)
{
override
fun
bindViews
(
data
:
Message
Ui
Model
)
{
with
(
itemView
)
{
if
(
data
.
isFirstUnread
)
new_messages_notif
.
visibility
=
View
.
VISIBLE
else
new_messages_notif
.
visibility
=
View
.
GONE
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/PeopleSuggestionsAdapter.kt
View file @
12550250
...
...
@@ -9,7 +9,7 @@ import android.widget.ImageView
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.PeopleSuggestionsAdapter.PeopleSuggestionViewHolder
import
chat.rocket.android.chatroom.
viewmodel.suggestion.PeopleSuggestionView
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.PeopleSuggestionUi
Model
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
import
chat.rocket.android.widget.autocompletion.ui.BaseSuggestionViewHolder
...
...
@@ -22,14 +22,14 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg
val
allDescription
=
context
.
getString
(
R
.
string
.
suggest_all_description
)
val
hereDescription
=
context
.
getString
(
R
.
string
.
suggest_here_description
)
val
pinnedList
=
listOf
(
PeopleSuggestion
View
Model
(
imageUri
=
null
,
PeopleSuggestion
Ui
Model
(
imageUri
=
null
,
text
=
"all"
,
username
=
"all"
,
name
=
allDescription
,
status
=
null
,
pinned
=
false
,
searchList
=
listOf
(
"all"
)),
PeopleSuggestion
View
Model
(
imageUri
=
null
,
PeopleSuggestion
Ui
Model
(
imageUri
=
null
,
text
=
"here"
,
username
=
"here"
,
name
=
hereDescription
,
...
...
@@ -49,7 +49,7 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg
class
PeopleSuggestionViewHolder
(
view
:
View
)
:
BaseSuggestionViewHolder
(
view
)
{
override
fun
bind
(
item
:
SuggestionModel
,
itemClickListener
:
SuggestionsAdapter
.
ItemClickListener
?)
{
item
as
PeopleSuggestion
View
Model
item
as
PeopleSuggestion
Ui
Model
with
(
itemView
)
{
val
username
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
text_username
)
val
name
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
text_name
)
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/RoomSuggestionsAdapter.kt
View file @
12550250
...
...
@@ -6,7 +6,7 @@ import android.view.ViewGroup
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.RoomSuggestionsAdapter.RoomSuggestionsViewHolder
import
chat.rocket.android.chatroom.
viewmodel.suggestion.ChatRoomSuggestionView
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.ChatRoomSuggestionUi
Model
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
import
chat.rocket.android.widget.autocompletion.ui.BaseSuggestionViewHolder
import
chat.rocket.android.widget.autocompletion.ui.SuggestionsAdapter
...
...
@@ -22,7 +22,7 @@ class RoomSuggestionsAdapter : SuggestionsAdapter<RoomSuggestionsViewHolder>("#"
class
RoomSuggestionsViewHolder
(
view
:
View
)
:
BaseSuggestionViewHolder
(
view
)
{
override
fun
bind
(
item
:
SuggestionModel
,
itemClickListener
:
SuggestionsAdapter
.
ItemClickListener
?)
{
item
as
ChatRoomSuggestion
View
Model
item
as
ChatRoomSuggestion
Ui
Model
with
(
itemView
)
{
val
fullname
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
text_fullname
)
val
name
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
text_name
)
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/UrlPreviewViewHolder.kt
View file @
12550250
package
chat.rocket.android.chatroom.adapter
import
android.content.Intent
import
android.net.Uri
import
android.view.View
import
chat.rocket.android.chatroom.
viewmodel.UrlPreviewView
Model
import
chat.rocket.android.chatroom.
uimodel.UrlPreviewUi
Model
import
chat.rocket.android.util.extensions.content
import
chat.rocket.android.util.extensions.openTabbedUrl
import
chat.rocket.android.util.extensions.setVisible
...
...
@@ -13,7 +12,7 @@ import kotlinx.android.synthetic.main.message_url_preview.view.*
class
UrlPreviewViewHolder
(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
UrlPreview
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
:
BaseViewHolder
<
UrlPreview
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
init
{
with
(
itemView
)
{
...
...
@@ -21,7 +20,7 @@ class UrlPreviewViewHolder(itemView: View,
}
}
override
fun
bindViews
(
data
:
UrlPreview
View
Model
)
{
override
fun
bindViews
(
data
:
UrlPreview
Ui
Model
)
{
with
(
itemView
)
{
if
(
data
.
thumbUrl
.
isNullOrEmpty
())
{
image_preview
.
setVisible
(
false
)
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/VideoAttachmentViewHolder.kt
View file @
12550250
package
chat.rocket.android.chatroom.adapter
import
android.view.View
import
chat.rocket.android.chatroom.
viewmodel.VideoAttachmentView
Model
import
chat.rocket.android.chatroom.
uimodel.VideoAttachmentUi
Model
import
chat.rocket.android.player.PlayerActivity
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.widget.emoji.EmojiReactionListener
...
...
@@ -10,7 +10,7 @@ import kotlinx.android.synthetic.main.message_attachment.view.*
class
VideoAttachmentViewHolder
(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
VideoAttachment
View
Model
>(
itemView
,
listener
,
reactionListener
)
{
:
BaseViewHolder
<
VideoAttachment
Ui
Model
>(
itemView
,
listener
,
reactionListener
)
{
init
{
with
(
itemView
)
{
...
...
@@ -20,7 +20,7 @@ class VideoAttachmentViewHolder(itemView: View,
}
}
override
fun
bindViews
(
data
:
VideoAttachment
View
Model
)
{
override
fun
bindViews
(
data
:
VideoAttachment
Ui
Model
)
{
with
(
itemView
)
{
file_name
.
text
=
data
.
attachmentTitle
audio_video_attachment
.
setOnClickListener
{
view
->
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
12550250
...
...
@@ -6,11 +6,11 @@ import chat.rocket.android.chatroom.adapter.AutoCompleteType
import
chat.rocket.android.chatroom.adapter.PEOPLE
import
chat.rocket.android.chatroom.adapter.ROOMS
import
chat.rocket.android.chatroom.domain.UriInteractor
import
chat.rocket.android.chatroom.
viewmodel.RoomView
Model
import
chat.rocket.android.chatroom.
viewmodel.View
ModelMapper
import
chat.rocket.android.chatroom.
viewmodel.suggestion.ChatRoomSuggestionView
Model
import
chat.rocket.android.chatroom.
viewmodel.suggestion.CommandSuggestionView
Model
import
chat.rocket.android.chatroom.
viewmodel.suggestion.PeopleSuggestionView
Model
import
chat.rocket.android.chatroom.
uimodel.RoomUi
Model
import
chat.rocket.android.chatroom.
uimodel.Ui
ModelMapper
import
chat.rocket.android.chatroom.
uimodel.suggestion.ChatRoomSuggestionUi
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.CommandSuggestionUi
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.PeopleSuggestionUi
Model
import
chat.rocket.android.core.behaviours.showMessage
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.MessageHelper
...
...
@@ -88,7 +88,7 @@ class ChatRoomPresenter @Inject constructor(
private
val
roomsRepository
:
RoomRepository
,
private
val
localRepository
:
LocalRepository
,
private
val
userHelper
:
UserHelper
,
private
val
mapper
:
View
ModelMapper
,
private
val
mapper
:
Ui
ModelMapper
,
private
val
jobSchedulerInteractor
:
JobSchedulerInteractor
,
private
val
messageHelper
:
MessageHelper
,
getSettingsInteractor
:
GetSettingsInteractor
,
...
...
@@ -152,7 +152,7 @@ class ChatRoomPresenter @Inject constructor(
try
{
if
(
offset
==
0L
)
{
val
localMessages
=
messagesRepository
.
getByRoomId
(
chatRoomId
)
val
oldMessages
=
mapper
.
map
(
localMessages
,
Room
View
Model
(
roles
=
chatRoles
,
val
oldMessages
=
mapper
.
map
(
localMessages
,
Room
Ui
Model
(
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
,
isRoom
=
true
))
if
(
oldMessages
.
isNotEmpty
())
{
view
.
showMessages
(
oldMessages
)
...
...
@@ -191,7 +191,7 @@ class ChatRoomPresenter @Inject constructor(
client
.
messages
(
chatRoomId
,
roomTypeOf
(
chatRoomType
),
offset
,
30
).
result
}
messagesRepository
.
saveAll
(
messages
)
view
.
showMessages
(
mapper
.
map
(
messages
,
Room
View
Model
(
roles
=
chatRoles
,
view
.
showMessages
(
mapper
.
map
(
messages
,
Room
Ui
Model
(
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
,
isRoom
=
true
)))
}
...
...
@@ -227,7 +227,7 @@ class ChatRoomPresenter @Inject constructor(
)
try
{
messagesRepository
.
save
(
newMessage
)
view
.
showNewMessage
(
mapper
.
map
(
newMessage
,
Room
View
Model
(
view
.
showNewMessage
(
mapper
.
map
(
newMessage
,
Room
Ui
Model
(
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
)))
client
.
sendMessage
(
id
,
chatRoomId
,
text
)
}
catch
(
ex
:
Exception
)
{
...
...
@@ -369,7 +369,7 @@ class ChatRoomPresenter @Inject constructor(
Timber
.
d
(
"History: $messages"
)
if
(
messages
.
result
.
isNotEmpty
())
{
val
models
=
mapper
.
map
(
messages
.
result
,
Room
View
Model
(
val
models
=
mapper
.
map
(
messages
.
result
,
Room
Ui
Model
(
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
,
isRoom
=
true
))
messagesRepository
.
saveAll
(
messages
.
result
)
...
...
@@ -451,7 +451,7 @@ class ChatRoomPresenter @Inject constructor(
view
.
showReplyingAction
(
username
=
getDisplayName
(
msg
.
sender
),
replyMarkdown
=
"[ ]($currentServer/$chatRoomType/$room?msg=$id) $mention "
,
quotedMessage
=
mapper
.
map
(
message
,
Room
View
Model
(
roles
=
chatRoles
,
quotedMessage
=
mapper
.
map
(
message
,
Room
Ui
Model
(
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
)).
last
().
preview
?.
message
?:
""
)
}
...
...
@@ -564,7 +564,7 @@ class ChatRoomPresenter @Inject constructor(
// Take at most the 100 most recent messages distinguished by user. Can return less.
val
recentMessages
=
messagesRepository
.
getRecentMessages
(
chatRoomId
,
100
)
.
filterNot
{
filterSelfOut
&&
it
.
sender
?.
username
==
self
}
val
activeUsers
=
mutableListOf
<
PeopleSuggestion
View
Model
>()
val
activeUsers
=
mutableListOf
<
PeopleSuggestion
Ui
Model
>()
recentMessages
.
forEach
{
val
sender
=
it
.
sender
!!
val
username
=
sender
.
username
?:
""
...
...
@@ -573,7 +573,7 @@ class ChatRoomPresenter @Inject constructor(
val
found
=
members
.
firstOrNull
{
member
->
member
.
username
==
username
}
val
status
=
if
(
found
!=
null
)
found
.
status
else
UserStatus
.
Offline
()
val
searchList
=
mutableListOf
(
username
,
name
)
activeUsers
.
add
(
PeopleSuggestion
View
Model
(
avatarUrl
,
username
,
username
,
name
,
status
,
activeUsers
.
add
(
PeopleSuggestion
Ui
Model
(
avatarUrl
,
username
,
username
,
name
,
status
,
true
,
searchList
))
}
// Filter out from members list the active users.
...
...
@@ -588,7 +588,7 @@ class ChatRoomPresenter @Inject constructor(
val
name
=
it
.
name
?:
""
val
avatarUrl
=
currentServer
.
avatarUrl
(
username
)
val
searchList
=
mutableListOf
(
username
,
name
)
PeopleSuggestion
View
Model
(
avatarUrl
,
username
,
username
,
name
,
it
.
status
,
true
,
searchList
)
PeopleSuggestion
Ui
Model
(
avatarUrl
,
username
,
username
,
name
,
it
.
status
,
true
,
searchList
)
})
view
.
populatePeopleSuggestions
(
activeUsers
)
...
...
@@ -613,14 +613,8 @@ class ChatRoomPresenter @Inject constructor(
val
name
=
it
.
name
?:
""
val
searchList
=
mutableListOf
(
username
,
name
)
it
.
emails
?.
forEach
{
email
->
searchList
.
add
(
email
.
address
)
}
PeopleSuggestionViewModel
(
currentServer
.
avatarUrl
(
username
),
username
,
username
,
name
,
it
.
status
,
false
,
searchList
)
PeopleSuggestionUiModel
(
currentServer
.
avatarUrl
(
username
),
username
,
username
,
name
,
it
.
status
,
false
,
searchList
)
}.
filterNot
{
filterSelfOut
&&
self
!=
null
&&
self
==
it
.
text
})
}
ROOMS
->
{
...
...
@@ -631,7 +625,7 @@ class ChatRoomPresenter @Inject constructor(
val
fullName
=
it
.
fullName
?:
""
val
name
=
it
.
name
?:
""
val
searchList
=
mutableListOf
(
fullName
,
name
)
ChatRoomSuggestion
View
Model
(
name
,
fullName
,
name
,
searchList
)
ChatRoomSuggestion
Ui
Model
(
name
,
fullName
,
name
,
searchList
)
})
}
}
...
...
@@ -663,7 +657,7 @@ class ChatRoomPresenter @Inject constructor(
.
map
{
chatRoom
->
val
name
=
chatRoom
.
name
val
fullName
=
chatRoom
.
fullName
?:
""
ChatRoomSuggestion
View
Model
(
ChatRoomSuggestion
Ui
Model
(
text
=
name
,
name
=
name
,
fullName
=
fullName
,
...
...
@@ -742,7 +736,7 @@ class ChatRoomPresenter @Inject constructor(
client
.
commands
(
0
,
100
).
result
}
view
.
populateCommandSuggestions
(
commands
.
map
{
CommandSuggestion
View
Model
(
it
.
command
,
it
.
description
?:
""
,
listOf
(
it
.
command
))
CommandSuggestion
Ui
Model
(
it
.
command
,
it
.
description
?:
""
,
listOf
(
it
.
command
))
})
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
...
...
@@ -840,7 +834,7 @@ class ChatRoomPresenter @Inject constructor(
private
fun
updateMessage
(
streamedMessage
:
Message
)
{
launchUI
(
strategy
)
{
val
viewModelStreamedMessage
=
mapper
.
map
(
streamedMessage
,
Room
View
Model
(
val
viewModelStreamedMessage
=
mapper
.
map
(
streamedMessage
,
Room
Ui
Model
(
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
))
val
roomMessages
=
messagesRepository
.
getByRoomId
(
streamedMessage
.
roomId
)
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomView.kt
View file @
12550250
package
chat.rocket.android.chatroom.presentation
import
android.net.Uri
import
chat.rocket.android.chatroom.
viewmodel.BaseView
Model
import
chat.rocket.android.chatroom.
viewmodel.suggestion.ChatRoomSuggestionView
Model
import
chat.rocket.android.chatroom.
viewmodel.suggestion.CommandSuggestionView
Model
import
chat.rocket.android.chatroom.
viewmodel.suggestion.PeopleSuggestionView
Model
import
chat.rocket.android.chatroom.
uimodel.BaseUi
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.ChatRoomSuggestionUi
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.CommandSuggestionUi
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.PeopleSuggestionUi
Model
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.core.internal.realtime.socket.model.State
...
...
@@ -17,7 +17,7 @@ interface ChatRoomView : LoadingView, MessageView {
*
* @param dataSet The data set to show.
*/
fun
showMessages
(
dataSet
:
List
<
Base
View
Model
<*
>>)
fun
showMessages
(
dataSet
:
List
<
Base
Ui
Model
<*
>>)
/**
* Send a message to a chat room.
...
...
@@ -60,7 +60,7 @@ interface ChatRoomView : LoadingView, MessageView {
*
* @param message The (recent) message sent to a chat room.
*/
fun
showNewMessage
(
message
:
List
<
Base
View
Model
<*
>>)
fun
showNewMessage
(
message
:
List
<
Base
Ui
Model
<*
>>)
/**
* Dispatch to the recycler views adapter that we should remove a message.
...
...
@@ -74,7 +74,7 @@ interface ChatRoomView : LoadingView, MessageView {
*
* @param index The index of the changed message
*/
fun
dispatchUpdateMessage
(
index
:
Int
,
message
:
List
<
Base
View
Model
<*
>>)
fun
dispatchUpdateMessage
(
index
:
Int
,
message
:
List
<
Base
Ui
Model
<*
>>)
/**
* Show reply status above the message composer.
...
...
@@ -117,9 +117,9 @@ interface ChatRoomView : LoadingView, MessageView {
fun
showConnectionState
(
state
:
State
)
fun
populatePeopleSuggestions
(
members
:
List
<
PeopleSuggestion
View
Model
>)
fun
populatePeopleSuggestions
(
members
:
List
<
PeopleSuggestion
Ui
Model
>)
fun
populateRoomSuggestions
(
chatRooms
:
List
<
ChatRoomSuggestion
View
Model
>)
fun
populateRoomSuggestions
(
chatRooms
:
List
<
ChatRoomSuggestion
Ui
Model
>)
/**
* This user has joined the chat callback.
*
...
...
@@ -134,7 +134,7 @@ interface ChatRoomView : LoadingView, MessageView {
*
* @param commands The list of available commands.
*/
fun
populateCommandSuggestions
(
commands
:
List
<
CommandSuggestion
View
Model
>)
fun
populateCommandSuggestions
(
commands
:
List
<
CommandSuggestion
Ui
Model
>)
/**
* Communicate whether it's a broadcast channel and if current user can post to it.
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
12550250
...
...
@@ -21,15 +21,24 @@ import chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.*
import
chat.rocket.android.chatroom.presentation.ChatRoomPresenter
import
chat.rocket.android.chatroom.presentation.ChatRoomView
import
chat.rocket.android.chatroom.
viewmodel.BaseView
Model
import
chat.rocket.android.chatroom.
viewmodel.MessageView
Model
import
chat.rocket.android.chatroom.
viewmodel.suggestion.ChatRoomSuggestionView
Model
import
chat.rocket.android.chatroom.
viewmodel.suggestion.CommandSuggestionView
Model
import
chat.rocket.android.chatroom.
viewmodel.suggestion.PeopleSuggestionView
Model
import
chat.rocket.android.chatroom.
uimodel.BaseUi
Model
import
chat.rocket.android.chatroom.
uimodel.MessageUi
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.ChatRoomSuggestionUi
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.CommandSuggestionUi
Model
import
chat.rocket.android.chatroom.
uimodel.suggestion.PeopleSuggestionUi
Model
import
chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.helper.MessageParser
import
chat.rocket.android.util.extensions.*
import
chat.rocket.android.util.extensions.asObservable
import
chat.rocket.android.util.extensions.circularRevealOrUnreveal
import
chat.rocket.android.util.extensions.fadeIn
import
chat.rocket.android.util.extensions.fadeOut
import
chat.rocket.android.util.extensions.hideKeyboard
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.rotateBy
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.textContent
import
chat.rocket.android.util.extensions.ui
import
chat.rocket.android.widget.emoji.*
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.roomTypeOf
...
...
@@ -220,26 +229,26 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
return
true
}
override
fun
showMessages
(
dataSet
:
List
<
Base
View
Model
<*
>>)
{
override
fun
showMessages
(
dataSet
:
List
<
Base
Ui
Model
<*
>>)
{
ui
{
// track the message sent immediately after the current message
var
prevMessage
ViewModel
:
MessageView
Model
?
=
null
var
prevMessage
UiModel
:
MessageUi
Model
?
=
null
// Loop over received messages to determine first unread
for
(
i
in
dataSet
.
indices
)
{
val
msgModel
=
dataSet
[
i
]
if
(
msgModel
is
Message
View
Model
)
{
if
(
msgModel
is
Message
Ui
Model
)
{
val
msg
=
msgModel
.
rawData
if
(
msg
.
timestamp
<
chatRoomLastSeen
)
{
// This message was sent before the last seen of the room. Hence, it was seen.
// if there is a message after (below) this, mark it firstUnread.
if
(
prevMessage
View
Model
!=
null
)
{
prevMessage
View
Model
.
isFirstUnread
=
true
if
(
prevMessage
Ui
Model
!=
null
)
{
prevMessage
Ui
Model
.
isFirstUnread
=
true
}
break
}
prevMessage
View
Model
=
msgModel
prevMessage
Ui
Model
=
msgModel
}
}
...
...
@@ -395,7 +404,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
showMessage
(
getString
(
R
.
string
.
msg_invalid_file
))
}
override
fun
showNewMessage
(
message
:
List
<
Base
View
Model
<*
>>)
{
override
fun
showNewMessage
(
message
:
List
<
Base
Ui
Model
<*
>>)
{
ui
{
adapter
.
prependData
(
message
)
recycler_view
.
scrollToPosition
(
0
)
...
...
@@ -428,7 +437,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
dispatchUpdateMessage
(
index
:
Int
,
message
:
List
<
Base
View
Model
<*
>>)
{
override
fun
dispatchUpdateMessage
(
index
:
Int
,
message
:
List
<
Base
Ui
Model
<*
>>)
{
ui
{
adapter
.
updateItem
(
message
.
last
())
if
(
message
.
size
>
1
)
{
...
...
@@ -458,11 +467,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
override
fun
showLoading
()
{
ui
{
view_loading
.
setVisible
(
true
)
}
ui
{
view_loading
.
isVisible
=
true
}
}
override
fun
hideLoading
()
{
ui
{
view_loading
.
setVisible
(
false
)
}
ui
{
view_loading
.
isVisible
=
false
}
}
override
fun
showMessage
(
message
:
String
)
{
...
...
@@ -479,19 +488,19 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
override
fun
populatePeopleSuggestions
(
members
:
List
<
PeopleSuggestion
View
Model
>)
{
override
fun
populatePeopleSuggestions
(
members
:
List
<
PeopleSuggestion
Ui
Model
>)
{
ui
{
suggestions_view
.
addItems
(
"@"
,
members
)
}
}
override
fun
populateRoomSuggestions
(
chatRooms
:
List
<
ChatRoomSuggestion
View
Model
>)
{
override
fun
populateRoomSuggestions
(
chatRooms
:
List
<
ChatRoomSuggestion
Ui
Model
>)
{
ui
{
suggestions_view
.
addItems
(
"#"
,
chatRooms
)
}
}
override
fun
populateCommandSuggestions
(
commands
:
List
<
CommandSuggestion
View
Model
>)
{
override
fun
populateCommandSuggestions
(
commands
:
List
<
CommandSuggestion
Ui
Model
>)
{
ui
{
suggestions_view
.
addItems
(
"/"
,
commands
)
}
...
...
@@ -603,8 +612,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
onJoined
(
userCanPost
:
Boolean
)
{
ui
{
input_container
.
setVisible
(
true
)
button_join_chat
.
setVisible
(
false
)
input_container
.
isVisible
=
true
button_join_chat
.
isVisible
=
false
isSubscribed
=
true
setupMessageComposer
(
userCanPost
)
}
...
...
@@ -639,16 +648,16 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
private
fun
setupMessageComposer
(
canPost
:
Boolean
)
{
if
(
isChatRoomReadOnly
&&
!
canPost
)
{
text_room_is_read_only
.
setVisible
(
true
)
input_container
.
setVisible
(
false
)
text_room_is_read_only
.
isVisible
=
true
input_container
.
isVisible
=
false
}
else
if
(!
isSubscribed
&&
roomTypeOf
(
chatRoomType
)
!
is
RoomType
.
DirectMessage
)
{
input_container
.
setVisible
(
false
)
button_join_chat
.
setVisible
(
true
)
input_container
.
isVisible
=
false
button_join_chat
.
isVisible
=
true
button_join_chat
.
setOnClickListener
{
presenter
.
joinChat
(
chatRoomId
)
}
}
else
{
button_send
.
setVisible
(
false
)
button_send
.
isVisible
=
false
button_show_attachment_options
.
alpha
=
1f
button_show_attachment_options
.
setVisible
(
true
)
button_show_attachment_options
.
isVisible
=
true
subscribeComposeTextMessage
()
emojiKeyboardPopup
=
...
...
@@ -781,14 +790,14 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
private
fun
setupComposeButtons
(
charSequence
:
CharSequence
)
{
if
(
charSequence
.
isNotEmpty
()
&&
playComposeMessageButtonsAnimation
)
{
button_show_attachment_options
.
setVisible
(
false
)
button_send
.
setVisible
(
true
)
button_show_attachment_options
.
isVisible
=
false
button_send
.
isVisible
=
true
playComposeMessageButtonsAnimation
=
false
}
if
(
charSequence
.
isEmpty
())
{
button_send
.
setVisible
(
false
)
button_show_attachment_options
.
setVisible
(
true
)
button_send
.
isVisible
=
false
button_show_attachment_options
.
isVisible
=
true
playComposeMessageButtonsAnimation
=
true
}
}
...
...
@@ -802,7 +811,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
private
fun
showAttachmentOptions
()
{
view_dim
.
setVisible
(
true
)
view_dim
.
isVisible
=
true
// Play anim.
button_show_attachment_options
.
rotateBy
(
45F
)
...
...
@@ -814,7 +823,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
button_show_attachment_options
.
rotateBy
(-
45F
)
layout_message_attachment_options
.
circularRevealOrUnreveal
(
centerX
,
centerY
,
max
,
0F
)
view_dim
.
setVisible
(
false
)
view_dim
.
isVisible
=
false
}
private
fun
setupToolbar
(
toolbarTitle
:
String
)
{
...
...
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/AudioAttachmentView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/AudioAttachmentUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.attachment.AudioAttachment
data class
AudioAttachment
View
Model
(
data class
AudioAttachment
Ui
Model
(
override
val
message
:
Message
,
override
val
rawData
:
AudioAttachment
,
override
val
messageId
:
String
,
override
val
attachmentUrl
:
String
,
override
val
attachmentTitle
:
CharSequence
,
override
val
id
:
Long
,
override
var
reactions
:
List
<
Reaction
View
Model
>,
override
var
nextDownStreamMessage
:
Base
View
Model
<*>?
=
null
,
override
var
reactions
:
List
<
Reaction
Ui
Model
>,
override
var
nextDownStreamMessage
:
Base
Ui
Model
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
)
:
BaseFileAttachment
View
Model
<
AudioAttachment
>
{
)
:
BaseFileAttachment
Ui
Model
<
AudioAttachment
>
{
override
val
viewType
:
Int
get
()
=
Base
View
Model
.
ViewType
.
AUDIO_ATTACHMENT
.
viewType
get
()
=
Base
Ui
Model
.
ViewType
.
AUDIO_ATTACHMENT
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
message_attachment
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/AuthorAttachmentView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/AuthorAttachmentUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.attachment.AuthorAttachment
data class
AuthorAttachment
View
Model
(
data class
AuthorAttachment
Ui
Model
(
override
val
attachmentUrl
:
String
,
val
id
:
Long
,
val
name
:
CharSequence
?,
...
...
@@ -13,13 +13,13 @@ data class AuthorAttachmentViewModel(
override
val
message
:
Message
,
override
val
rawData
:
AuthorAttachment
,
override
val
messageId
:
String
,
override
var
reactions
:
List
<
Reaction
View
Model
>,
override
var
nextDownStreamMessage
:
Base
View
Model
<*>?
=
null
,
override
var
reactions
:
List
<
Reaction
Ui
Model
>,
override
var
nextDownStreamMessage
:
Base
Ui
Model
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
)
:
BaseAttachment
View
Model
<
AuthorAttachment
>
{
)
:
BaseAttachment
Ui
Model
<
AuthorAttachment
>
{
override
val
viewType
:
Int
get
()
=
Base
View
Model
.
ViewType
.
AUTHOR_ATTACHMENT
.
viewType
get
()
=
Base
Ui
Model
.
ViewType
.
AUTHOR_ATTACHMENT
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
item_author_attachment
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/uimodel/BaseAttachmentUiModel.kt
0 → 100644
View file @
12550250
package
chat.rocket.android.chatroom.uimodel
interface
BaseAttachmentUiModel
<
out
T
>
:
BaseUiModel
<
T
>
{
val
attachmentUrl
:
String
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/BaseFileAttachmentView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/BaseFileAttachmentUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
interface
BaseFileAttachment
ViewModel
<
out
T
>
:
BaseAttachmentView
Model
<
T
>
{
interface
BaseFileAttachment
UiModel
<
out
T
>
:
BaseAttachmentUi
Model
<
T
>
{
val
attachmentTitle
:
CharSequence
val
id
:
Long
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/BaseMessageView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/BaseMessageUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
interface
BaseMessage
ViewModel
<
out
T
>
:
BaseView
Model
<
T
>
{
interface
BaseMessage
UiModel
<
out
T
>
:
BaseUi
Model
<
T
>
{
val
avatar
:
String
val
time
:
CharSequence
val
senderName
:
CharSequence
...
...
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/BaseView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/BaseUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.core.model.Message
import
java.security.InvalidParameterException
interface
Base
View
Model
<
out
T
>
{
interface
Base
Ui
Model
<
out
T
>
{
val
message
:
Message
val
rawData
:
T
val
messageId
:
String
val
viewType
:
Int
val
layoutId
:
Int
var
reactions
:
List
<
Reaction
View
Model
>
var
nextDownStreamMessage
:
Base
View
Model
<*>?
var
reactions
:
List
<
Reaction
Ui
Model
>
var
nextDownStreamMessage
:
Base
Ui
Model
<*>?
var
preview
:
Message
?
var
isTemporary
:
Boolean
...
...
@@ -29,7 +29,7 @@ interface BaseViewModel<out T> {
}
}
internal
fun
Int
.
toViewType
():
Base
View
Model
.
ViewType
{
return
Base
View
Model
.
ViewType
.
values
().
firstOrNull
{
it
.
viewType
==
this
}
?:
throw
InvalidParameterException
(
"Invalid viewType: $this for Base
View
Model.ViewType"
)
internal
fun
Int
.
toViewType
():
Base
Ui
Model
.
ViewType
{
return
Base
Ui
Model
.
ViewType
.
values
().
firstOrNull
{
it
.
viewType
==
this
}
?:
throw
InvalidParameterException
(
"Invalid viewType: $this for Base
Ui
Model.ViewType"
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/uimodel/ColorAttachmentUiModel.kt
0 → 100644
View file @
12550250
package
chat.rocket.android.chatroom.uimodel
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.attachment.ColorAttachment
data class
ColorAttachmentUiModel
(
override
val
attachmentUrl
:
String
,
val
id
:
Long
,
val
color
:
Int
,
val
text
:
CharSequence
,
override
val
message
:
Message
,
override
val
rawData
:
ColorAttachment
,
override
val
messageId
:
String
,
override
var
reactions
:
List
<
ReactionUiModel
>,
override
var
nextDownStreamMessage
:
BaseUiModel
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
)
:
BaseAttachmentUiModel
<
ColorAttachment
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
COLOR_ATTACHMENT
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
item_color_attachment
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/GenericFileAttachmentView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/GenericFileAttachmentUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.attachment.GenericFileAttachment
import
chat.rocket.core.model.attachment.ImageAttachment
data class
GenericFileAttachment
View
Model
(
data class
GenericFileAttachment
Ui
Model
(
override
val
message
:
Message
,
override
val
rawData
:
GenericFileAttachment
,
override
val
messageId
:
String
,
override
val
attachmentUrl
:
String
,
override
val
attachmentTitle
:
CharSequence
,
override
val
id
:
Long
,
override
var
reactions
:
List
<
Reaction
View
Model
>,
override
var
nextDownStreamMessage
:
Base
View
Model
<*>?
=
null
,
override
var
reactions
:
List
<
Reaction
Ui
Model
>,
override
var
nextDownStreamMessage
:
Base
Ui
Model
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
)
:
BaseFileAttachment
View
Model
<
GenericFileAttachment
>
{
)
:
BaseFileAttachment
Ui
Model
<
GenericFileAttachment
>
{
override
val
viewType
:
Int
get
()
=
Base
View
Model
.
ViewType
.
GENERIC_FILE_ATTACHMENT
.
viewType
get
()
=
Base
Ui
Model
.
ViewType
.
GENERIC_FILE_ATTACHMENT
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
item_file_attachment
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/ImageAttachmentView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/ImageAttachmentUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.attachment.ImageAttachment
data class
ImageAttachment
View
Model
(
data class
ImageAttachment
Ui
Model
(
override
val
message
:
Message
,
override
val
rawData
:
ImageAttachment
,
override
val
messageId
:
String
,
override
val
attachmentUrl
:
String
,
override
val
attachmentTitle
:
CharSequence
,
override
val
id
:
Long
,
override
var
reactions
:
List
<
Reaction
View
Model
>,
override
var
nextDownStreamMessage
:
Base
View
Model
<*>?
=
null
,
override
var
reactions
:
List
<
Reaction
Ui
Model
>,
override
var
nextDownStreamMessage
:
Base
Ui
Model
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
)
:
BaseFileAttachment
View
Model
<
ImageAttachment
>
{
)
:
BaseFileAttachment
Ui
Model
<
ImageAttachment
>
{
override
val
viewType
:
Int
get
()
=
Base
View
Model
.
ViewType
.
IMAGE_ATTACHMENT
.
viewType
get
()
=
Base
Ui
Model
.
ViewType
.
IMAGE_ATTACHMENT
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
message_attachment
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/MessageAttachmentView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/MessageAttachmentUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
data class
MessageAttachment
View
Model
(
data class
MessageAttachment
Ui
Model
(
override
val
message
:
Message
,
override
val
rawData
:
Message
,
override
val
messageId
:
String
,
...
...
@@ -11,14 +11,14 @@ data class MessageAttachmentViewModel(
val
time
:
CharSequence
?,
val
content
:
CharSequence
,
val
isPinned
:
Boolean
,
override
var
reactions
:
List
<
Reaction
View
Model
>,
override
var
nextDownStreamMessage
:
Base
View
Model
<*>?
=
null
,
override
var
reactions
:
List
<
Reaction
Ui
Model
>,
override
var
nextDownStreamMessage
:
Base
Ui
Model
<*>?
=
null
,
var
messageLink
:
String
?
=
null
,
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
)
:
Base
View
Model
<
Message
>
{
)
:
Base
Ui
Model
<
Message
>
{
override
val
viewType
:
Int
get
()
=
Base
View
Model
.
ViewType
.
MESSAGE_ATTACHMENT
.
viewType
get
()
=
Base
Ui
Model
.
ViewType
.
MESSAGE_ATTACHMENT
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
item_message_attachment
...
...
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/MessageReplyView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/MessageReplyUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.domain.MessageReply
import
chat.rocket.core.model.Message
data class
MessageReply
View
Model
(
override
val
rawData
:
MessageReply
,
override
val
messageId
:
String
,
override
var
reactions
:
List
<
ReactionView
Model
>,
override
var
nextDownStreamMessage
:
BaseView
Model
<*>?,
override
var
preview
:
Message
?,
override
var
isTemporary
:
Boolean
=
false
,
override
val
message
:
Message
)
:
Base
View
Model
<
MessageReply
>
{
data class
MessageReply
Ui
Model
(
override
val
rawData
:
MessageReply
,
override
val
messageId
:
String
,
override
var
reactions
:
List
<
ReactionUi
Model
>,
override
var
nextDownStreamMessage
:
BaseUi
Model
<*>?,
override
var
preview
:
Message
?,
override
var
isTemporary
:
Boolean
=
false
,
override
val
message
:
Message
)
:
Base
Ui
Model
<
MessageReply
>
{
override
val
viewType
:
Int
get
()
=
Base
View
Model
.
ViewType
.
MESSAGE_REPLY
.
viewType
get
()
=
Base
Ui
Model
.
ViewType
.
MESSAGE_REPLY
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
item_message_reply
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/uimodel/MessageUiModel.kt
0 → 100644
View file @
12550250
package
chat.rocket.android.chatroom.uimodel
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
data class
MessageUiModel
(
override
val
message
:
Message
,
override
val
rawData
:
Message
,
override
val
messageId
:
String
,
override
val
avatar
:
String
,
override
val
time
:
CharSequence
,
override
val
senderName
:
CharSequence
,
override
val
content
:
CharSequence
,
override
val
isPinned
:
Boolean
,
override
var
reactions
:
List
<
ReactionUiModel
>,
override
var
nextDownStreamMessage
:
BaseUiModel
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
var
isFirstUnread
:
Boolean
,
override
var
isTemporary
:
Boolean
=
false
)
:
BaseMessageUiModel
<
Message
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
MESSAGE
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
item_message
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/ReactionView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/ReactionUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
data class
Reaction
View
Model
(
data class
Reaction
Ui
Model
(
val
messageId
:
String
,
val
shortname
:
String
,
val
unicode
:
CharSequence
,
...
...
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/RoomView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/RoomUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.core.model.ChatRoomRole
data class
Room
View
Model
(
data class
Room
Ui
Model
(
val
roles
:
List
<
ChatRoomRole
>,
val
isBroadcast
:
Boolean
=
false
,
val
isRoom
:
Boolean
=
false
...
...
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/View
ModelMapper.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/Ui
ModelMapper.kt
View file @
12550250
This diff is collapsed.
Click to expand it.
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/UrlPreviewView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/UrlPreviewUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.url.Url
data class
UrlPreview
View
Model
(
data class
UrlPreview
Ui
Model
(
override
val
message
:
Message
,
override
val
rawData
:
Url
,
override
val
messageId
:
String
,
...
...
@@ -12,13 +12,13 @@ data class UrlPreviewViewModel(
val
hostname
:
String
,
val
description
:
CharSequence
?,
val
thumbUrl
:
String
?,
override
var
reactions
:
List
<
Reaction
View
Model
>,
override
var
nextDownStreamMessage
:
Base
View
Model
<*>?
=
null
,
override
var
reactions
:
List
<
Reaction
Ui
Model
>,
override
var
nextDownStreamMessage
:
Base
Ui
Model
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
)
:
Base
View
Model
<
Url
>
{
)
:
Base
Ui
Model
<
Url
>
{
override
val
viewType
:
Int
get
()
=
Base
View
Model
.
ViewType
.
URL_PREVIEW
.
viewType
get
()
=
Base
Ui
Model
.
ViewType
.
URL_PREVIEW
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
message_url_preview
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/
viewmodel/VideoAttachmentView
Model.kt
→
app/src/main/java/chat/rocket/android/chatroom/
uimodel/VideoAttachmentUi
Model.kt
View file @
12550250
package
chat.rocket.android.chatroom.
view
model
package
chat.rocket.android.chatroom.
ui
model
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.attachment.VideoAttachment
data class
VideoAttachment
View
Model
(
data class
VideoAttachment
Ui
Model
(
override
val
message
:
Message
,
override
val
rawData
:
VideoAttachment
,
override
val
messageId
:
String
,
override
val
attachmentUrl
:
String
,
override
val
attachmentTitle
:
CharSequence
,
override
val
id
:
Long
,
override
var
reactions
:
List
<
Reaction
View
Model
>,
override
var
nextDownStreamMessage
:
Base
View
Model
<*>?
=
null
,
override
var
reactions
:
List
<
Reaction
Ui
Model
>,
override
var
nextDownStreamMessage
:
Base
Ui
Model
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
)
:
BaseFileAttachment
View
Model
<
VideoAttachment
>
{
)
:
BaseFileAttachment
Ui
Model
<
VideoAttachment
>
{
override
val
viewType
:
Int
get
()
=
Base
View
Model
.
ViewType
.
VIDEO_ATTACHMENT
.
viewType
get
()
=
Base
Ui
Model
.
ViewType
.
VIDEO_ATTACHMENT
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
message_attachment
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/uimodel/suggestion/ChatRoomSuggestionUiModel.kt
0 → 100644
View file @
12550250
package
chat.rocket.android.chatroom.uimodel.suggestion
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
class
ChatRoomSuggestionUiModel
(
text
:
String
,
val
fullName
:
String
,
val
name
:
String
,
searchList
:
List
<
String
>)
:
SuggestionModel
(
text
,
searchList
,
false
)
{
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/uimodel/suggestion/CommandSuggestionUiModel.kt
0 → 100644
View file @
12550250
package
chat.rocket.android.chatroom.uimodel.suggestion
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
class
CommandSuggestionUiModel
(
text
:
String
,
val
description
:
String
,
searchList
:
List
<
String
>)
:
SuggestionModel
(
text
,
searchList
)
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/uimodel/suggestion/PeopleSuggestionUiModel.kt
0 → 100644
View file @
12550250
package
chat.rocket.android.chatroom.uimodel.suggestion
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
import
chat.rocket.common.model.UserStatus
class
PeopleSuggestionUiModel
(
val
imageUri
:
String
?,
text
:
String
,
val
username
:
String
,
val
name
:
String
,
val
status
:
UserStatus
?,
pinned
:
Boolean
=
false
,
searchList
:
List
<
String
>)
:
SuggestionModel
(
text
,
searchList
,
pinned
)
{
override
fun
toString
():
String
{
return
"PeopleSuggestionUiModel(imageUri='$imageUri', username='$username', name='$name', status=$status, pinned=$pinned)"
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/viewmodel/BaseAttachmentViewModel.kt
deleted
100644 → 0
View file @
60009b87
package
chat.rocket.android.chatroom.viewmodel
interface
BaseAttachmentViewModel
<
out
T
>
:
BaseViewModel
<
T
>
{
val
attachmentUrl
:
String
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/viewmodel/ColorAttachmentViewModel.kt
deleted
100644 → 0
View file @
60009b87
package
chat.rocket.android.chatroom.viewmodel
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.attachment.ColorAttachment
data class
ColorAttachmentViewModel
(
override
val
attachmentUrl
:
String
,
val
id
:
Long
,
val
color
:
Int
,
val
text
:
CharSequence
,
override
val
message
:
Message
,
override
val
rawData
:
ColorAttachment
,
override
val
messageId
:
String
,
override
var
reactions
:
List
<
ReactionViewModel
>,
override
var
nextDownStreamMessage
:
BaseViewModel
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
)
:
BaseAttachmentViewModel
<
ColorAttachment
>
{
override
val
viewType
:
Int
get
()
=
BaseViewModel
.
ViewType
.
COLOR_ATTACHMENT
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
item_color_attachment
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/viewmodel/MessageViewModel.kt
deleted
100644 → 0
View file @
60009b87
package
chat.rocket.android.chatroom.viewmodel
import
chat.rocket.android.R
import
chat.rocket.core.model.Message
data class
MessageViewModel
(
override
val
message
:
Message
,
override
val
rawData
:
Message
,
override
val
messageId
:
String
,
override
val
avatar
:
String
,
override
val
time
:
CharSequence
,
override
val
senderName
:
CharSequence
,
override
val
content
:
CharSequence
,
override
val
isPinned
:
Boolean
,
override
var
reactions
:
List
<
ReactionViewModel
>,
override
var
nextDownStreamMessage
:
BaseViewModel
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
var
isFirstUnread
:
Boolean
,
override
var
isTemporary
:
Boolean
=
false
)
:
BaseMessageViewModel
<
Message
>
{
override
val
viewType
:
Int
get
()
=
BaseViewModel
.
ViewType
.
MESSAGE
.
viewType
override
val
layoutId
:
Int
get
()
=
R
.
layout
.
item_message
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/viewmodel/suggestion/ChatRoomSuggestionViewModel.kt
deleted
100644 → 0
View file @
60009b87
package
chat.rocket.android.chatroom.viewmodel.suggestion
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
class
ChatRoomSuggestionViewModel
(
text
:
String
,
val
fullName
:
String
,
val
name
:
String
,
searchList
:
List
<
String
>)
:
SuggestionModel
(
text
,
searchList
,
false
)
{
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/viewmodel/suggestion/CommandSuggestionViewModel.kt
deleted
100644 → 0
View file @
60009b87
package
chat.rocket.android.chatroom.viewmodel.suggestion
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
class
CommandSuggestionViewModel
(
text
:
String
,
val
description
:
String
,
searchList
:
List
<
String
>)
:
SuggestionModel
(
text
,
searchList
)
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/viewmodel/suggestion/PeopleSuggestionViewModel.kt
deleted
100644 → 0
View file @
60009b87
package
chat.rocket.android.chatroom.viewmodel.suggestion
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
import
chat.rocket.common.model.UserStatus
class
PeopleSuggestionViewModel
(
val
imageUri
:
String
?,
text
:
String
,
val
username
:
String
,
val
name
:
String
,
val
status
:
UserStatus
?,
pinned
:
Boolean
=
false
,
searchList
:
List
<
String
>)
:
SuggestionModel
(
text
,
searchList
,
pinned
)
{
override
fun
toString
():
String
{
return
"PeopleSuggestionViewModel(imageUri='$imageUri', username='$username', name='$name', status=$status, pinned=$pinned)"
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/adapter/RoomItemHolder.kt
View file @
12550250
package
chat.rocket.android.chatrooms.adapter
import
chat.rocket.android.chatrooms.adapter.model.Room
import
chat.rocket.android.chatrooms.adapter.model.Room
UiModel
data class
RoomItemHolder
(
override
val
data
:
Room
)
:
ItemHolder
<
Room
>
\ No newline at end of file
data class
RoomItemHolder
(
override
val
data
:
RoomUiModel
)
:
ItemHolder
<
RoomUiModel
>
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/adapter/RoomMapper.kt
→
app/src/main/java/chat/rocket/android/chatrooms/adapter/Room
UiModel
Mapper.kt
View file @
12550250
...
...
@@ -6,7 +6,7 @@ import androidx.core.content.ContextCompat
import
androidx.core.text.bold
import
androidx.core.text.color
import
chat.rocket.android.R
import
chat.rocket.android.chatrooms.adapter.model.Room
import
chat.rocket.android.chatrooms.adapter.model.Room
UiModel
import
chat.rocket.android.db.model.ChatRoom
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.checkIfMyself
...
...
@@ -20,11 +20,12 @@ import chat.rocket.common.model.RoomType
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.model.userStatusOf
class
RoomMapper
(
private
val
context
:
Application
,
private
val
settings
:
PublicSettings
,
private
val
localRepository
:
LocalRepository
,
private
val
serverUrl
:
String
)
{
class
RoomUiModelMapper
(
private
val
context
:
Application
,
private
val
settings
:
PublicSettings
,
private
val
localRepository
:
LocalRepository
,
private
val
serverUrl
:
String
)
{
private
val
nameUnreadColor
=
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorPrimaryText
)
private
val
nameColor
=
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorSecondaryText
)
private
val
dateUnreadColor
=
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorAccent
)
...
...
@@ -46,7 +47,7 @@ class RoomMapper(private val context: Application,
return
list
}
fun
map
(
chatRoom
:
ChatRoom
):
Room
{
fun
map
(
chatRoom
:
ChatRoom
):
Room
UiModel
{
return
with
(
chatRoom
.
chatRoom
)
{
val
isUnread
=
alert
||
unread
>
0
val
type
=
roomTypeOf
(
type
)
...
...
@@ -62,7 +63,7 @@ class RoomMapper(private val context: Application,
val
lastMessage
=
mapLastMessage
(
chatRoom
.
lastMessageUserName
,
chatRoom
.
lastMessageUserFullName
,
lastMessageText
,
isUnread
)
Room
(
Room
UiModel
(
id
=
id
,
name
=
roomName
,
type
=
type
,
...
...
app/src/main/java/chat/rocket/android/chatrooms/adapter/model/Room.kt
→
app/src/main/java/chat/rocket/android/chatrooms/adapter/model/Room
UiModel
.kt
View file @
12550250
...
...
@@ -3,7 +3,7 @@ package chat.rocket.android.chatrooms.adapter.model
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.UserStatus
data class
Room
(
data class
Room
UiModel
(
val
id
:
String
,
val
type
:
RoomType
,
val
name
:
CharSequence
,
...
...
app/src/main/java/chat/rocket/android/chatrooms/di/ChatRoomsFragmentModule.kt
View file @
12550250
...
...
@@ -2,7 +2,7 @@ package chat.rocket.android.chatrooms.di
import
android.app.Application
import
androidx.lifecycle.LifecycleOwner
import
chat.rocket.android.chatrooms.adapter.RoomMapper
import
chat.rocket.android.chatrooms.adapter.Room
UiModel
Mapper
import
chat.rocket.android.chatrooms.domain.FetchChatRoomsInteractor
import
chat.rocket.android.chatrooms.presentation.ChatRoomsView
import
chat.rocket.android.chatrooms.ui.ChatRoomsFragment
...
...
@@ -87,7 +87,7 @@ class ChatRoomsFragmentModule {
fun
provideRoomMapper
(
context
:
Application
,
repository
:
SettingsRepository
,
localRepository
:
LocalRepository
,
@Named
(
"currentServer"
)
serverUrl
:
String
):
RoomMapper
{
return
RoomMapper
(
context
,
repository
.
get
(
serverUrl
),
localRepository
,
serverUrl
)
@Named
(
"currentServer"
)
serverUrl
:
String
):
Room
UiModel
Mapper
{
return
Room
UiModel
Mapper
(
context
,
repository
.
get
(
serverUrl
),
localRepository
,
serverUrl
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
View file @
12550250
...
...
@@ -5,12 +5,11 @@ import androidx.lifecycle.MutableLiveData
import
androidx.lifecycle.Transformations
import
androidx.lifecycle.ViewModel
import
chat.rocket.android.chatrooms.adapter.ItemHolder
import
chat.rocket.android.chatrooms.adapter.RoomMapper
import
chat.rocket.android.chatrooms.adapter.Room
UiModel
Mapper
import
chat.rocket.android.chatrooms.domain.FetchChatRoomsInteractor
import
chat.rocket.android.chatrooms.infrastructure.ChatRoomsRepository
import
chat.rocket.android.chatrooms.infrastructure.isGrouped
import
chat.rocket.android.server.infraestructure.ConnectionManager
import
chat.rocket.android.util.livedata.TransformedLiveData
import
chat.rocket.android.util.livedata.transform
import
chat.rocket.core.internal.realtime.socket.model.State
import
kotlinx.coroutines.experimental.launch
...
...
@@ -24,7 +23,7 @@ class ChatRoomsViewModel(
private
val
connectionManager
:
ConnectionManager
,
private
val
interactor
:
FetchChatRoomsInteractor
,
private
val
repository
:
ChatRoomsRepository
,
private
val
mapper
:
RoomMapper
private
val
mapper
:
Room
UiModel
Mapper
)
:
ViewModel
()
{
private
val
ordering
:
MutableLiveData
<
ChatRoomsRepository
.
Order
>
=
MutableLiveData
()
private
val
runContext
=
newSingleThreadContext
(
"chat-rooms-view-model"
)
...
...
app/src/main/java/chat/rocket/android/chatrooms/viewmodel/ChatRoomsViewModelFactory.kt
View file @
12550250
...
...
@@ -2,7 +2,7 @@ package chat.rocket.android.chatrooms.viewmodel
import
androidx.lifecycle.ViewModel
import
androidx.lifecycle.ViewModelProvider
import
chat.rocket.android.chatrooms.adapter.RoomMapper
import
chat.rocket.android.chatrooms.adapter.Room
UiModel
Mapper
import
chat.rocket.android.chatrooms.domain.FetchChatRoomsInteractor
import
chat.rocket.android.chatrooms.infrastructure.ChatRoomsRepository
import
chat.rocket.android.server.infraestructure.ConnectionManager
...
...
@@ -12,7 +12,7 @@ class ChatRoomsViewModelFactory @Inject constructor(
private
val
connectionManager
:
ConnectionManager
,
private
val
interactor
:
FetchChatRoomsInteractor
,
private
val
repository
:
ChatRoomsRepository
,
private
val
mapper
:
RoomMapper
private
val
mapper
:
Room
UiModel
Mapper
)
:
ViewModelProvider
.
NewInstanceFactory
()
{
@Suppress
(
"UNCHECKED_CAST"
)
...
...
app/src/main/java/chat/rocket/android/favoritemessages/presentation/FavoriteMessagesPresenter.kt
View file @
12550250
package
chat.rocket.android.favoritemessages.presentation
import
chat.rocket.android.chatroom.
viewmodel.View
ModelMapper
import
chat.rocket.android.chatroom.
uimodel.Ui
ModelMapper
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.ChatRoomsInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
...
...
@@ -16,7 +16,7 @@ class FavoriteMessagesPresenter @Inject constructor(
private
val
view
:
FavoriteMessagesView
,
private
val
strategy
:
CancelStrategy
,
private
val
roomsInteractor
:
ChatRoomsInteractor
,
private
val
mapper
:
View
ModelMapper
,
private
val
mapper
:
Ui
ModelMapper
,
val
serverInteractor
:
GetCurrentServerInteractor
,
val
factory
:
RocketChatClientFactory
)
{
...
...
app/src/main/java/chat/rocket/android/favoritemessages/presentation/FavoriteMessagesView.kt
View file @
12550250
package
chat.rocket.android.favoritemessages.presentation
import
chat.rocket.android.chatroom.
viewmodel.BaseView
Model
import
chat.rocket.android.chatroom.
uimodel.BaseUi
Model
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
...
...
@@ -11,5 +11,5 @@ interface FavoriteMessagesView : MessageView, LoadingView {
*
* @param favoriteMessages The list of favorite messages to show.
*/
fun
showFavoriteMessages
(
favoriteMessages
:
List
<
Base
View
Model
<*
>>)
fun
showFavoriteMessages
(
favoriteMessages
:
List
<
Base
Ui
Model
<*
>>)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/favoritemessages/ui/FavoriteMessagesFragment.kt
View file @
12550250
...
...
@@ -12,7 +12,7 @@ import androidx.recyclerview.widget.RecyclerView
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.ChatRoomAdapter
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.chatroom.
viewmodel.BaseView
Model
import
chat.rocket.android.chatroom.
uimodel.BaseUi
Model
import
chat.rocket.android.favoritemessages.presentation.FavoriteMessagesPresenter
import
chat.rocket.android.favoritemessages.presentation.FavoriteMessagesView
import
chat.rocket.android.helper.EndlessRecyclerViewScrollListener
...
...
@@ -63,7 +63,7 @@ class FavoriteMessagesFragment : Fragment(), FavoriteMessagesView {
presenter
.
loadFavoriteMessages
(
chatRoomId
)
}
override
fun
showFavoriteMessages
(
favoriteMessages
:
List
<
Base
View
Model
<*
>>)
{
override
fun
showFavoriteMessages
(
favoriteMessages
:
List
<
Base
Ui
Model
<*
>>)
{
ui
{
if
(
recycler_view
.
adapter
==
null
)
{
adapter
=
ChatRoomAdapter
(
enableActions
=
false
)
...
...
app/src/main/java/chat/rocket/android/files/adapter/FilesAdapter.kt
View file @
12550250
...
...
@@ -5,13 +5,13 @@ import android.view.ViewGroup
import
androidx.core.view.isVisible
import
androidx.recyclerview.widget.RecyclerView
import
chat.rocket.android.R
import
chat.rocket.android.files.
viewmodel.FileView
Model
import
chat.rocket.android.files.
uimodel.FileUi
Model
import
chat.rocket.android.util.extensions.inflate
import
kotlinx.android.synthetic.main.item_generic_attachment.view.*
class
FilesAdapter
(
private
val
listener
:
(
File
View
Model
)
->
Unit
)
:
class
FilesAdapter
(
private
val
listener
:
(
File
Ui
Model
)
->
Unit
)
:
RecyclerView
.
Adapter
<
FilesAdapter
.
ViewHolder
>()
{
private
var
dataSet
:
List
<
File
View
Model
>
=
ArrayList
()
private
var
dataSet
:
List
<
File
Ui
Model
>
=
ArrayList
()
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
FilesAdapter
.
ViewHolder
=
ViewHolder
(
parent
.
inflate
(
R
.
layout
.
item_generic_attachment
))
...
...
@@ -21,12 +21,12 @@ class FilesAdapter(private val listener: (FileViewModel) -> Unit) :
override
fun
getItemCount
():
Int
=
dataSet
.
size
fun
prependData
(
dataSet
:
List
<
File
View
Model
>)
{
fun
prependData
(
dataSet
:
List
<
File
Ui
Model
>)
{
this
.
dataSet
=
dataSet
notifyItemRangeInserted
(
0
,
dataSet
.
size
)
}
fun
appendData
(
dataSet
:
List
<
File
View
Model
>)
{
fun
appendData
(
dataSet
:
List
<
File
Ui
Model
>)
{
val
previousDataSetSize
=
this
.
dataSet
.
size
this
.
dataSet
+=
dataSet
notifyItemRangeInserted
(
previousDataSetSize
,
dataSet
.
size
)
...
...
@@ -34,15 +34,15 @@ class FilesAdapter(private val listener: (FileViewModel) -> Unit) :
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
fun
bind
(
file
ViewModel
:
FileViewModel
,
listener
:
(
FileView
Model
)
->
Unit
)
{
fun
bind
(
file
UiModel
:
FileUiModel
,
listener
:
(
FileUi
Model
)
->
Unit
)
{
with
(
itemView
)
{
when
{
file
View
Model
.
isImage
->
{
image_file_thumbnail
.
setImageURI
(
file
View
Model
.
url
)
file
Ui
Model
.
isImage
->
{
image_file_thumbnail
.
setImageURI
(
file
Ui
Model
.
url
)
image_file_media_thumbnail
.
isVisible
=
false
image_file_thumbnail
.
isVisible
=
true
}
file
View
Model
.
isMedia
->
{
file
Ui
Model
.
isMedia
->
{
image_file_media_thumbnail
.
setImageDrawable
(
context
.
resources
.
getDrawable
(
R
.
drawable
.
ic_play_arrow_black_24dp
,
null
...
...
@@ -61,10 +61,10 @@ class FilesAdapter(private val listener: (FileViewModel) -> Unit) :
image_file_media_thumbnail
.
isVisible
=
true
}
}
text_file_name
.
text
=
file
View
Model
.
name
text_uploader
.
text
=
file
View
Model
.
uploader
text_upload_date
.
text
=
file
View
Model
.
uploadDate
setOnClickListener
{
listener
(
file
View
Model
)
}
text_file_name
.
text
=
file
Ui
Model
.
name
text_uploader
.
text
=
file
Ui
Model
.
uploader
text_upload_date
.
text
=
file
Ui
Model
.
uploadDate
setOnClickListener
{
listener
(
file
Ui
Model
)
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/files/presentation/FilesPresenter.kt
View file @
12550250
...
...
@@ -2,8 +2,8 @@ package chat.rocket.android.files.presentation
import
androidx.core.net.toUri
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.files.
viewmodel.FileView
Model
import
chat.rocket.android.files.
viewmodel.FileView
ModelMapper
import
chat.rocket.android.files.
uimodel.FileUi
Model
import
chat.rocket.android.files.
uimodel.FileUi
ModelMapper
import
chat.rocket.android.server.domain.ChatRoomsInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
...
...
@@ -15,12 +15,12 @@ import timber.log.Timber
import
javax.inject.Inject
class
FilesPresenter
@Inject
constructor
(
private
val
view
:
FilesView
,
private
val
strategy
:
CancelStrategy
,
private
val
roomsInteractor
:
ChatRoomsInteractor
,
private
val
mapper
:
FileView
ModelMapper
,
val
serverInteractor
:
GetCurrentServerInteractor
,
val
factory
:
RocketChatClientFactory
private
val
view
:
FilesView
,
private
val
strategy
:
CancelStrategy
,
private
val
roomsInteractor
:
ChatRoomsInteractor
,
private
val
mapper
:
FileUi
ModelMapper
,
val
serverInteractor
:
GetCurrentServerInteractor
,
val
factory
:
RocketChatClientFactory
)
{
private
val
serverUrl
=
serverInteractor
.
get
()
!!
private
val
client
=
factory
.
create
(
serverUrl
)
...
...
@@ -37,8 +37,8 @@ class FilesPresenter @Inject constructor(
view
.
showLoading
()
roomsInteractor
.
getById
(
serverUrl
,
roomId
)
?.
let
{
val
files
=
client
.
getFiles
(
roomId
,
it
.
type
,
offset
)
val
files
ViewModel
=
mapper
.
mapToView
ModelList
(
files
.
result
)
view
.
showFiles
(
files
View
Model
,
files
.
total
)
val
files
UiModel
=
mapper
.
mapToUi
ModelList
(
files
.
result
)
view
.
showFiles
(
files
Ui
Model
,
files
.
total
)
offset
+=
1
*
30
}.
ifNull
{
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server."
)
...
...
@@ -56,15 +56,15 @@ class FilesPresenter @Inject constructor(
}
}
fun
openFile
(
file
ViewModel
:
FileView
Model
)
{
fun
openFile
(
file
UiModel
:
FileUi
Model
)
{
when
{
file
ViewModel
.
isImage
->
fileView
Model
.
url
?.
let
{
view
.
openImage
(
it
,
file
View
Model
.
name
?:
""
)
file
UiModel
.
isImage
->
fileUi
Model
.
url
?.
let
{
view
.
openImage
(
it
,
file
Ui
Model
.
name
?:
""
)
}
file
ViewModel
.
isMedia
->
fileView
Model
.
url
?.
let
{
file
UiModel
.
isMedia
->
fileUi
Model
.
url
?.
let
{
view
.
playMedia
(
it
)
}
else
->
file
View
Model
.
url
?.
let
{
else
->
file
Ui
Model
.
url
?.
let
{
view
.
openDocument
(
it
.
toUri
())
}
}
...
...
app/src/main/java/chat/rocket/android/files/presentation/FilesView.kt
View file @
12550250
...
...
@@ -3,7 +3,7 @@ package chat.rocket.android.files.presentation
import
android.net.Uri
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.android.files.
viewmodel.FileView
Model
import
chat.rocket.android.files.
uimodel.FileUi
Model
interface
FilesView
:
MessageView
,
LoadingView
{
...
...
@@ -13,7 +13,7 @@ interface FilesView : MessageView, LoadingView {
* @param dataSet The data set to show.
* @param total The total number of files.
*/
fun
showFiles
(
dataSet
:
List
<
File
View
Model
>,
total
:
Long
)
fun
showFiles
(
dataSet
:
List
<
File
Ui
Model
>,
total
:
Long
)
/**
* Plays a media file (audio/video).
...
...
app/src/main/java/chat/rocket/android/files/ui/FilesFragment.kt
View file @
12550250
...
...
@@ -15,7 +15,7 @@ import chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.files.adapter.FilesAdapter
import
chat.rocket.android.files.presentation.FilesPresenter
import
chat.rocket.android.files.presentation.FilesView
import
chat.rocket.android.files.
viewmodel.FileView
Model
import
chat.rocket.android.files.
uimodel.FileUi
Model
import
chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import
chat.rocket.android.helper.ImageHelper
import
chat.rocket.android.player.PlayerActivity
...
...
@@ -41,7 +41,7 @@ class FilesFragment : Fragment(), FilesView {
@Inject
lateinit
var
presenter
:
FilesPresenter
private
val
adapter
:
FilesAdapter
=
FilesAdapter
{
file
ViewModel
->
presenter
.
openFile
(
fileView
Model
)
}
FilesAdapter
{
file
UiModel
->
presenter
.
openFile
(
fileUi
Model
)
}
private
val
linearLayoutManager
=
LinearLayoutManager
(
context
)
private
lateinit
var
chatRoomId
:
String
...
...
@@ -69,7 +69,7 @@ class FilesFragment : Fragment(), FilesView {
presenter
.
loadFiles
(
chatRoomId
)
}
override
fun
showFiles
(
dataSet
:
List
<
File
View
Model
>,
total
:
Long
)
{
override
fun
showFiles
(
dataSet
:
List
<
File
Ui
Model
>,
total
:
Long
)
{
setupToolbar
(
total
)
if
(
adapter
.
itemCount
==
0
)
{
adapter
.
prependData
(
dataSet
)
...
...
app/src/main/java/chat/rocket/android/files/
viewmodel/FileView
Model.kt
→
app/src/main/java/chat/rocket/android/files/
uimodel/FileUi
Model.kt
View file @
12550250
package
chat.rocket.android.files.
view
model
package
chat.rocket.android.files.
ui
model
import
DateTimeHelper
import
chat.rocket.android.server.domain.TokenRepository
...
...
@@ -7,7 +7,7 @@ import chat.rocket.android.util.extensions.fileUrl
import
chat.rocket.core.model.Value
import
chat.rocket.core.model.attachment.GenericAttachment
class
File
View
Model
(
class
File
Ui
Model
(
private
val
genericAttachment
:
GenericAttachment
,
private
val
settings
:
Map
<
String
,
Value
<
Any
>>,
private
val
tokenRepository
:
TokenRepository
,
...
...
app/src/main/java/chat/rocket/android/files/
viewmodel/FileView
ModelMapper.kt
→
app/src/main/java/chat/rocket/android/files/
uimodel/FileUi
ModelMapper.kt
View file @
12550250
package
chat.rocket.android.files.
view
model
package
chat.rocket.android.files.
ui
model
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
...
...
@@ -8,7 +8,7 @@ import chat.rocket.core.model.Value
import
chat.rocket.core.model.attachment.GenericAttachment
import
javax.inject.Inject
class
File
View
ModelMapper
@Inject
constructor
(
class
File
Ui
ModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
,
private
val
tokenRepository
:
TokenRepository
...
...
@@ -17,7 +17,7 @@ class FileViewModelMapper @Inject constructor(
getSettingsInteractor
.
get
(
serverInteractor
.
get
()
!!
)
private
val
baseUrl
=
settings
.
baseUrl
()
fun
mapTo
ViewModelList
(
fileList
:
List
<
GenericAttachment
>):
List
<
FileView
Model
>
{
return
fileList
.
map
{
File
View
Model
(
it
,
settings
,
tokenRepository
,
baseUrl
)
}
fun
mapTo
UiModelList
(
fileList
:
List
<
GenericAttachment
>):
List
<
FileUi
Model
>
{
return
fileList
.
map
{
File
Ui
Model
(
it
,
settings
,
tokenRepository
,
baseUrl
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
12550250
...
...
@@ -2,8 +2,8 @@ package chat.rocket.android.main.presentation
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.main.
viewmodel.NavHeaderView
Model
import
chat.rocket.android.main.
viewmodel.NavHeaderView
ModelMapper
import
chat.rocket.android.main.
uimodel.NavHeaderUi
Model
import
chat.rocket.android.main.
uimodel.NavHeaderUi
ModelMapper
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.model.Account
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
...
...
@@ -28,19 +28,19 @@ import timber.log.Timber
import
javax.inject.Inject
class
MainPresenter
@Inject
constructor
(
private
val
view
:
MainView
,
private
val
strategy
:
CancelStrategy
,
private
val
navigator
:
MainNavigator
,
private
val
tokenRepository
:
TokenRepository
,
private
val
serverInteractor
:
GetCurrentServerInteractor
,
private
val
localRepository
:
LocalRepository
,
private
val
navHeaderMapper
:
NavHeaderView
ModelMapper
,
private
val
saveAccountInteractor
:
SaveAccountInteractor
,
private
val
getAccountsInteractor
:
GetAccountsInteractor
,
private
val
removeAccountInteractor
:
RemoveAccountInteractor
,
private
val
factory
:
RocketChatClientFactory
,
getSettingsInteractor
:
GetSettingsInteractor
,
managerFactory
:
ConnectionManagerFactory
private
val
view
:
MainView
,
private
val
strategy
:
CancelStrategy
,
private
val
navigator
:
MainNavigator
,
private
val
tokenRepository
:
TokenRepository
,
private
val
serverInteractor
:
GetCurrentServerInteractor
,
private
val
localRepository
:
LocalRepository
,
private
val
navHeaderMapper
:
NavHeaderUi
ModelMapper
,
private
val
saveAccountInteractor
:
SaveAccountInteractor
,
private
val
getAccountsInteractor
:
GetAccountsInteractor
,
private
val
removeAccountInteractor
:
RemoveAccountInteractor
,
private
val
factory
:
RocketChatClientFactory
,
getSettingsInteractor
:
GetSettingsInteractor
,
managerFactory
:
ConnectionManagerFactory
)
:
CheckServerPresenter
(
strategy
,
factory
,
view
=
view
)
{
private
val
currentServer
=
serverInteractor
.
get
()
!!
private
val
manager
=
managerFactory
.
create
(
currentServer
)
...
...
@@ -64,7 +64,7 @@ class MainPresenter @Inject constructor(
val
me
=
retryIO
(
"me"
)
{
client
.
me
()
}
val
model
=
navHeaderMapper
.
mapTo
View
Model
(
me
)
val
model
=
navHeaderMapper
.
mapTo
Ui
Model
(
me
)
saveAccount
(
model
)
view
.
setupNavHeader
(
model
,
getAccountsInteractor
.
get
())
}
catch
(
ex
:
Exception
)
{
...
...
@@ -157,16 +157,16 @@ class MainPresenter @Inject constructor(
}
}
private
suspend
fun
saveAccount
(
viewModel
:
NavHeaderView
Model
)
{
private
suspend
fun
saveAccount
(
uiModel
:
NavHeaderUi
Model
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
}
val
account
=
Account
(
currentServer
,
icon
,
view
Model
.
serverLogo
,
view
Model
.
userDisplayName
!!
,
view
Model
.
userAvatar
ui
Model
.
serverLogo
,
ui
Model
.
userDisplayName
!!
,
ui
Model
.
userAvatar
)
saveAccountInteractor
.
save
(
account
)
}
...
...
@@ -193,7 +193,7 @@ class MainPresenter @Inject constructor(
}
private
suspend
fun
updateMyself
(
myself
:
Myself
)
{
val
model
=
navHeaderMapper
.
mapTo
View
Model
(
myself
)
val
model
=
navHeaderMapper
.
mapTo
Ui
Model
(
myself
)
view
.
setupNavHeader
(
model
,
getAccountsInteractor
.
get
())
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/main/presentation/MainView.kt
View file @
12550250
...
...
@@ -2,7 +2,7 @@ package chat.rocket.android.main.presentation
import
chat.rocket.android.authentication.server.presentation.VersionCheckView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.android.main.
viewmodel.NavHeaderView
Model
import
chat.rocket.android.main.
uimodel.NavHeaderUi
Model
import
chat.rocket.android.server.domain.model.Account
import
chat.rocket.common.model.UserStatus
...
...
@@ -18,10 +18,10 @@ interface MainView : MessageView, VersionCheckView {
/**
* Setups the navigation header.
*
* @param
viewModel The [NavHeaderView
Model].
* @param
uiModel The [NavHeaderUi
Model].
* @param accounts The list of accounts.
*/
fun
setupNavHeader
(
viewModel
:
NavHeaderView
Model
,
accounts
:
List
<
Account
>)
fun
setupNavHeader
(
uiModel
:
NavHeaderUi
Model
,
accounts
:
List
<
Account
>)
fun
closeServerSelection
()
...
...
app/src/main/java/chat/rocket/android/main/ui/MainActivity.kt
View file @
12550250
...
...
@@ -18,7 +18,7 @@ import chat.rocket.android.main.adapter.AccountsAdapter
import
chat.rocket.android.main.adapter.Selector
import
chat.rocket.android.main.presentation.MainPresenter
import
chat.rocket.android.main.presentation.MainView
import
chat.rocket.android.main.
viewmodel.NavHeaderView
Model
import
chat.rocket.android.main.
uimodel.NavHeaderUi
Model
import
chat.rocket.android.server.domain.model.Account
import
chat.rocket.android.server.ui.INTENT_CHAT_ROOM_ID
import
chat.rocket.android.util.extensions.fadeIn
...
...
@@ -118,10 +118,10 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
}
}
override
fun
setupNavHeader
(
viewModel
:
NavHeaderView
Model
,
accounts
:
List
<
Account
>)
{
Timber
.
d
(
"Setting up nav header: $
view
Model"
)
override
fun
setupNavHeader
(
uiModel
:
NavHeaderUi
Model
,
accounts
:
List
<
Account
>)
{
Timber
.
d
(
"Setting up nav header: $
ui
Model"
)
with
(
headerLayout
)
{
with
(
view
Model
)
{
with
(
ui
Model
)
{
if
(
userStatus
!=
null
)
{
image_user_status
.
setImageDrawable
(
DrawableHelper
.
getUserStatusDrawable
(
userStatus
,
context
)
...
...
@@ -136,7 +136,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
if
(
serverLogo
!=
null
)
{
server_logo
.
setImageURI
(
serverLogo
)
}
text_server_url
.
text
=
view
Model
.
serverUrl
text_server_url
.
text
=
ui
Model
.
serverUrl
}
setupAccountsList
(
headerLayout
,
accounts
)
}
...
...
app/src/main/java/chat/rocket/android/main/
viewmodel/NavHeaderView
Model.kt
→
app/src/main/java/chat/rocket/android/main/
uimodel/NavHeaderUi
Model.kt
View file @
12550250
package
chat.rocket.android.main.
view
model
package
chat.rocket.android.main.
ui
model
import
chat.rocket.common.model.UserStatus
data class
NavHeader
View
Model
(
data class
NavHeader
Ui
Model
(
val
userDisplayName
:
String
?,
val
userStatus
:
UserStatus
?,
val
userAvatar
:
String
?,
...
...
app/src/main/java/chat/rocket/android/main/
viewmodel/NavHeaderView
ModelMapper.kt
→
app/src/main/java/chat/rocket/android/main/
uimodel/NavHeaderUi
ModelMapper.kt
View file @
12550250
package
chat.rocket.android.main.
view
model
package
chat.rocket.android.main.
ui
model
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.util.extensions.avatarUrl
...
...
@@ -6,21 +6,21 @@ import chat.rocket.android.util.extensions.serverLogoUrl
import
chat.rocket.core.model.Myself
import
javax.inject.Inject
class
NavHeader
View
ModelMapper
@Inject
constructor
(
class
NavHeader
Ui
ModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
)
{
private
val
currentServer
=
serverInteractor
.
get
()
!!
private
var
settings
:
PublicSettings
=
getSettingsInteractor
.
get
(
currentServer
)
fun
mapTo
ViewModel
(
me
:
Myself
):
NavHeaderView
Model
{
fun
mapTo
UiModel
(
me
:
Myself
):
NavHeaderUi
Model
{
val
displayName
=
mapDisplayName
(
me
)
val
status
=
me
.
status
val
avatar
=
me
.
username
?.
let
{
currentServer
.
avatarUrl
(
it
)
}
val
image
=
settings
.
wideTile
()
?:
settings
.
faviconLarge
()
val
logo
=
image
?.
let
{
currentServer
.
serverLogoUrl
(
it
)
}
return
NavHeader
View
Model
(
displayName
,
status
,
avatar
,
currentServer
,
logo
)
return
NavHeader
Ui
Model
(
displayName
,
status
,
avatar
,
currentServer
,
logo
)
}
private
fun
mapDisplayName
(
me
:
Myself
):
String
?
{
...
...
app/src/main/java/chat/rocket/android/members/adapter/MembersAdapter.kt
View file @
12550250
...
...
@@ -4,15 +4,15 @@ import androidx.recyclerview.widget.RecyclerView
import
android.view.View
import
android.view.ViewGroup
import
chat.rocket.android.R
import
chat.rocket.android.members.
viewmodel.MemberView
Model
import
chat.rocket.android.members.
uimodel.MemberUi
Model
import
chat.rocket.android.util.extensions.content
import
chat.rocket.android.util.extensions.inflate
import
kotlinx.android.synthetic.main.avatar.view.*
import
kotlinx.android.synthetic.main.item_member.view.*
class
MembersAdapter
(
private
val
listener
:
(
Member
View
Model
)
->
Unit
)
:
class
MembersAdapter
(
private
val
listener
:
(
Member
Ui
Model
)
->
Unit
)
:
RecyclerView
.
Adapter
<
MembersAdapter
.
ViewHolder
>()
{
private
var
dataSet
=
emptyList
<
MemberViewModel
>
()
private
var
dataSet
:
List
<
MemberUiModel
>
=
ArrayList
()
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
MembersAdapter
.
ViewHolder
=
ViewHolder
(
parent
.
inflate
(
R
.
layout
.
item_member
))
...
...
@@ -28,12 +28,12 @@ class MembersAdapter(private val listener: (MemberViewModel) -> Unit) :
notifyItemRangeRemoved
(
0
,
itemCount
)
}
fun
prependData
(
dataSet
:
List
<
Member
View
Model
>)
{
fun
prependData
(
dataSet
:
List
<
Member
Ui
Model
>)
{
this
.
dataSet
=
dataSet
notifyItemRangeInserted
(
0
,
dataSet
.
size
)
}
fun
appendData
(
dataSet
:
List
<
Member
View
Model
>)
{
fun
appendData
(
dataSet
:
List
<
Member
Ui
Model
>)
{
val
previousDataSetSize
=
this
.
dataSet
.
size
this
.
dataSet
+=
dataSet
notifyItemRangeInserted
(
previousDataSetSize
,
dataSet
.
size
)
...
...
@@ -41,11 +41,10 @@ class MembersAdapter(private val listener: (MemberViewModel) -> Unit) :
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
fun
bind
(
memberViewModel
:
MemberViewModel
,
listener
:
(
MemberViewModel
)
->
Unit
)
=
with
(
itemView
)
{
image_avatar
.
setImageURI
(
memberViewModel
.
avatarUri
)
text_member
.
content
=
memberViewModel
.
displayName
setOnClickListener
{
listener
(
memberViewModel
)
}
}
fun
bind
(
memberUiModel
:
MemberUiModel
,
listener
:
(
MemberUiModel
)
->
Unit
)
=
with
(
itemView
)
{
image_avatar
.
setImageURI
(
memberUiModel
.
avatarUri
)
text_member
.
content
=
memberUiModel
.
displayName
setOnClickListener
{
listener
(
memberUiModel
)
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/members/presentation/MembersPresenter.kt
View file @
12550250
package
chat.rocket.android.members.presentation
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.members.
viewmodel.MemberView
Model
import
chat.rocket.android.members.
viewmodel.MemberView
ModelMapper
import
chat.rocket.android.members.
uimodel.MemberUi
Model
import
chat.rocket.android.members.
uimodel.MemberUi
ModelMapper
import
chat.rocket.android.server.domain.ChatRoomsInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
...
...
@@ -19,7 +19,7 @@ class MembersPresenter @Inject constructor(
private
val
navigator
:
MembersNavigator
,
private
val
strategy
:
CancelStrategy
,
private
val
roomsInteractor
:
ChatRoomsInteractor
,
private
val
mapper
:
Member
View
ModelMapper
,
private
val
mapper
:
Member
Ui
ModelMapper
,
val
serverInteractor
:
GetCurrentServerInteractor
,
val
factory
:
RocketChatClientFactory
)
{
...
...
@@ -33,8 +33,8 @@ class MembersPresenter @Inject constructor(
view
.
showLoading
()
roomsInteractor
.
getById
(
serverUrl
,
roomId
)
?.
let
{
val
members
=
client
.
getMembers
(
it
.
id
,
it
.
type
,
offset
,
60
)
val
member
ViewModels
=
mapper
.
mapToView
ModelList
(
members
.
result
)
view
.
showMembers
(
member
View
Models
,
members
.
total
)
val
member
UiModels
=
mapper
.
mapToUi
ModelList
(
members
.
result
)
view
.
showMembers
(
member
Ui
Models
,
members
.
total
)
offset
+=
1
*
60L
}.
ifNull
{
Timber
.
e
(
"Couldn't find a room with id: $roomId at current server"
)
...
...
@@ -51,12 +51,12 @@ class MembersPresenter @Inject constructor(
}
}
fun
toMemberDetails
(
member
ViewModel
:
MemberView
Model
)
{
val
avatarUri
=
member
View
Model
.
avatarUri
.
toString
()
val
realName
=
member
View
Model
.
realName
.
toString
()
val
username
=
"@${member
View
Model.username}"
val
email
=
member
View
Model
.
email
?:
""
val
utcOffset
=
member
View
Model
.
utcOffset
.
toString
()
fun
toMemberDetails
(
member
UiModel
:
MemberUi
Model
)
{
val
avatarUri
=
member
Ui
Model
.
avatarUri
.
toString
()
val
realName
=
member
Ui
Model
.
realName
.
toString
()
val
username
=
"@${member
Ui
Model.username}"
val
email
=
member
Ui
Model
.
email
?:
""
val
utcOffset
=
member
Ui
Model
.
utcOffset
.
toString
()
navigator
.
toMemberDetails
(
avatarUri
,
realName
,
username
,
email
,
utcOffset
)
}
...
...
app/src/main/java/chat/rocket/android/members/presentation/MembersView.kt
View file @
12550250
...
...
@@ -2,7 +2,7 @@ package chat.rocket.android.members.presentation
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.android.members.
viewmodel.MemberView
Model
import
chat.rocket.android.members.
uimodel.MemberUi
Model
interface
MembersView
:
LoadingView
,
MessageView
{
...
...
@@ -12,5 +12,5 @@ interface MembersView: LoadingView, MessageView {
* @param dataSet The data set to show.
* @param total The total number of members.
*/
fun
showMembers
(
dataSet
:
List
<
Member
View
Model
>,
total
:
Long
)
fun
showMembers
(
dataSet
:
List
<
Member
Ui
Model
>,
total
:
Long
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/members/ui/MembersFragment.kt
View file @
12550250
...
...
@@ -2,7 +2,6 @@ package chat.rocket.android.members.ui
import
android.os.Bundle
import
androidx.fragment.app.Fragment
import
androidx.appcompat.app.AppCompatActivity
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
android.view.LayoutInflater
...
...
@@ -14,7 +13,7 @@ import chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import
chat.rocket.android.members.adapter.MembersAdapter
import
chat.rocket.android.members.presentation.MembersPresenter
import
chat.rocket.android.members.presentation.MembersView
import
chat.rocket.android.members.
viewmodel.MemberView
Model
import
chat.rocket.android.members.
uimodel.MemberUi
Model
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.showToast
...
...
@@ -38,7 +37,7 @@ class MembersFragment : Fragment(), MembersView {
@Inject
lateinit
var
presenter
:
MembersPresenter
private
val
adapter
:
MembersAdapter
=
MembersAdapter
{
member
ViewModel
->
presenter
.
toMemberDetails
(
memberView
Model
)
}
MembersAdapter
{
member
UiModel
->
presenter
.
toMemberDetails
(
memberUi
Model
)
}
private
val
linearLayoutManager
=
LinearLayoutManager
(
context
)
private
lateinit
var
chatRoomId
:
String
...
...
@@ -66,7 +65,7 @@ class MembersFragment : Fragment(), MembersView {
presenter
.
loadChatRoomsMembers
(
chatRoomId
)
}
override
fun
showMembers
(
dataSet
:
List
<
Member
View
Model
>,
total
:
Long
)
{
override
fun
showMembers
(
dataSet
:
List
<
Member
Ui
Model
>,
total
:
Long
)
{
ui
{
setupToolbar
(
total
)
if
(
adapter
.
itemCount
==
0
)
{
...
...
app/src/main/java/chat/rocket/android/members/
viewmodel/MemberView
Model.kt
→
app/src/main/java/chat/rocket/android/members/
uimodel/MemberUi
Model.kt
View file @
12550250
package
chat.rocket.android.members.
view
model
package
chat.rocket.android.members.
ui
model
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.common.model.User
import
chat.rocket.core.model.Value
class
Member
View
Model
(
class
Member
Ui
Model
(
private
val
member
:
User
,
private
val
settings
:
Map
<
String
,
Value
<
Any
>>,
private
val
baseUrl
:
String
?
...
...
app/src/main/java/chat/rocket/android/members/
viewmodel/MemberView
ModelMapper.kt
→
app/src/main/java/chat/rocket/android/members/
uimodel/MemberUi
ModelMapper.kt
View file @
12550250
package
chat.rocket.android.members.
view
model
package
chat.rocket.android.members.
ui
model
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
...
...
@@ -7,11 +7,11 @@ import chat.rocket.common.model.User
import
chat.rocket.core.model.Value
import
javax.inject.Inject
class
Member
View
ModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
)
{
class
Member
Ui
ModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
)
{
private
var
settings
:
Map
<
String
,
Value
<
Any
>>
=
getSettingsInteractor
.
get
(
serverInteractor
.
get
()
!!
)
private
val
baseUrl
=
settings
.
baseUrl
()
fun
mapTo
ViewModelList
(
memberList
:
List
<
User
>):
List
<
MemberView
Model
>
{
return
memberList
.
map
{
Member
View
Model
(
it
,
settings
,
baseUrl
)
}
fun
mapTo
UiModelList
(
memberList
:
List
<
User
>):
List
<
MemberUi
Model
>
{
return
memberList
.
map
{
Member
Ui
Model
(
it
,
settings
,
baseUrl
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/pinnedmessages/presentation/PinnedMessagesPresenter.kt
View file @
12550250
package
chat.rocket.android.pinnedmessages.presentation
import
chat.rocket.android.chatroom.
viewmodel.View
ModelMapper
import
chat.rocket.android.chatroom.
uimodel.Ui
ModelMapper
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.ChatRoomsInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
...
...
@@ -9,7 +9,6 @@ import chat.rocket.android.util.extensions.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.internal.rest.getPinnedMessages
import
chat.rocket.core.model.isSystemMessage
import
timber.log.Timber
import
javax.inject.Inject
...
...
@@ -17,7 +16,7 @@ class PinnedMessagesPresenter @Inject constructor(
private
val
view
:
PinnedMessagesView
,
private
val
strategy
:
CancelStrategy
,
private
val
roomsInteractor
:
ChatRoomsInteractor
,
private
val
mapper
:
View
ModelMapper
,
private
val
mapper
:
Ui
ModelMapper
,
val
serverInteractor
:
GetCurrentServerInteractor
,
val
factory
:
RocketChatClientFactory
)
{
...
...
app/src/main/java/chat/rocket/android/pinnedmessages/presentation/PinnedMessagesView.kt
View file @
12550250
package
chat.rocket.android.pinnedmessages.presentation
import
chat.rocket.android.chatroom.
viewmodel.BaseView
Model
import
chat.rocket.android.chatroom.
uimodel.BaseUi
Model
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
...
...
@@ -11,5 +11,5 @@ interface PinnedMessagesView : MessageView, LoadingView {
*
* @param pinnedMessages The list of pinned messages.
*/
fun
showPinnedMessages
(
pinnedMessages
:
List
<
Base
View
Model
<*
>>)
fun
showPinnedMessages
(
pinnedMessages
:
List
<
Base
Ui
Model
<*
>>)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/pinnedmessages/ui/PinnedMessagesFragment.kt
View file @
12550250
...
...
@@ -12,7 +12,7 @@ import androidx.core.view.isVisible
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.ChatRoomAdapter
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.chatroom.
viewmodel.BaseView
Model
import
chat.rocket.android.chatroom.
uimodel.BaseUi
Model
import
chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import
chat.rocket.android.pinnedmessages.presentation.PinnedMessagesPresenter
import
chat.rocket.android.pinnedmessages.presentation.PinnedMessagesView
...
...
@@ -65,7 +65,7 @@ class PinnedMessagesFragment : Fragment(), PinnedMessagesView {
presenter
.
loadPinnedMessages
(
chatRoomId
)
}
override
fun
showPinnedMessages
(
pinnedMessages
:
List
<
Base
View
Model
<*
>>)
{
override
fun
showPinnedMessages
(
pinnedMessages
:
List
<
Base
Ui
Model
<*
>>)
{
ui
{
if
(
recycler_view_pinned
.
adapter
==
null
)
{
adapter
=
ChatRoomAdapter
(
enableActions
=
false
)
...
...
app/src/main/java/chat/rocket/android/util/DataToDomain.kt
deleted
100644 → 0
View file @
60009b87
package
chat.rocket.android.util
interface
DataToDomain
<
Data
,
Domain
>
{
fun
translate
(
data
:
Data
):
Domain
}
app/src/main/java/chat/rocket/android/util/DomainToViewModel.kt
deleted
100644 → 0
View file @
60009b87
package
chat.rocket.android.util
interface
DomainToViewModel
<
Domain
,
ViewModel
>
{
fun
translate
(
domain
:
Domain
):
ViewModel
}
dependencies.gradle
View file @
12550250
...
...
@@ -4,8 +4,8 @@ ext {
compileSdk
:
28
,
targetSdk
:
28
,
buildTools
:
'28.0.0-rc2'
,
kotlin
:
'1.2.
41
'
,
coroutine
:
'0.2
2.5
'
,
kotlin
:
'1.2.
50
'
,
coroutine
:
'0.2
3.1
'
,
dokka
:
'0.9.16'
,
// Main dependencies
...
...
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