forked from GitHub-Mirror/riotX-android
Increment reaction when reaction pill clicked in timeline
This commit is contained in:
parent
ef26519993
commit
f9142fedfd
@ -483,6 +483,16 @@ class RoomDetailFragment :
|
|||||||
override fun onMemberNameClicked(informationData: MessageInformationData) {
|
override fun onMemberNameClicked(informationData: MessageInformationData) {
|
||||||
insertUserDisplayNameInTextEditor(informationData.memberName?.toString())
|
insertUserDisplayNameInTextEditor(informationData.memberName?.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onClickOnReactionPill(informationData: MessageInformationData, reaction: String, on: Boolean) {
|
||||||
|
if (on) {
|
||||||
|
//we should test the current real state of reaction on this event
|
||||||
|
roomDetailViewModel.process(RoomDetailActions.SendReaction(reaction,informationData.eventId))
|
||||||
|
} else {
|
||||||
|
//TODO it's an undo :/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// AutocompleteUserPresenter.Callback
|
// AutocompleteUserPresenter.Callback
|
||||||
|
|
||||||
override fun onQueryUsers(query: CharSequence?) {
|
override fun onQueryUsers(query: CharSequence?) {
|
||||||
@ -566,6 +576,7 @@ class RoomDetailFragment :
|
|||||||
* @param text the text to insert.
|
* @param text the text to insert.
|
||||||
*/
|
*/
|
||||||
private fun insertUserDisplayNameInTextEditor(text: String?) {
|
private fun insertUserDisplayNameInTextEditor(text: String?) {
|
||||||
|
//TODO move logic outside of fragment
|
||||||
if (null != text) {
|
if (null != text) {
|
||||||
// var vibrate = false
|
// var vibrate = false
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class TimelineEventController(private val dateFormatter: TimelineDateFormatter,
|
|||||||
private val backgroundHandler: Handler = TimelineAsyncHelper.getBackgroundHandler()
|
private val backgroundHandler: Handler = TimelineAsyncHelper.getBackgroundHandler()
|
||||||
) : EpoxyController(backgroundHandler, backgroundHandler), Timeline.Listener {
|
) : EpoxyController(backgroundHandler, backgroundHandler), Timeline.Listener {
|
||||||
|
|
||||||
interface Callback {
|
interface Callback : ReactionPillCallback {
|
||||||
fun onEventVisible(event: TimelineEvent)
|
fun onEventVisible(event: TimelineEvent)
|
||||||
fun onUrlClicked(url: String)
|
fun onUrlClicked(url: String)
|
||||||
fun onImageMessageClicked(messageImageContent: MessageImageContent, mediaData: ImageContentRenderer.Data, view: View)
|
fun onImageMessageClicked(messageImageContent: MessageImageContent, mediaData: ImageContentRenderer.Data, view: View)
|
||||||
@ -60,6 +60,10 @@ class TimelineEventController(private val dateFormatter: TimelineDateFormatter,
|
|||||||
fun onMemberNameClicked(informationData: MessageInformationData)
|
fun onMemberNameClicked(informationData: MessageInformationData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ReactionPillCallback {
|
||||||
|
fun onClickOnReactionPill(informationData: MessageInformationData, reaction: String, on: Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
private val collapsedEventIds = linkedSetOf<String>()
|
private val collapsedEventIds = linkedSetOf<String>()
|
||||||
private val mergeItemCollapseStates = HashMap<String, Boolean>()
|
private val mergeItemCollapseStates = HashMap<String, Boolean>()
|
||||||
private val modelCache = arrayListOf<CacheItemData?>()
|
private val modelCache = arrayListOf<CacheItemData?>()
|
||||||
|
@ -107,6 +107,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider,
|
|||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
.filename(messageContent.body)
|
.filename(messageContent.body)
|
||||||
.iconRes(R.drawable.filetype_audio)
|
.iconRes(R.drawable.filetype_audio)
|
||||||
|
.reactionPillCallback(callback)
|
||||||
.avatarClickListener(
|
.avatarClickListener(
|
||||||
DebouncedClickListener(View.OnClickListener { view ->
|
DebouncedClickListener(View.OnClickListener { view ->
|
||||||
callback?.onAvatarClicked(informationData)
|
callback?.onAvatarClicked(informationData)
|
||||||
@ -134,6 +135,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider,
|
|||||||
return MessageFileItem_()
|
return MessageFileItem_()
|
||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
.filename(messageContent.body)
|
.filename(messageContent.body)
|
||||||
|
.reactionPillCallback(callback)
|
||||||
.iconRes(R.drawable.filetype_attachment)
|
.iconRes(R.drawable.filetype_attachment)
|
||||||
.avatarClickListener(
|
.avatarClickListener(
|
||||||
DebouncedClickListener(View.OnClickListener { view ->
|
DebouncedClickListener(View.OnClickListener { view ->
|
||||||
@ -180,6 +182,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider,
|
|||||||
.playable(messageContent.info?.mimeType == "image/gif")
|
.playable(messageContent.info?.mimeType == "image/gif")
|
||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
.mediaData(data)
|
.mediaData(data)
|
||||||
|
.reactionPillCallback(callback)
|
||||||
.avatarClickListener(
|
.avatarClickListener(
|
||||||
DebouncedClickListener(View.OnClickListener { view ->
|
DebouncedClickListener(View.OnClickListener { view ->
|
||||||
callback?.onAvatarClicked(informationData)
|
callback?.onAvatarClicked(informationData)
|
||||||
@ -226,6 +229,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider,
|
|||||||
.playable(true)
|
.playable(true)
|
||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
.mediaData(thumbnailData)
|
.mediaData(thumbnailData)
|
||||||
|
.reactionPillCallback(callback)
|
||||||
.avatarClickListener(
|
.avatarClickListener(
|
||||||
DebouncedClickListener(View.OnClickListener { view ->
|
DebouncedClickListener(View.OnClickListener { view ->
|
||||||
callback?.onAvatarClicked(informationData)
|
callback?.onAvatarClicked(informationData)
|
||||||
@ -257,6 +261,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider,
|
|||||||
return MessageTextItem_()
|
return MessageTextItem_()
|
||||||
.message(linkifiedBody)
|
.message(linkifiedBody)
|
||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
|
.reactionPillCallback(callback)
|
||||||
.avatarClickListener(
|
.avatarClickListener(
|
||||||
DebouncedClickListener(View.OnClickListener { view ->
|
DebouncedClickListener(View.OnClickListener { view ->
|
||||||
callback?.onAvatarClicked(informationData)
|
callback?.onAvatarClicked(informationData)
|
||||||
@ -294,6 +299,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider,
|
|||||||
return MessageTextItem_()
|
return MessageTextItem_()
|
||||||
.message(message)
|
.message(message)
|
||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
|
.reactionPillCallback(callback)
|
||||||
.avatarClickListener(
|
.avatarClickListener(
|
||||||
DebouncedClickListener(View.OnClickListener { view ->
|
DebouncedClickListener(View.OnClickListener { view ->
|
||||||
callback?.onAvatarClicked(informationData)
|
callback?.onAvatarClicked(informationData)
|
||||||
@ -322,6 +328,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider,
|
|||||||
return MessageTextItem_()
|
return MessageTextItem_()
|
||||||
.message(message)
|
.message(message)
|
||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
|
.reactionPillCallback(callback)
|
||||||
.avatarClickListener(
|
.avatarClickListener(
|
||||||
DebouncedClickListener(View.OnClickListener { view ->
|
DebouncedClickListener(View.OnClickListener { view ->
|
||||||
callback?.onAvatarClicked(informationData)
|
callback?.onAvatarClicked(informationData)
|
||||||
|
@ -30,6 +30,7 @@ import com.airbnb.epoxy.EpoxyAttribute
|
|||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
import im.vector.riotredesign.core.utils.DimensionUtils.dpToPx
|
import im.vector.riotredesign.core.utils.DimensionUtils.dpToPx
|
||||||
import im.vector.riotredesign.features.home.AvatarRenderer
|
import im.vector.riotredesign.features.home.AvatarRenderer
|
||||||
|
import im.vector.riotredesign.features.home.room.detail.timeline.TimelineEventController
|
||||||
import im.vector.riotredesign.features.reactions.widget.ReactionButton
|
import im.vector.riotredesign.features.reactions.widget.ReactionButton
|
||||||
|
|
||||||
|
|
||||||
@ -49,6 +50,19 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : BaseEventItem<H>() {
|
|||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var memberClickListener: View.OnClickListener? = null
|
var memberClickListener: View.OnClickListener? = null
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var reactionPillCallback: TimelineEventController.ReactionPillCallback? = null
|
||||||
|
|
||||||
|
var reactionClickListener: ReactionButton.ReactedListener = object : ReactionButton.ReactedListener {
|
||||||
|
override fun onReacted(reactionButton: ReactionButton) {
|
||||||
|
reactionPillCallback?.onClickOnReactionPill(informationData, reactionButton.reactionString,true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUnReacted(reactionButton: ReactionButton) {
|
||||||
|
reactionPillCallback?.onClickOnReactionPill(informationData, reactionButton.reactionString,false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun bind(holder: H) {
|
override fun bind(holder: H) {
|
||||||
super.bind(holder)
|
super.bind(holder)
|
||||||
if (informationData.showInformation) {
|
if (informationData.showInformation) {
|
||||||
@ -91,6 +105,8 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : BaseEventItem<H>() {
|
|||||||
informationData.orderedReactionList?.chunked(7)?.firstOrNull()?.forEachIndexed { index, reaction ->
|
informationData.orderedReactionList?.chunked(7)?.firstOrNull()?.forEachIndexed { index, reaction ->
|
||||||
(holder.reactionWrapper?.children?.elementAtOrNull(index) as? ReactionButton)?.let { reactionButton ->
|
(holder.reactionWrapper?.children?.elementAtOrNull(index) as? ReactionButton)?.let { reactionButton ->
|
||||||
reactionButton.isVisible = true
|
reactionButton.isVisible = true
|
||||||
|
reactionButton.reactedListener = reactionClickListener
|
||||||
|
reactionButton.setTag(R.id.messageBottomInfo, reaction.first)
|
||||||
idToRefInFlow.add(reactionButton.id)
|
idToRefInFlow.add(reactionButton.id)
|
||||||
reactionButton.reactionString = reaction.first
|
reactionButton.reactionString = reaction.first
|
||||||
reactionButton.reactionCount = reaction.second
|
reactionButton.reactionCount = reaction.second
|
||||||
@ -107,6 +123,10 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : BaseEventItem<H>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun unbind(holder: H) {
|
||||||
|
super.unbind(holder)
|
||||||
|
}
|
||||||
|
|
||||||
protected fun View.renderSendState() {
|
protected fun View.renderSendState() {
|
||||||
isClickable = informationData.sendState.isSent()
|
isClickable = informationData.sendState.isSent()
|
||||||
alpha = if (informationData.sendState.isSent()) 1f else 0.5f
|
alpha = if (informationData.sendState.isSent()) 1f else 0.5f
|
||||||
|
Loading…
Reference in New Issue
Block a user