Skip to content

Commit

Permalink
Add FAQ url
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Dec 11, 2024
1 parent 0e20a44 commit 24c5e53
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ object LearnMoreConfig {
const val ENCRYPTION_URL: String = "https://element.io/help#encryption"
const val SECURE_BACKUP_URL: String = "https://element.io/help#encryption5"
const val IDENTITY_CHANGE_URL: String = "https://element.io/help#encryption18"
const val FAQ_URL: String = "https://aide.tchap.beta.gouv.fr"
}
1 change: 1 addition & 0 deletions features/createroom/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ android {
setupAnvil(componentMergingStrategy = ComponentMergingStrategy.KSP)

dependencies {
implementation(projects.appconfig)
implementation(projects.libraries.core)
implementation(projects.libraries.architecture)
implementation(projects.libraries.matrix.api)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import fr.gouv.tchap.libraries.tchaputils.TchapPatterns.isExternalTchapUser
import io.element.android.appconfig.LearnMoreConfig
import io.element.android.compound.theme.ElementTheme
import io.element.android.features.createroom.impl.R
import io.element.android.libraries.architecture.coverage.ExcludeFromCoverage
Expand Down Expand Up @@ -131,7 +132,14 @@ fun ConfigureRoomView(
},
)
}
if (state.config.invites.any { it.userId.toString().isExternalTchapUser() }) RoomExternalGuestsWarning() // TCHAP external user
// TCHAP external user
val hasExternalUsers = state.config.invites.any { it.userId.toString().isExternalTchapUser() }
if (hasExternalUsers) {
RoomExternalGuestsWarning()
if (state.config.roomVisibility is RoomVisibilityState.Public) {
state.eventSink(ConfigureRoomEvents.RoomVisibilityChanged(RoomVisibilityItem.Private))
}
}
RoomVisibilityOptions(
selected = when (state.config.roomVisibility) {
is RoomVisibilityState.Private -> RoomVisibilityItem.Private
Expand All @@ -142,6 +150,7 @@ fun ConfigureRoomView(
focusManager.clearFocus()
state.eventSink(ConfigureRoomEvents.RoomVisibilityChanged(it))
},
hasExternalUsers = hasExternalUsers,
)
if (state.config.roomVisibility is RoomVisibilityState.Public && state.isKnockFeatureEnabled) {
RoomAccessOptions(
Expand Down Expand Up @@ -286,20 +295,20 @@ private fun ConfigureRoomOptions(
private fun RoomExternalGuestsWarning() {
val externalGuestText = buildAnnotatedString {
val learnMoreStr = stringResource(CommonStrings.action_learn_more)
val extGuetsStr = stringResource(R.string.tchap_screen_create_room_external_guests_content)
val externalUsersStr = stringResource(R.string.tchap_screen_create_room_external_guests_content)
val fullText = stringResource(
id = R.string.tchap_screen_create_room_external_guests_warning_title,
extGuetsStr,
externalUsersStr,
learnMoreStr,
)
append(fullText)
val extGuetsStartIndex = fullText.indexOf(extGuetsStr)
val externalUsersStartIndex = fullText.indexOf(externalUsersStr)
addStyle(
style = SpanStyle(
fontWeight = FontWeight.Bold,
),
start = extGuetsStartIndex,
end = extGuetsStartIndex + extGuetsStr.length,
start = externalUsersStartIndex,
end = externalUsersStartIndex + externalUsersStr.length,
)
val learnMoreStartIndex = fullText.lastIndexOf(learnMoreStr)
addStyle(
Expand All @@ -311,7 +320,7 @@ private fun RoomExternalGuestsWarning() {
)
addStringAnnotation(
tag = LINK_TAG,
annotation = "https://aide.tchap.beta.gouv.fr",
annotation = "${LearnMoreConfig.FAQ_URL}/fr/article/comment-inviter-un-partenaire-externe-sur-tchap-android-j29jmh/",
start = learnMoreStartIndex,
end = learnMoreStartIndex + learnMoreStr.length
)
Expand All @@ -337,6 +346,7 @@ private fun RoomExternalGuestsWarning() {

@Composable
private fun RoomVisibilityOptions(
hasExternalUsers: Boolean,
selected: RoomVisibilityItem,
onOptionClick: (RoomVisibilityItem) -> Unit,
modifier: Modifier = Modifier,
Expand All @@ -359,6 +369,7 @@ private fun RoomVisibilityOptions(
supportingContent = { Text(text = stringResource(item.description)) },
trailingContent = ListItemContent.RadioButton(selected = isSelected),
onClick = { onOptionClick(item) },
enabled = !(hasExternalUsers && item == RoomVisibilityItem.Public)
)
}
}
Expand Down

0 comments on commit 24c5e53

Please sign in to comment.