mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Radio settings bottomsheet
This commit is contained in:
parent
1deb44f91f
commit
14103b1e7c
23 changed files with 260 additions and 117 deletions
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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.app.core.epoxy.bottomsheet
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
|
||||
/**
|
||||
* A action for bottom sheet.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.item_bottom_sheet_radio)
|
||||
abstract class BottomSheetRadioActionItem : VectorEpoxyModel<BottomSheetRadioActionItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute
|
||||
var title: CharSequence? = null
|
||||
|
||||
@StringRes
|
||||
@EpoxyAttribute
|
||||
var titleRes: Int? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var selected = false
|
||||
|
||||
@EpoxyAttribute
|
||||
var description: CharSequence? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
lateinit var listener: View.OnClickListener
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.view.setOnClickListener {
|
||||
listener.onClick(it)
|
||||
}
|
||||
|
||||
if (titleRes != null) {
|
||||
holder.titleText.setText(titleRes!!)
|
||||
} else {
|
||||
holder.titleText.text = title
|
||||
}
|
||||
holder.descriptionText.setTextOrHide(description)
|
||||
|
||||
if (selected) {
|
||||
holder.radioImage.setImageDrawable(ContextCompat.getDrawable(holder.view.context, R.drawable.ic_radio_on))
|
||||
holder.radioImage.contentDescription = holder.view.context.getString(R.string.a11y_checked)
|
||||
} else {
|
||||
holder.radioImage.setImageDrawable(ContextCompat.getDrawable(holder.view.context, R.drawable.ic_radio_off))
|
||||
holder.radioImage.contentDescription = holder.view.context.getString(R.string.a11y_unchecked)
|
||||
}
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
val titleText by bind<TextView>(R.id.actionTitle)
|
||||
val descriptionText by bind<TextView>(R.id.actionDescription)
|
||||
val radioImage by bind<ImageView>(R.id.radioIcon)
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ import javax.inject.Inject
|
|||
/**
|
||||
* Generic Bottom sheet with actions
|
||||
*/
|
||||
abstract class BottomSheetGeneric<STATE : BottomSheetGenericState, ACTION : BottomSheetGenericAction> :
|
||||
abstract class BottomSheetGeneric<STATE : BottomSheetGenericState, ACTION : BottomSheetGenericRadioAction> :
|
||||
VectorBaseBottomSheetDialogFragment<BottomSheetGenericListBinding>(),
|
||||
BottomSheetGenericController.Listener<ACTION> {
|
||||
|
||||
|
|
|
@ -17,12 +17,11 @@ package im.vector.app.core.ui.bottomsheet
|
|||
|
||||
import android.view.View
|
||||
import com.airbnb.epoxy.TypedEpoxyController
|
||||
import im.vector.app.core.epoxy.dividerItem
|
||||
|
||||
/**
|
||||
* Epoxy controller for generic bottom sheet actions
|
||||
*/
|
||||
abstract class BottomSheetGenericController<State : BottomSheetGenericState, Action : BottomSheetGenericAction>
|
||||
abstract class BottomSheetGenericController<State : BottomSheetGenericState, Action : BottomSheetGenericRadioAction>
|
||||
: TypedEpoxyController<State>() {
|
||||
|
||||
var listener: Listener<Action>? = null
|
||||
|
@ -43,16 +42,14 @@ abstract class BottomSheetGenericController<State : BottomSheetGenericState, Act
|
|||
subTitle(getSubTitle())
|
||||
}
|
||||
|
||||
dividerItem {
|
||||
id("title_separator")
|
||||
}
|
||||
// dividerItem {
|
||||
// id("title_separator")
|
||||
// }
|
||||
}
|
||||
// Actions
|
||||
val actions = getActions(state)
|
||||
val showIcons = actions.any { it.iconResId > 0 }
|
||||
actions.forEach { action ->
|
||||
action.toBottomSheetItem()
|
||||
.showIcon(showIcons)
|
||||
action.toRadioBottomSheetItem()
|
||||
.listener(View.OnClickListener { listener?.didSelectAction(action) })
|
||||
.addTo(this)
|
||||
}
|
||||
|
|
|
@ -16,27 +16,24 @@
|
|||
|
||||
package im.vector.app.core.ui.bottomsheet
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import im.vector.app.core.epoxy.bottomsheet.BottomSheetActionItem_
|
||||
import im.vector.app.core.epoxy.bottomsheet.BottomSheetRadioActionItem_
|
||||
import im.vector.app.core.platform.VectorSharedAction
|
||||
|
||||
/**
|
||||
* Parent class for a bottom sheet action
|
||||
*/
|
||||
open class BottomSheetGenericAction(
|
||||
open val title: String,
|
||||
@DrawableRes open val iconResId: Int,
|
||||
open val isSelected: Boolean,
|
||||
open val destructive: Boolean
|
||||
open class BottomSheetGenericRadioAction(
|
||||
open val title: CharSequence?,
|
||||
open val description: String? = null,
|
||||
open val isSelected: Boolean
|
||||
) : VectorSharedAction {
|
||||
|
||||
fun toBottomSheetItem(): BottomSheetActionItem_ {
|
||||
return BottomSheetActionItem_().apply {
|
||||
id("action_$title")
|
||||
iconRes(iconResId)
|
||||
text(title)
|
||||
selected(isSelected)
|
||||
destructive(destructive)
|
||||
fun toRadioBottomSheetItem(): BottomSheetRadioActionItem_ {
|
||||
return BottomSheetRadioActionItem_().apply {
|
||||
id("action_${this@BottomSheetGenericRadioAction.title}")
|
||||
title(this@BottomSheetGenericRadioAction.title)
|
||||
selected(this@BottomSheetGenericRadioAction.isSelected)
|
||||
description(this@BottomSheetGenericRadioAction.description)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,6 @@
|
|||
package im.vector.app.features.roomprofile.settings
|
||||
|
||||
import im.vector.app.core.platform.VectorViewModelAction
|
||||
import org.matrix.android.sdk.api.session.room.model.GuestAccess
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
|
||||
|
||||
|
@ -26,7 +25,7 @@ sealed class RoomSettingsAction : VectorViewModelAction {
|
|||
data class SetRoomName(val newName: String) : RoomSettingsAction()
|
||||
data class SetRoomTopic(val newTopic: String) : RoomSettingsAction()
|
||||
data class SetRoomHistoryVisibility(val visibility: RoomHistoryVisibility) : RoomSettingsAction()
|
||||
data class SetRoomJoinRule(val roomJoinRule: RoomJoinRules?, val roomGuestAccess: GuestAccess?) : RoomSettingsAction()
|
||||
data class SetRoomJoinRule(val roomJoinRule: RoomJoinRules?) : RoomSettingsAction()
|
||||
|
||||
object Save : RoomSettingsAction()
|
||||
object Cancel : RoomSettingsAction()
|
||||
|
|
|
@ -26,7 +26,6 @@ import im.vector.app.features.form.formEditTextItem
|
|||
import im.vector.app.features.form.formEditableAvatarItem
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.timeline.format.RoomHistoryVisibilityFormatter
|
||||
import org.matrix.android.sdk.api.session.room.model.GuestAccess
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import javax.inject.Inject
|
||||
|
@ -127,37 +126,23 @@ class RoomSettingsController @Inject constructor(
|
|||
|
||||
private fun RoomSettingsViewState.getJoinRuleWording(): String {
|
||||
val joinRule = newRoomJoinRules.newJoinRules ?: currentRoomJoinRules
|
||||
val guestAccess = newRoomJoinRules.newGuestAccess ?: currentGuestAccess
|
||||
val resId = when (joinRule) {
|
||||
RoomJoinRules.INVITE -> {
|
||||
R.string.room_settings_room_access_entry_only_invited to null
|
||||
RoomJoinRules.INVITE -> {
|
||||
R.string.room_settings_room_access_private_title to null
|
||||
}
|
||||
RoomJoinRules.PRIVATE -> {
|
||||
R.string.room_settings_room_access_entry_unknown to joinRule.value
|
||||
RoomJoinRules.PUBLIC -> {
|
||||
R.string.room_settings_room_access_public_title to null
|
||||
}
|
||||
RoomJoinRules.PUBLIC -> {
|
||||
if (guestAccess == GuestAccess.CanJoin) {
|
||||
R.string.room_settings_room_access_entry_anyone_with_link_including_guest to null
|
||||
} else {
|
||||
R.string.room_settings_room_access_entry_anyone_with_link_apart_guest to null
|
||||
}
|
||||
}
|
||||
RoomJoinRules.KNOCK -> {
|
||||
RoomJoinRules.KNOCK -> {
|
||||
R.string.room_settings_room_access_entry_knock to null
|
||||
}
|
||||
RoomJoinRules.RESTRICTED -> {
|
||||
R.string.room_settings_room_access_entry_restricted to null
|
||||
R.string.room_settings_room_access_restricted_title to null
|
||||
}
|
||||
else -> {
|
||||
R.string.room_settings_room_access_entry_unknown to joinRule.value
|
||||
}
|
||||
}
|
||||
return if (resId.second == null) stringProvider.getString(resId.first) else stringProvider.getString(resId.first, resId.second)
|
||||
// return stringProvider.getString(if (joinRule == RoomJoinRules.INVITE) {
|
||||
// R.string.room_settings_room_access_entry_only_invited
|
||||
// } else {
|
||||
// if (guestAccess == GuestAccess.CanJoin) {
|
||||
// R.string.room_settings_room_access_entry_anyone_with_link_including_guest
|
||||
// } else {
|
||||
// R.string.room_settings_room_access_entry_anyone_with_link_apart_guest
|
||||
// }
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ class RoomSettingsFragment @Inject constructor(
|
|||
roomJoinRuleSharedActionViewModel
|
||||
.observe()
|
||||
.subscribe { action ->
|
||||
viewModel.handle(RoomSettingsAction.SetRoomJoinRule(action.roomJoinRule, action.roomGuestAccess))
|
||||
viewModel.handle(RoomSettingsAction.SetRoomJoinRule(action.roomJoinRule))
|
||||
}
|
||||
.disposeOnDestroyView()
|
||||
}
|
||||
|
@ -176,8 +176,7 @@ class RoomSettingsFragment @Inject constructor(
|
|||
|
||||
override fun onJoinRuleClicked() = withState(viewModel) { state ->
|
||||
val currentJoinRule = state.newRoomJoinRules.newJoinRules ?: state.currentRoomJoinRules
|
||||
val currentGuestAccess = state.newRoomJoinRules.newGuestAccess ?: state.currentGuestAccess
|
||||
RoomJoinRuleBottomSheet.newInstance(currentJoinRule, currentGuestAccess)
|
||||
RoomJoinRuleBottomSheet.newInstance(currentJoinRule)
|
||||
.show(childFragmentManager, "RoomJoinRuleBottomSheet")
|
||||
}
|
||||
|
||||
|
|
|
@ -198,8 +198,7 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
private fun handleSetRoomJoinRule(action: RoomSettingsAction.SetRoomJoinRule) = withState { state ->
|
||||
setState {
|
||||
copy(newRoomJoinRules = RoomSettingsViewState.NewJoinRule(
|
||||
action.roomJoinRule.takeIf { it != state.currentRoomJoinRules },
|
||||
action.roomGuestAccess.takeIf { it != state.currentGuestAccess }
|
||||
action.roomJoinRule.takeIf { it != state.currentRoomJoinRules }
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ data class RoomHistoryVisibilityBottomSheetArgs(
|
|||
val currentRoomHistoryVisibility: RoomHistoryVisibility
|
||||
) : Parcelable
|
||||
|
||||
class RoomHistoryVisibilityBottomSheet : BottomSheetGeneric<RoomHistoryVisibilityState, RoomHistoryVisibilityAction>() {
|
||||
class RoomHistoryVisibilityBottomSheet : BottomSheetGeneric<RoomHistoryVisibilityState, RoomHistoryVisibilityRadioAction>() {
|
||||
|
||||
private lateinit var roomHistoryVisibilitySharedActionViewModel: RoomHistoryVisibilitySharedActionViewModel
|
||||
@Inject lateinit var controller: RoomHistoryVisibilityController
|
||||
|
@ -43,14 +43,14 @@ class RoomHistoryVisibilityBottomSheet : BottomSheetGeneric<RoomHistoryVisibilit
|
|||
injector.inject(this)
|
||||
}
|
||||
|
||||
override fun getController(): BottomSheetGenericController<RoomHistoryVisibilityState, RoomHistoryVisibilityAction> = controller
|
||||
override fun getController(): BottomSheetGenericController<RoomHistoryVisibilityState, RoomHistoryVisibilityRadioAction> = controller
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
roomHistoryVisibilitySharedActionViewModel = activityViewModelProvider.get(RoomHistoryVisibilitySharedActionViewModel::class.java)
|
||||
}
|
||||
|
||||
override fun didSelectAction(action: RoomHistoryVisibilityAction) {
|
||||
override fun didSelectAction(action: RoomHistoryVisibilityRadioAction) {
|
||||
roomHistoryVisibilitySharedActionViewModel.post(action)
|
||||
dismiss()
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@ import javax.inject.Inject
|
|||
class RoomHistoryVisibilityController @Inject constructor(
|
||||
private val historyVisibilityFormatter: RoomHistoryVisibilityFormatter,
|
||||
private val stringProvider: StringProvider
|
||||
) : BottomSheetGenericController<RoomHistoryVisibilityState, RoomHistoryVisibilityAction>() {
|
||||
) : BottomSheetGenericController<RoomHistoryVisibilityState, RoomHistoryVisibilityRadioAction>() {
|
||||
|
||||
override fun getTitle() = stringProvider.getString(R.string.room_settings_room_read_history_rules_pref_dialog_title)
|
||||
|
||||
override fun getSubTitle() = stringProvider.getString(R.string.room_settings_room_read_history_dialog_subtitle)
|
||||
|
||||
override fun getActions(state: RoomHistoryVisibilityState): List<RoomHistoryVisibilityAction> {
|
||||
override fun getActions(state: RoomHistoryVisibilityState): List<RoomHistoryVisibilityRadioAction> {
|
||||
return listOf(
|
||||
RoomHistoryVisibility.WORLD_READABLE,
|
||||
RoomHistoryVisibility.SHARED,
|
||||
|
@ -40,10 +40,9 @@ class RoomHistoryVisibilityController @Inject constructor(
|
|||
RoomHistoryVisibility.JOINED
|
||||
)
|
||||
.map { roomHistoryVisibility ->
|
||||
RoomHistoryVisibilityAction(
|
||||
RoomHistoryVisibilityRadioAction(
|
||||
roomHistoryVisibility = roomHistoryVisibility,
|
||||
title = historyVisibilityFormatter.getSetting(roomHistoryVisibility),
|
||||
iconResId = 0,
|
||||
isSelected = roomHistoryVisibility == state.currentRoomHistoryVisibility
|
||||
)
|
||||
}
|
||||
|
|
|
@ -16,18 +16,14 @@
|
|||
|
||||
package im.vector.app.features.roomprofile.settings.historyvisibility
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import im.vector.app.core.ui.bottomsheet.BottomSheetGenericAction
|
||||
import im.vector.app.core.ui.bottomsheet.BottomSheetGenericRadioAction
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility
|
||||
|
||||
class RoomHistoryVisibilityAction(
|
||||
class RoomHistoryVisibilityRadioAction(
|
||||
val roomHistoryVisibility: RoomHistoryVisibility,
|
||||
title: String,
|
||||
@DrawableRes iconResId: Int,
|
||||
title: String?,
|
||||
isSelected: Boolean
|
||||
) : BottomSheetGenericAction(
|
||||
) : BottomSheetGenericRadioAction(
|
||||
title = title,
|
||||
iconResId = iconResId,
|
||||
isSelected = isSelected,
|
||||
destructive = false
|
||||
isSelected = isSelected
|
||||
)
|
|
@ -20,4 +20,4 @@ import im.vector.app.core.platform.VectorSharedActionViewModel
|
|||
import javax.inject.Inject
|
||||
|
||||
class RoomHistoryVisibilitySharedActionViewModel @Inject constructor()
|
||||
: VectorSharedActionViewModel<RoomHistoryVisibilityAction>()
|
||||
: VectorSharedActionViewModel<RoomHistoryVisibilityRadioAction>()
|
||||
|
|
|
@ -25,17 +25,15 @@ import im.vector.app.core.di.ScreenComponent
|
|||
import im.vector.app.core.ui.bottomsheet.BottomSheetGeneric
|
||||
import im.vector.app.core.ui.bottomsheet.BottomSheetGenericController
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.matrix.android.sdk.api.session.room.model.GuestAccess
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
|
||||
import javax.inject.Inject
|
||||
|
||||
@Parcelize
|
||||
data class RoomJoinRuleBottomSheetArgs(
|
||||
val currentRoomJoinRule: RoomJoinRules,
|
||||
val currentGuestAccess: GuestAccess?
|
||||
val currentRoomJoinRule: RoomJoinRules
|
||||
) : Parcelable
|
||||
|
||||
class RoomJoinRuleBottomSheet : BottomSheetGeneric<RoomJoinRuleState, RoomJoinRuleAction>() {
|
||||
class RoomJoinRuleBottomSheet : BottomSheetGeneric<RoomJoinRuleState, RoomJoinRuleRadioAction>() {
|
||||
|
||||
private lateinit var roomJoinRuleSharedActionViewModel: RoomJoinRuleSharedActionViewModel
|
||||
@Inject lateinit var controller: RoomJoinRuleController
|
||||
|
@ -45,14 +43,14 @@ class RoomJoinRuleBottomSheet : BottomSheetGeneric<RoomJoinRuleState, RoomJoinRu
|
|||
injector.inject(this)
|
||||
}
|
||||
|
||||
override fun getController(): BottomSheetGenericController<RoomJoinRuleState, RoomJoinRuleAction> = controller
|
||||
override fun getController(): BottomSheetGenericController<RoomJoinRuleState, RoomJoinRuleRadioAction> = controller
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
roomJoinRuleSharedActionViewModel = activityViewModelProvider.get(RoomJoinRuleSharedActionViewModel::class.java)
|
||||
}
|
||||
|
||||
override fun didSelectAction(action: RoomJoinRuleAction) {
|
||||
override fun didSelectAction(action: RoomJoinRuleRadioAction) {
|
||||
roomJoinRuleSharedActionViewModel.post(action)
|
||||
dismiss()
|
||||
}
|
||||
|
@ -63,9 +61,9 @@ class RoomJoinRuleBottomSheet : BottomSheetGeneric<RoomJoinRuleState, RoomJoinRu
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(currentRoomJoinRule: RoomJoinRules, currentGuestAccess: GuestAccess?): RoomJoinRuleBottomSheet {
|
||||
fun newInstance(currentRoomJoinRule: RoomJoinRules): RoomJoinRuleBottomSheet {
|
||||
return RoomJoinRuleBottomSheet().apply {
|
||||
setArguments(RoomJoinRuleBottomSheetArgs(currentRoomJoinRule, currentGuestAccess))
|
||||
setArguments(RoomJoinRuleBottomSheetArgs(currentRoomJoinRule))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,46 +17,46 @@
|
|||
package im.vector.app.features.roomprofile.settings.joinrule
|
||||
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.DrawableProvider
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.ui.bottomsheet.BottomSheetGenericController
|
||||
import org.matrix.android.sdk.api.session.room.model.GuestAccess
|
||||
import me.gujun.android.span.image
|
||||
import me.gujun.android.span.span
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
|
||||
import javax.inject.Inject
|
||||
|
||||
class RoomJoinRuleController @Inject constructor(
|
||||
private val stringProvider: StringProvider
|
||||
) : BottomSheetGenericController<RoomJoinRuleState, RoomJoinRuleAction>() {
|
||||
private val stringProvider: StringProvider,
|
||||
private val drawableProvider: DrawableProvider
|
||||
) : BottomSheetGenericController<RoomJoinRuleState, RoomJoinRuleRadioAction>() {
|
||||
|
||||
override fun getTitle() = stringProvider.getString(R.string.room_settings_room_access_rules_pref_dialog_title)
|
||||
|
||||
override fun getActions(state: RoomJoinRuleState): List<RoomJoinRuleAction> {
|
||||
override fun getActions(state: RoomJoinRuleState): List<RoomJoinRuleRadioAction> {
|
||||
return listOf(
|
||||
RoomJoinRuleAction(
|
||||
RoomJoinRuleRadioAction(
|
||||
roomJoinRule = RoomJoinRules.INVITE,
|
||||
roomGuestAccess = null,
|
||||
title = stringProvider.getString(R.string.room_settings_room_access_entry_only_invited),
|
||||
iconResId = 0,
|
||||
description = stringProvider.getString(R.string.room_settings_room_access_private_description),
|
||||
title = stringProvider.getString(R.string.room_settings_room_access_private_title),
|
||||
isSelected = state.currentRoomJoinRule == RoomJoinRules.INVITE
|
||||
),
|
||||
RoomJoinRuleAction(
|
||||
RoomJoinRuleRadioAction(
|
||||
roomJoinRule = RoomJoinRules.PUBLIC,
|
||||
roomGuestAccess = GuestAccess.Forbidden,
|
||||
title = stringProvider.getString(R.string.room_settings_room_access_entry_anyone_with_link_apart_guest),
|
||||
iconResId = 0,
|
||||
isSelected = state.currentRoomJoinRule == RoomJoinRules.PUBLIC && state.currentGuestAccess == GuestAccess.Forbidden
|
||||
description = stringProvider.getString(R.string.room_settings_room_access_public_description),
|
||||
title = stringProvider.getString(R.string.room_settings_room_access_public_title),
|
||||
isSelected = state.currentRoomJoinRule == RoomJoinRules.PUBLIC
|
||||
),
|
||||
RoomJoinRuleAction(
|
||||
roomJoinRule = RoomJoinRules.PUBLIC,
|
||||
roomGuestAccess = GuestAccess.CanJoin,
|
||||
title = stringProvider.getString(R.string.room_settings_room_access_entry_anyone_with_link_including_guest),
|
||||
iconResId = 0,
|
||||
isSelected = state.currentRoomJoinRule == RoomJoinRules.PUBLIC && state.currentGuestAccess == GuestAccess.CanJoin
|
||||
),
|
||||
RoomJoinRuleAction(
|
||||
RoomJoinRuleRadioAction(
|
||||
roomJoinRule = RoomJoinRules.RESTRICTED,
|
||||
roomGuestAccess = null,
|
||||
title = stringProvider.getString(R.string.room_settings_room_access_entry_restricted),
|
||||
iconResId = 0,
|
||||
description = stringProvider.getString(R.string.room_settings_room_access_restricted_description),
|
||||
title = span {
|
||||
+stringProvider.getString(R.string.room_settings_room_access_restricted_title)
|
||||
+ " "
|
||||
image(
|
||||
drawableProvider.getDrawable(R.drawable.ic_beta_pill)!!,
|
||||
"bottom"
|
||||
)
|
||||
},
|
||||
isSelected = state.currentRoomJoinRule == RoomJoinRules.RESTRICTED
|
||||
)
|
||||
)
|
||||
|
|
|
@ -16,20 +16,16 @@
|
|||
|
||||
package im.vector.app.features.roomprofile.settings.joinrule
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import im.vector.app.core.ui.bottomsheet.BottomSheetGenericAction
|
||||
import org.matrix.android.sdk.api.session.room.model.GuestAccess
|
||||
import im.vector.app.core.ui.bottomsheet.BottomSheetGenericRadioAction
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
|
||||
|
||||
class RoomJoinRuleAction(
|
||||
class RoomJoinRuleRadioAction(
|
||||
val roomJoinRule: RoomJoinRules,
|
||||
val roomGuestAccess: GuestAccess?,
|
||||
title: String,
|
||||
@DrawableRes iconResId: Int,
|
||||
title: CharSequence,
|
||||
description: String,
|
||||
isSelected: Boolean
|
||||
) : BottomSheetGenericAction(
|
||||
) : BottomSheetGenericRadioAction(
|
||||
title = title,
|
||||
iconResId = iconResId,
|
||||
isSelected = isSelected,
|
||||
destructive = false
|
||||
description = description
|
||||
)
|
|
@ -20,4 +20,4 @@ import im.vector.app.core.platform.VectorSharedActionViewModel
|
|||
import javax.inject.Inject
|
||||
|
||||
class RoomJoinRuleSharedActionViewModel @Inject constructor()
|
||||
: VectorSharedActionViewModel<RoomJoinRuleAction>()
|
||||
: VectorSharedActionViewModel<RoomJoinRuleRadioAction>()
|
||||
|
|
|
@ -26,7 +26,6 @@ data class RoomJoinRuleState(
|
|||
) : BottomSheetGenericState() {
|
||||
|
||||
constructor(args: RoomJoinRuleBottomSheetArgs) : this(
|
||||
currentRoomJoinRule = args.currentRoomJoinRule,
|
||||
currentGuestAccess = args.currentGuestAccess
|
||||
currentRoomJoinRule = args.currentRoomJoinRule
|
||||
)
|
||||
}
|
||||
|
|
12
vector/src/main/res/drawable/ic_beta_pill.xml
Normal file
12
vector/src/main/res/drawable/ic_beta_pill.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="47dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="47"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:pathData="M0,4C0,1.7909 1.7909,0 4,0H43C45.2091,0 47,1.7909 47,4V16C47,18.2091 45.2091,20 43,20H4C1.7909,20 0,18.2091 0,16V4Z"
|
||||
android:fillColor="#368BD6"/>
|
||||
<path
|
||||
android:pathData="M8.8608,14V5.2727H12.2017C12.8324,5.2727 13.3565,5.3722 13.7741,5.571C14.1946,5.767 14.5085,6.0355 14.7159,6.3764C14.9261,6.7173 15.0312,7.1037 15.0312,7.5355C15.0312,7.8906 14.9631,8.1946 14.8267,8.4474C14.6903,8.6974 14.5071,8.9006 14.277,9.0568C14.0469,9.2131 13.7898,9.3253 13.5057,9.3935V9.4787C13.8153,9.4957 14.1122,9.5909 14.3963,9.7642C14.6832,9.9347 14.9176,10.1761 15.0994,10.4886C15.2813,10.8011 15.3722,11.179 15.3722,11.6222C15.3722,12.0739 15.2628,12.4801 15.044,12.8409C14.8253,13.1989 14.4957,13.4815 14.0554,13.6889C13.6151,13.8963 13.0611,14 12.3935,14H8.8608ZM10.4418,12.679H12.142C12.7159,12.679 13.1293,12.5696 13.3821,12.3509C13.6378,12.1293 13.7656,11.8452 13.7656,11.4986C13.7656,11.2401 13.7017,11.0071 13.5739,10.7997C13.446,10.5895 13.2642,10.4247 13.0284,10.3054C12.7926,10.1832 12.5114,10.1222 12.1847,10.1222H10.4418V12.679ZM10.4418,8.9844H12.0057C12.2784,8.9844 12.5241,8.9347 12.7429,8.8352C12.9616,8.733 13.1335,8.5895 13.2585,8.4048C13.3864,8.2173 13.4503,7.9957 13.4503,7.7401C13.4503,7.402 13.331,7.1236 13.0923,6.9048C12.8565,6.6861 12.5057,6.5767 12.0398,6.5767H10.4418V8.9844ZM16.7475,14V5.2727H22.4237V6.598H18.3285V8.9673H22.1296V10.2926H18.3285V12.6747H22.4577V14H16.7475ZM23.6531,6.598V5.2727H30.6161V6.598H27.9187V14H26.3505V6.598H23.6531ZM32.0245,14H30.337L33.4094,5.2727H35.3612L38.4379,14H36.7504L34.4194,7.0625H34.3512L32.0245,14ZM32.0799,10.5781H36.6822V11.848H32.0799V10.5781Z"
|
||||
android:fillColor="#ffffff"/>
|
||||
</vector>
|
10
vector/src/main/res/drawable/ic_radio_off.xml
Normal file
10
vector/src/main/res/drawable/ic_radio_off.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12,2C6.5,2 2,6.5 2,12C2,17.5 6.5,22 12,22C17.5,22 22,17.5 22,12C22,6.5 17.5,2 12,2ZM12,20C7.6,20 4,16.4 4,12C4,7.6 7.6,4 12,4C16.4,4 20,7.6 20,12C20,16.4 16.4,20 12,20Z"
|
||||
android:fillColor="#8E99A4"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
14
vector/src/main/res/drawable/ic_radio_on.xml
Normal file
14
vector/src/main/res/drawable/ic_radio_on.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<group>
|
||||
<clip-path
|
||||
android:pathData="M12,7C9.2,7 7,9.2 7,12C7,14.8 9.2,17 12,17C14.8,17 17,14.8 17,12C17,9.2 14.8,7 12,7V7ZM12,2C6.5,2 2,6.5 2,12C2,17.5 6.5,22 12,22C17.5,22 22,17.5 22,12C22,6.5 17.5,2 12,2V2ZM12,20C7.6,20 4,16.4 4,12C4,7.6 7.6,4 12,4C16.4,4 20,7.6 20,12C20,16.4 16.4,20 12,20V20Z"
|
||||
android:fillType="evenOdd"/>
|
||||
<path
|
||||
android:pathData="M2,2h20v20h-20z"
|
||||
android:fillColor="#0DBD8B"/>
|
||||
</group>
|
||||
</vector>
|
56
vector/src/main/res/layout/item_bottom_sheet_radio.xml
Normal file
56
vector/src/main/res/layout/item_bottom_sheet_radio.xml
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:minHeight="50dp"
|
||||
android:paddingStart="@dimen/layout_horizontal_margin"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="@dimen/layout_horizontal_margin"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/radioIcon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:contentDescription="@string/a11y_checked"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:src="@drawable/ic_radio_on" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="?riotx_text_primary"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@id/radioIcon"
|
||||
app:layout_constraintTop_toTopOf="@id/radioIcon"
|
||||
tools:text="@string/space_type_private" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionDescription"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:maxLines="4"
|
||||
android:textColor="?riotx_text_secondary"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/actionTitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionTitle"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -16,6 +16,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textColor="?riotx_text_primary"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toTopOf="@+id/itemBottomSheetTitleSubtitle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -1451,9 +1451,14 @@
|
|||
<string name="room_settings_room_access_entry_only_invited">Only people who have been invited</string>
|
||||
<string name="room_settings_room_access_entry_anyone_with_link_apart_guest">Anyone who knows the room’s link, apart from guests</string>
|
||||
<string name="room_settings_room_access_entry_anyone_with_link_including_guest">Anyone who knows the room’s link, including guests</string>
|
||||
<string name="room_settings_room_access_entry_restricted">Restricted to members of a parent space</string>
|
||||
<string name="room_settings_room_access_entry_knock">Anyone can knock on the room, members can then accept or reject</string>
|
||||
<string name="room_settings_room_access_entry_unknown">Unknown access setting (%s)</string>
|
||||
<string name="room_settings_room_access_private_title">Private</string>
|
||||
<string name="room_settings_room_access_private_description">Only people invited can find and join</string>
|
||||
<string name="room_settings_room_access_public_title">Public</string>
|
||||
<string name="room_settings_room_access_public_description">Anyone can find the room and join</string>
|
||||
<string name="room_settings_room_access_restricted_title">Spaces</string>
|
||||
<string name="room_settings_room_access_restricted_description">Anyone in a space with this room can find and join it. Only admins of this room can add it to a space.</string>
|
||||
|
||||
<!-- Room settings: banned users -->
|
||||
<string name="room_settings_banned_users_title">Banned users</string>
|
||||
|
@ -3229,6 +3234,7 @@
|
|||
<string name="a11y_open_emoji_picker">Open Emoji picker</string>
|
||||
<string name="a11y_close_emoji_picker">Close Emoji picker</string>
|
||||
<string name="a11y_checked">Checked</string>
|
||||
<string name="a11y_unchecked">Unchecked</string>
|
||||
<string name="a11y_error_message_not_sent">Message not sent due to error</string>
|
||||
<string name="a11y_rule_notify_noisy">Notify with sound</string>
|
||||
<string name="a11y_rule_notify_silent">Notify without sound</string>
|
||||
|
|
Loading…
Reference in a new issue