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
94e86c98
Commit
94e86c98
authored
Feb 04, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement copy to clipboard action
parent
b2db4bcc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
5 deletions
+41
-5
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+17
-0
ChatRoomView.kt
...chat/rocket/android/chatroom/presentation/ChatRoomView.kt
+7
-0
ChatRoomAdapter.kt
...n/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
+1
-0
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+11
-0
message_actions.xml
app/src/main/res/menu/message_actions.xml
+5
-5
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
94e86c98
...
...
@@ -197,6 +197,23 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
}
}
/**
* Copy message to clipboard.
*
* @param messageId The id of the message to copy to clipboard.
*/
fun
copyMessage
(
messageId
:
String
)
{
launchUI
(
strategy
)
{
try
{
messagesRepository
.
getById
(
messageId
)
?.
let
{
m
->
view
.
copyToClipboard
(
m
.
message
)
}
}
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/presentation/ChatRoomView.kt
View file @
94e86c98
...
...
@@ -50,6 +50,13 @@ interface ChatRoomView : LoadingView, MessageView {
*/
fun
showReplyStatus
(
replyMarkdown
:
String
,
quotedMessage
:
String
)
/**
* Copy message to clipboard.
*
* @param message The message to copy.
*/
fun
copyToClipboard
(
message
:
String
)
fun
disableMessageInput
()
fun
enableMessageInput
(
clear
:
Boolean
=
false
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
View file @
94e86c98
...
...
@@ -113,6 +113,7 @@ class ChatRoomAdapter(private val serverUrl: String,
R
.
id
.
action_menu_msg_delete
->
presenter
.
deleteMessage
(
roomId
,
id
)
R
.
id
.
action_menu_msg_quote
->
presenter
.
citeMessage
(
serverUrl
,
roomType
,
roomName
,
id
,
""
,
false
)
R
.
id
.
action_menu_msg_reply
->
presenter
.
citeMessage
(
serverUrl
,
roomType
,
roomName
,
id
,
""
,
true
)
R
.
id
.
action_menu_msg_copy
->
presenter
.
copyMessage
(
id
)
else
->
TODO
(
"Not implemented"
)
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
94e86c98
package
chat.rocket.android.chatroom.ui
import
android.content.ClipData
import
android.content.ClipboardManager
import
android.content.Context
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v7.widget.DefaultItemAnimator
...
...
@@ -22,6 +25,7 @@ import kotlinx.android.synthetic.main.fragment_chat_room.*
import
kotlinx.android.synthetic.main.message_composer.*
import
javax.inject.Inject
fun
newInstance
(
chatRoomId
:
String
,
chatRoomName
:
String
,
chatRoomType
:
String
,
isChatRoomReadOnly
:
Boolean
):
Fragment
{
return
ChatRoomFragment
().
apply
{
arguments
=
Bundle
(
1
).
apply
{
...
...
@@ -145,6 +149,13 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
override
fun
copyToClipboard
(
message
:
String
)
{
activity
?.
apply
{
val
clipboard
=
getSystemService
(
Context
.
CLIPBOARD_SERVICE
)
as
ClipboardManager
clipboard
.
setPrimaryClip
(
ClipData
.
newPlainText
(
""
,
message
))
}
}
private
fun
setupComposer
()
{
if
(
isChatRoomReadOnly
)
{
text_room_is_read_only
.
setVisible
(
true
)
...
...
app/src/main/res/menu/message_actions.xml
View file @
94e86c98
...
...
@@ -7,6 +7,11 @@
android:icon=
"@drawable/ic_reply_black_24px"
android:title=
"@string/action_msg_reply"
/>
<item
android:id=
"@+id/action_menu_msg_quote"
android:icon=
"@drawable/ic_quote_black_24px"
android:title=
"@string/action_msg_quote"
/>
<!--<item-->
<!--android:id="@+id/action_menu_msg_edit"-->
<!--android:title="@string/action_msg_edit" />-->
...
...
@@ -16,11 +21,6 @@
android:icon=
"@drawable/ic_content_copy_black_24px"
android:title=
"@string/action_msg_copy"
/>
<item
android:id=
"@+id/action_menu_msg_quote"
android:icon=
"@drawable/ic_quote_black_24px"
android:title=
"@string/action_msg_quote"
/>
<!--<item-->
<!--android:id="@+id/action_menu_msg_share"-->
<!--android:icon="@drawable/ic_share_black_24px"-->
...
...
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