Show current history readability.
This commit is contained in:
parent
52eec06110
commit
e1a12f4c77
|
@ -17,6 +17,10 @@
|
||||||
package im.vector.riotx.features.roomprofile.settings
|
package im.vector.riotx.features.roomprofile.settings
|
||||||
|
|
||||||
import com.airbnb.epoxy.TypedEpoxyController
|
import com.airbnb.epoxy.TypedEpoxyController
|
||||||
|
import im.vector.matrix.android.api.session.events.model.Event
|
||||||
|
import im.vector.matrix.android.api.session.events.model.toModel
|
||||||
|
import im.vector.matrix.android.api.session.room.model.RoomHistoryVisibility
|
||||||
|
import im.vector.matrix.android.api.session.room.model.RoomHistoryVisibilityContent
|
||||||
import im.vector.matrix.android.api.util.toMatrixItem
|
import im.vector.matrix.android.api.util.toMatrixItem
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.epoxy.profiles.buildProfileAction
|
import im.vector.riotx.core.epoxy.profiles.buildProfileAction
|
||||||
|
@ -39,6 +43,7 @@ class RoomSettingsController @Inject constructor(
|
||||||
fun onNameChanged(name: String)
|
fun onNameChanged(name: String)
|
||||||
fun onTopicChanged(topic: String)
|
fun onTopicChanged(topic: String)
|
||||||
fun onPhotoClicked()
|
fun onPhotoClicked()
|
||||||
|
fun onHistoryVisibilityClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color)
|
private val dividerColor = colorProvider.getColorFromAttribute(R.attr.vctr_list_divider_color)
|
||||||
|
@ -52,6 +57,8 @@ class RoomSettingsController @Inject constructor(
|
||||||
override fun buildModels(data: RoomSettingsViewState?) {
|
override fun buildModels(data: RoomSettingsViewState?) {
|
||||||
val roomSummary = data?.roomSummary?.invoke() ?: return
|
val roomSummary = data?.roomSummary?.invoke() ?: return
|
||||||
|
|
||||||
|
val historyVisibility = data.historyVisibilityEvent?.let { formatRoomHistoryVisibilityEvent(it) } ?: ""
|
||||||
|
|
||||||
buildProfileSection(
|
buildProfileSection(
|
||||||
stringProvider.getString(R.string.settings)
|
stringProvider.getString(R.string.settings)
|
||||||
)
|
)
|
||||||
|
@ -78,6 +85,16 @@ class RoomSettingsController @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildProfileAction(
|
||||||
|
id = "historyReadability",
|
||||||
|
title = stringProvider.getString(R.string.room_settings_room_read_history_rules_pref_title),
|
||||||
|
subtitle = historyVisibility.toString(),
|
||||||
|
dividerColor = dividerColor,
|
||||||
|
divider = false,
|
||||||
|
editable = true,
|
||||||
|
action = { callback?.onHistoryVisibilityClicked() }
|
||||||
|
)
|
||||||
|
|
||||||
buildProfileAction(
|
buildProfileAction(
|
||||||
id = "photo",
|
id = "photo",
|
||||||
title = stringProvider.getString(R.string.room_settings_room_photo),
|
title = stringProvider.getString(R.string.room_settings_room_photo),
|
||||||
|
@ -110,4 +127,16 @@ class RoomSettingsController @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun formatRoomHistoryVisibilityEvent(event: Event): String? {
|
||||||
|
val historyVisibility = event.getClearContent().toModel<RoomHistoryVisibilityContent>()?.historyVisibility ?: return null
|
||||||
|
|
||||||
|
val formattedVisibility = when (historyVisibility) {
|
||||||
|
RoomHistoryVisibility.SHARED -> stringProvider.getString(R.string.notice_room_visibility_shared)
|
||||||
|
RoomHistoryVisibility.INVITED -> stringProvider.getString(R.string.notice_room_visibility_invited)
|
||||||
|
RoomHistoryVisibility.JOINED -> stringProvider.getString(R.string.notice_room_visibility_joined)
|
||||||
|
RoomHistoryVisibility.WORLD_READABLE -> stringProvider.getString(R.string.notice_room_visibility_world_readable)
|
||||||
|
}
|
||||||
|
return formattedVisibility
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,4 +152,8 @@ class RoomSettingsFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onHistoryVisibilityClicked() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import com.squareup.inject.assisted.Assisted
|
||||||
import com.squareup.inject.assisted.AssistedInject
|
import com.squareup.inject.assisted.AssistedInject
|
||||||
import im.vector.matrix.android.api.MatrixCallback
|
import im.vector.matrix.android.api.MatrixCallback
|
||||||
import im.vector.matrix.android.api.session.Session
|
import im.vector.matrix.android.api.session.Session
|
||||||
|
import im.vector.matrix.android.api.session.events.model.EventType
|
||||||
import im.vector.matrix.rx.rx
|
import im.vector.matrix.rx.rx
|
||||||
import im.vector.matrix.rx.unwrap
|
import im.vector.matrix.rx.unwrap
|
||||||
import im.vector.riotx.core.platform.VectorViewModel
|
import im.vector.riotx.core.platform.VectorViewModel
|
||||||
|
@ -60,6 +61,7 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
|
||||||
.execute { async ->
|
.execute { async ->
|
||||||
val roomSummary = async.invoke()
|
val roomSummary = async.invoke()
|
||||||
copy(
|
copy(
|
||||||
|
historyVisibilityEvent = room.getStateEvent(EventType.STATE_ROOM_HISTORY_VISIBILITY),
|
||||||
roomSummary = async,
|
roomSummary = async,
|
||||||
newName = roomSummary?.displayName,
|
newName = roomSummary?.displayName,
|
||||||
newTopic = roomSummary?.topic
|
newTopic = roomSummary?.topic
|
||||||
|
|
|
@ -19,12 +19,14 @@ package im.vector.riotx.features.roomprofile.settings
|
||||||
import com.airbnb.mvrx.Async
|
import com.airbnb.mvrx.Async
|
||||||
import com.airbnb.mvrx.MvRxState
|
import com.airbnb.mvrx.MvRxState
|
||||||
import com.airbnb.mvrx.Uninitialized
|
import com.airbnb.mvrx.Uninitialized
|
||||||
|
import im.vector.matrix.android.api.session.events.model.Event
|
||||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
||||||
import im.vector.riotx.features.roomprofile.RoomProfileArgs
|
import im.vector.riotx.features.roomprofile.RoomProfileArgs
|
||||||
import im.vector.riotx.multipicker.entity.MultiPickerImageType
|
import im.vector.riotx.multipicker.entity.MultiPickerImageType
|
||||||
|
|
||||||
data class RoomSettingsViewState(
|
data class RoomSettingsViewState(
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
|
val historyVisibilityEvent: Event? = null,
|
||||||
val roomSummary: Async<RoomSummary> = Uninitialized,
|
val roomSummary: Async<RoomSummary> = Uninitialized,
|
||||||
val isLoading: Boolean = false,
|
val isLoading: Boolean = false,
|
||||||
val newName: String? = null,
|
val newName: String? = null,
|
||||||
|
|
Loading…
Reference in New Issue