Add a presence sync enabling build config
This commit is contained in:
parent
36564d3657
commit
4bcf31e0c2
@ -156,6 +156,11 @@ project(":library:diff-match-patch") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Global configuration across all modules
|
||||||
|
ext {
|
||||||
|
isPresenceSyncEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
//project(":matrix-sdk-android") {
|
//project(":matrix-sdk-android") {
|
||||||
// sonarqube {
|
// sonarqube {
|
||||||
// properties {
|
// properties {
|
||||||
|
1
changelog.d/5563.misc
Normal file
1
changelog.d/5563.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Add a presence sync enabling build config
|
@ -37,6 +37,7 @@ android {
|
|||||||
buildConfigField "String", "GIT_SDK_REVISION_UNIX_DATE", "\"${gitRevisionUnixDate()}\""
|
buildConfigField "String", "GIT_SDK_REVISION_UNIX_DATE", "\"${gitRevisionUnixDate()}\""
|
||||||
buildConfigField "String", "GIT_SDK_REVISION_DATE", "\"${gitRevisionDate()}\""
|
buildConfigField "String", "GIT_SDK_REVISION_DATE", "\"${gitRevisionDate()}\""
|
||||||
|
|
||||||
|
buildConfigField "Boolean", "PRESENCE_SYNC_ENABLED", "${isPresenceSyncEnabled}"
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
consumerProguardFiles 'proguard-rules.pro'
|
consumerProguardFiles 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package org.matrix.android.sdk.internal.session.sync.handler
|
package org.matrix.android.sdk.internal.session.sync.handler
|
||||||
|
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
|
import org.matrix.android.sdk.BuildConfig
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
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.events.model.getPresenceContent
|
||||||
import org.matrix.android.sdk.api.session.sync.model.PresenceSyncResponse
|
import org.matrix.android.sdk.api.session.sync.model.PresenceSyncResponse
|
||||||
@ -30,24 +31,26 @@ import javax.inject.Inject
|
|||||||
internal class PresenceSyncHandler @Inject constructor() {
|
internal class PresenceSyncHandler @Inject constructor() {
|
||||||
|
|
||||||
fun handle(realm: Realm, presenceSyncResponse: PresenceSyncResponse?) {
|
fun handle(realm: Realm, presenceSyncResponse: PresenceSyncResponse?) {
|
||||||
presenceSyncResponse?.events
|
if (BuildConfig.PRESENCE_SYNC_ENABLED) {
|
||||||
?.filter { event -> event.type == EventType.PRESENCE }
|
presenceSyncResponse?.events
|
||||||
?.forEach { event ->
|
?.filter { event -> event.type == EventType.PRESENCE }
|
||||||
val content = event.getPresenceContent() ?: return@forEach
|
?.forEach { event ->
|
||||||
val userId = event.senderId ?: return@forEach
|
val content = event.getPresenceContent() ?: return@forEach
|
||||||
val userPresenceEntity = UserPresenceEntity(
|
val userId = event.senderId ?: return@forEach
|
||||||
userId = userId,
|
val userPresenceEntity = UserPresenceEntity(
|
||||||
lastActiveAgo = content.lastActiveAgo,
|
userId = userId,
|
||||||
statusMessage = content.statusMessage,
|
lastActiveAgo = content.lastActiveAgo,
|
||||||
isCurrentlyActive = content.isCurrentlyActive,
|
statusMessage = content.statusMessage,
|
||||||
avatarUrl = content.avatarUrl,
|
isCurrentlyActive = content.isCurrentlyActive,
|
||||||
displayName = content.displayName
|
avatarUrl = content.avatarUrl,
|
||||||
).also {
|
displayName = content.displayName
|
||||||
it.presence = content.presence
|
).also {
|
||||||
}
|
it.presence = content.presence
|
||||||
|
}
|
||||||
|
|
||||||
storePresenceToDB(realm, userPresenceEntity)
|
storePresenceToDB(realm, userPresenceEntity)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,6 +151,7 @@ android {
|
|||||||
|
|
||||||
buildConfigField "Boolean", "enableLocationSharing", "true"
|
buildConfigField "Boolean", "enableLocationSharing", "true"
|
||||||
buildConfigField "String", "mapTilerKey", "\"fU3vlMsMn4Jb6dnEIFsx\""
|
buildConfigField "String", "mapTilerKey", "\"fU3vlMsMn4Jb6dnEIFsx\""
|
||||||
|
buildConfigField "Boolean", "PRESENCE_SYNC_ENABLED", "${isPresenceSyncEnabled}"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import android.content.Context
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.appcompat.widget.AppCompatImageView
|
import androidx.appcompat.widget.AppCompatImageView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import im.vector.app.BuildConfig
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import org.matrix.android.sdk.api.session.presence.model.PresenceEnum
|
import org.matrix.android.sdk.api.session.presence.model.PresenceEnum
|
||||||
import org.matrix.android.sdk.api.session.presence.model.UserPresence
|
import org.matrix.android.sdk.api.session.presence.model.UserPresence
|
||||||
@ -34,7 +35,7 @@ class PresenceStateImageView @JvmOverloads constructor(
|
|||||||
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
fun render(showPresence: Boolean = true, userPresence: UserPresence?) {
|
fun render(showPresence: Boolean = true, userPresence: UserPresence?) {
|
||||||
isVisible = showPresence && userPresence != null
|
isVisible = showPresence && userPresence != null && BuildConfig.PRESENCE_SYNC_ENABLED
|
||||||
|
|
||||||
when (userPresence?.presence) {
|
when (userPresence?.presence) {
|
||||||
PresenceEnum.ONLINE -> {
|
PresenceEnum.ONLINE -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user