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
a3f7898b
Commit
a3f7898b
authored
Oct 29, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'beta' of github.com:RocketChat/Rocket.Chat.Android into improvement/image-compression
parents
4c8e492a
041a0f0d
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
102 additions
and
74 deletions
+102
-74
RegisterUsernameFragment.kt
...ntication/registerusername/ui/RegisterUsernameFragment.kt
+3
-3
ResetPasswordFragment.kt
.../authentication/resetpassword/ui/ResetPasswordFragment.kt
+3
-3
MessageInfoFragment.kt
.../rocket/android/chatinformation/ui/MessageInfoFragment.kt
+4
-4
PeopleSuggestionsAdapter.kt
...cket/android/chatroom/adapter/PeopleSuggestionsAdapter.kt
+4
-4
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+5
-8
Dialog.kt
app/src/main/java/chat/rocket/android/chatroom/ui/Dialog.kt
+24
-15
Menu.kt
app/src/main/java/chat/rocket/android/chatroom/ui/Menu.kt
+11
-0
RoomUiModelMapper.kt
...hat/rocket/android/chatrooms/adapter/RoomUiModelMapper.kt
+12
-10
ChatRoomsAdapter.kt
...java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
+8
-7
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+3
-0
ChatRoomsViewModel.kt
.../rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
+8
-3
MessageParser.kt
...src/main/java/chat/rocket/android/helper/MessageParser.kt
+6
-1
MembersAdapter.kt
...ava/chat/rocket/android/members/adapter/MembersAdapter.kt
+1
-0
MemberUiModel.kt
...java/chat/rocket/android/members/uimodel/MemberUiModel.kt
+5
-0
Ui.kt
app/src/main/java/chat/rocket/android/util/extensions/Ui.kt
+0
-13
item_member.xml
app/src/main/res/layout/item_member.xml
+5
-3
No files found.
app/src/main/java/chat/rocket/android/authentication/registerusername/ui/RegisterUsernameFragment.kt
View file @
a3f7898b
...
...
@@ -8,6 +8,7 @@ import android.view.View
import
android.view.ViewGroup
import
androidx.core.content.ContextCompat
import
androidx.core.view.ViewCompat
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
chat.rocket.android.R
import
chat.rocket.android.analytics.AnalyticsManager
...
...
@@ -16,7 +17,6 @@ import chat.rocket.android.authentication.registerusername.presentation.Register
import
chat.rocket.android.authentication.registerusername.presentation.RegisterUsernameView
import
chat.rocket.android.util.extension.asObservable
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.showKeyboard
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.textContent
...
...
@@ -113,13 +113,13 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView {
override
fun
showLoading
()
{
ui
{
disableUserInput
()
view_loading
.
setVisible
(
true
)
view_loading
.
isVisible
=
true
}
}
override
fun
hideLoading
()
{
ui
{
view_loading
.
setVisible
(
false
)
view_loading
.
isVisible
=
false
enableUserInput
()
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/resetpassword/ui/ResetPasswordFragment.kt
View file @
a3f7898b
...
...
@@ -6,6 +6,7 @@ import android.view.View
import
android.view.ViewGroup
import
androidx.core.content.ContextCompat
import
androidx.core.view.ViewCompat
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
chat.rocket.android.R
import
chat.rocket.android.analytics.AnalyticsManager
...
...
@@ -15,7 +16,6 @@ import chat.rocket.android.authentication.resetpassword.presentation.ResetPasswo
import
chat.rocket.android.util.extension.asObservable
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.isEmail
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.showKeyboard
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.textContent
...
...
@@ -93,13 +93,13 @@ class ResetPasswordFragment : Fragment(), ResetPasswordView {
override
fun
showLoading
()
{
ui
{
disableUserInput
()
view_loading
.
setVisible
(
true
)
view_loading
.
isVisible
=
true
}
}
override
fun
hideLoading
()
{
ui
{
view_loading
.
setVisible
(
false
)
view_loading
.
isVisible
=
false
enableUserInput
()
}
}
...
...
app/src/main/java/chat/rocket/android/chatinformation/ui/MessageInfoFragment.kt
View file @
a3f7898b
...
...
@@ -4,6 +4,7 @@ import android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
androidx.recyclerview.widget.DefaultItemAnimator
import
androidx.recyclerview.widget.LinearLayoutManager
...
...
@@ -15,7 +16,6 @@ import chat.rocket.android.chatinformation.adapter.ReadReceiptAdapter
import
chat.rocket.android.chatinformation.presentation.MessageInfoPresenter
import
chat.rocket.android.chatinformation.presentation.MessageInfoView
import
chat.rocket.android.chatinformation.viewmodel.ReadReceiptViewModel
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.ui
import
dagger.android.support.AndroidSupportInjection
...
...
@@ -86,15 +86,15 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
override
fun
showLoading
()
{
ui
{
view_loading
.
setVisible
(
true
)
view_loading
.
isVisible
=
true
view_loading
.
show
()
}
}
override
fun
hideLoading
()
{
ui
{
view_loading
.
isVisible
=
false
view_loading
.
hide
()
view_loading
.
setVisible
(
false
)
}
}
...
...
@@ -103,4 +103,4 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
adapter
.
addAll
(
messageReceipts
)
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/adapter/PeopleSuggestionsAdapter.kt
View file @
a3f7898b
...
...
@@ -7,10 +7,10 @@ import android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.core.view.isVisible
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.PeopleSuggestionsAdapter.PeopleSuggestionViewHolder
import
chat.rocket.android.chatroom.uimodel.suggestion.PeopleSuggestionUiModel
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.suggestions.model.SuggestionModel
import
chat.rocket.android.suggestions.ui.BaseSuggestionViewHolder
import
chat.rocket.android.suggestions.ui.SuggestionsAdapter
...
...
@@ -58,9 +58,9 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg
username
.
text
=
item
.
username
name
.
text
=
item
.
name
if
(
item
.
imageUri
?.
isEmpty
()
!=
false
)
{
avatar
.
setVisible
(
false
)
avatar
.
isVisible
=
false
}
else
{
avatar
.
setVisible
(
true
)
avatar
.
isVisible
=
true
avatar
.
setImageURI
(
item
.
imageUri
)
}
val
status
=
item
.
status
...
...
@@ -68,7 +68,7 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg
val
statusDrawable
=
DrawableHelper
.
getUserStatusDrawable
(
status
,
itemView
.
context
)
statusView
.
setImageDrawable
(
statusDrawable
)
}
else
{
statusView
.
setVisible
(
false
)
statusView
.
isVisible
=
false
}
setOnClickListener
{
itemClickListener
?.
onClick
(
item
)
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
a3f7898b
...
...
@@ -266,16 +266,16 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
onPause
()
{
super
.
onPause
()
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
dismissEmojiKeyboard
()
activity
?.
invalidateOptionsMenu
()
}
private
fun
dismissEmojiKeyboard
()
{
fun
dismissEmojiKeyboard
()
{
// Check if the keyboard was ever initialized.
// It may be the case when you are looking a not joined room
if
(
::
emojiKeyboardPopup
.
isInitialized
)
{
emojiKeyboardPopup
.
dismiss
()
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
}
}
...
...
@@ -784,8 +784,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
context
:
Context
)
{
if
(
f
is
MessageActionsBottomSheet
)
{
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
emojiKeyboardPopup
.
dismiss
()
dismissEmojiKeyboard
()
}
}
},
...
...
@@ -805,9 +804,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
it
.
onBackPressed
()
}
KeyboardHelper
.
hideSoftKeyboard
(
it
)
emojiKeyboardPopup
.
dismiss
()
dismissEmojiKeyboard
()
}
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
}
}
...
...
@@ -917,8 +915,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
setReactionButtonIcon
(
R
.
drawable
.
ic_keyboard_black_24dp
)
}
else
{
// If popup is showing, simply dismiss it to show the underlying text keyboard
emojiKeyboardPopup
.
dismiss
()
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
dismissEmojiKeyboard
()
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/Dialog.kt
View file @
a3f7898b
...
...
@@ -24,21 +24,30 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) {
description
.
text
.
clear
()
when
{
mimeType
.
startsWith
(
"image"
)
->
{
GlideApp
.
with
(
context
)
.
asBitmap
()
.
load
(
uri
)
.
fitCenter
()
.
into
(
object
:
SimpleTarget
<
Bitmap
>()
{
override
fun
onResourceReady
(
resource
:
Bitmap
,
transition
:
Transition
<
in
Bitmap
>?
)
{
bitmap
=
resource
imagePreview
.
setImageBitmap
(
resource
)
imagePreview
.
isVisible
=
true
}
})
if
(
mimeType
.
contains
(
"gif"
))
{
GlideApp
.
with
(
context
)
.
asGif
()
.
load
(
uri
)
.
fitCenter
()
.
into
(
imagePreview
)
}
else
{
GlideApp
.
with
(
context
)
.
asBitmap
()
.
load
(
uri
)
.
fitCenter
()
.
into
(
object
:
SimpleTarget
<
Bitmap
>()
{
override
fun
onResourceReady
(
resource
:
Bitmap
,
transition
:
Transition
<
in
Bitmap
>?
)
{
bitmap
=
resource
imagePreview
.
setImageBitmap
(
resource
)
}
})
}
imagePreview
.
isVisible
=
true
}
mimeType
.
startsWith
(
"video"
)
->
audioVideoAttachment
.
isVisible
=
true
else
->
{
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/Menu.kt
View file @
a3f7898b
...
...
@@ -79,6 +79,17 @@ private fun ChatRoomFragment.setupSearchMessageMenuItem(menu: Menu, context: Con
.
setShowAsActionFlags
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
or
MenuItem
.
SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
)
.
setOnActionExpandListener
(
object
:
MenuItem
.
OnActionExpandListener
{
override
fun
onMenuItemActionExpand
(
item
:
MenuItem
?):
Boolean
{
dismissEmojiKeyboard
()
return
true
}
override
fun
onMenuItemActionCollapse
(
item
:
MenuItem
?):
Boolean
{
dismissEmojiKeyboard
()
return
true
}
})
(
searchItem
?.
actionView
as
?
SearchView
)
?.
let
{
// TODO: Check why we need to stylize the search text programmatically instead of by defining it in the styles.xml (ChatRoom.SearchView)
...
...
app/src/main/java/chat/rocket/android/chatrooms/adapter/RoomUiModelMapper.kt
View file @
a3f7898b
...
...
@@ -42,27 +42,28 @@ class RoomUiModelMapper(
userInteractor
.
get
()
}
fun
map
(
rooms
:
List
<
ChatRoom
>,
grouped
:
Boolean
=
false
):
List
<
ItemHolder
<*
>>
{
fun
map
(
rooms
:
List
<
ChatRoom
>,
grouped
:
Boolean
=
false
,
showLastMessage
:
Boolean
=
true
):
List
<
ItemHolder
<*
>>
{
val
list
=
ArrayList
<
ItemHolder
<*>>(
rooms
.
size
+
4
)
var
lastType
:
String
?
=
null
rooms
.
forEach
{
room
->
if
(
grouped
&&
lastType
!=
room
.
chatRoom
.
type
)
{
list
.
add
(
HeaderItemHolder
(
roomType
(
room
.
chatRoom
.
type
)))
}
list
.
add
(
RoomItemHolder
(
map
(
room
)))
list
.
add
(
RoomItemHolder
(
map
(
room
,
showLastMessage
)))
lastType
=
room
.
chatRoom
.
type
}
return
list
}
fun
map
(
spotlight
:
SpotlightResult
):
List
<
ItemHolder
<*
>>
{
fun
map
(
spotlight
:
SpotlightResult
,
showLastMessage
:
Boolean
=
true
):
List
<
ItemHolder
<*
>>
{
val
list
=
ArrayList
<
ItemHolder
<*>>(
spotlight
.
users
.
size
+
spotlight
.
rooms
.
size
)
spotlight
.
users
.
filterNot
{
it
.
username
.
isNullOrEmpty
()
}.
forEach
{
user
->
list
.
add
(
RoomItemHolder
(
mapUser
(
user
)))
}
spotlight
.
rooms
.
filterNot
{
it
.
name
.
isNullOrEmpty
()
}.
forEach
{
room
->
list
.
add
(
RoomItemHolder
(
mapRoom
(
room
)))
list
.
add
(
RoomItemHolder
(
mapRoom
(
room
,
showLastMessage
)))
}
return
list
...
...
@@ -86,21 +87,21 @@ class RoomUiModelMapper(
}
}
private
fun
mapRoom
(
room
:
Room
):
RoomUiModel
{
private
fun
mapRoom
(
room
:
Room
,
showLastMessage
:
Boolean
=
true
):
RoomUiModel
{
return
with
(
room
)
{
RoomUiModel
(
id
=
id
,
name
=
name
!!
,
type
=
type
,
avatar
=
serverUrl
.
avatarUrl
(
name
!!
,
isGroupOrChannel
=
true
),
lastMessage
=
mapLastMessage
(
lastMessage
?.
sender
?.
id
,
lastMessage
?.
sender
?.
username
,
lastMessage
=
if
(
showLastMessage
)
{
mapLastMessage
(
lastMessage
?.
sender
?.
id
,
lastMessage
?.
sender
?.
username
,
lastMessage
?.
sender
?.
name
,
lastMessage
?.
message
,
isDirectMessage
=
type
is
RoomType
.
DirectMessage
)
isDirectMessage
=
type
is
RoomType
.
DirectMessage
)
}
else
{
null
}
)
}
}
fun
map
(
chatRoom
:
ChatRoom
):
RoomUiModel
{
fun
map
(
chatRoom
:
ChatRoom
,
showLastMessage
:
Boolean
=
true
):
RoomUiModel
{
return
with
(
chatRoom
.
chatRoom
)
{
val
isUnread
=
alert
||
unread
>
0
val
type
=
roomTypeOf
(
type
)
...
...
@@ -113,9 +114,9 @@ class RoomUiModelMapper(
serverUrl
.
avatarUrl
(
name
,
isGroupOrChannel
=
true
)
}
val
unread
=
mapUnread
(
unread
)
val
lastMessage
=
mapLastMessage
(
lastMessageUserId
,
chatRoom
.
lastMessageUserName
,
val
lastMessage
=
if
(
showLastMessage
)
{
mapLastMessage
(
lastMessageUserId
,
chatRoom
.
lastMessageUserName
,
chatRoom
.
lastMessageUserFullName
,
lastMessageText
,
isUnread
,
type
is
RoomType
.
DirectMessage
)
type
is
RoomType
.
DirectMessage
)
}
else
{
null
}
val
open
=
open
RoomUiModel
(
...
...
@@ -148,6 +149,7 @@ class RoomUiModelMapper(
private
fun
mapLastMessage
(
userId
:
String
?,
name
:
String
?,
fullName
:
String
?,
text
:
String
?,
unread
:
Boolean
=
false
,
isDirectMessage
:
Boolean
=
false
):
CharSequence
?
{
return
if
(!
settings
.
showLastMessage
())
{
null
}
else
if
(
name
!=
null
&&
text
!=
null
)
{
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsAdapter.kt
View file @
a3f7898b
...
...
@@ -12,6 +12,7 @@ import android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.core.view.isVisible
import
chat.rocket.android.R
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.checkIfMyself
...
...
@@ -53,13 +54,13 @@ class ChatRoomsAdapter(
bindName
(
chatRoom
,
text_chat_name
)
bindIcon
(
chatRoom
,
image_chat_icon
)
if
(
settings
.
showLastMessage
())
{
text_last_message
.
setVisible
(
true
)
text_last_message_date_time
.
setVisible
(
true
)
text_last_message
.
isVisible
=
true
text_last_message_date_time
.
isVisible
=
true
bindLastMessageDateTime
(
chatRoom
,
text_last_message_date_time
)
bindLastMessage
(
chatRoom
,
text_last_message
)
}
else
{
text_last_message
.
setVisible
(
false
)
text_last_message_date_time
.
setVisible
(
false
)
text_last_message
.
isVisible
=
false
text_last_message_date_time
.
isVisible
=
false
}
bindUnreadMessages
(
chatRoom
,
text_total_unread_messages
)
...
...
@@ -178,13 +179,13 @@ class ChatRoomsAdapter(
when
{
totalUnreadMessage
in
1
..
99
->
{
textView
.
textContent
=
totalUnreadMessage
.
toString
()
textView
.
setVisible
(
true
)
textView
.
isVisible
=
true
}
totalUnreadMessage
>
99
->
{
textView
.
textContent
=
context
.
getString
(
R
.
string
.
msg_more_than_ninety_nine_unread_messages
)
textView
.
setVisible
(
true
)
textView
.
isVisible
=
true
}
else
->
textView
.
setVisible
(
false
)
else
->
textView
.
isVisible
=
false
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
a3f7898b
...
...
@@ -178,11 +178,14 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override
fun
onMenuItemActionCollapse
(
item
:
MenuItem
):
Boolean
{
// Simply setting sortView to visible won't work, so we invalidate the options
// to recreate the entire menu...
viewModel
.
showLastMessage
=
true
activity
?.
invalidateOptionsMenu
()
queryChatRoomsByName
(
null
)
return
true
}
override
fun
onMenuItemActionExpand
(
item
:
MenuItem
):
Boolean
{
viewModel
.
showLastMessage
=
false
sortView
?.
isVisible
=
false
return
true
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
View file @
a3f7898b
...
...
@@ -30,6 +30,7 @@ import timber.log.Timber
import
java.security.InvalidParameterException
import
kotlin.coroutines.experimental.coroutineContext
class
ChatRoomsViewModel
(
private
val
connectionManager
:
ConnectionManager
,
private
val
interactor
:
FetchChatRoomsInteractor
,
...
...
@@ -41,9 +42,11 @@ class ChatRoomsViewModel(
private
val
runContext
=
newSingleThreadContext
(
"chat-rooms-view-model"
)
private
val
client
=
connectionManager
.
client
private
var
loaded
=
false
var
showLastMessage
=
true
fun
getChatRooms
():
LiveData
<
RoomsModel
>
{
return
Transformations
.
switchMap
(
query
)
{
query
->
return
@switchMap
if
(
query
.
isSearch
())
{
this
@ChatRoomsViewModel
.
query
.
wrap
(
runContext
)
{
_
,
data
:
MutableLiveData
<
RoomsModel
>
->
val
string
=
(
query
as
Query
.
Search
).
query
...
...
@@ -53,11 +56,13 @@ class ChatRoomsViewModel(
// TODO - find a better way for cancellation checking
if
(!
coroutineContext
.
isActive
)
return
@wrap
val
rooms
=
repository
.
search
(
string
).
let
{
mapper
.
map
(
it
)
}
val
rooms
=
repository
.
search
(
string
).
let
{
mapper
.
map
(
it
,
showLastMessage
=
this
.
showLastMessage
)
}
data
.
postValue
(
rooms
.
toMutableList
()
+
LoadingItemHolder
())
if
(!
coroutineContext
.
isActive
)
return
@wrap
val
spotlight
=
spotlight
(
query
.
query
)
?.
let
{
mapper
.
map
(
it
)
}
val
spotlight
=
spotlight
(
query
.
query
)
?.
let
{
mapper
.
map
(
it
,
showLastMessage
=
this
.
showLastMessage
)
}
if
(!
coroutineContext
.
isActive
)
return
@wrap
spotlight
?.
let
{
...
...
@@ -72,7 +77,7 @@ class ChatRoomsViewModel(
.
distinct
()
.
transform
(
runContext
)
{
rooms
->
val
mappedRooms
=
rooms
?.
let
{
mapper
.
map
(
rooms
,
query
.
isGrouped
())
mapper
.
map
(
rooms
,
query
.
isGrouped
()
,
this
.
showLastMessage
)
}
if
(
loaded
&&
mappedRooms
?.
isEmpty
()
==
true
)
{
loadingState
.
postValue
(
LoadingState
.
Loaded
(
0
))
...
...
app/src/main/java/chat/rocket/android/helper/MessageParser.kt
View file @
a3f7898b
...
...
@@ -13,7 +13,6 @@ import android.text.style.ReplacementSpan
import
android.view.View
import
androidx.core.content.res.ResourcesCompat
import
androidx.core.util.PatternsCompat
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.ui.StrikethroughDelimiterProcessor
import
chat.rocket.android.emoji.EmojiParser
import
chat.rocket.android.emoji.EmojiRepository
...
...
@@ -32,6 +31,7 @@ import org.commonmark.node.Emphasis
import
org.commonmark.node.ListItem
import
org.commonmark.node.Node
import
org.commonmark.node.OrderedList
import
org.commonmark.node.SoftLineBreak
import
org.commonmark.node.StrongEmphasis
import
org.commonmark.parser.Parser
import
ru.noties.markwon.SpannableBuilder
...
...
@@ -219,6 +219,11 @@ class MessageParser @Inject constructor(
builder
.
append
(
'\n'
)
}
}
override
fun
visit
(
softLineBreak
:
SoftLineBreak
)
{
super
.
visit
(
softLineBreak
)
builder
.
append
(
"\n"
)
}
}
class
LinkVisitor
(
private
val
builder
:
SpannableBuilder
)
:
AbstractVisitor
()
{
...
...
app/src/main/java/chat/rocket/android/members/adapter/MembersAdapter.kt
View file @
a3f7898b
...
...
@@ -43,6 +43,7 @@ class MembersAdapter(private val listener: (MemberUiModel) -> Unit) :
fun
bind
(
memberUiModel
:
MemberUiModel
,
listener
:
(
MemberUiModel
)
->
Unit
)
=
with
(
itemView
)
{
image_avatar
.
setImageURI
(
memberUiModel
.
avatarUri
)
text_member
.
content
=
memberUiModel
.
displayName
text_member
.
setCompoundDrawablesRelativeWithIntrinsicBounds
(
DrawableHelper
.
getUserStatusDrawable
(
memberUiModel
.
status
,
context
),
null
,
null
,
null
)
setOnClickListener
{
listener
(
memberUiModel
)
}
}
}
...
...
app/src/main/java/chat/rocket/android/members/uimodel/MemberUiModel.kt
View file @
a3f7898b
...
...
@@ -3,6 +3,7 @@ package chat.rocket.android.members.uimodel
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.common.model.User
import
chat.rocket.common.model.UserStatus
import
chat.rocket.core.model.Value
class
MemberUiModel
(
...
...
@@ -16,6 +17,7 @@ class MemberUiModel(
val
username
:
String
?
val
email
:
String
?
val
utcOffset
:
Float
?
val
status
:
UserStatus
?
init
{
avatarUri
=
getUserAvatar
()
...
...
@@ -24,6 +26,7 @@ class MemberUiModel(
username
=
getUserUsername
()
email
=
getUserEmail
()
utcOffset
=
getUserUtcOffset
()
status
=
getUserStatus
()
}
private
fun
getUserAvatar
():
String
?
{
...
...
@@ -47,4 +50,6 @@ class MemberUiModel(
private
fun
getUserEmail
():
String
?
=
member
.
emails
?.
get
(
0
)
?.
address
private
fun
getUserUtcOffset
():
Float
?
=
member
.
utcOffset
private
fun
getUserStatus
():
UserStatus
?
=
member
.
status
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/util/extensions/Ui.kt
View file @
a3f7898b
...
...
@@ -37,19 +37,6 @@ fun FragmentActivity.clearLightStatusBar() {
}
}
// TODO: Remove. Use KTX instead.
fun
View
.
setVisible
(
visible
:
Boolean
)
{
visibility
=
if
(
visible
)
{
View
.
VISIBLE
}
else
{
View
.
GONE
}
}
fun
View
.
isVisible
():
Boolean
{
return
visibility
==
View
.
VISIBLE
}
fun
ViewGroup
.
inflate
(
@LayoutRes
resource
:
Int
,
attachToRoot
:
Boolean
=
false
):
View
=
LayoutInflater
.
from
(
context
).
inflate
(
resource
,
this
,
attachToRoot
)
...
...
app/src/main/res/layout/item_member.xml
View file @
a3f7898b
...
...
@@ -5,10 +5,10 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"?android:attr/selectableItemBackground"
android:paddingBottom=
"@dimen/member_item_top_and_bottom_padding"
android:paddingEnd=
"@dimen/screen_edge_left_and_right_padding"
android:paddingStart=
"@dimen/screen_edge_left_and_right_padding"
android:paddingTop=
"@dimen/member_item_top_and_bottom_padding"
>
android:paddingTop=
"@dimen/member_item_top_and_bottom_padding"
android:paddingEnd=
"@dimen/screen_edge_left_and_right_padding"
android:paddingBottom=
"@dimen/member_item_top_and_bottom_padding"
>
<include
android:id=
"@+id/layout_avatar"
...
...
@@ -24,9 +24,11 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:drawablePadding=
"@dimen/text_view_drawable_padding"
app:layout_constraintBottom_toBottomOf=
"@+id/layout_avatar"
app:layout_constraintLeft_toRightOf=
"@+id/layout_avatar"
app:layout_constraintTop_toTopOf=
"@+id/layout_avatar"
tools:drawableStart=
"@drawable/ic_status_invisible_12dp"
tools:text=
"Ronald Perkins"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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