Misskeyのバージョン判定を修正。v13の絵文字をとりあず表示する。
This commit is contained in:
parent
d63c539508
commit
38c770cd8d
|
@ -232,8 +232,7 @@ class TootInstance(parser: TootParser, src: JsonObject) {
|
||||||
val misskeyVersion: Int
|
val misskeyVersion: Int
|
||||||
get() = when {
|
get() = when {
|
||||||
instanceType != InstanceType.Misskey -> 0
|
instanceType != InstanceType.Misskey -> 0
|
||||||
versionGE(MISSKEY_VERSION_11) -> 11
|
else-> decoded_version.majorVersion ?: 10
|
||||||
else -> 10
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val canUseReference: Boolean?
|
val canUseReference: Boolean?
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package jp.juggler.subwaytooter.util
|
package jp.juggler.subwaytooter.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.SystemClock
|
|
||||||
import android.text.SpannableStringBuilder
|
import android.text.SpannableStringBuilder
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import android.util.SparseBooleanArray
|
import android.util.SparseBooleanArray
|
||||||
|
@ -18,15 +17,15 @@ import jp.juggler.subwaytooter.span.HighlightSpan
|
||||||
import jp.juggler.subwaytooter.span.NetworkEmojiSpan
|
import jp.juggler.subwaytooter.span.NetworkEmojiSpan
|
||||||
import jp.juggler.subwaytooter.span.createSpan
|
import jp.juggler.subwaytooter.span.createSpan
|
||||||
import jp.juggler.subwaytooter.table.HighlightWord
|
import jp.juggler.subwaytooter.table.HighlightWord
|
||||||
|
import jp.juggler.util.LogCategory
|
||||||
import jp.juggler.util.asciiPattern
|
import jp.juggler.util.asciiPattern
|
||||||
import jp.juggler.util.codePointBefore
|
import jp.juggler.util.codePointBefore
|
||||||
import java.util.*
|
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
object EmojiDecoder {
|
object EmojiDecoder {
|
||||||
|
|
||||||
// private val log = LogCategory("EmojiDecoder")
|
private val log = LogCategory("EmojiDecoder")
|
||||||
|
|
||||||
private const val cpColon = ':'.code
|
private const val cpColon = ':'.code
|
||||||
|
|
||||||
|
@ -383,17 +382,50 @@ object EmojiDecoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// カスタム絵文字
|
// カスタム絵文字
|
||||||
val emojiCustom = emojiMapCustom?.get(name)
|
fun CustomEmoji.customEmojiToUrl(): String = when {
|
||||||
?: App1.custom_emoji_lister.getCachedEmoji(
|
PrefB.bpDisableEmojiAnimation() && staticUrl?.isNotEmpty() == true ->
|
||||||
options.linkHelper?.apiHost?.ascii,
|
this.staticUrl
|
||||||
name
|
else ->
|
||||||
)
|
this.url
|
||||||
|
}
|
||||||
|
|
||||||
if (emojiCustom != null) {
|
fun findCustomEmojiUrl(): String? {
|
||||||
val url = when {
|
val misskeyVersion = options.linkHelper?.misskeyVersion ?: 0
|
||||||
PrefB.bpDisableEmojiAnimation() && emojiCustom.staticUrl?.isNotEmpty() == true -> emojiCustom.staticUrl
|
if (misskeyVersion >= 13) {
|
||||||
else -> emojiCustom.url
|
val cols = name.split("@", limit = 2)
|
||||||
|
val apiHostAscii = options.linkHelper?.apiHost?.ascii
|
||||||
|
|
||||||
|
// @以降にあるホスト名か、投稿者のホスト名か、閲覧先サーバのホスト名
|
||||||
|
val userHost = cols.elementAtOrNull(1)
|
||||||
|
?: options.authorDomain?.apiHost?.ascii
|
||||||
|
?: apiHostAscii
|
||||||
|
|
||||||
|
log.i("decodeEmoji Misskey13 c0=${cols.elementAtOrNull(0)} c1=${
|
||||||
|
cols.elementAtOrNull(1)
|
||||||
|
} apiHostAscii=$apiHostAscii, userHost=$userHost")
|
||||||
|
|
||||||
|
when {
|
||||||
|
apiHostAscii == null -> {
|
||||||
|
log.w("decodeEmoji Misskey13 missing apiHostAscii")
|
||||||
|
}
|
||||||
|
userHost != null && userHost != "." && userHost != apiHostAscii -> {
|
||||||
|
// 投稿者のホスト名を使う
|
||||||
|
return "https://${apiHostAscii}/emoji/${
|
||||||
|
cols.elementAtOrNull(0)
|
||||||
|
}@${userHost}.webp"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
// 閲覧先サーバの絵文字を探す
|
||||||
|
App1.custom_emoji_lister.getCachedEmoji(apiHostAscii, name)
|
||||||
|
?.let { return it.customEmojiToUrl() }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return emojiMapCustom?.get(name)?.customEmojiToUrl()
|
||||||
|
}
|
||||||
|
|
||||||
|
val url = findCustomEmojiUrl()
|
||||||
|
if (url != null) {
|
||||||
builder.addNetworkEmojiSpan(part, url)
|
builder.addNetworkEmojiSpan(part, url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,4 +168,14 @@ class VersionString(src: String?) : Comparable<VersionString> {
|
||||||
this.isEmpty || other.isEmpty -> false
|
this.isEmpty || other.isEmpty -> false
|
||||||
else -> this >= other
|
else -> this >= other
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val majorVersion: Int?
|
||||||
|
get(){
|
||||||
|
nodeList.forEach {
|
||||||
|
if(it is BigInteger){
|
||||||
|
return it.toString().toIntOrNull()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue