forked from element-hq/element-android
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some notes: - Doesn't re-parse reactions already in the db to add the url field - so may need an initial sync for those. - Since some clients don't really follow MSC3746, as in: they don't use the url field, but instead only write and check the key if it is an mxc-url, support those as well. - Accordingly, initial sync is likely not required for those reactions I've seen in the wild so far, as it's common to use the mxc url also as key. Change-Id: Ib1c50315425494986fa2e794d165658220a4f342
- Loading branch information
1 parent
8855665
commit 85a26ae
Showing
19 changed files
with
160 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
.../main/java/de/spiritcroc/android/sdk/internal/database/migration/MigrateScSessionTo005.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package de.spiritcroc.android.sdk.internal.database.migration | ||
|
||
import de.spiritcroc.android.sdk.internal.util.database.ScRealmMigrator | ||
import io.realm.DynamicRealm | ||
import org.matrix.android.sdk.internal.database.model.ReactionAggregatedSummaryEntityFields | ||
|
||
internal class MigrateScSessionTo005(realm: DynamicRealm) : ScRealmMigrator(realm, 5) { | ||
|
||
override fun doMigrate(realm: DynamicRealm) { | ||
realm.schema.get("ReactionAggregatedSummaryEntity") | ||
?.addField(ReactionAggregatedSummaryEntityFields.URL, String::class.java) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
vector/src/main/java/im/vector/app/core/glide/GlideReactionUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package im.vector.app.core.glide | ||
|
||
import android.graphics.drawable.Drawable | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.core.view.isVisible | ||
import com.bumptech.glide.load.DataSource | ||
import com.bumptech.glide.load.engine.GlideException | ||
import com.bumptech.glide.request.RequestListener | ||
import com.bumptech.glide.request.target.Target | ||
import org.matrix.android.sdk.api.MatrixUrls.isMxcUrl | ||
import org.matrix.android.sdk.api.extensions.orFalse | ||
import org.matrix.android.sdk.api.session.Session | ||
import org.matrix.android.sdk.api.session.content.ContentUrlResolver | ||
import timber.log.Timber | ||
|
||
@Suppress("UNUSED_PARAMETER") | ||
fun renderReactionImage(reactionUrl: String?, | ||
reactionKey: String?, | ||
size: Int, | ||
session: Session, | ||
textView: TextView, | ||
imageView: ImageView) { | ||
val effectiveReactionUrl = when { | ||
!reactionUrl.isNullOrEmpty() -> reactionUrl | ||
reactionKey?.isMxcUrl().orFalse() -> reactionKey | ||
else -> null | ||
} | ||
if (effectiveReactionUrl.isNullOrEmpty()) { | ||
textView.isVisible = true | ||
imageView.isVisible = false | ||
} else { | ||
// Not all thumbnail providers allow GIFs! | ||
//val url = session.contentUrlResolver().resolveThumbnail(effectiveReactionUrl, size, size, ContentUrlResolver.ThumbnailMethod.SCALE) | ||
val url = session.contentUrlResolver().resolveFullSize(effectiveReactionUrl) | ||
if (url == null) { | ||
textView.isVisible = true | ||
imageView.isVisible = false | ||
} else { | ||
textView.isVisible = false | ||
imageView.isVisible = true | ||
GlideApp.with(imageView) | ||
.load(url) | ||
.centerCrop() | ||
.listener(object : RequestListener<Drawable> { | ||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean { | ||
Timber.w("Reaction image load failed for $effectiveReactionUrl: $e") | ||
textView.isVisible = true | ||
imageView.isVisible = false | ||
return false | ||
} | ||
override fun onResourceReady(resource: Drawable?, | ||
model: Any?, | ||
target: Target<Drawable>?, | ||
dataSource: DataSource?, | ||
isFirstResource: Boolean): Boolean { | ||
return false | ||
} | ||
}) | ||
.into(imageView) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters