2018-01-04 19:52:25 +01:00
|
|
|
package jp.juggler.subwaytooter.util
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.text.Spannable
|
|
|
|
import android.text.SpannableStringBuilder
|
|
|
|
|
|
|
|
import jp.juggler.subwaytooter.api.entity.CustomEmoji
|
|
|
|
import jp.juggler.subwaytooter.api.entity.NicoProfileEmoji
|
|
|
|
import jp.juggler.subwaytooter.api.entity.TootAttachmentLike
|
|
|
|
import jp.juggler.subwaytooter.table.HighlightWord
|
|
|
|
|
|
|
|
@Suppress("MemberVisibilityCanPrivate")
|
|
|
|
class DecodeOptions(
|
2018-01-10 16:47:35 +01:00
|
|
|
var short : Boolean = false,
|
2018-01-04 19:52:25 +01:00
|
|
|
var decodeEmoji : Boolean = false,
|
2018-01-10 16:47:35 +01:00
|
|
|
var attachmentList : ArrayList<TootAttachmentLike>? = null,
|
2018-01-04 19:52:25 +01:00
|
|
|
var linkTag : Any? = null,
|
|
|
|
var emojiMapCustom : CustomEmoji.Map? = null,
|
|
|
|
var emojiMapProfile : NicoProfileEmoji.Map? = null
|
2018-01-10 16:47:35 +01:00
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
) {
|
|
|
|
|
|
|
|
// true if highlight found
|
|
|
|
var hasHighlight : Boolean = false
|
2018-01-10 16:47:35 +01:00
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
// highlight found with sound
|
|
|
|
var highlight_sound : HighlightWord? = null
|
|
|
|
|
|
|
|
var highlight_trie : WordTrieTree? = null
|
|
|
|
|
|
|
|
fun setShort(b : Boolean) : DecodeOptions {
|
|
|
|
short = b
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
fun setDecodeEmoji(b : Boolean) : DecodeOptions {
|
|
|
|
decodeEmoji = b
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
fun setAttachment(list_attachment : ArrayList<TootAttachmentLike>?) : DecodeOptions {
|
2018-01-04 19:52:25 +01:00
|
|
|
this.attachmentList = list_attachment
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
fun setLinkTag(link_tag : Any?) : DecodeOptions {
|
|
|
|
this.linkTag = link_tag
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
fun setCustomEmojiMap(customEmojiMap : CustomEmoji.Map?) : DecodeOptions {
|
|
|
|
this.emojiMapCustom = customEmojiMap
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
fun setProfileEmojis(profile_emojis : NicoProfileEmoji.Map?) : DecodeOptions {
|
|
|
|
this.emojiMapProfile = profile_emojis
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
fun setHighlightTrie(highlight_trie : WordTrieTree?) : DecodeOptions {
|
|
|
|
this.highlight_trie = highlight_trie
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
// decoder
|
|
|
|
|
|
|
|
fun decodeHTML(context : Context?, lcc : LinkClickContext?, html : String?) : SpannableStringBuilder {
|
|
|
|
return HTMLDecoder.decodeHTML(context, lcc, html, this)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun decodeEmoji(context : Context, s : String?) : Spannable {
|
2018-01-10 16:47:35 +01:00
|
|
|
return EmojiDecoder.decodeEmoji(context, s ?: "", this)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|