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
1753e6b8
Unverified
Commit
1753e6b8
authored
Oct 23, 2018
by
Rafael Morales
Committed by
GitHub
Oct 23, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into basicauth
parents
ef0c17c5
427d6ced
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
22 deletions
+45
-22
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+5
-8
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
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
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
1753e6b8
...
...
@@ -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/Menu.kt
View file @
1753e6b8
...
...
@@ -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 @
1753e6b8
...
...
@@ -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/ChatRoomsFragment.kt
View file @
1753e6b8
...
...
@@ -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 @
1753e6b8
...
...
@@ -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 @
1753e6b8
...
...
@@ -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
()
{
...
...
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