Use MatrixConfiguration & move presence sync enabled checks out of view
This commit is contained in:
parent
4bcf31e0c2
commit
d3459d1d3d
@ -156,11 +156,6 @@ project(":library:diff-match-patch") {
|
||||
}
|
||||
}
|
||||
|
||||
// Global configuration across all modules
|
||||
ext {
|
||||
isPresenceSyncEnabled = true
|
||||
}
|
||||
|
||||
//project(":matrix-sdk-android") {
|
||||
// sonarqube {
|
||||
// properties {
|
||||
|
@ -37,7 +37,6 @@ android {
|
||||
buildConfigField "String", "GIT_SDK_REVISION_UNIX_DATE", "\"${gitRevisionUnixDate()}\""
|
||||
buildConfigField "String", "GIT_SDK_REVISION_DATE", "\"${gitRevisionDate()}\""
|
||||
|
||||
buildConfigField "Boolean", "PRESENCE_SYNC_ENABLED", "${isPresenceSyncEnabled}"
|
||||
defaultConfig {
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
|
@ -60,7 +60,11 @@ data class MatrixConfiguration(
|
||||
/**
|
||||
* RoomDisplayNameFallbackProvider to provide default room display name.
|
||||
*/
|
||||
val roomDisplayNameFallbackProvider: RoomDisplayNameFallbackProvider
|
||||
val roomDisplayNameFallbackProvider: RoomDisplayNameFallbackProvider,
|
||||
/**
|
||||
* True to enable presence information sync (if available). False to disable regardless of server setting.
|
||||
*/
|
||||
val presenceSyncEnabled: Boolean = true
|
||||
) {
|
||||
|
||||
/**
|
||||
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.sync.handler
|
||||
|
||||
import io.realm.Realm
|
||||
import org.matrix.android.sdk.BuildConfig
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.getPresenceContent
|
||||
import org.matrix.android.sdk.api.session.sync.model.PresenceSyncResponse
|
||||
@ -28,10 +29,10 @@ import org.matrix.android.sdk.internal.database.query.updateDirectUserPresence
|
||||
import org.matrix.android.sdk.internal.database.query.updateUserPresence
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class PresenceSyncHandler @Inject constructor() {
|
||||
internal class PresenceSyncHandler @Inject constructor(private val matrixConfiguration: MatrixConfiguration) {
|
||||
|
||||
fun handle(realm: Realm, presenceSyncResponse: PresenceSyncResponse?) {
|
||||
if (BuildConfig.PRESENCE_SYNC_ENABLED) {
|
||||
if (matrixConfiguration.presenceSyncEnabled) {
|
||||
presenceSyncResponse?.events
|
||||
?.filter { event -> event.type == EventType.PRESENCE }
|
||||
?.forEach { event ->
|
||||
|
@ -151,7 +151,7 @@ android {
|
||||
|
||||
buildConfigField "Boolean", "enableLocationSharing", "true"
|
||||
buildConfigField "String", "mapTilerKey", "\"fU3vlMsMn4Jb6dnEIFsx\""
|
||||
buildConfigField "Boolean", "PRESENCE_SYNC_ENABLED", "${isPresenceSyncEnabled}"
|
||||
buildConfigField "Boolean", "PRESENCE_SYNC_ENABLED", "true"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
@ -116,7 +116,8 @@ object VectorStaticModule {
|
||||
fun providesMatrixConfiguration(vectorRoomDisplayNameFallbackProvider: VectorRoomDisplayNameFallbackProvider): MatrixConfiguration {
|
||||
return MatrixConfiguration(
|
||||
applicationFlavor = BuildConfig.FLAVOR_DESCRIPTION,
|
||||
roomDisplayNameFallbackProvider = vectorRoomDisplayNameFallbackProvider
|
||||
roomDisplayNameFallbackProvider = vectorRoomDisplayNameFallbackProvider,
|
||||
presenceSyncEnabled = BuildConfig.PRESENCE_SYNC_ENABLED
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,11 @@ import org.matrix.android.sdk.api.session.presence.model.UserPresence
|
||||
@EpoxyModelClass(layout = R.layout.item_profile_matrix_item)
|
||||
abstract class ProfileMatrixItemWithPowerLevelWithPresence : ProfileMatrixItemWithPowerLevel() {
|
||||
|
||||
@EpoxyAttribute var showPresence: Boolean = true
|
||||
@EpoxyAttribute var userPresence: UserPresence? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.presenceImageView.render(userPresence = userPresence)
|
||||
holder.presenceImageView.render(showPresence, userPresence)
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class PresenceStateImageView @JvmOverloads constructor(
|
||||
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
||||
|
||||
fun render(showPresence: Boolean = true, userPresence: UserPresence?) {
|
||||
isVisible = showPresence && userPresence != null && BuildConfig.PRESENCE_SYNC_ENABLED
|
||||
isVisible = showPresence && userPresence != null
|
||||
|
||||
when (userPresence?.presence) {
|
||||
PresenceEnum.ONLINE -> {
|
||||
|
@ -206,6 +206,7 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.billcarsonfr.jsonviewer.JSonViewerDialog
|
||||
import org.commonmark.parser.Parser
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.content.ContentAttachmentData
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
@ -260,7 +261,8 @@ class TimelineFragment @Inject constructor(
|
||||
private val pillsPostProcessorFactory: PillsPostProcessor.Factory,
|
||||
private val callManager: WebRtcCallManager,
|
||||
private val voiceMessagePlaybackTracker: VoiceMessagePlaybackTracker,
|
||||
private val clock: Clock
|
||||
private val clock: Clock,
|
||||
private val matrixConfiguration: MatrixConfiguration
|
||||
) :
|
||||
VectorBaseFragment<FragmentTimelineBinding>(),
|
||||
TimelineEventController.Callback,
|
||||
@ -1611,7 +1613,7 @@ class TimelineFragment @Inject constructor(
|
||||
views.includeRoomToolbar.roomToolbarTitleView.text = roomSummary.displayName
|
||||
avatarRenderer.render(roomSummary.toMatrixItem(), views.includeRoomToolbar.roomToolbarAvatarImageView)
|
||||
views.includeRoomToolbar.roomToolbarDecorationImageView.render(roomSummary.roomEncryptionTrustLevel)
|
||||
views.includeRoomToolbar.roomToolbarPresenceImageView.render(roomSummary.isDirect, roomSummary.directUserPresence)
|
||||
views.includeRoomToolbar.roomToolbarPresenceImageView.render(roomSummary.isDirect && matrixConfiguration.presenceSyncEnabled, roomSummary.directUserPresence)
|
||||
views.includeRoomToolbar.roomToolbarPublicImageView.isVisible = roomSummary.isPublic && !roomSummary.isDirect
|
||||
}
|
||||
} else {
|
||||
|
@ -29,6 +29,7 @@ import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.timeline.format.DisplayableEventFormatter
|
||||
import im.vector.app.features.home.room.typing.TypingHelper
|
||||
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
@ -41,7 +42,8 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
||||
private val stringProvider: StringProvider,
|
||||
private val typingHelper: TypingHelper,
|
||||
private val avatarRenderer: AvatarRenderer,
|
||||
private val errorFormatter: ErrorFormatter) {
|
||||
private val errorFormatter: ErrorFormatter,
|
||||
private val matrixConfiguration: MatrixConfiguration) {
|
||||
|
||||
fun create(roomSummary: RoomSummary,
|
||||
roomChangeMembershipStates: Map<String, ChangeMembershipState>,
|
||||
@ -125,7 +127,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
||||
// We do not display shield in the room list anymore
|
||||
// .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel)
|
||||
.izPublic(roomSummary.isPublic)
|
||||
.showPresence(roomSummary.isDirect)
|
||||
.showPresence(roomSummary.isDirect && matrixConfiguration.presenceSyncEnabled)
|
||||
.userPresence(roomSummary.directUserPresence)
|
||||
.matrixItem(roomSummary.toMatrixItem())
|
||||
.lastEventTime(latestEventTime)
|
||||
|
@ -54,6 +54,7 @@ import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedA
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import timber.log.Timber
|
||||
@ -67,7 +68,8 @@ data class RoomProfileArgs(
|
||||
class RoomProfileFragment @Inject constructor(
|
||||
private val roomProfileController: RoomProfileController,
|
||||
private val avatarRenderer: AvatarRenderer,
|
||||
private val roomDetailPendingActionStore: RoomDetailPendingActionStore
|
||||
private val roomDetailPendingActionStore: RoomDetailPendingActionStore,
|
||||
private val matrixConfiguration: MatrixConfiguration
|
||||
) :
|
||||
VectorBaseFragment<FragmentMatrixProfileBinding>(),
|
||||
RoomProfileController.Callback {
|
||||
@ -222,7 +224,7 @@ class RoomProfileFragment @Inject constructor(
|
||||
avatarRenderer.render(matrixItem, views.matrixProfileToolbarAvatarImageView)
|
||||
headerViews.roomProfileDecorationImageView.render(it.roomEncryptionTrustLevel)
|
||||
views.matrixProfileDecorationToolbarAvatarImageView.render(it.roomEncryptionTrustLevel)
|
||||
headerViews.roomProfilePresenceImageView.render(it.isDirect, it.directUserPresence)
|
||||
headerViews.roomProfilePresenceImageView.render(it.isDirect && matrixConfiguration.presenceSyncEnabled, it.directUserPresence)
|
||||
headerViews.roomProfilePublicImageView.isVisible = it.isPublic && !it.isDirect
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import me.gujun.android.span.span
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
|
||||
@ -39,7 +40,8 @@ class RoomMemberListController @Inject constructor(
|
||||
private val avatarRenderer: AvatarRenderer,
|
||||
private val stringProvider: StringProvider,
|
||||
private val colorProvider: ColorProvider,
|
||||
private val roomMemberSummaryFilter: RoomMemberSummaryFilter
|
||||
private val roomMemberSummaryFilter: RoomMemberSummaryFilter,
|
||||
private val matrixConfiguration: MatrixConfiguration
|
||||
) : TypedEpoxyController<RoomMemberListViewState>() {
|
||||
|
||||
interface Callback {
|
||||
@ -122,6 +124,7 @@ class RoomMemberListController @Inject constructor(
|
||||
host: RoomMemberListController,
|
||||
data: RoomMemberListViewState) {
|
||||
val powerLabel = stringProvider.getString(powerLevelCategory.titleRes)
|
||||
val presenceSyncEnabled = matrixConfiguration.presenceSyncEnabled
|
||||
|
||||
profileMatrixItemWithPowerLevelWithPresence {
|
||||
id(roomMember.userId)
|
||||
@ -131,6 +134,7 @@ class RoomMemberListController @Inject constructor(
|
||||
clickListener {
|
||||
host.callback?.onRoomMemberClicked(roomMember)
|
||||
}
|
||||
showPresence(presenceSyncEnabled)
|
||||
userPresence(roomMember.userPresence)
|
||||
powerLevelLabel(
|
||||
span {
|
||||
|
Loading…
Reference in New Issue
Block a user