quality : format and clean

This commit is contained in:
ganfra
2026-01-07 21:09:20 +01:00
parent 9cbc8cfa67
commit 4eb1926d53
14 changed files with 24 additions and 30 deletions

View File

@@ -21,7 +21,6 @@ import com.bumble.appyx.core.node.Node
import com.bumble.appyx.core.plugin.Plugin
import com.bumble.appyx.navmodel.backstack.BackStack
import com.bumble.appyx.navmodel.backstack.activeElement
import com.bumble.appyx.navmodel.backstack.operation.pop
import dev.zacsweers.metro.Assisted
import dev.zacsweers.metro.AssistedInject
import io.element.android.annotations.ContributesNode
@@ -35,7 +34,6 @@ import io.element.android.libraries.architecture.BaseFlowNode
import io.element.android.libraries.architecture.callback
import io.element.android.libraries.architecture.createNode
import io.element.android.libraries.di.RoomScope
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.room.JoinedRoom
import io.element.android.libraries.matrix.api.room.powerlevels.use
import kotlinx.coroutines.NonCancellable
@@ -92,9 +90,11 @@ class SecurityAndPrivacyFlowNode(
callback.onDone()
}
}
whenChildrenAttached { commonLifecycle: Lifecycle,
whenChildrenAttached {
commonLifecycle: Lifecycle,
securityAndPrivacyNode: SecurityAndPrivacyNode,
manageAuthorizedSpacesNode: ManageAuthorizedSpacesNode ->
manageAuthorizedSpacesNode: ManageAuthorizedSpacesNode
->
commonLifecycle.coroutineScope.launch {
val authorizedSpacesData = securityAndPrivacyNode.getAuthorizedSpacesData()
val selectedSpaces = manageAuthorizedSpacesNode.waitForCompletion(authorizedSpacesData)

View File

@@ -18,7 +18,7 @@ interface SecurityAndPrivacyNavigator : Plugin {
fun onDone()
fun openEditRoomAddress()
fun closeEditRoomAddress()
fun openManageAuthorizedSpaces(forKnockRestricted: Boolean = false)
fun openManageAuthorizedSpaces(forKnockRestricted: Boolean)
fun closeManageAuthorizedSpaces()
}

View File

@@ -33,7 +33,6 @@ class ManageAuthorizedSpacesNode(
@Assisted plugins: List<Plugin>,
presenter: ManageAuthorizedSpacesPresenter,
) : Node(buildContext, plugins = plugins) {
private val navigator = plugins<SecurityAndPrivacyNavigator>().first()
private val stateFlow = launchMolecule { presenter.present() }

View File

@@ -18,11 +18,10 @@ import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.matrix.api.core.RoomId
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.collections.immutable.toImmutableList
@Inject
class ManageAuthorizedSpacesPresenter() : Presenter<ManageAuthorizedSpacesState> {
class ManageAuthorizedSpacesPresenter : Presenter<ManageAuthorizedSpacesState> {
@Composable
override fun present(): ManageAuthorizedSpacesState {
var selectedIds: ImmutableList<RoomId> by remember { mutableStateOf(persistentListOf()) }
@@ -31,12 +30,12 @@ class ManageAuthorizedSpacesPresenter() : Presenter<ManageAuthorizedSpacesState>
fun handleEvent(event: ManageAuthorizedSpacesEvent) {
when (event) {
ManageAuthorizedSpacesEvent.Done ->isSelectionComplete = true
ManageAuthorizedSpacesEvent.Done -> isSelectionComplete = true
is ManageAuthorizedSpacesEvent.ToggleSpace -> {
selectedIds = if (selectedIds.contains(event.roomId)) {
selectedIds.minus(event.roomId).toPersistentList()
selectedIds.minus(event.roomId).toImmutableList()
} else {
selectedIds.plus(event.roomId).toPersistentList()
selectedIds.plus(event.roomId).toImmutableList()
}
}
is ManageAuthorizedSpacesEvent.SetData -> {

View File

@@ -69,4 +69,3 @@ private fun aManageAuthorizedSpacesState(
isSelectionComplete = false,
eventSink = eventSink,
)

View File

@@ -15,8 +15,10 @@ sealed interface SecurityAndPrivacyEvent {
data object Exit : SecurityAndPrivacyEvent
data object DismissExitConfirmation : SecurityAndPrivacyEvent
data class ChangeRoomAccess(val roomAccess: SecurityAndPrivacyRoomAccess) : SecurityAndPrivacyEvent
// Special case for "Space Members"
data object SelectSpaceMemberAccess : SecurityAndPrivacyEvent
// Special case for "Ask to join with Space Members"
data object SelectAskToJoinWithSpaceMembersAccess : SecurityAndPrivacyEvent
data object ToggleEncryptionState : SecurityAndPrivacyEvent

View File

@@ -46,7 +46,7 @@ class SecurityAndPrivacyNode(
activity.openUrlInChromeCustomTab(null, darkTheme, url)
}
fun getAuthorizedSpacesData(): AuthorizedSpacesSelection{
fun getAuthorizedSpacesData(): AuthorizedSpacesSelection {
return stateFlow.value.getAuthorizedSpacesSelection()
}
@@ -72,5 +72,4 @@ class SecurityAndPrivacyNode(
modifier = modifier
)
}
}

View File

@@ -35,7 +35,6 @@ import io.element.android.libraries.featureflag.api.FeatureFlagService
import io.element.android.libraries.featureflag.api.FeatureFlags
import io.element.android.libraries.matrix.api.MatrixClient
import io.element.android.libraries.matrix.api.core.RoomAlias
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.room.JoinedRoom
import io.element.android.libraries.matrix.api.room.RoomInfo
import io.element.android.libraries.matrix.api.room.history.RoomHistoryVisibility
@@ -193,11 +192,12 @@ class SecurityAndPrivacyPresenter(
saveAction.value = AsyncAction.Uninitialized
}
SecurityAndPrivacyEvent.ManageAuthorizedSpaces -> {
navigator.openManageAuthorizedSpaces()
navigator.openManageAuthorizedSpaces(
forKnockRestricted = editedRoomAccess.value is SecurityAndPrivacyRoomAccess.AskToJoinWithSpaceMember
)
}
SecurityAndPrivacyEvent.SelectSpaceMemberAccess -> handleSpaceMemberAccessSelection(
spaceSelectionMode = spaceSelectionMode,
spaceIds = editedSettings.roomAccess.spaceIds(),
editedAccess = editedRoomAccess,
)
SecurityAndPrivacyEvent.SelectAskToJoinWithSpaceMembersAccess -> handleAskToJoinWithSpaceMembersAccessSelection(
@@ -250,7 +250,6 @@ class SecurityAndPrivacyPresenter(
private fun handleSpaceMemberAccessSelection(
spaceSelectionMode: SpaceSelectionMode,
spaceIds: List<RoomId>,
editedAccess: MutableState<SecurityAndPrivacyRoomAccess>,
) {
if (editedAccess.value is SecurityAndPrivacyRoomAccess.SpaceMember) {

View File

@@ -38,7 +38,6 @@ data class SecurityAndPrivacyState(
private val spaceSelectionMode: SpaceSelectionMode,
val eventSink: (SecurityAndPrivacyEvent) -> Unit
) {
val isSpaceMemberSelectable = isSpaceSettingsEnabled && spaceSelectionMode != SpaceSelectionMode.None
// Show SpaceMember option in two cases:
@@ -58,7 +57,7 @@ data class SecurityAndPrivacyState(
// - AskToJoin is the current saved value (legacy), OR
// - Knock FF enabled BUT (SpaceSettings FF disabled OR no spaces available)
val showAskToJoinOption = savedSettings.roomAccess == SecurityAndPrivacyRoomAccess.AskToJoin ||
(isAskToJoinSelectable && !isAskToJoinWithSpaceMembersSelectable)
isAskToJoinSelectable && !isAskToJoinWithSpaceMembersSelectable
// Show AskToJoinWithSpaceMember option when:
// - It's the current saved value, OR
@@ -98,7 +97,9 @@ data class SecurityAndPrivacyState(
stringResource(R.string.screen_security_and_privacy_room_access_space_members_option_single_parent_description, spaceName)
}
is SpaceSelectionMode.None,
is SpaceSelectionMode.Multiple -> stringResource(R.string.screen_security_and_privacy_room_access_space_members_option_multiple_parents_description)
is SpaceSelectionMode.Multiple -> stringResource(
R.string.screen_security_and_privacy_room_access_space_members_option_multiple_parents_description
)
}
} else {
stringResource(R.string.screen_security_and_privacy_room_access_space_members_option_unavailable_description)

View File

@@ -208,9 +208,7 @@ private fun RoomAccessSection(
state: SecurityAndPrivacyState,
modifier: Modifier = Modifier,
) {
val edited = state.editedSettings.roomAccess
val saved = state.savedSettings.roomAccess
fun onSelectOption(option: SecurityAndPrivacyRoomAccess) {
state.eventSink(SecurityAndPrivacyEvent.ChangeRoomAccess(option))
@@ -282,7 +280,7 @@ private fun RoomAccessSection(
val footerText = stringWithLink(
textRes = R.string.screen_security_and_privacy_room_access_footer,
url = stringResource(R.string.screen_security_and_privacy_room_access_footer_manage_spaces_action),
onLinkClick = {onManageSpacesClick()},
onLinkClick = { onManageSpacesClick() },
)
Text(
text = footerText,

View File

@@ -11,7 +11,6 @@ package io.element.android.features.securityandprivacy.impl
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.bumble.appyx.core.modality.AncestryInfo
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.navmodel.backstack.BackStack
import com.bumble.appyx.navmodel.backstack.activeElement
import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl
import com.google.common.truth.Truth.assertThat
@@ -27,7 +26,6 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class SecurityAndPrivacyFlowNodeTest {
@Test
fun `initial backstack contains SecurityAndPrivacy`() = runTest {
val flowNode = createFlowNode()

View File

@@ -44,6 +44,7 @@ import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.test.runTest
import org.junit.Test
@Suppress("LargeClass")
class SecurityAndPrivacyPresenterTest {
@Test
fun `present - initial states`() = runTest {

View File

@@ -22,15 +22,15 @@ import io.element.android.features.securityandprivacy.impl.root.SecurityAndPriva
import io.element.android.features.securityandprivacy.impl.root.SpaceSelectionMode
import io.element.android.features.securityandprivacy.impl.root.aSecurityAndPrivacySettings
import io.element.android.features.securityandprivacy.impl.root.aSecurityAndPrivacyState
import io.element.android.libraries.matrix.test.A_ROOM_ID
import kotlinx.collections.immutable.persistentListOf
import io.element.android.libraries.architecture.AsyncAction
import io.element.android.libraries.architecture.AsyncData
import io.element.android.libraries.matrix.test.A_ROOM_ID
import io.element.android.libraries.ui.strings.CommonStrings
import io.element.android.tests.testutils.EnsureNeverCalledWithParam
import io.element.android.tests.testutils.EventsRecorder
import io.element.android.tests.testutils.clickOn
import io.element.android.tests.testutils.pressBack
import kotlinx.collections.immutable.persistentListOf
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestRule

View File

@@ -9,7 +9,6 @@
package io.element.android.features.securityandprivacy.impl.manageauthorizedspaces
import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.test.A_ROOM_ID
import io.element.android.tests.testutils.test
import kotlinx.collections.immutable.persistentListOf