Introduce CreateRoomActivity, a simple container for [CreateRoomFragment]

This commit is contained in:
Benoit Marty 2019-07-15 17:22:46 +02:00
parent 3c25088243
commit 61bb4c0427
6 changed files with 86 additions and 2 deletions

View File

@ -58,6 +58,7 @@
<activity <activity
android:name=".features.reactions.EmojiReactionPickerActivity" android:name=".features.reactions.EmojiReactionPickerActivity"
android:label="@string/title_activity_emoji_reaction_picker" /> android:label="@string/title_activity_emoji_reaction_picker" />
<activity android:name=".features.roomdirectory.createroom.CreateRoomActivity" />
<activity android:name=".features.roomdirectory.RoomDirectoryActivity" /> <activity android:name=".features.roomdirectory.RoomDirectoryActivity" />
<activity android:name=".features.roomdirectory.roompreview.RoomPreviewActivity" /> <activity android:name=".features.roomdirectory.roompreview.RoomPreviewActivity" />
<activity android:name=".features.home.room.filtered.FilteredRoomsActivity" /> <activity android:name=".features.home.room.filtered.FilteredRoomsActivity" />

View File

@ -51,6 +51,7 @@ import im.vector.riotx.features.rageshake.RageShake
import im.vector.riotx.features.reactions.EmojiReactionPickerActivity import im.vector.riotx.features.reactions.EmojiReactionPickerActivity
import im.vector.riotx.features.roomdirectory.PublicRoomsFragment import im.vector.riotx.features.roomdirectory.PublicRoomsFragment
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment
import im.vector.riotx.features.roomdirectory.picker.RoomDirectoryPickerFragment import im.vector.riotx.features.roomdirectory.picker.RoomDirectoryPickerFragment
import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewNoPreviewFragment import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewNoPreviewFragment
@ -136,6 +137,8 @@ interface ScreenComponent {


fun inject(filteredRoomsActivity: FilteredRoomsActivity) fun inject(filteredRoomsActivity: FilteredRoomsActivity)


fun inject(createRoomActivity: CreateRoomActivity)

fun inject(vectorInviteView: VectorInviteView) fun inject(vectorInviteView: VectorInviteView)


fun inject(videoMediaViewerActivity: VideoMediaViewerActivity) fun inject(videoMediaViewerActivity: VideoMediaViewerActivity)

View File

@ -266,9 +266,9 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Listener, O
roomListViewModel.accept(RoomListActions.ToggleCategory(roomCategory)) roomListViewModel.accept(RoomListActions.ToggleCategory(roomCategory))
} }


// TODO Pass title
override fun createRoom() { override fun createRoom() {
// TODO Create an Activity to host CreateRoomFragment navigator.openCreateRoom(requireActivity())
navigator.openRoomDirectory(requireActivity())
} }


} }

View File

@ -29,6 +29,7 @@ import im.vector.riotx.features.home.room.detail.RoomDetailActivity
import im.vector.riotx.features.home.room.detail.RoomDetailArgs import im.vector.riotx.features.home.room.detail.RoomDetailArgs
import im.vector.riotx.features.home.room.filtered.FilteredRoomsActivity import im.vector.riotx.features.home.room.filtered.FilteredRoomsActivity
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity
import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewActivity import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewActivity
import im.vector.riotx.features.settings.VectorSettingsActivity import im.vector.riotx.features.settings.VectorSettingsActivity
import timber.log.Timber import timber.log.Timber
@ -62,6 +63,11 @@ class DefaultNavigator @Inject constructor() : Navigator {
context.startActivity(intent) context.startActivity(intent)
} }


override fun openCreateRoom(context: Context) {
val intent = CreateRoomActivity.getIntent(context)
context.startActivity(intent)
}

override fun openRoomsFiltering(context: Context) { override fun openRoomsFiltering(context: Context) {
val intent = FilteredRoomsActivity.newIntent(context) val intent = FilteredRoomsActivity.newIntent(context)
context.startActivity(intent) context.startActivity(intent)

View File

@ -27,6 +27,8 @@ interface Navigator {


fun openRoomPreview(publicRoom: PublicRoom, context: Context) fun openRoomPreview(publicRoom: PublicRoom, context: Context)


fun openCreateRoom(context: Context)

fun openRoomDirectory(context: Context) fun openRoomDirectory(context: Context)


fun openRoomsFiltering(context: Context) fun openRoomsFiltering(context: Context)

View File

@ -0,0 +1,72 @@
/*
* 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.roomdirectory.createroom

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.ViewModelProviders
import im.vector.riotx.R
import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.extensions.addFragment
import im.vector.riotx.core.extensions.observeEvent
import im.vector.riotx.core.platform.ToolbarConfigurable
import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
import im.vector.riotx.features.roomdirectory.RoomDirectoryNavigationViewModel

/**
* Simple container for [CreateRoomFragment]
*/
class CreateRoomActivity : VectorBaseActivity(), ToolbarConfigurable {

private lateinit var navigationViewModel: RoomDirectoryNavigationViewModel

override fun getLayoutRes() = R.layout.activity_simple

override fun configure(toolbar: Toolbar) {
configureToolbar(toolbar)
}

override fun initUiAndData() {
if (isFirstCreation()) {
addFragment(CreateRoomFragment(), R.id.simpleFragmentContainer)
}
}

override fun injectWith(injector: ScreenComponent) {
injector.inject(this)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
navigationViewModel = ViewModelProviders.of(this, viewModelFactory).get(RoomDirectoryNavigationViewModel::class.java)
navigationViewModel.navigateTo.observeEvent(this) { navigation ->
when (navigation) {
is RoomDirectoryActivity.Navigation.Back -> finish()
}
}
}

companion object {
fun getIntent(context: Context): Intent {
return Intent(context, CreateRoomActivity::class.java)
}
}

}