Improve images on timeline
This commit is contained in:
parent
3e6c3d0397
commit
1948e75ece
6 changed files with 31 additions and 9 deletions
|
|
@ -1,7 +1,10 @@
|
|||
package io.element.android.x.matrix
|
||||
|
||||
import android.content.Context
|
||||
import coil.ComponentRegistry
|
||||
import io.element.android.x.core.coroutine.CoroutineDispatchers
|
||||
import io.element.android.x.matrix.media.MediaFetcher
|
||||
import io.element.android.x.matrix.media.MediaKeyer
|
||||
import io.element.android.x.matrix.session.SessionStore
|
||||
import io.element.android.x.matrix.util.logError
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
|
@ -55,6 +58,11 @@ class Matrix(
|
|||
return matrixClient.value.get()
|
||||
}
|
||||
|
||||
fun registerComponents(builder: ComponentRegistry.Builder) {
|
||||
builder.add(MediaKeyer())
|
||||
builder.add(MediaFetcher.Factory(this))
|
||||
}
|
||||
|
||||
suspend fun restoreSession() = withContext(coroutineDispatchers.io) {
|
||||
sessionStore.getLatestSession()
|
||||
?.let { session ->
|
||||
|
|
@ -88,8 +96,8 @@ class Matrix(
|
|||
withContext(coroutineDispatchers.io) {
|
||||
val client = try {
|
||||
authService.login(username, password, "ElementX", null)
|
||||
}catch (failure:Throwable){
|
||||
Timber.e(failure,"Fail login")
|
||||
} catch (failure: Throwable) {
|
||||
Timber.e(failure, "Fail login")
|
||||
throw failure
|
||||
}
|
||||
sessionStore.storeData(client.session())
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import coil.request.Options
|
|||
import io.element.android.x.matrix.Matrix
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
class MediaFetcher(
|
||||
internal class MediaFetcher(
|
||||
private val mediaResolver: MediaResolver,
|
||||
private val meta: MediaResolver.Meta,
|
||||
private val options: Options,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package io.element.android.x.matrix.media
|
||||
|
||||
import coil.key.Keyer
|
||||
import coil.request.Options
|
||||
|
||||
internal class MediaKeyer : Keyer<MediaResolver.Meta> {
|
||||
override fun key(data: MediaResolver.Meta, options: Options): String? {
|
||||
return "${data.source.url()}_${data.kind}"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue