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
89842afc
Commit
89842afc
authored
Mar 12, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Toggle reaction when touching on an added reaction
parent
deeac58b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
12 deletions
+51
-12
BaseViewHolder.kt
...va/chat/rocket/android/chatroom/adapter/BaseViewHolder.kt
+7
-3
MessageReactionsAdapter.kt
...ocket/android/chatroom/adapter/MessageReactionsAdapter.kt
+25
-5
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+5
-1
ReactionViewModel.kt
...at/rocket/android/chatroom/viewmodel/ReactionViewModel.kt
+2
-1
ViewModelMapper.kt
...chat/rocket/android/chatroom/viewmodel/ViewModelMapper.kt
+2
-1
EmojiReactionListener.kt
...chat/rocket/android/widget/emoji/EmojiReactionListener.kt
+9
-1
item_reaction.xml
app/src/main/res/layout/item_reaction.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/BaseViewHolder.kt
View file @
89842afc
...
...
@@ -48,15 +48,19 @@ abstract class BaseViewHolder<T : BaseViewModel<*>>(
if
(
it
.
nextDownStreamMessage
==
null
)
{
adapter
.
listener
=
object
:
EmojiReactionListener
{
override
fun
onEmojiReactionAdded
(
messageId
:
String
,
emoji
:
Emoji
)
{
reactionListener
?.
onEmojiReactionAdded
(
messageId
,
emoji
)
override
fun
onReactionTouched
(
messageId
:
String
,
emojiShortname
:
String
)
{
reactionListener
?.
onReactionTouched
(
messageId
,
emojiShortname
)
}
override
fun
onReactionAdded
(
messageId
:
String
,
emoji
:
Emoji
)
{
reactionListener
?.
onReactionAdded
(
messageId
,
emoji
)
}
}
val
context
=
itemView
.
context
val
manager
=
FlexboxLayoutManager
(
context
,
FlexDirection
.
ROW
)
recyclerView
.
layoutManager
=
manager
recyclerView
.
adapter
=
adapter
adapter
.
addReactions
(
it
.
reactions
.
filterNot
{
it
.
shortnam
e
.
startsWith
(
":"
)
})
adapter
.
addReactions
(
it
.
reactions
.
filterNot
{
it
.
unicod
e
.
startsWith
(
":"
)
})
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/adapter/MessageReactionsAdapter.kt
View file @
89842afc
...
...
@@ -36,7 +36,7 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
}
else
->
{
view
=
inflater
.
inflate
(
R
.
layout
.
item_reaction
,
parent
,
false
)
SingleReactionViewHolder
(
view
)
SingleReactionViewHolder
(
view
,
listener
)
}
}
}
...
...
@@ -71,8 +71,13 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
notifyItemRangeRemoved
(
0
,
oldSize
)
}
class
SingleReactionViewHolder
(
view
:
View
)
:
RecyclerView
.
ViewHolder
(
view
)
{
class
SingleReactionViewHolder
(
view
:
View
,
private
val
listener
:
EmojiReactionListener
?)
:
RecyclerView
.
ViewHolder
(
view
),
View
.
OnClickListener
{
@Inject
lateinit
var
localRepository
:
LocalRepository
@Volatile
lateinit
var
reaction
:
ReactionViewModel
@Volatile
var
clickHandled
=
false
init
{
DaggerLocalComponent
.
builder
()
...
...
@@ -82,10 +87,12 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
}
fun
bind
(
reaction
:
ReactionViewModel
)
{
clickHandled
=
false
this
.
reaction
=
reaction
with
(
itemView
)
{
val
emojiTextView
=
findViewById
<
TextView
>(
R
.
id
.
text_emoji
)
val
countTextView
=
findViewById
<
TextView
>(
R
.
id
.
text_count
)
emojiTextView
.
text
=
reaction
.
shortnam
e
emojiTextView
.
text
=
reaction
.
unicod
e
countTextView
.
text
=
reaction
.
count
.
toString
()
val
myself
=
localRepository
.
get
(
LocalRepository
.
USERNAME_KEY
)
if
(
reaction
.
usernames
.
contains
(
myself
))
{
...
...
@@ -93,18 +100,31 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
val
resources
=
context
.
resources
countTextView
.
setTextColor
(
resources
.
getColor
(
R
.
color
.
colorAccent
))
}
emojiTextView
.
setOnClickListener
(
this
@SingleReactionViewHolder
)
countTextView
.
setOnClickListener
(
this
@SingleReactionViewHolder
)
}
}
override
fun
onClick
(
v
:
View
?)
{
synchronized
(
this
)
{
if
(!
clickHandled
)
{
clickHandled
=
true
listener
?.
onReactionTouched
(
reaction
.
messageId
,
reaction
.
shortname
)
}
}
}
}
class
AddReactionViewHolder
(
view
:
View
,
val
listener
:
EmojiReactionListener
?)
:
RecyclerView
.
ViewHolder
(
view
)
{
class
AddReactionViewHolder
(
view
:
View
,
private
val
listener
:
EmojiReactionListener
?)
:
RecyclerView
.
ViewHolder
(
view
)
{
fun
bind
(
messageId
:
String
)
{
itemView
as
ImageView
itemView
.
setOnClickListener
{
val
emojiPickerPopup
=
EmojiPickerPopup
(
itemView
.
context
)
emojiPickerPopup
.
listener
=
object
:
EmojiKeyboardListenerAdapter
()
{
override
fun
onEmojiAdded
(
emoji
:
Emoji
)
{
listener
?.
on
Emoji
ReactionAdded
(
messageId
,
emoji
)
listener
?.
onReactionAdded
(
messageId
,
emoji
)
}
}
emojiPickerPopup
.
show
()
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
89842afc
...
...
@@ -279,7 +279,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
onEmojiReactionAdded
(
messageId
:
String
,
emoji
:
Emoji
)
{
override
fun
onReactionTouched
(
messageId
:
String
,
emojiShortname
:
String
)
{
presenter
.
react
(
messageId
,
emojiShortname
)
}
override
fun
onReactionAdded
(
messageId
:
String
,
emoji
:
Emoji
)
{
presenter
.
react
(
messageId
,
emoji
.
shortname
)
}
...
...
app/src/main/java/chat/rocket/android/chatroom/viewmodel/ReactionViewModel.kt
View file @
89842afc
...
...
@@ -2,7 +2,8 @@ package chat.rocket.android.chatroom.viewmodel
data class
ReactionViewModel
(
val
messageId
:
String
,
val
shortname
:
CharSequence
,
val
shortname
:
String
,
val
unicode
:
CharSequence
,
val
count
:
Int
,
val
usernames
:
List
<
String
>
=
emptyList
()
)
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/viewmodel/ViewModelMapper.kt
View file @
89842afc
...
...
@@ -160,7 +160,8 @@ class ViewModelMapper @Inject constructor(private val context: Context,
val
count
=
usernames
.
size
list
.
add
(
ReactionViewModel
(
messageId
=
message
.
id
,
shortname
=
EmojiParser
.
parse
(
shortname
),
shortname
=
shortname
,
unicode
=
EmojiParser
.
parse
(
shortname
),
count
=
count
,
usernames
=
usernames
)
)
...
...
app/src/main/java/chat/rocket/android/widget/emoji/EmojiReactionListener.kt
View file @
89842afc
...
...
@@ -7,5 +7,13 @@ interface EmojiReactionListener {
* @param messageId The id of the message being reacted.
* @param emoji The emoji used to react.
*/
fun
onEmojiReactionAdded
(
messageId
:
String
,
emoji
:
Emoji
)
fun
onReactionAdded
(
messageId
:
String
,
emoji
:
Emoji
)
/**
* Callback when an added reaction is touched.
*
* @param messageId The id of the message with the reaction.
* @param emojiShortname The shortname of the emoji (:grin:, :smiley:, etc).
*/
fun
onReactionTouched
(
messageId
:
String
,
emojiShortname
:
String
)
}
\ No newline at end of file
app/src/main/res/layout/item_reaction.xml
View file @
89842afc
...
...
@@ -7,6 +7,7 @@
android:layout_marginRight=
"2dp"
android:layout_marginTop=
"2dp"
android:layout_marginBottom=
"2dp"
android:descendantFocusability=
"beforeDescendants"
android:background=
"@drawable/rounded_background"
android:orientation=
"horizontal"
>
...
...
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