リファクタ。メンションの扱いを改善
This commit is contained in:
parent
6440185a6a
commit
b262645afa
|
@ -181,8 +181,8 @@ open class TootAccount(parser : TootParser, src : JSONObject) {
|
|||
this.fields = parseFields(src.optJSONArray("fields"))
|
||||
|
||||
this.bot = src.optBoolean("bot", false)
|
||||
this.isAdmin = false // TODO
|
||||
this.isCat = false // TODO
|
||||
this.isAdmin = false
|
||||
this.isCat = false
|
||||
// this.user_hides_network = src.optBoolean("user_hides_network")
|
||||
|
||||
when(parser.serviceType) {
|
||||
|
@ -308,7 +308,20 @@ open class TootAccount(parser : TootParser, src : JSONObject) {
|
|||
|
||||
@Suppress("HasPlatformType")
|
||||
val reAccountUrl =
|
||||
Pattern.compile("\\Ahttps://([A-Za-z0-9.-]+)/@([A-Za-z0-9_]+)(?:\\z|[?#])")
|
||||
Pattern.compile("\\Ahttps://([A-Za-z0-9.-]+)/@([A-Za-z0-9_]+(?:@[A-Za-z0-9][A-Za-z0-9.-]+?[A-Za-z0-9])?)(?:\\z|[?#])")
|
||||
fun getAcctFromUrl(url:String):String?{
|
||||
val m = TootAccount.reAccountUrl.matcher(url)
|
||||
if(m.find()){
|
||||
val instance = m.group(1)
|
||||
val acct = m.group(2)
|
||||
return if( acct.contains('@')){
|
||||
acct
|
||||
}else{
|
||||
"$acct@$instance"
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun parseSource(src : JSONObject?) : Source? {
|
||||
src ?: return null
|
||||
|
|
|
@ -83,8 +83,8 @@ class TootAttachment(serviceType:ServiceType,src : JSONObject) : TootAttachmentL
|
|||
remote_url = url
|
||||
text_url = url
|
||||
description = src.parseString("comment")
|
||||
focusX = 0f // TODO
|
||||
focusY = 0f // TODO
|
||||
focusX = 0f
|
||||
focusY = 0f
|
||||
isSensitive = src.optBoolean("isSensitive",false)
|
||||
}
|
||||
else->{
|
||||
|
|
|
@ -222,7 +222,7 @@ class TootStatus(parser : TootParser, src : JSONObject) : TimelineItem() {
|
|||
|
||||
this.in_reply_to_id = EntityId.Companion.mayNull(src.parseString("replyId"))
|
||||
this.in_reply_to_account_id = null
|
||||
this.mentions = null
|
||||
|
||||
this.pinned = parser.pinned
|
||||
this.muted = false
|
||||
this.language = null
|
||||
|
@ -235,11 +235,6 @@ class TootStatus(parser : TootParser, src : JSONObject) : TimelineItem() {
|
|||
|
||||
this.viaMobile = src.optBoolean("viaMobile")
|
||||
|
||||
this.decoded_mentions = HTMLDecoder.decodeMentions(
|
||||
parser.linkHelper,
|
||||
this.mentions,
|
||||
this
|
||||
) ?: EMPTY_SPANNABLE
|
||||
|
||||
// this.decoded_tags = HTMLDecoder.decodeTags( account,status.tags );
|
||||
|
||||
|
@ -262,6 +257,13 @@ class TootStatus(parser : TootParser, src : JSONObject) : TimelineItem() {
|
|||
if(options.highlight_sound != null && this.highlight_sound == null) {
|
||||
this.highlight_sound = options.highlight_sound
|
||||
}
|
||||
// Markdownのデコード結果からmentionsを読むのだった
|
||||
this.mentions = (decoded_content as? MisskeyMarkdownDecoder.SpannableStringBuilderEx)?.mentions
|
||||
this.decoded_mentions = HTMLDecoder.decodeMentions(
|
||||
parser.linkHelper,
|
||||
this.mentions,
|
||||
this
|
||||
) ?: EMPTY_SPANNABLE
|
||||
|
||||
// spoiler_text
|
||||
this.spoiler_text = reWhitespace
|
||||
|
|
|
@ -354,8 +354,10 @@ class SavedAccount(
|
|||
// implements LinkHelper
|
||||
override fun findAcctColor(url : String?) : AcctColor? {
|
||||
if(url != null) {
|
||||
val m = TootAccount.reAccountUrl.matcher(url)
|
||||
if(m.find()) return AcctColor.load(m.group(2) + "@" + m.group(1))
|
||||
val acct = TootAccount.getAcctFromUrl(url)
|
||||
if( acct != null){
|
||||
return AcctColor.load(acct)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
|
|
@ -158,7 +158,6 @@ class UserRelation{
|
|||
try {
|
||||
for(src in src_list) {
|
||||
cv.put(COL_WHO_ID, src.id.toLong())
|
||||
// TODO misskey用にidがStringのテーブルを用意する?
|
||||
cv.put(COL_FOLLOWING, src.following.b2i())
|
||||
cv.put(COL_FOLLOWED_BY, src.followed_by.b2i())
|
||||
cv.put(COL_BLOCKING, src.blocking.b2i())
|
||||
|
|
|
@ -406,10 +406,8 @@ object HTMLDecoder {
|
|||
if(! reNormalLink.matcher(display_url).find() ) {
|
||||
if(display_url.startsWith("@") && href != null && Pref.bpMentionFullAcct(App1.pref)) {
|
||||
// メンションをfull acct にする
|
||||
val m = TootAccount.reAccountUrl.matcher(href)
|
||||
if(m.find()) {
|
||||
return "@" + m.group(2) + "@" + m.group(1)
|
||||
}
|
||||
val acct = TootAccount.getAcctFromUrl(href)
|
||||
if( acct!= null) return acct
|
||||
}
|
||||
// ハッシュタグやメンションはURLの短縮表示の対象外
|
||||
return display_url
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue