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
7afef2b9
Unverified
Commit
7afef2b9
authored
Jul 20, 2018
by
Rafael Kellermann Streit
Committed by
GitHub
Jul 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #845 from pcforgeek/add-day-marker-in-chatroom
[NEW] Add day marker in chatroom
parents
7332dc06
83f82e1c
Changes
25
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
359 additions
and
234 deletions
+359
-234
DateTimeHelper.kt
app/src/main/java/chat/rocket/android/app/DateTimeHelper.kt
+39
-30
MessageViewHolder.kt
...chat/rocket/android/chatroom/adapter/MessageViewHolder.kt
+15
-5
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+42
-26
AudioAttachmentUiModel.kt
...rocket/android/chatroom/uimodel/AudioAttachmentUiModel.kt
+3
-1
AuthorAttachmentUiModel.kt
...ocket/android/chatroom/uimodel/AuthorAttachmentUiModel.kt
+16
-14
BaseUiModel.kt
.../java/chat/rocket/android/chatroom/uimodel/BaseUiModel.kt
+2
-0
ColorAttachmentUiModel.kt
...rocket/android/chatroom/uimodel/ColorAttachmentUiModel.kt
+15
-13
GenericFileAttachmentUiModel.kt
.../android/chatroom/uimodel/GenericFileAttachmentUiModel.kt
+14
-12
ImageAttachmentUiModel.kt
...rocket/android/chatroom/uimodel/ImageAttachmentUiModel.kt
+16
-14
MessageAttachmentUiModel.kt
...cket/android/chatroom/uimodel/MessageAttachmentUiModel.kt
+16
-14
MessageReplyUiModel.kt
...at/rocket/android/chatroom/uimodel/MessageReplyUiModel.kt
+3
-1
MessageUiModel.kt
...va/chat/rocket/android/chatroom/uimodel/MessageUiModel.kt
+2
-0
UiModelMapper.kt
...ava/chat/rocket/android/chatroom/uimodel/UiModelMapper.kt
+47
-11
UrlPreviewUiModel.kt
...chat/rocket/android/chatroom/uimodel/UrlPreviewUiModel.kt
+15
-13
VideoAttachmentUiModel.kt
...rocket/android/chatroom/uimodel/VideoAttachmentUiModel.kt
+3
-1
item_message.xml
app/src/main/res/layout/item_message.xml
+45
-3
strings.xml
app/src/main/res/values-es/strings.xml
+45
-71
strings.xml
app/src/main/res/values-fr/strings.xml
+1
-0
strings.xml
app/src/main/res/values-hi-rIN/strings.xml
+1
-0
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+2
-1
strings.xml
app/src/main/res/values-uk-rRU/strings.xml
+3
-3
colors.xml
app/src/main/res/values/colors.xml
+2
-0
fonts.xml
app/src/main/res/values/fonts.xml
+4
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
styles.xml
app/src/main/res/values/styles.xml
+7
-1
No files found.
app/src/main/java/chat/rocket/android/app/DateTimeHelper.kt
View file @
7afef2b9
...
...
@@ -44,39 +44,48 @@ object DateTimeHelper {
}
}
/**
fun
getFormattedDateForMessages
(
localDateTime
:
LocalDateTime
,
context
:
Context
):
String
{
val
localDate
=
localDateTime
.
toLocalDate
()
return
when
(
localDate
)
{
today
->
context
.
getString
(
R
.
string
.
msg_today
)
yesterday
->
context
.
getString
(
R
.
string
.
msg_yesterday
)
else
->
formatLocalDate
(
localDate
)
}
}
/**
* Returns a time from a [LocalDateTime].
*
* @param localDateTime The [LocalDateTime].
* @return The time from a [LocalDateTime].
*/
fun
getTime
(
localDateTime
:
LocalDateTime
):
String
{
fun
getTime
(
localDateTime
:
LocalDateTime
):
String
{
val
formatter
=
DateTimeFormatter
.
ofLocalizedTime
(
FormatStyle
.
SHORT
)
return
localDateTime
.
toLocalTime
().
format
(
formatter
).
toString
()
}
}
/**
/**
* Returns a date time from a [LocalDateTime].
*
* @param localDateTime The [LocalDateTime].
* @return The time from a [LocalDateTime].
*/
fun
getDateTime
(
localDateTime
:
LocalDateTime
):
String
{
fun
getDateTime
(
localDateTime
:
LocalDateTime
):
String
{
return
formatLocalDateTime
(
localDateTime
)
}
}
private
fun
formatLocalDateTime
(
localDateTime
:
LocalDateTime
):
String
{
private
fun
formatLocalDateTime
(
localDateTime
:
LocalDateTime
):
String
{
val
formatter
=
DateTimeFormatter
.
ofLocalizedDateTime
(
FormatStyle
.
SHORT
)
return
localDateTime
.
format
(
formatter
).
toString
()
}
}
private
fun
formatLocalDate
(
localDate
:
LocalDate
):
String
{
private
fun
formatLocalDate
(
localDate
:
LocalDate
):
String
{
val
formatter
=
DateTimeFormatter
.
ofLocalizedDate
(
FormatStyle
.
SHORT
)
return
localDate
.
format
(
formatter
).
toString
()
}
}
private
fun
formatLocalTime
(
localTime
:
LocalTime
):
String
{
private
fun
formatLocalTime
(
localTime
:
LocalTime
):
String
{
val
formatter
=
DateTimeFormatter
.
ofLocalizedTime
(
FormatStyle
.
SHORT
)
return
localTime
.
format
(
formatter
).
toString
()
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/adapter/MessageViewHolder.kt
View file @
7afef2b9
...
...
@@ -26,20 +26,30 @@ class MessageViewHolder(
override
fun
bindViews
(
data
:
MessageUiModel
)
{
with
(
itemView
)
{
if
(
data
.
isFirstUnread
)
new_messages_notif
.
visibility
=
View
.
VISIBLE
else
new_messages_notif
.
visibility
=
View
.
GONE
day_marker_layout
.
visibility
=
if
(
data
.
showDayMarker
)
{
day
.
text
=
data
.
currentDayMarkerText
View
.
VISIBLE
}
else
{
View
.
GONE
}
if
(
data
.
isFirstUnread
)
{
new_messages_notif
.
visibility
=
View
.
VISIBLE
}
else
{
new_messages_notif
.
visibility
=
View
.
GONE
}
text_message_time
.
text
=
data
.
time
text_sender
.
text
=
data
.
senderName
text_content
.
text
=
data
.
content
image_avatar
.
setImageURI
(
data
.
avatar
)
text_content
.
setTextColor
(
if
(
data
.
isTemporary
)
Color
.
GRAY
else
Color
.
BLACK
)
text_content
.
setTextColor
(
if
(
data
.
isTemporary
)
Color
.
GRAY
else
Color
.
BLACK
)
data
.
message
.
let
{
text_edit_indicator
.
isVisible
=
!
it
.
isSystemMessage
()
&&
it
.
editedBy
!=
null
image_star_indicator
.
isVisible
=
it
.
starred
?.
isNotEmpty
()
?:
false
}
if
(
data
.
unread
==
null
)
{
read_receipt_view
.
isVisible
=
false
}
else
{
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
7afef2b9
...
...
@@ -12,15 +12,14 @@ import android.text.SpannableStringBuilder
import
android.view.KeyEvent
import
android.view.LayoutInflater
import
android.view.Menu
import
android.view.MenuInflater
import
android.view.MenuItem
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.Button
import
android.widget.EditText
import
android.widget.TextView
import
android.widget.FrameLayout
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.annotation.DrawableRes
import
androidx.core.text.bold
import
androidx.core.view.isVisible
...
...
@@ -53,9 +52,9 @@ import chat.rocket.android.emoji.EmojiParser
import
chat.rocket.android.emoji.EmojiPickerPopup
import
chat.rocket.android.emoji.EmojiReactionListener
import
chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import
chat.rocket.android.helper.ImageHelper
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.helper.MessageParser
import
chat.rocket.android.helper.ImageHelper
import
chat.rocket.android.util.extension.asObservable
import
chat.rocket.android.util.extensions.circularRevealOrUnreveal
import
chat.rocket.android.util.extensions.fadeIn
...
...
@@ -296,14 +295,30 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
adapter
.
clearData
()
}
if
(
dataSet
.
isNotEmpty
())
{
var
prevMsgModel
=
dataSet
[
0
]
// track the message sent immediately after the current message
var
prevMessageUiModel
:
MessageUiModel
?
=
null
// Checking for all messages to assign true to the required showDayMaker
// Loop over received messages to determine first unread
var
firstUnread
=
false
for
(
i
in
dataSet
.
indices
)
{
val
msgModel
=
dataSet
[
i
]
if
(
msgModel
is
MessageUiModel
)
{
if
(
i
>
0
)
{
prevMsgModel
=
dataSet
[
i
-
1
]
}
val
currentDayMarkerText
=
msgModel
.
currentDayMarkerText
val
previousDayMarkerText
=
prevMsgModel
.
currentDayMarkerText
println
(
"$previousDayMarkerText then $currentDayMarkerText"
)
if
(
previousDayMarkerText
!=
currentDayMarkerText
)
{
prevMsgModel
.
showDayMarker
=
true
}
if
(!
firstUnread
&&
msgModel
is
MessageUiModel
)
{
val
msg
=
msgModel
.
rawData
if
(
msg
.
timestamp
<
chatRoomLastSeen
)
{
// This message was sent before the last seen of the room. Hence, it was seen.
...
...
@@ -311,11 +326,13 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
if
(
prevMessageUiModel
!=
null
)
{
prevMessageUiModel
.
isFirstUnread
=
true
}
break
// Found first unread message.
firstUnread
=
true
}
prevMessageUiModel
=
msgModel
}
}
}
if
(
recycler_view
.
adapter
==
null
)
{
adapter
=
ChatRoomAdapter
(
...
...
@@ -428,7 +445,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
else
{
if
(
dy
<
0
&&
!
button_fab
.
isVisible
)
{
button_fab
.
show
()
if
(
newMessageCount
!=
0
)
text_count
.
isVisible
=
true
if
(
newMessageCount
!=
0
)
text_count
.
isVisible
=
true
}
}
}
...
...
@@ -493,8 +510,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
text_count
.
text
=
"99+"
text_count
.
isVisible
=
true
}
else
if
(!
button_fab
.
isVisible
)
}
else
if
(!
button_fab
.
isVisible
)
recycler_view
.
scrollToPosition
(
0
)
verticalScrollOffset
.
set
(
0
)
empty_chat_view
.
isVisible
=
adapter
.
itemCount
==
0
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/AudioAttachmentUiModel.kt
View file @
7afef2b9
...
...
@@ -16,7 +16,9 @@ data class AudioAttachmentUiModel(
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
,
override
var
unread
:
Boolean
?
=
null
,
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
()
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
(),
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
)
:
BaseFileAttachmentUiModel
<
AudioAttachment
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
AUDIO_ATTACHMENT
.
viewType
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/AuthorAttachmentUiModel.kt
View file @
7afef2b9
...
...
@@ -18,7 +18,9 @@ data class AuthorAttachmentUiModel(
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
,
override
var
unread
:
Boolean
?
=
null
,
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
()
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
(),
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
)
:
BaseAttachmentUiModel
<
AuthorAttachment
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
AUTHOR_ATTACHMENT
.
viewType
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/BaseUiModel.kt
View file @
7afef2b9
...
...
@@ -14,6 +14,8 @@ interface BaseUiModel<out T> {
var
preview
:
Message
?
var
isTemporary
:
Boolean
var
unread
:
Boolean
?
var
currentDayMarkerText
:
String
var
showDayMarker
:
Boolean
var
menuItemsToHide
:
MutableList
<
Int
>
enum
class
ViewType
(
val
viewType
:
Int
)
{
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/ColorAttachmentUiModel.kt
View file @
7afef2b9
...
...
@@ -17,7 +17,9 @@ data class ColorAttachmentUiModel(
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
,
override
var
unread
:
Boolean
?,
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
()
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
(),
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
)
:
BaseAttachmentUiModel
<
ColorAttachment
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
COLOR_ATTACHMENT
.
viewType
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/GenericFileAttachmentUiModel.kt
View file @
7afef2b9
...
...
@@ -16,7 +16,9 @@ data class GenericFileAttachmentUiModel(
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
,
override
var
unread
:
Boolean
?
=
null
,
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
()
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
(),
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
)
:
BaseFileAttachmentUiModel
<
GenericFileAttachment
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
GENERIC_FILE_ATTACHMENT
.
viewType
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/ImageAttachmentUiModel.kt
View file @
7afef2b9
...
...
@@ -18,7 +18,9 @@ data class ImageAttachmentUiModel(
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
,
override
var
unread
:
Boolean
?
=
null
,
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
()
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
(),
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
)
:
BaseFileAttachmentUiModel
<
ImageAttachment
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
IMAGE_ATTACHMENT
.
viewType
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/MessageAttachmentUiModel.kt
View file @
7afef2b9
...
...
@@ -17,7 +17,9 @@ data class MessageAttachmentUiModel(
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
,
override
var
unread
:
Boolean
?
=
null
,
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
()
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
(),
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
)
:
BaseUiModel
<
Message
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
MESSAGE_ATTACHMENT
.
viewType
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/MessageReplyUiModel.kt
View file @
7afef2b9
...
...
@@ -13,7 +13,9 @@ data class MessageReplyUiModel(
override
var
isTemporary
:
Boolean
=
false
,
override
val
message
:
Message
,
override
var
unread
:
Boolean
?
=
null
,
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
()
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
(),
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
)
:
BaseUiModel
<
MessageReply
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
MESSAGE_REPLY
.
viewType
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/MessageUiModel.kt
View file @
7afef2b9
...
...
@@ -12,6 +12,8 @@ data class MessageUiModel(
override
val
senderName
:
CharSequence
,
override
val
content
:
CharSequence
,
override
val
isPinned
:
Boolean
,
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
,
override
var
reactions
:
List
<
ReactionUiModel
>,
override
var
nextDownStreamMessage
:
BaseUiModel
<*>?
=
null
,
override
var
preview
:
Message
?
=
null
,
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/UiModelMapper.kt
View file @
7afef2b9
...
...
@@ -265,6 +265,10 @@ class UiModelMapper @Inject constructor(
val
roomName
=
if
(
settings
.
useRealName
()
&&
name
!=
null
)
name
else
message
.
sender
?.
username
?:
""
val
permalink
=
messageHelper
.
createPermalink
(
message
,
chatRoom
)
val
localDateTime
=
DateTimeHelper
.
getLocalDateTime
(
message
.
timestamp
)
val
dayMarkerText
=
DateTimeHelper
.
getFormattedDateForMessages
(
localDateTime
,
context
)
return
MessageReplyUiModel
(
messageId
=
message
.
id
,
isTemporary
=
false
,
...
...
@@ -273,7 +277,9 @@ class UiModelMapper @Inject constructor(
preview
=
mapMessagePreview
(
message
),
rawData
=
MessageReply
(
roomName
=
roomName
,
permalink
=
permalink
),
nextDownStreamMessage
=
null
,
unread
=
message
.
unread
unread
=
message
.
unread
,
currentDayMarkerText
=
dayMarkerText
,
showDayMarker
=
false
)
}
...
...
@@ -285,8 +291,12 @@ class UiModelMapper @Inject constructor(
val
title
=
url
.
meta
?.
title
val
description
=
url
.
meta
?.
description
val
localDateTime
=
DateTimeHelper
.
getLocalDateTime
(
message
.
timestamp
)
val
dayMarkerText
=
DateTimeHelper
.
getFormattedDateForMessages
(
localDateTime
,
context
)
return
UrlPreviewUiModel
(
message
,
url
,
message
.
id
,
title
,
hostname
,
description
,
thumb
,
getReactions
(
message
),
preview
=
message
.
copy
(
message
=
url
.
url
),
unread
=
message
.
unread
)
getReactions
(
message
),
preview
=
message
.
copy
(
message
=
url
.
url
),
unread
=
message
.
unread
,
showDayMarker
=
false
,
currentDayMarkerText
=
dayMarkerText
)
}
private
fun
mapAttachment
(
message
:
Message
,
attachment
:
Attachment
):
BaseUiModel
<
*
>?
{
...
...
@@ -304,10 +314,14 @@ class UiModelMapper @Inject constructor(
val
content
=
stripMessageQuotes
(
message
)
val
id
=
attachmentId
(
message
,
attachment
)
val
localDateTime
=
DateTimeHelper
.
getLocalDateTime
(
message
.
timestamp
)
val
dayMarkerText
=
DateTimeHelper
.
getFormattedDateForMessages
(
localDateTime
,
context
)
ColorAttachmentUiModel
(
attachmentUrl
=
url
,
id
=
id
,
color
=
color
.
color
,
text
=
text
,
message
=
message
,
rawData
=
attachment
,
messageId
=
message
.
id
,
reactions
=
getReactions
(
message
),
preview
=
message
.
copy
(
message
=
content
.
message
),
unread
=
message
.
unread
)
preview
=
message
.
copy
(
message
=
content
.
message
),
unread
=
message
.
unread
,
showDayMarker
=
false
,
currentDayMarkerText
=
dayMarkerText
)
}
}
...
...
@@ -332,10 +346,14 @@ class UiModelMapper @Inject constructor(
}
val
id
=
attachmentId
(
message
,
attachment
)
val
localDateTime
=
DateTimeHelper
.
getLocalDateTime
(
message
.
timestamp
)
val
dayMarkerText
=
DateTimeHelper
.
getFormattedDateForMessages
(
localDateTime
,
context
)
AuthorAttachmentUiModel
(
attachmentUrl
=
url
,
id
=
id
,
name
=
authorName
,
icon
=
authorIcon
,
fields
=
fieldsText
,
message
=
message
,
rawData
=
attachment
,
messageId
=
message
.
id
,
reactions
=
getReactions
(
message
),
preview
=
message
.
copy
(
message
=
content
.
message
),
unread
=
message
.
unread
)
preview
=
message
.
copy
(
message
=
content
.
message
),
unread
=
message
.
unread
,
showDayMarker
=
false
,
currentDayMarkerText
=
dayMarkerText
)
}
}
...
...
@@ -349,11 +367,17 @@ class UiModelMapper @Inject constructor(
is
GenericFileAttachment
->
context
.
getString
(
R
.
string
.
msg_preview_file
)
else
->
attachment
.
text
?:
""
}
val
localDateTime
=
DateTimeHelper
.
getLocalDateTime
(
message
.
timestamp
)
val
dayMarkerText
=
DateTimeHelper
.
getFormattedDateForMessages
(
localDateTime
,
context
)
val
content
=
stripMessageQuotes
(
message
)
return
MessageAttachmentUiModel
(
message
=
content
,
rawData
=
message
,
messageId
=
message
.
id
,
time
=
time
,
senderName
=
attachmentAuthor
,
content
=
attachmentText
,
isPinned
=
message
.
pinned
,
reactions
=
getReactions
(
message
),
preview
=
message
.
copy
(
message
=
content
.
message
),
unread
=
message
.
unread
)
preview
=
message
.
copy
(
message
=
content
.
message
),
unread
=
message
.
unread
,
currentDayMarkerText
=
dayMarkerText
,
showDayMarker
=
false
)
}
private
fun
mapFileAttachment
(
message
:
Message
,
attachment
:
FileAttachment
):
BaseUiModel
<
*
>?
{
...
...
@@ -362,19 +386,27 @@ class UiModelMapper @Inject constructor(
val
attachmentText
=
attachmentText
(
attachment
)
val
attachmentDescription
=
attachmentDescription
(
attachment
)
val
id
=
attachmentId
(
message
,
attachment
)
val
localDateTime
=
DateTimeHelper
.
getLocalDateTime
(
message
.
timestamp
)
val
dayMarkerText
=
DateTimeHelper
.
getFormattedDateForMessages
(
localDateTime
,
context
)
return
when
(
attachment
)
{
is
ImageAttachment
->
ImageAttachmentUiModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
,
attachmentText
,
attachmentDescription
,
id
,
getReactions
(
message
),
preview
=
message
.
copy
(
message
=
context
.
getString
(
R
.
string
.
msg_preview_photo
)),
unread
=
message
.
unread
)
preview
=
message
.
copy
(
message
=
context
.
getString
(
R
.
string
.
msg_preview_photo
)),
unread
=
message
.
unread
,
showDayMarker
=
false
,
currentDayMarkerText
=
dayMarkerText
)
is
VideoAttachment
->
VideoAttachmentUiModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
,
id
,
getReactions
(
message
),
preview
=
message
.
copy
(
message
=
context
.
getString
(
R
.
string
.
msg_preview_video
)),
unread
=
message
.
unread
)
preview
=
message
.
copy
(
message
=
context
.
getString
(
R
.
string
.
msg_preview_video
)),
unread
=
message
.
unread
,
showDayMarker
=
false
,
currentDayMarkerText
=
dayMarkerText
)
is
AudioAttachment
->
AudioAttachmentUiModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
,
id
,
getReactions
(
message
),
preview
=
message
.
copy
(
message
=
context
.
getString
(
R
.
string
.
msg_preview_audio
)),
unread
=
message
.
unread
)
preview
=
message
.
copy
(
message
=
context
.
getString
(
R
.
string
.
msg_preview_audio
)),
unread
=
message
.
unread
,
showDayMarker
=
false
,
currentDayMarkerText
=
dayMarkerText
)
is
GenericFileAttachment
->
GenericFileAttachmentUiModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
,
id
,
getReactions
(
message
),
preview
=
message
.
copy
(
message
=
context
.
getString
(
R
.
string
.
msg_preview_file
)),
unread
=
message
.
unread
)
preview
=
message
.
copy
(
message
=
context
.
getString
(
R
.
string
.
msg_preview_file
)),
unread
=
message
.
unread
,
showDayMarker
=
false
,
currentDayMarkerText
=
dayMarkerText
)
else
->
null
}
}
...
...
@@ -434,11 +466,15 @@ class UiModelMapper @Inject constructor(
null
}
val
localDateTime
=
DateTimeHelper
.
getLocalDateTime
(
message
.
timestamp
)
val
dayMarkerText
=
DateTimeHelper
.
getFormattedDateForMessages
(
localDateTime
,
context
)
val
content
=
getContent
(
stripMessageQuotes
(
message
))
MessageUiModel
(
message
=
stripMessageQuotes
(
message
),
rawData
=
message
,
messageId
=
message
.
id
,
avatar
=
avatar
!!
,
time
=
time
,
senderName
=
sender
,
content
=
content
,
isPinned
=
message
.
pinned
,
reactions
=
getReactions
(
message
),
isFirstUnread
=
false
,
preview
=
preview
,
isTemporary
=
isTemp
,
unread
=
unread
)
content
=
content
,
isPinned
=
message
.
pinned
,
currentDayMarkerText
=
dayMarkerText
,
showDayMarker
=
false
,
reactions
=
getReactions
(
message
),
isFirstUnread
=
false
,
preview
=
preview
,
isTemporary
=
isTemp
,
unread
=
unread
)
}
private
fun
mapMessagePreview
(
message
:
Message
):
Message
{
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/UrlPreviewUiModel.kt
View file @
7afef2b9
...
...
@@ -17,7 +17,9 @@ data class UrlPreviewUiModel(
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
,
override
var
unread
:
Boolean
?
=
null
,
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
()
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
(),
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
)
:
BaseUiModel
<
Url
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
URL_PREVIEW
.
viewType
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/VideoAttachmentUiModel.kt
View file @
7afef2b9
...
...
@@ -16,7 +16,9 @@ data class VideoAttachmentUiModel(
override
var
preview
:
Message
?
=
null
,
override
var
isTemporary
:
Boolean
=
false
,
override
var
unread
:
Boolean
?
=
null
,
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
()
override
var
menuItemsToHide
:
MutableList
<
Int
>
=
mutableListOf
(),
override
var
currentDayMarkerText
:
String
,
override
var
showDayMarker
:
Boolean
)
:
BaseFileAttachmentUiModel
<
VideoAttachment
>
{
override
val
viewType
:
Int
get
()
=
BaseUiModel
.
ViewType
.
VIDEO_ATTACHMENT
.
viewType
...
...
app/src/main/res/layout/item_message.xml
View file @
7afef2b9
...
...
@@ -13,6 +13,47 @@
android:paddingEnd=
"@dimen/screen_edge_left_and_right_padding"
android:paddingBottom=
"@dimen/message_item_top_and_bottom_padding"
>
<LinearLayout
android:id=
"@+id/day_marker_layout"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
android:paddingBottom=
"8dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/new_messages_notif"
>
<View
android:layout_width=
"0px"
android:layout_height=
"1dp"
android:layout_weight=
"1"
android:background=
"@color/colorDivider"
/>
<TextView
android:id=
"@+id/day"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"16dp"
android:textAppearance=
"@style/Message.DayMarker"
tools:text=
"Wednesday"
/>
<View
android:layout_width=
"0dp"
android:layout_height=
"1dp"
android:layout_weight=
"1"
android:background=
"@color/colorDivider"
/>
</LinearLayout>
<include
android:id=
"@+id/layout_avatar"
layout=
"@layout/avatar"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/text_sender"
/>
<LinearLayout
android:id=
"@+id/new_messages_notif"
android:layout_width=
"match_parent"
...
...
@@ -50,7 +91,7 @@
<include
android:id=
"@+id/layout_avatar"
layout=
"@layout/avatar"
android:layout_width=
"
40
dp"
android:layout_width=
"
38
dp"
android:layout_height=
"40dp"
android:layout_marginTop=
"5dp"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -63,8 +104,9 @@
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintLeft_toRightOf=
"@+id/layout_avatar"
app:layout_constraintStart_toEndOf=
"@+id/layout_avatar"
app:layout_constraintTop_toBottomOf=
"@+id/
new_messages_notif
"
app:layout_constraintTop_toBottomOf=
"@+id/
day_marker_layout
"
tools:text=
"Ronald Perkins"
/>
<TextView
...
...
app/src/main/res/values-es/strings.xml
View file @
7afef2b9
This diff is collapsed.
Click to expand it.
app/src/main/res/values-fr/strings.xml
View file @
7afef2b9
...
...
@@ -72,6 +72,7 @@
<string
name=
"msg_new_user_agreement"
>
En procédant, vous acceptez notre\n%1$s et %2$s
</string>
<string
name=
"msg_2fa_code"
>
Code 2FA
</string>
<string
name=
"msg_yesterday"
>
Hier
</string>
<string
name=
"msg_today"
>
Aujourd\'hui
</string>
<string
name=
"msg_message"
>
Message
</string>
<string
name=
"msg_this_room_is_read_only"
>
Cette salle est seulement de lecture
</string>
<string
name=
"msg_invalid_2fa_code"
>
Code 2FA non valide
</string>
...
...
app/src/main/res/values-hi-rIN/strings.xml
View file @
7afef2b9
...
...
@@ -65,6 +65,7 @@
<string
name=
"msg_new_user_agreement"
>
आगे बढ़कर आप हमारे %1$s और %2$s से सहमत हो रहे हैं
</string>
<string
name=
"msg_2fa_code"
>
कोड 2FA
</string>
<string
name=
"msg_yesterday"
>
कल
</string>
<string
name=
"msg_today"
>
आज
</string>
<string
name=
"msg_message"
>
संदेश
</string>
<string
name=
"msg_this_room_is_read_only"
>
यह रूम केवल पढ़ने के लिए है
</string>
<string
name=
"msg_invalid_2fa_code"
>
अमान्य 2FA कोड
</string>
...
...
app/src/main/res/values-pt-rBR/strings.xml
View file @
7afef2b9
...
...
@@ -64,7 +64,8 @@
<string
name=
"msg_invalid_email"
>
Por favor informe um e-mail válido
</string>
<string
name=
"msg_new_user_agreement"
>
Ao proceder você concorda com nossos %1$s e %2$s
</string>
<string
name=
"msg_2fa_code"
>
Código 2FA
</string>
<string
name=
"msg_yesterday"
>
ontem
</string>
<string
name=
"msg_yesterday"
>
Ontem
</string>
<string
name=
"msg_today"
>
Hoje
</string>
<string
name=
"msg_message"
>
Mensagem
</string>
<string
name=
"msg_this_room_is_read_only"
>
Este chat é apenas de leitura
</string>
<string
name=
"msg_invalid_2fa_code"
>
Código 2FA inválido
</string>
...
...
app/src/main/res/values-uk-rRU/strings.xml
View file @
7afef2b9
...
...
@@ -64,6 +64,7 @@
<string
name=
"msg_new_user_agreement"
>
Продолжая, вы соглашаетесь с нашими\n%1$s и %2$s
</string>
<string
name=
"msg_2fa_code"
>
Код 2FA
</string>
<string
name=
"msg_yesterday"
>
Вчера
</string>
<string
name=
"msg_today"
>
Сьогодні
</string>
<string
name=
"msg_message"
>
Сообщение
</string>
<string
name=
"msg_this_room_is_read_only"
>
Этот канал только для чтения
</string>
<string
name=
"msg_invalid_2fa_code"
>
Неверный код 2FA
</string>
...
...
@@ -173,8 +174,7 @@
<string
name=
"permission_starring_not_allowed"
>
Отмечивание запрещено
</string>
<!-- Search message -->
<!-- TODO Add proper translation-->
<string
name=
"title_search_message"
>
Search message
</string>
<string
name=
"title_search_message"
>
Поиск сообщения
</string>
<!-- Favorite/Unfavorite chat room -->
<string
name=
"title_favorite_chat"
>
Добавить чат в избранное
</string>
...
...
@@ -266,5 +266,5 @@
<string
name=
"notif_action_reply_hint"
>
ОТВЕТИТЬ
</string>
<string
name=
"notif_error_sending"
>
Ошибка ответа. Пожалуйста, попробуйте еще раз.
</string>
<string
name=
"notif_success_sending"
>
Сообщение отправлено %1$s!
</string>
<string
name=
"msg_log_out"
>
В
иходьте
…
</string>
<string
name=
"msg_log_out"
>
В
ыход
…
</string>
</resources>
app/src/main/res/values/colors.xml
View file @
7afef2b9
...
...
@@ -44,6 +44,8 @@
<color
name=
"quoteBar"
>
#A0A0A0
</color>
<color
name=
"colorDivider"
>
#1F000000
</color>
<!-- Suggestions -->
<color
name=
"suggestion_background_color"
>
@color/colorWhite
</color>
...
...
app/src/main/res/values/fonts.xml
0 → 100644
View file @
7afef2b9
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name=
"font_fontFamily_medium"
translatable=
"false"
>
sans-serif-medium
</string>
</resources>
app/src/main/res/values/strings.xml
View file @
7afef2b9
...
...
@@ -67,6 +67,7 @@
<string
name=
"msg_2fa_code"
>
2FA Code
</string>
<string
name=
"msg_more_than_ninety_nine_unread_messages"
translatable=
"false"
>
99+
</string>
<string
name=
"msg_yesterday"
>
Yesterday
</string>
<string
name=
"msg_today"
>
Today
</string>
<string
name=
"msg_message"
>
Message
</string>
<string
name=
"msg_this_room_is_read_only"
>
This room is read only
</string>
<string
name=
"msg_invalid_2fa_code"
>
Invalid 2FA Code
</string>
...
...
app/src/main/res/values/styles.xml
View file @
7afef2b9
...
...
@@ -101,6 +101,12 @@
<item
name=
"android:textColor"
>
@color/colorPrimaryText
</item>
</style>
<style
name=
"Message.DayMarker"
parent=
"TextAppearance.AppCompat"
>
<item
name=
"android:textSize"
>
14sp
</item>
<item
name=
"android:textColor"
>
@color/colorPrimaryText
</item>
<item
name=
"android:fontFamily"
>
@string/font_fontFamily_medium
</item>
</style>
<style
name=
"Message.Quote.TextView"
parent=
"Message.TextView"
>
<item
name=
"android:textColor"
>
@color/colorPrimaryText
</item>
</style>
...
...
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