diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomAction.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomAction.kt
index 3b687395fd..22a963b525 100644
--- a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomAction.kt
+++ b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomAction.kt
@@ -20,6 +20,7 @@ import im.vector.app.core.platform.VectorViewModelAction
sealed class CreateRoomAction : VectorViewModelAction {
data class SetName(val name: String) : CreateRoomAction()
+ data class SetTopic(val topic: String) : CreateRoomAction()
data class SetIsPublic(val isPublic: Boolean) : CreateRoomAction()
data class SetIsInRoomDirectory(val isInRoomDirectory: Boolean) : CreateRoomAction()
data class SetIsEncrypted(val isEncrypted: Boolean) : CreateRoomAction()
diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomController.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomController.kt
index ba7c5ca083..9585932da2 100644
--- a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomController.kt
+++ b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomController.kt
@@ -26,6 +26,7 @@ import im.vector.app.core.epoxy.errorWithRetryItem
import im.vector.app.core.epoxy.loadingItem
import im.vector.app.core.error.ErrorFormatter
import im.vector.app.core.resources.StringProvider
+import im.vector.app.features.discovery.settingsSectionTitleItem
import im.vector.app.features.form.formEditTextItem
import im.vector.app.features.form.formSwitchItem
import javax.inject.Inject
@@ -67,6 +68,10 @@ class CreateRoomController @Inject constructor(private val stringProvider: Strin
}
private fun buildForm(viewState: CreateRoomViewState, enableFormElement: Boolean) {
+ settingsSectionTitleItem {
+ id("nameSection")
+ titleResId(R.string.create_room_name_section)
+ }
formEditTextItem {
id("name")
enabled(enableFormElement)
@@ -77,6 +82,24 @@ class CreateRoomController @Inject constructor(private val stringProvider: Strin
listener?.onNameChange(text)
}
}
+ settingsSectionTitleItem {
+ id("topicSection")
+ titleResId(R.string.create_room_topic_section)
+ }
+ formEditTextItem {
+ id("topic")
+ enabled(enableFormElement)
+ value(viewState.roomTopic)
+ hint(stringProvider.getString(R.string.create_room_topic_hint))
+
+ onTextChange { text ->
+ listener?.onTopicChange(text)
+ }
+ }
+ settingsSectionTitleItem {
+ id("settingsSection")
+ titleResId(R.string.create_room_settings_section)
+ }
formSwitchItem {
id("public")
enabled(enableFormElement)
@@ -120,6 +143,7 @@ class CreateRoomController @Inject constructor(private val stringProvider: Strin
interface Listener {
fun onNameChange(newName: String)
+ fun onTopicChange(newTopic: String)
fun setIsPublic(isPublic: Boolean)
fun setIsInRoomDirectory(isInRoomDirectory: Boolean)
fun setIsEncrypted(isEncrypted: Boolean)
diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomFragment.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomFragment.kt
index f3be178e64..ff20ceae6b 100644
--- a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomFragment.kt
+++ b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomFragment.kt
@@ -32,7 +32,9 @@ import kotlinx.android.synthetic.main.fragment_create_room.*
import timber.log.Timber
import javax.inject.Inject
-class CreateRoomFragment @Inject constructor(private val createRoomController: CreateRoomController) : VectorBaseFragment(), CreateRoomController.Listener {
+class CreateRoomFragment @Inject constructor(
+ private val createRoomController: CreateRoomController
+) : VectorBaseFragment(), CreateRoomController.Listener {
private lateinit var sharedActionViewModel: RoomDirectorySharedActionViewModel
private val viewModel: CreateRoomViewModel by activityViewModel()
@@ -77,6 +79,10 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C
viewModel.handle(CreateRoomAction.SetName(newName))
}
+ override fun onTopicChange(newTopic: String) {
+ viewModel.handle(CreateRoomAction.SetTopic(newTopic))
+ }
+
override fun setIsPublic(isPublic: Boolean) {
viewModel.handle(CreateRoomAction.SetIsPublic(isPublic))
}
diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewModel.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewModel.kt
index c213992258..d160f46472 100644
--- a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewModel.kt
+++ b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewModel.kt
@@ -26,6 +26,7 @@ import com.airbnb.mvrx.Success
import com.airbnb.mvrx.ViewModelContext
import com.squareup.inject.assisted.Assisted
import com.squareup.inject.assisted.AssistedInject
+import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.raw.wellknown.getElementWellknown
@@ -91,15 +92,18 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted initialState: Cr
override fun handle(action: CreateRoomAction) {
when (action) {
is CreateRoomAction.SetName -> setName(action)
+ is CreateRoomAction.SetTopic -> setTopic(action)
is CreateRoomAction.SetIsPublic -> setIsPublic(action)
is CreateRoomAction.SetIsInRoomDirectory -> setIsInRoomDirectory(action)
is CreateRoomAction.SetIsEncrypted -> setIsEncrypted(action)
is CreateRoomAction.Create -> doCreateRoom()
- }
+ }.exhaustive
}
private fun setName(action: CreateRoomAction.SetName) = setState { copy(roomName = action.name) }
+ private fun setTopic(action: CreateRoomAction.SetTopic) = setState { copy(roomTopic = action.topic) }
+
private fun setIsPublic(action: CreateRoomAction.SetIsPublic) = setState {
copy(
isPublic = action.isPublic,
@@ -123,6 +127,7 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted initialState: Cr
val createRoomParams = CreateRoomParams()
.apply {
name = state.roomName.takeIf { it.isNotBlank() }
+ topic = state.roomTopic.takeIf { it.isNotBlank() }
// Directory visibility
visibility = if (state.isInRoomDirectory) RoomDirectoryVisibility.PUBLIC else RoomDirectoryVisibility.PRIVATE
// Public room
diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewState.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewState.kt
index a49473b16e..3398a37361 100644
--- a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewState.kt
+++ b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomViewState.kt
@@ -22,6 +22,7 @@ import com.airbnb.mvrx.Uninitialized
data class CreateRoomViewState(
val roomName: String = "",
+ val roomTopic: String = "",
val isPublic: Boolean = false,
val isInRoomDirectory: Boolean = false,
val isEncrypted: Boolean = false,
diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml
index ec916d1daf..349698cb31 100644
--- a/vector/src/main/res/values/strings.xml
+++ b/vector/src/main/res/values/strings.xml
@@ -1675,7 +1675,11 @@
"New Room"
"CREATE"
- "Room name"
+ "Room name"
+ "Name"
+ "Room topic (optional)"
+ "Topic"
+ "Room settings"
"Public"
"Anyone will be able to join this room"
"Room Directory"