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

Add invite by email screen in create space flow #3976

Merged
merged 3 commits into from
Sep 14, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3678.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Spaces | M3.23 Invite by email in create private space flow
1 change: 1 addition & 0 deletions changelog.d/3945.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the "Teammate spaces aren't quite ready" bottom sheet
6 changes: 6 additions & 0 deletions vector/src/main/java/im/vector/app/core/di/FragmentModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ import im.vector.app.features.signout.soft.SoftLogoutFragment
import im.vector.app.features.spaces.SpaceListFragment
import im.vector.app.features.spaces.create.ChoosePrivateSpaceTypeFragment
import im.vector.app.features.spaces.create.ChooseSpaceTypeFragment
import im.vector.app.features.spaces.create.CreateSpaceAdd3pidInvitesFragment
import im.vector.app.features.spaces.create.CreateSpaceDefaultRoomsFragment
import im.vector.app.features.spaces.create.CreateSpaceDetailsFragment
import im.vector.app.features.spaces.explore.SpaceDirectoryFragment
Expand Down Expand Up @@ -793,6 +794,11 @@ interface FragmentModule {
@FragmentKey(ChoosePrivateSpaceTypeFragment::class)
fun bindChoosePrivateSpaceTypeFragment(fragment: ChoosePrivateSpaceTypeFragment): Fragment

@Binds
@IntoMap
@FragmentKey(CreateSpaceAdd3pidInvitesFragment::class)
fun bindCreateSpaceAdd3pidInvitesFragment(fragment: CreateSpaceAdd3pidInvitesFragment): Fragment

@Binds
@IntoMap
@FragmentKey(SpaceAddRoomFragment::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import im.vector.app.core.platform.SimpleFragmentActivity
import im.vector.app.features.spaces.create.ChoosePrivateSpaceTypeFragment
import im.vector.app.features.spaces.create.ChooseSpaceTypeFragment
import im.vector.app.features.spaces.create.CreateSpaceAction
import im.vector.app.features.spaces.create.CreateSpaceAdd3pidInvitesFragment
import im.vector.app.features.spaces.create.CreateSpaceDefaultRoomsFragment
import im.vector.app.features.spaces.create.CreateSpaceDetailsFragment
import im.vector.app.features.spaces.create.CreateSpaceEvents
Expand All @@ -55,18 +56,21 @@ class SpaceCreationActivity : SimpleFragmentActivity(), CreateSpaceViewModel.Fac
super.onCreate(savedInstanceState)
if (isFirstCreation()) {
when (withState(viewModel) { it.step }) {
CreateSpaceState.Step.ChooseType -> {
CreateSpaceState.Step.ChooseType -> {
navigateToFragment(ChooseSpaceTypeFragment::class.java)
}
CreateSpaceState.Step.SetDetails -> {
CreateSpaceState.Step.SetDetails -> {
navigateToFragment(ChooseSpaceTypeFragment::class.java)
}
CreateSpaceState.Step.AddRooms -> {
CreateSpaceState.Step.AddRooms -> {
navigateToFragment(CreateSpaceDefaultRoomsFragment::class.java)
}
CreateSpaceState.Step.ChoosePrivateType -> {
CreateSpaceState.Step.ChoosePrivateType -> {
navigateToFragment(ChoosePrivateSpaceTypeFragment::class.java)
}
CreateSpaceState.Step.AddEmailsOrInvites -> {
navigateToFragment(CreateSpaceAdd3pidInvitesFragment::class.java)
}
}
}
}
Expand All @@ -92,6 +96,9 @@ class SpaceCreationActivity : SimpleFragmentActivity(), CreateSpaceViewModel.Fac
CreateSpaceEvents.NavigateToAddRooms -> {
navigateToFragment(CreateSpaceDefaultRoomsFragment::class.java)
}
CreateSpaceEvents.NavigateToAdd3Pid -> {
navigateToFragment(CreateSpaceAdd3pidInvitesFragment::class.java)
}
CreateSpaceEvents.NavigateToChoosePrivateType -> {
navigateToFragment(ChoosePrivateSpaceTypeFragment::class.java)
}
Expand Down Expand Up @@ -143,6 +150,7 @@ class SpaceCreationActivity : SimpleFragmentActivity(), CreateSpaceViewModel.Fac
if (state.spaceType == SpaceType.Public) R.string.your_public_space
else R.string.your_private_space
}
CreateSpaceState.Step.AddEmailsOrInvites,
CreateSpaceState.Step.ChoosePrivateType -> R.string.your_private_space
}
supportActionBar?.let {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.setFragmentResultListener
import com.airbnb.mvrx.activityViewModel
import im.vector.app.R
import im.vector.app.core.epoxy.onClick
Expand All @@ -39,13 +38,6 @@ class ChoosePrivateSpaceTypeFragment @Inject constructor(
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?) =
FragmentSpaceCreateChoosePrivateModelBinding.inflate(layoutInflater, container, false)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setFragmentResultListener(BetaWarningBottomSheet.REQUEST_KEY) { _, _ ->
sharedViewModel.handle(CreateSpaceAction.SetSpaceTopology(SpaceTopology.MeAndTeammates))
}
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand All @@ -54,7 +46,7 @@ class ChoosePrivateSpaceTypeFragment @Inject constructor(
}

views.teammatesButton.onClick {
BetaWarningBottomSheet().show(parentFragmentManager, "warning")
sharedViewModel.handle(CreateSpaceAction.SetSpaceTopology(SpaceTopology.MeAndTeammates))
}

sharedViewModel.subscribe { state ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ sealed class CreateSpaceAction : VectorViewModelAction {
object OnBackPressed : CreateSpaceAction()
object NextFromDetails : CreateSpaceAction()
object NextFromDefaultRooms : CreateSpaceAction()
object NextFromAdd3pid : CreateSpaceAction()
data class DefaultRoomNameChanged(val index: Int, val name: String) : CreateSpaceAction()
data class DefaultInvite3pidChanged(val index: Int, val email: String) : CreateSpaceAction()
data class SetSpaceTopology(val topology: SpaceTopology) : CreateSpaceAction()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.app.features.spaces.create

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.airbnb.mvrx.activityViewModel
import im.vector.app.R
import im.vector.app.core.extensions.cleanup
import im.vector.app.core.extensions.configureWith
import im.vector.app.core.extensions.hideKeyboard
import im.vector.app.core.platform.OnBackPressed
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentSpaceCreateGenericEpoxyFormBinding
import im.vector.app.features.settings.VectorSettingsActivity
import javax.inject.Inject

class CreateSpaceAdd3pidInvitesFragment @Inject constructor(
private val epoxyController: SpaceAdd3pidEpoxyController
) : VectorBaseFragment<FragmentSpaceCreateGenericEpoxyFormBinding>(),
SpaceAdd3pidEpoxyController.Listener,
OnBackPressed {

private val sharedViewModel: CreateSpaceViewModel by activityViewModel()

override fun onBackPressed(toolbarButton: Boolean): Boolean {
sharedViewModel.handle(CreateSpaceAction.OnBackPressed)
return true
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

views.recyclerView.configureWith(epoxyController)
epoxyController.listener = this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add cleanup in onDestroyView()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


sharedViewModel.subscribe(this) {
invalidateState(it)
}

views.nextButton.setText(R.string.next_pf)
views.nextButton.debouncedClicks {
view.hideKeyboard()
sharedViewModel.handle(CreateSpaceAction.NextFromAdd3pid)
}
}

private fun invalidateState(it: CreateSpaceState) {
epoxyController.setData(it)
val noEmails = it.default3pidInvite?.all { it.value.isNullOrBlank() } ?: true
views.nextButton.text = if (noEmails) {
getString(R.string.skip_for_now)
} else {
getString(R.string.next_pf)
}
}

override fun onDestroyView() {
views.recyclerView.cleanup()
epoxyController.listener = null
super.onDestroyView()
}

override fun getBinding(inflater: LayoutInflater, container: ViewGroup?) =
FragmentSpaceCreateGenericEpoxyFormBinding.inflate(layoutInflater, container, false)

override fun on3pidChange(index: Int, newName: String) {
sharedViewModel.handle(CreateSpaceAction.DefaultInvite3pidChanged(index, newName))
}

override fun onNoIdentityServer() {
navigator.openSettings(
requireContext(),
VectorSettingsActivity.EXTRA_DIRECT_ACCESS_DISCOVERY_SETTINGS
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sealed class CreateSpaceEvents : VectorViewEvents {
object NavigateToDetails : CreateSpaceEvents()
object NavigateToChooseType : CreateSpaceEvents()
object NavigateToAddRooms : CreateSpaceEvents()
object NavigateToAdd3Pid : CreateSpaceEvents()
object NavigateToChoosePrivateType : CreateSpaceEvents()
object Dismiss : CreateSpaceEvents()
data class FinishSuccess(val spaceId: String, val defaultRoomId: String?, val topology: SpaceTopology?) : CreateSpaceEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ data class CreateSpaceState(
val aliasVerificationTask: Async<Boolean> = Uninitialized,
val nameInlineError: String? = null,
val defaultRooms: Map<Int /** position in form */, String?>? = null,
val creationResult: Async<String> = Uninitialized
val default3pidInvite: Map<Int /** position in form */, String?>? = null,
val emailValidationResult: Map<Int /** position in form */, Boolean>? = null,
val creationResult: Async<String> = Uninitialized,
val canInviteByMail: Boolean = false
) : MvRxState {

enum class Step {
ChooseType,
SetDetails,
AddRooms,
ChoosePrivateType
ChoosePrivateType,
AddEmailsOrInvites
}
}
Loading