Add a setting to hide redacted events (#951)
This commit is contained in:
parent
05d1e64cb5
commit
e542e4ba22
|
@ -6,6 +6,7 @@ Features ✨:
|
||||||
|
|
||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
- Better connectivity lost indicator when airplane mode is on
|
- Better connectivity lost indicator when airplane mode is on
|
||||||
|
- Add a setting to hide redacted events (#951)
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Fix issues with FontScale switch (#69, #645)
|
- Fix issues with FontScale switch (#69, #645)
|
||||||
|
|
|
@ -28,6 +28,10 @@ data class TimelineSettings(
|
||||||
* A flag to filter edit events
|
* A flag to filter edit events
|
||||||
*/
|
*/
|
||||||
val filterEdits: Boolean = false,
|
val filterEdits: Boolean = false,
|
||||||
|
/**
|
||||||
|
* A flag to filter redacted events
|
||||||
|
*/
|
||||||
|
val filterRedacted: Boolean = false,
|
||||||
/**
|
/**
|
||||||
* A flag to filter by types. It should be used with [allowedTypes] field
|
* A flag to filter by types. It should be used with [allowedTypes] field
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.matrix.android.internal.database.query
|
||||||
|
|
||||||
|
internal object UnsignedContent {
|
||||||
|
internal const val REDACTED_TYPE = """{*"redacted_because":*}"""
|
||||||
|
}
|
|
@ -36,6 +36,7 @@ import im.vector.matrix.android.internal.database.model.RoomEntity
|
||||||
import im.vector.matrix.android.internal.database.model.TimelineEventEntity
|
import im.vector.matrix.android.internal.database.model.TimelineEventEntity
|
||||||
import im.vector.matrix.android.internal.database.model.TimelineEventEntityFields
|
import im.vector.matrix.android.internal.database.model.TimelineEventEntityFields
|
||||||
import im.vector.matrix.android.internal.database.query.FilterContent
|
import im.vector.matrix.android.internal.database.query.FilterContent
|
||||||
|
import im.vector.matrix.android.internal.database.query.UnsignedContent
|
||||||
import im.vector.matrix.android.internal.database.query.findAllInRoomWithSendStates
|
import im.vector.matrix.android.internal.database.query.findAllInRoomWithSendStates
|
||||||
import im.vector.matrix.android.internal.database.query.where
|
import im.vector.matrix.android.internal.database.query.where
|
||||||
import im.vector.matrix.android.internal.database.query.whereInRoom
|
import im.vector.matrix.android.internal.database.query.whereInRoom
|
||||||
|
@ -727,6 +728,9 @@ internal class DefaultTimeline(
|
||||||
not().like(TimelineEventEntityFields.ROOT.CONTENT, FilterContent.EDIT_TYPE)
|
not().like(TimelineEventEntityFields.ROOT.CONTENT, FilterContent.EDIT_TYPE)
|
||||||
not().like(TimelineEventEntityFields.ROOT.CONTENT, FilterContent.RESPONSE_TYPE)
|
not().like(TimelineEventEntityFields.ROOT.CONTENT, FilterContent.RESPONSE_TYPE)
|
||||||
}
|
}
|
||||||
|
if (settings.filterRedacted) {
|
||||||
|
not().like(TimelineEventEntityFields.ROOT.UNSIGNED_DATA, UnsignedContent.REDACTED_TYPE)
|
||||||
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,13 +741,19 @@ internal class DefaultTimeline(
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
if (!filterType) return@filter false
|
||||||
|
|
||||||
val filterEdits = if (settings.filterEdits && it.root.type == EventType.MESSAGE) {
|
val filterEdits = if (settings.filterEdits && it.root.type == EventType.MESSAGE) {
|
||||||
val messageContent = it.root.content.toModel<MessageContent>()
|
val messageContent = it.root.content.toModel<MessageContent>()
|
||||||
messageContent?.relatesTo?.type != RelationType.REPLACE
|
messageContent?.relatesTo?.type != RelationType.REPLACE
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
filterType && filterEdits
|
if (!filterEdits) return@filter false
|
||||||
|
|
||||||
|
val filterRedacted = settings.filterRedacted && it.root.isRedacted()
|
||||||
|
|
||||||
|
filterRedacted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,10 @@ class UserPreferencesProvider @Inject constructor(private val vectorPreferences:
|
||||||
return vectorPreferences.showReadReceipts()
|
return vectorPreferences.showReadReceipts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun shouldShowRedactedMessages(): Boolean {
|
||||||
|
return vectorPreferences.showRedactedMessages()
|
||||||
|
}
|
||||||
|
|
||||||
fun shouldShowLongClickOnRoomHelp(): Boolean {
|
fun shouldShowLongClickOnRoomHelp(): Boolean {
|
||||||
return vectorPreferences.shouldShowLongClickOnRoomHelp()
|
return vectorPreferences.shouldShowLongClickOnRoomHelp()
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,11 +99,13 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||||
private val timelineSettings = if (userPreferencesProvider.shouldShowHiddenEvents()) {
|
private val timelineSettings = if (userPreferencesProvider.shouldShowHiddenEvents()) {
|
||||||
TimelineSettings(30,
|
TimelineSettings(30,
|
||||||
filterEdits = false,
|
filterEdits = false,
|
||||||
|
filterRedacted = userPreferencesProvider.shouldShowRedactedMessages().not(),
|
||||||
filterTypes = false,
|
filterTypes = false,
|
||||||
buildReadReceipts = userPreferencesProvider.shouldShowReadReceipts())
|
buildReadReceipts = userPreferencesProvider.shouldShowReadReceipts())
|
||||||
} else {
|
} else {
|
||||||
TimelineSettings(30,
|
TimelineSettings(30,
|
||||||
filterEdits = true,
|
filterEdits = true,
|
||||||
|
filterRedacted = userPreferencesProvider.shouldShowRedactedMessages().not(),
|
||||||
filterTypes = true,
|
filterTypes = true,
|
||||||
allowedTypes = TimelineDisplayableEvents.DISPLAYABLE_TYPES,
|
allowedTypes = TimelineDisplayableEvents.DISPLAYABLE_TYPES,
|
||||||
buildReadReceipts = userPreferencesProvider.shouldShowReadReceipts())
|
buildReadReceipts = userPreferencesProvider.shouldShowReadReceipts())
|
||||||
|
|
|
@ -88,6 +88,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
||||||
private const val SETTINGS_ALWAYS_SHOW_TIMESTAMPS_KEY = "SETTINGS_ALWAYS_SHOW_TIMESTAMPS_KEY"
|
private const val SETTINGS_ALWAYS_SHOW_TIMESTAMPS_KEY = "SETTINGS_ALWAYS_SHOW_TIMESTAMPS_KEY"
|
||||||
private const val SETTINGS_12_24_TIMESTAMPS_KEY = "SETTINGS_12_24_TIMESTAMPS_KEY"
|
private const val SETTINGS_12_24_TIMESTAMPS_KEY = "SETTINGS_12_24_TIMESTAMPS_KEY"
|
||||||
private const val SETTINGS_SHOW_READ_RECEIPTS_KEY = "SETTINGS_SHOW_READ_RECEIPTS_KEY"
|
private const val SETTINGS_SHOW_READ_RECEIPTS_KEY = "SETTINGS_SHOW_READ_RECEIPTS_KEY"
|
||||||
|
private const val SETTINGS_SHOW_REDACTED_KEY = "SETTINGS_SHOW_REDACTED_KEY"
|
||||||
private const val SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY = "SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY"
|
private const val SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY = "SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY"
|
||||||
private const val SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY = "SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY"
|
private const val SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY = "SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY"
|
||||||
private const val SETTINGS_VIBRATE_ON_MENTION_KEY = "SETTINGS_VIBRATE_ON_MENTION_KEY"
|
private const val SETTINGS_VIBRATE_ON_MENTION_KEY = "SETTINGS_VIBRATE_ON_MENTION_KEY"
|
||||||
|
@ -625,6 +626,15 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
||||||
return defaultPrefs.getBoolean(SETTINGS_SHOW_READ_RECEIPTS_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_SHOW_READ_RECEIPTS_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells if the redacted message should be shown
|
||||||
|
*
|
||||||
|
* @return true if the redacted should be shown
|
||||||
|
*/
|
||||||
|
fun showRedactedMessages(): Boolean {
|
||||||
|
return defaultPrefs.getBoolean(SETTINGS_SHOW_REDACTED_KEY, true)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells if the help on room list should be shown
|
* Tells if the help on room list should be shown
|
||||||
*
|
*
|
||||||
|
|
|
@ -1564,6 +1564,8 @@ Why choose Riot.im?
|
||||||
<string name="reactions">Reactions</string>
|
<string name="reactions">Reactions</string>
|
||||||
|
|
||||||
<string name="event_redacted">Message deleted</string>
|
<string name="event_redacted">Message deleted</string>
|
||||||
|
<string name="settings_show_redacted">Show removed messages</string>
|
||||||
|
<string name="settings_show_redacted_summary">Show a placeholder for removed messages</string>
|
||||||
<string name="event_redacted_by_user_reason">Event deleted by user</string>
|
<string name="event_redacted_by_user_reason">Event deleted by user</string>
|
||||||
<string name="event_redacted_by_admin_reason">Event moderated by room admin</string>
|
<string name="event_redacted_by_admin_reason">Event moderated by room admin</string>
|
||||||
<string name="last_edited_info_message">Last edited by %1$s on %2$s</string>
|
<string name="last_edited_info_message">Last edited by %1$s on %2$s</string>
|
||||||
|
|
|
@ -70,6 +70,12 @@
|
||||||
android:summary="@string/settings_show_read_receipts_summary"
|
android:summary="@string/settings_show_read_receipts_summary"
|
||||||
android:title="@string/settings_show_read_receipts" />
|
android:title="@string/settings_show_read_receipts" />
|
||||||
|
|
||||||
|
<im.vector.riotx.core.preference.VectorSwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="SETTINGS_SHOW_REDACTED_KEY"
|
||||||
|
android:summary="@string/settings_show_redacted_summary"
|
||||||
|
android:title="@string/settings_show_redacted" />
|
||||||
|
|
||||||
<im.vector.riotx.core.preference.VectorSwitchPreference
|
<im.vector.riotx.core.preference.VectorSwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY"
|
android:key="SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY"
|
||||||
|
|
Loading…
Reference in New Issue