Notification: display rooms and users' avatars
This commit is contained in:
parent
4f0ed402bf
commit
5a1242109d
|
@ -16,17 +16,11 @@
|
||||||
|
|
||||||
package im.vector.riotredesign
|
package im.vector.riotredesign
|
||||||
|
|
||||||
import android.app.AlarmManager
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.app.PendingIntent
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.content.ServiceConnection
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.HandlerThread
|
import android.os.HandlerThread
|
||||||
import android.os.IBinder
|
|
||||||
import androidx.core.provider.FontRequest
|
import androidx.core.provider.FontRequest
|
||||||
import androidx.core.provider.FontsContractCompat
|
import androidx.core.provider.FontsContractCompat
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
|
@ -41,14 +35,13 @@ import com.github.piasy.biv.BigImageViewer
|
||||||
import com.github.piasy.biv.loader.glide.GlideImageLoader
|
import com.github.piasy.biv.loader.glide.GlideImageLoader
|
||||||
import com.jakewharton.threetenabp.AndroidThreeTen
|
import com.jakewharton.threetenabp.AndroidThreeTen
|
||||||
import im.vector.matrix.android.api.Matrix
|
import im.vector.matrix.android.api.Matrix
|
||||||
import im.vector.matrix.android.internal.session.sync.job.SyncService
|
|
||||||
import im.vector.riotredesign.core.di.AppModule
|
import im.vector.riotredesign.core.di.AppModule
|
||||||
import im.vector.riotredesign.core.services.AlarmSyncBroadcastReceiver
|
import im.vector.riotredesign.core.services.AlarmSyncBroadcastReceiver
|
||||||
import im.vector.riotredesign.core.services.VectorSyncService
|
|
||||||
import im.vector.riotredesign.features.configuration.VectorConfiguration
|
import im.vector.riotredesign.features.configuration.VectorConfiguration
|
||||||
import im.vector.riotredesign.features.crypto.keysbackup.KeysBackupModule
|
import im.vector.riotredesign.features.crypto.keysbackup.KeysBackupModule
|
||||||
import im.vector.riotredesign.features.home.HomeModule
|
import im.vector.riotredesign.features.home.HomeModule
|
||||||
import im.vector.riotredesign.features.lifecycle.VectorActivityLifecycleCallbacks
|
import im.vector.riotredesign.features.lifecycle.VectorActivityLifecycleCallbacks
|
||||||
|
import im.vector.riotredesign.features.notifications.NotificationDrawerManager
|
||||||
import im.vector.riotredesign.features.notifications.NotificationUtils
|
import im.vector.riotredesign.features.notifications.NotificationUtils
|
||||||
import im.vector.riotredesign.features.notifications.PushRuleTriggerListener
|
import im.vector.riotredesign.features.notifications.PushRuleTriggerListener
|
||||||
import im.vector.riotredesign.features.rageshake.VectorFileLogger
|
import im.vector.riotredesign.features.rageshake.VectorFileLogger
|
||||||
|
@ -64,7 +57,6 @@ import org.koin.standalone.StandAloneContext.startKoin
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
class VectorApplication : Application() {
|
class VectorApplication : Application() {
|
||||||
|
|
||||||
|
@ -75,6 +67,8 @@ class VectorApplication : Application() {
|
||||||
|
|
||||||
val vectorConfiguration: VectorConfiguration by inject()
|
val vectorConfiguration: VectorConfiguration by inject()
|
||||||
|
|
||||||
|
private val notificationDrawerManager by inject<NotificationDrawerManager>()
|
||||||
|
|
||||||
// var slowMode = false
|
// var slowMode = false
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +125,9 @@ class VectorApplication : Application() {
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||||
fun entersBackground() {
|
fun entersBackground() {
|
||||||
Timber.i("App entered background")
|
Timber.i("App entered background") // call persistInfo
|
||||||
|
|
||||||
|
notificationDrawerManager.persistInfo()
|
||||||
|
|
||||||
if (FcmHelper.isPushSupported()) {
|
if (FcmHelper.isPushSupported()) {
|
||||||
//TODO FCM fallback
|
//TODO FCM fallback
|
||||||
|
|
|
@ -17,6 +17,7 @@ package im.vector.riotredesign.features.notifications
|
||||||
|
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import im.vector.matrix.android.api.session.Session
|
import im.vector.matrix.android.api.session.Session
|
||||||
|
import im.vector.matrix.android.api.session.content.ContentUrlResolver
|
||||||
import im.vector.matrix.android.api.session.events.model.Event
|
import im.vector.matrix.android.api.session.events.model.Event
|
||||||
import im.vector.matrix.android.api.session.events.model.EventType
|
import im.vector.matrix.android.api.session.events.model.EventType
|
||||||
import im.vector.matrix.android.api.session.events.model.toModel
|
import im.vector.matrix.android.api.session.events.model.toModel
|
||||||
|
@ -36,8 +37,8 @@ import timber.log.Timber
|
||||||
* The NotifiableEventResolver is the only aware of session/store, the NotificationDrawerManager has no knowledge of that,
|
* The NotifiableEventResolver is the only aware of session/store, the NotificationDrawerManager has no knowledge of that,
|
||||||
* this pattern allow decoupling between the object responsible of displaying notifications and the matrix sdk.
|
* this pattern allow decoupling between the object responsible of displaying notifications and the matrix sdk.
|
||||||
*/
|
*/
|
||||||
class NotifiableEventResolver(val stringProvider: StringProvider,
|
class NotifiableEventResolver(private val stringProvider: StringProvider,
|
||||||
val noticeEventFormatter: NoticeEventFormatter) {
|
private val noticeEventFormatter: NoticeEventFormatter) {
|
||||||
|
|
||||||
//private val eventDisplay = RiotEventDisplay(context)
|
//private val eventDisplay = RiotEventDisplay(context)
|
||||||
|
|
||||||
|
@ -132,26 +133,19 @@ class NotifiableEventResolver(val stringProvider: StringProvider,
|
||||||
notifiableEvent.matrixID = session.sessionParams.credentials.userId
|
notifiableEvent.matrixID = session.sessionParams.credentials.userId
|
||||||
notifiableEvent.soundName = null
|
notifiableEvent.soundName = null
|
||||||
|
|
||||||
//TODO get the avatar?
|
// Get the avatars URL
|
||||||
|
// TODO They will be not displayed the first time (known limitation)
|
||||||
|
notifiableEvent.roomAvatarPath = session.contentUrlResolver()
|
||||||
|
.resolveThumbnail(room.roomSummary?.avatarUrl,
|
||||||
|
250,
|
||||||
|
250,
|
||||||
|
ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||||
|
|
||||||
// val roomAvatarPath = session.mediaCache?.thumbnailCacheFile(room.avatarUrl, 50)
|
notifiableEvent.senderAvatarPath = session.contentUrlResolver()
|
||||||
// if (roomAvatarPath != null) {
|
.resolveThumbnail(event.senderAvatar,
|
||||||
// notifiableEvent.roomAvatarPath = roomAvatarPath.path
|
250,
|
||||||
// } else {
|
250,
|
||||||
// // prepare for the next time
|
ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||||
// session.mediaCache?.loadAvatarThumbnail(session.homeServerConfig, ImageView(context), room.avatarUrl, 50)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// room.state.getMember(event.sender)?.avatarUrl?.let {
|
|
||||||
// val size = context.resources.getDimensionPixelSize(R.dimen.profile_avatar_size)
|
|
||||||
// val userAvatarUrlPath = session.mediaCache?.thumbnailCacheFile(it, size)
|
|
||||||
// if (userAvatarUrlPath != null) {
|
|
||||||
// notifiableEvent.senderAvatarPath = userAvatarUrlPath.path
|
|
||||||
// } else {
|
|
||||||
// // prepare for the next time
|
|
||||||
// session.mediaCache?.loadAvatarThumbnail(session.homeServerConfig, ImageView(context), it, size)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return notifiableEvent
|
return notifiableEvent
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver(), KoinComponent {
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
if (intent == null || context == null) return
|
if (intent == null || context == null) return
|
||||||
|
|
||||||
Timber.v("ReplyNotificationBroadcastReceiver received : $intent")
|
Timber.v("NotificationBroadcastReceiver received : $intent")
|
||||||
|
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
NotificationUtils.SMART_REPLY_ACTION ->
|
NotificationUtils.SMART_REPLY_ACTION ->
|
||||||
|
|
Loading…
Reference in New Issue