Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [RC] feature flag passowrd guest link (WPB-1531) #2282

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1240,4 +1240,9 @@ class UseCaseModule {
@Provides
fun providesJoinConversationViaCodeUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).conversations.joinConversationViaCode

@ViewModelScoped
@Provides
fun providesCanCreatePasswordProtectedLinksUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).conversations.canCreatePasswordProtectedLinks
}
28 changes: 23 additions & 5 deletions app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class WireActivity : AppCompatActivity() {
Column {
val navigator = rememberNavigator(this@WireActivity::finish)
val scope = rememberCoroutineScope()

CommonTopAppBar(
connectivityUIState = commonTopAppBarViewModel.connectivityState,
onReturnToCallClick = { establishedCall ->
Expand Down Expand Up @@ -230,7 +231,11 @@ class WireActivity : AppCompatActivity() {
@Composable
private fun handleDialogs(navigate: (NavigationCommand) -> Unit) {
updateAppDialog({ updateTheApp() }, viewModel.globalAppState.updateAppDialog)
joinConversationDialog(viewModel.globalAppState.conversationJoinedDialog, navigate)
joinConversationDialog(
viewModel.globalAppState.conversationJoinedDialog,
navigate,
viewModel::onJoinConversationFlowCompleted
)
customBackendDialog(navigate)
maxAccountDialog(
onConfirm = {
Expand Down Expand Up @@ -276,15 +281,24 @@ class WireActivity : AppCompatActivity() {
}

@Composable
private fun joinConversationDialog(joinedDialogState: JoinConversationViaCodeState?, navigate: (NavigationCommand) -> Unit) {
private fun joinConversationDialog(
joinedDialogState: JoinConversationViaCodeState?,
navigate: (NavigationCommand) -> Unit,
onJoinConversationFlowCompleted: () -> Unit
) {
joinedDialogState?.let {

val onComplete: (convId: ConversationId?) -> Unit = remember {
{
onJoinConversationFlowCompleted()
it?.also {
appLogger.d("Join conversation via code dialog completed, navigating to conversation screen")
navigate(NavigationCommand(ConversationScreenDestination(it), BackStackMode.CLEAR_TILL_START))
viewModel.onJoinConversationFlowCompleted()
navigate(
NavigationCommand(
ConversationScreenDestination(it),
BackStackMode.CLEAR_TILL_START
)
)
}
}
}
Expand Down Expand Up @@ -407,7 +421,11 @@ class WireActivity : AppCompatActivity() {
}.joinToString("")
when (data) {
is NewClientsData.OtherUser -> {
title = stringResource(R.string.new_device_dialog_other_user_title, data.userName ?: "", data.userHandle ?: "")
title = stringResource(
R.string.new_device_dialog_other_user_title,
data.userName ?: "",
data.userHandle ?: ""
)
text = stringResource(R.string.new_device_dialog_other_user_message, devicesList)
btnText = stringResource(R.string.new_device_dialog_other_user_btn)
btnAction = { switchAccountAndOpenDeviceManager(data.userId) }
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/kotlin/com/wire/android/ui/home/HomeDialogs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ fun FileRestrictionDialog(
isFileSharingEnabled: Boolean,
hideDialogStatus: () -> Unit,
) {
val text: String = stringResource(id = if (isFileSharingEnabled) R.string.sharing_files_enabled else R.string.sharing_files_disabled)
val text: String =
stringResource(id = if (isFileSharingEnabled) R.string.sharing_files_enabled else R.string.sharing_files_disabled)

WireDialog(
title = stringResource(id = R.string.team_settings_changed),
Expand All @@ -67,7 +68,10 @@ fun SelfDeletingMessagesDialog(
}

areSelfDeletingMessagesEnabled -> {
stringResource(R.string.self_deleting_messages_team_setting_enabled_enforced_timeout, formattedTimeout)
stringResource(
R.string.self_deleting_messages_team_setting_enabled_enforced_timeout,
formattedTimeout
)
}

else -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ fun CreateGuestLinkBottomSheet(
MenuModalSheetContent(
header = MenuModalSheetHeader.Visible(title = stringResource(R.string.create_guest_link)),
menuItems = buildList {
add {
CreateInviteLinkSheetItem(
title = stringResource(R.string.create_guest_link_with_password),
onClicked = { onItemClick(true) },
enabled = isPasswordInviteLinksAllowed
)
if (isPasswordInviteLinksAllowed) {
add {
CreateInviteLinkSheetItem(
title = stringResource(R.string.create_guest_link_with_password),
onClicked = { onItemClick(true) },
enabled = isPasswordInviteLinksAllowed
)
}
}
add {
CreateInviteLinkSheetItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ fun EditGuestAccessScreen(
CreateGuestLinkBottomSheet(
sheetState = sheetState,
onSheetItemClick,
isPasswordInviteLinksAllowed = true,
isPasswordInviteLinksAllowed = editGuestAccessViewModel
.editGuestAccessState
.isPasswordProtectedLinksAllowed
)

Scaffold(topBar = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ data class EditGuestAccessState(
val isFailedToRevokeGuestRoomLink: Boolean = false,
val link: String? = null,
val isLinkPasswordProtected: Boolean = false,
val shouldShowPasswordDialog: Boolean = false
val shouldShowPasswordDialog: Boolean = false,
val isPasswordProtectedLinksAllowed: Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ import androidx.compose.runtime.setValue
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wire.android.BuildConfig
import com.wire.android.ui.home.conversations.details.participants.usecase.ObserveParticipantsForConversationUseCase
import com.wire.android.ui.navArgs
import com.wire.android.util.dispatchers.DispatcherProvider
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.feature.conversation.ObserveConversationDetailsUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationAccessRoleUseCase
import com.wire.kalium.logic.feature.conversation.guestroomlink.CanCreatePasswordProtectedLinksUseCase
import com.wire.kalium.logic.feature.conversation.guestroomlink.GenerateGuestRoomLinkResult
import com.wire.kalium.logic.feature.conversation.guestroomlink.GenerateGuestRoomLinkUseCase
import com.wire.kalium.logic.feature.conversation.guestroomlink.ObserveGuestRoomLinkUseCase
Expand Down Expand Up @@ -63,6 +65,7 @@ class EditGuestAccessViewModel @Inject constructor(
private val revokeGuestRoomLink: RevokeGuestRoomLinkUseCase,
private val observeGuestRoomLink: ObserveGuestRoomLinkUseCase,
private val observeGuestRoomLinkFeatureFlag: ObserveGuestRoomLinkFeatureFlagUseCase,
private val canCreatePasswordProtectedLinks: CanCreatePasswordProtectedLinksUseCase,
savedStateHandle: SavedStateHandle
) : ViewModel() {

Expand All @@ -82,6 +85,19 @@ class EditGuestAccessViewModel @Inject constructor(
observeConversationDetails()
startObservingGuestRoomLink()
observeGuestRoomLinkFeature()
checkIfUserCanCreatePasswordProtectedLinks()
}

private fun checkIfUserCanCreatePasswordProtectedLinks() {
viewModelScope.launch {
val canCreatePasswordProtectedLinks = when {
!BuildConfig.IS_PASSWORD_PROTECTED_GUEST_LINK_ENABLED -> false
else -> canCreatePasswordProtectedLinks()
}
editGuestAccessState = editGuestAccessState.copy(
isPasswordProtectedLinksAllowed = canCreatePasswordProtectedLinks
)
}
}

private fun observeGuestRoomLinkFeature() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ fun PasswordProtectedLinkBanner() {
modifier = Modifier
.width(16.dp)
.height(16.dp),
contentDescription = null
contentDescription = null,
tint = colorsScheme().labelText
)
}
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.wire.android.R
import com.wire.android.ui.common.button.IconAlignment
import com.wire.android.ui.common.button.WireButtonState
import com.wire.android.ui.common.button.WireSecondaryButton
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.theme.wireTypography

Expand All @@ -50,7 +51,8 @@ fun GeneratePasswordButton(
Icon(
modifier = Modifier.padding(end = dimensions().corner4x),
painter = painterResource(id = R.drawable.ic_shield_holo),
contentDescription = null
contentDescription = null,
tint = colorsScheme().labelText
)
},
leadingIconAlignment = IconAlignment.Center,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.wire.android.ui.common.button.WireButtonState
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.textfield.WirePasswordTextField
import com.wire.android.ui.common.textfield.WireTextFieldState
import com.wire.android.ui.common.wireDialogPropertiesBuilder
import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.capitalizeFirstLetter
Expand Down Expand Up @@ -153,7 +154,11 @@ fun JoinConversationViaDeepLinkDialog(
focusRequester.requestFocus()
}
}
}
},
properties = wireDialogPropertiesBuilder(
dismissOnBackPress = false,
dismissOnClickOutside = false
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.wire.kalium.logic.CoreFailure
import com.wire.kalium.logic.NetworkFailure
import com.wire.kalium.logic.feature.conversation.ObserveConversationDetailsUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationAccessRoleUseCase
import com.wire.kalium.logic.feature.conversation.guestroomlink.CanCreatePasswordProtectedLinksUseCase
import com.wire.kalium.logic.feature.conversation.guestroomlink.GenerateGuestRoomLinkResult
import com.wire.kalium.logic.feature.conversation.guestroomlink.GenerateGuestRoomLinkUseCase
import com.wire.kalium.logic.feature.conversation.guestroomlink.ObserveGuestRoomLinkUseCase
Expand Down Expand Up @@ -81,6 +82,9 @@ class EditGuestAccessViewModelTest {
@MockK
lateinit var observeGuestRoomLinkFeatureFlag: ObserveGuestRoomLinkFeatureFlagUseCase

@MockK
lateinit var canCreatePasswordProtectedLinks: CanCreatePasswordProtectedLinksUseCase

private lateinit var editGuestAccessViewModel: EditGuestAccessViewModel

@Before
Expand All @@ -94,7 +98,8 @@ class EditGuestAccessViewModelTest {
revokeGuestRoomLink = revokeGuestRoomLink,
observeGuestRoomLink = observeGuestRoomLink,
savedStateHandle = savedStateHandle,
observeGuestRoomLinkFeatureFlag = observeGuestRoomLinkFeatureFlag
observeGuestRoomLinkFeatureFlag = observeGuestRoomLinkFeatureFlag,
canCreatePasswordProtectedLinks = canCreatePasswordProtectedLinks
)
every { savedStateHandle.navArgs<EditGuestAccessNavArgs>() } returns EditGuestAccessNavArgs(
conversationId = TestConversation.ID,
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/customization/FeatureConfigs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ enum class FeatureConfigs(val value: String, val configType: ConfigType) {
DEFAULT_BACKEND_URL_WEBSITE("default_backend_url_website", ConfigType.STRING),
DEFAULT_BACKEND_TITLE("default_backend_title", ConfigType.STRING),
// TODO: Add support for default proxy configs

IS_PASSWORD_PROTECTED_GUEST_LINK_ENABLED("is_password_protected_guest_link_enabled", ConfigType.BOOLEAN)
}
6 changes: 4 additions & 2 deletions default.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"default_backend_url_teams": "https://wire-teams-staging.zinfra.io",
"default_backend_url_blacklist": "https://clientblacklist.wire.com/staging",
"default_backend_url_website": "https://wire.com",
"default_backend_title": "wire-staging"
"default_backend_title": "wire-staging",
"is_password_protected_guest_link_enabled": true
},
"staging": {
"application_id": "com.waz.zclient.dev",
Expand Down Expand Up @@ -100,5 +101,6 @@
"default_backend_url_teams": "https://teams.wire.com",
"default_backend_url_blacklist": "https://clientblacklist.wire.com/prod",
"default_backend_url_website": "https://wire.com",
"default_backend_title": "wire-production"
"default_backend_title": "wire-production",
"is_password_protected_guest_link_enabled": false
}