Fix / Kick user dialog for spaces talks about rooms
This commit is contained in:
parent
9914fb2d0f
commit
d758d5c270
|
@ -0,0 +1 @@
|
||||||
|
Kick user dialog for spaces talks about rooms
|
|
@ -45,8 +45,8 @@ class RoomMemberProfileController @Inject constructor(
|
||||||
fun onJumpToReadReceiptClicked()
|
fun onJumpToReadReceiptClicked()
|
||||||
fun onMentionClicked()
|
fun onMentionClicked()
|
||||||
fun onEditPowerLevel(currentRole: Role)
|
fun onEditPowerLevel(currentRole: Role)
|
||||||
fun onKickClicked()
|
fun onKickClicked(isSpace: Boolean)
|
||||||
fun onBanClicked(isUserBanned: Boolean)
|
fun onBanClicked(isSpace: Boolean, isUserBanned: Boolean)
|
||||||
fun onCancelInviteClicked()
|
fun onCancelInviteClicked()
|
||||||
fun onInviteClicked()
|
fun onInviteClicked()
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,9 @@ class RoomMemberProfileController @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildRoomMemberActions(state: RoomMemberProfileViewState) {
|
private fun buildRoomMemberActions(state: RoomMemberProfileViewState) {
|
||||||
buildSecuritySection(state)
|
if (!state.isSpace) {
|
||||||
|
buildSecuritySection(state)
|
||||||
|
}
|
||||||
buildMoreSection(state)
|
buildMoreSection(state)
|
||||||
buildAdminSection(state)
|
buildAdminSection(state)
|
||||||
}
|
}
|
||||||
|
@ -181,7 +183,7 @@ class RoomMemberProfileController @Inject constructor(
|
||||||
action = { callback?.onOpenDmClicked() }
|
action = { callback?.onOpenDmClicked() }
|
||||||
)
|
)
|
||||||
|
|
||||||
if (state.hasReadReceipt) {
|
if (!state.isSpace && state.hasReadReceipt) {
|
||||||
buildProfileAction(
|
buildProfileAction(
|
||||||
id = "read_receipt",
|
id = "read_receipt",
|
||||||
editable = false,
|
editable = false,
|
||||||
|
@ -191,16 +193,18 @@ class RoomMemberProfileController @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
val ignoreActionTitle = state.buildIgnoreActionTitle()
|
val ignoreActionTitle = state.buildIgnoreActionTitle()
|
||||||
|
if (!state.isSpace) {
|
||||||
buildProfileAction(
|
buildProfileAction(
|
||||||
id = "mention",
|
id = "mention",
|
||||||
title = stringProvider.getString(R.string.room_participants_action_mention),
|
title = stringProvider.getString(R.string.room_participants_action_mention),
|
||||||
editable = false,
|
editable = false,
|
||||||
divider = ignoreActionTitle != null,
|
divider = ignoreActionTitle != null,
|
||||||
action = { callback?.onMentionClicked() }
|
action = { callback?.onMentionClicked() }
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val canInvite = state.actionPermissions.canInvite
|
val canInvite = state.actionPermissions.canInvite
|
||||||
|
|
||||||
if (canInvite && (membership == Membership.LEAVE || membership == Membership.KNOCK)) {
|
if (canInvite && (membership == Membership.LEAVE || membership == Membership.KNOCK)) {
|
||||||
buildProfileAction(
|
buildProfileAction(
|
||||||
id = "invite",
|
id = "invite",
|
||||||
|
@ -261,7 +265,7 @@ class RoomMemberProfileController @Inject constructor(
|
||||||
divider = canBan,
|
divider = canBan,
|
||||||
destructive = true,
|
destructive = true,
|
||||||
title = stringProvider.getString(R.string.room_participants_action_kick),
|
title = stringProvider.getString(R.string.room_participants_action_kick),
|
||||||
action = { callback?.onKickClicked() }
|
action = { callback?.onKickClicked(state.isSpace) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Membership.INVITE -> {
|
Membership.INVITE -> {
|
||||||
|
@ -288,7 +292,7 @@ class RoomMemberProfileController @Inject constructor(
|
||||||
editable = false,
|
editable = false,
|
||||||
destructive = true,
|
destructive = true,
|
||||||
title = banActionTitle,
|
title = banActionTitle,
|
||||||
action = { callback?.onBanClicked(membership == Membership.BAN) }
|
action = { callback?.onBanClicked(state.isSpace, membership == Membership.BAN) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,16 +305,16 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
val views = DialogShareQrCodeBinding.bind(view)
|
val views = DialogShareQrCodeBinding.bind(view)
|
||||||
views.itemShareQrCodeImage.setData(permalink)
|
views.itemShareQrCodeImage.setData(permalink)
|
||||||
MaterialAlertDialogBuilder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setNeutralButton(R.string.ok, null)
|
.setNeutralButton(R.string.ok, null)
|
||||||
.setPositiveButton(R.string.share_by_text) { _, _ ->
|
.setPositiveButton(R.string.share_by_text) { _, _ ->
|
||||||
startSharePlainTextIntent(
|
startSharePlainTextIntent(
|
||||||
fragment = this,
|
fragment = this,
|
||||||
activityResultLauncher = null,
|
activityResultLauncher = null,
|
||||||
chooserTitle = null,
|
chooserTitle = null,
|
||||||
text = permalink
|
text = permalink
|
||||||
)
|
)
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onAvatarClicked(view: View, userMatrixItem: MatrixItem) {
|
private fun onAvatarClicked(view: View, userMatrixItem: MatrixItem) {
|
||||||
|
@ -327,12 +327,13 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onKickClicked() {
|
override fun onKickClicked(isSpace: Boolean) {
|
||||||
ConfirmationDialogBuilder
|
ConfirmationDialogBuilder
|
||||||
.show(
|
.show(
|
||||||
activity = requireActivity(),
|
activity = requireActivity(),
|
||||||
askForReason = true,
|
askForReason = true,
|
||||||
confirmationRes = R.string.room_participants_kick_prompt_msg,
|
confirmationRes = if (isSpace) R.string.space_participants_kick_prompt_msg
|
||||||
|
else R.string.room_participants_kick_prompt_msg,
|
||||||
positiveRes = R.string.room_participants_action_kick,
|
positiveRes = R.string.room_participants_action_kick,
|
||||||
reasonHintRes = R.string.room_participants_kick_reason,
|
reasonHintRes = R.string.room_participants_kick_reason,
|
||||||
titleRes = R.string.room_participants_kick_title
|
titleRes = R.string.room_participants_kick_title
|
||||||
|
@ -341,16 +342,18 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBanClicked(isUserBanned: Boolean) {
|
override fun onBanClicked(isSpace: Boolean, isUserBanned: Boolean) {
|
||||||
val titleRes: Int
|
val titleRes: Int
|
||||||
val positiveButtonRes: Int
|
val positiveButtonRes: Int
|
||||||
val confirmationRes: Int
|
val confirmationRes: Int
|
||||||
if (isUserBanned) {
|
if (isUserBanned) {
|
||||||
confirmationRes = R.string.room_participants_unban_prompt_msg
|
confirmationRes = if (isSpace) R.string.space_participants_unban_prompt_msg
|
||||||
|
else R.string.room_participants_unban_prompt_msg
|
||||||
titleRes = R.string.room_participants_unban_title
|
titleRes = R.string.room_participants_unban_title
|
||||||
positiveButtonRes = R.string.room_participants_action_unban
|
positiveButtonRes = R.string.room_participants_action_unban
|
||||||
} else {
|
} else {
|
||||||
confirmationRes = R.string.room_participants_ban_prompt_msg
|
confirmationRes = if (isSpace) R.string.space_participants_ban_prompt_msg
|
||||||
|
else R.string.room_participants_ban_prompt_msg
|
||||||
titleRes = R.string.room_participants_ban_title
|
titleRes = R.string.room_participants_ban_title
|
||||||
positiveButtonRes = R.string.room_participants_action_ban
|
positiveButtonRes = R.string.room_participants_action_ban
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
|
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.RoomType
|
||||||
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
||||||
import org.matrix.android.sdk.api.session.room.powerlevels.Role
|
import org.matrix.android.sdk.api.session.room.powerlevels.Role
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
|
@ -86,7 +87,8 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v
|
||||||
copy(
|
copy(
|
||||||
isMine = session.myUserId == this.userId,
|
isMine = session.myUserId == this.userId,
|
||||||
userMatrixItem = room?.getRoomMember(initialState.userId)?.toMatrixItem()?.let { Success(it) } ?: Uninitialized,
|
userMatrixItem = room?.getRoomMember(initialState.userId)?.toMatrixItem()?.let { Success(it) } ?: Uninitialized,
|
||||||
hasReadReceipt = room?.getUserReadReceipt(initialState.userId) != null
|
hasReadReceipt = room?.getUserReadReceipt(initialState.userId) != null,
|
||||||
|
isSpace = room?.roomSummary()?.roomType == RoomType.SPACE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
observeIgnoredState()
|
observeIgnoredState()
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
data class RoomMemberProfileViewState(
|
data class RoomMemberProfileViewState(
|
||||||
val userId: String,
|
val userId: String,
|
||||||
val roomId: String?,
|
val roomId: String?,
|
||||||
|
val isSpace: Boolean = false,
|
||||||
val showAsMember: Boolean = false,
|
val showAsMember: Boolean = false,
|
||||||
val isMine: Boolean = false,
|
val isMine: Boolean = false,
|
||||||
val isIgnored: Async<Boolean> = Uninitialized,
|
val isIgnored: Async<Boolean> = Uninitialized,
|
||||||
|
|
|
@ -903,11 +903,14 @@
|
||||||
<string name="room_participants_kick_title">Kick user</string>
|
<string name="room_participants_kick_title">Kick user</string>
|
||||||
<string name="room_participants_kick_reason">Reason to kick</string>
|
<string name="room_participants_kick_reason">Reason to kick</string>
|
||||||
<string name="room_participants_kick_prompt_msg">kicking user will remove them from this room.\n\nTo prevent them from joining again, you should ban them instead.</string>
|
<string name="room_participants_kick_prompt_msg">kicking user will remove them from this room.\n\nTo prevent them from joining again, you should ban them instead.</string>
|
||||||
|
<string name="space_participants_kick_prompt_msg">kicking user will remove them from this space.\n\nTo prevent them from joining again, you should ban them instead.</string>
|
||||||
<string name="room_participants_ban_title">Ban user</string>
|
<string name="room_participants_ban_title">Ban user</string>
|
||||||
<string name="room_participants_ban_reason">Reason to ban</string>
|
<string name="room_participants_ban_reason">Reason to ban</string>
|
||||||
<string name="room_participants_unban_title">Unban user</string>
|
<string name="room_participants_unban_title">Unban user</string>
|
||||||
<string name="room_participants_ban_prompt_msg">Banning user will kick them from this room and prevent them from joining again.</string>
|
<string name="room_participants_ban_prompt_msg">Banning user will kick them from this room and prevent them from joining again.</string>
|
||||||
|
<string name="space_participants_ban_prompt_msg">Banning user will kick them from this space and prevent them from joining again.</string>
|
||||||
<string name="room_participants_unban_prompt_msg">Unbanning user will allow them to join the room again.</string>
|
<string name="room_participants_unban_prompt_msg">Unbanning user will allow them to join the room again.</string>
|
||||||
|
<string name="space_participants_unban_prompt_msg">Unbanning user will allow them to join the space again.</string>
|
||||||
|
|
||||||
<string name="reason_hint">Reason</string>
|
<string name="reason_hint">Reason</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue