(Mastodon 3.2)添付メディアのpreview_remote_urlに対応。
This commit is contained in:
parent
54f851cca1
commit
5f95d25c69
|
@ -833,6 +833,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
|||
addMoreMenu(ad, "url", ta.url, Intent.ACTION_VIEW)
|
||||
addMoreMenu(ad, "remote_url", ta.remote_url, Intent.ACTION_VIEW)
|
||||
addMoreMenu(ad, "preview_url", ta.preview_url, Intent.ACTION_VIEW)
|
||||
addMoreMenu(ad, "preview_remote_url", ta.preview_remote_url, Intent.ACTION_VIEW)
|
||||
addMoreMenu(ad, "text_url", ta.text_url, Intent.ACTION_VIEW)
|
||||
|
||||
} else if(ta is TootAttachmentMSP) {
|
||||
|
|
|
@ -1723,7 +1723,7 @@ internal class ItemViewHolder(
|
|||
TootAttachmentType.Audio -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_music))
|
||||
iv.setImageUrl(activity.pref, 0f, ta.urlForThumbnail)
|
||||
iv.setImageUrl(activity.pref, 0f, ta.urlForThumbnail(activity.pref))
|
||||
showUrl = true
|
||||
}
|
||||
|
||||
|
@ -1734,7 +1734,7 @@ internal class ItemViewHolder(
|
|||
showUrl = true
|
||||
}
|
||||
|
||||
else -> when(val urlThumbnail = ta.urlForThumbnail) {
|
||||
else -> when(val urlThumbnail = ta.urlForThumbnail(activity.pref)) {
|
||||
null, "" -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_question))
|
||||
|
|
|
@ -24,6 +24,8 @@ class TootAttachment : TootAttachmentLike {
|
|||
private const val KEY_URL = "url"
|
||||
private const val KEY_REMOTE_URL = "remote_url"
|
||||
private const val KEY_PREVIEW_URL = "preview_url"
|
||||
private const val KEY_PREVIEW_REMOTE_URL = "preview_remote_url"
|
||||
|
||||
private const val KEY_TEXT_URL = "text_url"
|
||||
private const val KEY_DESCRIPTION = "description"
|
||||
private const val KEY_IS_SENSITIVE = "isSensitive"
|
||||
|
@ -68,6 +70,8 @@ class TootAttachment : TootAttachmentLike {
|
|||
// (Misskey v11) audioのpreview_url は null
|
||||
val preview_url : String?
|
||||
|
||||
val preview_remote_url : String?
|
||||
|
||||
// Shorter URL for the image, for insertion into text (only present on local images)
|
||||
val text_url : String?
|
||||
|
||||
|
@ -89,19 +93,13 @@ class TootAttachment : TootAttachmentLike {
|
|||
///////////////////////////////
|
||||
|
||||
override fun hasUrl(url : String) : Boolean = when(url) {
|
||||
this.preview_url, this.remote_url, this.url, this.text_url -> true
|
||||
this.preview_url, this.preview_remote_url, this.remote_url, this.url, this.text_url -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
override val urlForDescription : String?
|
||||
get() = remote_url.notEmpty() ?: url
|
||||
|
||||
override val urlForThumbnail : String?
|
||||
get() = preview_url.notEmpty() ?: when(type){
|
||||
TootAttachmentType.Image -> remote_url.notEmpty() ?: url
|
||||
else -> null
|
||||
}
|
||||
|
||||
constructor(serviceType : ServiceType, src : JsonObject) {
|
||||
|
||||
when(serviceType) {
|
||||
|
@ -119,6 +117,7 @@ class TootAttachment : TootAttachmentLike {
|
|||
|
||||
url = src.string("url")
|
||||
preview_url = src.string("thumbnailUrl")
|
||||
preview_remote_url = null
|
||||
remote_url = url
|
||||
text_url = url
|
||||
|
||||
|
@ -141,6 +140,8 @@ class TootAttachment : TootAttachmentLike {
|
|||
url = src.string("url")
|
||||
remote_url = src.string("remote_url")
|
||||
preview_url = src.string("preview_url")
|
||||
preview_remote_url = src.string("preview_remote_url")
|
||||
|
||||
text_url = src.string("text_url")
|
||||
description = src.string("description")
|
||||
isSensitive = false // Misskey用のパラメータなので、マストドンでは適当な値を使ってOK
|
||||
|
@ -167,6 +168,16 @@ class TootAttachment : TootAttachmentLike {
|
|||
private fun parseType(src : String?) =
|
||||
TootAttachmentType.values().find { it.id == src }
|
||||
|
||||
override fun urlForThumbnail(pref : SharedPreferences) =
|
||||
if(Pref.bpPriorLocalURL(pref)) {
|
||||
preview_url.notEmpty() ?: preview_remote_url.notEmpty()
|
||||
} else {
|
||||
preview_remote_url.notEmpty() ?: preview_url.notEmpty()
|
||||
} ?: when(type) {
|
||||
TootAttachmentType.Image -> getLargeUrl(pref)
|
||||
else -> null
|
||||
}
|
||||
|
||||
fun getLargeUrl(pref : SharedPreferences) =
|
||||
if(Pref.bpPriorLocalURL(pref)) {
|
||||
url.notEmpty() ?: remote_url
|
||||
|
@ -192,6 +203,7 @@ class TootAttachment : TootAttachmentLike {
|
|||
put(KEY_URL, url)
|
||||
put(KEY_REMOTE_URL, remote_url)
|
||||
put(KEY_PREVIEW_URL, preview_url)
|
||||
put(KEY_PREVIEW_REMOTE_URL, preview_remote_url)
|
||||
put(KEY_TEXT_URL, text_url)
|
||||
put(KEY_DESCRIPTION, description)
|
||||
put(KEY_IS_SENSITIVE, isSensitive)
|
||||
|
@ -217,6 +229,7 @@ class TootAttachment : TootAttachmentLike {
|
|||
url = src.string(KEY_URL)
|
||||
remote_url = src.string(KEY_REMOTE_URL)
|
||||
preview_url = src.string(KEY_PREVIEW_URL)
|
||||
preview_remote_url = src.string(KEY_PREVIEW_REMOTE_URL)
|
||||
text_url = src.string(KEY_TEXT_URL)
|
||||
|
||||
type = when(val tmpType = parseType(src.string(KEY_TYPE))) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package jp.juggler.subwaytooter.api.entity
|
||||
|
||||
import android.content.SharedPreferences
|
||||
|
||||
enum class TootAttachmentType(val id:String){
|
||||
Unknown("unknown"),
|
||||
Image( "image"),
|
||||
|
@ -14,7 +16,7 @@ interface TootAttachmentLike{
|
|||
val description : String?
|
||||
|
||||
// url for thumbnail, or null or empty
|
||||
val urlForThumbnail : String?
|
||||
fun urlForThumbnail(pref:SharedPreferences) : String?
|
||||
|
||||
// url for description, or null or empty
|
||||
val urlForDescription :String?
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package jp.juggler.subwaytooter.api.entity
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import jp.juggler.util.JsonArray
|
||||
import jp.juggler.util.notBlank
|
||||
|
||||
|
@ -13,8 +14,7 @@ class TootAttachmentMSP(
|
|||
override val description : String?
|
||||
get() = null
|
||||
|
||||
override val urlForThumbnail : String?
|
||||
get() = preview_url
|
||||
override fun urlForThumbnail(pref : SharedPreferences) = preview_url
|
||||
|
||||
override val urlForDescription : String?
|
||||
get() = preview_url
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package jp.juggler.subwaytooter.api.entity
|
||||
|
||||
import jp.juggler.subwaytooter.Pref
|
||||
import jp.juggler.subwaytooter.api.TootParser
|
||||
import jp.juggler.subwaytooter.util.DecodeOptions
|
||||
import jp.juggler.subwaytooter.util.HTMLDecoder
|
||||
import jp.juggler.util.JsonObject
|
||||
import jp.juggler.util.filterNotEmpty
|
||||
|
||||
|
@ -59,7 +59,10 @@ class TootCard(
|
|||
)
|
||||
options.decodeHTML(src.content ?: "").toString()
|
||||
},
|
||||
image = src.media_attachments?.firstOrNull()?.urlForThumbnail ?: src.account.avatar_static,
|
||||
image = src.media_attachments
|
||||
?.firstOrNull()
|
||||
?.urlForThumbnail(Pref.pref(parser.context))
|
||||
?: src.account.avatar_static,
|
||||
type = "photo"
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue