Add just me space flow Initial commit
This commit is contained in:
parent
264eb3b0a2
commit
7465ac2ef6
|
@ -48,6 +48,7 @@ import im.vector.app.features.MainActivity
|
|||
import im.vector.app.features.MainActivityArgs
|
||||
import im.vector.app.features.disclaimer.showDisclaimerDialog
|
||||
import im.vector.app.features.matrixto.MatrixToBottomSheet
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
import im.vector.app.features.notifications.NotificationDrawerManager
|
||||
import im.vector.app.features.permalink.NavigationInterceptor
|
||||
import im.vector.app.features.permalink.PermalinkHandler
|
||||
|
@ -115,11 +116,21 @@ class HomeActivity :
|
|||
if (activityResult.resultCode == Activity.RESULT_OK) {
|
||||
val spaceId = SpaceCreationActivity.getCreatedSpaceId(activityResult.data)
|
||||
val defaultRoomId = SpaceCreationActivity.getDefaultRoomId(activityResult.data)
|
||||
val isJustMe = SpaceCreationActivity.isJustMeSpace(activityResult.data)
|
||||
views.drawerLayout.closeDrawer(GravityCompat.START)
|
||||
|
||||
val postSwitchOption: Navigator.PostSwitchSpaceAction = if (defaultRoomId != null) {
|
||||
Navigator.PostSwitchSpaceAction.OpenDefaultRoom(defaultRoomId, !isJustMe)
|
||||
} else if (isJustMe) {
|
||||
Navigator.PostSwitchSpaceAction.OpenAddExistingRooms
|
||||
} else {
|
||||
Navigator.PostSwitchSpaceAction.None
|
||||
}
|
||||
// Here we want to change current space to the newly created one, and then immediately open the default room
|
||||
if (spaceId != null) {
|
||||
navigator.switchToSpace(this, spaceId, defaultRoomId, true)
|
||||
navigator.switchToSpace(context = this,
|
||||
spaceId = spaceId,
|
||||
postSwitchOption)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +278,7 @@ class HomeActivity :
|
|||
|
||||
private fun renderState(state: HomeActivityViewState) {
|
||||
when (val status = state.initialSyncProgressServiceStatus) {
|
||||
is InitialSyncProgressService.Status.Idle -> {
|
||||
is InitialSyncProgressService.Status.Idle -> {
|
||||
views.waitingView.root.isVisible = false
|
||||
}
|
||||
is InitialSyncProgressService.Status.Progressing -> {
|
||||
|
@ -494,7 +505,7 @@ class HomeActivity :
|
|||
}
|
||||
|
||||
override fun switchToSpace(spaceId: String) {
|
||||
navigator.switchToSpace(this@HomeActivity, spaceId, null, false)
|
||||
navigator.switchToSpace(this@HomeActivity, spaceId, Navigator.PostSwitchSpaceAction.None)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ import im.vector.app.features.share.SharedData
|
|||
import im.vector.app.features.spaces.InviteRoomSpaceChooserBottomSheet
|
||||
import im.vector.app.features.spaces.SpaceExploreActivity
|
||||
import im.vector.app.features.spaces.SpacePreviewActivity
|
||||
import im.vector.app.features.spaces.manage.SpaceManageActivity
|
||||
import im.vector.app.features.terms.ReviewTermsActivity
|
||||
import im.vector.app.features.widgets.WidgetActivity
|
||||
import im.vector.app.features.widgets.WidgetArgsBuilder
|
||||
|
@ -106,21 +107,27 @@ class DefaultNavigator @Inject constructor(
|
|||
startActivity(context, intent, buildTask)
|
||||
}
|
||||
|
||||
override fun switchToSpace(context: Context, spaceId: String, roomId: String?, openShareSheet: Boolean) {
|
||||
override fun switchToSpace(context: Context, spaceId: String, postSwitchSpaceAction: Navigator.PostSwitchSpaceAction) {
|
||||
if (sessionHolder.getSafeActiveSession()?.getRoomSummary(spaceId) == null) {
|
||||
fatalError("Trying to open an unknown space $spaceId", vectorPreferences.failFast())
|
||||
return
|
||||
}
|
||||
appStateHandler.setCurrentSpace(spaceId)
|
||||
if (roomId != null) {
|
||||
val args = RoomDetailArgs(roomId, eventId = null, openShareSpaceForId = spaceId.takeIf { openShareSheet })
|
||||
val intent = RoomDetailActivity.newIntent(context, args)
|
||||
startActivity(context, intent, false)
|
||||
} else {
|
||||
// go back to home if we are showing room details?
|
||||
// This is a bit ugly, but the navigator is supposed to know about the activity stack
|
||||
if (context is RoomDetailActivity) {
|
||||
context.finish()
|
||||
when (postSwitchSpaceAction) {
|
||||
Navigator.PostSwitchSpaceAction.None -> {
|
||||
// go back to home if we are showing room details?
|
||||
// This is a bit ugly, but the navigator is supposed to know about the activity stack
|
||||
if (context is RoomDetailActivity) {
|
||||
context.finish()
|
||||
}
|
||||
}
|
||||
Navigator.PostSwitchSpaceAction.OpenAddExistingRooms -> {
|
||||
startActivity(context, SpaceManageActivity.newIntent(context, spaceId), false)
|
||||
}
|
||||
is Navigator.PostSwitchSpaceAction.OpenDefaultRoom -> {
|
||||
val args = RoomDetailArgs(postSwitchSpaceAction.roomId, eventId = null, openShareSpaceForId = spaceId.takeIf { postSwitchSpaceAction.showShareSheet })
|
||||
val intent = RoomDetailActivity.newIntent(context, args)
|
||||
startActivity(context, intent, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +243,7 @@ class DefaultNavigator @Inject constructor(
|
|||
}
|
||||
|
||||
override fun switchToSpace(spaceId: String) {
|
||||
this@DefaultNavigator.switchToSpace(context, spaceId, null, openShareSheet = false)
|
||||
this@DefaultNavigator.switchToSpace(context, spaceId, Navigator.PostSwitchSpaceAction.None)
|
||||
}
|
||||
}
|
||||
// TODO check if there is already one??
|
||||
|
|
|
@ -38,7 +38,13 @@ interface Navigator {
|
|||
|
||||
fun openRoom(context: Context, roomId: String, eventId: String? = null, buildTask: Boolean = false)
|
||||
|
||||
fun switchToSpace(context: Context, spaceId: String, roomId: String?, openShareSheet: Boolean)
|
||||
sealed class PostSwitchSpaceAction {
|
||||
object None : PostSwitchSpaceAction()
|
||||
data class OpenDefaultRoom(val roomId: String, val showShareSheet: Boolean) : PostSwitchSpaceAction()
|
||||
object OpenAddExistingRooms: PostSwitchSpaceAction()
|
||||
}
|
||||
|
||||
fun switchToSpace(context: Context, spaceId: String, postSwitchSpaceAction: PostSwitchSpaceAction)
|
||||
|
||||
fun openSpacePreview(context: Context, spaceId: String)
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import im.vector.app.features.spaces.create.CreateSpaceDetailsFragment
|
|||
import im.vector.app.features.spaces.create.CreateSpaceEvents
|
||||
import im.vector.app.features.spaces.create.CreateSpaceState
|
||||
import im.vector.app.features.spaces.create.CreateSpaceViewModel
|
||||
import im.vector.app.features.spaces.create.SpaceTopology
|
||||
import im.vector.app.features.spaces.create.SpaceType
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -61,7 +62,7 @@ class SpaceCreationActivity : SimpleFragmentActivity(), CreateSpaceViewModel.Fac
|
|||
CreateSpaceState.Step.SetDetails -> {
|
||||
navigateToFragment(ChooseSpaceTypeFragment::class.java)
|
||||
}
|
||||
CreateSpaceState.Step.AddRooms -> {
|
||||
CreateSpaceState.Step.AddRooms -> {
|
||||
navigateToFragment(CreateSpaceDefaultRoomsFragment::class.java)
|
||||
}
|
||||
CreateSpaceState.Step.ChoosePrivateType -> {
|
||||
|
@ -106,6 +107,9 @@ class SpaceCreationActivity : SimpleFragmentActivity(), CreateSpaceViewModel.Fac
|
|||
setResult(RESULT_OK, Intent().apply {
|
||||
putExtra(RESULT_DATA_CREATED_SPACE_ID, it.spaceId)
|
||||
putExtra(RESULT_DATA_DEFAULT_ROOM_ID, it.defaultRoomId)
|
||||
if (it.topology == SpaceTopology.JustMe) {
|
||||
putExtra(RESULT_DATA_CREATED_SPACE_IS_JUST_ME, true)
|
||||
}
|
||||
})
|
||||
finish()
|
||||
}
|
||||
|
@ -155,6 +159,7 @@ class SpaceCreationActivity : SimpleFragmentActivity(), CreateSpaceViewModel.Fac
|
|||
companion object {
|
||||
private const val RESULT_DATA_CREATED_SPACE_ID = "RESULT_DATA_CREATED_SPACE_ID"
|
||||
private const val RESULT_DATA_DEFAULT_ROOM_ID = "RESULT_DATA_DEFAULT_ROOM_ID"
|
||||
private const val RESULT_DATA_CREATED_SPACE_IS_JUST_ME = "RESULT_DATA_CREATED_SPACE_IS_JUST_ME"
|
||||
|
||||
fun newIntent(context: Context): Intent {
|
||||
return Intent(context, SpaceCreationActivity::class.java).apply {
|
||||
|
@ -169,6 +174,10 @@ class SpaceCreationActivity : SimpleFragmentActivity(), CreateSpaceViewModel.Fac
|
|||
fun getDefaultRoomId(data: Intent?): String? {
|
||||
return data?.extras?.getString(RESULT_DATA_DEFAULT_ROOM_ID)
|
||||
}
|
||||
|
||||
fun isJustMeSpace(data: Intent?): Boolean {
|
||||
return data?.extras?.getBoolean(RESULT_DATA_CREATED_SPACE_IS_JUST_ME, false) == true
|
||||
}
|
||||
}
|
||||
|
||||
override fun create(initialState: CreateSpaceState): CreateSpaceViewModel = viewModelFactory.create(initialState)
|
||||
|
|
|
@ -42,8 +42,7 @@ class ChoosePrivateSpaceTypeFragment @Inject constructor(
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
views.justMeButton.setOnClickListener(DebouncedClickListener({
|
||||
vectorBaseActivity.notImplemented("Organize room as space is not yet implemented")
|
||||
// sharedViewModel.handle(CreateSpaceAction.SetSpaceTopology(SpaceTopology.JustMe))
|
||||
sharedViewModel.handle(CreateSpaceAction.SetSpaceTopology(SpaceTopology.JustMe))
|
||||
}))
|
||||
|
||||
views.teammatesButton.setOnClickListener(DebouncedClickListener({
|
||||
|
|
|
@ -24,7 +24,7 @@ sealed class CreateSpaceEvents : VectorViewEvents {
|
|||
object NavigateToAddRooms : CreateSpaceEvents()
|
||||
object NavigateToChoosePrivateType : CreateSpaceEvents()
|
||||
object Dismiss : CreateSpaceEvents()
|
||||
data class FinishSuccess(val spaceId: String, val defaultRoomId: String?) : CreateSpaceEvents()
|
||||
data class FinishSuccess(val spaceId: String, val defaultRoomId: String?, val topology: SpaceTopology?) : CreateSpaceEvents()
|
||||
data class ShowModalError(val errorMessage: String) : CreateSpaceEvents()
|
||||
object HideModalLoading : CreateSpaceEvents()
|
||||
}
|
||||
|
|
|
@ -126,10 +126,12 @@ class CreateSpaceViewModel @AssistedInject constructor(
|
|||
SpaceTopology.JustMe -> {
|
||||
setState {
|
||||
copy(
|
||||
spaceTopology = SpaceTopology.JustMe
|
||||
spaceTopology = SpaceTopology.JustMe,
|
||||
defaultRooms = emptyMap()
|
||||
)
|
||||
}
|
||||
// XXX finish and open the add rooms directly
|
||||
handleNextFromDefaultRooms()
|
||||
}
|
||||
SpaceTopology.MeAndTeammates -> {
|
||||
setState {
|
||||
|
@ -237,14 +239,26 @@ class CreateSpaceViewModel @AssistedInject constructor(
|
|||
setState {
|
||||
copy(creationResult = Success(result.spaceId))
|
||||
}
|
||||
_viewEvents.post(CreateSpaceEvents.FinishSuccess(result.spaceId, result.childIds.firstOrNull()))
|
||||
_viewEvents.post(
|
||||
CreateSpaceEvents.FinishSuccess(
|
||||
result.spaceId,
|
||||
result.childIds.firstOrNull(),
|
||||
state.spaceTopology
|
||||
)
|
||||
)
|
||||
}
|
||||
is CreateSpaceTaskResult.PartialSuccess -> {
|
||||
// XXX what can we do here?
|
||||
setState {
|
||||
copy(creationResult = Success(result.spaceId))
|
||||
}
|
||||
_viewEvents.post(CreateSpaceEvents.FinishSuccess(result.spaceId, result.childIds.firstOrNull()))
|
||||
_viewEvents.post(
|
||||
CreateSpaceEvents.FinishSuccess(
|
||||
result.spaceId,
|
||||
result.childIds.firstOrNull(),
|
||||
state.spaceTopology
|
||||
)
|
||||
)
|
||||
}
|
||||
is CreateSpaceTaskResult.FailedToCreateSpace -> {
|
||||
setState {
|
||||
|
|
Loading…
Reference in New Issue