diff --git a/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt b/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt index 9eaf89b70e..dcca33a645 100644 --- a/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt +++ b/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt @@ -45,6 +45,7 @@ import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment import im.vector.riotx.features.roomdirectory.picker.RoomDirectoryPickerFragment import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewNoPreviewFragment import im.vector.riotx.features.roomprofile.RoomProfileFragment +import im.vector.riotx.features.roomprofile.members.RoomMemberListFragment import im.vector.riotx.features.settings.* import im.vector.riotx.features.settings.ignored.VectorSettingsIgnoredUsersFragment import im.vector.riotx.features.settings.push.PushGatewaysFragment @@ -259,6 +260,11 @@ interface FragmentModule { @FragmentKey(RoomProfileFragment::class) fun bindRoomProfileFragment(fragment: RoomProfileFragment): Fragment + @Binds + @IntoMap + @FragmentKey(RoomMemberListFragment::class) + fun bindRoomMemberListFragment(fragment: RoomMemberListFragment): Fragment + @Binds @IntoMap @FragmentKey(BreadcrumbsFragment::class) diff --git a/vector/src/main/java/im/vector/riotx/core/di/ViewModelModule.kt b/vector/src/main/java/im/vector/riotx/core/di/ViewModelModule.kt index bfd0124391..5d4288f4b8 100644 --- a/vector/src/main/java/im/vector/riotx/core/di/ViewModelModule.kt +++ b/vector/src/main/java/im/vector/riotx/core/di/ViewModelModule.kt @@ -35,6 +35,7 @@ import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsShare import im.vector.riotx.features.login.LoginSharedActionViewModel import im.vector.riotx.features.reactions.EmojiChooserViewModel import im.vector.riotx.features.roomdirectory.RoomDirectorySharedActionViewModel +import im.vector.riotx.features.roomprofile.RoomProfileSharedActionViewModel import im.vector.riotx.features.workers.signout.SignOutViewModel @Module @@ -124,4 +125,9 @@ interface ViewModelModule { @IntoMap @ViewModelKey(RoomDetailSharedActionViewModel::class) fun bindRoomDetailSharedActionViewModel(viewModel: RoomDetailSharedActionViewModel): ViewModel + + @Binds + @IntoMap + @ViewModelKey(RoomProfileSharedActionViewModel::class) + fun bindRoomProfileSharedActionViewModel(viewModel: RoomProfileSharedActionViewModel): ViewModel } diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileActivity.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileActivity.kt index e57debee7f..14c3421e7f 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileActivity.kt @@ -22,8 +22,10 @@ import android.content.Intent import androidx.appcompat.widget.Toolbar import im.vector.riotx.R import im.vector.riotx.core.extensions.addFragment +import im.vector.riotx.core.extensions.addFragmentToBackstack import im.vector.riotx.core.platform.ToolbarConfigurable import im.vector.riotx.core.platform.VectorBaseActivity +import im.vector.riotx.features.roomprofile.members.RoomMemberListFragment class RoomProfileActivity : VectorBaseActivity(), ToolbarConfigurable { @@ -39,14 +41,39 @@ class RoomProfileActivity : VectorBaseActivity(), ToolbarConfigurable { } } + private lateinit var sharedActionViewModel: RoomProfileSharedActionViewModel + private lateinit var roomProfileArgs: RoomProfileArgs + override fun getLayoutRes() = R.layout.activity_simple override fun initUiAndData() { + sharedActionViewModel = viewModelProvider.get(RoomProfileSharedActionViewModel::class.java) + roomProfileArgs = intent?.extras?.getParcelable(EXTRA_ROOM_PROFILE_ARGS) ?: return if (isFirstCreation()) { - val roomProfileArgs: RoomProfileArgs = intent?.extras?.getParcelable(EXTRA_ROOM_PROFILE_ARGS) - ?: return addFragment(R.id.simpleFragmentContainer, RoomProfileFragment::class.java, roomProfileArgs) } + sharedActionViewModel + .observe() + .subscribe { sharedAction -> + when (sharedAction) { + is RoomProfileSharedAction.OpenRoomMembers -> openRoomMembers() + is RoomProfileSharedAction.OpenRoomSettings -> openRoomSettings() + is RoomProfileSharedAction.OpenRoomUploads -> openRoomUploads() + } + } + .disposeOnDestroy() + } + + private fun openRoomUploads() { + notImplemented("Open room uploads") + } + + private fun openRoomSettings() { + notImplemented("Open room settings") + } + + private fun openRoomMembers() { + addFragmentToBackstack(R.id.simpleFragmentContainer, RoomMemberListFragment::class.java, roomProfileArgs) } override fun configure(toolbar: Toolbar) { diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileFragment.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileFragment.kt index c4fec612ac..0ebbbcde6b 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileFragment.kt @@ -60,14 +60,16 @@ class RoomProfileFragment @Inject constructor( private var progress: ProgressDialog? = null private val roomProfileArgs: RoomProfileArgs by args() - private lateinit var sharedActionViewModel: RoomListQuickActionsSharedActionViewModel + private lateinit var roomListQuickActionsSharedActionViewModel: RoomListQuickActionsSharedActionViewModel + private lateinit var roomProfileSharedActionViewModel: RoomProfileSharedActionViewModel private val roomProfileViewModel: RoomProfileViewModel by fragmentViewModel() override fun getLayoutResId() = R.layout.fragment_room_profile override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - sharedActionViewModel = activityViewModelProvider.get(RoomListQuickActionsSharedActionViewModel::class.java) + roomListQuickActionsSharedActionViewModel = activityViewModelProvider.get(RoomListQuickActionsSharedActionViewModel::class.java) + roomProfileSharedActionViewModel = activityViewModelProvider.get(RoomProfileSharedActionViewModel::class.java) setupToolbar(roomProfileToolbar) setupRecyclerView() roomProfileViewModel.viewEvents @@ -82,7 +84,7 @@ class RoomProfileFragment @Inject constructor( } .disposeOnDestroyView() - sharedActionViewModel + roomListQuickActionsSharedActionViewModel .observe() .subscribe { handleQuickActions(it) } .disposeOnDestroyView() @@ -156,11 +158,11 @@ class RoomProfileFragment @Inject constructor( } override fun onMemberListClicked() { - vectorBaseActivity.notImplemented("See room member list") + roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomMembers) } override fun onSettingsClicked() { - vectorBaseActivity.notImplemented("See Room settings") + roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomSettings) } override fun onNotificationsClicked() { @@ -170,7 +172,7 @@ class RoomProfileFragment @Inject constructor( } override fun onUploadsClicked() { - vectorBaseActivity.notImplemented("See uploads") + roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomUploads) } override fun onLeaveRoomClicked() { diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileSharedAction.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileSharedAction.kt new file mode 100644 index 0000000000..71142c0aae --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileSharedAction.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2019 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.riotx.features.roomprofile + +import im.vector.riotx.core.platform.VectorSharedAction + +/** + * Supported navigation actions for [RoomProfileActivity] + */ +sealed class RoomProfileSharedAction : VectorSharedAction { + object OpenRoomSettings : RoomProfileSharedAction() + object OpenRoomUploads : RoomProfileSharedAction() + object OpenRoomMembers : RoomProfileSharedAction() +} diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileSharedActionViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileSharedActionViewModel.kt new file mode 100644 index 0000000000..e1921b0c23 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileSharedActionViewModel.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2019 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.riotx.features.roomprofile + +import im.vector.riotx.core.platform.VectorSharedActionViewModel +import javax.inject.Inject + +class RoomProfileSharedActionViewModel @Inject constructor() : VectorSharedActionViewModel() diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListAction.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListAction.kt new file mode 100644 index 0000000000..01a35b84d3 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListAction.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2019 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.riotx.features.roomprofile.members + +import im.vector.riotx.core.platform.VectorViewModelAction + +sealed class RoomMemberListAction : VectorViewModelAction diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListFragment.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListFragment.kt new file mode 100644 index 0000000000..ae0e990c4a --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListFragment.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2019 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.riotx.features.roomprofile.members + +import android.os.Bundle +import android.view.View +import com.airbnb.mvrx.args +import com.airbnb.mvrx.fragmentViewModel +import com.airbnb.mvrx.withState +import im.vector.riotx.R +import im.vector.riotx.core.platform.VectorBaseFragment +import im.vector.riotx.features.roomprofile.RoomProfileArgs +import javax.inject.Inject + + +class RoomMemberListFragment @Inject constructor( + val viewModelFactory: RoomMemberListViewModel.Factory +) : VectorBaseFragment() { + + private val viewModel: RoomMemberListViewModel by fragmentViewModel() + private val roomProfileArgs: RoomProfileArgs by args() + + override fun getLayoutResId() = R.layout.fragment_room_member_list + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + // Initialize your view, subscribe to viewModel... + } + + override fun onDestroyView() { + super.onDestroyView() + // Clear your view, unsubscribe... + } + + override fun invalidate() = withState(viewModel) { _ -> + + } + +} diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListViewModel.kt new file mode 100644 index 0000000000..d1a4592965 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListViewModel.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2019 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.riotx.features.roomprofile.members + +import com.airbnb.mvrx.FragmentViewModelContext +import com.airbnb.mvrx.MvRxViewModelFactory +import com.airbnb.mvrx.ViewModelContext +import com.squareup.inject.assisted.Assisted +import com.squareup.inject.assisted.AssistedInject +import im.vector.riotx.core.platform.VectorViewModel + +class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState: RoomMemberListViewState) + : VectorViewModel(initialState) { + + @AssistedInject.Factory + interface Factory { + fun create(initialState: RoomMemberListViewState): RoomMemberListViewModel + } + + companion object : MvRxViewModelFactory { + + @JvmStatic + override fun create(viewModelContext: ViewModelContext, state: RoomMemberListViewState): RoomMemberListViewModel? { + val fragment: RoomMemberListFragment = (viewModelContext as FragmentViewModelContext).fragment() + return fragment.viewModelFactory.create(state) + } + } + + override fun handle(action: RoomMemberListAction) { + //TODO + } + +} diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListViewState.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListViewState.kt new file mode 100644 index 0000000000..2e432c59f5 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListViewState.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2019 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.riotx.features.roomprofile.members + +import com.airbnb.mvrx.MvRxState + +data class RoomMemberListViewState( + val noValue: Boolean = false +) : MvRxState diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMembersEpoxyController.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMembersEpoxyController.kt new file mode 100644 index 0000000000..9fb6c400c3 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMembersEpoxyController.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2019 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.riotx.features.roomprofile.members + +import com.airbnb.epoxy.TypedEpoxyController + +class RoomMembersEpoxyController : TypedEpoxyController() { + + override fun buildModels(data: RoomMemberListViewState?) { + + } + +} diff --git a/vector/src/main/res/layout/fragment_room_member_list.xml b/vector/src/main/res/layout/fragment_room_member_list.xml new file mode 100644 index 0000000000..eb453ac2e8 --- /dev/null +++ b/vector/src/main/res/layout/fragment_room_member_list.xml @@ -0,0 +1,19 @@ + + + + + + +