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
f19c9522
Commit
f19c9522
authored
Oct 09, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add quote message action
parent
975bedbd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
27 deletions
+30
-27
RoomContract.java
...a/chat/rocket/android/fragment/chatroom/RoomContract.java
+5
-6
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+2
-1
RoomPresenter.java
.../chat/rocket/android/fragment/chatroom/RoomPresenter.java
+10
-14
MessagePopup.java
...at/rocket/android/layouthelper/chatroom/MessagePopup.java
+13
-6
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomContract.java
View file @
f19c9522
package
chat
.
rocket
.
android
.
fragment
.
chatroom
;
package
chat
.
rocket
.
android
.
fragment
.
chatroom
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
java.util.List
;
import
java.util.List
;
...
@@ -55,11 +56,11 @@ public interface RoomContract {
...
@@ -55,11 +56,11 @@ public interface RoomContract {
void
sendMessage
(
String
messageText
);
void
sendMessage
(
String
messageText
);
void
resendMessage
(
Message
message
);
void
resendMessage
(
@NonNull
Message
message
);
void
updateMessage
(
Message
message
,
String
content
);
void
updateMessage
(
@NonNull
Message
message
,
String
content
);
void
deleteMessage
(
Message
message
);
void
deleteMessage
(
@NonNull
Message
message
);
void
onUnreadCount
();
void
onUnreadCount
();
...
@@ -67,8 +68,6 @@ public interface RoomContract {
...
@@ -67,8 +68,6 @@ public interface RoomContract {
void
refreshRoom
();
void
refreshRoom
();
void
replyMessage
(
Message
message
);
void
replyMessage
(
@NonNull
Message
message
,
boolean
justQuote
);
void
copyMessage
(
Message
message
);
}
}
}
}
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
f19c9522
...
@@ -666,9 +666,10 @@ public class RoomFragment extends AbstractChatRoomFragment implements
...
@@ -666,9 +666,10 @@ public class RoomFragment extends AbstractChatRoomFragment implements
Activity
context
=
getActivity
();
Activity
context
=
getActivity
();
if
(
context
!=
null
&&
context
instanceof
MainActivity
)
{
if
(
context
!=
null
&&
context
instanceof
MainActivity
)
{
MessagePopup
.
take
(
message
)
MessagePopup
.
take
(
message
)
.
setReplyAction
(
presenter:
:
replyMessage
)
.
setReplyAction
(
msg
->
presenter
.
replyMessage
(
message
,
false
)
)
.
setEditAction
(
this
::
onEditMessage
)
.
setEditAction
(
this
::
onEditMessage
)
.
setCopyAction
(
msg
->
onCopy
(
message
.
getMessage
()))
.
setCopyAction
(
msg
->
onCopy
(
message
.
getMessage
()))
.
setQuoteAction
(
msg
->
presenter
.
replyMessage
(
message
,
true
))
.
showWith
(
context
);
.
showWith
(
context
);
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomPresenter.java
View file @
f19c9522
...
@@ -123,7 +123,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -123,7 +123,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
}
}
@Override
@Override
public
void
replyMessage
(
Message
messag
e
)
{
public
void
replyMessage
(
@NonNull
Message
message
,
boolean
justQuot
e
)
{
this
.
absoluteUrlHelper
.
getRocketChatAbsoluteUrl
()
this
.
absoluteUrlHelper
.
getRocketChatAbsoluteUrl
()
.
cache
()
.
cache
()
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
...
@@ -131,20 +131,16 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -131,20 +131,16 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
.
subscribe
(
.
subscribe
(
serverUrl
->
{
serverUrl
->
{
if
(
serverUrl
.
isPresent
())
{
if
(
serverUrl
.
isPresent
())
{
String
baseUrl
=
serverUrl
.
get
().
getBaseUrl
();
RocketChatAbsoluteUrl
absoluteUrl
=
serverUrl
.
get
();
view
.
onReply
(
serverUrl
.
get
(),
buildReplyMarkDown
(
baseUrl
,
message
),
message
);
String
baseUrl
=
absoluteUrl
.
getBaseUrl
();
view
.
onReply
(
absoluteUrl
,
buildReplyOrQuoteMarkdown
(
baseUrl
,
message
,
justQuote
),
message
);
}
}
},
},
Logger:
:
report
Logger:
:
report
);
);
}
}
@Override
private
String
buildReplyOrQuoteMarkdown
(
String
baseUrl
,
Message
message
,
boolean
justQuote
)
{
public
void
copyMessage
(
Message
message
)
{
view
.
onCopy
(
message
.
getMessage
());
}
private
String
buildReplyMarkDown
(
String
baseUrl
,
Message
message
)
{
if
(
currentRoom
==
null
||
message
.
getUser
()
==
null
)
{
if
(
currentRoom
==
null
||
message
.
getUser
()
==
null
)
{
return
""
;
return
""
;
}
}
...
@@ -154,10 +150,10 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -154,10 +150,10 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
message
.
getUser
().
getUsername
(),
message
.
getUser
().
getUsername
(),
message
.
getId
());
message
.
getId
());
}
else
{
}
else
{
return
String
.
format
(
"[ ](%s/channel/%s?msg=%s)
@%s
"
,
baseUrl
,
return
String
.
format
(
"[ ](%s/channel/%s?msg=%s)
%s
"
,
baseUrl
,
currentRoom
.
getName
(),
currentRoom
.
getName
(),
message
.
getId
(),
message
.
getId
(),
message
.
getUser
().
getUsername
()
);
justQuote
?
""
:
"@"
+
message
.
getUser
().
getUsername
()
+
" "
);
}
}
}
}
...
@@ -185,7 +181,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -185,7 +181,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
}
}
@Override
@Override
public
void
resendMessage
(
Message
message
)
{
public
void
resendMessage
(
@NonNull
Message
message
)
{
final
Disposable
subscription
=
getCurrentUser
()
final
Disposable
subscription
=
getCurrentUser
()
.
flatMap
(
user
->
messageInteractor
.
resend
(
message
,
user
))
.
flatMap
(
user
->
messageInteractor
.
resend
(
message
,
user
))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
...
@@ -196,7 +192,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -196,7 +192,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
}
}
@Override
@Override
public
void
updateMessage
(
Message
message
,
String
content
)
{
public
void
updateMessage
(
@NonNull
Message
message
,
String
content
)
{
view
.
disableMessageInput
();
view
.
disableMessageInput
();
final
Disposable
subscription
=
getCurrentUser
()
final
Disposable
subscription
=
getCurrentUser
()
.
flatMap
(
user
->
messageInteractor
.
update
(
message
,
user
,
content
))
.
flatMap
(
user
->
messageInteractor
.
update
(
message
,
user
,
content
))
...
@@ -219,7 +215,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -219,7 +215,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
}
}
@Override
@Override
public
void
deleteMessage
(
Message
message
)
{
public
void
deleteMessage
(
@NonNull
Message
message
)
{
final
Disposable
subscription
=
messageInteractor
.
delete
(
message
)
final
Disposable
subscription
=
messageInteractor
.
delete
(
message
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessagePopup.java
View file @
f19c9522
...
@@ -9,7 +9,6 @@ import java.util.ArrayList;
...
@@ -9,7 +9,6 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.RocketChatApplication
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.helper.Logger
;
import
chat.rocket.android.helper.Logger
;
import
chat.rocket.core.interactors.EditMessageInteractor
;
import
chat.rocket.core.interactors.EditMessageInteractor
;
...
@@ -35,9 +34,10 @@ import io.reactivex.disposables.Disposable;
...
@@ -35,9 +34,10 @@ import io.reactivex.disposables.Disposable;
public
class
MessagePopup
{
public
class
MessagePopup
{
private
static
volatile
MessagePopup
singleton
=
null
;
private
static
volatile
MessagePopup
singleton
=
null
;
private
static
final
Action
REPLY_ACTION_INFO
=
new
Action
(
"Reply"
,
null
,
true
);
private
static
final
Action
REPLY_ACTION_INFO
=
new
Action
(
"Reply"
,
null
,
true
);
private
static
final
Action
QUOTE_ACTION_INFO
=
new
Action
(
"Quote"
,
null
,
true
);
private
static
final
Action
EDIT_ACTION_INFO
=
new
Action
(
"Edit"
,
null
,
true
);
private
static
final
Action
EDIT_ACTION_INFO
=
new
Action
(
"Edit"
,
null
,
true
);
private
static
final
Action
COPY_ACTION_INFO
=
new
Action
(
"Copy"
,
null
,
true
);
private
static
final
Action
COPY_ACTION_INFO
=
new
Action
(
"Copy"
,
null
,
true
);
private
final
List
<
Action
>
defaultActions
=
new
ArrayList
<>(
3
);
private
final
List
<
Action
>
defaultActions
=
new
ArrayList
<>(
4
);
private
final
List
<
Action
>
otherActions
=
new
ArrayList
<>();
private
final
List
<
Action
>
otherActions
=
new
ArrayList
<>();
private
Message
message
;
private
Message
message
;
private
CompositeDisposable
compositeDisposable
=
new
CompositeDisposable
();
private
CompositeDisposable
compositeDisposable
=
new
CompositeDisposable
();
...
@@ -47,7 +47,7 @@ public class MessagePopup {
...
@@ -47,7 +47,7 @@ public class MessagePopup {
}
}
private
void
showAvailableActionsOnly
(
Context
context
)
{
private
void
showAvailableActionsOnly
(
Context
context
)
{
RocketChatCache
cache
=
new
RocketChatCache
(
RocketChatApplication
.
getInstance
());
RocketChatCache
cache
=
new
RocketChatCache
(
context
.
getApplicationContext
());
String
hostname
=
cache
.
getSelectedServerHostname
();
String
hostname
=
cache
.
getSelectedServerHostname
();
...
@@ -107,6 +107,7 @@ public class MessagePopup {
...
@@ -107,6 +107,7 @@ public class MessagePopup {
private
void
addDefaultActions
()
{
private
void
addDefaultActions
()
{
singleton
.
defaultActions
.
add
(
REPLY_ACTION_INFO
);
singleton
.
defaultActions
.
add
(
REPLY_ACTION_INFO
);
singleton
.
defaultActions
.
add
(
QUOTE_ACTION_INFO
);
singleton
.
defaultActions
.
add
(
EDIT_ACTION_INFO
);
singleton
.
defaultActions
.
add
(
EDIT_ACTION_INFO
);
singleton
.
defaultActions
.
add
(
COPY_ACTION_INFO
);
singleton
.
defaultActions
.
add
(
COPY_ACTION_INFO
);
}
}
...
@@ -148,17 +149,22 @@ public class MessagePopup {
...
@@ -148,17 +149,22 @@ public class MessagePopup {
}
}
public
MessagePopup
setReplyAction
(
ActionListener
actionListener
)
{
public
MessagePopup
setReplyAction
(
ActionListener
actionListener
)
{
REPLY_ACTION_INFO
.
actionListener
=
actionListener
;
REPLY_ACTION_INFO
.
actionListener
=
actionListener
;
return
singleton
;
return
singleton
;
}
}
public
MessagePopup
setEditAction
(
ActionListener
actionListener
)
{
public
MessagePopup
setEditAction
(
ActionListener
actionListener
)
{
EDIT_ACTION_INFO
.
actionListener
=
actionListener
;
EDIT_ACTION_INFO
.
actionListener
=
actionListener
;
return
singleton
;
return
singleton
;
}
}
public
MessagePopup
setCopyAction
(
ActionListener
actionListener
)
{
public
MessagePopup
setCopyAction
(
ActionListener
actionListener
)
{
COPY_ACTION_INFO
.
actionListener
=
actionListener
;
COPY_ACTION_INFO
.
actionListener
=
actionListener
;
return
singleton
;
}
public
MessagePopup
setQuoteAction
(
ActionListener
actionListener
)
{
QUOTE_ACTION_INFO
.
actionListener
=
actionListener
;
return
singleton
;
return
singleton
;
}
}
...
@@ -192,6 +198,7 @@ public class MessagePopup {
...
@@ -192,6 +198,7 @@ public class MessagePopup {
private
static
class
Builder
{
private
static
class
Builder
{
private
final
Message
message
;
private
final
Message
message
;
Builder
(
Message
message
)
{
Builder
(
Message
message
)
{
if
(
message
==
null
)
{
if
(
message
==
null
)
{
throw
new
IllegalArgumentException
(
"Message must not be null"
);
throw
new
IllegalArgumentException
(
"Message must not be null"
);
...
...
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