Merge pull request #343 from vector-im/feature/click_on_redacted_event

Handle click on redacted event
This commit is contained in:
Benoit Marty 2019-07-15 10:46:06 +02:00 committed by GitHub
commit 2ba83e456d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 45 deletions

View File

@ -5,13 +5,13 @@ Features:
- -


Improvements: Improvements:
- - Handle click on redacted events: view source and create permalink


Other changes: Other changes:
- -


Bugfix: Bugfix:
- - Fix regression on permalink click


Translations: Translations:
- -

View File

@ -42,7 +42,7 @@ object MatrixLinkify {
hasMatch = true hasMatch = true
val startPos = match.range.first val startPos = match.range.first
if (startPos == 0 || text[startPos - 1] != '/') { if (startPos == 0 || text[startPos - 1] != '/') {
val endPos = match.range.last val endPos = match.range.last + 1
val url = text.substring(match.range) val url = text.substring(match.range)
val span = MatrixPermalinkSpan(url, callback) val span = MatrixPermalinkSpan(url, callback)
spannable.setSpan(span, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) spannable.setSpan(span, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
@ -51,5 +51,5 @@ object MatrixLinkify {
} }
return hasMatch return hasMatch
} }

} }

View File

@ -21,5 +21,5 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent


fun TimelineEvent.canReact(): Boolean { fun TimelineEvent.canReact(): Boolean {
// Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment
return root.getClearType() == EventType.MESSAGE && sendState.isSent() return root.getClearType() == EventType.MESSAGE && sendState.isSent() && !root.isRedacted()
} }

View File

@ -126,51 +126,53 @@ class MessageMenuViewModel @AssistedInject constructor(@Assisted initialState: M
} }
//TODO is downloading attachement? //TODO is downloading attachement?


if (event.canReact()) { if (!event.root.isRedacted()) {
this.add(SimpleAction(ACTION_ADD_REACTION, R.string.message_add_reaction, R.drawable.ic_add_reaction, eventId)) if (event.canReact()) {
} this.add(SimpleAction(ACTION_ADD_REACTION, R.string.message_add_reaction, R.drawable.ic_add_reaction, eventId))
if (canCopy(type)) { }
//TODO copy images? html? see ClipBoard if (canCopy(type)) {
this.add(SimpleAction(ACTION_COPY, R.string.copy, R.drawable.ic_copy, messageContent!!.body)) //TODO copy images? html? see ClipBoard
} this.add(SimpleAction(ACTION_COPY, R.string.copy, R.drawable.ic_copy, messageContent!!.body))

}
if (canReply(event, messageContent)) {
this.add(SimpleAction(ACTION_REPLY, R.string.reply, R.drawable.ic_reply, eventId)) if (canReply(event, messageContent)) {
} this.add(SimpleAction(ACTION_REPLY, R.string.reply, R.drawable.ic_reply, eventId))

}
if (canEdit(event, session.sessionParams.credentials.userId)) {
this.add(SimpleAction(ACTION_EDIT, R.string.edit, R.drawable.ic_edit, eventId)) if (canEdit(event, session.sessionParams.credentials.userId)) {
} this.add(SimpleAction(ACTION_EDIT, R.string.edit, R.drawable.ic_edit, eventId))

}
if (canRedact(event, session.sessionParams.credentials.userId)) {
this.add(SimpleAction(ACTION_DELETE, R.string.delete, R.drawable.ic_delete, eventId)) if (canRedact(event, session.sessionParams.credentials.userId)) {
} this.add(SimpleAction(ACTION_DELETE, R.string.delete, R.drawable.ic_delete, eventId))

}
if (canQuote(event, messageContent)) {
this.add(SimpleAction(ACTION_QUOTE, R.string.quote, R.drawable.ic_quote, eventId)) if (canQuote(event, messageContent)) {
} this.add(SimpleAction(ACTION_QUOTE, R.string.quote, R.drawable.ic_quote, eventId))

}
if (canViewReactions(event)) {
this.add(SimpleAction(ACTION_VIEW_REACTIONS, R.string.message_view_reaction, R.drawable.ic_view_reactions, informationData)) if (canViewReactions(event)) {
} this.add(SimpleAction(ACTION_VIEW_REACTIONS, R.string.message_view_reaction, R.drawable.ic_view_reactions, informationData))

}
if (canShare(type)) {
if (messageContent is MessageImageContent) { if (canShare(type)) {
this.add( if (messageContent is MessageImageContent) {
SimpleAction(ACTION_SHARE, this.add(
R.string.share, R.drawable.ic_share, SimpleAction(ACTION_SHARE,
session.contentUrlResolver().resolveFullSize(messageContent.url)) R.string.share, R.drawable.ic_share,
) session.contentUrlResolver().resolveFullSize(messageContent.url))
)
}
//TODO
} }
//TODO
}




if (event.sendState == SendState.SENT) { if (event.sendState == SendState.SENT) {


//TODO Can be redacted //TODO Can be redacted


//TODO sent by me or sufficient power level //TODO sent by me or sufficient power level
}
} }


this.add(SimpleAction(VIEW_SOURCE, R.string.view_source, R.drawable.ic_view_source, event.root.toContentStringWithIndent())) this.add(SimpleAction(VIEW_SOURCE, R.string.view_source, R.drawable.ic_view_source, event.root.toContentStringWithIndent()))

View File

@ -417,6 +417,14 @@ class MessageItemFactory @Inject constructor(
.informationData(informationData) .informationData(informationData)
.highlighted(highlight) .highlighted(highlight)
.avatarCallback(callback) .avatarCallback(callback)
.cellClickListener(
DebouncedClickListener(View.OnClickListener { view ->
callback?.onEventCellClicked(informationData, null, view)
}))
.longClickListener { view ->
return@longClickListener callback?.onEventLongClicked(informationData, null, view)
?: false
}
} }


private fun linkifyBody(body: CharSequence, callback: TimelineEventController.Callback?): CharSequence { private fun linkifyBody(body: CharSequence, callback: TimelineEventController.Callback?): CharSequence {