diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesPresenter.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesPresenter.kt index 3ab2d060cd..54795210e7 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesPresenter.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesPresenter.kt @@ -212,7 +212,7 @@ class MessagesPresenter @AssistedInject constructor( } return MessagesState( - isDebugBuild = buildMeta.isDebuggable, + isDebugBuild = buildMeta.isDebuggable, roomId = room.roomId, roomName = roomName, roomAvatar = roomAvatar, diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt index 13bb662a67..00a1dea677 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt @@ -90,7 +90,6 @@ import io.element.android.features.messages.impl.voicemessages.composer.VoiceMes import io.element.android.features.messages.impl.voicemessages.composer.VoiceMessageSendingFailedDialog import io.element.android.features.networkmonitor.api.ui.ConnectivityIndicatorView import io.element.android.libraries.androidutils.ui.hideKeyboard -import io.element.android.libraries.core.bool.orFalse import io.element.android.libraries.designsystem.atomic.molecules.IconTitlePlaceholdersRowMolecule import io.element.android.libraries.designsystem.components.ProgressDialog import io.element.android.libraries.designsystem.components.ProgressDialogType diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/suggestions/SuggestionsPickerView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/suggestions/SuggestionsPickerView.kt index b77494efb1..970479fb31 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/suggestions/SuggestionsPickerView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/suggestions/SuggestionsPickerView.kt @@ -32,7 +32,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import io.element.android.compound.theme.ElementTheme -import io.element.android.features.messages.impl.MessagesState import io.element.android.features.messages.impl.R import io.element.android.libraries.designsystem.components.avatar.Avatar import io.element.android.libraries.designsystem.components.avatar.AvatarData diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/reactionsummary/ReactionSummaryView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/reactionsummary/ReactionSummaryView.kt index 435411c9dc..36025bb669 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/reactionsummary/ReactionSummaryView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/reactionsummary/ReactionSummaryView.kt @@ -158,7 +158,8 @@ private fun SheetContent( SenderRow( isDebugBuild = summary.isDebugBuild, avatarData = user.getAvatarData(AvatarSize.UserListItem), - name = user.getBestName(), // TCHAP TODO should be applied in Element X + // TCHAP TODO should be applied in Element X + name = user.getBestName(), userId = user.userId.value, sentTime = sender.sentTime ) diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/RoomDetailsView.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/RoomDetailsView.kt index b34b454414..fe166b37d3 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/RoomDetailsView.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/RoomDetailsView.kt @@ -370,7 +370,8 @@ private fun DmHeaderSection( ) TitleAndSubtitle( title = roomName, - subtitle = otherMember.userId.value.takeIf { isDebugBuild }, // TCHAP hide the Matrix Id in release mode + // TCHAP hide the Matrix Id in release mode + subtitle = otherMember.userId.value.takeIf { isDebugBuild }, ) } } diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationView.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationView.kt index 700cfbaa05..88fe803a2d 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationView.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationView.kt @@ -225,7 +225,8 @@ private fun RoomMemberActionsBottomSheet( .align(Alignment.CenterHorizontally) ) Text( - text = roomMember.getBestName(), // TCHAP display a value generated from userId if displayname does not exist + // TCHAP display a value generated from userId if displayname does not exist + text = roomMember.getBestName(), style = ElementTheme.typography.fontHeadingLgBold, maxLines = 1, overflow = TextOverflow.Ellipsis, @@ -234,8 +235,7 @@ private fun RoomMemberActionsBottomSheet( .padding(start = 16.dp, end = 16.dp, bottom = 8.dp) .fillMaxWidth() ) - // TCHAP hide the Matrix Id in release mode - if (isDebugBuild) { + if (isDebugBuild) { // TCHAP hide the Matrix Id in release mode Text( text = roomMember.userId.toString(), style = ElementTheme.typography.fontBodyLgRegular, diff --git a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/model/InviteSender.kt b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/model/InviteSender.kt index 155b3d21a7..17bd7dcee4 100644 --- a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/model/InviteSender.kt +++ b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/model/InviteSender.kt @@ -38,7 +38,7 @@ data class InviteSender( ) { @Composable fun annotatedString(): AnnotatedString { - return stringResource(R.string.screen_invites_invited_you, displayName, userId.value).let { text -> // TCHAP TODO text should be changed to hide the user id + return stringResource(R.string.screen_invites_invited_you, displayName, userId.value).let { text -> // TCHAP TODO should be changed to hide the user id val senderNameStart = LocalContext.current.getString(R.string.screen_invites_invited_you).indexOf("%1\$s") AnnotatedString( text = text, diff --git a/libraries/tchaputils/src/main/java/fr/gouv/tchap/libraries/tchaputils/TchapPatterns.kt b/libraries/tchaputils/src/main/java/fr/gouv/tchap/libraries/tchaputils/TchapPatterns.kt index f88b28caee..5115b02812 100644 --- a/libraries/tchaputils/src/main/java/fr/gouv/tchap/libraries/tchaputils/TchapPatterns.kt +++ b/libraries/tchaputils/src/main/java/fr/gouv/tchap/libraries/tchaputils/TchapPatterns.kt @@ -33,7 +33,6 @@ object TchapPatterns { * For example in case of "@jean-philippe.martin-modernisation.fr:matrix.test.org", this will return "matrix.test.org". * in case of "!AAAAAAA:matrix.test.org", this will return "matrix.test.org". * - * @param mxId the matrix identifier. * @return the homeserver name, if any. */ fun String.toHomeserverName() = this.substringAfter(":", "") @@ -46,7 +45,6 @@ object TchapPatterns { * For example in case of "@jean-philippe.martin-modernisation.fr:name1.tchap.gouv.fr", this will return "Name1". * in case of "@jean-philippe.martin-modernisation.fr:agent.name2.tchap.gouv.fr", this will return "Name2". * - * @param mxId the matrix identifier. * @return the Tchap display name of the homeserver. */ fun String.toHomeserverDisplayName(): String { @@ -62,7 +60,6 @@ object TchapPatterns { /** * Tells whether a homeserver name corresponds to an external server or not. * - * @param homeServerName the homeserver name to check. * @return true if external. */ fun String.isExternalTchapServer() = this.isEmpty() || this.startsWith("e.") || this.startsWith("agent.externe.") @@ -71,7 +68,6 @@ object TchapPatterns { * Get name part of a display name by removing the domain part if any. * For example in case of "Jean Martin `[Modernisation]`", this will return "Jean Martin". * - * @param displayName the display name to compute. * @return displayName without domain (or the display name itself if no domain has been found). */ fun String.getUserName() = this.substringBefore('[').trim() @@ -80,7 +76,6 @@ object TchapPatterns { * Get the potential domain name from a display name. * For example in case of "Jean Martin `[Modernisation]`", this will return "Modernisation". * - * @param displayName the display name to compute. * @return displayName without name, empty string if no domain is available. */ fun String.getUserDomain() = this.substringBeforeLast(']', "").substringAfterLast('[', "").trim() @@ -115,7 +110,7 @@ object TchapPatterns { for (i in 0 until lastHyphenIndex) { val char = identifier[i] when { - (capitalizeNext && (char == '.' || char == '-')) -> continue + capitalizeNext && (char == '.' || char == '-') -> continue char == '.' -> { // Replace the dot character by space character append(' ') @@ -140,7 +135,6 @@ object TchapPatterns { * Tells whether the provided tchap identifier corresponds to an extern user. * Note: invalid tchap identifier will be considered as external. * - * @param tchapUserId user identifier (ie. the matrix identifier). * @return true if external. */ fun String.isExternalTchapUser() = this.toHomeserverName().isExternalTchapServer() @@ -156,7 +150,7 @@ object TchapPatterns { /** * Create a room alias with a prefix. * - * @param session the user's session. + * @param sessionId the user's id session. * @param prefix the alias name prefix. * @return the suggested alias. */ diff --git a/libraries/tchaputils/src/test/java/fr/gouv/tchap/libraries/tchaputils/TchapPatternsTest.kt b/libraries/tchaputils/src/test/java/fr/gouv/tchap/libraries/tchaputils/TchapPatternsTest.kt index cd0d6aba2b..68c835cdb7 100644 --- a/libraries/tchaputils/src/test/java/fr/gouv/tchap/libraries/tchaputils/TchapPatternsTest.kt +++ b/libraries/tchaputils/src/test/java/fr/gouv/tchap/libraries/tchaputils/TchapPatternsTest.kt @@ -26,20 +26,19 @@ package fr.gouv.tchap.libraries.tchaputils import fr.gouv.tchap.libraries.tchaputils.TchapPatterns.getUserDomain import fr.gouv.tchap.libraries.tchaputils.TchapPatterns.getUserName -import fr.gouv.tchap.libraries.tchaputils.TchapPatterns.toUserDisplayName import fr.gouv.tchap.libraries.tchaputils.TchapPatterns.toHomeserverDisplayName +import fr.gouv.tchap.libraries.tchaputils.TchapPatterns.toUserDisplayName import org.junit.Assert.assertEquals import org.junit.Test class TchapPatternsTest { - /** * Test getting full name without domain. */ @Test fun `given a displayName if it contains brackets then return its first element after split`() { - assertEquals( "Nom Prenom", "Nom Prenom [Modernisation]".getUserName()) + assertEquals("Nom Prenom", "Nom Prenom [Modernisation]".getUserName()) } @Test diff --git a/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/model/MarkdownTextEditorState.kt b/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/model/MarkdownTextEditorState.kt index 57a49cb3ba..4507f888d9 100644 --- a/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/model/MarkdownTextEditorState.kt +++ b/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/model/MarkdownTextEditorState.kt @@ -73,7 +73,8 @@ class MarkdownTextEditorState( } is ResolvedSuggestion.Member -> { val currentText = SpannableStringBuilder(text.value()) - val text = resolvedSuggestion.roomMember.displayName?.prependIndent("@") ?: resolvedSuggestion.roomMember.userId.value // TCHAP TODO check needed about mxid displaying + val text = resolvedSuggestion.roomMember.displayName?.prependIndent("@") + ?: resolvedSuggestion.roomMember.userId.value // TCHAP TODO check needed about mxid displaying val link = permalinkBuilder.permalinkForUser(resolvedSuggestion.roomMember.userId).getOrNull() ?: return val mentionPill = mentionSpanProvider.getMentionSpanFor(text, link) currentText.replace(suggestion.start, suggestion.end, "@ ") diff --git a/tests/konsist/src/test/kotlin/fr/gouv/tchap/android/tests/konsist/KonsistLicenseTest.kt b/tests/konsist/src/test/kotlin/fr/gouv/tchap/android/tests/konsist/KonsistLicenseTest.kt new file mode 100644 index 0000000000..03363aed18 --- /dev/null +++ b/tests/konsist/src/test/kotlin/fr/gouv/tchap/android/tests/konsist/KonsistLicenseTest.kt @@ -0,0 +1,70 @@ +/* + * MIT License + * + * Copyright (c) 2024. DINUM + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package fr.gouv.tchap.android.tests.konsist + +import com.lemonappdev.konsist.api.Konsist +import com.lemonappdev.konsist.api.verify.assertTrue +import org.junit.Test + +class KonsistLicenseTest { + private val tchapLicense = """ + /\* + \* MIT License + \* + \* Copyright \(c\) 20\d\d\. DINUM + \* + \* Permission is hereby granted, free of charge, to any person obtaining a copy + \* of this software and associated documentation files \(the "Software"\), to deal + \* in the Software without restriction, including without limitation the rights + \* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + \* copies of the Software, and to permit persons to whom the Software is + \* furnished to do so, subject to the following conditions: + \* + \* The above copyright notice and this permission notice shall be included in all + \* copies or substantial portions of the Software\. + \* + \* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + \* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + \* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\. + \* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + \* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + \* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + \* OR OTHER DEALINGS IN THE SOFTWARE\. + \*/ + """.trimIndent().toRegex() + + @Test + fun `assert that Tchap files have the correct license header`() { + Konsist + .scopeFromProject() + .files + .filter { + it.path.contains("/fr/gouv/tchap/") + } + .assertTrue { + tchapLicense.containsMatchIn(it.text) + } + } +} diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistLicenseTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistLicenseTest.kt index 5f8a47d275..9b4ef100d9 100644 --- a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistLicenseTest.kt +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistLicenseTest.kt @@ -21,32 +21,6 @@ import com.lemonappdev.konsist.api.verify.assertTrue import org.junit.Test class KonsistLicenseTest { - private val tchapLicense = """ - /\* - \* MIT License - \* - \* Copyright \(c\) 20\d\d\. DINUM - \* - \* Permission is hereby granted, free of charge, to any person obtaining a copy - \* of this software and associated documentation files \(the "Software"\), to deal - \* in the Software without restriction, including without limitation the rights - \* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - \* copies of the Software, and to permit persons to whom the Software is - \* furnished to do so, subject to the following conditions: - \* - \* The above copyright notice and this permission notice shall be included in all - \* copies or substantial portions of the Software\. - \* - \* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - \* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - \* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\. - \* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - \* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - \* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE - \* OR OTHER DEALINGS IN THE SOFTWARE\. - \*/ - """.trimIndent().toRegex() - private val publicLicense = """ /\* (?:.*\n)* \* Copyright \(c\) 20\d\d New Vector Ltd @@ -81,19 +55,6 @@ class KonsistLicenseTest { \*/ """.trimIndent().toRegex() - @Test - fun `assert that Tchap files have the correct license header`() { - Konsist - .scopeFromProject() - .files - .filter { - it.path.contains("/fr/gouv/tchap/") - } - .assertTrue { - tchapLicense.containsMatchIn(it.text) - } - } - @Test fun `assert that FOSS files have the correct license header`() { Konsist