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
a0486d28
Commit
a0486d28
authored
Feb 07, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement pin and unpin a message from a chat
parent
c9314b15
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
10 deletions
+40
-10
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+11
-0
ChatRoomAdapter.kt
...n/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
+21
-6
MessageViewModel.kt
...hat/rocket/android/chatroom/viewmodel/MessageViewModel.kt
+4
-2
message_actions.xml
app/src/main/res/menu/message_actions.xml
+1
-1
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+2
-1
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
a0486d28
...
...
@@ -246,6 +246,17 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
}
}
fun
unpinMessage
(
messageId
:
String
)
{
launchUI
(
strategy
)
{
//TODO: Check permissions.
try
{
client
.
unpinMessage
(
messageId
)
}
catch
(
e
:
RocketChatException
)
{
Timber
.
e
(
e
)
}
}
}
private
suspend
fun
listenMessages
(
roomId
:
String
)
{
launch
(
CommonPool
+
strategy
.
jobs
)
{
for
(
message
in
client
.
messagesChannel
)
{
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
View file @
a0486d28
...
...
@@ -21,7 +21,8 @@ import com.stfalcon.frescoimageviewer.ImageViewer
import
kotlinx.android.synthetic.main.avatar.view.*
import
kotlinx.android.synthetic.main.item_message.view.*
import
kotlinx.android.synthetic.main.message_attachment.view.*
import
ru.whalemare.sheetmenu.SheetMenu
import
ru.whalemare.sheetmenu.extension.inflate
import
ru.whalemare.sheetmenu.extension.toList
class
ChatRoomAdapter
(
private
val
serverUrl
:
String
,
private
val
roomType
:
String
,
...
...
@@ -98,10 +99,16 @@ class ChatRoomAdapter(private val serverUrl: String,
file_name
)
text_content
.
setOnClickListener
{
if
(!
message
.
systemMessage
)
{
SheetMenu
().
apply
{
click
=
this
@ViewHolder
menu
=
R
.
menu
.
message_actions
if
(!
message
.
isSystemMessage
)
{
val
menuItems
=
it
.
context
.
inflate
(
R
.
menu
.
message_actions
).
toList
()
menuItems
.
find
{
it
.
itemId
==
R
.
id
.
action_menu_msg_pin_unpin
}
?.
apply
{
val
isPinned
=
message
.
isPinned
setTitle
(
if
(
isPinned
)
R
.
string
.
action_msg_unpin
else
R
.
string
.
action_msg_pin
)
setChecked
(
isPinned
)
}
val
adapter
=
ActionListAdapter
(
menuItems
,
this
@ViewHolder
)
BottomSheetMenu
(
adapter
).
apply
{
}.
show
(
it
.
context
)
}
}
...
...
@@ -115,7 +122,15 @@ class ChatRoomAdapter(private val serverUrl: String,
R
.
id
.
action_menu_msg_reply
->
presenter
.
citeMessage
(
serverUrl
,
roomType
,
roomName
,
id
,
""
,
true
)
R
.
id
.
action_menu_msg_copy
->
presenter
.
copyMessage
(
id
)
R
.
id
.
action_menu_msg_edit
->
presenter
.
editMessage
(
roomId
,
id
,
getOriginalMessage
())
R
.
id
.
action_menu_msg_pin
->
presenter
.
pinMessage
(
id
)
R
.
id
.
action_menu_msg_pin_unpin
->
{
with
(
item
)
{
if
(!
isChecked
)
{
presenter
.
pinMessage
(
id
)
}
else
{
presenter
.
unpinMessage
(
id
)
}
}
}
else
->
TODO
(
"Not implemented"
)
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/viewmodel/MessageViewModel.kt
View file @
a0486d28
...
...
@@ -44,11 +44,13 @@ data class MessageViewModel(val context: Context,
var
attachmentMessageAuthor
:
String
?
=
null
var
attachmentMessageIcon
:
String
?
=
null
var
attachmentTimestamp
:
Long
?
=
null
var
systemMessage
:
Boolean
=
false
var
isSystemMessage
:
Boolean
=
false
var
isPinned
:
Boolean
=
false
init
{
sender
=
getSenderName
()
time
=
getTime
(
message
.
timestamp
)
isPinned
=
message
.
pinned
val
baseUrl
=
settings
.
get
(
SITE_URL
)
message
.
urls
?.
let
{
...
...
@@ -153,7 +155,7 @@ data class MessageViewModel(val context: Context,
}
private
fun
getSystemMessage
(
content
:
String
):
CharSequence
{
s
ystemMessage
=
true
isS
ystemMessage
=
true
val
spannableMsg
=
SpannableStringBuilder
(
content
)
spannableMsg
.
setSpan
(
StyleSpan
(
Typeface
.
ITALIC
),
0
,
spannableMsg
.
length
,
0
)
...
...
app/src/main/res/menu/message_actions.xml
View file @
a0486d28
...
...
@@ -28,7 +28,7 @@
<!--android:title="@string/action_msg_share" />-->
<item
android:id=
"@+id/action_menu_msg_pin"
android:id=
"@+id/action_menu_msg_pin
_unpin
"
android:icon=
"@drawable/ic_pin_black_24dp"
android:title=
"@string/action_msg_pin"
/>
...
...
app/src/main/res/values-pt-rBR/strings.xml
View file @
a0486d28
...
...
@@ -63,7 +63,8 @@
<string
name=
"action_msg_copy"
>
Copiar
</string>
<string
name=
"action_msg_quote"
>
Citar
</string>
<string
name=
"action_msg_delete"
>
Remover
</string>
<string
name=
"action_msg_pin"
>
Pinar Mensagem
</string>
<string
name=
"action_msg_pin"
>
Fixar Mensagem
</string>
<string
name=
"action_msg_unpin"
>
Desafixar Messagem
</string>
<string
name=
"action_msg_star"
>
Favoritar Mensagem
</string>
<string
name=
"action_msg_share"
>
Compartilhar
</string>
<string
name=
"action_title_editing"
>
Editando Mensagem
</string>
...
...
app/src/main/res/values/strings.xml
View file @
a0486d28
...
...
@@ -66,6 +66,7 @@
<string
name=
"action_msg_quote"
>
Quote
</string>
<string
name=
"action_msg_delete"
>
Delete
</string>
<string
name=
"action_msg_pin"
>
Pin Message
</string>
<string
name=
"action_msg_unpin"
>
Unpin Message
</string>
<string
name=
"action_msg_star"
>
Star Message
</string>
<string
name=
"action_msg_share"
>
Share
</string>
<string
name=
"action_title_editing"
>
Editing Message
</string>
...
...
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