Merge branch 'develop' into feature/4s_msc1946

This commit is contained in:
Benoit Marty 2020-02-14 17:45:44 +01:00 committed by GitHub
commit db19ab0531
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 74 additions and 19 deletions

View File

@ -1,4 +1,4 @@
Changes in RiotX 0.16.0 (2020-XX-XX) Changes in RiotX 0.17.0 (2020-XX-XX)
=================================================== ===================================================
Features ✨: Features ✨:
@ -6,19 +6,16 @@ Features ✨:
- Polls and Bot Buttons (MSC 2192 matrix-org/matrix-doc#2192) - Polls and Bot Buttons (MSC 2192 matrix-org/matrix-doc#2192)
Improvements 🙌: Improvements 🙌:
- Show confirmation dialog before deleting a message (#967) -
- Open room member profile from reactions list and read receipts list (#875)
Bugfix 🐛: Bugfix 🐛:
- Fix crash by removing all notifications after clearing cache (#878) -
- Fix issue with verification when other client declares it can only show QR code (#988)
Translations 🗣: Translations 🗣:
- -
SDK API changes 🔞: SDK API changes ⚠️:
- Javadoc improved for PushersService -
- PushersService.pushers() has been renamed to PushersService.getPushers()
Build 🧱: Build 🧱:
- -
@ -26,6 +23,25 @@ Build 🧱:
Other changes: Other changes:
- -
Changes in RiotX 0.16.0 (2020-02-14)
===================================================
Features ✨:
- Polls and Bot Buttons (MSC 2192 matrix-org/matrix-doc#2192)
Improvements 🙌:
- Show confirmation dialog before deleting a message (#967, #1003)
- Open room member profile from reactions list and read receipts list (#875)
Bugfix 🐛:
- Fix crash by removing all notifications after clearing cache (#878)
- Fix issue with verification when other client declares it can only show QR code (#988)
- Fix too errors in the code (1941862499c9ec5268cc80882512ced379cafcfd, a250a895fe0a4acf08c671e03434edcd29ccd84f)
SDK API changes ⚠️:
- Javadoc improved for PushersService
- PushersService.pushers() has been renamed to PushersService.getPushers()
Changes in RiotX 0.15.0 (2020-02-10) Changes in RiotX 0.15.0 (2020-02-10)
=================================================== ===================================================
@ -397,7 +413,7 @@ Bugfix 🐛:
Translations 🗣: Translations 🗣:
- -
SDK API changes 🔞: SDK API changes ⚠️:
- -
Build 🧱: Build 🧱:
@ -405,4 +421,3 @@ Build 🧱:
Other changes: Other changes:
- -

View File

@ -157,6 +157,11 @@ data class Event(
*/ */
fun isRedacted() = unsignedData?.redactedEvent != null fun isRedacted() = unsignedData?.redactedEvent != null
/**
* Tells if the event is redacted by the user himself.
*/
fun isRedactedBySameUser() = senderId == unsignedData?.redactedEvent?.senderId
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
if (javaClass != other?.javaClass) return false if (javaClass != other?.javaClass) return false

View File

@ -15,7 +15,7 @@ androidExtensions {
} }
ext.versionMajor = 0 ext.versionMajor = 0
ext.versionMinor = 16 ext.versionMinor = 17
ext.versionPatch = 0 ext.versionPatch = 0
static def getGitTimestamp() { static def getGitTimestamp() {

View File

@ -789,12 +789,15 @@ class RoomDetailFragment @Inject constructor(
.show() .show()
} }
private fun promptReasonToRedactEvent(eventId: String) { private fun promptConfirmationToRedactEvent(action: EventSharedAction.Redact) {
val layout = requireActivity().layoutInflater.inflate(R.layout.dialog_delete_event, null) val layout = requireActivity().layoutInflater.inflate(R.layout.dialog_delete_event, null)
val reasonCheckBox = layout.findViewById<MaterialCheckBox>(R.id.deleteEventReasonCheck) val reasonCheckBox = layout.findViewById<MaterialCheckBox>(R.id.deleteEventReasonCheck)
val reasonTextInputLayout = layout.findViewById<TextInputLayout>(R.id.deleteEventReasonTextInputLayout) val reasonTextInputLayout = layout.findViewById<TextInputLayout>(R.id.deleteEventReasonTextInputLayout)
val reasonInput = layout.findViewById<TextInputEditText>(R.id.deleteEventReasonInput) val reasonInput = layout.findViewById<TextInputEditText>(R.id.deleteEventReasonInput)
reasonCheckBox.isVisible = action.askForReason
reasonTextInputLayout.isVisible = action.askForReason
reasonCheckBox.setOnCheckedChangeListener { _, isChecked -> reasonTextInputLayout.isEnabled = isChecked } reasonCheckBox.setOnCheckedChangeListener { _, isChecked -> reasonTextInputLayout.isEnabled = isChecked }
AlertDialog.Builder(requireActivity()) AlertDialog.Builder(requireActivity())
@ -802,9 +805,10 @@ class RoomDetailFragment @Inject constructor(
.setView(layout) .setView(layout)
.setPositiveButton(R.string.remove) { _, _ -> .setPositiveButton(R.string.remove) { _, _ ->
val reason = reasonInput.text.toString() val reason = reasonInput.text.toString()
.takeIf { reasonCheckBox.isChecked } .takeIf { action.askForReason }
?.takeIf { reasonCheckBox.isChecked }
?.takeIf { it.isNotBlank() } ?.takeIf { it.isNotBlank() }
roomDetailViewModel.handle(RoomDetailAction.RedactAction(eventId, reason)) roomDetailViewModel.handle(RoomDetailAction.RedactAction(action.eventId, reason))
} }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.show() .show()
@ -1122,7 +1126,7 @@ class RoomDetailFragment @Inject constructor(
showSnackWithMessage(getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT) showSnackWithMessage(getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT)
} }
is EventSharedAction.Redact -> { is EventSharedAction.Redact -> {
promptReasonToRedactEvent(action.eventId) promptConfirmationToRedactEvent(action)
} }
is EventSharedAction.Share -> { is EventSharedAction.Share -> {
// TODO current data communication is too limited // TODO current data communication is too limited

View File

@ -55,7 +55,7 @@ sealed class EventSharedAction(@StringRes val titleRes: Int,
data class Remove(val eventId: String) : data class Remove(val eventId: String) :
EventSharedAction(R.string.remove, R.drawable.ic_trash, true) EventSharedAction(R.string.remove, R.drawable.ic_trash, true)
data class Redact(val eventId: String) : data class Redact(val eventId: String, val askForReason: Boolean) :
EventSharedAction(R.string.message_action_item_redact, R.drawable.ic_delete, true) EventSharedAction(R.string.message_action_item_redact, R.drawable.ic_delete, true)
data class Cancel(val eventId: String) : data class Cancel(val eventId: String) :

View File

@ -168,6 +168,10 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
} }
private fun computeMessageBody(timelineEvent: TimelineEvent): CharSequence { private fun computeMessageBody(timelineEvent: TimelineEvent): CharSequence {
if (timelineEvent.root.isRedacted()) {
return getRedactionReason(timelineEvent)
}
return when (timelineEvent.root.getClearType()) { return when (timelineEvent.root.getClearType()) {
EventType.MESSAGE, EventType.MESSAGE,
EventType.STICKER -> { EventType.STICKER -> {
@ -200,6 +204,31 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
} ?: "" } ?: ""
} }
private fun getRedactionReason(timelineEvent: TimelineEvent): String {
return (timelineEvent
.root
.unsignedData
?.redactedEvent
?.content
?.get("reason") as? String)
?.takeIf { it.isNotBlank() }
.let { reason ->
if (reason == null) {
if (timelineEvent.root.isRedactedBySameUser()) {
stringProvider.getString(R.string.event_redacted_by_user_reason)
} else {
stringProvider.getString(R.string.event_redacted_by_admin_reason)
}
} else {
if (timelineEvent.root.isRedactedBySameUser()) {
stringProvider.getString(R.string.event_redacted_by_user_reason_with_reason, reason)
} else {
stringProvider.getString(R.string.event_redacted_by_admin_reason_with_reason, reason)
}
}
}
}
private fun actionsForEvent(timelineEvent: TimelineEvent): List<EventSharedAction> { private fun actionsForEvent(timelineEvent: TimelineEvent): List<EventSharedAction> {
val messageContent: MessageContent? = timelineEvent.annotations?.editSummary?.aggregatedContent.toModel() val messageContent: MessageContent? = timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()
?: timelineEvent.root.getClearContent().toModel() ?: timelineEvent.root.getClearContent().toModel()
@ -227,7 +256,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
} }
if (canRedact(timelineEvent, session.myUserId)) { if (canRedact(timelineEvent, session.myUserId)) {
add(EventSharedAction.Redact(eventId)) add(EventSharedAction.Redact(eventId, askForReason = informationData.senderId != session.myUserId))
} }
if (canCopy(msgType)) { if (canCopy(msgType)) {

View File

@ -43,8 +43,7 @@
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/deleteEventReasonInput" android:id="@+id/deleteEventReasonInput"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
android:text="@string/event_redacted_by_user_reason" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

View File

@ -35,6 +35,9 @@
<string name="delete_event_dialog_content">Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.</string> <string name="delete_event_dialog_content">Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.</string>
<string name="delete_event_dialog_reason_checkbox">Include a reason</string> <string name="delete_event_dialog_reason_checkbox">Include a reason</string>
<string name="delete_event_dialog_reason_hint">Reason for redacting</string> <string name="delete_event_dialog_reason_hint">Reason for redacting</string>
<string name="event_redacted_by_user_reason_with_reason">Event deleted by user, reason: %1$s</string>
<string name="event_redacted_by_admin_reason_with_reason">Event moderated by room admin, reason: %1$s</string>
<!-- END Strings added by Onuray --> <!-- END Strings added by Onuray -->