diff --git a/matrix-sdk-android/src/main/res/values/strings.xml b/matrix-sdk-android/src/main/res/values/strings.xml
index 023650e0af..de30a64c32 100644
--- a/matrix-sdk-android/src/main/res/values/strings.xml
+++ b/matrix-sdk-android/src/main/res/values/strings.xml
@@ -72,15 +72,15 @@
You upgraded this room.
%s upgraded here.
You upgraded here.
- %s set the server ACLs for this room:
- You set the server ACLs for this room:
+ %s set the server ACLs for this room.
+ You set the server ACLs for this room.
• Server matching %s are banned.
• Server matching %s are allowed.
• Server matching IP literals are allowed.
• Server matching IP literals are banned.
- %s changed the server ACLs for this room:
- You changed the server ACLs for this room:
+ %s changed the server ACLs for this room.
+ You changed the server ACLs for this room.
• Server matching %s are now banned.
• Server matching %s were removed from the ban list.
• Server matching %s are now allowed.
diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt
index c93f6b9837..b5859ba1ba 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt
@@ -19,6 +19,7 @@ package im.vector.app.features.home.room.detail.timeline.format
import im.vector.app.ActiveSessionDataSource
import im.vector.app.R
import im.vector.app.core.resources.StringProvider
+import im.vector.app.features.settings.VectorPreferences
import org.matrix.android.sdk.api.extensions.appendNl
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.events.model.Event
@@ -50,9 +51,12 @@ import org.matrix.android.sdk.internal.crypto.model.event.EncryptionEventContent
import timber.log.Timber
import javax.inject.Inject
-class NoticeEventFormatter @Inject constructor(private val activeSessionDataSource: ActiveSessionDataSource,
- private val roomHistoryVisibilityFormatter: RoomHistoryVisibilityFormatter,
- private val sp: StringProvider) {
+class NoticeEventFormatter @Inject constructor(
+ private val activeSessionDataSource: ActiveSessionDataSource,
+ private val roomHistoryVisibilityFormatter: RoomHistoryVisibilityFormatter,
+ private val vectorPreferences: VectorPreferences,
+ private val sp: StringProvider
+) {
private val currentUserId: String?
get() = activeSessionDataSource.currentValue?.orNull()?.myUserId
@@ -405,55 +409,58 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
sp.getString(R.string.notice_room_server_acl_updated_title, senderName)
}
})
- // Details
if (eventContent.allowList.isEmpty()) {
// Special case for stuck room
- append("\n")
- append(sp.getString(R.string.notice_room_server_acl_allow_is_empty))
+ appendNl(sp.getString(R.string.notice_room_server_acl_allow_is_empty))
+ } else if (vectorPreferences.developerMode()) {
+ // Details, only in developer mode
+ appendAclDetails(eventContent, prevEventContent)
+ }
+ }
+ }
+
+ private fun StringBuilder.appendAclDetails(eventContent: RoomServerAclContent, prevEventContent: RoomServerAclContent?) {
+ if (prevEventContent == null) {
+ eventContent.allowList.forEach { appendNl(sp.getString(R.string.notice_room_server_acl_set_allowed, it)) }
+ eventContent.denyList.forEach { appendNl(sp.getString(R.string.notice_room_server_acl_set_banned, it)) }
+ if (eventContent.allowIpLiterals) {
+ appendNl(sp.getString(R.string.notice_room_server_acl_set_ip_literals_allowed))
} else {
- if (prevEventContent == null) {
- eventContent.allowList.forEach { appendNl(sp.getString(R.string.notice_room_server_acl_set_allowed, it)) }
- eventContent.denyList.forEach { appendNl(sp.getString(R.string.notice_room_server_acl_set_banned, it)) }
- if (eventContent.allowIpLiterals) {
- appendNl(sp.getString(R.string.notice_room_server_acl_set_ip_literals_allowed))
- } else {
- appendNl(sp.getString(R.string.notice_room_server_acl_set_ip_literals_not_allowed))
- }
+ appendNl(sp.getString(R.string.notice_room_server_acl_set_ip_literals_not_allowed))
+ }
+ } else {
+ // Display only diff
+ var hasChanged = false
+ // New allowed servers
+ (eventContent.allowList - prevEventContent.allowList)
+ .also { hasChanged = hasChanged || it.isNotEmpty() }
+ .forEach { appendNl(sp.getString(R.string.notice_room_server_acl_updated_allowed, it)) }
+ // Removed allowed servers
+ (prevEventContent.allowList - eventContent.allowList)
+ .also { hasChanged = hasChanged || it.isNotEmpty() }
+ .forEach { appendNl(sp.getString(R.string.notice_room_server_acl_updated_was_allowed, it)) }
+ // New denied servers
+ (eventContent.denyList - prevEventContent.denyList)
+ .also { hasChanged = hasChanged || it.isNotEmpty() }
+ .forEach { appendNl(sp.getString(R.string.notice_room_server_acl_updated_banned, it)) }
+ // Removed denied servers
+ (prevEventContent.denyList - eventContent.denyList)
+ .also { hasChanged = hasChanged || it.isNotEmpty() }
+ .forEach { appendNl(sp.getString(R.string.notice_room_server_acl_updated_was_banned, it)) }
+
+
+ if (prevEventContent.allowIpLiterals != eventContent.allowIpLiterals) {
+ hasChanged = true
+ if (eventContent.allowIpLiterals) {
+ appendNl(sp.getString(R.string.notice_room_server_acl_updated_ip_literals_allowed))
} else {
- // Display only diff
- var hasChanged = false
- // New allowed servers
- (eventContent.allowList - prevEventContent.allowList)
- .also { hasChanged = hasChanged || it.isNotEmpty() }
- .forEach { appendNl(sp.getString(R.string.notice_room_server_acl_updated_allowed, it)) }
- // Removed allowed servers
- (prevEventContent.allowList - eventContent.allowList)
- .also { hasChanged = hasChanged || it.isNotEmpty() }
- .forEach { appendNl(sp.getString(R.string.notice_room_server_acl_updated_was_allowed, it)) }
- // New denied servers
- (eventContent.denyList - prevEventContent.denyList)
- .also { hasChanged = hasChanged || it.isNotEmpty() }
- .forEach { appendNl(sp.getString(R.string.notice_room_server_acl_updated_banned, it)) }
- // Removed denied servers
- (prevEventContent.denyList - eventContent.denyList)
- .also { hasChanged = hasChanged || it.isNotEmpty() }
- .forEach { appendNl(sp.getString(R.string.notice_room_server_acl_updated_was_banned, it)) }
-
-
- if (prevEventContent.allowIpLiterals != eventContent.allowIpLiterals) {
- hasChanged = true
- if (eventContent.allowIpLiterals) {
- appendNl(sp.getString(R.string.notice_room_server_acl_updated_ip_literals_allowed))
- } else {
- appendNl(sp.getString(R.string.notice_room_server_acl_updated_ip_literals_not_allowed))
- }
- }
-
- if (!hasChanged) {
- appendNl(sp.getString(R.string.notice_room_server_acl_updated_no_change))
- }
+ appendNl(sp.getString(R.string.notice_room_server_acl_updated_ip_literals_not_allowed))
}
}
+
+ if (!hasChanged) {
+ appendNl(sp.getString(R.string.notice_room_server_acl_updated_no_change))
+ }
}
}