2021-06-28 09:09:00 +02:00
|
|
|
package jp.juggler.subwaytooter.itemviewholder
|
2021-05-19 09:13:26 +02:00
|
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
|
import android.content.res.ColorStateList
|
2022-03-16 05:04:04 +01:00
|
|
|
import android.graphics.Typeface
|
2021-05-19 09:13:26 +02:00
|
|
|
import android.os.SystemClock
|
|
|
|
import android.text.Spannable
|
|
|
|
import android.text.SpannableString
|
|
|
|
import android.text.SpannableStringBuilder
|
2022-03-16 05:04:04 +01:00
|
|
|
import android.text.style.StyleSpan
|
2021-05-19 09:13:26 +02:00
|
|
|
import android.view.View
|
|
|
|
import android.widget.Button
|
|
|
|
import android.widget.TextView
|
2021-06-20 15:12:25 +02:00
|
|
|
import androidx.annotation.StringRes
|
2022-07-20 06:27:19 +02:00
|
|
|
import jp.juggler.subwaytooter.ActMain
|
|
|
|
import jp.juggler.subwaytooter.R
|
|
|
|
import jp.juggler.subwaytooter.Styler
|
2021-06-28 09:09:00 +02:00
|
|
|
import jp.juggler.subwaytooter.actmain.closePopup
|
2021-05-19 09:13:26 +02:00
|
|
|
import jp.juggler.subwaytooter.api.TootParser
|
|
|
|
import jp.juggler.subwaytooter.api.entity.*
|
2022-07-20 06:27:19 +02:00
|
|
|
import jp.juggler.subwaytooter.appendColorShadeIcon
|
2021-06-28 09:09:00 +02:00
|
|
|
import jp.juggler.subwaytooter.column.Column
|
|
|
|
import jp.juggler.subwaytooter.column.ColumnType
|
|
|
|
import jp.juggler.subwaytooter.column.getAcctColor
|
|
|
|
import jp.juggler.subwaytooter.column.getContentColor
|
|
|
|
import jp.juggler.subwaytooter.columnviewholder.ItemListAdapter
|
2021-05-19 09:13:26 +02:00
|
|
|
import jp.juggler.subwaytooter.drawable.PreviewCardBorder
|
2021-11-06 04:00:29 +01:00
|
|
|
import jp.juggler.subwaytooter.pref.PrefB
|
|
|
|
import jp.juggler.subwaytooter.pref.PrefI
|
2021-05-19 09:13:26 +02:00
|
|
|
import jp.juggler.subwaytooter.span.MyClickableSpan
|
|
|
|
import jp.juggler.subwaytooter.table.*
|
|
|
|
import jp.juggler.subwaytooter.util.Benchmark
|
|
|
|
import jp.juggler.subwaytooter.util.DecodeOptions
|
|
|
|
import jp.juggler.subwaytooter.view.MyNetworkImageView
|
|
|
|
import jp.juggler.util.*
|
|
|
|
import org.jetbrains.anko.backgroundColor
|
|
|
|
import org.jetbrains.anko.textColor
|
|
|
|
import kotlin.math.max
|
|
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
|
fun ItemViewHolder.bind(
|
2021-06-20 15:12:25 +02:00
|
|
|
listAdapter: ItemListAdapter,
|
2021-05-19 09:13:26 +02:00
|
|
|
column: Column,
|
|
|
|
bSimpleList: Boolean,
|
2021-06-20 15:12:25 +02:00
|
|
|
item: TimelineItem,
|
2021-05-19 09:13:26 +02:00
|
|
|
) {
|
|
|
|
val b = Benchmark(ItemViewHolder.log, "Item-bind", 40L)
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
this.listAdapter = listAdapter
|
2021-05-19 09:13:26 +02:00
|
|
|
this.column = column
|
|
|
|
this.bSimpleList = bSimpleList
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
this.accessInfo = column.accessInfo
|
2021-05-19 09:13:26 +02:00
|
|
|
|
2022-07-16 23:44:58 +02:00
|
|
|
val fontBold = ActMain.timelineFontBold
|
2021-06-20 15:12:25 +02:00
|
|
|
val fontNormal = ActMain.timelineFont
|
2021-05-19 09:13:26 +02:00
|
|
|
viewRoot.scan { v ->
|
|
|
|
try {
|
|
|
|
when (v) {
|
|
|
|
// ボタンは太字なので触らない
|
|
|
|
is CountImageButton -> {
|
|
|
|
}
|
|
|
|
// ボタンは太字なので触らない
|
|
|
|
is Button -> {
|
|
|
|
}
|
|
|
|
|
|
|
|
is TextView -> v.typeface = when {
|
|
|
|
v === tvName ||
|
2021-11-12 20:41:19 +01:00
|
|
|
v === tvFollowerName ||
|
|
|
|
v === tvBoosted ||
|
|
|
|
v === tvReply ||
|
|
|
|
v === tvTrendTagCount ||
|
|
|
|
v === tvTrendTagName ||
|
|
|
|
v === tvConversationIconsMore ||
|
|
|
|
v === tvConversationParticipants ||
|
|
|
|
v === tvFilterPhrase -> fontBold
|
2021-06-20 15:12:25 +02:00
|
|
|
else -> fontNormal
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ex: Throwable) {
|
|
|
|
ItemViewHolder.log.trace(ex)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bSimpleList) {
|
|
|
|
|
|
|
|
viewRoot.setOnTouchListener { _, ev ->
|
|
|
|
// ポップアップを閉じた時にクリックでリストを触ったことになってしまう不具合の回避
|
|
|
|
val now = SystemClock.elapsedRealtime()
|
|
|
|
// ポップアップを閉じた直後はタッチダウンを無視する
|
2021-06-20 15:12:25 +02:00
|
|
|
if (now - StatusButtonsPopup.lastPopupClose >= 30L) {
|
2021-05-19 09:13:26 +02:00
|
|
|
false
|
|
|
|
} else {
|
|
|
|
val action = ev.action
|
|
|
|
ItemViewHolder.log.d("onTouchEvent action=$action")
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
viewRoot.setOnClickListener { viewClicked ->
|
2021-06-28 09:09:00 +02:00
|
|
|
activity.closePopup()
|
2021-06-20 15:12:25 +02:00
|
|
|
statusShowing?.let { status ->
|
2021-05-19 09:13:26 +02:00
|
|
|
val popup =
|
|
|
|
StatusButtonsPopup(activity, column, bSimpleList, this@bind)
|
2021-06-28 09:09:00 +02:00
|
|
|
activity.popupStatusButtons = popup
|
2021-05-19 09:13:26 +02:00
|
|
|
popup.show(
|
2021-06-20 15:12:25 +02:00
|
|
|
listAdapter.columnVh.listView,
|
2021-05-19 09:13:26 +02:00
|
|
|
viewClicked,
|
|
|
|
status,
|
|
|
|
item as? TootNotification
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
llButtonBar.visibility = View.GONE
|
2021-06-20 15:12:25 +02:00
|
|
|
this.buttonsForStatus = null
|
2021-05-19 09:13:26 +02:00
|
|
|
} else {
|
|
|
|
viewRoot.isClickable = false
|
|
|
|
llButtonBar.visibility = View.VISIBLE
|
2021-06-20 15:12:25 +02:00
|
|
|
this.buttonsForStatus = StatusButtons(
|
2021-05-19 09:13:26 +02:00
|
|
|
activity,
|
|
|
|
column,
|
|
|
|
false,
|
|
|
|
statusButtonsViewHolder,
|
|
|
|
this
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
this.statusShowing = null
|
|
|
|
this.statusReply = null
|
|
|
|
this.statusAccount = null
|
|
|
|
this.boostAccount = null
|
|
|
|
this.followAccount = null
|
|
|
|
this.boostTime = 0L
|
2021-05-19 09:13:26 +02:00
|
|
|
this.viewRoot.setBackgroundColor(0)
|
|
|
|
this.boostedAction = defaultBoostedAction
|
|
|
|
|
|
|
|
llOpenSticker.visibility = View.GONE
|
|
|
|
llBoosted.visibility = View.GONE
|
|
|
|
llReply.visibility = View.GONE
|
|
|
|
llFollow.visibility = View.GONE
|
|
|
|
llStatus.visibility = View.GONE
|
|
|
|
llSearchTag.visibility = View.GONE
|
|
|
|
btnGapHead.visibility = View.GONE
|
|
|
|
btnGapTail.visibility = View.GONE
|
|
|
|
llList.visibility = View.GONE
|
|
|
|
llFollowRequest.visibility = View.GONE
|
|
|
|
tvMessageHolder.visibility = View.GONE
|
|
|
|
llTrendTag.visibility = View.GONE
|
|
|
|
llFilter.visibility = View.GONE
|
|
|
|
tvMediaDescription.visibility = View.GONE
|
|
|
|
llCardOuter.visibility = View.GONE
|
|
|
|
tvCardText.visibility = View.GONE
|
|
|
|
flCardImage.visibility = View.GONE
|
|
|
|
llConversationIcons.visibility = View.GONE
|
|
|
|
|
|
|
|
removeExtraView()
|
|
|
|
|
|
|
|
var c: Int
|
|
|
|
c = column.getContentColor()
|
2021-06-20 15:12:25 +02:00
|
|
|
this.contentColor = c
|
|
|
|
this.contentColorCsl = ColorStateList.valueOf(c)
|
2021-05-19 09:13:26 +02:00
|
|
|
|
|
|
|
tvBoosted.setTextColor(c)
|
|
|
|
tvReply.setTextColor(c)
|
|
|
|
tvFollowerName.setTextColor(c)
|
|
|
|
tvName.setTextColor(c)
|
|
|
|
tvMentions.setTextColor(c)
|
|
|
|
tvContentWarning.setTextColor(c)
|
|
|
|
tvContent.setTextColor(c)
|
|
|
|
//NSFWは文字色固定 btnShowMedia.setTextColor( c );
|
|
|
|
tvApplication.setTextColor(c)
|
|
|
|
tvMessageHolder.setTextColor(c)
|
|
|
|
tvTrendTagName.setTextColor(c)
|
|
|
|
tvTrendTagCount.setTextColor(c)
|
|
|
|
cvTagHistory.setColor(c)
|
|
|
|
tvFilterPhrase.setTextColor(c)
|
|
|
|
tvMediaDescription.setTextColor(c)
|
|
|
|
tvCardText.setTextColor(c)
|
|
|
|
tvConversationIconsMore.setTextColor(c)
|
|
|
|
tvConversationParticipants.setTextColor(c)
|
|
|
|
|
|
|
|
(llCardOuter.background as? PreviewCardBorder)?.let {
|
|
|
|
val rgb = c and 0xffffff
|
|
|
|
val alpha = max(1, c ushr (24 + 1)) // 本来の値の半分にする
|
|
|
|
it.color = rgb or (alpha shl 24)
|
|
|
|
}
|
|
|
|
|
|
|
|
c = column.getAcctColor()
|
2021-06-20 15:12:25 +02:00
|
|
|
this.acctColor = c
|
2021-05-19 09:13:26 +02:00
|
|
|
tvBoostedTime.setTextColor(c)
|
|
|
|
tvTime.setTextColor(c)
|
|
|
|
tvTrendTagDesc.setTextColor(c)
|
|
|
|
tvFilterDetail.setTextColor(c)
|
|
|
|
tvFilterPhrase.setTextColor(c)
|
|
|
|
|
|
|
|
// 以下のビューの文字色はsetAcct() で設定される
|
|
|
|
// tvBoostedAcct.setTextColor(c)
|
|
|
|
// tvFollowerAcct.setTextColor(c)
|
|
|
|
// tvAcct.setTextColor(c)
|
|
|
|
|
|
|
|
this.item = item
|
|
|
|
when (item) {
|
|
|
|
is TootStatus -> {
|
|
|
|
val reblog = item.reblog
|
|
|
|
when {
|
|
|
|
reblog == null -> showStatusOrReply(item)
|
|
|
|
|
|
|
|
item.isQuoteToot -> {
|
|
|
|
// 引用Renote
|
2021-06-22 10:31:51 +02:00
|
|
|
val colorBg = PrefI.ipEventBgColorBoost(activity.pref)
|
2021-05-19 09:13:26 +02:00
|
|
|
showReply(reblog, R.drawable.ic_repeat, R.string.quote_to)
|
|
|
|
showStatus(item, colorBg)
|
|
|
|
}
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
// 引用なしブースト
|
2021-06-22 10:31:51 +02:00
|
|
|
val colorBg = PrefI.ipEventBgColorBoost(activity.pref)
|
2021-05-19 09:13:26 +02:00
|
|
|
showBoost(
|
|
|
|
item.accountRef,
|
|
|
|
item.time_created_at,
|
|
|
|
R.drawable.ic_repeat,
|
|
|
|
R.string.display_name_boosted_by,
|
2021-06-20 15:12:25 +02:00
|
|
|
boostStatus = item
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
2022-03-15 12:39:37 +01:00
|
|
|
showStatusOrReply(reblog, colorBg)
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
is TootAccountRef -> showAccount(item)
|
|
|
|
is TootNotification -> showNotification(item)
|
|
|
|
is TootGap -> showGap()
|
|
|
|
is TootSearchGap -> showSearchGap(item)
|
|
|
|
is TootDomainBlock -> showDomainBlock(item)
|
|
|
|
is TootList -> showList(item)
|
|
|
|
is MisskeyAntenna -> showAntenna(item)
|
|
|
|
is TootMessageHolder -> showMessageHolder(item)
|
|
|
|
is TootTag -> showSearchTag(item)
|
|
|
|
is TootFilter -> showFilter(item)
|
|
|
|
is TootConversationSummary -> {
|
|
|
|
showStatusOrReply(item.last_status)
|
|
|
|
showConversationIcons(item)
|
|
|
|
}
|
2021-06-22 10:31:51 +02:00
|
|
|
is TootScheduled -> showScheduled(item)
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
b.report()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.removeExtraView() {
|
|
|
|
llExtra.scan { v ->
|
|
|
|
if (v is MyNetworkImageView) {
|
|
|
|
v.cancelLoading()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
llExtra.removeAllViews()
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
for (invalidator in extraInvalidatorList) {
|
2021-05-19 09:13:26 +02:00
|
|
|
invalidator.register(null)
|
|
|
|
}
|
2021-06-20 15:12:25 +02:00
|
|
|
extraInvalidatorList.clear()
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showAccount(whoRef: TootAccountRef) {
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
followAccount = whoRef
|
2021-05-19 09:13:26 +02:00
|
|
|
val who = whoRef.get()
|
|
|
|
llFollow.visibility = View.VISIBLE
|
|
|
|
ivFollow.setImageUrl(
|
|
|
|
Styler.calcIconRound(ivFollow.layoutParams),
|
2021-06-20 15:12:25 +02:00
|
|
|
accessInfo.supplyBaseUrl(who.avatar_static),
|
|
|
|
accessInfo.supplyBaseUrl(who.avatar)
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
tvFollowerName.text = whoRef.decoded_display_name
|
2021-06-20 15:12:25 +02:00
|
|
|
followInvalidator.register(whoRef.decoded_display_name)
|
2021-05-19 09:13:26 +02:00
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
setAcct(tvFollowerAcct, accessInfo, who)
|
2021-05-19 09:13:26 +02:00
|
|
|
|
2021-05-21 13:56:22 +02:00
|
|
|
who.setAccountExtra(
|
2021-06-20 15:12:25 +02:00
|
|
|
accessInfo,
|
2021-05-21 13:56:22 +02:00
|
|
|
tvLastStatusAt,
|
2021-06-20 15:12:25 +02:00
|
|
|
lastActiveInvalidator,
|
2021-05-21 13:56:22 +02:00
|
|
|
suggestionSource = if (column.type == ColumnType.FOLLOW_SUGGESTION) {
|
2021-06-20 15:12:25 +02:00
|
|
|
SuggestionSource.get(accessInfo.db_id, who.acct)
|
2021-05-21 13:56:22 +02:00
|
|
|
} else {
|
|
|
|
null
|
|
|
|
}
|
|
|
|
)
|
2021-05-19 09:13:26 +02:00
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
val relation = UserRelation.load(accessInfo.db_id, who.id)
|
2021-05-19 09:13:26 +02:00
|
|
|
Styler.setFollowIcon(
|
|
|
|
activity,
|
|
|
|
btnFollow,
|
|
|
|
ivFollowedBy,
|
|
|
|
relation,
|
|
|
|
who,
|
2021-06-20 15:12:25 +02:00
|
|
|
contentColor,
|
|
|
|
alphaMultiplier = Styler.boostAlpha
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if (column.type == ColumnType.FOLLOW_REQUESTS) {
|
|
|
|
llFollowRequest.visibility = View.VISIBLE
|
2021-06-20 15:12:25 +02:00
|
|
|
btnFollowRequestAccept.imageTintList = contentColorCsl
|
|
|
|
btnFollowRequestDeny.imageTintList = contentColorCsl
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showAntenna(a: MisskeyAntenna) {
|
|
|
|
llList.visibility = View.VISIBLE
|
|
|
|
btnListTL.text = a.name
|
2021-06-20 15:12:25 +02:00
|
|
|
btnListTL.textColor = contentColor
|
|
|
|
btnListMore.imageTintList = contentColorCsl
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showBoost(
|
|
|
|
whoRef: TootAccountRef,
|
|
|
|
time: Long,
|
|
|
|
iconId: Int,
|
2021-06-20 15:12:25 +02:00
|
|
|
@StringRes stringId: Int,
|
2021-05-19 09:13:26 +02:00
|
|
|
reaction: TootReaction? = null,
|
2021-06-20 15:12:25 +02:00
|
|
|
boostStatus: TootStatus? = null,
|
2021-11-12 20:41:19 +01:00
|
|
|
reblogVisibility: TootVisibility? = null,
|
2021-05-19 09:13:26 +02:00
|
|
|
) {
|
2021-06-20 15:12:25 +02:00
|
|
|
boostAccount = whoRef
|
2021-05-19 09:13:26 +02:00
|
|
|
|
|
|
|
setIconDrawableId(
|
|
|
|
activity,
|
|
|
|
ivBoosted,
|
|
|
|
iconId,
|
2021-06-20 15:12:25 +02:00
|
|
|
color = contentColor,
|
|
|
|
alphaMultiplier = Styler.boostAlpha
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
val who = whoRef.get()
|
|
|
|
|
|
|
|
// フォローの場合 decoded_display_name が2箇所で表示に使われるのを避ける必要がある
|
|
|
|
val text: Spannable = if (reaction != null) {
|
|
|
|
val options = DecodeOptions(
|
|
|
|
activity,
|
2021-06-20 15:12:25 +02:00
|
|
|
accessInfo,
|
2021-05-19 09:13:26 +02:00
|
|
|
decodeEmoji = true,
|
|
|
|
enlargeEmoji = 1.5f,
|
|
|
|
enlargeCustomEmoji = 1.5f
|
|
|
|
)
|
2021-06-20 15:12:25 +02:00
|
|
|
val ssb = reaction.toSpannableStringBuilder(options, boostStatus)
|
2021-05-19 09:13:26 +02:00
|
|
|
ssb.append(" ")
|
|
|
|
ssb.append(
|
|
|
|
who.decodeDisplayName(activity)
|
2021-06-20 15:12:25 +02:00
|
|
|
.intoStringResource(activity, stringId)
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
|
|
|
} else {
|
|
|
|
who.decodeDisplayName(activity)
|
2021-06-20 15:12:25 +02:00
|
|
|
.intoStringResource(activity, stringId)
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
boostTime = time
|
2021-05-19 09:13:26 +02:00
|
|
|
llBoosted.visibility = View.VISIBLE
|
2021-11-12 20:41:19 +01:00
|
|
|
showStatusTime(
|
|
|
|
activity,
|
|
|
|
tvBoostedTime,
|
|
|
|
who,
|
|
|
|
time = time,
|
|
|
|
status = boostStatus,
|
|
|
|
reblogVisibility = reblogVisibility
|
|
|
|
)
|
2021-05-19 09:13:26 +02:00
|
|
|
tvBoosted.text = text
|
2021-06-20 15:12:25 +02:00
|
|
|
boostInvalidator.register(text)
|
|
|
|
setAcct(tvBoostedAcct, accessInfo, who)
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showMessageHolder(item: TootMessageHolder) {
|
|
|
|
tvMessageHolder.visibility = View.VISIBLE
|
|
|
|
tvMessageHolder.text = item.text
|
|
|
|
tvMessageHolder.gravity = item.gravity
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showList(list: TootList) {
|
|
|
|
llList.visibility = View.VISIBLE
|
|
|
|
btnListTL.text = list.title
|
2021-06-20 15:12:25 +02:00
|
|
|
btnListTL.textColor = contentColor
|
|
|
|
btnListMore.imageTintList = contentColorCsl
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
fun ItemViewHolder.showDomainBlock(domainBlock: TootDomainBlock) {
|
2021-05-19 09:13:26 +02:00
|
|
|
llSearchTag.visibility = View.VISIBLE
|
2021-06-20 15:12:25 +02:00
|
|
|
btnSearchTag.text = domainBlock.domain.pretty
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showFilter(filter: TootFilter) {
|
|
|
|
llFilter.visibility = View.VISIBLE
|
|
|
|
tvFilterPhrase.text = filter.phrase
|
|
|
|
|
|
|
|
val sb = StringBuffer()
|
|
|
|
//
|
|
|
|
sb.append(activity.getString(R.string.filter_context))
|
|
|
|
.append(": ")
|
|
|
|
.append(filter.getContextNames(activity).joinToString("/"))
|
|
|
|
//
|
|
|
|
val flags = ArrayList<String>()
|
|
|
|
if (filter.irreversible) flags.add(activity.getString(R.string.filter_irreversible))
|
|
|
|
if (filter.whole_word) flags.add(activity.getString(R.string.filter_word_match))
|
|
|
|
if (flags.isNotEmpty()) {
|
|
|
|
sb.append('\n')
|
|
|
|
.append(flags.joinToString(", "))
|
|
|
|
}
|
|
|
|
//
|
|
|
|
if (filter.time_expires_at != 0L) {
|
|
|
|
sb.append('\n')
|
|
|
|
.append(activity.getString(R.string.filter_expires_at))
|
|
|
|
.append(": ")
|
|
|
|
.append(TootStatus.formatTime(activity, filter.time_expires_at, false))
|
|
|
|
}
|
|
|
|
|
|
|
|
tvFilterDetail.text = sb.toString()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showSearchTag(tag: TootTag) {
|
|
|
|
if (tag.history?.isNotEmpty() == true) {
|
|
|
|
llTrendTag.visibility = View.VISIBLE
|
2022-03-16 06:08:54 +01:00
|
|
|
|
2021-05-19 09:13:26 +02:00
|
|
|
tvTrendTagCount.text = "${tag.countDaily}(${tag.countWeekly})"
|
|
|
|
cvTagHistory.setHistory(tag.history)
|
2022-07-20 06:27:19 +02:00
|
|
|
when (tag.type) {
|
2022-07-20 23:41:53 +02:00
|
|
|
TootTag.TagType.Link -> {
|
2022-07-20 06:27:19 +02:00
|
|
|
tvTrendTagName.text = tag.url?.ellipsizeDot3(256)
|
|
|
|
tvTrendTagDesc.text = tag.name + "\n" + tag.description
|
|
|
|
}
|
2022-07-20 23:41:53 +02:00
|
|
|
TootTag.TagType.Tag -> {
|
2022-07-20 06:27:19 +02:00
|
|
|
tvTrendTagName.text = "#${tag.name.ellipsizeDot3(256)}"
|
2022-07-20 23:41:53 +02:00
|
|
|
tvTrendTagDesc.text = listOf(
|
|
|
|
when (tag.following) {
|
|
|
|
true -> activity.getString(R.string.following)
|
|
|
|
else -> ""
|
|
|
|
},
|
2022-07-20 06:27:19 +02:00
|
|
|
activity.getString(R.string.people_talking, tag.accountDaily, tag.accountWeekly)
|
2022-07-20 23:41:53 +02:00
|
|
|
).filter { it.isNotEmpty() }.joinToString(" ")
|
2022-07-20 06:27:19 +02:00
|
|
|
}
|
2022-03-16 06:08:54 +01:00
|
|
|
}
|
2021-05-19 09:13:26 +02:00
|
|
|
} else {
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
|
|
|
btnSearchTag.text = "#" + tag.name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showGap() {
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
|
|
|
btnSearchTag.text = activity.getString(R.string.read_gap)
|
|
|
|
|
|
|
|
btnGapHead.vg(column.type.gapDirection(column, true))
|
2021-06-20 15:12:25 +02:00
|
|
|
?.imageTintList = contentColorCsl
|
2021-05-19 09:13:26 +02:00
|
|
|
|
|
|
|
btnGapTail.vg(column.type.gapDirection(column, false))
|
2021-06-20 15:12:25 +02:00
|
|
|
?.imageTintList = contentColorCsl
|
2021-05-19 09:13:26 +02:00
|
|
|
|
2021-11-20 01:36:43 +01:00
|
|
|
val c = PrefI.ipEventBgColorGap()
|
2021-05-19 09:13:26 +02:00
|
|
|
if (c != 0) this.viewRoot.backgroundColor = c
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showSearchGap(item: TootSearchGap) {
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
|
|
|
btnSearchTag.text = activity.getString(
|
|
|
|
when (item.type) {
|
|
|
|
TootSearchGap.SearchType.Hashtag -> R.string.read_more_hashtag
|
|
|
|
TootSearchGap.SearchType.Account -> R.string.read_more_account
|
|
|
|
TootSearchGap.SearchType.Status -> R.string.read_more_status
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showReply(iconId: Int, text: Spannable) {
|
|
|
|
|
|
|
|
llReply.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
setIconDrawableId(
|
|
|
|
activity,
|
|
|
|
ivReply,
|
|
|
|
iconId,
|
2021-06-20 15:12:25 +02:00
|
|
|
color = contentColor,
|
|
|
|
alphaMultiplier = Styler.boostAlpha
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
tvReply.text = text
|
2021-06-20 15:12:25 +02:00
|
|
|
replyInvalidator.register(text)
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showReply(reply: TootStatus, iconId: Int, stringId: Int) {
|
2021-06-20 15:12:25 +02:00
|
|
|
statusReply = reply
|
2021-05-19 09:13:26 +02:00
|
|
|
showReply(
|
|
|
|
iconId,
|
|
|
|
reply.accountRef.decoded_display_name.intoStringResource(activity, stringId)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showReply(reply: TootStatus, accountId: EntityId) {
|
|
|
|
val name = if (accountId == reply.account.id) {
|
|
|
|
// 自己レスなら
|
2021-06-20 15:12:25 +02:00
|
|
|
AcctColor.getNicknameWithColor(accessInfo, reply.account)
|
2021-05-19 09:13:26 +02:00
|
|
|
} else {
|
|
|
|
val m = reply.mentions?.find { it.id == accountId }
|
|
|
|
if (m != null) {
|
2021-06-20 15:12:25 +02:00
|
|
|
AcctColor.getNicknameWithColor(accessInfo.getFullAcct(m.acct))
|
2021-05-19 09:13:26 +02:00
|
|
|
} else {
|
2021-06-20 15:12:25 +02:00
|
|
|
SpannableString("ID($accountId)")
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val text = name.intoStringResource(activity, R.string.reply_to)
|
|
|
|
showReply(R.drawable.ic_reply, text)
|
|
|
|
|
|
|
|
// tootsearchはreplyオブジェクトがなくin_reply_toだけが提供される場合があるが
|
|
|
|
// tootsearchではどのタンスから読んだか分からないのでin_reply_toのIDも信用できない
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showStatusTime(
|
|
|
|
activity: ActMain,
|
|
|
|
tv: TextView,
|
|
|
|
@Suppress("UNUSED_PARAMETER") who: TootAccount,
|
|
|
|
status: TootStatus? = null,
|
2021-06-20 15:12:25 +02:00
|
|
|
time: Long? = null,
|
2021-11-12 20:41:19 +01:00
|
|
|
reblogVisibility: TootVisibility? = null,
|
2021-05-19 09:13:26 +02:00
|
|
|
) {
|
|
|
|
val sb = SpannableStringBuilder()
|
|
|
|
|
|
|
|
if (status != null) {
|
|
|
|
|
|
|
|
if (status.account.isAdmin) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_shield, "admin")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status.account.isPro) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_authorized, "pro")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status.account.isCat) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_cat, "cat")
|
|
|
|
}
|
|
|
|
|
|
|
|
// botマーク
|
|
|
|
if (status.account.bot) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_bot, "bot")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status.account.suspended) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_delete, "suspended")
|
|
|
|
}
|
|
|
|
|
|
|
|
// mobileマーク
|
|
|
|
if (status.viaMobile) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_mobile, "mobile")
|
|
|
|
}
|
|
|
|
|
|
|
|
// mobileマーク
|
|
|
|
if (status.bookmarked) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_bookmark, "bookmarked")
|
|
|
|
}
|
|
|
|
|
|
|
|
// NSFWマーク
|
|
|
|
if (status.hasMedia() && status.sensitive) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_eye_off, "NSFW")
|
|
|
|
}
|
|
|
|
|
|
|
|
// visibility
|
|
|
|
val visIconId =
|
2021-06-20 15:12:25 +02:00
|
|
|
Styler.getVisibilityIconId(accessInfo.isMisskey, status.visibility)
|
2021-05-19 09:13:26 +02:00
|
|
|
if (R.drawable.ic_public != visIconId) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(
|
|
|
|
activity,
|
|
|
|
visIconId,
|
|
|
|
Styler.getVisibilityString(
|
|
|
|
activity,
|
2021-06-20 15:12:25 +02:00
|
|
|
accessInfo.isMisskey,
|
2021-05-19 09:13:26 +02:00
|
|
|
status.visibility
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// pinned
|
|
|
|
if (status.pinned) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_pin, "pinned")
|
|
|
|
|
|
|
|
// val start = sb.length
|
|
|
|
// sb.append("pinned")
|
|
|
|
// val end = sb.length
|
|
|
|
// val icon_id = Styler.getAttributeResourceId(activity, R.attr.ic_pin)
|
|
|
|
// sb.setSpan(
|
|
|
|
// EmojiImageSpan(activity, icon_id),
|
|
|
|
// start,
|
|
|
|
// end,
|
|
|
|
// Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
|
// )
|
|
|
|
}
|
|
|
|
|
|
|
|
// unread
|
|
|
|
if (status.conversationSummary?.unread == true) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
|
|
|
sb.appendColorShadeIcon(
|
|
|
|
activity,
|
|
|
|
R.drawable.ic_unread,
|
|
|
|
"unread",
|
|
|
|
color = MyClickableSpan.defaultLinkColor
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status.isPromoted) {
|
|
|
|
if (sb.isNotEmpty()) sb.append(' ')
|
|
|
|
sb.append(activity.getString(R.string.promoted))
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status.isFeatured) {
|
|
|
|
if (sb.isNotEmpty()) sb.append(' ')
|
|
|
|
sb.append(activity.getString(R.string.featured))
|
|
|
|
}
|
2022-03-16 05:04:04 +01:00
|
|
|
|
|
|
|
if (status.time_edited_at > 0L) {
|
|
|
|
if (sb.isNotEmpty()) sb.append(' ')
|
|
|
|
val start = sb.length
|
|
|
|
sb.append(activity.getString(R.string.edited))
|
|
|
|
val end = sb.length
|
|
|
|
sb.setSpan(StyleSpan(Typeface.BOLD), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
|
|
}
|
2021-11-12 20:41:19 +01:00
|
|
|
} else {
|
|
|
|
reblogVisibility?.takeIf { it != TootVisibility.Unknown }?.let { visibility ->
|
|
|
|
val visIconId = Styler.getVisibilityIconId(accessInfo.isMisskey, visibility)
|
|
|
|
if (R.drawable.ic_public != visIconId) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(
|
|
|
|
activity,
|
|
|
|
visIconId,
|
|
|
|
Styler.getVisibilityString(
|
|
|
|
activity,
|
|
|
|
accessInfo.isMisskey,
|
|
|
|
visibility
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sb.isNotEmpty()) sb.append(' ')
|
2022-08-02 04:41:05 +02:00
|
|
|
|
2021-05-19 09:13:26 +02:00
|
|
|
sb.append(
|
2022-08-02 04:41:05 +02:00
|
|
|
(time ?: status?.time_created_at)?.let {
|
|
|
|
TootStatus.formatTime(activity, it, column.canRelativeTime)
|
|
|
|
} ?: "?"
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
tv.text = sb
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showStatusTimeScheduled(
|
|
|
|
activity: ActMain,
|
|
|
|
tv: TextView,
|
2021-06-20 15:12:25 +02:00
|
|
|
item: TootScheduled,
|
2021-05-19 09:13:26 +02:00
|
|
|
) {
|
|
|
|
val sb = SpannableStringBuilder()
|
|
|
|
|
|
|
|
// NSFWマーク
|
|
|
|
if (item.hasMedia() && item.sensitive) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_eye_off, "NSFW")
|
|
|
|
}
|
|
|
|
|
|
|
|
// visibility
|
|
|
|
val visIconId =
|
2021-06-20 15:12:25 +02:00
|
|
|
Styler.getVisibilityIconId(accessInfo.isMisskey, item.visibility)
|
2021-05-19 09:13:26 +02:00
|
|
|
if (R.drawable.ic_public != visIconId) {
|
|
|
|
if (sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
sb.appendColorShadeIcon(
|
|
|
|
activity,
|
|
|
|
visIconId,
|
|
|
|
Styler.getVisibilityString(
|
|
|
|
activity,
|
2021-06-20 15:12:25 +02:00
|
|
|
accessInfo.isMisskey,
|
2021-05-19 09:13:26 +02:00
|
|
|
item.visibility
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb.isNotEmpty()) sb.append(' ')
|
2022-08-02 04:41:05 +02:00
|
|
|
sb.append(TootStatus.formatTime(activity, item.timeScheduledAt, column.canRelativeTime))
|
2021-05-19 09:13:26 +02:00
|
|
|
|
|
|
|
tv.text = sb
|
|
|
|
}
|
2022-08-02 04:41:05 +02:00
|
|
|
|
|
|
|
val Column.canRelativeTime
|
|
|
|
get() = when (type) {
|
|
|
|
ColumnType.CONVERSATION,
|
|
|
|
ColumnType.CONVERSATION_WITH_REFERENCE,
|
|
|
|
ColumnType.STATUS_HISTORY,
|
|
|
|
-> false
|
|
|
|
else -> true
|
|
|
|
}
|
|
|
|
|
2021-05-19 09:13:26 +02:00
|
|
|
// fun updateRelativeTime() {
|
|
|
|
// val boost_time = this.boost_time
|
|
|
|
// if(boost_time != 0L) {
|
|
|
|
// tvBoostedTime.text = TootStatus.formatTime(tvBoostedTime.context, boost_time, true)
|
|
|
|
// }
|
|
|
|
// val status_showing = this.status_showing
|
|
|
|
// if(status_showing != null) {
|
|
|
|
// showStatusTime(activity, status_showing)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
fun ItemViewHolder.showScheduled(item: TootScheduled) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
llStatus.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
this.viewRoot.setBackgroundColor(0)
|
|
|
|
|
|
|
|
showStatusTimeScheduled(activity, tvTime, item)
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
val who = column.whoAccount!!.get()
|
|
|
|
val whoRef = TootAccountRef(TootParser(activity, accessInfo), who)
|
|
|
|
this.statusAccount = whoRef
|
2021-05-19 09:13:26 +02:00
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
setAcct(tvAcct, accessInfo, who)
|
2021-05-19 09:13:26 +02:00
|
|
|
|
|
|
|
tvName.text = whoRef.decoded_display_name
|
2021-06-20 15:12:25 +02:00
|
|
|
nameInvalidator.register(whoRef.decoded_display_name)
|
2021-06-22 10:31:51 +02:00
|
|
|
ivAvatar.setImageUrl(
|
|
|
|
Styler.calcIconRound(ivAvatar.layoutParams),
|
2021-06-20 15:12:25 +02:00
|
|
|
accessInfo.supplyBaseUrl(who.avatar_static),
|
|
|
|
accessInfo.supplyBaseUrl(who.avatar)
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
val content = SpannableString(item.text ?: "")
|
|
|
|
|
|
|
|
tvMentions.visibility = View.GONE
|
|
|
|
|
|
|
|
tvContent.text = content
|
2021-06-20 15:12:25 +02:00
|
|
|
contentInvalidator.register(content)
|
2021-05-19 09:13:26 +02:00
|
|
|
|
|
|
|
tvContent.minLines = -1
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
val decodedSpoilerText = SpannableString(item.spoilerText ?: "")
|
2021-05-19 09:13:26 +02:00
|
|
|
when {
|
2021-06-20 15:12:25 +02:00
|
|
|
decodedSpoilerText.isNotEmpty() -> {
|
2021-05-19 09:13:26 +02:00
|
|
|
// 元データに含まれるContent Warning を使う
|
|
|
|
llContentWarning.visibility = View.VISIBLE
|
2021-06-20 15:12:25 +02:00
|
|
|
tvContentWarning.text = decodedSpoilerText
|
|
|
|
spoilerInvalidator.register(decodedSpoilerText)
|
|
|
|
val cwShown = ContentWarning.isShown(item.uri, accessInfo.expand_cw)
|
2021-06-24 06:49:27 +02:00
|
|
|
setContentVisibility(cwShown)
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
// CWしない
|
|
|
|
llContentWarning.visibility = View.GONE
|
|
|
|
llContents.visibility = View.VISIBLE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
val mediaAttachments = item.mediaAttachments
|
|
|
|
if (mediaAttachments?.isEmpty() != false) {
|
2021-05-19 09:13:26 +02:00
|
|
|
flMedia.visibility = View.GONE
|
|
|
|
llMedia.visibility = View.GONE
|
|
|
|
btnShowMedia.visibility = View.GONE
|
|
|
|
} else {
|
|
|
|
flMedia.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
// hide sensitive media
|
2021-06-20 15:12:25 +02:00
|
|
|
val defaultShown = when {
|
|
|
|
column.hideMediaDefault -> false
|
|
|
|
accessInfo.dont_hide_nsfw -> true
|
2021-05-19 09:13:26 +02:00
|
|
|
else -> !item.sensitive
|
|
|
|
}
|
2021-06-20 15:12:25 +02:00
|
|
|
val isShown = MediaShown.isShown(item.uri, defaultShown)
|
2021-05-19 09:13:26 +02:00
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
btnShowMedia.visibility = if (!isShown) View.VISIBLE else View.GONE
|
|
|
|
llMedia.visibility = if (!isShown) View.GONE else View.VISIBLE
|
2021-05-19 09:13:26 +02:00
|
|
|
val sb = StringBuilder()
|
2021-06-20 15:12:25 +02:00
|
|
|
setMedia(mediaAttachments, sb, ivMedia1, 0)
|
|
|
|
setMedia(mediaAttachments, sb, ivMedia2, 1)
|
|
|
|
setMedia(mediaAttachments, sb, ivMedia3, 2)
|
|
|
|
setMedia(mediaAttachments, sb, ivMedia4, 3)
|
2021-05-19 09:13:26 +02:00
|
|
|
if (sb.isNotEmpty()) {
|
|
|
|
tvMediaDescription.visibility = View.VISIBLE
|
|
|
|
tvMediaDescription.text = sb
|
|
|
|
}
|
|
|
|
|
|
|
|
setIconDrawableId(
|
|
|
|
activity,
|
|
|
|
btnHideMedia,
|
|
|
|
R.drawable.ic_close,
|
2021-06-20 15:12:25 +02:00
|
|
|
color = contentColor,
|
|
|
|
alphaMultiplier = Styler.boostAlpha
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
buttonsForStatus?.hide()
|
2021-05-19 09:13:26 +02:00
|
|
|
|
|
|
|
tvApplication.visibility = View.GONE
|
|
|
|
} catch (ex: Throwable) {
|
2021-06-20 15:12:25 +02:00
|
|
|
ItemViewHolder.log.w(ex, "showScheduled failed")
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
|
|
|
btnSearchTag.text = activity.getString(R.string.scheduled_status) + " " +
|
2021-11-12 20:41:19 +01:00
|
|
|
TootStatus.formatTime(activity, item.timeScheduledAt, true)
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.showConversationIcons(cs: TootConversationSummary) {
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
val lastAccountId = cs.last_status.account.id
|
2021-05-19 09:13:26 +02:00
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
val accountsOther = cs.accounts.filter { it.get().id != lastAccountId }
|
2021-05-19 09:13:26 +02:00
|
|
|
if (accountsOther.isNotEmpty()) {
|
|
|
|
llConversationIcons.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
val size = accountsOther.size
|
|
|
|
|
|
|
|
tvConversationParticipants.text = if (size <= 1) {
|
|
|
|
activity.getString(R.string.conversation_to)
|
|
|
|
} else {
|
|
|
|
activity.getString(R.string.participants)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun showIcon(iv: MyNetworkImageView, idx: Int) {
|
|
|
|
val bShown = idx < size
|
|
|
|
iv.visibility = if (bShown) View.VISIBLE else View.GONE
|
|
|
|
if (!bShown) return
|
|
|
|
|
|
|
|
val who = accountsOther[idx].get()
|
|
|
|
iv.setImageUrl(
|
|
|
|
Styler.calcIconRound(iv.layoutParams),
|
2021-06-20 15:12:25 +02:00
|
|
|
accessInfo.supplyBaseUrl(who.avatar_static),
|
|
|
|
accessInfo.supplyBaseUrl(who.avatar)
|
2021-05-19 09:13:26 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
showIcon(ivConversationIcon1, 0)
|
|
|
|
showIcon(ivConversationIcon2, 1)
|
|
|
|
showIcon(ivConversationIcon3, 2)
|
|
|
|
showIcon(ivConversationIcon4, 3)
|
|
|
|
|
|
|
|
tvConversationIconsMore.text = when {
|
|
|
|
size <= 4 -> ""
|
|
|
|
else -> activity.getString(R.string.participants_and_more)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cs.last_status.in_reply_to_id != null) {
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
|
|
|
btnSearchTag.text = activity.getString(R.string.show_conversation)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun ItemViewHolder.setAcct(tv: TextView, accessInfo: SavedAccount, who: TootAccount) {
|
|
|
|
val ac = AcctColor.load(accessInfo, who)
|
|
|
|
tv.text = when {
|
|
|
|
AcctColor.hasNickname(ac) -> ac.nickname
|
2021-11-20 01:36:43 +01:00
|
|
|
PrefB.bpShortAcctLocalUser() -> "@${who.acct.pretty}"
|
2021-05-19 09:13:26 +02:00
|
|
|
else -> "@${ac.nickname}"
|
|
|
|
}
|
2021-06-20 15:12:25 +02:00
|
|
|
tv.textColor = ac.color_fg.notZero() ?: this.acctColor
|
2021-05-19 09:13:26 +02:00
|
|
|
|
|
|
|
tv.setBackgroundColor(ac.color_bg) // may 0
|
2021-06-20 15:12:25 +02:00
|
|
|
tv.setPaddingRelative(activity.acctPadLr, 0, activity.acctPadLr, 0)
|
2021-05-19 09:13:26 +02:00
|
|
|
}
|