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:
-
- Handle click on redacted events: view source and create permalink
Other changes:
-
Bugfix:
-
- Fix regression on permalink click
Translations:
-

View file

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

View file

@ -21,5 +21,5 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
fun TimelineEvent.canReact(): Boolean {
// 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,6 +126,7 @@ class MessageMenuViewModel @AssistedInject constructor(@Assisted initialState: M
}
//TODO is downloading attachement?
if (!event.root.isRedacted()) {
if (event.canReact()) {
this.add(SimpleAction(ACTION_ADD_REACTION, R.string.message_add_reaction, R.drawable.ic_add_reaction, eventId))
}
@ -172,6 +173,7 @@ class MessageMenuViewModel @AssistedInject constructor(@Assisted initialState: M
//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()))
if (event.isEncrypted()) {

View file

@ -417,6 +417,14 @@ class MessageItemFactory @Inject constructor(
.informationData(informationData)
.highlighted(highlight)
.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 {