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
98f4530f
Commit
98f4530f
authored
May 11, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Open a DM to the user when clicking on the Reply button on broadcast channels
parent
5163405f
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
72 additions
and
11 deletions
+72
-11
ChatRoomAdapter.kt
...a/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
+4
-2
MessageReplyViewHolder.kt
...rocket/android/chatroom/adapter/MessageReplyViewHolder.kt
+4
-3
MessageReply.kt
.../java/chat/rocket/android/chatroom/domain/MessageReply.kt
+1
-0
ChatRoomNavigator.kt
...rocket/android/chatroom/presentation/ChatRoomNavigator.kt
+13
-0
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+26
-0
ChatRoomView.kt
...chat/rocket/android/chatroom/presentation/ChatRoomView.kt
+7
-0
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+7
-0
ViewModelMapper.kt
...chat/rocket/android/chatroom/viewmodel/ViewModelMapper.kt
+5
-2
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+0
-2
MainNavigator.kt
...va/chat/rocket/android/main/presentation/MainNavigator.kt
+0
-1
GetChatRoomsInteractor.kt
...at/rocket/android/server/domain/GetChatRoomsInteractor.kt
+5
-1
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
View file @
98f4530f
...
...
@@ -5,6 +5,7 @@ import android.view.MenuItem
import
android.view.ViewGroup
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.presentation.ChatRoomPresenter
import
chat.rocket.android.chatroom.ui.chatRoomIntent
import
chat.rocket.android.chatroom.viewmodel.AudioAttachmentViewModel
import
chat.rocket.android.chatroom.viewmodel.AuthorAttachmentViewModel
import
chat.rocket.android.chatroom.viewmodel.BaseFileAttachmentViewModel
...
...
@@ -18,6 +19,7 @@ import chat.rocket.android.chatroom.viewmodel.MessageViewModel
import
chat.rocket.android.chatroom.viewmodel.UrlPreviewViewModel
import
chat.rocket.android.chatroom.viewmodel.VideoAttachmentViewModel
import
chat.rocket.android.chatroom.viewmodel.toViewType
import
chat.rocket.android.main.presentation.MainNavigator
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
chat.rocket.core.model.Message
...
...
@@ -79,8 +81,8 @@ class ChatRoomAdapter(
}
BaseViewModel
.
ViewType
.
MESSAGE_REPLY
->
{
val
view
=
parent
.
inflate
(
R
.
layout
.
item_message_reply
)
MessageReplyViewHolder
(
view
,
actionsListener
,
reactionListener
)
{
permalink
->
MessageReplyViewHolder
(
view
,
actionsListener
,
reactionListener
)
{
roomName
,
permalink
->
presenter
?.
openDirectMessage
(
roomName
,
permalink
)
}
}
else
->
{
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/MessageReplyViewHolder.kt
View file @
98f4530f
package
chat.rocket.android.chatroom.adapter
import
android.view.View
import
android.widget.Toast
import
chat.rocket.android.chatroom.viewmodel.MessageReplyViewModel
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
kotlinx.android.synthetic.main.item_message_reply.view.*
...
...
@@ -10,7 +9,7 @@ class MessageReplyViewHolder(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
,
private
val
replyCallback
:
(
permalink
:
String
)
->
Unit
private
val
replyCallback
:
(
roomName
:
String
,
permalink
:
String
)
->
Unit
)
:
BaseViewHolder
<
MessageReplyViewModel
>(
itemView
,
listener
,
reactionListener
)
{
init
{
...
...
@@ -22,7 +21,9 @@ class MessageReplyViewHolder(
override
fun
bindViews
(
data
:
MessageReplyViewModel
)
{
with
(
itemView
)
{
button_message_reply
.
setOnClickListener
{
replyCallback
.
invoke
(
data
.
rawData
.
permalink
)
with
(
data
.
rawData
)
{
replyCallback
.
invoke
(
roomName
,
permalink
)
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/domain/MessageReply.kt
View file @
98f4530f
package
chat.rocket.android.chatroom.domain
data class
MessageReply
(
val
roomName
:
String
,
val
permalink
:
String
)
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomNavigator.kt
View file @
98f4530f
...
...
@@ -2,6 +2,7 @@ package chat.rocket.android.chatroom.presentation
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.ui.ChatRoomActivity
import
chat.rocket.android.chatroom.ui.chatRoomIntent
import
chat.rocket.android.members.ui.newInstance
import
chat.rocket.android.server.ui.changeServerIntent
import
chat.rocket.android.util.extensions.addFragmentBackStack
...
...
@@ -24,4 +25,16 @@ class ChatRoomNavigator(internal val activity: ChatRoomActivity) {
activity
.
startActivity
(
activity
.
changeServerIntent
())
activity
.
finish
()
}
fun
toDirectMessage
(
chatRoomId
:
String
,
chatRoomName
:
String
,
chatRoomType
:
String
,
isChatRoomReadOnly
:
Boolean
,
chatRoomLastSeen
:
Long
,
isChatRoomSubscribed
:
Boolean
,
isChatRoomOwner
:
Boolean
)
{
activity
.
startActivity
(
activity
.
chatRoomIntent
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
isChatRoomReadOnly
,
chatRoomLastSeen
,
isChatRoomSubscribed
,
isChatRoomOwner
))
activity
.
overridePendingTransition
(
R
.
anim
.
open_enter
,
R
.
anim
.
open_exit
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
98f4530f
...
...
@@ -611,6 +611,32 @@ class ChatRoomPresenter @Inject constructor(
}
}
fun
openDirectMessage
(
roomName
:
String
,
permalink
:
String
)
{
launchUI
(
strategy
)
{
try
{
getChatRoomsInteractor
.
getByName
(
currentServer
,
roomName
)
?.
let
{
val
isDirectMessage
=
it
.
type
is
RoomType
.
DirectMessage
if
(
isDirectMessage
)
{
navigator
.
toDirectMessage
(
chatRoomId
=
it
.
id
,
chatRoomType
=
it
.
type
.
toString
(),
chatRoomLastSeen
=
it
.
lastSeen
?:
-
1
,
chatRoomName
=
roomName
,
isChatRoomOwner
=
false
,
isChatRoomReadOnly
=
false
,
isChatRoomSubscribed
=
it
.
open
)
}
else
{
throw
IllegalStateException
(
"Not a direct-message"
)
}
}
}
catch
(
ex
:
Exception
)
{
Timber
.
e
(
ex
)
view
.
showMessage
(
ex
.
message
!!
)
}
}
}
/**
* Send an emoji reaction to a message.
*/
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomView.kt
View file @
98f4530f
...
...
@@ -8,6 +8,7 @@ import chat.rocket.android.chatroom.viewmodel.suggestion.PeopleSuggestionViewMod
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.core.internal.realtime.socket.model.State
import
chat.rocket.core.model.ChatRoom
interface
ChatRoomView
:
LoadingView
,
MessageView
{
...
...
@@ -127,4 +128,10 @@ interface ChatRoomView : LoadingView, MessageView {
* Communicate whether it's a broadcast channel and if current user can post to it.
*/
fun
onRoomUpdated
(
canPost
:
Boolean
,
broadcastChannel
:
Boolean
)
/**
* Open a DM with the user in the given [chatRoom] and pass the [permalink] for the message
* to reply.
*/
fun
openDirectMessage
(
chatRoom
:
ChatRoom
,
permalink
:
String
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
98f4530f
...
...
@@ -36,6 +36,7 @@ import chat.rocket.android.chatroom.viewmodel.suggestion.PeopleSuggestionViewMod
import
chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.helper.MessageParser
import
chat.rocket.android.main.presentation.MainNavigator
import
chat.rocket.android.util.extensions.asObservable
import
chat.rocket.android.util.extensions.circularRevealOrUnreveal
import
chat.rocket.android.util.extensions.fadeIn
...
...
@@ -58,6 +59,7 @@ import chat.rocket.android.widget.emoji.EmojiParser
import
chat.rocket.android.widget.emoji.EmojiPickerPopup
import
chat.rocket.android.widget.emoji.EmojiReactionListener
import
chat.rocket.core.internal.realtime.socket.model.State
import
chat.rocket.core.model.ChatRoom
import
dagger.android.support.AndroidSupportInjection
import
io.reactivex.Observable
import
io.reactivex.disposables.CompositeDisposable
...
...
@@ -102,6 +104,7 @@ private const val BUNDLE_CHAT_ROOM_IS_SUBSCRIBED = "chat_room_is_subscribed"
private
const
val
BUNDLE_CHAT_ROOM_IS_OWNER
=
"chat_room_is_owner"
class
ChatRoomFragment
:
Fragment
(),
ChatRoomView
,
EmojiKeyboardListener
,
EmojiReactionListener
{
@Inject
lateinit
var
presenter
:
ChatRoomPresenter
@Inject
...
...
@@ -273,6 +276,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
if
(
isBroadcastChannel
)
activity
?.
invalidateOptionsMenu
()
}
override
fun
openDirectMessage
(
chatRoom
:
ChatRoom
,
permalink
:
String
)
{
}
private
fun
toggleNoChatView
(
size
:
Int
)
{
if
(
size
==
0
)
{
image_chat_icon
.
setVisible
(
true
)
...
...
app/src/main/java/chat/rocket/android/chatroom/viewmodel/ViewModelMapper.kt
View file @
98f4530f
...
...
@@ -15,6 +15,7 @@ import androidx.core.text.scale
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.domain.MessageReply
import
chat.rocket.android.helper.MessageParser
import
chat.rocket.android.helper.UserHelper
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.util.extensions.avatarUrl
...
...
@@ -35,6 +36,7 @@ import javax.inject.Inject
class
ViewModelMapper
@Inject
constructor
(
private
val
context
:
Context
,
private
val
parser
:
MessageParser
,
private
val
userHelper
:
UserHelper
,
tokenRepository
:
TokenRepository
,
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
,
...
...
@@ -97,14 +99,15 @@ class ViewModelMapper @Inject constructor(
}
private
fun
mapMessageReply
(
message
:
Message
):
MessageReplyViewModel
{
val
messageReply
=
MessageReply
(
permalink
=
makePermalink
(
message
))
val
name
=
message
.
sender
?.
name
val
roomName
=
if
(
settings
.
useRealName
()
&&
name
!=
null
)
name
else
message
.
sender
?.
username
?:
""
return
MessageReplyViewModel
(
messageId
=
message
.
id
,
isTemporary
=
false
,
reactions
=
emptyList
(),
message
=
message
,
preview
=
mapMessagePreview
(
message
),
rawData
=
messageReply
,
rawData
=
MessageReply
(
roomName
=
roomName
,
permalink
=
makePermalink
(
message
))
,
nextDownStreamMessage
=
null
)
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
98f4530f
...
...
@@ -44,7 +44,6 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
lateinit
var
settingsRepository
:
SettingsRepository
@Inject
lateinit
var
localRepository
:
LocalRepository
private
lateinit
var
preferences
:
SharedPreferences
private
var
searchView
:
SearchView
?
=
null
private
val
handler
=
Handler
()
...
...
@@ -59,7 +58,6 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
setHasOptionsMenu
(
true
)
preferences
=
context
?.
getSharedPreferences
(
"temp"
,
Context
.
MODE_PRIVATE
)
!!
}
override
fun
onDestroy
()
{
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainNavigator.kt
View file @
98f4530f
package
chat.rocket.android.main.presentation
import
android.content.Context
import
chat.rocket.android.R
import
chat.rocket.android.authentication.ui.newServerIntent
import
chat.rocket.android.chatroom.ui.chatRoomIntent
...
...
app/src/main/java/chat/rocket/android/server/domain/GetChatRoomsInteractor.kt
View file @
98f4530f
...
...
@@ -55,7 +55,11 @@ class GetChatRoomsInteractor @Inject constructor(private val repository: ChatRoo
* @return The [ChatRoom] object or null if we couldn't find any.
*/
fun
getByName
(
serverUrl
:
String
,
name
:
String
):
ChatRoom
?
{
return
getAll
(
serverUrl
).
toMutableList
().
find
{
chatRoom
->
chatRoom
.
name
==
name
}
return
getAll
(
serverUrl
).
let
{
val
found
=
it
.
find
{
chatRoom
->
chatRoom
.
name
==
name
}
?:
return
@let
it
.
find
{
chatRoom
->
chatRoom
.
fullName
==
name
}
found
}
}
/**
...
...
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