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
07d9c48a
Commit
07d9c48a
authored
Apr 28, 2019
by
Hussein El Feky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Typing +:emoji_name: reacts to last message
parent
521f0a8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
15 deletions
+37
-15
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+16
-3
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+21
-12
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
07d9c48a
...
...
@@ -121,6 +121,7 @@ class ChatRoomPresenter @Inject constructor(
private
var
lastState
=
manager
.
state
private
var
typingStatusList
=
arrayListOf
<
String
>()
private
val
roomChangesChannel
=
Channel
<
Room
>(
Channel
.
CONFLATED
)
private
var
lastMessageId
:
String
?
=
null
private
lateinit
var
draftKey
:
String
fun
setupChatRoom
(
...
...
@@ -220,6 +221,7 @@ class ChatRoomPresenter @Inject constructor(
isBroadcast
=
chatIsBroadcast
,
isRoom
=
true
)
)
lastMessageId
=
localMessages
.
first
().
id
val
lastSyncDate
=
messagesRepository
.
getLastSyncDate
(
chatRoomId
)
if
(
oldMessages
.
isNotEmpty
()
&&
lastSyncDate
!=
null
)
{
view
.
showMessages
(
oldMessages
,
clearDataSet
)
...
...
@@ -368,6 +370,7 @@ class ChatRoomPresenter @Inject constructor(
throw
ex
}
}
lastMessageId
=
id
}
else
{
client
.
updateMessage
(
chatRoomId
,
messageId
,
text
)
}
...
...
@@ -1071,7 +1074,7 @@ class ChatRoomPresenter @Inject constructor(
/**
* Send an emoji reaction to a message.
*/
fun
react
(
messageId
:
String
,
emoji
:
String
)
{
fun
react
(
messageId
:
String
,
emoji
:
String
,
roomId
:
String
)
{
launchUI
(
strategy
)
{
try
{
retryIO
(
"toggleEmoji($messageId, $emoji)"
)
{
...
...
@@ -1080,6 +1083,10 @@ class ChatRoomPresenter @Inject constructor(
logReactionEvent
()
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
// emoji is not valid, post it
sendMessage
(
roomId
,
"+$emoji"
,
null
)
}
finally
{
view
.
clearMessageComposition
(
true
)
}
}
}
...
...
@@ -1178,6 +1185,7 @@ class ChatRoomPresenter @Inject constructor(
// command is not valid, post it
sendMessage
(
roomId
,
text
,
null
)
}
finally
{
view
.
clearMessageComposition
(
true
)
view
.
enableSendMessageButton
()
}
}
...
...
@@ -1246,8 +1254,8 @@ class ChatRoomPresenter @Inject constructor(
launchUI
(
strategy
)
{
val
viewModelStreamedMessage
=
mapper
.
map
(
streamedMessage
,
RoomUiModel
(
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
,
isRoom
=
true
)
roles
=
chatRoles
,
isBroadcast
=
chatIsBroadcast
,
isRoom
=
true
)
)
val
roomMessages
=
messagesRepository
.
getByRoomId
(
streamedMessage
.
roomId
)
val
index
=
roomMessages
.
indexOfFirst
{
msg
->
msg
.
id
==
streamedMessage
.
id
}
...
...
@@ -1281,6 +1289,7 @@ class ChatRoomPresenter @Inject constructor(
fun
clearDraftMessage
()
{
localRepository
.
clear
(
draftKey
)
}
/**
* Get unfinished message from local repository, when user left chat room without
* sending a message and now the user is back.
...
...
@@ -1290,4 +1299,8 @@ class ChatRoomPresenter @Inject constructor(
fun
getDraftUnfinishedMessage
():
String
?
{
return
localRepository
.
get
(
draftKey
)
}
fun
getLastMessageId
():
String
?
{
return
lastMessageId
}
}
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
07d9c48a
...
...
@@ -148,10 +148,14 @@ private const val BUNDLE_CHAT_ROOM_MESSAGE = "chat_room_message"
class
ChatRoomFragment
:
Fragment
(),
ChatRoomView
,
EmojiKeyboardListener
,
EmojiReactionListener
,
ChatRoomAdapter
.
OnActionSelected
,
Drawable
.
Callback
{
@Inject
lateinit
var
presenter
:
ChatRoomPresenter
@Inject
lateinit
var
parser
:
MessageParser
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
@Inject
lateinit
var
navigator
:
ChatRoomNavigator
@Inject
lateinit
var
presenter
:
ChatRoomPresenter
@Inject
lateinit
var
parser
:
MessageParser
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
@Inject
lateinit
var
navigator
:
ChatRoomNavigator
private
lateinit
var
adapter
:
ChatRoomAdapter
internal
lateinit
var
chatRoomId
:
String
private
lateinit
var
chatRoomName
:
String
...
...
@@ -476,11 +480,17 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
sendMessage
(
text
:
String
)
{
ui
{
if
(!
text
.
isBlank
())
{
if
(!
text
.
startsWith
(
"/"
))
{
presenter
.
sendMessage
(
chatRoomId
,
text
,
editingMessageId
)
}
else
{
if
(
text
.
startsWith
(
"/"
))
{
presenter
.
runCommand
(
text
,
chatRoomId
)
return
@ui
}
else
if
(
text
.
startsWith
(
"+"
)
&&
presenter
.
getLastMessageId
()
!=
null
)
{
val
trimmedText
=
text
.
substring
(
1
).
trimEnd
()
if
(
trimmedText
.
length
-
trimmedText
.
removeSurrounding
(
":"
).
length
==
2
)
{
presenter
.
react
(
presenter
.
getLastMessageId
()
!!
,
trimmedText
,
chatRoomId
)
return
@ui
}
}
presenter
.
sendMessage
(
chatRoomId
,
text
,
editingMessageId
)
}
}
}
...
...
@@ -524,7 +534,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
clearMessageComposition
(
deleteMessage
:
Boolean
)
{
ui
{
citation
=
null
...
...
@@ -671,11 +680,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
override
fun
onReactionTouched
(
messageId
:
String
,
emojiShortname
:
String
)
{
presenter
.
react
(
messageId
,
emojiShortname
)
presenter
.
react
(
messageId
,
emojiShortname
,
chatRoomId
)
}
override
fun
onReactionAdded
(
messageId
:
String
,
emoji
:
Emoji
)
{
presenter
.
react
(
messageId
,
emoji
.
shortname
)
presenter
.
react
(
messageId
,
emoji
.
shortname
,
chatRoomId
)
}
override
fun
onReactionLongClicked
(
...
...
@@ -896,7 +905,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
button_take_a_photo
.
setOnClickListener
{
// Check for camera permission
context
?.
let
{
if
(
hasCameraPermission
(
it
))
{
if
(
hasCameraPermission
(
it
))
{
dispatchTakePictureIntent
()
}
else
{
getCameraPermission
(
this
)
...
...
@@ -964,7 +973,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
grantResults
:
IntArray
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
)
when
(
requestCode
)
{
when
(
requestCode
)
{
AndroidPermissionsHelper
.
CAMERA_CODE
->
{
if
(
grantResults
.
isNotEmpty
()
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
// permission was granted
...
...
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