2018-01-04 19:52:25 +01:00
|
|
|
package jp.juggler.subwaytooter
|
|
|
|
|
2018-10-09 08:39:05 +02:00
|
|
|
import android.graphics.Color
|
2018-01-04 19:52:25 +01:00
|
|
|
import android.text.SpannableStringBuilder
|
|
|
|
import android.text.Spanned
|
2018-10-09 08:39:05 +02:00
|
|
|
import android.text.style.ForegroundColorSpan
|
2018-01-04 19:52:25 +01:00
|
|
|
import android.view.View
|
2018-04-30 16:01:00 +02:00
|
|
|
import android.widget.*
|
2018-01-04 19:52:25 +01:00
|
|
|
import jp.juggler.emoji.EmojiMap201709
|
|
|
|
import jp.juggler.subwaytooter.action.Action_Follow
|
|
|
|
import jp.juggler.subwaytooter.action.Action_User
|
2018-11-06 02:29:33 +01:00
|
|
|
import jp.juggler.subwaytooter.api.MisskeyAccountDetailMap
|
2018-01-04 19:52:25 +01:00
|
|
|
import jp.juggler.subwaytooter.api.entity.TootAccount
|
2018-05-08 10:25:02 +02:00
|
|
|
import jp.juggler.subwaytooter.api.entity.TootAccountRef
|
2018-01-04 19:52:25 +01:00
|
|
|
import jp.juggler.subwaytooter.api.entity.TootStatus
|
2018-11-18 03:38:52 +01:00
|
|
|
import jp.juggler.subwaytooter.span.EmojiImageSpan
|
2018-01-04 19:52:25 +01:00
|
|
|
import jp.juggler.subwaytooter.table.AcctColor
|
|
|
|
import jp.juggler.subwaytooter.table.UserRelation
|
2018-04-30 16:01:00 +02:00
|
|
|
import jp.juggler.subwaytooter.util.DecodeOptions
|
2018-01-04 19:52:25 +01:00
|
|
|
import jp.juggler.subwaytooter.util.NetworkEmojiInvalidator
|
2018-04-30 16:01:00 +02:00
|
|
|
import jp.juggler.subwaytooter.util.startMargin
|
2018-01-04 19:52:25 +01:00
|
|
|
import jp.juggler.subwaytooter.view.MyLinkMovementMethod
|
|
|
|
import jp.juggler.subwaytooter.view.MyNetworkImageView
|
2018-04-30 16:01:00 +02:00
|
|
|
import jp.juggler.subwaytooter.view.MyTextView
|
2019-01-18 16:33:53 +01:00
|
|
|
import jp.juggler.util.*
|
2018-11-18 03:38:52 +01:00
|
|
|
import org.jetbrains.anko.textColor
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
internal class ViewHolderHeaderProfile(
|
|
|
|
activity : ActMain,
|
|
|
|
viewRoot : View
|
|
|
|
) : ViewHolderHeaderBase(activity, viewRoot), View.OnClickListener, View.OnLongClickListener {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
private val ivBackground : MyNetworkImageView
|
|
|
|
private val tvCreated : TextView
|
2019-08-29 18:16:21 +02:00
|
|
|
private val tvLastStatusAt : TextView
|
2018-01-04 19:52:25 +01:00
|
|
|
private val ivAvatar : MyNetworkImageView
|
|
|
|
private val tvDisplayName : TextView
|
|
|
|
private val tvAcct : TextView
|
|
|
|
private val btnFollowing : Button
|
|
|
|
private val btnFollowers : Button
|
|
|
|
private val btnStatusCount : Button
|
|
|
|
private val tvNote : TextView
|
2018-12-10 04:46:38 +01:00
|
|
|
private val tvMisskeyExtra : TextView
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
private val btnFollow : ImageButton
|
|
|
|
private val ivFollowedBy : ImageView
|
|
|
|
private val llProfile : View
|
|
|
|
private val tvRemoteProfileWarning : TextView
|
|
|
|
private val name_invalidator : NetworkEmojiInvalidator
|
|
|
|
private val note_invalidator : NetworkEmojiInvalidator
|
2018-04-30 16:01:00 +02:00
|
|
|
private val llFields : LinearLayout
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
private var whoRef : TootAccountRef? = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
private var movedRef : TootAccountRef? = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
private val llMoved : View
|
|
|
|
private val tvMoved : TextView
|
|
|
|
private val ivMoved : MyNetworkImageView
|
|
|
|
private val tvMovedName : TextView
|
|
|
|
private val tvMovedAcct : TextView
|
|
|
|
private val btnMoved : ImageButton
|
|
|
|
private val ivMovedBy : ImageView
|
|
|
|
private val moved_caption_invalidator : NetworkEmojiInvalidator
|
|
|
|
private val moved_name_invalidator : NetworkEmojiInvalidator
|
2018-04-30 16:01:00 +02:00
|
|
|
private val density : Float
|
2018-11-18 03:38:52 +01:00
|
|
|
private val btnMore : ImageButton
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
init {
|
|
|
|
ivBackground = viewRoot.findViewById(R.id.ivBackground)
|
|
|
|
llProfile = viewRoot.findViewById(R.id.llProfile)
|
|
|
|
tvCreated = viewRoot.findViewById(R.id.tvCreated)
|
2019-08-29 18:16:21 +02:00
|
|
|
tvLastStatusAt= viewRoot.findViewById(R.id.tvLastStatusAt)
|
2018-01-04 19:52:25 +01:00
|
|
|
ivAvatar = viewRoot.findViewById(R.id.ivAvatar)
|
|
|
|
tvDisplayName = viewRoot.findViewById(R.id.tvDisplayName)
|
|
|
|
tvAcct = viewRoot.findViewById(R.id.tvAcct)
|
|
|
|
btnFollowing = viewRoot.findViewById(R.id.btnFollowing)
|
|
|
|
btnFollowers = viewRoot.findViewById(R.id.btnFollowers)
|
|
|
|
btnStatusCount = viewRoot.findViewById(R.id.btnStatusCount)
|
|
|
|
tvNote = viewRoot.findViewById(R.id.tvNote)
|
2019-01-18 16:33:53 +01:00
|
|
|
tvMisskeyExtra = viewRoot.findViewById(R.id.tvMisskeyExtra)
|
2018-11-18 03:38:52 +01:00
|
|
|
btnMore = viewRoot.findViewById(R.id.btnMore)
|
2018-01-04 19:52:25 +01:00
|
|
|
btnFollow = viewRoot.findViewById(R.id.btnFollow)
|
|
|
|
ivFollowedBy = viewRoot.findViewById(R.id.ivFollowedBy)
|
|
|
|
tvRemoteProfileWarning = viewRoot.findViewById(R.id.tvRemoteProfileWarning)
|
|
|
|
|
|
|
|
llMoved = viewRoot.findViewById(R.id.llMoved)
|
|
|
|
tvMoved = viewRoot.findViewById(R.id.tvMoved)
|
|
|
|
ivMoved = viewRoot.findViewById(R.id.ivMoved)
|
|
|
|
tvMovedName = viewRoot.findViewById(R.id.tvMovedName)
|
|
|
|
tvMovedAcct = viewRoot.findViewById(R.id.tvMovedAcct)
|
|
|
|
btnMoved = viewRoot.findViewById(R.id.btnMoved)
|
|
|
|
ivMovedBy = viewRoot.findViewById(R.id.ivMovedBy)
|
2018-04-30 16:01:00 +02:00
|
|
|
llFields = viewRoot.findViewById(R.id.llFields)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-04-30 16:01:00 +02:00
|
|
|
density = tvDisplayName.resources.displayMetrics.density
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
ivBackground.setOnClickListener(this)
|
|
|
|
btnFollowing.setOnClickListener(this)
|
|
|
|
btnFollowers.setOnClickListener(this)
|
|
|
|
btnStatusCount.setOnClickListener(this)
|
|
|
|
btnMore.setOnClickListener(this)
|
|
|
|
btnFollow.setOnClickListener(this)
|
|
|
|
tvRemoteProfileWarning.setOnClickListener(this)
|
|
|
|
|
|
|
|
btnMoved.setOnClickListener(this)
|
|
|
|
llMoved.setOnClickListener(this)
|
|
|
|
|
|
|
|
btnMoved.setOnLongClickListener(this)
|
|
|
|
btnFollow.setOnLongClickListener(this)
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
tvNote.movementMethod = MyLinkMovementMethod
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
name_invalidator = NetworkEmojiInvalidator(activity.handler, tvDisplayName)
|
|
|
|
note_invalidator = NetworkEmojiInvalidator(activity.handler, tvNote)
|
|
|
|
moved_caption_invalidator = NetworkEmojiInvalidator(activity.handler, tvMoved)
|
|
|
|
moved_name_invalidator = NetworkEmojiInvalidator(activity.handler, tvMovedName)
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
ivBackground.measureProfileBg = true
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun showColor() {
|
2019-01-18 16:33:53 +01:00
|
|
|
llProfile.setBackgroundColor(
|
|
|
|
when(val c = column.column_bg_color) {
|
|
|
|
0 -> getAttributeColor(activity, R.attr.colorProfileBackgroundMask)
|
|
|
|
else -> - 0x40000000 or (0x00ffffff and c)
|
|
|
|
}
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
private var contentColor = 0
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
override fun bindData(column : Column) {
|
2018-01-17 18:39:16 +01:00
|
|
|
super.bindData(column)
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
var f : Float
|
2018-11-06 02:29:33 +01:00
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
f = activity.timeline_font_size_sp
|
|
|
|
if(! f.isNaN()) {
|
|
|
|
tvMovedName.textSize = f
|
|
|
|
tvMoved.textSize = f
|
2018-01-17 18:39:16 +01:00
|
|
|
}
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
f = activity.acct_font_size_sp
|
|
|
|
if(! f.isNaN()) {
|
|
|
|
tvMovedAcct.textSize = f
|
|
|
|
tvCreated.textSize = f
|
2019-08-29 18:16:21 +02:00
|
|
|
tvLastStatusAt.textSize = f
|
2018-01-17 18:39:16 +01:00
|
|
|
}
|
|
|
|
|
2018-11-19 23:46:14 +01:00
|
|
|
val contentColor = column.getContentColor()
|
2018-11-18 03:38:52 +01:00
|
|
|
this.contentColor = contentColor
|
|
|
|
|
|
|
|
tvMoved.textColor = contentColor
|
|
|
|
tvMovedName.textColor = contentColor
|
|
|
|
tvDisplayName.textColor = contentColor
|
|
|
|
tvNote.textColor = contentColor
|
|
|
|
tvRemoteProfileWarning.textColor = contentColor
|
|
|
|
btnStatusCount.textColor = contentColor
|
|
|
|
btnFollowing.textColor = contentColor
|
|
|
|
btnFollowers.textColor = contentColor
|
2018-12-01 00:02:18 +01:00
|
|
|
|
|
|
|
setIconDrawableId(
|
2018-11-18 15:29:35 +01:00
|
|
|
activity,
|
|
|
|
btnMore,
|
2019-01-16 13:33:07 +01:00
|
|
|
R.drawable.ic_more,
|
2018-11-18 15:29:35 +01:00
|
|
|
color = contentColor,
|
|
|
|
alphaMultiplier = Styler.boost_alpha
|
|
|
|
)
|
2018-11-18 03:38:52 +01:00
|
|
|
|
2018-11-19 23:46:14 +01:00
|
|
|
val acctColor = column.getAcctColor()
|
2018-11-18 03:38:52 +01:00
|
|
|
tvCreated.textColor = acctColor
|
|
|
|
tvMovedAcct.textColor = acctColor
|
2019-08-29 18:16:21 +02:00
|
|
|
tvLastStatusAt.textColor = acctColor
|
2018-11-18 03:38:52 +01:00
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
val whoRef = column.who_account
|
|
|
|
this.whoRef = whoRef
|
2018-05-18 19:08:46 +02:00
|
|
|
val who = whoRef?.get()
|
2018-11-18 03:38:52 +01:00
|
|
|
|
2018-11-06 02:29:33 +01:00
|
|
|
// Misskeyの場合はNote中のUserエンティティと /api/users/show の情報量がかなり異なる
|
|
|
|
val whoDetail = if(who == null) {
|
|
|
|
null
|
|
|
|
} else {
|
|
|
|
MisskeyAccountDetailMap.get(access_info, who.id)
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
showColor()
|
|
|
|
|
|
|
|
llMoved.visibility = View.GONE
|
2018-02-16 08:52:20 +01:00
|
|
|
tvMoved.visibility = View.GONE
|
2018-04-30 16:01:00 +02:00
|
|
|
llFields.visibility = View.GONE
|
|
|
|
llFields.removeAllViews()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
if(who == null) {
|
|
|
|
tvCreated.text = ""
|
2019-08-29 18:16:21 +02:00
|
|
|
vg(tvLastStatusAt,false)
|
2018-01-04 19:52:25 +01:00
|
|
|
ivBackground.setImageDrawable(null)
|
|
|
|
ivAvatar.setImageDrawable(null)
|
|
|
|
|
|
|
|
tvAcct.text = "@"
|
|
|
|
|
|
|
|
tvDisplayName.text = ""
|
|
|
|
name_invalidator.register(null)
|
|
|
|
|
|
|
|
tvNote.text = ""
|
2019-01-18 16:33:53 +01:00
|
|
|
tvMisskeyExtra.text = ""
|
2018-01-04 19:52:25 +01:00
|
|
|
note_invalidator.register(null)
|
|
|
|
|
|
|
|
btnStatusCount.text = activity.getString(R.string.statuses) + "\n" + "?"
|
|
|
|
btnFollowing.text = activity.getString(R.string.following) + "\n" + "?"
|
|
|
|
btnFollowers.text = activity.getString(R.string.followers) + "\n" + "?"
|
|
|
|
|
|
|
|
btnFollow.setImageDrawable(null)
|
|
|
|
tvRemoteProfileWarning.visibility = View.GONE
|
|
|
|
} else {
|
2018-11-18 03:38:52 +01:00
|
|
|
tvCreated.text =
|
|
|
|
TootStatus.formatTime(tvCreated.context, (whoDetail ?: who).time_created_at, true)
|
2019-08-29 18:16:21 +02:00
|
|
|
|
|
|
|
if( vg( tvLastStatusAt,who.last_status_at > 0L)){
|
|
|
|
tvLastStatusAt.text = activity.getString(R.string.last_active)+": "+TootStatus.formatTime(activity,who.last_status_at,true)
|
|
|
|
}
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
ivBackground.setImageUrl(
|
|
|
|
activity.pref,
|
|
|
|
0f,
|
|
|
|
access_info.supplyBaseUrl(who.header_static)
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
ivAvatar.setImageUrl(
|
|
|
|
activity.pref,
|
2018-01-18 08:53:32 +01:00
|
|
|
Styler.calcIconRound(ivAvatar.layoutParams),
|
2018-01-17 18:39:16 +01:00
|
|
|
access_info.supplyBaseUrl(who.avatar_static),
|
|
|
|
access_info.supplyBaseUrl(who.avatar)
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-11-06 02:29:33 +01:00
|
|
|
val name = whoDetail?.decodeDisplayName(activity) ?: whoRef.decoded_display_name
|
2018-01-04 19:52:25 +01:00
|
|
|
tvDisplayName.text = name
|
|
|
|
name_invalidator.register(name)
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
tvRemoteProfileWarning.visibility =
|
|
|
|
if(column.access_info.isRemoteUser(who)) View.VISIBLE else View.GONE
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2019-01-18 16:33:53 +01:00
|
|
|
fun SpannableStringBuilder.appendSpan(text : String, span : Any) {
|
2018-12-10 04:46:38 +01:00
|
|
|
val start = length
|
|
|
|
append(text)
|
|
|
|
setSpan(
|
|
|
|
span,
|
|
|
|
start,
|
|
|
|
length,
|
|
|
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
2018-12-10 04:46:38 +01:00
|
|
|
|
2019-01-18 16:33:53 +01:00
|
|
|
tvAcct.text = SpannableStringBuilder().apply {
|
|
|
|
|
2018-12-10 04:46:38 +01:00
|
|
|
append("@")
|
2019-01-18 16:33:53 +01:00
|
|
|
|
2018-12-10 04:46:38 +01:00
|
|
|
append(access_info.getFullAcct(who))
|
2019-01-18 16:33:53 +01:00
|
|
|
|
2018-12-10 04:46:38 +01:00
|
|
|
if(whoDetail?.locked ?: who.locked) {
|
|
|
|
append(" ")
|
|
|
|
val info = EmojiMap201709.sShortNameToImageId["lock"]
|
|
|
|
if(info != null) {
|
|
|
|
appendSpan("locked", EmojiImageSpan(activity, info.image_id))
|
2019-01-18 16:33:53 +01:00
|
|
|
} else {
|
2018-12-10 04:46:38 +01:00
|
|
|
append("locked")
|
|
|
|
}
|
|
|
|
}
|
2019-01-18 16:33:53 +01:00
|
|
|
|
2018-12-10 04:46:38 +01:00
|
|
|
if(who.bot) {
|
|
|
|
append(" ")
|
|
|
|
val info = EmojiMap201709.sShortNameToImageId["robot_face"]
|
|
|
|
if(info != null) {
|
|
|
|
appendSpan("bot", EmojiImageSpan(activity, info.image_id))
|
2019-01-18 16:33:53 +01:00
|
|
|
} else {
|
2018-12-10 04:46:38 +01:00
|
|
|
append("bot")
|
|
|
|
}
|
2018-05-08 10:55:08 +02:00
|
|
|
}
|
|
|
|
}
|
2018-12-10 04:46:38 +01:00
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
val note = whoRef.decoded_note
|
2018-01-04 19:52:25 +01:00
|
|
|
tvNote.text = note
|
|
|
|
note_invalidator.register(note)
|
|
|
|
|
2019-01-18 16:33:53 +01:00
|
|
|
tvMisskeyExtra.text = SpannableStringBuilder().apply {
|
2018-12-10 04:46:38 +01:00
|
|
|
var s = whoDetail?.location
|
2019-01-18 16:33:53 +01:00
|
|
|
if(s?.isNotEmpty() == true) {
|
2018-12-10 04:46:38 +01:00
|
|
|
if(isNotEmpty()) append('\n')
|
|
|
|
appendSpan(
|
|
|
|
activity.getString(R.string.location),
|
|
|
|
EmojiImageSpan(
|
2019-01-18 16:33:53 +01:00
|
|
|
activity,
|
|
|
|
R.drawable.ic_location,
|
|
|
|
useColorShader = true
|
|
|
|
)
|
|
|
|
)
|
2018-12-10 04:46:38 +01:00
|
|
|
append(' ')
|
|
|
|
append(s)
|
|
|
|
}
|
|
|
|
s = whoDetail?.birthday
|
2019-01-18 16:33:53 +01:00
|
|
|
if(s?.isNotEmpty() == true) {
|
2018-12-10 04:46:38 +01:00
|
|
|
if(isNotEmpty()) append('\n')
|
|
|
|
appendSpan(
|
|
|
|
activity.getString(R.string.birthday),
|
|
|
|
EmojiImageSpan(
|
|
|
|
activity,
|
|
|
|
R.drawable.ic_cake,
|
|
|
|
useColorShader = true
|
2019-01-18 16:33:53 +01:00
|
|
|
)
|
|
|
|
)
|
2018-12-10 04:46:38 +01:00
|
|
|
append(' ')
|
|
|
|
append(s)
|
|
|
|
}
|
|
|
|
}
|
2019-01-18 16:33:53 +01:00
|
|
|
vg(tvMisskeyExtra, tvMisskeyExtra.text.isNotEmpty())
|
2018-12-10 04:46:38 +01:00
|
|
|
|
2018-11-06 02:29:33 +01:00
|
|
|
btnStatusCount.text = activity.getString(R.string.statuses) + "\n" +
|
|
|
|
(whoDetail?.statuses_count ?: who.statuses_count)
|
|
|
|
btnFollowing.text = activity.getString(R.string.following) + "\n" +
|
|
|
|
(whoDetail?.following_count ?: who.following_count)
|
|
|
|
btnFollowers.text = activity.getString(R.string.followers) + "\n" +
|
|
|
|
(whoDetail?.followers_count ?: who.followers_count)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
val relation = UserRelation.load(access_info.db_id, who.id)
|
2019-01-18 16:33:53 +01:00
|
|
|
Styler.setFollowIcon(
|
|
|
|
activity,
|
|
|
|
btnFollow,
|
|
|
|
ivFollowedBy,
|
|
|
|
relation,
|
|
|
|
who,
|
|
|
|
contentColor,
|
|
|
|
alphaMultiplier = Styler.boost_alpha
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
showMoved(who, who.movedRef)
|
2018-04-30 16:01:00 +02:00
|
|
|
|
2018-12-10 04:46:38 +01:00
|
|
|
val fields = whoDetail?.fields ?: who.fields
|
|
|
|
if(fields != null) {
|
2018-04-30 16:01:00 +02:00
|
|
|
|
|
|
|
llFields.visibility = View.VISIBLE
|
|
|
|
|
2018-12-12 07:37:23 +01:00
|
|
|
// fieldsのnameにはカスタム絵文字が適用されない
|
|
|
|
val nameDecodeOptions = DecodeOptions(
|
2018-04-30 16:01:00 +02:00
|
|
|
context = activity,
|
|
|
|
decodeEmoji = true,
|
|
|
|
linkHelper = access_info,
|
2018-05-06 13:08:06 +02:00
|
|
|
short = true,
|
2018-12-12 07:37:23 +01:00
|
|
|
emojiMapProfile = who.profile_emojis
|
2018-04-30 16:01:00 +02:00
|
|
|
)
|
2019-01-18 16:33:53 +01:00
|
|
|
|
2018-12-12 07:37:23 +01:00
|
|
|
// valueはMisskeyならMFM、MastodonならHTML
|
|
|
|
val valueDecodeOptions = DecodeOptions(
|
2018-05-06 16:14:45 +02:00
|
|
|
context = activity,
|
|
|
|
decodeEmoji = true,
|
|
|
|
linkHelper = access_info,
|
|
|
|
short = true,
|
2018-12-12 07:37:23 +01:00
|
|
|
emojiMapCustom = who.custom_emojis,
|
2018-05-06 16:14:45 +02:00
|
|
|
emojiMapProfile = who.profile_emojis
|
|
|
|
)
|
2018-11-06 02:29:33 +01:00
|
|
|
|
2018-08-22 03:05:54 +02:00
|
|
|
val nameTypeface = ActMain.timeline_font_bold
|
|
|
|
val valueTypeface = ActMain.timeline_font
|
2018-04-30 16:01:00 +02:00
|
|
|
|
2018-12-10 04:46:38 +01:00
|
|
|
for(item in fields) {
|
2018-04-30 16:01:00 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
val nameView = MyTextView(activity)
|
|
|
|
val nameLp = LinearLayout.LayoutParams(
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
|
|
|
)
|
2018-12-12 07:37:23 +01:00
|
|
|
val nameText = nameDecodeOptions.decodeEmoji(item.name)
|
2018-05-06 13:08:06 +02:00
|
|
|
val nameInvalidator = NetworkEmojiInvalidator(activity.handler, nameView)
|
|
|
|
nameInvalidator.register(nameText)
|
|
|
|
|
2018-04-30 16:01:00 +02:00
|
|
|
nameLp.topMargin = (density * 6f).toInt()
|
|
|
|
nameView.layoutParams = nameLp
|
2018-05-06 13:08:06 +02:00
|
|
|
nameView.text = nameText
|
2018-11-18 03:38:52 +01:00
|
|
|
nameView.setTextColor(contentColor)
|
2018-04-30 16:01:00 +02:00
|
|
|
nameView.typeface = nameTypeface
|
|
|
|
nameView.movementMethod = MyLinkMovementMethod
|
|
|
|
llFields.addView(nameView)
|
|
|
|
|
2018-05-06 13:08:06 +02:00
|
|
|
// 値の方はHTMLエンコードされている
|
2018-04-30 16:01:00 +02:00
|
|
|
val valueView = MyTextView(activity)
|
|
|
|
val valueLp = LinearLayout.LayoutParams(
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
|
|
|
)
|
2018-10-09 08:39:05 +02:00
|
|
|
|
2018-12-12 07:37:23 +01:00
|
|
|
val valueText = valueDecodeOptions.decodeHTML(item.value)
|
2018-11-06 02:29:33 +01:00
|
|
|
if(item.verified_at > 0L) {
|
2018-10-09 08:39:05 +02:00
|
|
|
valueText.append('\n')
|
2018-11-06 02:29:33 +01:00
|
|
|
|
2018-10-09 08:39:05 +02:00
|
|
|
val start = valueText.length
|
2018-11-06 02:29:33 +01:00
|
|
|
valueText.append(activity.getString(R.string.verified_at))
|
|
|
|
valueText.append(": ")
|
|
|
|
valueText.append(TootStatus.formatTime(activity, item.verified_at, false))
|
2018-10-09 08:39:05 +02:00
|
|
|
val end = valueText.length
|
2018-11-06 02:29:33 +01:00
|
|
|
|
2018-10-09 08:39:05 +02:00
|
|
|
valueText.setSpan(
|
|
|
|
ForegroundColorSpan(Color.BLACK or 0x7fbc99)
|
2018-11-06 02:29:33 +01:00
|
|
|
, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
2018-10-09 08:39:05 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-05-06 13:08:06 +02:00
|
|
|
val valueInvalidator = NetworkEmojiInvalidator(activity.handler, valueView)
|
|
|
|
valueInvalidator.register(valueText)
|
|
|
|
|
2018-04-30 16:01:00 +02:00
|
|
|
valueLp.startMargin = (density * 32f).toInt()
|
|
|
|
valueView.layoutParams = valueLp
|
2018-05-06 13:08:06 +02:00
|
|
|
valueView.text = valueText
|
2018-11-18 03:38:52 +01:00
|
|
|
valueView.setTextColor(contentColor)
|
2018-04-30 16:01:00 +02:00
|
|
|
valueView.typeface = valueTypeface
|
|
|
|
valueView.movementMethod = MyLinkMovementMethod
|
2018-10-09 08:39:05 +02:00
|
|
|
|
2018-11-06 02:29:33 +01:00
|
|
|
if(item.verified_at > 0L) {
|
2018-10-09 08:39:05 +02:00
|
|
|
valueView.setBackgroundColor(0x337fbc99)
|
|
|
|
}
|
|
|
|
|
2018-04-30 16:01:00 +02:00
|
|
|
llFields.addView(valueView)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
private fun showMoved(who : TootAccount, movedRef : TootAccountRef?) {
|
|
|
|
if(movedRef == null) return
|
|
|
|
this.movedRef = movedRef
|
2018-05-18 19:08:46 +02:00
|
|
|
val moved = movedRef.get()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
llMoved.visibility = View.VISIBLE
|
|
|
|
tvMoved.visibility = View.VISIBLE
|
|
|
|
|
2018-12-01 00:02:18 +01:00
|
|
|
val caption = who.decodeDisplayName(activity)
|
|
|
|
.intoStringResource(activity, R.string.account_moved_to)
|
2018-02-16 08:52:20 +01:00
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
tvMoved.text = caption
|
|
|
|
moved_caption_invalidator.register(caption)
|
|
|
|
|
|
|
|
ivMoved.layoutParams.width = activity.avatarIconSize
|
2018-01-18 08:53:32 +01:00
|
|
|
ivMoved.setImageUrl(
|
|
|
|
activity.pref,
|
|
|
|
Styler.calcIconRound(ivMoved.layoutParams),
|
2018-05-08 10:25:02 +02:00
|
|
|
access_info.supplyBaseUrl(moved.avatar_static)
|
2018-01-18 08:53:32 +01:00
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
tvMovedName.text = movedRef.decoded_display_name
|
|
|
|
moved_name_invalidator.register(movedRef.decoded_display_name)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
setAcct(tvMovedAcct, access_info.getFullAcct(moved), moved.acct)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
val relation = UserRelation.load(access_info.db_id, moved.id)
|
2019-01-18 16:33:53 +01:00
|
|
|
Styler.setFollowIcon(
|
|
|
|
activity,
|
|
|
|
btnMoved,
|
|
|
|
ivMovedBy,
|
|
|
|
relation,
|
|
|
|
moved,
|
|
|
|
contentColor,
|
|
|
|
alphaMultiplier = Styler.boost_alpha
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun setAcct(tv : TextView, acctLong : String, acctShort : String) {
|
|
|
|
val ac = AcctColor.load(acctLong)
|
2018-01-17 18:39:16 +01:00
|
|
|
tv.text = when {
|
|
|
|
AcctColor.hasNickname(ac) -> ac.nickname
|
2018-11-18 03:38:52 +01:00
|
|
|
Pref.bpShortAcctLocalUser(App1.pref) -> "@$acctShort"
|
2018-01-17 18:39:16 +01:00
|
|
|
else -> acctLong
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2019-01-20 22:04:57 +01:00
|
|
|
tv.textColor = ac.color_fg.notZero() ?: column.getAcctColor()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
2019-01-20 22:04:57 +01:00
|
|
|
tv.setBackgroundColor(ac.color_bg) // may 0
|
2018-01-04 19:52:25 +01:00
|
|
|
tv.setPaddingRelative(activity.acct_pad_lr, 0, activity.acct_pad_lr, 0)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onClick(v : View) {
|
|
|
|
|
|
|
|
when(v.id) {
|
|
|
|
|
2018-05-18 19:08:46 +02:00
|
|
|
R.id.ivBackground, R.id.tvRemoteProfileWarning -> whoRef?.get()?.url?.let { url ->
|
2018-01-04 19:52:25 +01:00
|
|
|
App1.openCustomTab(activity, url)
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.btnFollowing -> {
|
2019-08-23 01:49:20 +02:00
|
|
|
column.profile_tab = ProfileTab.Following
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column.startLoading()
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.btnFollowers -> {
|
2019-08-23 01:49:20 +02:00
|
|
|
column.profile_tab = ProfileTab.Followers
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column.startLoading()
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.btnStatusCount -> {
|
2019-08-23 01:49:20 +02:00
|
|
|
column.profile_tab = ProfileTab.Status
|
2018-01-04 19:52:25 +01:00
|
|
|
activity.app_state.saveColumnList()
|
|
|
|
column.startLoading()
|
|
|
|
}
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
R.id.btnMore -> whoRef?.let { whoRef ->
|
2019-01-18 16:33:53 +01:00
|
|
|
DlgContextMenu(activity, column, whoRef, null, null, null).show()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
R.id.btnFollow -> whoRef?.let { whoRef ->
|
2019-01-18 16:33:53 +01:00
|
|
|
DlgContextMenu(activity, column, whoRef, null, null, null).show()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
R.id.btnMoved -> movedRef?.let { movedRef ->
|
2019-01-18 16:33:53 +01:00
|
|
|
DlgContextMenu(activity, column, movedRef, null, null, null).show()
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
R.id.llMoved -> movedRef?.let { movedRef ->
|
2018-01-11 10:31:25 +01:00
|
|
|
if(access_info.isPseudo) {
|
2019-01-18 16:33:53 +01:00
|
|
|
DlgContextMenu(activity, column, movedRef, null, null, null).show()
|
2018-01-11 10:31:25 +01:00
|
|
|
} else {
|
2018-01-17 18:39:16 +01:00
|
|
|
Action_User.profileLocal(
|
|
|
|
activity,
|
|
|
|
activity.nextPosition(column),
|
|
|
|
access_info,
|
2018-05-18 19:08:46 +02:00
|
|
|
movedRef.get()
|
2018-01-17 18:39:16 +01:00
|
|
|
)
|
2018-01-11 10:31:25 +01:00
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onLongClick(v : View) : Boolean {
|
|
|
|
when(v.id) {
|
|
|
|
|
|
|
|
R.id.btnFollow -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
Action_Follow.followFromAnotherAccount(
|
|
|
|
activity,
|
|
|
|
activity.nextPosition(column),
|
|
|
|
access_info,
|
2018-05-18 19:08:46 +02:00
|
|
|
whoRef?.get()
|
2018-01-17 18:39:16 +01:00
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
R.id.btnMoved -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
Action_Follow.followFromAnotherAccount(
|
|
|
|
activity,
|
|
|
|
activity.nextPosition(column),
|
|
|
|
access_info,
|
2018-05-18 19:08:46 +02:00
|
|
|
movedRef?.get()
|
2018-01-17 18:39:16 +01:00
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
override fun onViewRecycled() {
|
|
|
|
}
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
// fun updateRelativeTime() {
|
|
|
|
// val who = whoRef?.get()
|
|
|
|
// if(who != null) {
|
|
|
|
// tvCreated.text = TootStatus.formatTime(tvCreated.context, who.time_created_at, true)
|
|
|
|
// }
|
|
|
|
// }
|
2018-01-20 07:51:14 +01:00
|
|
|
|
2019-04-04 04:10:42 +02:00
|
|
|
override fun getAccount() : TootAccountRef? = whoRef
|
|
|
|
}
|