mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 10:55:55 +03:00
Clean code after Benoit's review
This commit is contained in:
parent
d6e6092eea
commit
52de14b1b5
14 changed files with 41 additions and 29 deletions
|
@ -17,7 +17,7 @@ package im.vector.matrix.android.api.pushrules
|
|||
|
||||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.matrix.android.api.session.room.model.PowerLevelsContent
|
||||
import im.vector.matrix.android.api.session.room.powerlevers.PowerLevelsHelper
|
||||
import im.vector.matrix.android.api.session.room.powerlevels.PowerLevelsHelper
|
||||
|
||||
class SenderNotificationPermissionCondition(val key: String) : Condition(Kind.sender_notification_permission) {
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@ import im.vector.matrix.android.api.util.Cancelable
|
|||
import im.vector.matrix.android.api.util.JsonDict
|
||||
import im.vector.matrix.android.api.util.Optional
|
||||
|
||||
/**
|
||||
* This interface defines methods to handling profile information. It's implemented at the session level.
|
||||
*/
|
||||
interface ProfileService {
|
||||
|
||||
companion object Constants {
|
||||
|
@ -29,9 +32,25 @@ interface ProfileService {
|
|||
const val AVATAR_URL_KEY = "avatar_url"
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current dispayname for this user
|
||||
* @param userId the userId param to look for
|
||||
*
|
||||
*/
|
||||
fun getDisplayName(userId: String, matrixCallback: MatrixCallback<Optional<String>>): Cancelable
|
||||
|
||||
/**
|
||||
* Return the current avatarUrl for this user.
|
||||
* @param userId the userId param to look for
|
||||
*
|
||||
*/
|
||||
fun getAvatarUrl(userId: String, matrixCallback: MatrixCallback<Optional<String>>): Cancelable
|
||||
|
||||
/**
|
||||
* Get the combined profile information for this user.
|
||||
* This may return keys which are not limited to displayname or avatar_url.
|
||||
* @param userId the userId param to look for
|
||||
*
|
||||
*/
|
||||
fun getProfile(userId: String, matrixCallback: MatrixCallback<JsonDict>): Cancelable
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package im.vector.matrix.android.api.session.room.model
|
|||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import im.vector.matrix.android.api.session.room.powerlevers.PowerLevelsConstants
|
||||
import im.vector.matrix.android.api.session.room.powerlevels.PowerLevelsConstants
|
||||
|
||||
/**
|
||||
* Class representing the EventType.EVENT_TYPE_STATE_ROOM_POWER_LEVELS state event content.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package im.vector.matrix.android.api.session.room.powerlevers
|
||||
package im.vector.matrix.android.api.session.room.powerlevels
|
||||
|
||||
object PowerLevelsConstants {
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package im.vector.matrix.android.api.session.room.powerlevers
|
||||
package im.vector.matrix.android.api.session.room.powerlevels
|
||||
|
||||
import im.vector.matrix.android.api.session.events.model.EventType
|
||||
import im.vector.matrix.android.api.session.room.model.PowerLevelsContent
|
||||
|
@ -64,9 +64,7 @@ class PowerLevelsHelper(private val powerLevelsContent: PowerLevelsContent) {
|
|||
* @return the level
|
||||
*/
|
||||
fun notificationLevel(key: String): Int {
|
||||
val value = powerLevelsContent.notifications[key]
|
||||
?: return PowerLevelsConstants.DEFAULT_ROOM_MODERATOR_LEVEL
|
||||
return when (value) {
|
||||
return when (val value = powerLevelsContent.notifications[key]) {
|
||||
// the first implementation was a string value
|
||||
is String -> value.toInt()
|
||||
is Int -> value
|
|
@ -32,5 +32,5 @@ interface ProfileAPI {
|
|||
* @param userId the user id to fetch profile info
|
||||
*/
|
||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}")
|
||||
fun getProfile(@Path("userId") roomId: String): Call<JsonDict>
|
||||
fun getProfile(@Path("userId") userId: String): Call<JsonDict>
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package im.vector.riotx.features.roommemberprofile
|
||||
|
||||
/**
|
||||
* Transient events for RoomProfile
|
||||
* Transient events for RoomMemberProfile
|
||||
*/
|
||||
sealed class RoomMemberProfileViewEvents {
|
||||
data class Loading(val message: CharSequence) : RoomMemberProfileViewEvents()
|
||||
|
|
|
@ -33,8 +33,8 @@ import im.vector.matrix.android.api.session.room.Room
|
|||
import im.vector.matrix.android.api.session.room.members.roomMemberQueryParams
|
||||
import im.vector.matrix.android.api.session.room.model.PowerLevelsContent
|
||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
||||
import im.vector.matrix.android.api.session.room.powerlevers.PowerLevelsConstants
|
||||
import im.vector.matrix.android.api.session.room.powerlevers.PowerLevelsHelper
|
||||
import im.vector.matrix.android.api.session.room.powerlevels.PowerLevelsConstants
|
||||
import im.vector.matrix.android.api.session.room.powerlevels.PowerLevelsHelper
|
||||
import im.vector.matrix.android.api.util.MatrixItem
|
||||
import im.vector.matrix.android.api.util.toMatrixItem
|
||||
import im.vector.matrix.android.api.util.toOptional
|
||||
|
@ -196,7 +196,7 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v
|
|||
if (isIgnored) {
|
||||
session.unIgnoreUserIds(listOf(state.userId), ignoreActionCallback)
|
||||
} else {
|
||||
session.ignoreUserIds(listOf(initialState.userId), ignoreActionCallback)
|
||||
session.ignoreUserIds(listOf(state.userId), ignoreActionCallback)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,12 +42,10 @@ class RoomProfileController @Inject constructor(private val stringProvider: Stri
|
|||
if (data == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val roomSummary = data.roomSummary()
|
||||
|
||||
val roomSummary = data.roomSummary() ?: return
|
||||
// Security
|
||||
buildProfileSection(stringProvider.getString(R.string.room_profile_section_security))
|
||||
val learnMoreSubtitle = if (data.isEncrypted) {
|
||||
val learnMoreSubtitle = if (roomSummary.isEncrypted) {
|
||||
R.string.room_profile_encrypted_subtitle
|
||||
} else {
|
||||
R.string.room_profile_not_encrypted_subtitle
|
||||
|
@ -73,10 +71,10 @@ class RoomProfileController @Inject constructor(private val stringProvider: Stri
|
|||
icon = R.drawable.ic_room_profile_notification,
|
||||
action = { callback?.onNotificationsClicked() }
|
||||
)
|
||||
val numberOfMembers = roomSummary?.joinedMembersCount?.toString() ?: "-"
|
||||
val numberOfMembers = roomSummary.joinedMembersCount ?: 0
|
||||
buildProfileAction(
|
||||
id = "member_list",
|
||||
title = stringProvider.getString(R.string.room_profile_section_more_member_list, numberOfMembers),
|
||||
title = stringProvider.getQuantityString(R.plurals.room_profile_section_more_member_list, numberOfMembers, numberOfMembers),
|
||||
icon = R.drawable.ic_room_profile_member_list,
|
||||
action = { callback?.onMemberListClicked() }
|
||||
)
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package im.vector.riotx.features.roomprofile
|
||||
|
||||
import android.os.Bundle
|
||||
|
|
|
@ -64,10 +64,7 @@ class RoomProfileViewModel @AssistedInject constructor(@Assisted initialState: R
|
|||
room.rx().liveRoomSummary()
|
||||
.unwrap()
|
||||
.execute {
|
||||
copy(
|
||||
roomSummary = it,
|
||||
isEncrypted = room.isEncrypted()
|
||||
)
|
||||
copy(roomSummary = it)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,7 @@ import im.vector.matrix.android.api.session.room.model.RoomSummary
|
|||
|
||||
data class RoomProfileViewState(
|
||||
val roomId: String,
|
||||
val roomSummary: Async<RoomSummary> = Uninitialized,
|
||||
val isEncrypted: Boolean = false
|
||||
val roomSummary: Async<RoomSummary> = Uninitialized
|
||||
) : MvRxState {
|
||||
|
||||
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
|
||||
|
|
|
@ -29,8 +29,8 @@ import im.vector.matrix.android.api.session.room.members.roomMemberQueryParams
|
|||
import im.vector.matrix.android.api.session.room.model.Membership
|
||||
import im.vector.matrix.android.api.session.room.model.PowerLevelsContent
|
||||
import im.vector.matrix.android.api.session.room.model.RoomMemberSummary
|
||||
import im.vector.matrix.android.api.session.room.powerlevers.PowerLevelsConstants
|
||||
import im.vector.matrix.android.api.session.room.powerlevers.PowerLevelsHelper
|
||||
import im.vector.matrix.android.api.session.room.powerlevels.PowerLevelsConstants
|
||||
import im.vector.matrix.android.api.session.room.powerlevels.PowerLevelsHelper
|
||||
import im.vector.matrix.rx.mapOptional
|
||||
import im.vector.matrix.rx.rx
|
||||
import im.vector.matrix.rx.unwrap
|
||||
|
|
|
@ -12,7 +12,10 @@
|
|||
<string name="room_profile_section_more">More</string>
|
||||
<string name="room_profile_section_more_settings">Room settings</string>
|
||||
<string name="room_profile_section_more_notifications">Notifications</string>
|
||||
<string name="room_profile_section_more_member_list">"%1$s people"</string>
|
||||
<plurals name="room_profile_section_more_member_list">
|
||||
<item quantity="one">"One person"</item>
|
||||
<item quantity="other">"%1$d people"</item>
|
||||
</plurals>
|
||||
<string name="room_profile_section_more_uploads">Uploads</string>
|
||||
<string name="room_profile_section_more_leave">Leave Room</string>
|
||||
<string name="room_profile_leaving_room">"Leaving the room..."</string>
|
||||
|
|
Loading…
Reference in a new issue