mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-16 12:00:03 +03:00
Add a presence sync enabling build config
This commit is contained in:
parent
36564d3657
commit
4bcf31e0c2
6 changed files with 30 additions and 18 deletions
|
@ -156,6 +156,11 @@ project(":library:diff-match-patch") {
|
|||
}
|
||||
}
|
||||
|
||||
// Global configuration across all modules
|
||||
ext {
|
||||
isPresenceSyncEnabled = true
|
||||
}
|
||||
|
||||
//project(":matrix-sdk-android") {
|
||||
// sonarqube {
|
||||
// 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_DATE", "\"${gitRevisionDate()}\""
|
||||
|
||||
buildConfigField "Boolean", "PRESENCE_SYNC_ENABLED", "${isPresenceSyncEnabled}"
|
||||
defaultConfig {
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
|
|
|
@ -17,6 +17,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.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.getPresenceContent
|
||||
import org.matrix.android.sdk.api.session.sync.model.PresenceSyncResponse
|
||||
|
@ -30,24 +31,26 @@ import javax.inject.Inject
|
|||
internal class PresenceSyncHandler @Inject constructor() {
|
||||
|
||||
fun handle(realm: Realm, presenceSyncResponse: PresenceSyncResponse?) {
|
||||
presenceSyncResponse?.events
|
||||
?.filter { event -> event.type == EventType.PRESENCE }
|
||||
?.forEach { event ->
|
||||
val content = event.getPresenceContent() ?: return@forEach
|
||||
val userId = event.senderId ?: return@forEach
|
||||
val userPresenceEntity = UserPresenceEntity(
|
||||
userId = userId,
|
||||
lastActiveAgo = content.lastActiveAgo,
|
||||
statusMessage = content.statusMessage,
|
||||
isCurrentlyActive = content.isCurrentlyActive,
|
||||
avatarUrl = content.avatarUrl,
|
||||
displayName = content.displayName
|
||||
).also {
|
||||
it.presence = content.presence
|
||||
}
|
||||
if (BuildConfig.PRESENCE_SYNC_ENABLED) {
|
||||
presenceSyncResponse?.events
|
||||
?.filter { event -> event.type == EventType.PRESENCE }
|
||||
?.forEach { event ->
|
||||
val content = event.getPresenceContent() ?: return@forEach
|
||||
val userId = event.senderId ?: return@forEach
|
||||
val userPresenceEntity = UserPresenceEntity(
|
||||
userId = userId,
|
||||
lastActiveAgo = content.lastActiveAgo,
|
||||
statusMessage = content.statusMessage,
|
||||
isCurrentlyActive = content.isCurrentlyActive,
|
||||
avatarUrl = content.avatarUrl,
|
||||
displayName = content.displayName
|
||||
).also {
|
||||
it.presence = content.presence
|
||||
}
|
||||
|
||||
storePresenceToDB(realm, userPresenceEntity)
|
||||
}
|
||||
storePresenceToDB(realm, userPresenceEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -151,6 +151,7 @@ android {
|
|||
|
||||
buildConfigField "Boolean", "enableLocationSharing", "true"
|
||||
buildConfigField "String", "mapTilerKey", "\"fU3vlMsMn4Jb6dnEIFsx\""
|
||||
buildConfigField "Boolean", "PRESENCE_SYNC_ENABLED", "${isPresenceSyncEnabled}"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.content.Context
|
|||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.view.isVisible
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.R
|
||||
import org.matrix.android.sdk.api.session.presence.model.PresenceEnum
|
||||
import org.matrix.android.sdk.api.session.presence.model.UserPresence
|
||||
|
@ -34,7 +35,7 @@ class PresenceStateImageView @JvmOverloads constructor(
|
|||
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
||||
|
||||
fun render(showPresence: Boolean = true, userPresence: UserPresence?) {
|
||||
isVisible = showPresence && userPresence != null
|
||||
isVisible = showPresence && userPresence != null && BuildConfig.PRESENCE_SYNC_ENABLED
|
||||
|
||||
when (userPresence?.presence) {
|
||||
PresenceEnum.ONLINE -> {
|
||||
|
|
Loading…
Add table
Reference in a new issue