diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendContent.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendContent.kt index b38b4d6e9..f4e3af496 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendContent.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendContent.kt @@ -60,6 +60,7 @@ import com.x8bit.bitwarden.ui.tools.feature.send.addsend.handlers.AddSendHandler fun AddSendContent( state: AddSendState.ViewState.Content, policyDisablesSend: Boolean, + policySendOptionsInEffect: Boolean, isAddMode: Boolean, isShared: Boolean, addSendHandlers: AddSendHandlers, @@ -85,6 +86,17 @@ fun AddSendContent( Spacer(modifier = Modifier.height(16.dp)) } + if (policySendOptionsInEffect) { + BitwardenPolicyWarningText( + text = stringResource(id = R.string.send_options_policy_in_effect), + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth(), + ) + + Spacer(modifier = Modifier.height(16.dp)) + } + BitwardenTextField( modifier = Modifier .semantics { testTag = "SendNameEntry" } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreen.kt index b108a7174..40afa48c7 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreen.kt @@ -198,6 +198,7 @@ fun AddSendScreen( is AddSendState.ViewState.Content -> AddSendContent( state = viewState, policyDisablesSend = state.policyDisablesSend, + policySendOptionsInEffect = state.shouldDisplayPolicyWarning, isAddMode = state.isAddMode, isShared = state.isShared, addSendHandlers = addSendHandlers, diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendViewModel.kt index 30685c60e..adf1da50c 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendViewModel.kt @@ -713,6 +713,13 @@ data class AddSendState( is AddSendType.EditItem -> R.string.edit_send.asText() } + /** + * Helper to determine if the policy notice should be displayed. + */ + val shouldDisplayPolicyWarning: Boolean + get() = !policyDisablesSend && + (viewState as? ViewState.Content)?.common?.isHideEmailAddressEnabled != true + /** * Helper to determine if the UI should display the content in add send mode. */ diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreenTest.kt index 449d50caf..8131d740a 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreenTest.kt @@ -987,6 +987,37 @@ class AddSendScreenTest : BaseComposeTest() { .assert(hasAnyAncestor(isDialog())) } + @Test + fun `policy send options text should be displayed based on state`() { + val text = "One or more organization policies are affecting your Send options." + + mutableStateFlow.update { + it.copy( + viewState = DEFAULT_VIEW_STATE, + policyDisablesSend = true, + ) + } + + composeTestRule + .onNodeWithText(text) + .assertIsNotDisplayed() + + mutableStateFlow.update { + it.copy( + viewState = DEFAULT_VIEW_STATE.copy( + common = DEFAULT_COMMON_STATE.copy( + isHideEmailAddressEnabled = false, + ), + ), + policyDisablesSend = false, + ) + } + + composeTestRule + .onNodeWithText(text) + .assertIsDisplayed() + } + companion object { private val DEFAULT_COMMON_STATE = AddSendState.ViewState.Content.Common( name = "",