Avoid long lines
This commit is contained in:
parent
7f26dbe260
commit
108a31eca3
@ -59,23 +59,24 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
|
|
||||||
private fun RoomSummary?.isDm() = this?.isDirect.orFalse()
|
private fun RoomSummary?.isDm() = this?.isDirect.orFalse()
|
||||||
|
|
||||||
fun format(timelineEvent: TimelineEvent, roomSummary: RoomSummary?): CharSequence? {
|
fun format(timelineEvent: TimelineEvent, rs: RoomSummary?): CharSequence? {
|
||||||
return when (val type = timelineEvent.root.getClearType()) {
|
return when (val type = timelineEvent.root.getClearType()) {
|
||||||
EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, roomSummary)
|
EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, rs)
|
||||||
EventType.STATE_ROOM_CREATE -> formatRoomCreateEvent(timelineEvent.root, roomSummary)
|
EventType.STATE_ROOM_CREATE -> formatRoomCreateEvent(timelineEvent.root, rs)
|
||||||
EventType.STATE_ROOM_NAME -> formatRoomNameEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
EventType.STATE_ROOM_NAME -> formatRoomNameEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
||||||
EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
||||||
EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
||||||
EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, roomSummary)
|
EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, rs)
|
||||||
EventType.STATE_ROOM_THIRD_PARTY_INVITE -> formatRoomThirdPartyInvite(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, roomSummary )
|
EventType.STATE_ROOM_THIRD_PARTY_INVITE -> formatRoomThirdPartyInvite(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, rs)
|
||||||
EventType.STATE_ROOM_ALIASES -> formatRoomAliasesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
EventType.STATE_ROOM_ALIASES -> formatRoomAliasesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
||||||
EventType.STATE_ROOM_CANONICAL_ALIAS -> formatRoomCanonicalAliasEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
EventType.STATE_ROOM_CANONICAL_ALIAS -> formatRoomCanonicalAliasEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
||||||
EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, roomSummary)
|
EventType.STATE_ROOM_HISTORY_VISIBILITY ->
|
||||||
EventType.STATE_ROOM_GUEST_ACCESS -> formatRoomGuestAccessEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, roomSummary)
|
formatRoomHistoryVisibilityEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, rs)
|
||||||
|
EventType.STATE_ROOM_GUEST_ACCESS -> formatRoomGuestAccessEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, rs)
|
||||||
EventType.STATE_ROOM_ENCRYPTION -> formatRoomEncryptionEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
EventType.STATE_ROOM_ENCRYPTION -> formatRoomEncryptionEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
||||||
EventType.STATE_ROOM_WIDGET,
|
EventType.STATE_ROOM_WIDGET,
|
||||||
EventType.STATE_ROOM_WIDGET_LEGACY -> formatWidgetEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
EventType.STATE_ROOM_WIDGET_LEGACY -> formatWidgetEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
||||||
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, roomSummary)
|
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, rs)
|
||||||
EventType.STATE_ROOM_POWER_LEVELS -> formatRoomPowerLevels(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
EventType.STATE_ROOM_POWER_LEVELS -> formatRoomPowerLevels(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
|
||||||
EventType.CALL_INVITE,
|
EventType.CALL_INVITE,
|
||||||
EventType.CALL_CANDIDATES,
|
EventType.CALL_CANDIDATES,
|
||||||
@ -154,19 +155,19 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun format(event: Event, senderName: String?, roomSummary: RoomSummary?): CharSequence? {
|
fun format(event: Event, senderName: String?, rs: RoomSummary?): CharSequence? {
|
||||||
return when (val type = event.getClearType()) {
|
return when (val type = event.getClearType()) {
|
||||||
EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(event, senderName, roomSummary)
|
EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(event, senderName, rs)
|
||||||
EventType.STATE_ROOM_NAME -> formatRoomNameEvent(event, senderName)
|
EventType.STATE_ROOM_NAME -> formatRoomNameEvent(event, senderName)
|
||||||
EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(event, senderName)
|
EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(event, senderName)
|
||||||
EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(event, senderName)
|
EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(event, senderName)
|
||||||
EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(event, senderName, roomSummary)
|
EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(event, senderName, rs)
|
||||||
EventType.STATE_ROOM_THIRD_PARTY_INVITE -> formatRoomThirdPartyInvite(event, senderName, roomSummary)
|
EventType.STATE_ROOM_THIRD_PARTY_INVITE -> formatRoomThirdPartyInvite(event, senderName, rs)
|
||||||
EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(event, senderName, roomSummary)
|
EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(event, senderName, rs)
|
||||||
EventType.CALL_INVITE,
|
EventType.CALL_INVITE,
|
||||||
EventType.CALL_HANGUP,
|
EventType.CALL_HANGUP,
|
||||||
EventType.CALL_ANSWER -> formatCallEvent(type, event, senderName)
|
EventType.CALL_ANSWER -> formatCallEvent(type, event, senderName)
|
||||||
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName, roomSummary)
|
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName, rs)
|
||||||
else -> {
|
else -> {
|
||||||
Timber.v("Type $type not handled by this formatter")
|
Timber.v("Type $type not handled by this formatter")
|
||||||
null
|
null
|
||||||
@ -178,14 +179,14 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
return "{ \"type\": ${event.getClearType()} }"
|
return "{ \"type\": ${event.getClearType()} }"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatRoomCreateEvent(event: Event, roomSummary: RoomSummary?): CharSequence? {
|
private fun formatRoomCreateEvent(event: Event, rs: RoomSummary?): CharSequence? {
|
||||||
return event.getClearContent().toModel<RoomCreateContent>()
|
return event.getClearContent().toModel<RoomCreateContent>()
|
||||||
?.takeIf { it.creator.isNullOrBlank().not() }
|
?.takeIf { it.creator.isNullOrBlank().not() }
|
||||||
?.let {
|
?.let {
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_created_by_you else R.string.notice_room_created_by_you)
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_created_by_you else R.string.notice_room_created_by_you)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_created else R.string.notice_room_created, it.creator)
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_created else R.string.notice_room_created, it.creator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,11 +208,11 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatRoomTombstoneEvent(event: Event, senderName: String?, roomSummary: RoomSummary?): CharSequence? {
|
private fun formatRoomTombstoneEvent(event: Event, senderName: String?, rs: RoomSummary?): CharSequence? {
|
||||||
return if (event.isSentByCurrentUser()) {
|
return if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_update_by_you else R.string.notice_room_update_by_you)
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_update_by_you else R.string.notice_room_update_by_you)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_update else R.string.notice_room_update, senderName)
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_update else R.string.notice_room_update, senderName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,20 +250,20 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatRoomHistoryVisibilityEvent(event: Event, senderName: String?, roomSummary: RoomSummary?): CharSequence? {
|
private fun formatRoomHistoryVisibilityEvent(event: Event, senderName: String?, rs: RoomSummary?): CharSequence? {
|
||||||
val historyVisibility = event.getClearContent().toModel<RoomHistoryVisibilityContent>()?.historyVisibility ?: return null
|
val historyVisibility = event.getClearContent().toModel<RoomHistoryVisibilityContent>()?.historyVisibility ?: return null
|
||||||
|
|
||||||
val formattedVisibility = roomHistoryVisibilityFormatter.format(historyVisibility)
|
val formattedVisibility = roomHistoryVisibilityFormatter.format(historyVisibility)
|
||||||
return if (event.isSentByCurrentUser()) {
|
return if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_made_future_direct_room_visibility_by_you else R.string.notice_made_future_room_visibility_by_you,
|
sp.getString(if (rs.isDm()) R.string.notice_made_future_direct_room_visibility_by_you else R.string.notice_made_future_room_visibility_by_you,
|
||||||
formattedVisibility)
|
formattedVisibility)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_made_future_direct_room_visibility else R.string.notice_made_future_room_visibility,
|
sp.getString(if (rs.isDm()) R.string.notice_made_future_direct_room_visibility else R.string.notice_made_future_room_visibility,
|
||||||
senderName, formattedVisibility)
|
senderName, formattedVisibility)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatRoomThirdPartyInvite(event: Event, senderName: String?, roomSummary: RoomSummary?): CharSequence? {
|
private fun formatRoomThirdPartyInvite(event: Event, senderName: String?, rs: RoomSummary?): CharSequence? {
|
||||||
val content = event.getClearContent().toModel<RoomThirdPartyInviteContent>()
|
val content = event.getClearContent().toModel<RoomThirdPartyInviteContent>()
|
||||||
val prevContent = event.resolvedPrevContent()?.toModel<RoomThirdPartyInviteContent>()
|
val prevContent = event.resolvedPrevContent()?.toModel<RoomThirdPartyInviteContent>()
|
||||||
|
|
||||||
@ -271,24 +272,24 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
// Revoke case
|
// Revoke case
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(
|
sp.getString(
|
||||||
if (roomSummary.isDm()) {
|
if (rs.isDm()) {
|
||||||
R.string.notice_direct_room_third_party_revoked_invite_by_you
|
R.string.notice_direct_room_third_party_revoked_invite_by_you
|
||||||
} else {
|
} else {
|
||||||
R.string.notice_room_third_party_revoked_invite_by_you
|
R.string.notice_room_third_party_revoked_invite_by_you
|
||||||
},
|
},
|
||||||
prevContent.displayName)
|
prevContent.displayName)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_third_party_revoked_invite else R.string.notice_room_third_party_revoked_invite,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_third_party_revoked_invite else R.string.notice_room_third_party_revoked_invite,
|
||||||
senderName, prevContent.displayName)
|
senderName, prevContent.displayName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
content != null -> {
|
content != null -> {
|
||||||
// Invitation case
|
// Invitation case
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_third_party_invite_by_you else R.string.notice_room_third_party_invite_by_you,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_third_party_invite_by_you else R.string.notice_room_third_party_invite_by_you,
|
||||||
content.displayName)
|
content.displayName)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_third_party_invite else R.string.notice_room_third_party_invite,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_third_party_invite else R.string.notice_room_third_party_invite,
|
||||||
senderName, content.displayName)
|
senderName, content.displayName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,13 +338,13 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatRoomMemberEvent(event: Event, senderName: String?, roomSummary: RoomSummary?): String? {
|
private fun formatRoomMemberEvent(event: Event, senderName: String?, rs: RoomSummary?): String? {
|
||||||
val eventContent: RoomMemberContent? = event.getClearContent().toModel()
|
val eventContent: RoomMemberContent? = event.getClearContent().toModel()
|
||||||
val prevEventContent: RoomMemberContent? = event.resolvedPrevContent().toModel()
|
val prevEventContent: RoomMemberContent? = event.resolvedPrevContent().toModel()
|
||||||
val isMembershipEvent = prevEventContent?.membership != eventContent?.membership
|
val isMembershipEvent = prevEventContent?.membership != eventContent?.membership
|
||||||
|| eventContent?.membership == Membership.LEAVE
|
|| eventContent?.membership == Membership.LEAVE
|
||||||
return if (isMembershipEvent) {
|
return if (isMembershipEvent) {
|
||||||
buildMembershipNotice(event, senderName, eventContent, prevEventContent, roomSummary)
|
buildMembershipNotice(event, senderName, eventContent, prevEventContent, rs)
|
||||||
} else {
|
} else {
|
||||||
buildProfileNotice(event, senderName, eventContent, prevEventContent)
|
buildProfileNotice(event, senderName, eventContent, prevEventContent)
|
||||||
}
|
}
|
||||||
@ -401,25 +402,25 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatRoomGuestAccessEvent(event: Event, senderName: String?, roomSummary: RoomSummary?): String? {
|
private fun formatRoomGuestAccessEvent(event: Event, senderName: String?, rs: RoomSummary?): String? {
|
||||||
val eventContent: RoomGuestAccessContent? = event.getClearContent().toModel()
|
val eventContent: RoomGuestAccessContent? = event.getClearContent().toModel()
|
||||||
return when (eventContent?.guestAccess) {
|
return when (eventContent?.guestAccess) {
|
||||||
GuestAccess.CanJoin ->
|
GuestAccess.CanJoin ->
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(
|
sp.getString(
|
||||||
if (roomSummary.isDm()) R.string.notice_direct_room_guest_access_can_join_by_you else R.string.notice_room_guest_access_can_join_by_you
|
if (rs.isDm()) R.string.notice_direct_room_guest_access_can_join_by_you else R.string.notice_room_guest_access_can_join_by_you
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_guest_access_can_join else R.string.notice_room_guest_access_can_join,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_guest_access_can_join else R.string.notice_room_guest_access_can_join,
|
||||||
senderName)
|
senderName)
|
||||||
}
|
}
|
||||||
GuestAccess.Forbidden ->
|
GuestAccess.Forbidden ->
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(
|
sp.getString(
|
||||||
if (roomSummary.isDm()) R.string.notice_direct_room_guest_access_forbidden_by_you else R.string.notice_room_guest_access_forbidden_by_you
|
if (rs.isDm()) R.string.notice_direct_room_guest_access_forbidden_by_you else R.string.notice_room_guest_access_forbidden_by_you
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_guest_access_forbidden else R.string.notice_room_guest_access_forbidden,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_guest_access_forbidden else R.string.notice_room_guest_access_forbidden,
|
||||||
senderName)
|
senderName)
|
||||||
}
|
}
|
||||||
else -> null
|
else -> null
|
||||||
@ -496,7 +497,11 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
return displayText.toString()
|
return displayText.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildMembershipNotice(event: Event, senderName: String?, eventContent: RoomMemberContent?, prevEventContent: RoomMemberContent?, roomSummary: RoomSummary?): String? {
|
private fun buildMembershipNotice(event: Event,
|
||||||
|
senderName: String?,
|
||||||
|
eventContent: RoomMemberContent?,
|
||||||
|
prevEventContent: RoomMemberContent?,
|
||||||
|
rs: RoomSummary?): String? {
|
||||||
val senderDisplayName = senderName ?: event.senderId ?: ""
|
val senderDisplayName = senderName ?: event.senderId ?: ""
|
||||||
val targetDisplayName = eventContent?.displayName ?: prevEventContent?.displayName ?: event.stateKey ?: ""
|
val targetDisplayName = eventContent?.displayName ?: prevEventContent?.displayName ?: event.stateKey ?: ""
|
||||||
return when (eventContent?.membership) {
|
return when (eventContent?.membership) {
|
||||||
@ -546,17 +551,17 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
Membership.JOIN ->
|
Membership.JOIN ->
|
||||||
eventContent.safeReason?.let { reason ->
|
eventContent.safeReason?.let { reason ->
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_join_with_reason_by_you else R.string.notice_room_join_with_reason_by_you,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_join_with_reason_by_you else R.string.notice_room_join_with_reason_by_you,
|
||||||
reason)
|
reason)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_join_with_reason else R.string.notice_room_join_with_reason,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_join_with_reason else R.string.notice_room_join_with_reason,
|
||||||
senderDisplayName, reason)
|
senderDisplayName, reason)
|
||||||
}
|
}
|
||||||
} ?: run {
|
} ?: run {
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_join_by_you else R.string.notice_room_join_by_you)
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_join_by_you else R.string.notice_room_join_by_you)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_join else R.string.notice_room_join,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_join else R.string.notice_room_join,
|
||||||
senderDisplayName)
|
senderDisplayName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -578,7 +583,7 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
eventContent.safeReason?.let { reason ->
|
eventContent.safeReason?.let { reason ->
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(
|
sp.getString(
|
||||||
if (roomSummary.isDm()) {
|
if (rs.isDm()) {
|
||||||
R.string.notice_direct_room_leave_with_reason_by_you
|
R.string.notice_direct_room_leave_with_reason_by_you
|
||||||
} else {
|
} else {
|
||||||
R.string.notice_room_leave_with_reason_by_you
|
R.string.notice_room_leave_with_reason_by_you
|
||||||
@ -586,14 +591,14 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
reason
|
reason
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_leave_with_reason else R.string.notice_room_leave_with_reason,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_leave_with_reason else R.string.notice_room_leave_with_reason,
|
||||||
senderDisplayName, reason)
|
senderDisplayName, reason)
|
||||||
}
|
}
|
||||||
} ?: run {
|
} ?: run {
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_leave_by_you else R.string.notice_room_leave_by_you)
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_leave_by_you else R.string.notice_room_leave_by_you)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.notice_direct_room_leave else R.string.notice_room_leave,
|
sp.getString(if (rs.isDm()) R.string.notice_direct_room_leave else R.string.notice_room_leave,
|
||||||
senderDisplayName)
|
senderDisplayName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -658,14 +663,14 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatJoinRulesEvent(event: Event, senderName: String?, roomSummary: RoomSummary?): CharSequence? {
|
private fun formatJoinRulesEvent(event: Event, senderName: String?, rs: RoomSummary?): CharSequence? {
|
||||||
val content = event.getClearContent().toModel<RoomJoinRulesContent>() ?: return null
|
val content = event.getClearContent().toModel<RoomJoinRulesContent>() ?: return null
|
||||||
return when (content.joinRules) {
|
return when (content.joinRules) {
|
||||||
RoomJoinRules.INVITE ->
|
RoomJoinRules.INVITE ->
|
||||||
if (event.isSentByCurrentUser()) {
|
if (event.isSentByCurrentUser()) {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.direct_room_join_rules_invite_by_you else R.string.room_join_rules_invite_by_you)
|
sp.getString(if (rs.isDm()) R.string.direct_room_join_rules_invite_by_you else R.string.room_join_rules_invite_by_you)
|
||||||
} else {
|
} else {
|
||||||
sp.getString(if (roomSummary.isDm()) R.string.direct_room_join_rules_invite else R.string.room_join_rules_invite,
|
sp.getString(if (rs.isDm()) R.string.direct_room_join_rules_invite else R.string.room_join_rules_invite,
|
||||||
senderName)
|
senderName)
|
||||||
}
|
}
|
||||||
RoomJoinRules.PUBLIC ->
|
RoomJoinRules.PUBLIC ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user