(Misskey)外部ユーザのFieldsを表示する
This commit is contained in:
parent
9367906cd8
commit
285950dba1
|
@ -325,22 +325,22 @@ internal class ViewHolderHeaderProfile(
|
|||
|
||||
llFields.visibility = View.VISIBLE
|
||||
|
||||
val decodeOptions = DecodeOptions(
|
||||
// fieldsのnameにはカスタム絵文字が適用されない
|
||||
val nameDecodeOptions = DecodeOptions(
|
||||
context = activity,
|
||||
decodeEmoji = true,
|
||||
linkHelper = access_info,
|
||||
short = true,
|
||||
emojiMapProfile = who.profile_emojis
|
||||
)
|
||||
|
||||
// valueはMisskeyならMFM、MastodonならHTML
|
||||
val valueDecodeOptions = DecodeOptions(
|
||||
context = activity,
|
||||
decodeEmoji = true,
|
||||
linkHelper = access_info,
|
||||
short = true,
|
||||
emojiMapCustom = who.custom_emojis,
|
||||
emojiMapProfile = who.profile_emojis,
|
||||
forceHtml = true // misskey用のfieldはアプリ内部でHTMLを生成している
|
||||
)
|
||||
|
||||
// fieldsのnameにはカスタム絵文字が適用されない
|
||||
val decodeOptionsNoCustomEmoji = DecodeOptions(
|
||||
context = activity,
|
||||
decodeEmoji = true,
|
||||
linkHelper = access_info,
|
||||
short = true,
|
||||
emojiMapProfile = who.profile_emojis
|
||||
)
|
||||
|
||||
|
@ -355,7 +355,7 @@ internal class ViewHolderHeaderProfile(
|
|||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
val nameText = decodeOptionsNoCustomEmoji.decodeEmoji(item.name)
|
||||
val nameText = nameDecodeOptions.decodeEmoji(item.name)
|
||||
val nameInvalidator = NetworkEmojiInvalidator(activity.handler, nameView)
|
||||
nameInvalidator.register(nameText)
|
||||
|
||||
|
@ -374,7 +374,7 @@ internal class ViewHolderHeaderProfile(
|
|||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
|
||||
val valueText = decodeOptions.decodeHTML(item.value)
|
||||
val valueText = valueDecodeOptions.decodeHTML(item.value)
|
||||
if(item.verified_at > 0L) {
|
||||
valueText.append('\n')
|
||||
|
||||
|
|
|
@ -426,17 +426,31 @@ open class TootAccount(parser : TootParser, src : JSONObject) {
|
|||
}
|
||||
}
|
||||
|
||||
// https://github.com/syuilo/misskey/pull/3499
|
||||
// https://github.com/syuilo/misskey/pull/3586
|
||||
private fun parseMisskeyFields(src : JSONObject) : ArrayList<Field>? {
|
||||
|
||||
var dst : ArrayList<Field>? = null
|
||||
|
||||
// リモートユーザーはAP経由のフィールドが表示される
|
||||
// https://github.com/syuilo/misskey/pull/3590/files
|
||||
src.optJSONArray("fields")?.forEach { o->
|
||||
if(o !is JSONObject ) return@forEach
|
||||
//plain text
|
||||
val n = o.parseString("name") ?: return@forEach
|
||||
// mfm
|
||||
val v = o.parseString("value") ?: ""
|
||||
dst = (dst ?: ArrayList()).apply { add(Field(n, v, 0L)) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// misskeyローカルユーザーはTwitter等の連携をフィールドに表示する
|
||||
// https://github.com/syuilo/misskey/pull/3499
|
||||
// https://github.com/syuilo/misskey/pull/3586
|
||||
|
||||
fun appendField(name : String, caption : String, url : String) {
|
||||
val value =
|
||||
"""<a href="${HTMLDecoder.encodeEntity(url)}" rel="me nofollow noopener" target="_blank"><span>${HTMLDecoder.encodeEntity(
|
||||
caption
|
||||
)}</span></a>"""
|
||||
val value = """[$caption]($url)"""
|
||||
dst = (dst ?: ArrayList()).apply { add(Field(name, value, 0L)) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue