2018-01-04 19:52:25 +01:00
|
|
|
|
package jp.juggler.subwaytooter
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
2019-01-20 10:27:29 +01:00
|
|
|
|
import android.content.res.ColorStateList
|
2018-01-04 19:52:25 +01:00
|
|
|
|
import android.graphics.Typeface
|
2018-01-17 18:39:16 +01:00
|
|
|
|
import android.os.SystemClock
|
2019-02-15 02:51:22 +01:00
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
|
import androidx.appcompat.app.AlertDialog
|
2018-11-18 03:38:52 +01:00
|
|
|
|
import android.text.Spannable
|
|
|
|
|
import android.text.SpannableString
|
|
|
|
|
import android.text.SpannableStringBuilder
|
|
|
|
|
import android.text.TextUtils
|
2019-05-05 06:41:13 +02:00
|
|
|
|
import android.text.style.BackgroundColorSpan
|
2018-12-08 16:29:07 +01:00
|
|
|
|
import android.util.TypedValue
|
2018-01-14 22:47:42 +01:00
|
|
|
|
import android.view.Gravity
|
2018-01-04 19:52:25 +01:00
|
|
|
|
import android.view.View
|
2018-01-14 22:47:42 +01:00
|
|
|
|
import android.view.ViewGroup
|
|
|
|
|
import android.widget.*
|
2018-08-21 03:53:52 +02:00
|
|
|
|
import com.google.android.flexbox.FlexWrap
|
|
|
|
|
import com.google.android.flexbox.FlexboxLayout
|
2018-08-21 15:31:44 +02:00
|
|
|
|
import com.google.android.flexbox.JustifyContent
|
2019-01-16 13:33:07 +01:00
|
|
|
|
import jp.juggler.subwaytooter.Styler.defaultColorIcon
|
2018-07-07 07:15:16 +02:00
|
|
|
|
import jp.juggler.subwaytooter.action.*
|
2019-01-06 15:55:25 +01:00
|
|
|
|
import jp.juggler.subwaytooter.api.*
|
2018-01-04 19:52:25 +01:00
|
|
|
|
import jp.juggler.subwaytooter.api.entity.*
|
|
|
|
|
import jp.juggler.subwaytooter.dialog.ActionsDialog
|
|
|
|
|
import jp.juggler.subwaytooter.dialog.DlgConfirm
|
2019-03-06 10:49:02 +01:00
|
|
|
|
import jp.juggler.subwaytooter.drawable.PollPlotDrawable
|
2018-11-12 18:19:57 +01:00
|
|
|
|
import jp.juggler.subwaytooter.drawable.PreviewCardBorder
|
2018-10-28 14:08:10 +01:00
|
|
|
|
import jp.juggler.subwaytooter.span.MyClickableSpan
|
2020-01-04 14:36:01 +01:00
|
|
|
|
import jp.juggler.subwaytooter.span.NetworkEmojiSpan
|
2018-08-21 15:31:44 +02:00
|
|
|
|
import jp.juggler.subwaytooter.table.*
|
2018-01-14 22:47:42 +01:00
|
|
|
|
import jp.juggler.subwaytooter.util.*
|
2018-01-04 19:52:25 +01:00
|
|
|
|
import jp.juggler.subwaytooter.view.*
|
2018-12-01 00:02:18 +01:00
|
|
|
|
import jp.juggler.util.*
|
2018-01-14 22:47:42 +01:00
|
|
|
|
import org.jetbrains.anko.*
|
2018-11-18 03:38:52 +01:00
|
|
|
|
import kotlin.math.max
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
internal class ItemViewHolder(
|
2018-01-17 18:39:16 +01:00
|
|
|
|
val activity : ActMain
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) : View.OnClickListener, View.OnLongClickListener {
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
private val log = LogCategory("ItemViewHolder")
|
2018-08-31 14:47:40 +02:00
|
|
|
|
var toot_color_unlisted : Int = 0
|
|
|
|
|
var toot_color_follower : Int = 0
|
|
|
|
|
var toot_color_direct_user : Int = 0
|
|
|
|
|
var toot_color_direct_me : Int = 0
|
2018-12-16 12:24:44 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
val viewRoot : View
|
|
|
|
|
|
|
|
|
|
private var bSimpleList : Boolean = false
|
2018-01-21 13:46:36 +01:00
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
lateinit var column : Column
|
2018-01-21 13:46:36 +01:00
|
|
|
|
|
2018-10-28 14:08:10 +01:00
|
|
|
|
internal lateinit var list_adapter : ItemListAdapter
|
2018-08-23 05:46:14 +02:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var llBoosted : View
|
|
|
|
|
private lateinit var ivBoosted : ImageView
|
|
|
|
|
private lateinit var tvBoosted : TextView
|
|
|
|
|
private lateinit var tvBoostedAcct : TextView
|
|
|
|
|
private lateinit var tvBoostedTime : TextView
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-08-23 05:46:14 +02:00
|
|
|
|
private lateinit var llReply : View
|
|
|
|
|
private lateinit var ivReply : ImageView
|
|
|
|
|
private lateinit var tvReply : TextView
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var llFollow : View
|
|
|
|
|
private lateinit var ivFollow : MyNetworkImageView
|
|
|
|
|
private lateinit var tvFollowerName : TextView
|
|
|
|
|
private lateinit var tvFollowerAcct : TextView
|
|
|
|
|
private lateinit var btnFollow : ImageButton
|
|
|
|
|
private lateinit var ivFollowedBy : ImageView
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var llStatus : View
|
|
|
|
|
private lateinit var ivThumbnail : MyNetworkImageView
|
|
|
|
|
private lateinit var tvName : TextView
|
|
|
|
|
private lateinit var tvTime : TextView
|
|
|
|
|
private lateinit var tvAcct : TextView
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var llContentWarning : View
|
|
|
|
|
private lateinit var tvContentWarning : MyTextView
|
|
|
|
|
private lateinit var btnContentWarning : Button
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var llContents : View
|
|
|
|
|
private lateinit var tvMentions : MyTextView
|
2019-01-08 10:41:07 +01:00
|
|
|
|
internal lateinit var tvContent : MyTextView
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var flMedia : View
|
2018-01-21 13:46:36 +01:00
|
|
|
|
private lateinit var llMedia : View
|
2019-07-24 10:59:07 +02:00
|
|
|
|
private lateinit var btnShowMedia : BlurhashView
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var ivMedia1 : MyNetworkImageView
|
|
|
|
|
private lateinit var ivMedia2 : MyNetworkImageView
|
|
|
|
|
private lateinit var ivMedia3 : MyNetworkImageView
|
|
|
|
|
private lateinit var ivMedia4 : MyNetworkImageView
|
2018-11-18 03:38:52 +01:00
|
|
|
|
private lateinit var btnHideMedia : ImageButton
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-08-21 15:31:44 +02:00
|
|
|
|
private lateinit var statusButtonsViewHolder : StatusButtonsViewHolder
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var llButtonBar : View
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var llSearchTag : View
|
|
|
|
|
private lateinit var btnSearchTag : Button
|
2018-05-30 07:18:45 +02:00
|
|
|
|
private lateinit var llTrendTag : View
|
|
|
|
|
private lateinit var tvTrendTagName : TextView
|
|
|
|
|
private lateinit var tvTrendTagDesc : TextView
|
|
|
|
|
private lateinit var tvTrendTagCount : TextView
|
2019-09-13 17:49:19 +02:00
|
|
|
|
private lateinit var cvTagHistory : TagHistoryView
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var llList : View
|
|
|
|
|
private lateinit var btnListTL : Button
|
|
|
|
|
private lateinit var btnListMore : ImageButton
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-04-17 18:29:50 +02:00
|
|
|
|
private lateinit var llFollowRequest : View
|
2019-01-20 10:27:29 +01:00
|
|
|
|
private lateinit var btnFollowRequestAccept : ImageButton
|
|
|
|
|
private lateinit var btnFollowRequestDeny : ImageButton
|
2018-04-17 18:29:50 +02:00
|
|
|
|
|
2018-07-07 07:15:16 +02:00
|
|
|
|
private lateinit var llFilter : View
|
|
|
|
|
private lateinit var tvFilterPhrase : TextView
|
|
|
|
|
private lateinit var tvFilterDetail : TextView
|
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
private lateinit var tvMediaDescription : TextView
|
2018-11-12 18:19:57 +01:00
|
|
|
|
|
|
|
|
|
private lateinit var llCardOuter : View
|
2018-11-17 22:01:06 +01:00
|
|
|
|
private lateinit var tvCardText : MyTextView
|
2020-01-29 06:15:32 +01:00
|
|
|
|
private lateinit var flCardImage : View
|
|
|
|
|
private lateinit var llCardImage : View
|
2018-11-11 11:43:20 +01:00
|
|
|
|
private lateinit var ivCardImage : MyNetworkImageView
|
2020-01-29 06:15:32 +01:00
|
|
|
|
private lateinit var btnCardImageHide : ImageButton
|
|
|
|
|
private lateinit var btnCardImageShow : Button
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var llExtra : LinearLayout
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
private lateinit var llConversationIcons : View
|
|
|
|
|
private lateinit var ivConversationIcon1 : MyNetworkImageView
|
|
|
|
|
private lateinit var ivConversationIcon2 : MyNetworkImageView
|
|
|
|
|
private lateinit var ivConversationIcon3 : MyNetworkImageView
|
|
|
|
|
private lateinit var ivConversationIcon4 : MyNetworkImageView
|
|
|
|
|
private lateinit var tvConversationIconsMore : TextView
|
|
|
|
|
private lateinit var tvConversationParticipants : TextView
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
private lateinit var tvApplication : TextView
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-05-24 18:33:09 +02:00
|
|
|
|
private lateinit var tvMessageHolder : TextView
|
2018-12-08 16:29:07 +01:00
|
|
|
|
|
2018-12-26 05:47:16 +01:00
|
|
|
|
private lateinit var llInstanceTicker : View
|
|
|
|
|
private lateinit var ivInstanceTicker : MyNetworkImageView
|
|
|
|
|
private lateinit var tvInstanceTicker : TextView
|
|
|
|
|
|
2019-08-29 18:16:21 +02:00
|
|
|
|
private lateinit var tvLastStatusAt : TextView
|
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
private lateinit var access_info : SavedAccount
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
private var buttons_for_status : StatusButtons? = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-20 07:51:14 +01:00
|
|
|
|
private var item : TimelineItem? = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-18 22:22:27 +01:00
|
|
|
|
private var status_showing : TootStatus? = null
|
2018-08-23 05:46:14 +02:00
|
|
|
|
private var status_reply : TootStatus? = null
|
2018-05-08 10:25:02 +02:00
|
|
|
|
private var status_account : TootAccountRef? = null
|
|
|
|
|
private var boost_account : TootAccountRef? = null
|
|
|
|
|
private var follow_account : TootAccountRef? = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
|
private var boost_time : Long = 0L
|
2018-01-20 07:51:14 +01:00
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
|
private var content_color : Int = 0
|
2018-01-04 19:52:25 +01:00
|
|
|
|
private var acct_color : Int = 0
|
2019-01-20 10:27:29 +01:00
|
|
|
|
private var content_color_csl : ColorStateList = ColorStateList.valueOf(0)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
private val boost_invalidator : NetworkEmojiInvalidator
|
2018-08-23 05:46:14 +02:00
|
|
|
|
private val reply_invalidator : NetworkEmojiInvalidator
|
2018-01-04 19:52:25 +01:00
|
|
|
|
private val follow_invalidator : NetworkEmojiInvalidator
|
|
|
|
|
private val name_invalidator : NetworkEmojiInvalidator
|
|
|
|
|
private val content_invalidator : NetworkEmojiInvalidator
|
|
|
|
|
private val spoiler_invalidator : NetworkEmojiInvalidator
|
2019-12-15 14:01:42 +01:00
|
|
|
|
private val lastActive_invalidator : NetworkEmojiInvalidator
|
2018-01-04 19:52:25 +01:00
|
|
|
|
private val extra_invalidator_list = ArrayList<NetworkEmojiInvalidator>()
|
|
|
|
|
|
|
|
|
|
init {
|
2018-08-21 15:31:44 +02:00
|
|
|
|
this.viewRoot = inflate(activity)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
btnListTL.setOnClickListener(this)
|
|
|
|
|
btnListMore.setOnClickListener(this)
|
|
|
|
|
|
|
|
|
|
btnSearchTag.setOnClickListener(this)
|
2018-01-10 16:47:35 +01:00
|
|
|
|
btnSearchTag.setOnLongClickListener(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
btnContentWarning.setOnClickListener(this)
|
|
|
|
|
btnShowMedia.setOnClickListener(this)
|
|
|
|
|
ivMedia1.setOnClickListener(this)
|
|
|
|
|
ivMedia2.setOnClickListener(this)
|
|
|
|
|
ivMedia3.setOnClickListener(this)
|
|
|
|
|
ivMedia4.setOnClickListener(this)
|
|
|
|
|
btnFollow.setOnClickListener(this)
|
|
|
|
|
btnFollow.setOnLongClickListener(this)
|
|
|
|
|
|
2018-11-14 07:47:25 +01:00
|
|
|
|
ivCardImage.setOnClickListener(this)
|
|
|
|
|
ivCardImage.setOnLongClickListener(this)
|
2020-01-29 06:15:32 +01:00
|
|
|
|
btnCardImageHide.setOnClickListener(this)
|
|
|
|
|
btnCardImageShow.setOnClickListener(this)
|
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
ivThumbnail.setOnClickListener(this)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
llBoosted.setOnClickListener(this)
|
|
|
|
|
llBoosted.setOnLongClickListener(this)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2018-08-23 05:46:14 +02:00
|
|
|
|
llReply.setOnClickListener(this)
|
|
|
|
|
llReply.setOnLongClickListener(this)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
llFollow.setOnClickListener(this)
|
|
|
|
|
llFollow.setOnLongClickListener(this)
|
2018-11-11 11:43:20 +01:00
|
|
|
|
llConversationIcons.setOnLongClickListener(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
btnFollow.setOnClickListener(this)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-04-17 18:29:50 +02:00
|
|
|
|
btnFollowRequestAccept.setOnClickListener(this)
|
|
|
|
|
btnFollowRequestDeny.setOnClickListener(this)
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
// ロングタップ
|
|
|
|
|
ivThumbnail.setOnLongClickListener(this)
|
|
|
|
|
|
|
|
|
|
//
|
2018-01-10 16:47:35 +01:00
|
|
|
|
tvContent.movementMethod = MyLinkMovementMethod
|
|
|
|
|
tvMentions.movementMethod = MyLinkMovementMethod
|
|
|
|
|
tvContentWarning.movementMethod = MyLinkMovementMethod
|
2018-11-11 11:43:20 +01:00
|
|
|
|
tvMediaDescription.movementMethod = MyLinkMovementMethod
|
2018-11-17 22:01:06 +01:00
|
|
|
|
tvCardText.movementMethod = MyLinkMovementMethod
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
btnHideMedia.setOnClickListener(this)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-05-30 07:18:45 +02:00
|
|
|
|
llTrendTag.setOnClickListener(this)
|
|
|
|
|
llTrendTag.setOnLongClickListener(this)
|
2018-08-04 20:07:55 +02:00
|
|
|
|
llFilter.setOnClickListener(this)
|
2018-03-21 16:39:10 +01:00
|
|
|
|
|
2018-11-18 15:29:35 +01:00
|
|
|
|
var f : Float
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
|
|
|
|
f = activity.timeline_font_size_sp
|
|
|
|
|
if(! f.isNaN()) {
|
|
|
|
|
tvFollowerName.textSize = f
|
|
|
|
|
tvName.textSize = f
|
|
|
|
|
tvMentions.textSize = f
|
|
|
|
|
tvContentWarning.textSize = f
|
|
|
|
|
tvContent.textSize = f
|
|
|
|
|
btnShowMedia.textSize = f
|
2020-01-29 06:15:32 +01:00
|
|
|
|
btnCardImageShow.textSize = f
|
2018-11-18 03:38:52 +01:00
|
|
|
|
tvApplication.textSize = f
|
|
|
|
|
tvMessageHolder.textSize = f
|
|
|
|
|
btnListTL.textSize = f
|
|
|
|
|
tvTrendTagName.textSize = f
|
|
|
|
|
tvTrendTagCount.textSize = f
|
|
|
|
|
tvFilterPhrase.textSize = f
|
|
|
|
|
tvMediaDescription.textSize = f
|
|
|
|
|
tvCardText.textSize = f
|
|
|
|
|
tvConversationIconsMore.textSize = f
|
|
|
|
|
tvConversationParticipants.textSize = f
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
|
|
|
|
f = activity.notification_tl_font_size_sp
|
|
|
|
|
if(! f.isNaN()) {
|
|
|
|
|
tvBoosted.textSize = f
|
|
|
|
|
tvReply.textSize = f
|
2018-06-24 03:12:45 +02:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
|
f = activity.acct_font_size_sp
|
|
|
|
|
if(! f.isNaN()) {
|
|
|
|
|
tvBoostedAcct.textSize = f
|
|
|
|
|
tvBoostedTime.textSize = f
|
|
|
|
|
tvFollowerAcct.textSize = f
|
2019-08-29 18:16:21 +02:00
|
|
|
|
tvLastStatusAt.textSize = f
|
2018-11-18 03:38:52 +01:00
|
|
|
|
tvAcct.textSize = f
|
|
|
|
|
tvTime.textSize = f
|
|
|
|
|
tvTrendTagDesc.textSize = f
|
2018-11-18 15:29:35 +01:00
|
|
|
|
tvFilterDetail.textSize = f
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-22 20:56:24 +02:00
|
|
|
|
val spacing = activity.timeline_spacing
|
2019-12-03 15:55:30 +01:00
|
|
|
|
if(spacing != null) {
|
|
|
|
|
tvFollowerName.setLineSpacing(0f, spacing)
|
|
|
|
|
tvName.setLineSpacing(0f, spacing)
|
|
|
|
|
tvMentions.setLineSpacing(0f, spacing)
|
|
|
|
|
tvContentWarning.setLineSpacing(0f, spacing)
|
|
|
|
|
tvContent.setLineSpacing(0f, spacing)
|
|
|
|
|
btnShowMedia.setLineSpacing(0f, spacing)
|
2020-01-29 06:15:32 +01:00
|
|
|
|
btnCardImageShow.setLineSpacing(0f, spacing)
|
2019-12-03 15:55:30 +01:00
|
|
|
|
tvApplication.setLineSpacing(0f, spacing)
|
|
|
|
|
tvMessageHolder.setLineSpacing(0f, spacing)
|
|
|
|
|
btnListTL.setLineSpacing(0f, spacing)
|
|
|
|
|
tvTrendTagName.setLineSpacing(0f, spacing)
|
|
|
|
|
tvTrendTagCount.setLineSpacing(0f, spacing)
|
|
|
|
|
tvFilterPhrase.setLineSpacing(0f, spacing)
|
|
|
|
|
tvMediaDescription.setLineSpacing(0f, spacing)
|
|
|
|
|
tvCardText.setLineSpacing(0f, spacing)
|
|
|
|
|
tvConversationIconsMore.setLineSpacing(0f, spacing)
|
|
|
|
|
tvConversationParticipants.setLineSpacing(0f, spacing)
|
|
|
|
|
tvBoosted.setLineSpacing(0f, spacing)
|
|
|
|
|
tvReply.setLineSpacing(0f, spacing)
|
2019-10-22 20:56:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
|
var s = activity.avatarIconSize
|
|
|
|
|
ivThumbnail.layoutParams.height = s
|
|
|
|
|
ivThumbnail.layoutParams.width = s
|
|
|
|
|
ivFollow.layoutParams.width = s
|
|
|
|
|
ivBoosted.layoutParams.width = s
|
2018-11-18 15:29:35 +01:00
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
s = ActMain.replyIconSize + (activity.density * 8).toInt()
|
2019-01-08 03:02:02 +01:00
|
|
|
|
ivReply.layoutParams.width = s
|
|
|
|
|
ivReply.layoutParams.height = s
|
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
|
s = activity.notificationTlIconSize
|
|
|
|
|
ivBoosted.layoutParams.height = s
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
this.content_invalidator = NetworkEmojiInvalidator(activity.handler, tvContent)
|
|
|
|
|
this.spoiler_invalidator = NetworkEmojiInvalidator(activity.handler, tvContentWarning)
|
|
|
|
|
this.boost_invalidator = NetworkEmojiInvalidator(activity.handler, tvBoosted)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
this.reply_invalidator = NetworkEmojiInvalidator(activity.handler, tvReply)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
this.follow_invalidator = NetworkEmojiInvalidator(activity.handler, tvFollowerName)
|
|
|
|
|
this.name_invalidator = NetworkEmojiInvalidator(activity.handler, tvName)
|
2019-12-15 14:01:42 +01:00
|
|
|
|
this.lastActive_invalidator = NetworkEmojiInvalidator(activity.handler, tvLastStatusAt)
|
2019-12-15 16:34:46 +01:00
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
val cardBackground = llCardOuter.background
|
|
|
|
|
if(cardBackground is PreviewCardBorder) {
|
|
|
|
|
val density = activity.density
|
|
|
|
|
cardBackground.round = (density * 8f)
|
|
|
|
|
cardBackground.width = (density * 1f)
|
|
|
|
|
}
|
2019-05-05 06:41:13 +02:00
|
|
|
|
|
2020-01-29 06:15:32 +01:00
|
|
|
|
val textShowMedia = SpannableString(activity.getString(R.string.tap_to_show))
|
|
|
|
|
.apply {
|
|
|
|
|
val colorBg = getAttributeColor(activity, R.attr.colorShowMediaBackground)
|
|
|
|
|
.applyAlphaMultiplier(0.5f)
|
|
|
|
|
setSpan(
|
|
|
|
|
BackgroundColorSpan(colorBg),
|
|
|
|
|
0,
|
|
|
|
|
this.length,
|
|
|
|
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnShowMedia.text = textShowMedia
|
|
|
|
|
btnCardImageShow.text = textShowMedia
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
fun onViewRecycled() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-21 13:46:36 +01:00
|
|
|
|
fun bind(
|
|
|
|
|
list_adapter : ItemListAdapter,
|
|
|
|
|
column : Column,
|
|
|
|
|
bSimpleList : Boolean,
|
|
|
|
|
item : TimelineItem
|
|
|
|
|
) {
|
2018-11-15 23:08:11 +01:00
|
|
|
|
val b = Benchmark(log, "Item-bind", 40L)
|
2018-08-21 03:53:52 +02:00
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
this.list_adapter = list_adapter
|
|
|
|
|
this.column = column
|
|
|
|
|
this.bSimpleList = bSimpleList
|
|
|
|
|
|
|
|
|
|
this.access_info = column.access_info
|
|
|
|
|
|
2018-08-22 03:05:54 +02:00
|
|
|
|
val font_bold = ActMain.timeline_font_bold
|
|
|
|
|
val font_normal = ActMain.timeline_font
|
|
|
|
|
viewRoot.scan { v ->
|
|
|
|
|
try {
|
|
|
|
|
when(v) {
|
|
|
|
|
// ボタンは太字なので触らない
|
|
|
|
|
is CountImageButton -> {
|
|
|
|
|
}
|
|
|
|
|
// ボタンは太字なので触らない
|
|
|
|
|
is Button -> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
is TextView -> v.typeface = when {
|
|
|
|
|
v === tvName ||
|
|
|
|
|
v === tvFollowerName ||
|
|
|
|
|
v === tvBoosted ||
|
2018-08-23 05:46:14 +02:00
|
|
|
|
v === tvReply ||
|
2018-08-22 03:05:54 +02:00
|
|
|
|
v === tvTrendTagCount ||
|
|
|
|
|
v === tvTrendTagName ||
|
2018-11-11 11:43:20 +01:00
|
|
|
|
v === tvConversationIconsMore ||
|
|
|
|
|
v === tvConversationParticipants ||
|
2018-08-22 03:05:54 +02:00
|
|
|
|
v === tvFilterPhrase -> font_bold
|
|
|
|
|
else -> font_normal
|
2018-01-17 18:39:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-22 03:05:54 +02:00
|
|
|
|
} catch(ex : Throwable) {
|
|
|
|
|
log.trace(ex)
|
2018-01-17 18:39:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bSimpleList) {
|
|
|
|
|
|
|
|
|
|
viewRoot.setOnTouchListener { _, ev ->
|
|
|
|
|
// ポップアップを閉じた時にクリックでリストを触ったことになってしまう不具合の回避
|
|
|
|
|
val now = SystemClock.elapsedRealtime()
|
|
|
|
|
// ポップアップを閉じた直後はタッチダウンを無視する
|
|
|
|
|
if(now - StatusButtonsPopup.last_popup_close >= 30L) {
|
|
|
|
|
false
|
|
|
|
|
} else {
|
|
|
|
|
val action = ev.action
|
|
|
|
|
log.d("onTouchEvent action=$action")
|
|
|
|
|
true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
viewRoot.setOnClickListener { viewClicked ->
|
|
|
|
|
activity.closeListItemPopup()
|
2018-01-18 22:22:27 +01:00
|
|
|
|
status_showing?.let { status ->
|
2018-10-28 14:08:10 +01:00
|
|
|
|
val popup =
|
|
|
|
|
StatusButtonsPopup(activity, column, bSimpleList, this@ItemViewHolder)
|
2018-01-17 18:39:16 +01:00
|
|
|
|
activity.listItemPopup = popup
|
|
|
|
|
popup.show(
|
|
|
|
|
list_adapter.columnVh.listView,
|
|
|
|
|
viewClicked,
|
|
|
|
|
status,
|
|
|
|
|
item as? TootNotification
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
llButtonBar.visibility = View.GONE
|
|
|
|
|
this.buttons_for_status = null
|
|
|
|
|
} else {
|
|
|
|
|
viewRoot.isClickable = false
|
|
|
|
|
llButtonBar.visibility = View.VISIBLE
|
|
|
|
|
this.buttons_for_status = StatusButtons(
|
|
|
|
|
activity,
|
|
|
|
|
column,
|
|
|
|
|
false,
|
2018-10-28 14:08:10 +01:00
|
|
|
|
statusButtonsViewHolder,
|
|
|
|
|
this
|
2018-01-17 18:39:16 +01:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-18 22:22:27 +01:00
|
|
|
|
this.status_showing = null
|
2018-08-23 05:46:14 +02:00
|
|
|
|
this.status_reply = null
|
2018-01-04 19:52:25 +01:00
|
|
|
|
this.status_account = null
|
|
|
|
|
this.boost_account = null
|
|
|
|
|
this.follow_account = null
|
2018-01-20 07:51:14 +01:00
|
|
|
|
this.boost_time = 0L
|
2018-08-20 07:10:56 +02:00
|
|
|
|
this.viewRoot.setBackgroundColor(0)
|
2018-08-21 12:19:02 +02:00
|
|
|
|
this.boostedAction = defaultBoostedAction
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-12-08 16:29:07 +01:00
|
|
|
|
llInstanceTicker.visibility = View.GONE
|
2018-01-04 19:52:25 +01:00
|
|
|
|
llBoosted.visibility = View.GONE
|
2018-08-23 05:46:14 +02:00
|
|
|
|
llReply.visibility = View.GONE
|
2018-01-04 19:52:25 +01:00
|
|
|
|
llFollow.visibility = View.GONE
|
|
|
|
|
llStatus.visibility = View.GONE
|
|
|
|
|
llSearchTag.visibility = View.GONE
|
|
|
|
|
llList.visibility = View.GONE
|
2018-04-17 18:29:50 +02:00
|
|
|
|
llFollowRequest.visibility = View.GONE
|
2018-05-20 00:31:59 +02:00
|
|
|
|
tvMessageHolder.visibility = View.GONE
|
2018-05-30 07:18:45 +02:00
|
|
|
|
llTrendTag.visibility = View.GONE
|
2018-07-07 07:15:16 +02:00
|
|
|
|
llFilter.visibility = View.GONE
|
2018-11-11 11:43:20 +01:00
|
|
|
|
tvMediaDescription.visibility = View.GONE
|
2018-11-12 18:19:57 +01:00
|
|
|
|
llCardOuter.visibility = View.GONE
|
2018-11-11 11:43:20 +01:00
|
|
|
|
tvCardText.visibility = View.GONE
|
2020-01-29 06:15:32 +01:00
|
|
|
|
flCardImage.visibility = View.GONE
|
2018-11-11 11:43:20 +01:00
|
|
|
|
llConversationIcons.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
removeExtraView()
|
2018-01-21 13:46:36 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
var c : Int
|
2018-11-19 23:46:14 +01:00
|
|
|
|
c = column.getContentColor()
|
2018-11-18 03:38:52 +01:00
|
|
|
|
this.content_color = c
|
2019-01-20 10:27:29 +01:00
|
|
|
|
this.content_color_csl = ColorStateList.valueOf(c)
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
2018-01-10 16:47:35 +01:00
|
|
|
|
tvBoosted.setTextColor(c)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
tvReply.setTextColor(c)
|
2018-01-10 16:47:35 +01:00
|
|
|
|
tvFollowerName.setTextColor(c)
|
|
|
|
|
tvName.setTextColor(c)
|
|
|
|
|
tvMentions.setTextColor(c)
|
|
|
|
|
tvContentWarning.setTextColor(c)
|
|
|
|
|
tvContent.setTextColor(c)
|
|
|
|
|
//NSFWは文字色固定 btnShowMedia.setTextColor( c );
|
2018-01-14 22:47:42 +01:00
|
|
|
|
tvApplication.setTextColor(c)
|
2018-05-20 00:31:59 +02:00
|
|
|
|
tvMessageHolder.setTextColor(c)
|
2018-05-30 07:18:45 +02:00
|
|
|
|
tvTrendTagName.setTextColor(c)
|
|
|
|
|
tvTrendTagCount.setTextColor(c)
|
2019-09-13 17:49:19 +02:00
|
|
|
|
cvTagHistory.setColor(c)
|
2018-07-07 07:15:16 +02:00
|
|
|
|
tvFilterPhrase.setTextColor(c)
|
2018-11-11 11:43:20 +01:00
|
|
|
|
tvMediaDescription.setTextColor(c)
|
|
|
|
|
tvCardText.setTextColor(c)
|
|
|
|
|
tvConversationIconsMore.setTextColor(c)
|
|
|
|
|
tvConversationParticipants.setTextColor(c)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
|
(llCardOuter.background as? PreviewCardBorder)?.let {
|
|
|
|
|
val rgb = c and 0xffffff
|
2018-11-18 15:29:35 +01:00
|
|
|
|
val alpha = max(1, c ushr (24 + 1)) // 本来の値の半分にする
|
|
|
|
|
it.color = rgb or (alpha shl 24)
|
2018-11-12 18:19:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-19 23:46:14 +01:00
|
|
|
|
c = column.getAcctColor()
|
2018-01-14 22:47:42 +01:00
|
|
|
|
this.acct_color = c
|
|
|
|
|
tvBoostedTime.setTextColor(c)
|
|
|
|
|
tvTime.setTextColor(c)
|
2018-05-30 07:18:45 +02:00
|
|
|
|
tvTrendTagDesc.setTextColor(c)
|
2018-11-18 03:38:52 +01:00
|
|
|
|
tvFilterDetail.setTextColor(c)
|
2018-07-07 07:15:16 +02:00
|
|
|
|
tvFilterPhrase.setTextColor(c)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
|
// 以下のビューの文字色はsetAcct() で設定される
|
|
|
|
|
// tvBoostedAcct.setTextColor(c)
|
|
|
|
|
// tvFollowerAcct.setTextColor(c)
|
|
|
|
|
// tvAcct.setTextColor(c)
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
this.item = item
|
|
|
|
|
when(item) {
|
|
|
|
|
is TootStatus -> {
|
|
|
|
|
val reblog = item.reblog
|
2018-08-31 14:47:40 +02:00
|
|
|
|
when {
|
2018-08-23 05:46:14 +02:00
|
|
|
|
reblog == null -> showStatusOrReply(item)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2018-08-23 05:46:14 +02:00
|
|
|
|
item.hasAnyContent() -> {
|
|
|
|
|
// 引用Renote
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorBoost(activity.pref)
|
2019-09-23 19:02:01 +02:00
|
|
|
|
showReply(reblog, R.drawable.ic_repeat, R.string.renote_to)
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showStatus(item, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
|
|
|
|
else -> {
|
2018-08-23 05:46:14 +02:00
|
|
|
|
// 引用なしブースト
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorBoost(activity.pref)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
showBoost(
|
|
|
|
|
item.accountRef,
|
|
|
|
|
item.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_repeat,
|
2019-04-04 05:13:15 +02:00
|
|
|
|
R.string.display_name_boosted_by,
|
|
|
|
|
boost_status = item
|
2018-08-23 05:46:14 +02:00
|
|
|
|
)
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showStatusOrReply(item.reblog, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-20 00:31:59 +02:00
|
|
|
|
is TootAccountRef -> showAccount(item)
|
|
|
|
|
|
|
|
|
|
is TootNotification -> showNotification(item)
|
2018-05-24 18:33:09 +02:00
|
|
|
|
|
2018-05-20 00:31:59 +02:00
|
|
|
|
is TootGap -> showGap()
|
2019-08-12 06:36:42 +02:00
|
|
|
|
is TootSearchGap -> showSearchGap(item)
|
2018-05-20 00:31:59 +02:00
|
|
|
|
is TootDomainBlock -> showDomainBlock(item)
|
|
|
|
|
is TootList -> showList(item)
|
|
|
|
|
|
|
|
|
|
is TootMessageHolder -> showMessageHolder(item)
|
2018-08-21 03:53:52 +02:00
|
|
|
|
|
2018-05-30 07:18:45 +02:00
|
|
|
|
is TootTag -> showSearchTag(item)
|
2018-05-20 00:31:59 +02:00
|
|
|
|
|
2018-07-07 07:15:16 +02:00
|
|
|
|
is TootFilter -> showFilter(item)
|
|
|
|
|
|
2018-10-09 01:20:43 +02:00
|
|
|
|
is TootConversationSummary -> {
|
2018-11-16 15:44:23 +01:00
|
|
|
|
showStatusOrReply(item.last_status)
|
2018-11-11 11:43:20 +01:00
|
|
|
|
showConversationIcons(item)
|
2018-10-09 01:20:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
is TootScheduled -> {
|
2019-01-06 11:17:54 +01:00
|
|
|
|
showScheduled(item)
|
|
|
|
|
}
|
2019-01-16 13:33:07 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
else -> {
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-15 23:08:11 +01:00
|
|
|
|
b.report()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-06 11:17:54 +01:00
|
|
|
|
private fun showScheduled(item : TootScheduled) {
|
2019-01-06 15:55:25 +01:00
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
llStatus.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
|
|
this.viewRoot.setBackgroundColor(0)
|
|
|
|
|
|
|
|
|
|
showStatusTimeScheduled(activity, tvTime, item)
|
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
val who = access_info.loginAccount !!
|
2019-01-06 15:55:25 +01:00
|
|
|
|
val whoRef = TootAccountRef(TootParser(activity, access_info), who)
|
2019-01-16 13:33:07 +01:00
|
|
|
|
this.status_account = whoRef
|
2019-01-06 15:55:25 +01:00
|
|
|
|
|
|
|
|
|
setAcct(tvAcct, access_info.getFullAcct(who), who.acct)
|
|
|
|
|
|
|
|
|
|
tvName.text = whoRef.decoded_display_name
|
|
|
|
|
name_invalidator.register(whoRef.decoded_display_name)
|
|
|
|
|
ivThumbnail.setImageUrl(
|
|
|
|
|
activity.pref,
|
|
|
|
|
Styler.calcIconRound(ivThumbnail.layoutParams),
|
|
|
|
|
access_info.supplyBaseUrl(who.avatar_static),
|
|
|
|
|
access_info.supplyBaseUrl(who.avatar)
|
|
|
|
|
)
|
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
val content = SpannableString(item.text ?: "")
|
2019-01-06 15:55:25 +01:00
|
|
|
|
|
|
|
|
|
tvMentions.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
tvContent.text = content
|
|
|
|
|
content_invalidator.register(content)
|
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
tvContent.minLines = - 1
|
2019-01-06 15:55:25 +01:00
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
val decoded_spoiler_text = SpannableString(item.spoiler_text ?: "")
|
2019-01-06 15:55:25 +01:00
|
|
|
|
when {
|
|
|
|
|
decoded_spoiler_text.isNotEmpty() -> {
|
|
|
|
|
// 元データに含まれるContent Warning を使う
|
|
|
|
|
llContentWarning.visibility = View.VISIBLE
|
|
|
|
|
tvContentWarning.text = decoded_spoiler_text
|
|
|
|
|
spoiler_invalidator.register(decoded_spoiler_text)
|
2019-06-04 01:24:54 +02:00
|
|
|
|
val cw_shown = ContentWarning.isShown(item.uri, access_info.expand_cw)
|
2019-01-06 15:55:25 +01:00
|
|
|
|
showContent(cw_shown)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
|
// CWしない
|
|
|
|
|
llContentWarning.visibility = View.GONE
|
|
|
|
|
llContents.visibility = View.VISIBLE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val media_attachments = item.media_attachments
|
2019-01-16 13:33:07 +01:00
|
|
|
|
if(media_attachments?.isEmpty() != false) {
|
2019-01-06 15:55:25 +01:00
|
|
|
|
flMedia.visibility = View.GONE
|
|
|
|
|
llMedia.visibility = View.GONE
|
|
|
|
|
btnShowMedia.visibility = View.GONE
|
|
|
|
|
} else {
|
|
|
|
|
flMedia.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
|
|
// hide sensitive media
|
|
|
|
|
val default_shown = when {
|
|
|
|
|
column.hide_media_default -> false
|
|
|
|
|
access_info.dont_hide_nsfw -> true
|
|
|
|
|
else -> ! item.sensitive
|
|
|
|
|
}
|
2019-01-16 13:33:07 +01:00
|
|
|
|
val is_shown = MediaShown.isShown(item.uri, default_shown)
|
2019-01-06 15:55:25 +01:00
|
|
|
|
|
|
|
|
|
btnShowMedia.visibility = if(! is_shown) View.VISIBLE else View.GONE
|
|
|
|
|
llMedia.visibility = if(! is_shown) View.GONE else View.VISIBLE
|
|
|
|
|
val sb = StringBuilder()
|
|
|
|
|
setMedia(media_attachments, sb, ivMedia1, 0)
|
|
|
|
|
setMedia(media_attachments, sb, ivMedia2, 1)
|
|
|
|
|
setMedia(media_attachments, sb, ivMedia3, 2)
|
|
|
|
|
setMedia(media_attachments, sb, ivMedia4, 3)
|
|
|
|
|
if(sb.isNotEmpty()) {
|
|
|
|
|
tvMediaDescription.visibility = View.VISIBLE
|
|
|
|
|
tvMediaDescription.text = sb
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
setIconDrawableId(
|
2019-01-06 15:55:25 +01:00
|
|
|
|
activity,
|
|
|
|
|
btnHideMedia,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_close,
|
2019-01-06 15:55:25 +01:00
|
|
|
|
color = content_color,
|
|
|
|
|
alphaMultiplier = Styler.boost_alpha
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buttons_for_status?.hide()
|
|
|
|
|
|
|
|
|
|
tvApplication.visibility = View.GONE
|
2019-01-16 13:33:07 +01:00
|
|
|
|
|
|
|
|
|
} catch(ex : Throwable) {
|
2019-01-06 15:55:25 +01:00
|
|
|
|
|
|
|
|
|
}
|
2019-01-06 11:17:54 +01:00
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
2019-01-16 13:33:07 +01:00
|
|
|
|
btnSearchTag.text = activity.getString(R.string.scheduled_status) + " " +
|
|
|
|
|
TootStatus.formatTime(
|
|
|
|
|
activity,
|
|
|
|
|
item.timeScheduledAt,
|
|
|
|
|
true
|
|
|
|
|
)
|
2019-01-06 11:17:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-09 01:20:43 +02:00
|
|
|
|
private fun removeExtraView() {
|
|
|
|
|
llExtra.scan { v ->
|
|
|
|
|
if(v is MyNetworkImageView) {
|
|
|
|
|
v.cancelLoading()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
llExtra.removeAllViews()
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
|
|
|
|
for(invalidator in extra_invalidator_list) {
|
|
|
|
|
invalidator.register(null)
|
|
|
|
|
}
|
|
|
|
|
extra_invalidator_list.clear()
|
|
|
|
|
|
2018-10-09 01:20:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
private fun showConversationIcons(cs : TootConversationSummary) {
|
2018-10-28 14:08:10 +01:00
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
val last_account_id = cs.last_status.account.id
|
2018-10-28 14:08:10 +01:00
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
val accountsOther = cs.accounts.filter { it.get().id != last_account_id }
|
|
|
|
|
if(accountsOther.isNotEmpty()) {
|
|
|
|
|
llConversationIcons.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
|
|
val size = accountsOther.size
|
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
tvConversationParticipants.text = if(size <= 1) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
activity.getString(R.string.conversation_to)
|
2018-11-12 18:19:57 +01:00
|
|
|
|
} else {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
activity.getString(R.string.participants)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun showIcon(iv : MyNetworkImageView, idx : Int) {
|
2018-11-11 13:17:36 +01:00
|
|
|
|
val bShown = idx < size
|
|
|
|
|
iv.visibility = if(bShown) View.VISIBLE else View.GONE
|
2018-11-12 18:19:57 +01:00
|
|
|
|
if(! bShown) return
|
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
val who = accountsOther[idx].get()
|
|
|
|
|
iv.setImageUrl(
|
|
|
|
|
activity.pref,
|
|
|
|
|
Styler.calcIconRound(iv.layoutParams),
|
|
|
|
|
access_info.supplyBaseUrl(who.avatar_static),
|
|
|
|
|
access_info.supplyBaseUrl(who.avatar)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-12 18:19:57 +01:00
|
|
|
|
|
|
|
|
|
if(cs.last_status.in_reply_to_id != null) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
|
|
|
|
btnSearchTag.text = activity.getString(R.string.show_conversation)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
private fun openConversationSummary() {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
val cs = item as? TootConversationSummary ?: return
|
|
|
|
|
|
|
|
|
|
if(cs.unread) {
|
|
|
|
|
cs.unread = false
|
|
|
|
|
// 表示の更新
|
|
|
|
|
list_adapter.notifyChange(
|
|
|
|
|
reason = "ConversationSummary reset unread",
|
|
|
|
|
reset = true
|
|
|
|
|
)
|
|
|
|
|
// 未読フラグのクリアをサーバに送る
|
2018-11-12 18:19:57 +01:00
|
|
|
|
Action_Toot.clearConversationUnread(activity, access_info, cs)
|
2018-11-11 11:43:20 +01:00
|
|
|
|
}
|
2018-10-09 01:20:43 +02:00
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
Action_Toot.conversation(
|
|
|
|
|
activity,
|
|
|
|
|
activity.nextPosition(column),
|
|
|
|
|
access_info,
|
|
|
|
|
cs.last_status
|
|
|
|
|
)
|
2018-10-09 01:20:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-04 12:29:48 +01:00
|
|
|
|
private fun showStatusOrReply(item : TootStatus, colorBgArg : Int = 0) {
|
|
|
|
|
var colorBg = colorBgArg
|
2018-08-23 05:46:14 +02:00
|
|
|
|
val reply = item.reply
|
2018-11-16 15:44:23 +01:00
|
|
|
|
val in_reply_to_id = item.in_reply_to_id
|
|
|
|
|
val in_reply_to_account_id = item.in_reply_to_account_id
|
|
|
|
|
when {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
reply != null -> {
|
2019-09-23 19:02:01 +02:00
|
|
|
|
showReply(reply, R.drawable.ic_reply, R.string.reply_to)
|
2019-03-06 10:49:02 +01:00
|
|
|
|
if(colorBgArg == 0) colorBg = Pref.ipEventBgColorMention(activity.pref)
|
2019-02-04 12:29:48 +01:00
|
|
|
|
}
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
2018-11-16 15:44:23 +01:00
|
|
|
|
in_reply_to_id != null && in_reply_to_account_id != null -> {
|
2019-09-23 19:02:01 +02:00
|
|
|
|
showReply(item, in_reply_to_account_id)
|
2019-03-06 10:49:02 +01:00
|
|
|
|
if(colorBgArg == 0) colorBg = Pref.ipEventBgColorMention(activity.pref)
|
2018-11-16 15:44:23 +01:00
|
|
|
|
}
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showStatus(item, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2019-09-23 18:03:27 +02:00
|
|
|
|
|
2018-05-20 00:31:59 +02:00
|
|
|
|
private fun showMessageHolder(item : TootMessageHolder) {
|
|
|
|
|
tvMessageHolder.visibility = View.VISIBLE
|
|
|
|
|
tvMessageHolder.text = item.text
|
|
|
|
|
tvMessageHolder.gravity = item.gravity
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
private fun showNotification(n : TootNotification) {
|
|
|
|
|
val n_status = n.status
|
2018-05-08 10:25:02 +02:00
|
|
|
|
val n_accountRef = n.accountRef
|
2018-05-18 19:08:46 +02:00
|
|
|
|
val n_account = n_accountRef?.get()
|
2018-08-23 05:46:14 +02:00
|
|
|
|
|
2019-02-04 05:19:57 +01:00
|
|
|
|
fun showNotificationStatus(item : TootStatus, colorBgDefault : Int) {
|
2018-08-23 05:46:14 +02:00
|
|
|
|
val reblog = item.reblog
|
2018-08-31 14:47:40 +02:00
|
|
|
|
when {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
reblog == null -> showStatusOrReply(item, colorBgDefault)
|
2018-11-18 15:29:35 +01:00
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
|
! item.hasAnyContent() -> {
|
|
|
|
|
// 通常のブースト。引用なしブースト。
|
|
|
|
|
// ブースト表示は通知イベントと被るのでしない
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showStatusOrReply(reblog, Pref.ipEventBgColorBoost(activity.pref))
|
2018-11-18 03:38:52 +01:00
|
|
|
|
}
|
2018-11-18 15:29:35 +01:00
|
|
|
|
|
2018-08-23 05:46:14 +02:00
|
|
|
|
else -> {
|
|
|
|
|
// 引用Renote
|
2019-09-23 19:02:01 +02:00
|
|
|
|
showReply(reblog, R.drawable.ic_repeat, R.string.renote_to)
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showStatus(item, Pref.ipEventBgColorQuote(activity.pref))
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
when(n.type) {
|
2018-08-21 12:19:02 +02:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
TootNotification.TYPE_FAVOURITE -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorFavourite(activity.pref)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
if(n_account != null) showBoost(
|
2018-05-08 10:25:02 +02:00
|
|
|
|
n_accountRef,
|
2018-01-21 13:46:36 +01:00
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
if(access_info.isNicoru(n_account)) R.drawable.ic_nicoru else R.drawable.ic_star,
|
2019-02-04 05:19:57 +01:00
|
|
|
|
R.string.display_name_favourited_by
|
2018-01-04 19:52:25 +01:00
|
|
|
|
)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(n_status != null) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showNotificationStatus(n_status, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 15:31:44 +02:00
|
|
|
|
TootNotification.TYPE_REBLOG -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorBoost(activity.pref)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
if(n_account != null) showBoost(
|
2018-05-08 10:25:02 +02:00
|
|
|
|
n_accountRef,
|
2018-01-21 13:46:36 +01:00
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_repeat,
|
2019-04-04 05:13:15 +02:00
|
|
|
|
R.string.display_name_boosted_by,
|
|
|
|
|
boost_status = n_status
|
2018-01-04 19:52:25 +01:00
|
|
|
|
)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(n_status != null) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showNotificationStatus(n_status, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
}
|
2018-08-21 15:31:44 +02:00
|
|
|
|
|
|
|
|
|
TootNotification.TYPE_RENOTE -> {
|
2018-08-21 12:19:02 +02:00
|
|
|
|
// 引用のないreblog
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorBoost(activity.pref)
|
2018-08-21 12:19:02 +02:00
|
|
|
|
if(n_account != null) showBoost(
|
|
|
|
|
n_accountRef,
|
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_repeat,
|
2019-04-04 05:13:15 +02:00
|
|
|
|
R.string.display_name_boosted_by,
|
|
|
|
|
boost_status = n_status
|
2018-08-21 12:19:02 +02:00
|
|
|
|
)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(n_status != null) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showNotificationStatus(n_status, colorBg)
|
2018-08-21 12:19:02 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-21 15:31:44 +02:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
TootNotification.TYPE_FOLLOW -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorFollow(activity.pref)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
if(n_account != null) {
|
|
|
|
|
showBoost(
|
2018-05-08 10:25:02 +02:00
|
|
|
|
n_accountRef,
|
2018-01-21 13:46:36 +01:00
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_follow_plus,
|
2019-02-04 05:19:57 +01:00
|
|
|
|
R.string.display_name_followed_by
|
2018-01-04 19:52:25 +01:00
|
|
|
|
)
|
2018-05-08 10:25:02 +02:00
|
|
|
|
showAccount(n_accountRef)
|
2019-02-04 05:19:57 +01:00
|
|
|
|
if(colorBg != 0) this.viewRoot.backgroundColor = colorBg
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2018-08-25 02:29:24 +02:00
|
|
|
|
TootNotification.TYPE_UNFOLLOW -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorUnfollow(activity.pref)
|
2018-08-25 02:29:24 +02:00
|
|
|
|
if(n_account != null) {
|
|
|
|
|
showBoost(
|
|
|
|
|
n_accountRef,
|
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_follow_cross,
|
2019-02-04 05:19:57 +01:00
|
|
|
|
R.string.display_name_unfollowed_by
|
2018-08-25 02:29:24 +02:00
|
|
|
|
)
|
|
|
|
|
showAccount(n_accountRef)
|
2019-02-04 05:19:57 +01:00
|
|
|
|
if(colorBg != 0) this.viewRoot.backgroundColor = colorBg
|
2018-08-25 02:29:24 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2018-11-18 03:38:52 +01:00
|
|
|
|
TootNotification.TYPE_MENTION,
|
|
|
|
|
TootNotification.TYPE_REPLY -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorMention(activity.pref)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
if(! bSimpleList && ! access_info.isMisskey) {
|
2019-08-24 05:35:22 +02:00
|
|
|
|
when {
|
|
|
|
|
n_account == null -> {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
n_status?.in_reply_to_id != null || n_status?.reply != null -> {
|
2018-11-18 03:38:52 +01:00
|
|
|
|
// トゥート内部に「~への返信」を表示するので、
|
|
|
|
|
// 通知イベントの「~からの返信」は表示しない
|
2019-08-24 05:35:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else -> // 返信ではなくメンションの場合は「~からの返信」を表示する
|
2018-11-18 03:38:52 +01:00
|
|
|
|
showBoost(
|
|
|
|
|
n_accountRef,
|
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_reply,
|
2019-02-04 05:19:57 +01:00
|
|
|
|
R.string.display_name_mentioned_by
|
2018-11-18 03:38:52 +01:00
|
|
|
|
)
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(n_status != null) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showNotificationStatus(n_status, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2018-08-21 15:31:44 +02:00
|
|
|
|
|
2018-08-21 12:19:02 +02:00
|
|
|
|
TootNotification.TYPE_REACTION -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorReaction(activity.pref)
|
2018-08-21 15:31:44 +02:00
|
|
|
|
val reaction = MisskeyReaction.shortcodeMap[n.reaction ?: ""]
|
2018-08-21 12:19:02 +02:00
|
|
|
|
if(n_account != null) showBoost(
|
|
|
|
|
n_accountRef,
|
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_question, // not used
|
2019-02-03 17:58:37 +01:00
|
|
|
|
R.string.display_name_reaction_by,
|
2020-01-04 14:36:01 +01:00
|
|
|
|
misskeyReaction = reaction
|
2018-08-21 12:19:02 +02:00
|
|
|
|
)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(n_status != null) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showNotificationStatus(n_status, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2018-08-21 12:19:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 15:31:44 +02:00
|
|
|
|
TootNotification.TYPE_QUOTE -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorQuote(activity.pref)
|
2018-08-21 12:19:02 +02:00
|
|
|
|
if(n_account != null) showBoost(
|
|
|
|
|
n_accountRef,
|
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_repeat,
|
2019-02-04 05:19:57 +01:00
|
|
|
|
R.string.display_name_quoted_by
|
2018-08-21 12:19:02 +02:00
|
|
|
|
)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(n_status != null) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showNotificationStatus(n_status, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2018-08-21 12:19:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 15:31:44 +02:00
|
|
|
|
TootNotification.TYPE_VOTE -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorVote(activity.pref)
|
2018-08-21 12:19:02 +02:00
|
|
|
|
if(n_account != null) showBoost(
|
|
|
|
|
n_accountRef,
|
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_vote,
|
2019-02-04 05:19:57 +01:00
|
|
|
|
R.string.display_name_voted_by
|
2018-08-21 12:19:02 +02:00
|
|
|
|
)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(n_status != null) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showNotificationStatus(n_status, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2018-08-21 12:19:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-16 16:56:27 +01:00
|
|
|
|
TootNotification.TYPE_FOLLOW_REQUEST,
|
|
|
|
|
TootNotification.TYPE_FOLLOW_REQUEST_MISSKEY -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = Pref.ipEventBgColorFollowRequest(activity.pref)
|
2018-08-21 12:19:02 +02:00
|
|
|
|
if(n_account != null) showBoost(
|
|
|
|
|
n_accountRef,
|
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_follow_wait,
|
2019-02-04 05:19:57 +01:00
|
|
|
|
R.string.display_name_follow_request_by
|
2018-08-21 12:19:02 +02:00
|
|
|
|
)
|
2019-02-04 05:19:57 +01:00
|
|
|
|
viewRoot.backgroundColor = colorBg
|
2018-08-21 12:19:02 +02:00
|
|
|
|
boostedAction = {
|
|
|
|
|
activity.addColumn(
|
|
|
|
|
activity.nextPosition(column)
|
|
|
|
|
, access_info
|
2019-08-23 01:49:20 +02:00
|
|
|
|
, ColumnType.FOLLOW_REQUESTS
|
2018-08-21 12:19:02 +02:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2019-03-13 18:34:56 +01:00
|
|
|
|
TootNotification.TYPE_POLL -> {
|
|
|
|
|
val colorBg = 0
|
|
|
|
|
if(n_account != null) showBoost(
|
|
|
|
|
n_accountRef,
|
|
|
|
|
n.time_created_at,
|
|
|
|
|
R.drawable.ic_vote,
|
|
|
|
|
R.string.end_of_polling_from
|
|
|
|
|
)
|
|
|
|
|
if(n_status != null) {
|
|
|
|
|
showNotificationStatus(n_status, colorBg)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
else -> {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val colorBg = 0
|
2018-08-21 12:19:02 +02:00
|
|
|
|
if(n_account != null) showBoost(
|
|
|
|
|
n_accountRef,
|
|
|
|
|
n.time_created_at,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_question,
|
2019-02-04 05:19:57 +01:00
|
|
|
|
R.string.unknown_notification_from
|
2018-08-21 12:19:02 +02:00
|
|
|
|
)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(n_status != null) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
showNotificationStatus(n_status, colorBg)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
2018-08-21 12:19:02 +02:00
|
|
|
|
tvMessageHolder.visibility = View.VISIBLE
|
|
|
|
|
tvMessageHolder.text = "notification type is ${n.type}"
|
|
|
|
|
tvMessageHolder.gravity = Gravity.CENTER
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun showList(list : TootList) {
|
|
|
|
|
llList.visibility = View.VISIBLE
|
|
|
|
|
btnListTL.text = list.title
|
2019-01-20 10:27:29 +01:00
|
|
|
|
btnListTL.textColor = content_color
|
|
|
|
|
btnListMore.imageTintList = content_color_csl
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun showDomainBlock(domain_block : TootDomainBlock) {
|
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
|
|
|
|
btnSearchTag.text = domain_block.domain
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-04 20:07:55 +02:00
|
|
|
|
private fun showFilter(filter : TootFilter) {
|
2018-07-07 07:15:16 +02:00
|
|
|
|
llFilter.visibility = View.VISIBLE
|
|
|
|
|
tvFilterPhrase.text = filter.phrase
|
2018-08-04 20:07:55 +02:00
|
|
|
|
|
2018-07-07 07:15:16 +02:00
|
|
|
|
val sb = StringBuffer()
|
2018-07-08 19:00:47 +02:00
|
|
|
|
//
|
2018-08-04 20:07:55 +02:00
|
|
|
|
sb.append(activity.getString(R.string.filter_context))
|
2018-07-07 07:15:16 +02:00
|
|
|
|
.append(": ")
|
|
|
|
|
.append(filter.getContextNames(activity).joinToString("/"))
|
2018-07-08 19:00:47 +02:00
|
|
|
|
//
|
2018-07-10 08:44:34 +02:00
|
|
|
|
val flags = ArrayList<String>()
|
2018-08-04 20:07:55 +02:00
|
|
|
|
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()) {
|
2018-07-10 08:44:34 +02:00
|
|
|
|
sb.append('\n')
|
2018-08-04 20:07:55 +02:00
|
|
|
|
.append(flags.joinToString(", "))
|
2018-07-10 08:44:34 +02:00
|
|
|
|
}
|
|
|
|
|
//
|
2018-08-04 20:07:55 +02:00
|
|
|
|
if(filter.time_expires_at != 0L) {
|
2018-07-08 19:00:47 +02:00
|
|
|
|
sb.append('\n')
|
2018-07-07 07:15:16 +02:00
|
|
|
|
.append(activity.getString(R.string.filter_expires_at))
|
|
|
|
|
.append(": ")
|
2018-08-04 20:07:55 +02:00
|
|
|
|
.append(TootStatus.formatTime(activity, filter.time_expires_at, false))
|
2018-07-07 07:15:16 +02:00
|
|
|
|
}
|
2018-08-04 20:07:55 +02:00
|
|
|
|
|
2018-07-07 07:15:16 +02:00
|
|
|
|
tvFilterDetail.text = sb.toString()
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-20 07:51:14 +01:00
|
|
|
|
private fun showSearchTag(tag : TootTag) {
|
2019-09-23 18:03:27 +02:00
|
|
|
|
if(tag.history?.isNotEmpty() == true) {
|
2019-09-13 17:49:19 +02:00
|
|
|
|
llTrendTag.visibility = View.VISIBLE
|
|
|
|
|
tvTrendTagName.text = "#${tag.name}"
|
|
|
|
|
tvTrendTagDesc.text =
|
|
|
|
|
activity.getString(R.string.people_talking, tag.accountDaily, tag.accountWeekly)
|
|
|
|
|
tvTrendTagCount.text = "${tag.countDaily}(${tag.countWeekly})"
|
|
|
|
|
cvTagHistory.setHistory(tag.history)
|
2019-09-23 18:03:27 +02:00
|
|
|
|
} else {
|
2019-09-13 17:49:19 +02:00
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
|
|
|
|
btnSearchTag.text = "#" + tag.name
|
|
|
|
|
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun showGap() {
|
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
|
|
|
|
btnSearchTag.text = activity.getString(R.string.read_gap)
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-23 01:49:20 +02:00
|
|
|
|
private fun showSearchGap(item : TootSearchGap) {
|
2019-08-12 06:36:42 +02:00
|
|
|
|
llSearchTag.visibility = View.VISIBLE
|
2019-08-23 01:49:20 +02:00
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
)
|
2019-08-12 06:36:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 19:02:01 +02:00
|
|
|
|
private fun showReply(iconId : Int, text : Spannable) {
|
|
|
|
|
|
2018-11-16 15:44:23 +01:00
|
|
|
|
llReply.visibility = View.VISIBLE
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
2019-09-23 19:02:01 +02:00
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
setIconDrawableId(
|
2018-11-18 03:38:52 +01:00
|
|
|
|
activity,
|
|
|
|
|
ivReply,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
iconId,
|
2018-11-18 15:29:35 +01:00
|
|
|
|
color = content_color,
|
|
|
|
|
alphaMultiplier = Styler.boost_alpha
|
2018-11-18 03:38:52 +01:00
|
|
|
|
)
|
|
|
|
|
|
2018-11-16 15:44:23 +01:00
|
|
|
|
tvReply.text = text
|
|
|
|
|
reply_invalidator.register(text)
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 19:02:01 +02:00
|
|
|
|
private fun showReply(reply : TootStatus, iconId : Int, stringId : Int) {
|
2018-08-23 05:46:14 +02:00
|
|
|
|
status_reply = reply
|
2019-09-23 19:02:01 +02:00
|
|
|
|
showReply(
|
|
|
|
|
iconId,
|
|
|
|
|
reply.accountRef.decoded_display_name.intoStringResource(activity, stringId)
|
|
|
|
|
)
|
2018-11-16 15:44:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 19:02:01 +02:00
|
|
|
|
private fun showReply(reply : TootStatus, accountId : EntityId) {
|
2019-09-23 18:03:27 +02:00
|
|
|
|
val name = if(accountId == reply.account.id) {
|
2019-09-23 19:02:01 +02:00
|
|
|
|
// 自己レスなら
|
2019-09-23 18:03:27 +02:00
|
|
|
|
AcctColor.getNicknameWithColor(access_info.getFullAcct(reply.account))
|
2018-11-18 03:38:52 +01:00
|
|
|
|
} else {
|
2019-09-23 18:03:27 +02:00
|
|
|
|
val m = reply.mentions?.find { it.id == accountId }
|
2018-11-18 03:38:52 +01:00
|
|
|
|
if(m != null) {
|
2018-11-18 15:29:35 +01:00
|
|
|
|
AcctColor.getNicknameWithColor(access_info.getFullAcct(m.acct))
|
2018-11-18 03:38:52 +01:00
|
|
|
|
} else {
|
2018-11-16 15:44:23 +01:00
|
|
|
|
SpannableString("ID(${accountId})")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val text = name.intoStringResource(activity, R.string.reply_to)
|
2019-09-23 18:03:27 +02:00
|
|
|
|
showReply(R.drawable.ic_reply, text)
|
2019-09-23 19:08:38 +02:00
|
|
|
|
|
|
|
|
|
// tootsearchはreplyオブジェクトがなくin_reply_toだけが提供される場合があるが
|
|
|
|
|
// tootsearchではどのタンスから読んだか分からないのでin_reply_toのIDも信用できない
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-08 10:55:08 +02:00
|
|
|
|
private fun showBoost(
|
|
|
|
|
whoRef : TootAccountRef,
|
|
|
|
|
time : Long,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
iconId : Int,
|
2018-08-21 12:19:02 +02:00
|
|
|
|
string_id : Int,
|
2020-01-04 14:36:01 +01:00
|
|
|
|
misskeyReaction : MisskeyReaction? = null,
|
2019-04-25 04:06:41 +02:00
|
|
|
|
boost_status : TootStatus? = null
|
2018-05-08 10:55:08 +02:00
|
|
|
|
) {
|
2018-05-08 10:25:02 +02:00
|
|
|
|
boost_account = whoRef
|
2018-05-18 19:08:46 +02:00
|
|
|
|
val who = whoRef.get()
|
2018-05-24 18:33:09 +02:00
|
|
|
|
|
|
|
|
|
val text : Spannable = if(string_id == R.string.display_name_followed_by) {
|
|
|
|
|
// フォローの場合 decoded_display_name が2箇所で表示に使われるのを避ける必要がある
|
|
|
|
|
who.decodeDisplayName(activity)
|
|
|
|
|
} else {
|
|
|
|
|
// それ以外の場合は decoded_display_name を再利用して構わない
|
|
|
|
|
whoRef.decoded_display_name
|
|
|
|
|
}.intoStringResource(activity, string_id)
|
|
|
|
|
|
2020-01-11 03:55:31 +01:00
|
|
|
|
val emojiResource = misskeyReaction?.emojiResource
|
2020-01-10 14:42:37 +01:00
|
|
|
|
if(emojiResource != null) {
|
|
|
|
|
emojiResource.loadToImageView(activity, ivBoosted)
|
2020-01-04 14:36:01 +01:00
|
|
|
|
// TODO パディング少し変える?
|
2018-08-21 15:31:44 +02:00
|
|
|
|
} else {
|
2019-01-16 13:33:07 +01:00
|
|
|
|
setIconDrawableId(
|
2018-11-18 03:38:52 +01:00
|
|
|
|
activity,
|
|
|
|
|
ivBoosted,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
iconId,
|
2018-11-18 15:29:35 +01:00
|
|
|
|
color = content_color,
|
|
|
|
|
alphaMultiplier = Styler.boost_alpha
|
2018-11-18 03:38:52 +01:00
|
|
|
|
)
|
2018-08-21 12:19:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-20 07:51:14 +01:00
|
|
|
|
boost_time = time
|
2018-01-04 19:52:25 +01:00
|
|
|
|
llBoosted.visibility = View.VISIBLE
|
2019-04-25 04:06:41 +02:00
|
|
|
|
showStatusTime(activity, tvBoostedTime, who, time = time, status = boost_status)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
tvBoosted.text = text
|
|
|
|
|
boost_invalidator.register(text)
|
|
|
|
|
setAcct(tvBoostedAcct, access_info.getFullAcct(who), who.acct)
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
|
private fun showAccount(whoRef : TootAccountRef) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
|
follow_account = whoRef
|
2018-05-18 19:08:46 +02:00
|
|
|
|
val who = whoRef.get()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
llFollow.visibility = View.VISIBLE
|
2018-01-21 13:46:36 +01:00
|
|
|
|
ivFollow.setImageUrl(
|
|
|
|
|
activity.pref,
|
|
|
|
|
Styler.calcIconRound(ivFollow.layoutParams),
|
2018-11-11 11:43:20 +01:00
|
|
|
|
access_info.supplyBaseUrl(who.avatar_static),
|
|
|
|
|
access_info.supplyBaseUrl(who.avatar)
|
2018-01-21 13:46:36 +01:00
|
|
|
|
)
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
|
tvFollowerName.text = whoRef.decoded_display_name
|
|
|
|
|
follow_invalidator.register(whoRef.decoded_display_name)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
setAcct(tvFollowerAcct, access_info.getFullAcct(who), who.acct)
|
|
|
|
|
|
2019-12-15 16:34:46 +01:00
|
|
|
|
who.setAccountExtra(access_info, tvLastStatusAt, lastActive_invalidator)
|
2019-08-29 18:16:21 +02:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val relation = UserRelation.load(access_info.db_id, who.id)
|
2018-11-18 15:29:35 +01:00
|
|
|
|
Styler.setFollowIcon(
|
|
|
|
|
activity,
|
|
|
|
|
btnFollow,
|
|
|
|
|
ivFollowedBy,
|
|
|
|
|
relation,
|
|
|
|
|
who,
|
|
|
|
|
content_color,
|
|
|
|
|
alphaMultiplier = Styler.boost_alpha
|
|
|
|
|
)
|
2018-04-17 18:29:50 +02:00
|
|
|
|
|
2019-08-23 01:49:20 +02:00
|
|
|
|
if(column.type == ColumnType.FOLLOW_REQUESTS) {
|
2018-04-17 18:29:50 +02:00
|
|
|
|
llFollowRequest.visibility = View.VISIBLE
|
2019-01-20 22:04:57 +01:00
|
|
|
|
btnFollowRequestAccept.imageTintList = content_color_csl
|
|
|
|
|
btnFollowRequestDeny.imageTintList = content_color_csl
|
2018-04-17 18:29:50 +02:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-04 05:19:57 +01:00
|
|
|
|
private fun showStatus(status : TootStatus, colorBg : Int = 0) {
|
2018-08-04 20:07:55 +02:00
|
|
|
|
|
2019-12-06 07:45:04 +01:00
|
|
|
|
val filteredWord = status.filteredWord
|
2019-12-15 16:34:46 +01:00
|
|
|
|
if(filteredWord != null) {
|
|
|
|
|
showMessageHolder(
|
|
|
|
|
TootMessageHolder(
|
|
|
|
|
if(Pref.bpShowFilteredWord(activity.pref)) {
|
|
|
|
|
"${activity.getString(R.string.filtered)} / $filteredWord"
|
|
|
|
|
} else {
|
|
|
|
|
activity.getString(R.string.filtered)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
)
|
2018-07-06 17:22:22 +02:00
|
|
|
|
return
|
|
|
|
|
}
|
2018-08-04 20:07:55 +02:00
|
|
|
|
|
2018-01-18 22:22:27 +01:00
|
|
|
|
this.status_showing = status
|
2018-01-04 19:52:25 +01:00
|
|
|
|
llStatus.visibility = View.VISIBLE
|
|
|
|
|
|
2018-08-21 03:53:52 +02:00
|
|
|
|
if(status.conversation_main) {
|
|
|
|
|
this.viewRoot.setBackgroundColor(
|
2018-12-01 00:02:18 +01:00
|
|
|
|
(getAttributeColor(
|
2018-08-21 03:53:52 +02:00
|
|
|
|
activity,
|
|
|
|
|
R.attr.colorImageButtonAccent
|
|
|
|
|
) and 0xffffff) or 0x20000000
|
|
|
|
|
)
|
2018-08-31 14:47:40 +02:00
|
|
|
|
} else {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
val c = colorBg.notZero()
|
|
|
|
|
?: when(status.getBackgroundColorType(access_info)) {
|
|
|
|
|
TootVisibility.UnlistedHome -> toot_color_unlisted
|
|
|
|
|
TootVisibility.PrivateFollowers -> toot_color_follower
|
|
|
|
|
TootVisibility.DirectSpecified -> toot_color_direct_user
|
|
|
|
|
TootVisibility.DirectPrivate -> toot_color_direct_me
|
|
|
|
|
else -> 0
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(c != 0) {
|
2019-02-04 05:19:57 +01:00
|
|
|
|
this.viewRoot.backgroundColor = c
|
2018-08-24 07:04:55 +02:00
|
|
|
|
}
|
2018-08-20 07:10:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-05 20:04:45 +02:00
|
|
|
|
showStatusTime(activity, tvTime, who = status.account, status = status)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
|
val whoRef = status.accountRef
|
2018-05-18 19:08:46 +02:00
|
|
|
|
val who = whoRef.get()
|
2018-05-08 10:25:02 +02:00
|
|
|
|
this.status_account = whoRef
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
setAcct(tvAcct, access_info.getFullAcct(who), who.acct)
|
|
|
|
|
|
|
|
|
|
// if(who == null) {
|
|
|
|
|
// tvName.text = "?"
|
|
|
|
|
// name_invalidator.register(null)
|
|
|
|
|
// ivThumbnail.setImageUrl(activity.pref, 16f, null, null)
|
|
|
|
|
// } else {
|
2018-05-08 10:25:02 +02:00
|
|
|
|
tvName.text = whoRef.decoded_display_name
|
|
|
|
|
name_invalidator.register(whoRef.decoded_display_name)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
ivThumbnail.setImageUrl(
|
2018-01-17 18:39:16 +01:00
|
|
|
|
activity.pref,
|
2018-01-18 08:53:32 +01:00
|
|
|
|
Styler.calcIconRound(ivThumbnail.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-12-16 12:24:44 +01:00
|
|
|
|
showInstanceTicker(who)
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
var content = status.decoded_content
|
2018-11-12 18:19:57 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
// ニコフレのアンケートの表示
|
|
|
|
|
val enquete = status.enquete
|
2019-08-24 05:35:22 +02:00
|
|
|
|
when {
|
|
|
|
|
enquete == null -> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enquete.pollType == TootPollsType.FriendsNico && enquete.type != TootPolls.TYPE_ENQUETE -> {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
// フレニコの投票の結果表示は普通にテキストを表示するだけでよい
|
2019-08-24 05:35:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else -> {
|
2018-08-24 18:24:11 +02:00
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
// アンケートの本文を上書きする
|
|
|
|
|
val question = enquete.decoded_question
|
2018-08-24 18:24:11 +02:00
|
|
|
|
if(question.isNotBlank()) content = question
|
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
showEnqueteItems(status, enquete)
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-20 01:33:57 +01:00
|
|
|
|
showPreviewCard(status)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
// if( status.decoded_tags == null ){
|
|
|
|
|
// tvTags.setVisibility( View.GONE );
|
|
|
|
|
// }else{
|
|
|
|
|
// tvTags.setVisibility( View.VISIBLE );
|
|
|
|
|
// tvTags.setText( status.decoded_tags );
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if(status.decoded_mentions.isEmpty()) {
|
|
|
|
|
tvMentions.visibility = View.GONE
|
|
|
|
|
} else {
|
|
|
|
|
tvMentions.visibility = View.VISIBLE
|
|
|
|
|
tvMentions.text = status.decoded_mentions
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(status.time_deleted_at > 0L) {
|
2018-08-23 05:46:14 +02:00
|
|
|
|
val s = SpannableStringBuilder()
|
|
|
|
|
.append('(')
|
2018-08-31 14:47:40 +02:00
|
|
|
|
.append(
|
|
|
|
|
activity.getString(
|
|
|
|
|
R.string.deleted_at,
|
|
|
|
|
TootStatus.formatTime(activity, status.time_deleted_at, true)
|
|
|
|
|
)
|
|
|
|
|
)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
.append(')')
|
2018-08-31 14:47:40 +02:00
|
|
|
|
content = s
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
tvContent.text = content
|
|
|
|
|
content_invalidator.register(content)
|
|
|
|
|
|
|
|
|
|
activity.checkAutoCW(status, content)
|
|
|
|
|
val r = status.auto_cw
|
|
|
|
|
|
|
|
|
|
tvContent.minLines = r?.originalLineCount ?: - 1
|
|
|
|
|
|
|
|
|
|
val decoded_spoiler_text = status.decoded_spoiler_text
|
|
|
|
|
when {
|
|
|
|
|
decoded_spoiler_text.isNotEmpty() -> {
|
|
|
|
|
// 元データに含まれるContent Warning を使う
|
|
|
|
|
llContentWarning.visibility = View.VISIBLE
|
|
|
|
|
tvContentWarning.text = status.decoded_spoiler_text
|
|
|
|
|
spoiler_invalidator.register(status.decoded_spoiler_text)
|
2019-06-04 01:24:54 +02:00
|
|
|
|
val cw_shown = ContentWarning.isShown(status, access_info.expand_cw)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
showContent(cw_shown)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r?.decoded_spoiler_text != null -> {
|
|
|
|
|
// 自動CW
|
|
|
|
|
llContentWarning.visibility = View.VISIBLE
|
|
|
|
|
tvContentWarning.text = r.decoded_spoiler_text
|
|
|
|
|
spoiler_invalidator.register(r.decoded_spoiler_text)
|
2019-06-04 01:24:54 +02:00
|
|
|
|
val cw_shown = ContentWarning.isShown(status, access_info.expand_cw)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
showContent(cw_shown)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
|
// CWしない
|
|
|
|
|
llContentWarning.visibility = View.GONE
|
|
|
|
|
llContents.visibility = View.VISIBLE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val media_attachments = status.media_attachments
|
|
|
|
|
if(media_attachments == null || media_attachments.isEmpty()) {
|
|
|
|
|
flMedia.visibility = View.GONE
|
2018-01-18 22:22:27 +01:00
|
|
|
|
llMedia.visibility = View.GONE
|
|
|
|
|
btnShowMedia.visibility = View.GONE
|
2018-01-04 19:52:25 +01:00
|
|
|
|
} else {
|
|
|
|
|
flMedia.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
|
|
// hide sensitive media
|
|
|
|
|
val default_shown = when {
|
|
|
|
|
column.hide_media_default -> false
|
|
|
|
|
access_info.dont_hide_nsfw -> true
|
|
|
|
|
else -> ! status.sensitive
|
|
|
|
|
}
|
|
|
|
|
val is_shown = MediaShown.isShown(status, default_shown)
|
2018-01-21 13:46:36 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
btnShowMedia.visibility = if(! is_shown) View.VISIBLE else View.GONE
|
2018-01-18 22:22:27 +01:00
|
|
|
|
llMedia.visibility = if(! is_shown) View.GONE else View.VISIBLE
|
2018-11-11 11:43:20 +01:00
|
|
|
|
val sb = StringBuilder()
|
|
|
|
|
setMedia(media_attachments, sb, ivMedia1, 0)
|
|
|
|
|
setMedia(media_attachments, sb, ivMedia2, 1)
|
|
|
|
|
setMedia(media_attachments, sb, ivMedia3, 2)
|
|
|
|
|
setMedia(media_attachments, sb, ivMedia4, 3)
|
2019-07-19 11:21:21 +02:00
|
|
|
|
|
2019-08-23 01:49:20 +02:00
|
|
|
|
val m0 =
|
|
|
|
|
if(media_attachments.isEmpty()) null else media_attachments[0] as? TootAttachment
|
2019-07-24 10:59:07 +02:00
|
|
|
|
btnShowMedia.blurhash = m0?.blurhash
|
2019-05-05 06:41:13 +02:00
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
if(sb.isNotEmpty()) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
tvMediaDescription.visibility = View.VISIBLE
|
|
|
|
|
tvMediaDescription.text = sb
|
|
|
|
|
}
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
setIconDrawableId(
|
2018-11-18 03:38:52 +01:00
|
|
|
|
activity,
|
|
|
|
|
btnHideMedia,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
R.drawable.ic_close,
|
2018-11-18 15:29:35 +01:00
|
|
|
|
color = content_color,
|
|
|
|
|
alphaMultiplier = Styler.boost_alpha
|
2018-11-18 03:38:52 +01:00
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 17:38:52 +01:00
|
|
|
|
makeReactionsView(status)
|
2018-08-21 03:53:52 +02:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
buttons_for_status?.bind(status, (item as? TootNotification))
|
2019-12-13 20:49:45 +01:00
|
|
|
|
|
2019-12-15 16:34:46 +01:00
|
|
|
|
var sb : StringBuilder? = null
|
|
|
|
|
|
|
|
|
|
fun prepareSb() : StringBuilder =
|
|
|
|
|
sb?.append(", ") ?: StringBuilder().also { sb = it }
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
val application = status.application
|
2019-12-13 20:49:45 +01:00
|
|
|
|
if(application != null &&
|
|
|
|
|
(column.type == ColumnType.CONVERSATION || Pref.bpShowAppName(activity.pref))
|
2018-01-17 02:16:26 +01:00
|
|
|
|
) {
|
2019-12-13 20:49:45 +01:00
|
|
|
|
prepareSb().append(activity.getString(R.string.application_is, application.name ?: ""))
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-15 16:34:46 +01:00
|
|
|
|
val language = status.language
|
|
|
|
|
if(language != null &&
|
|
|
|
|
(column.type == ColumnType.CONVERSATION || Pref.bpShowLanguage(activity.pref))
|
|
|
|
|
) {
|
|
|
|
|
prepareSb().append(activity.getString(R.string.language_is, language))
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2019-12-15 16:34:46 +01:00
|
|
|
|
|
|
|
|
|
tvApplication.vg(sb != null)?.text = sb
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 05:47:16 +01:00
|
|
|
|
private fun showInstanceTicker(who : TootAccount) {
|
2018-12-16 12:24:44 +01:00
|
|
|
|
try {
|
2018-12-26 05:47:16 +01:00
|
|
|
|
if(! Column.useInstanceTicker) return
|
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
val host = who.host
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
// LTLでホスト名が同じならTickerを表示しない
|
2019-08-23 01:49:20 +02:00
|
|
|
|
when(column.type) {
|
|
|
|
|
ColumnType.LOCAL, ColumnType.LOCAL_AROUND -> {
|
2018-12-26 05:47:16 +01:00
|
|
|
|
if(host == access_info.host) return
|
2018-12-16 12:24:44 +01:00
|
|
|
|
}
|
2019-08-23 01:49:20 +02:00
|
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
|
|
|
|
|
|
}
|
2018-12-16 12:24:44 +01:00
|
|
|
|
}
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
val item = InstanceTicker.lastList[host] ?: return
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
tvInstanceTicker.text = item.name
|
|
|
|
|
tvInstanceTicker.textColor = item.colorText
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
val density = activity.density
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
val lp = ivInstanceTicker.layoutParams
|
2018-12-26 05:47:16 +01:00
|
|
|
|
lp.height = (density * 16f + 0.5f).toInt()
|
|
|
|
|
lp.width = (density * item.imageWidth + 0.5f).toInt()
|
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
ivInstanceTicker.layoutParams = lp
|
|
|
|
|
ivInstanceTicker.setImageUrl(activity.pref, 0f, item.image)
|
|
|
|
|
val colorBg = item.colorBg
|
|
|
|
|
when {
|
2018-12-26 05:47:16 +01:00
|
|
|
|
colorBg.isEmpty() -> {
|
2018-12-16 12:24:44 +01:00
|
|
|
|
tvInstanceTicker.background = null
|
|
|
|
|
ivInstanceTicker.background = null
|
|
|
|
|
}
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
colorBg.size == 1 -> {
|
|
|
|
|
tvInstanceTicker.setBackgroundColor(colorBg.first())
|
|
|
|
|
ivInstanceTicker.setBackgroundColor(colorBg.first())
|
|
|
|
|
}
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
else -> {
|
|
|
|
|
ivInstanceTicker.setBackgroundColor(colorBg.last())
|
|
|
|
|
tvInstanceTicker.background = colorBg.getGradation()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
llInstanceTicker.visibility = View.VISIBLE
|
|
|
|
|
llInstanceTicker.requestLayout()
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
|
|
|
|
} catch(ex : Throwable) {
|
2018-12-16 12:24:44 +01:00
|
|
|
|
log.trace(ex)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-05 20:04:45 +02:00
|
|
|
|
private fun showStatusTime(
|
|
|
|
|
activity : ActMain,
|
|
|
|
|
tv : TextView,
|
|
|
|
|
@Suppress("UNUSED_PARAMETER") who : TootAccount,
|
|
|
|
|
status : TootStatus? = null,
|
|
|
|
|
time : Long? = null
|
|
|
|
|
) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val sb = SpannableStringBuilder()
|
|
|
|
|
|
2018-04-05 20:04:45 +02:00
|
|
|
|
// if(access_info.getFullAcct(who) == "unarist@mstdn.maud.io") {
|
|
|
|
|
// // if(sb.isNotEmpty()) sb.append(' ')
|
|
|
|
|
//
|
|
|
|
|
// val start = sb.length
|
|
|
|
|
// sb.append("unarist")
|
|
|
|
|
// val end = sb.length
|
|
|
|
|
// val icon_id = R.drawable.unarist
|
|
|
|
|
// sb.setSpan(
|
|
|
|
|
// EmojiImageSpan(activity, icon_id),
|
|
|
|
|
// start,
|
|
|
|
|
// end,
|
|
|
|
|
// Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
|
|
// )
|
|
|
|
|
// }
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-04-05 20:04:45 +02:00
|
|
|
|
if(status != null) {
|
2018-05-08 10:55:08 +02:00
|
|
|
|
|
2018-08-20 19:37:42 +02:00
|
|
|
|
if(status.account.isAdmin) {
|
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_shield, "admin")
|
|
|
|
|
}
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2018-08-24 13:40:19 +02:00
|
|
|
|
if(status.account.isPro) {
|
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_authorized, "pro")
|
|
|
|
|
}
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2018-08-20 19:37:42 +02:00
|
|
|
|
if(status.account.isCat) {
|
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_cat, "cat")
|
|
|
|
|
}
|
2018-08-21 03:53:52 +02:00
|
|
|
|
|
2018-05-10 00:25:44 +02:00
|
|
|
|
// botマーク
|
2018-05-08 10:55:08 +02:00
|
|
|
|
if(status.account.bot) {
|
2018-05-10 00:25:44 +02:00
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_bot, "bot")
|
2018-08-21 01:20:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// mobileマーク
|
|
|
|
|
if(status.viaMobile) {
|
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_mobile, "mobile")
|
2018-05-08 10:55:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-10 00:25:44 +02:00
|
|
|
|
// NSFWマーク
|
2018-04-05 20:04:45 +02:00
|
|
|
|
if(status.hasMedia() && status.sensitive) {
|
2018-05-10 00:25:44 +02:00
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
2018-11-18 03:38:52 +01:00
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_eye_off, "NSFW")
|
2018-04-05 20:04:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-10 00:25:44 +02:00
|
|
|
|
// visibility
|
2019-01-16 13:33:07 +01:00
|
|
|
|
val visIconId =
|
|
|
|
|
Styler.getVisibilityIconId(access_info.isMisskey, status.visibility)
|
|
|
|
|
if(R.drawable.ic_public != visIconId) {
|
2018-05-10 00:25:44 +02:00
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
2018-11-18 03:38:52 +01:00
|
|
|
|
sb.appendColorShadeIcon(
|
|
|
|
|
activity,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
visIconId,
|
2018-08-21 03:53:52 +02:00
|
|
|
|
Styler.getVisibilityString(
|
|
|
|
|
activity,
|
|
|
|
|
access_info.isMisskey,
|
|
|
|
|
status.visibility
|
|
|
|
|
)
|
|
|
|
|
)
|
2018-04-05 20:04:45 +02:00
|
|
|
|
}
|
2018-05-24 18:33:09 +02:00
|
|
|
|
|
2018-05-10 00:25:44 +02:00
|
|
|
|
// pinned
|
2018-04-05 20:04:45 +02:00
|
|
|
|
if(status.pinned) {
|
2018-05-10 00:25:44 +02:00
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_pin, "pinned")
|
|
|
|
|
|
2018-05-24 18:33:09 +02:00
|
|
|
|
// 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
|
|
|
|
|
// )
|
2018-04-05 20:04:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-28 14:08:10 +01:00
|
|
|
|
// unread
|
|
|
|
|
if(status.conversationSummary?.unread == true) {
|
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
|
|
|
|
|
sb.appendColorShadeIcon(
|
|
|
|
|
activity,
|
|
|
|
|
R.drawable.ic_unread,
|
|
|
|
|
"unread",
|
2019-01-21 00:00:59 +01:00
|
|
|
|
color = MyClickableSpan.defaultLinkColor
|
2018-10-28 14:08:10 +01:00
|
|
|
|
)
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(sb.isNotEmpty()) sb.append(' ')
|
2018-01-17 18:39:16 +01:00
|
|
|
|
sb.append(
|
2018-04-05 20:04:45 +02:00
|
|
|
|
when {
|
|
|
|
|
time != null -> TootStatus.formatTime(
|
|
|
|
|
activity,
|
|
|
|
|
time,
|
2019-08-23 01:49:20 +02:00
|
|
|
|
column.type != ColumnType.CONVERSATION
|
2018-04-05 20:04:45 +02:00
|
|
|
|
)
|
|
|
|
|
status != null -> TootStatus.formatTime(
|
|
|
|
|
activity,
|
|
|
|
|
status.time_created_at,
|
2019-08-23 01:49:20 +02:00
|
|
|
|
column.type != ColumnType.CONVERSATION
|
2018-04-05 20:04:45 +02:00
|
|
|
|
)
|
|
|
|
|
else -> "?"
|
|
|
|
|
}
|
2018-01-17 18:39:16 +01:00
|
|
|
|
)
|
2018-04-05 20:04:45 +02:00
|
|
|
|
|
|
|
|
|
tv.text = sb
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-06 15:55:25 +01:00
|
|
|
|
private fun showStatusTimeScheduled(
|
|
|
|
|
activity : ActMain,
|
|
|
|
|
tv : TextView,
|
|
|
|
|
item : TootScheduled
|
|
|
|
|
) {
|
|
|
|
|
val sb = SpannableStringBuilder()
|
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
// NSFWマーク
|
|
|
|
|
if(item.hasMedia() && item.sensitive) {
|
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
sb.appendColorShadeIcon(activity, R.drawable.ic_eye_off, "NSFW")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// visibility
|
|
|
|
|
val visIconId =
|
|
|
|
|
Styler.getVisibilityIconId(access_info.isMisskey, item.visibility)
|
|
|
|
|
if(R.drawable.ic_public != visIconId) {
|
|
|
|
|
if(sb.isNotEmpty()) sb.append('\u200B')
|
|
|
|
|
sb.appendColorShadeIcon(
|
|
|
|
|
activity,
|
|
|
|
|
visIconId,
|
|
|
|
|
Styler.getVisibilityString(
|
2019-01-06 15:55:25 +01:00
|
|
|
|
activity,
|
2019-01-16 13:33:07 +01:00
|
|
|
|
access_info.isMisskey,
|
|
|
|
|
item.visibility
|
2019-01-06 15:55:25 +01:00
|
|
|
|
)
|
2019-01-16 13:33:07 +01:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-06 15:55:25 +01:00
|
|
|
|
|
|
|
|
|
if(sb.isNotEmpty()) sb.append(' ')
|
|
|
|
|
sb.append(
|
|
|
|
|
TootStatus.formatTime(
|
|
|
|
|
activity,
|
|
|
|
|
item.timeScheduledAt,
|
2019-08-23 01:49:20 +02:00
|
|
|
|
column.type != ColumnType.CONVERSATION
|
2019-01-06 15:55:25 +01:00
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
tv.text = sb
|
|
|
|
|
}
|
2018-01-21 17:47:13 +01: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)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2018-01-20 07:51:14 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
private fun setAcct(tv : TextView, acctLong : String, acctShort : String?) {
|
|
|
|
|
|
|
|
|
|
val ac = AcctColor.load(acctLong)
|
|
|
|
|
tv.text = when {
|
|
|
|
|
AcctColor.hasNickname(ac) -> ac.nickname
|
2018-01-18 19:09:36 +01:00
|
|
|
|
Pref.bpShortAcctLocalUser(App1.pref) -> "@" + (acctShort ?: "?")
|
2018-01-04 19:52:25 +01:00
|
|
|
|
else -> acctLong
|
|
|
|
|
}
|
2019-02-04 05:19:57 +01:00
|
|
|
|
tv.textColor = ac.color_fg.notZero() ?: this.acct_color
|
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)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun showContent(shown : Boolean) {
|
|
|
|
|
llContents.visibility = if(shown) View.VISIBLE else View.GONE
|
|
|
|
|
btnContentWarning.setText(if(shown) R.string.hide else R.string.show)
|
2018-01-18 22:22:27 +01:00
|
|
|
|
status_showing?.let { status ->
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val r = status.auto_cw
|
|
|
|
|
tvContent.minLines = r?.originalLineCount ?: - 1
|
|
|
|
|
if(r?.decoded_spoiler_text != null) {
|
|
|
|
|
// 自動CWの場合はContentWarningのテキストを切り替える
|
2018-01-17 18:39:16 +01:00
|
|
|
|
tvContentWarning.text =
|
|
|
|
|
if(shown) activity.getString(R.string.auto_cw_prefix) else r.decoded_spoiler_text
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
private fun setMedia(
|
|
|
|
|
media_attachments : ArrayList<TootAttachmentLike>,
|
2018-11-11 11:43:20 +01:00
|
|
|
|
sbDesc : StringBuilder,
|
|
|
|
|
iv : MyNetworkImageView,
|
2018-01-17 18:39:16 +01:00
|
|
|
|
idx : Int
|
|
|
|
|
) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val ta = if(idx < media_attachments.size) media_attachments[idx] else null
|
2018-12-17 21:41:17 +01:00
|
|
|
|
if(ta == null) {
|
|
|
|
|
iv.visibility = View.GONE
|
|
|
|
|
return
|
|
|
|
|
}
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2018-12-17 21:41:17 +01:00
|
|
|
|
iv.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
|
|
iv.setFocusPoint(ta.focusX, ta.focusY)
|
|
|
|
|
|
|
|
|
|
if(Pref.bpDontCropMediaThumb(App1.pref)) {
|
|
|
|
|
iv.scaleType = ImageView.ScaleType.FIT_CENTER
|
|
|
|
|
} else {
|
|
|
|
|
iv.setScaleTypeForMedia()
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 13:16:01 +01:00
|
|
|
|
val showUrl : Boolean
|
2018-12-17 21:41:17 +01:00
|
|
|
|
|
|
|
|
|
when(ta.type) {
|
2019-06-23 16:58:53 +02:00
|
|
|
|
TootAttachmentType.Audio -> {
|
2018-12-17 21:41:17 +01:00
|
|
|
|
iv.setMediaType(0)
|
2019-01-18 13:16:01 +01:00
|
|
|
|
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_music))
|
2018-12-26 05:47:16 +01:00
|
|
|
|
iv.setImageUrl(activity.pref, 0f, null)
|
2019-01-18 13:16:01 +01:00
|
|
|
|
showUrl = true
|
2018-12-17 21:41:17 +01:00
|
|
|
|
}
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2019-06-23 16:58:53 +02:00
|
|
|
|
TootAttachmentType.Unknown -> {
|
2018-12-17 21:41:17 +01:00
|
|
|
|
iv.setMediaType(0)
|
2019-01-18 13:16:01 +01:00
|
|
|
|
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_question))
|
2018-12-26 05:47:16 +01:00
|
|
|
|
iv.setImageUrl(activity.pref, 0f, null)
|
2019-01-18 13:16:01 +01:00
|
|
|
|
showUrl = true
|
2018-12-17 21:41:17 +01:00
|
|
|
|
}
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
2019-01-18 13:16:01 +01:00
|
|
|
|
else -> when(val urlThumbnail = ta.urlForThumbnail) {
|
|
|
|
|
null, "" -> {
|
|
|
|
|
iv.setMediaType(0)
|
|
|
|
|
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_question))
|
|
|
|
|
iv.setImageUrl(activity.pref, 0f, null)
|
|
|
|
|
showUrl = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
|
iv.setMediaType(
|
|
|
|
|
when(ta.type) {
|
2019-06-23 16:58:53 +02:00
|
|
|
|
TootAttachmentType.Video -> R.drawable.media_type_video
|
|
|
|
|
TootAttachmentType.GIFV -> R.drawable.media_type_gifv
|
2019-01-18 13:16:01 +01:00
|
|
|
|
else -> 0
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
iv.setDefaultImage(null)
|
|
|
|
|
iv.setImageUrl(
|
|
|
|
|
activity.pref,
|
|
|
|
|
0f,
|
|
|
|
|
access_info.supplyBaseUrl(urlThumbnail),
|
|
|
|
|
access_info.supplyBaseUrl(urlThumbnail)
|
|
|
|
|
)
|
|
|
|
|
showUrl = false
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-18 13:16:01 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 13:16:01 +01:00
|
|
|
|
fun appendDescription(s : String) {
|
|
|
|
|
// val lp = LinearLayout.LayoutParams(
|
|
|
|
|
// LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
// LinearLayout.LayoutParams.WRAP_CONTENT
|
|
|
|
|
// )
|
|
|
|
|
// lp.topMargin = (0.5f + activity.density * 3f).toInt()
|
2018-12-17 21:41:17 +01:00
|
|
|
|
//
|
2019-01-18 13:16:01 +01:00
|
|
|
|
// val tv = MyTextView(activity)
|
|
|
|
|
// tv.layoutParams = lp
|
|
|
|
|
// //
|
|
|
|
|
// tv.movementMethod = MyLinkMovementMethod
|
|
|
|
|
// if(! activity.timeline_font_size_sp.isNaN()) {
|
|
|
|
|
// tv.textSize = activity.timeline_font_size_sp
|
|
|
|
|
// }
|
|
|
|
|
// tv.setTextColor(content_color)
|
|
|
|
|
|
|
|
|
|
if(sbDesc.isNotEmpty()) sbDesc.append("\n")
|
|
|
|
|
val desc = activity.getString(R.string.media_description, idx + 1, s)
|
|
|
|
|
sbDesc.append(desc)
|
2018-12-17 21:41:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-22 14:06:03 +01:00
|
|
|
|
when(val description = ta.description.notEmpty()) {
|
|
|
|
|
null -> if(showUrl) ta.urlForDescription.notEmpty()?.let { appendDescription(it) }
|
|
|
|
|
else -> appendDescription(description)
|
2019-01-18 13:16:01 +01:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 15:31:44 +02:00
|
|
|
|
private val defaultBoostedAction : () -> Unit = {
|
2018-08-21 12:19:02 +02:00
|
|
|
|
val pos = activity.nextPosition(column)
|
|
|
|
|
val notification = (item as? TootNotification)
|
|
|
|
|
boost_account?.let { whoRef ->
|
|
|
|
|
if(access_info.isPseudo) {
|
2019-01-16 13:33:07 +01:00
|
|
|
|
DlgContextMenu(activity, column, whoRef, null, notification, tvContent).show()
|
2018-08-21 12:19:02 +02:00
|
|
|
|
} else {
|
|
|
|
|
Action_User.profileLocal(activity, pos, access_info, whoRef.get())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-21 15:31:44 +02:00
|
|
|
|
private var boostedAction : () -> Unit = defaultBoostedAction
|
2018-08-21 12:19:02 +02:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
override fun onClick(v : View) {
|
|
|
|
|
|
|
|
|
|
val pos = activity.nextPosition(column)
|
|
|
|
|
val item = this.item
|
|
|
|
|
val notification = (item as? TootNotification)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
when(v) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2020-01-29 06:15:32 +01:00
|
|
|
|
btnHideMedia, btnCardImageHide -> {
|
|
|
|
|
fun hideViews(){
|
|
|
|
|
llMedia.visibility = View.GONE
|
|
|
|
|
btnShowMedia.visibility = View.VISIBLE
|
|
|
|
|
llCardImage.visibility =View.GONE
|
|
|
|
|
btnCardImageShow.visibility = View.VISIBLE
|
|
|
|
|
}
|
2019-01-06 15:55:25 +01:00
|
|
|
|
status_showing?.let { status ->
|
|
|
|
|
MediaShown.save(status, false)
|
2020-01-29 06:15:32 +01:00
|
|
|
|
hideViews()
|
2019-01-06 15:55:25 +01:00
|
|
|
|
}
|
2019-01-18 13:16:01 +01:00
|
|
|
|
if(item is TootScheduled) {
|
2019-01-06 15:55:25 +01:00
|
|
|
|
MediaShown.save(item.uri, false)
|
2020-01-29 06:15:32 +01:00
|
|
|
|
hideViews()
|
2019-01-06 15:55:25 +01:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 06:15:32 +01:00
|
|
|
|
btnShowMedia, btnCardImageShow -> {
|
|
|
|
|
fun showViews(){
|
|
|
|
|
llMedia.visibility = View.VISIBLE
|
|
|
|
|
btnShowMedia.visibility = View.GONE
|
|
|
|
|
llCardImage.visibility =View.VISIBLE
|
|
|
|
|
btnCardImageShow.visibility = View.GONE
|
|
|
|
|
}
|
2019-01-06 15:55:25 +01:00
|
|
|
|
status_showing?.let { status ->
|
|
|
|
|
MediaShown.save(status, true)
|
2020-01-29 06:15:32 +01:00
|
|
|
|
showViews()
|
2019-01-06 15:55:25 +01:00
|
|
|
|
}
|
2019-01-18 13:16:01 +01:00
|
|
|
|
if(item is TootScheduled) {
|
2019-01-06 15:55:25 +01:00
|
|
|
|
MediaShown.save(item.uri, true)
|
2020-01-29 06:15:32 +01:00
|
|
|
|
showViews()
|
2019-01-06 15:55:25 +01:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
ivMedia1 -> clickMedia(0)
|
|
|
|
|
ivMedia2 -> clickMedia(1)
|
|
|
|
|
ivMedia3 -> clickMedia(2)
|
|
|
|
|
ivMedia4 -> clickMedia(3)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
btnContentWarning -> {
|
2019-01-06 15:55:25 +01:00
|
|
|
|
status_showing?.let { status ->
|
|
|
|
|
val new_shown = llContents.visibility == View.GONE
|
|
|
|
|
ContentWarning.save(status, new_shown)
|
|
|
|
|
|
|
|
|
|
// 1個だけ開閉するのではなく、例えば通知TLにある複数の要素をまとめて開閉するなどある
|
|
|
|
|
list_adapter.notifyChange(reason = "ContentWarning onClick", reset = true)
|
|
|
|
|
|
|
|
|
|
}
|
2019-01-18 13:16:01 +01:00
|
|
|
|
if(item is TootScheduled) {
|
2019-01-06 15:55:25 +01:00
|
|
|
|
val new_shown = llContents.visibility == View.GONE
|
|
|
|
|
ContentWarning.save(item.uri, new_shown)
|
|
|
|
|
|
|
|
|
|
// 1個だけ開閉するのではなく、例えば通知TLにある複数の要素をまとめて開閉するなどある
|
|
|
|
|
list_adapter.notifyChange(reason = "ContentWarning onClick", reset = true)
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
|
ivThumbnail -> status_account?.let { whoRef ->
|
2018-08-18 12:58:14 +02:00
|
|
|
|
when {
|
2019-01-06 09:35:22 +01:00
|
|
|
|
access_info.isNA -> DlgContextMenu(
|
2018-08-21 03:53:52 +02:00
|
|
|
|
activity,
|
|
|
|
|
column,
|
|
|
|
|
whoRef,
|
|
|
|
|
null,
|
2019-01-08 10:41:07 +01:00
|
|
|
|
notification,
|
|
|
|
|
tvContent
|
2018-08-21 03:53:52 +02:00
|
|
|
|
).show()
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
|
|
|
|
// 2018/12/26 疑似アカウントでもプロフカラムを表示する https://github.com/tootsuite/mastodon/commit/108b2139cd87321f6c0aec63ef93db85ce30bfec
|
|
|
|
|
|
|
|
|
|
else -> Action_User.profileLocal(
|
|
|
|
|
activity,
|
|
|
|
|
pos,
|
|
|
|
|
access_info,
|
|
|
|
|
whoRef.get()
|
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 12:19:02 +02:00
|
|
|
|
llBoosted -> boostedAction()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-08-31 14:47:40 +02:00
|
|
|
|
llReply -> {
|
2018-11-16 15:44:23 +01:00
|
|
|
|
val s = status_reply
|
2019-12-03 15:55:30 +01:00
|
|
|
|
|
2019-09-23 19:02:01 +02:00
|
|
|
|
when {
|
|
|
|
|
s != null -> Action_Toot.conversation(activity, pos, access_info, s)
|
|
|
|
|
|
|
|
|
|
// tootsearchは返信元のIDを取得するのにひと手間必要
|
|
|
|
|
column.type == ColumnType.SEARCH_TS ->
|
|
|
|
|
Action_Toot.showReplyTootsearch(activity, pos, status_showing)
|
2019-12-03 15:55:30 +01:00
|
|
|
|
|
2019-09-23 19:02:01 +02:00
|
|
|
|
else -> {
|
|
|
|
|
val id = status_showing?.in_reply_to_id
|
|
|
|
|
if(id != null) {
|
|
|
|
|
Action_Toot.conversationLocal(activity, pos, access_info, id)
|
|
|
|
|
}
|
2018-11-16 15:44:23 +01:00
|
|
|
|
}
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
|
llFollow -> follow_account?.let { whoRef ->
|
2018-01-04 19:52:25 +01:00
|
|
|
|
if(access_info.isPseudo) {
|
2019-01-16 13:33:07 +01:00
|
|
|
|
DlgContextMenu(activity, column, whoRef, null, notification, tvContent).show()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
} else {
|
2018-05-18 19:08:46 +02:00
|
|
|
|
Action_User.profileLocal(activity, pos, access_info, whoRef.get())
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-28 14:08:10 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
btnFollow -> follow_account?.let { who ->
|
2019-01-16 13:33:07 +01:00
|
|
|
|
DlgContextMenu(activity, column, who, null, notification, tvContent).show()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-30 07:18:45 +02:00
|
|
|
|
btnSearchTag, llTrendTag -> when(item) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
|
|
|
|
is TootConversationSummary -> openConversationSummary()
|
|
|
|
|
|
2018-08-18 12:58:14 +02:00
|
|
|
|
is TootGap -> column.startGap(item)
|
2019-08-12 06:36:42 +02:00
|
|
|
|
is TootSearchGap -> column.startGap(item)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
is TootDomainBlock -> {
|
|
|
|
|
val domain = item.domain
|
|
|
|
|
AlertDialog.Builder(activity)
|
|
|
|
|
.setMessage(activity.getString(R.string.confirm_unblock_domain, domain))
|
|
|
|
|
.setNegativeButton(R.string.cancel, null)
|
2018-01-17 18:39:16 +01:00
|
|
|
|
.setPositiveButton(R.string.ok) { _, _ ->
|
|
|
|
|
Action_Instance.blockDomain(
|
|
|
|
|
activity,
|
|
|
|
|
access_info,
|
|
|
|
|
domain,
|
|
|
|
|
false
|
|
|
|
|
)
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
.show()
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-20 07:51:14 +01:00
|
|
|
|
is TootTag -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
|
Action_HashTag.timeline(
|
|
|
|
|
activity,
|
|
|
|
|
activity.nextPosition(column),
|
|
|
|
|
access_info,
|
2018-01-20 07:51:14 +01:00
|
|
|
|
item.name // #を含まない
|
2018-01-17 18:39:16 +01:00
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2019-01-06 11:17:54 +01:00
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
is TootScheduled -> {
|
2019-01-06 11:17:54 +01:00
|
|
|
|
ActionsDialog()
|
2019-11-11 13:34:50 +01:00
|
|
|
|
.addAction(activity.getString(R.string.edit)) {
|
|
|
|
|
Action_Toot.editScheduledPost(activity, access_info, item)
|
|
|
|
|
}
|
|
|
|
|
.addAction(activity.getString(R.string.delete)) {
|
2019-01-16 13:33:07 +01:00
|
|
|
|
Action_Toot.deleteScheduledPost(activity, access_info, item) {
|
2019-01-06 11:17:54 +01:00
|
|
|
|
column.onScheduleDeleted(item)
|
2019-01-16 13:33:07 +01:00
|
|
|
|
showToast(activity, false, R.string.scheduled_post_deleted)
|
2019-01-06 11:17:54 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.show(activity)
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
btnListTL -> if(item is TootList) {
|
2019-08-23 01:49:20 +02:00
|
|
|
|
activity.addColumn(pos, access_info, ColumnType.LIST_TL, item.id)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
btnListMore -> if(item is TootList) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
ActionsDialog()
|
|
|
|
|
.addAction(activity.getString(R.string.list_timeline)) {
|
2019-08-23 01:49:20 +02:00
|
|
|
|
activity.addColumn(pos, access_info, ColumnType.LIST_TL, item.id)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
.addAction(activity.getString(R.string.list_member)) {
|
2018-03-21 16:39:10 +01:00
|
|
|
|
activity.addColumn(
|
|
|
|
|
false,
|
|
|
|
|
pos,
|
|
|
|
|
access_info,
|
2019-08-23 01:49:20 +02:00
|
|
|
|
ColumnType.LIST_MEMBER,
|
2018-03-21 16:39:10 +01:00
|
|
|
|
item.id
|
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2018-03-21 16:39:10 +01:00
|
|
|
|
.addAction(activity.getString(R.string.rename)) {
|
2018-02-04 18:55:42 +01:00
|
|
|
|
Action_List.rename(activity, access_info, item)
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
.addAction(activity.getString(R.string.delete)) {
|
2018-08-31 14:47:40 +02:00
|
|
|
|
Action_List.delete(activity, access_info, item)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
.show(activity, item.title)
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
|
btnFollowRequestAccept -> follow_account?.let { whoRef ->
|
2018-05-18 19:08:46 +02:00
|
|
|
|
val who = whoRef.get()
|
2018-05-08 10:55:08 +02:00
|
|
|
|
DlgConfirm.openSimple(
|
|
|
|
|
activity,
|
|
|
|
|
activity.getString(
|
|
|
|
|
R.string.follow_accept_confirm,
|
|
|
|
|
AcctColor.getNickname(access_info.getFullAcct(who))
|
|
|
|
|
)
|
|
|
|
|
) {
|
2018-05-08 10:25:02 +02:00
|
|
|
|
Action_Follow.authorizeFollowRequest(activity, access_info, whoRef, true)
|
2018-04-17 18:29:50 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-08 10:25:02 +02:00
|
|
|
|
btnFollowRequestDeny -> follow_account?.let { whoRef ->
|
2018-05-18 19:08:46 +02:00
|
|
|
|
val who = whoRef.get()
|
2018-05-08 10:55:08 +02:00
|
|
|
|
DlgConfirm.openSimple(
|
|
|
|
|
activity,
|
|
|
|
|
activity.getString(
|
|
|
|
|
R.string.follow_deny_confirm,
|
|
|
|
|
AcctColor.getNickname(access_info.getFullAcct(who))
|
|
|
|
|
)
|
|
|
|
|
) {
|
2018-05-08 10:25:02 +02:00
|
|
|
|
Action_Follow.authorizeFollowRequest(activity, access_info, whoRef, false)
|
2018-04-17 18:29:50 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-04 20:07:55 +02:00
|
|
|
|
llFilter -> if(item is TootFilter) {
|
2018-07-07 07:15:16 +02:00
|
|
|
|
openFilterMenu(item)
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-14 07:47:25 +01:00
|
|
|
|
ivCardImage -> status_showing?.card?.let { card ->
|
2018-11-12 18:19:57 +01:00
|
|
|
|
val originalStatus = card.originalStatus
|
|
|
|
|
if(originalStatus != null) {
|
|
|
|
|
Action_Toot.conversation(
|
|
|
|
|
activity,
|
|
|
|
|
activity.nextPosition(column),
|
|
|
|
|
access_info,
|
|
|
|
|
originalStatus
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
val url = card.url
|
|
|
|
|
if(url?.isNotEmpty() == true) {
|
|
|
|
|
ChromeTabOpener(
|
|
|
|
|
activity,
|
|
|
|
|
pos,
|
|
|
|
|
url,
|
|
|
|
|
accessInfo = access_info
|
|
|
|
|
).open()
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
llConversationIcons -> openConversationSummary()
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onLongClick(v : View) : Boolean {
|
|
|
|
|
|
|
|
|
|
val notification = (item as? TootNotification)
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
when(v) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
ivThumbnail -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
|
status_account?.let { who ->
|
|
|
|
|
DlgContextMenu(
|
|
|
|
|
activity,
|
|
|
|
|
column,
|
|
|
|
|
who,
|
|
|
|
|
null,
|
2019-01-08 10:41:07 +01:00
|
|
|
|
notification,
|
|
|
|
|
tvContent
|
2018-01-17 18:39:16 +01:00
|
|
|
|
).show()
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
llBoosted -> {
|
2018-01-17 18:39:16 +01:00
|
|
|
|
boost_account?.let { who ->
|
|
|
|
|
DlgContextMenu(
|
|
|
|
|
activity,
|
|
|
|
|
column,
|
|
|
|
|
who,
|
|
|
|
|
null,
|
2019-01-08 10:41:07 +01:00
|
|
|
|
notification,
|
|
|
|
|
tvContent
|
2018-01-17 18:39:16 +01:00
|
|
|
|
).show()
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 14:47:40 +02:00
|
|
|
|
llReply -> {
|
2018-11-16 15:44:23 +01:00
|
|
|
|
val s = status_reply
|
2019-09-23 19:02:01 +02:00
|
|
|
|
when {
|
2019-12-03 15:55:30 +01:00
|
|
|
|
|
2019-09-23 19:02:01 +02:00
|
|
|
|
// 返信元のstatusがあるならコンテキストメニュー
|
|
|
|
|
s != null -> DlgContextMenu(
|
2018-08-23 05:46:14 +02:00
|
|
|
|
activity,
|
|
|
|
|
column,
|
|
|
|
|
s.accountRef,
|
|
|
|
|
s,
|
2019-01-08 10:41:07 +01:00
|
|
|
|
notification,
|
|
|
|
|
tvContent
|
2018-08-23 05:46:14 +02:00
|
|
|
|
).show()
|
2019-09-23 19:02:01 +02:00
|
|
|
|
|
|
|
|
|
// それ以外はコンテキストメニューではなく会話を開く
|
2019-12-03 15:55:30 +01:00
|
|
|
|
|
2019-09-23 19:02:01 +02:00
|
|
|
|
// tootsearchは返信元のIDを取得するのにひと手間必要
|
|
|
|
|
column.type == ColumnType.SEARCH_TS ->
|
|
|
|
|
Action_Toot.showReplyTootsearch(
|
2018-11-18 03:38:52 +01:00
|
|
|
|
activity,
|
|
|
|
|
activity.nextPosition(column),
|
2019-09-23 19:02:01 +02:00
|
|
|
|
status_showing
|
2018-11-18 03:38:52 +01:00
|
|
|
|
)
|
2019-09-23 19:02:01 +02:00
|
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
|
val id = status_showing?.in_reply_to_id
|
|
|
|
|
if(id != null) {
|
|
|
|
|
Action_Toot.conversationLocal(
|
|
|
|
|
activity,
|
|
|
|
|
activity.nextPosition(column),
|
|
|
|
|
access_info,
|
|
|
|
|
id
|
|
|
|
|
)
|
|
|
|
|
}
|
2018-11-16 15:44:23 +01:00
|
|
|
|
}
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
llFollow -> {
|
2018-05-08 10:25:02 +02:00
|
|
|
|
follow_account?.let { whoRef ->
|
2018-01-17 18:39:16 +01:00
|
|
|
|
DlgContextMenu(
|
|
|
|
|
activity,
|
|
|
|
|
column,
|
2018-05-08 10:25:02 +02:00
|
|
|
|
whoRef,
|
2018-01-17 18:39:16 +01:00
|
|
|
|
null,
|
|
|
|
|
notification
|
|
|
|
|
).show()
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
btnFollow -> {
|
2018-05-08 10:25:02 +02:00
|
|
|
|
follow_account?.let { whoRef ->
|
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
|
|
|
|
|
}
|
2018-01-10 16:47:35 +01:00
|
|
|
|
|
2018-11-14 07:47:25 +01:00
|
|
|
|
ivCardImage -> Action_Toot.conversationOtherInstance(
|
2018-11-12 18:19:57 +01:00
|
|
|
|
activity,
|
|
|
|
|
activity.nextPosition(column),
|
|
|
|
|
status_showing?.card?.originalStatus
|
|
|
|
|
)
|
|
|
|
|
|
2018-05-30 07:18:45 +02:00
|
|
|
|
btnSearchTag, llTrendTag -> {
|
2019-04-25 04:06:41 +02:00
|
|
|
|
when(val item = this.item) {
|
2018-08-21 03:53:52 +02:00
|
|
|
|
// is TootGap -> column.startGap(item)
|
|
|
|
|
//
|
|
|
|
|
// is TootDomainBlock -> {
|
|
|
|
|
// val domain = item.domain
|
|
|
|
|
// AlertDialog.Builder(activity)
|
|
|
|
|
// .setMessage(activity.getString(R.string.confirm_unblock_domain, domain))
|
|
|
|
|
// .setNegativeButton(R.string.cancel, null)
|
|
|
|
|
// .setPositiveButton(R.string.ok) { _, _ -> Action_Instance.blockDomain(activity, access_info, domain, false) }
|
|
|
|
|
// .show()
|
|
|
|
|
// }
|
2018-01-10 16:47:35 +01:00
|
|
|
|
|
2018-01-20 07:51:14 +01:00
|
|
|
|
is TootTag -> {
|
2018-01-10 16:47:35 +01:00
|
|
|
|
// search_tag は#を含まない
|
2018-01-21 13:46:36 +01:00
|
|
|
|
val tagEncoded = item.name.encodePercent()
|
2018-01-10 16:47:35 +01:00
|
|
|
|
val host = access_info.host
|
|
|
|
|
val url = "https://$host/tags/$tagEncoded"
|
|
|
|
|
Action_HashTag.timelineOtherInstance(
|
2018-01-14 22:47:42 +01:00
|
|
|
|
activity = activity,
|
|
|
|
|
pos = activity.nextPosition(column),
|
|
|
|
|
url = url,
|
|
|
|
|
host = host,
|
2018-01-20 07:51:14 +01:00
|
|
|
|
tag_without_sharp = item.name
|
2018-01-10 16:47:35 +01:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun clickMedia(i : Int) {
|
|
|
|
|
try {
|
2019-01-16 13:33:07 +01:00
|
|
|
|
val media_attachments =
|
|
|
|
|
status_showing?.media_attachments ?: (item as? TootScheduled)?.media_attachments
|
|
|
|
|
?: return
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
|
|
|
|
when(val item = if(i < media_attachments.size) media_attachments[i] else return) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
is TootAttachmentMSP -> {
|
|
|
|
|
// マストドン検索ポータルのデータではmedia_attachmentsが簡略化されている
|
|
|
|
|
// 会話の流れを表示する
|
2018-01-17 18:39:16 +01:00
|
|
|
|
Action_Toot.conversationOtherInstance(
|
|
|
|
|
activity,
|
|
|
|
|
activity.nextPosition(column),
|
2018-01-18 22:22:27 +01:00
|
|
|
|
status_showing
|
2018-01-17 18:39:16 +01:00
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 13:28:02 +01:00
|
|
|
|
is TootAttachment -> when {
|
|
|
|
|
|
|
|
|
|
// unknownが1枚だけなら内蔵ビューアを使わずにインテントを投げる
|
2019-12-22 14:06:03 +01:00
|
|
|
|
item.type == TootAttachmentType.Unknown && media_attachments.size == 1 -> {
|
|
|
|
|
// https://github.com/tateisu/SubwayTooter/pull/119
|
|
|
|
|
// メディアタイプがunknownの場合、そのほとんどはリモートから来たURLである
|
|
|
|
|
// Pref.bpPriorLocalURL の状態に関わらずリモートURLがあればそれをブラウザで開く
|
|
|
|
|
when(val remoteUrl = item.remote_url.notEmpty()) {
|
|
|
|
|
null -> App1.openCustomTab(activity, item)
|
|
|
|
|
else -> App1.openCustomTab(activity, remoteUrl)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-18 13:28:02 +01:00
|
|
|
|
|
|
|
|
|
// 内蔵メディアビューアを使う
|
|
|
|
|
Pref.bpUseInternalMediaViewer(App1.pref) ->
|
|
|
|
|
ActMediaViewer.open(
|
|
|
|
|
activity,
|
|
|
|
|
when(access_info.isMisskey) {
|
|
|
|
|
true -> ServiceType.MISSKEY
|
|
|
|
|
else -> ServiceType.MASTODON
|
|
|
|
|
},
|
|
|
|
|
media_attachments,
|
|
|
|
|
i
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ブラウザで開く
|
|
|
|
|
else -> App1.openCustomTab(activity, item)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch(ex : Throwable) {
|
|
|
|
|
log.trace(ex)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-20 01:33:57 +01:00
|
|
|
|
private fun showPreviewCard(status : TootStatus) {
|
|
|
|
|
|
|
|
|
|
if(Pref.bpDontShowPreviewCard(activity.pref)) return
|
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
val card = status.card ?: return
|
|
|
|
|
|
|
|
|
|
// 会話カラムで返信ステータスなら捏造したカードを表示しない
|
2019-08-23 01:49:20 +02:00
|
|
|
|
if(column.type == ColumnType.CONVERSATION
|
2018-11-12 18:19:57 +01:00
|
|
|
|
&& card.originalStatus != null
|
|
|
|
|
&& status.reply != null
|
|
|
|
|
) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 06:15:32 +01:00
|
|
|
|
var bShowOuter = false
|
2018-11-12 18:19:57 +01:00
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val sb = StringBuilder()
|
2018-11-12 18:19:57 +01:00
|
|
|
|
|
|
|
|
|
addLinkAndCaption(
|
|
|
|
|
sb,
|
|
|
|
|
activity.getString(R.string.card_header_card),
|
|
|
|
|
card.url,
|
|
|
|
|
card.title
|
|
|
|
|
)
|
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
addLinkAndCaption(
|
|
|
|
|
sb,
|
|
|
|
|
activity.getString(R.string.card_header_author),
|
|
|
|
|
card.author_url,
|
|
|
|
|
card.author_name
|
|
|
|
|
)
|
2018-11-12 18:19:57 +01:00
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
addLinkAndCaption(
|
|
|
|
|
sb,
|
|
|
|
|
activity.getString(R.string.card_header_provider),
|
|
|
|
|
card.provider_url,
|
|
|
|
|
card.provider_name
|
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
val description = card.description
|
2018-01-14 22:47:42 +01:00
|
|
|
|
if(description != null && description.isNotEmpty()) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
if(sb.isNotEmpty()) sb.append("<br>")
|
2018-11-02 14:28:09 +01:00
|
|
|
|
|
|
|
|
|
val limit = Pref.spCardDescriptionLength.toInt(activity.pref)
|
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
sb.append(
|
|
|
|
|
HTMLDecoder.encodeEntity(
|
|
|
|
|
ellipsize(
|
|
|
|
|
description,
|
|
|
|
|
if(limit <= 0) 64 else limit
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
if(sb.isNotEmpty()) {
|
|
|
|
|
val text =
|
2020-01-29 06:15:32 +01:00
|
|
|
|
DecodeOptions(activity, access_info, forceHtml = true)
|
|
|
|
|
.decodeHTML(sb.toString())
|
2018-11-12 18:19:57 +01:00
|
|
|
|
if(text.isNotEmpty()) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
tvCardText.visibility = View.VISIBLE
|
|
|
|
|
tvCardText.text = text
|
2020-01-29 06:15:32 +01:00
|
|
|
|
bShowOuter = true
|
2018-11-11 11:43:20 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
val image = card.image
|
2020-01-29 06:15:32 +01:00
|
|
|
|
if(flCardImage.vg(image?.isNotEmpty()==true) !=null) {
|
|
|
|
|
val imageUrl = access_info.supplyBaseUrl(image)
|
|
|
|
|
ivCardImage.setImageUrl(activity.pref, 0f, imageUrl, imageUrl)
|
|
|
|
|
|
|
|
|
|
// show about card outer
|
|
|
|
|
bShowOuter = true
|
|
|
|
|
|
|
|
|
|
// show about image content
|
|
|
|
|
val default_shown = when {
|
|
|
|
|
column.hide_media_default -> false
|
|
|
|
|
access_info.dont_hide_nsfw -> true
|
|
|
|
|
else -> ! status.sensitive
|
|
|
|
|
}
|
|
|
|
|
val is_shown = MediaShown.isShown(status, default_shown)
|
|
|
|
|
llCardImage.vg(is_shown)
|
|
|
|
|
btnCardImageShow.vg(! is_shown)
|
2018-11-14 07:47:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 06:15:32 +01:00
|
|
|
|
if(bShowOuter) llCardOuter.visibility = View.VISIBLE
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-17 18:39:16 +01:00
|
|
|
|
private fun addLinkAndCaption(
|
|
|
|
|
sb : StringBuilder,
|
|
|
|
|
header : String,
|
|
|
|
|
url : String?,
|
|
|
|
|
caption : String?
|
|
|
|
|
) {
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
if(url.isNullOrEmpty() && caption.isNullOrEmpty()) return
|
|
|
|
|
|
|
|
|
|
if(sb.isNotEmpty()) sb.append("<br>")
|
|
|
|
|
|
|
|
|
|
sb.append(HTMLDecoder.encodeEntity(header)).append(": ")
|
|
|
|
|
|
|
|
|
|
if(url != null && url.isNotEmpty()) {
|
|
|
|
|
sb.append("<a href=\"").append(HTMLDecoder.encodeEntity(url)).append("\">")
|
|
|
|
|
}
|
2018-01-17 18:39:16 +01:00
|
|
|
|
sb.append(
|
|
|
|
|
HTMLDecoder.encodeEntity(
|
|
|
|
|
when {
|
|
|
|
|
caption != null && caption.isNotEmpty() -> caption
|
|
|
|
|
url != null && url.isNotEmpty() -> url
|
|
|
|
|
else -> "???"
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
if(url != null && url.isNotEmpty()) {
|
|
|
|
|
sb.append("</a>")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-06 09:35:22 +01:00
|
|
|
|
private fun makeReactionsView(status : TootStatus) {
|
2018-08-21 15:31:44 +02:00
|
|
|
|
if(! access_info.isMisskey) return
|
2019-01-06 09:35:22 +01:00
|
|
|
|
|
2018-12-29 17:38:52 +01:00
|
|
|
|
val reactionsCount = status.reactionCounts
|
2018-08-21 15:31:44 +02:00
|
|
|
|
|
2018-12-16 12:24:44 +01:00
|
|
|
|
val density = activity.density
|
2018-08-21 15:31:44 +02:00
|
|
|
|
|
|
|
|
|
val buttonHeight = ActMain.boostButtonSize
|
2020-01-04 15:17:19 +01:00
|
|
|
|
val marginBetween = (buttonHeight.toFloat() * 0.05f + 0.5f).toInt()
|
2018-08-21 15:31:44 +02:00
|
|
|
|
|
2018-08-31 14:47:40 +02:00
|
|
|
|
val paddingH = (buttonHeight.toFloat() * 0.1f + 0.5f).toInt()
|
|
|
|
|
val paddingV = (buttonHeight.toFloat() * 0.1f + 0.5f).toInt()
|
2018-08-21 03:53:52 +02:00
|
|
|
|
|
2020-01-07 09:03:32 +01:00
|
|
|
|
val box = FlexboxLayout(activity).apply {
|
2020-01-04 15:17:19 +01:00
|
|
|
|
flexWrap = FlexWrap.WRAP
|
|
|
|
|
justifyContent = JustifyContent.FLEX_START
|
|
|
|
|
layoutParams = LinearLayout.LayoutParams(
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
2020-01-07 09:03:32 +01:00
|
|
|
|
).apply {
|
2020-01-04 15:17:19 +01:00
|
|
|
|
topMargin = (0.5f + density * 3f).toInt()
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-04 14:36:01 +01:00
|
|
|
|
|
2018-08-21 03:53:52 +02:00
|
|
|
|
// +ボタン
|
2018-08-21 15:31:44 +02:00
|
|
|
|
run {
|
2018-08-21 03:53:52 +02:00
|
|
|
|
val b = ImageButton(activity)
|
|
|
|
|
val blp = FlexboxLayout.LayoutParams(
|
2018-08-21 15:31:44 +02:00
|
|
|
|
buttonHeight,
|
|
|
|
|
buttonHeight
|
2018-08-21 03:53:52 +02:00
|
|
|
|
)
|
2018-08-21 15:31:44 +02:00
|
|
|
|
blp.endMargin = marginBetween
|
2018-08-21 03:53:52 +02:00
|
|
|
|
b.layoutParams = blp
|
|
|
|
|
b.background = ContextCompat.getDrawable(
|
|
|
|
|
activity,
|
|
|
|
|
R.drawable.btn_bg_transparent
|
|
|
|
|
)
|
2018-12-29 17:38:52 +01:00
|
|
|
|
|
|
|
|
|
val hasMyReaction = status.myReaction?.isNotEmpty() == true
|
2019-01-06 09:35:22 +01:00
|
|
|
|
b.contentDescription =
|
|
|
|
|
activity.getString(if(hasMyReaction) R.string.reaction_remove else R.string.reaction_add)
|
2018-08-21 15:31:44 +02:00
|
|
|
|
b.scaleType = ImageView.ScaleType.FIT_CENTER
|
|
|
|
|
b.padding = paddingV
|
2018-12-29 17:38:52 +01:00
|
|
|
|
b.setOnClickListener {
|
2019-01-06 09:35:22 +01:00
|
|
|
|
if(hasMyReaction) {
|
2018-12-29 17:38:52 +01:00
|
|
|
|
removeReaction(status, false)
|
2019-01-06 09:35:22 +01:00
|
|
|
|
} else {
|
2018-12-29 17:38:52 +01:00
|
|
|
|
addReaction(status, null)
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-01 00:02:18 +01:00
|
|
|
|
|
2018-11-22 01:07:53 +01:00
|
|
|
|
b.setOnLongClickListener {
|
|
|
|
|
Action_Toot.reactionFromAnotherAccount(
|
|
|
|
|
activity,
|
|
|
|
|
access_info,
|
|
|
|
|
status_showing
|
|
|
|
|
)
|
|
|
|
|
true
|
|
|
|
|
}
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
2018-12-01 00:02:18 +01:00
|
|
|
|
setIconDrawableId(
|
2018-11-18 03:38:52 +01:00
|
|
|
|
activity,
|
|
|
|
|
b,
|
2018-12-29 17:38:52 +01:00
|
|
|
|
if(hasMyReaction) R.drawable.ic_remove else R.drawable.ic_add,
|
2018-11-18 15:29:35 +01:00
|
|
|
|
color = content_color,
|
|
|
|
|
alphaMultiplier = Styler.boost_alpha
|
2018-11-18 03:38:52 +01:00
|
|
|
|
)
|
|
|
|
|
|
2018-08-21 03:53:52 +02:00
|
|
|
|
box.addView(b)
|
|
|
|
|
}
|
2019-04-07 15:47:05 +02:00
|
|
|
|
|
2019-04-25 04:06:41 +02:00
|
|
|
|
if(reactionsCount != null) {
|
|
|
|
|
|
2019-04-07 15:47:05 +02:00
|
|
|
|
var lastButton : View? = null
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
2020-01-04 15:17:19 +01:00
|
|
|
|
val options = DecodeOptions(
|
|
|
|
|
activity,
|
|
|
|
|
access_info,
|
|
|
|
|
decodeEmoji = true,
|
2020-01-07 09:03:32 +01:00
|
|
|
|
enlargeEmoji = 1.5f
|
2020-01-04 15:17:19 +01:00
|
|
|
|
)
|
2020-01-04 14:36:01 +01:00
|
|
|
|
|
2020-01-04 15:17:19 +01:00
|
|
|
|
// 通常の絵文字はUnicodeを使う
|
2020-01-07 09:03:32 +01:00
|
|
|
|
fun addEmojiReaction(name : String, unicode : String, count : Int) {
|
|
|
|
|
val b = Button(activity).apply {
|
|
|
|
|
|
2020-01-05 09:24:52 +01:00
|
|
|
|
layoutParams = FlexboxLayout.LayoutParams(
|
|
|
|
|
FlexboxLayout.LayoutParams.WRAP_CONTENT,
|
|
|
|
|
buttonHeight
|
2020-01-07 09:03:32 +01:00
|
|
|
|
).apply {
|
2020-01-05 09:24:52 +01:00
|
|
|
|
endMargin = marginBetween
|
|
|
|
|
}
|
2020-01-07 09:03:32 +01:00
|
|
|
|
|
|
|
|
|
text = EmojiDecoder.decodeEmoji(options, "$unicode $count")
|
2020-01-05 09:24:52 +01:00
|
|
|
|
allCaps = false
|
|
|
|
|
tag = name
|
|
|
|
|
minWidthCompat = buttonHeight
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
this@ItemViewHolder.activity,
|
|
|
|
|
R.drawable.btn_bg_transparent
|
2019-04-07 15:47:05 +02:00
|
|
|
|
)
|
2020-01-05 09:24:52 +01:00
|
|
|
|
setTextColor(content_color)
|
|
|
|
|
setPadding(paddingH, paddingV, paddingH, paddingV)
|
|
|
|
|
setOnClickListener {
|
|
|
|
|
addReaction(status, it.tag as? String)
|
|
|
|
|
}
|
|
|
|
|
setOnLongClickListener {
|
|
|
|
|
Action_Toot.reactionFromAnotherAccount(
|
|
|
|
|
this@ItemViewHolder.activity,
|
|
|
|
|
access_info,
|
|
|
|
|
status_showing,
|
|
|
|
|
it.tag as? String
|
|
|
|
|
)
|
|
|
|
|
true
|
|
|
|
|
}
|
2019-04-07 15:47:05 +02:00
|
|
|
|
}
|
|
|
|
|
box.addView(b)
|
|
|
|
|
lastButton = b
|
2018-11-22 01:07:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 09:03:32 +01:00
|
|
|
|
fun addCustomEmojiReaction(name : String, customCode : String, count : Int) {
|
|
|
|
|
val b = Button(activity).apply {
|
2020-01-05 09:24:52 +01:00
|
|
|
|
layoutParams = FlexboxLayout.LayoutParams(
|
|
|
|
|
FlexboxLayout.LayoutParams.WRAP_CONTENT,
|
|
|
|
|
buttonHeight
|
2020-01-07 09:03:32 +01:00
|
|
|
|
).apply {
|
2020-01-05 09:24:52 +01:00
|
|
|
|
endMargin = marginBetween
|
2020-01-04 15:17:19 +01:00
|
|
|
|
}
|
2020-01-05 09:24:52 +01:00
|
|
|
|
minWidthCompat = buttonHeight
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
this@ItemViewHolder.activity,
|
|
|
|
|
R.drawable.btn_bg_transparent
|
2019-04-07 15:47:05 +02:00
|
|
|
|
)
|
2020-01-05 09:24:52 +01:00
|
|
|
|
setTextColor(content_color)
|
|
|
|
|
setPadding(paddingH, paddingV, paddingH, paddingV)
|
|
|
|
|
|
2020-01-08 07:57:21 +01:00
|
|
|
|
val emoji = status.custom_emojis?.get(customCode)
|
|
|
|
|
?: App1.custom_emoji_lister.getMap(access_info.host, true)
|
|
|
|
|
?.get(customCode)
|
|
|
|
|
|
|
|
|
|
val emojiUrl = emoji?.let {
|
2020-01-10 14:42:37 +01:00
|
|
|
|
if(Pref.bpDisableEmojiAnimation(this@ItemViewHolder.activity.pref)) {
|
|
|
|
|
it.static_url
|
|
|
|
|
} else {
|
|
|
|
|
it.url
|
2020-01-05 09:24:52 +01:00
|
|
|
|
}
|
2020-01-10 14:42:37 +01:00
|
|
|
|
}
|
2020-01-05 09:24:52 +01:00
|
|
|
|
|
|
|
|
|
val sb = SpannableStringBuilder("$name $count")
|
|
|
|
|
if(emojiUrl != null) {
|
|
|
|
|
sb.setSpan(
|
|
|
|
|
NetworkEmojiSpan(emojiUrl, scale = 1.5f),
|
|
|
|
|
0,
|
|
|
|
|
name.length,
|
|
|
|
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
|
|
)
|
2020-01-07 09:03:32 +01:00
|
|
|
|
val invalidator =
|
|
|
|
|
NetworkEmojiInvalidator(this@ItemViewHolder.activity.handler, this)
|
2020-01-05 09:24:52 +01:00
|
|
|
|
invalidator.register(sb)
|
|
|
|
|
extra_invalidator_list.add(invalidator)
|
|
|
|
|
}
|
|
|
|
|
text = sb
|
|
|
|
|
allCaps = false
|
|
|
|
|
|
|
|
|
|
tag = name
|
|
|
|
|
|
|
|
|
|
setOnClickListener {
|
|
|
|
|
addReaction(status, it.tag as? String)
|
|
|
|
|
}
|
|
|
|
|
setOnLongClickListener {
|
|
|
|
|
Action_Toot.reactionFromAnotherAccount(
|
|
|
|
|
this@ItemViewHolder.activity,
|
|
|
|
|
access_info,
|
|
|
|
|
status_showing,
|
|
|
|
|
it.tag as? String
|
|
|
|
|
)
|
|
|
|
|
true
|
|
|
|
|
}
|
2019-04-07 15:47:05 +02:00
|
|
|
|
}
|
|
|
|
|
box.addView(b)
|
|
|
|
|
lastButton = b
|
|
|
|
|
}
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
2020-01-07 09:31:05 +01:00
|
|
|
|
for(entry in reactionsCount.entries) {
|
|
|
|
|
val key = entry.key
|
|
|
|
|
val count = entry.value
|
|
|
|
|
if(count <= 0) continue
|
2020-01-04 15:17:19 +01:00
|
|
|
|
|
2020-01-07 09:31:05 +01:00
|
|
|
|
// 組み込みのリアクション
|
|
|
|
|
val mr = MisskeyReaction.shortcodeMap[key]
|
|
|
|
|
if(mr != null) {
|
|
|
|
|
addEmojiReaction(mr.shortcode, mr.emojiUtf16, count)
|
|
|
|
|
continue
|
|
|
|
|
}
|
2020-01-10 14:42:37 +01:00
|
|
|
|
|
2020-01-07 09:31:05 +01:00
|
|
|
|
// カスタム絵文字のリアクション
|
2020-01-07 09:03:32 +01:00
|
|
|
|
val customCode = key.replace(":", "")
|
|
|
|
|
if(key != customCode) {
|
|
|
|
|
addCustomEmojiReaction(key, customCode, count)
|
2020-01-07 09:31:05 +01:00
|
|
|
|
continue
|
2019-04-07 15:47:05 +02:00
|
|
|
|
}
|
2020-01-07 09:31:05 +01:00
|
|
|
|
|
|
|
|
|
// Unicode絵文字のリアクション
|
|
|
|
|
addEmojiReaction(key, key, count)
|
2018-08-21 03:53:52 +02:00
|
|
|
|
}
|
2020-01-04 15:17:19 +01:00
|
|
|
|
|
|
|
|
|
lastButton
|
|
|
|
|
?.layoutParams
|
2020-01-05 09:24:52 +01:00
|
|
|
|
?.cast<ViewGroup.MarginLayoutParams>()
|
2020-01-04 15:17:19 +01:00
|
|
|
|
?.endMargin = 0
|
2018-08-21 03:53:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llExtra.addView(box)
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 17:38:52 +01:00
|
|
|
|
private fun addReaction(status : TootStatus, code : String?) {
|
2018-08-21 03:53:52 +02:00
|
|
|
|
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(status.myReaction?.isNotEmpty() == true) {
|
|
|
|
|
showToast(activity, false, R.string.already_reactioned)
|
2018-08-23 06:32:55 +02:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 15:31:44 +02:00
|
|
|
|
if(access_info.isPseudo || ! access_info.isMisskey) return
|
|
|
|
|
|
|
|
|
|
if(code == null) {
|
2018-08-21 03:53:52 +02:00
|
|
|
|
val ad = ActionsDialog()
|
2018-08-21 15:31:44 +02:00
|
|
|
|
for(mr in MisskeyReaction.values()) {
|
|
|
|
|
val newCode = mr.shortcode
|
2018-08-21 03:53:52 +02:00
|
|
|
|
val sb = SpannableStringBuilder()
|
2019-09-14 22:09:52 +02:00
|
|
|
|
.appendMisskeyReaction(activity, mr.emojiUtf16, " ")
|
2018-08-21 03:53:52 +02:00
|
|
|
|
.append(' ')
|
|
|
|
|
.append(mr.shortcode)
|
2018-08-21 15:31:44 +02:00
|
|
|
|
ad.addAction(sb) {
|
|
|
|
|
addReaction(status, newCode)
|
2018-08-21 03:53:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ad.show(activity)
|
|
|
|
|
return
|
|
|
|
|
}
|
2018-08-21 15:31:44 +02:00
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity, progress_style = TootTaskRunner.PROGRESS_NONE).run(access_info,
|
|
|
|
|
object : TootTask {
|
|
|
|
|
override fun background(client : TootApiClient) : TootApiResult? {
|
2020-01-07 09:03:32 +01:00
|
|
|
|
val params = access_info.putMisskeyApiToken().apply {
|
|
|
|
|
put("noteId", status.id.toString())
|
|
|
|
|
put("reaction", code)
|
|
|
|
|
}
|
2018-08-21 15:31:44 +02:00
|
|
|
|
|
|
|
|
|
@Suppress("UnnecessaryVariable")
|
|
|
|
|
val result =
|
|
|
|
|
client.request("/api/notes/reactions/create", params.toPostRequestBuilder())
|
|
|
|
|
|
|
|
|
|
// 成功すると204 no content
|
|
|
|
|
|
|
|
|
|
return result
|
2018-08-21 03:53:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 15:31:44 +02:00
|
|
|
|
override fun handleResult(result : TootApiResult?) {
|
|
|
|
|
result ?: return
|
|
|
|
|
|
|
|
|
|
val error = result.error
|
|
|
|
|
if(error != null) {
|
|
|
|
|
showToast(activity, false, error)
|
|
|
|
|
return
|
2018-08-21 03:53:52 +02:00
|
|
|
|
}
|
2018-08-21 15:31:44 +02:00
|
|
|
|
|
2019-08-24 05:35:22 +02:00
|
|
|
|
if((result.response?.code ?: - 1) in 200 until 300) {
|
2018-11-12 18:19:57 +01:00
|
|
|
|
if(status.increaseReaction(code, true, "addReaction")) {
|
2018-11-03 17:14:14 +01:00
|
|
|
|
// 1個だけ描画更新するのではなく、TLにある複数の要素をまとめて更新する
|
|
|
|
|
list_adapter.notifyChange(reason = "addReaction complete", reset = true)
|
2018-08-21 15:31:44 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 03:53:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 15:31:44 +02:00
|
|
|
|
})
|
2018-08-21 03:53:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 17:38:52 +01:00
|
|
|
|
private fun removeReaction(status : TootStatus, confirmed : Boolean = false) {
|
|
|
|
|
|
|
|
|
|
val reaction = status.myReaction
|
|
|
|
|
|
|
|
|
|
if(reaction?.isNotEmpty() != true) {
|
|
|
|
|
showToast(activity, false, R.string.not_reactioned)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(access_info.isPseudo || ! access_info.isMisskey) return
|
|
|
|
|
|
2019-01-06 09:35:22 +01:00
|
|
|
|
if(! confirmed) {
|
2018-12-29 17:38:52 +01:00
|
|
|
|
AlertDialog.Builder(activity)
|
2019-01-06 09:35:22 +01:00
|
|
|
|
.setMessage(activity.getString(R.string.reaction_remove_confirm, reaction))
|
2018-12-29 17:38:52 +01:00
|
|
|
|
.setNegativeButton(R.string.cancel, null)
|
|
|
|
|
.setPositiveButton(R.string.ok) { _, _ ->
|
|
|
|
|
removeReaction(status, confirmed = true)
|
|
|
|
|
}
|
|
|
|
|
.show()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TootTaskRunner(activity, progress_style = TootTaskRunner.PROGRESS_NONE).run(access_info,
|
|
|
|
|
object : TootTask {
|
|
|
|
|
override fun background(client : TootApiClient) : TootApiResult? =
|
2019-04-25 04:06:41 +02:00
|
|
|
|
// 成功すると204 no content
|
2018-12-29 17:38:52 +01:00
|
|
|
|
client.request(
|
|
|
|
|
"/api/notes/reactions/delete",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
access_info.putMisskeyApiToken().apply {
|
|
|
|
|
put("noteId", status.id.toString())
|
|
|
|
|
}
|
2018-12-29 17:38:52 +01:00
|
|
|
|
.toPostRequestBuilder()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
override fun handleResult(result : TootApiResult?) {
|
|
|
|
|
result ?: return
|
|
|
|
|
|
|
|
|
|
val error = result.error
|
|
|
|
|
if(error != null) {
|
|
|
|
|
showToast(activity, false, error)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-24 05:35:22 +02:00
|
|
|
|
if((result.response?.code ?: - 1) in 200 until 300) {
|
2019-01-06 09:35:22 +01:00
|
|
|
|
if(status.decreaseReaction(reaction, true, "removeReaction")) {
|
2018-12-29 17:38:52 +01:00
|
|
|
|
// 1個だけ描画更新するのではなく、TLにある複数の要素をまとめて更新する
|
2019-01-06 09:35:22 +01:00
|
|
|
|
list_adapter.notifyChange(
|
|
|
|
|
reason = "removeReaction complete",
|
|
|
|
|
reset = true
|
|
|
|
|
)
|
2018-12-29 17:38:52 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2019-01-06 09:35:22 +01:00
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
private fun showEnqueteItems(status : TootStatus, enquete : TootPolls) {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
val items = enquete.items ?: return
|
|
|
|
|
|
|
|
|
|
val now = System.currentTimeMillis()
|
|
|
|
|
|
|
|
|
|
val canVote = when(enquete.pollType) {
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Mastodon -> when {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
enquete.expired -> false
|
|
|
|
|
now >= enquete.expired_at -> false
|
2019-09-22 20:25:00 +02:00
|
|
|
|
enquete.ownVoted -> false
|
2019-03-06 10:49:02 +01:00
|
|
|
|
else -> true
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.FriendsNico -> {
|
|
|
|
|
val remain = enquete.time_start + TootPolls.ENQUETE_EXPIRE - now
|
2019-09-23 18:03:27 +02:00
|
|
|
|
remain > 0L && ! enquete.ownVoted
|
2019-03-06 10:49:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 18:03:27 +02:00
|
|
|
|
TootPollsType.Misskey -> ! enquete.ownVoted
|
2019-03-06 10:49:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
items.forEachIndexed { index, choice ->
|
|
|
|
|
makeEnqueteChoiceView(status, enquete, canVote, index, choice)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
when(enquete.pollType) {
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Mastodon -> makeEnqueteFooterMastodon(status, enquete, canVote)
|
2019-03-06 10:49:02 +01:00
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.FriendsNico -> makeEnqueteFooterFriendsNico(enquete)
|
2019-03-06 10:49:02 +01:00
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Misskey -> {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
private fun makeEnqueteChoiceView(
|
2019-03-06 10:49:02 +01:00
|
|
|
|
status : TootStatus,
|
2019-04-14 05:41:29 +02:00
|
|
|
|
enquete : TootPolls,
|
2019-03-06 10:49:02 +01:00
|
|
|
|
canVote : Boolean,
|
2018-01-04 19:52:25 +01:00
|
|
|
|
i : Int,
|
2019-04-14 05:41:29 +02:00
|
|
|
|
item : TootPollsChoice
|
2018-01-04 19:52:25 +01:00
|
|
|
|
) {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
|
|
|
|
|
val text = when(enquete.pollType) {
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Misskey -> {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
val sb = SpannableStringBuilder()
|
|
|
|
|
.append(item.decoded_text)
|
|
|
|
|
|
2019-09-23 18:03:27 +02:00
|
|
|
|
if(enquete.ownVoted) {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
sb.append(" / ")
|
|
|
|
|
sb.append(activity.getString(R.string.vote_count_text, item.votes))
|
2019-09-23 18:03:27 +02:00
|
|
|
|
if(item.isVoted) sb.append(' ').append(0x2713.toChar())
|
2019-03-06 10:49:02 +01:00
|
|
|
|
}
|
|
|
|
|
sb
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.FriendsNico -> {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
item.decoded_text
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Mastodon -> if(canVote) {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
item.decoded_text
|
|
|
|
|
} else {
|
|
|
|
|
val sb = SpannableStringBuilder()
|
|
|
|
|
.append(item.decoded_text)
|
|
|
|
|
if(! canVote) {
|
2019-12-03 15:55:30 +01:00
|
|
|
|
val v = item.votes
|
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
sb.append(" / ")
|
|
|
|
|
sb.append(
|
2019-12-03 15:55:30 +01:00
|
|
|
|
when {
|
|
|
|
|
v == null ||
|
|
|
|
|
(column.isSearchColumn && column.access_info.isNA) ->
|
|
|
|
|
activity.getString(R.string.vote_count_unavailable)
|
|
|
|
|
else ->
|
|
|
|
|
activity.getString(R.string.vote_count_text, v)
|
2019-03-06 10:49:02 +01:00
|
|
|
|
}
|
|
|
|
|
)
|
2019-09-23 18:03:27 +02:00
|
|
|
|
if(item.isVoted) sb.append(' ').append(0x2713.toChar())
|
2019-03-06 10:49:02 +01:00
|
|
|
|
}
|
|
|
|
|
sb
|
|
|
|
|
}
|
2018-08-24 18:24:11 +02:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
// 投票ボタンの表示
|
2018-01-17 18:39:16 +01:00
|
|
|
|
val lp = LinearLayout.LayoutParams(
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
2019-03-06 10:49:02 +01:00
|
|
|
|
).apply {
|
|
|
|
|
if(i == 0) topMargin = (0.5f + activity.density * 3f).toInt()
|
2018-08-24 18:24:11 +02:00
|
|
|
|
}
|
2019-03-06 10:49:02 +01:00
|
|
|
|
|
2018-08-31 14:47:40 +02:00
|
|
|
|
if(! canVote) {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
|
|
|
|
|
val b = TextView(activity)
|
|
|
|
|
b.layoutParams = lp
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
b.text = text
|
|
|
|
|
val invalidator = NetworkEmojiInvalidator(activity.handler, b)
|
|
|
|
|
extra_invalidator_list.add(invalidator)
|
|
|
|
|
invalidator.register(text)
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
b.padding = (activity.density * 3f + 0.5f).toInt()
|
|
|
|
|
|
2019-04-25 04:06:41 +02:00
|
|
|
|
val ratio = when(enquete.pollType) {
|
|
|
|
|
TootPollsType.Mastodon -> {
|
|
|
|
|
val votesCount = enquete.votes_count ?: 0
|
|
|
|
|
val max = enquete.maxVotesCount ?: 0
|
|
|
|
|
if(max > 0 && votesCount > 0) {
|
|
|
|
|
(item.votes ?: 0).toFloat() / votesCount.toFloat()
|
|
|
|
|
} else {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
|
|
|
|
else -> {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
val ratios = enquete.ratios
|
2019-04-25 04:06:41 +02:00
|
|
|
|
if(ratios != null && i <= ratios.size) {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
ratios[i]
|
2019-04-25 04:06:41 +02:00
|
|
|
|
} else {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
|
|
|
|
if(ratio != null) {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
b.backgroundDrawable = PollPlotDrawable(
|
|
|
|
|
color = (content_color and 0xFFFFFF) or 0x20000000,
|
|
|
|
|
ratio = ratio,
|
|
|
|
|
isRtl = b.layoutDirection == View.LAYOUT_DIRECTION_RTL,
|
|
|
|
|
startWidth = (activity.density * 2f + 0.5f).toInt()
|
|
|
|
|
)
|
|
|
|
|
}
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
llExtra.addView(b)
|
2019-04-25 04:06:41 +02:00
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
} else if(enquete.multiple) {
|
|
|
|
|
// 複数選択なのでチェックボックス
|
|
|
|
|
val b = CheckBox(activity)
|
|
|
|
|
b.layoutParams = lp
|
|
|
|
|
b.isAllCaps = false
|
|
|
|
|
b.text = text
|
|
|
|
|
val invalidator = NetworkEmojiInvalidator(activity.handler, b)
|
|
|
|
|
extra_invalidator_list.add(invalidator)
|
|
|
|
|
invalidator.register(text)
|
|
|
|
|
if(! canVote) {
|
|
|
|
|
b.isEnabled = false
|
|
|
|
|
} else {
|
|
|
|
|
b.isChecked = item.checked
|
|
|
|
|
b.setOnCheckedChangeListener { _, checked ->
|
|
|
|
|
item.checked = checked
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
llExtra.addView(b)
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
} else {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
val b = Button(activity)
|
|
|
|
|
b.layoutParams = lp
|
|
|
|
|
b.isAllCaps = false
|
|
|
|
|
b.text = text
|
|
|
|
|
val invalidator = NetworkEmojiInvalidator(activity.handler, b)
|
|
|
|
|
extra_invalidator_list.add(invalidator)
|
|
|
|
|
invalidator.register(text)
|
|
|
|
|
if(! canVote) {
|
|
|
|
|
b.isEnabled = false
|
|
|
|
|
} else {
|
|
|
|
|
val accessInfo = this@ItemViewHolder.access_info
|
|
|
|
|
b.setOnClickListener { view ->
|
|
|
|
|
val context = view.context ?: return@setOnClickListener
|
|
|
|
|
onClickEnqueteChoice(status, enquete, context, accessInfo, i)
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
2019-03-06 10:49:02 +01:00
|
|
|
|
llExtra.addView(b)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
private fun makeEnqueteFooterFriendsNico(enquete : TootPolls) {
|
2018-12-16 12:24:44 +01:00
|
|
|
|
val density = activity.density
|
2018-01-04 19:52:25 +01:00
|
|
|
|
val height = (0.5f + 6 * density).toInt()
|
|
|
|
|
val view = EnqueteTimerView(activity)
|
2018-01-17 18:39:16 +01:00
|
|
|
|
view.layoutParams =
|
|
|
|
|
LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height)
|
2019-04-14 05:41:29 +02:00
|
|
|
|
view.setParams(enquete.time_start, TootPolls.ENQUETE_EXPIRE)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
llExtra.addView(view)
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
private fun makeEnqueteFooterMastodon(
|
|
|
|
|
status : TootStatus,
|
2019-04-14 05:41:29 +02:00
|
|
|
|
enquete : TootPolls,
|
2019-03-06 10:49:02 +01:00
|
|
|
|
canVote : Boolean
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
val density = activity.density
|
|
|
|
|
|
|
|
|
|
if(canVote && enquete.multiple) {
|
|
|
|
|
// 複数選択の投票ボタン
|
|
|
|
|
val lp = LinearLayout.LayoutParams(
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
|
|
|
|
).apply {
|
|
|
|
|
topMargin = (0.5f + density * 3f).toInt()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val b = Button(activity)
|
|
|
|
|
b.layoutParams = lp
|
|
|
|
|
b.isAllCaps = false
|
|
|
|
|
b.text = activity.getString(R.string.vote_button)
|
|
|
|
|
val accessInfo = this@ItemViewHolder.access_info
|
|
|
|
|
b.setOnClickListener { view ->
|
|
|
|
|
val context = view.context ?: return@setOnClickListener
|
|
|
|
|
sendMultiple(status, enquete, context, accessInfo)
|
|
|
|
|
}
|
|
|
|
|
llExtra.addView(b)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val tv = TextView(activity)
|
|
|
|
|
val lp = LinearLayout.LayoutParams(
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
|
|
|
|
)
|
|
|
|
|
lp.topMargin = (0.5f + 3 * density).toInt()
|
|
|
|
|
tv.layoutParams = lp
|
|
|
|
|
|
|
|
|
|
val sb = StringBuilder()
|
|
|
|
|
|
|
|
|
|
val votes_count = enquete.votes_count ?: 0
|
|
|
|
|
when {
|
|
|
|
|
votes_count == 1 -> sb.append(activity.getString(R.string.vote_1))
|
|
|
|
|
votes_count > 1 -> sb.append(activity.getString(R.string.vote_2, votes_count))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
when(val t = enquete.expired_at) {
|
|
|
|
|
|
|
|
|
|
Long.MAX_VALUE -> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
|
if(sb.isNotEmpty()) sb.append(" ")
|
|
|
|
|
sb.append(
|
|
|
|
|
activity.getString(
|
|
|
|
|
R.string.vote_expire_at,
|
|
|
|
|
TootStatus.formatTime(activity, t, false)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tv.text = sb.toString()
|
|
|
|
|
|
|
|
|
|
llExtra.addView(tv)
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 19:52:25 +01:00
|
|
|
|
private fun onClickEnqueteChoice(
|
2019-03-06 10:49:02 +01:00
|
|
|
|
status : TootStatus,
|
2019-04-14 05:41:29 +02:00
|
|
|
|
enquete : TootPolls,
|
2018-01-04 19:52:25 +01:00
|
|
|
|
context : Context,
|
|
|
|
|
accessInfo : SavedAccount,
|
|
|
|
|
idx : Int
|
|
|
|
|
) {
|
2019-09-22 20:25:00 +02:00
|
|
|
|
if(enquete.ownVoted) {
|
2018-08-24 18:24:11 +02:00
|
|
|
|
showToast(context, false, R.string.already_voted)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
2019-03-06 10:49:02 +01:00
|
|
|
|
|
|
|
|
|
val now = System.currentTimeMillis()
|
|
|
|
|
|
|
|
|
|
when(enquete.pollType) {
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Misskey -> {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
// Misskeyのアンケートには期限がない?
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.FriendsNico -> {
|
|
|
|
|
val remain = enquete.time_start + TootPolls.ENQUETE_EXPIRE - now
|
2019-03-06 10:49:02 +01:00
|
|
|
|
if(remain <= 0L) {
|
|
|
|
|
showToast(context, false, R.string.enquete_was_end)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Mastodon -> {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
if(enquete.expired || now >= enquete.expired_at) {
|
|
|
|
|
showToast(context, false, R.string.enquete_was_end)
|
|
|
|
|
return
|
|
|
|
|
}
|
2018-08-24 18:24:11 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
|
|
TootTaskRunner(context).run(accessInfo, object : TootTask {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
override fun background(client : TootApiClient) = when(enquete.pollType) {
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Misskey -> client.request(
|
2019-03-06 10:49:02 +01:00
|
|
|
|
"/api/notes/polls/vote",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
accessInfo.putMisskeyApiToken().apply {
|
|
|
|
|
put("noteId", enquete.status_id.toString())
|
|
|
|
|
put("choice", idx)
|
|
|
|
|
|
|
|
|
|
}.toPostRequestBuilder()
|
2019-03-06 10:49:02 +01:00
|
|
|
|
)
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Mastodon -> client.request(
|
2019-03-06 10:49:02 +01:00
|
|
|
|
"/api/v1/polls/${enquete.pollId}/votes",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
jsonObject {
|
|
|
|
|
put("choices", jsonArray { add(idx) })
|
|
|
|
|
}.toPostRequestBuilder()
|
2019-03-06 10:49:02 +01:00
|
|
|
|
)
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.FriendsNico -> client.request(
|
2019-03-06 10:49:02 +01:00
|
|
|
|
"/api/v1/votes/${enquete.status_id}",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
jsonObject {
|
|
|
|
|
put("item_index", idx.toString())
|
|
|
|
|
}.toPostRequestBuilder()
|
2019-03-06 10:49:02 +01:00
|
|
|
|
)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun handleResult(result : TootApiResult?) {
|
|
|
|
|
result ?: return // cancelled.
|
|
|
|
|
|
|
|
|
|
val data = result.jsonObject
|
|
|
|
|
if(data != null) {
|
2019-03-06 10:49:02 +01:00
|
|
|
|
when(enquete.pollType) {
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Misskey -> if(enquete.increaseVote(activity, idx, true)) {
|
2018-11-03 17:14:14 +01:00
|
|
|
|
showToast(context, false, R.string.enquete_voted)
|
2018-11-12 18:19:57 +01:00
|
|
|
|
|
2018-11-03 17:14:14 +01:00
|
|
|
|
// 1個だけ開閉するのではなく、例えば通知TLにある複数の要素をまとめて開閉するなどある
|
|
|
|
|
list_adapter.notifyChange(reason = "onClickEnqueteChoice", reset = true)
|
|
|
|
|
}
|
2018-08-31 14:47:40 +02:00
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Mastodon -> {
|
|
|
|
|
val newPoll = TootPolls.parse(
|
2019-03-06 10:49:02 +01:00
|
|
|
|
TootParser(activity, accessInfo),
|
|
|
|
|
status,
|
|
|
|
|
status.media_attachments,
|
|
|
|
|
data,
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Mastodon
|
2019-03-06 10:49:02 +01:00
|
|
|
|
)
|
|
|
|
|
if(newPoll != null) {
|
|
|
|
|
status.enquete = newPoll
|
|
|
|
|
// 1個だけ開閉するのではなく、例えば通知TLにある複数の要素をまとめて開閉するなどある
|
|
|
|
|
list_adapter.notifyChange(
|
|
|
|
|
reason = "onClickEnqueteChoice",
|
|
|
|
|
reset = true
|
|
|
|
|
)
|
|
|
|
|
} else if(result.error != null) {
|
|
|
|
|
showToast(context, true, "response parse error")
|
|
|
|
|
}
|
2018-08-24 18:24:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.FriendsNico -> {
|
2020-01-08 04:23:45 +01:00
|
|
|
|
val message = data.string("message") ?: "?"
|
2019-03-06 10:49:02 +01:00
|
|
|
|
val valid = data.optBoolean("valid")
|
|
|
|
|
if(valid) {
|
|
|
|
|
showToast(context, false, R.string.enquete_voted)
|
|
|
|
|
} else {
|
|
|
|
|
showToast(context, true, R.string.enquete_vote_failed, message)
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2018-01-21 13:46:36 +01:00
|
|
|
|
showToast(context, true, result.error)
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
private fun sendMultiple(
|
|
|
|
|
status : TootStatus,
|
2019-04-14 05:41:29 +02:00
|
|
|
|
enquete : TootPolls,
|
2019-03-06 10:49:02 +01:00
|
|
|
|
context : Context,
|
|
|
|
|
accessInfo : SavedAccount
|
|
|
|
|
) {
|
|
|
|
|
val now = System.currentTimeMillis()
|
|
|
|
|
if(now >= enquete.expired_at) {
|
|
|
|
|
showToast(context, false, R.string.enquete_was_end)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-25 04:06:41 +02:00
|
|
|
|
if(enquete.items?.find { it.checked } == null) {
|
2019-04-20 08:49:05 +02:00
|
|
|
|
showToast(context, false, R.string.polls_choice_not_selected)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 10:49:02 +01:00
|
|
|
|
TootTaskRunner(context).run(accessInfo, object : TootTask {
|
|
|
|
|
|
2019-04-14 05:41:29 +02:00
|
|
|
|
var newPoll : TootPolls? = null
|
2019-03-06 10:49:02 +01:00
|
|
|
|
|
|
|
|
|
override fun background(client : TootApiClient) : TootApiResult? {
|
|
|
|
|
return client.request(
|
|
|
|
|
"/api/v1/polls/${enquete.pollId}/votes",
|
2020-01-07 09:03:32 +01:00
|
|
|
|
jsonObject {
|
|
|
|
|
put("choices", jsonArray {
|
2019-04-25 04:06:41 +02:00
|
|
|
|
enquete.items.forEachIndexed { index, choice ->
|
2020-01-07 09:03:32 +01:00
|
|
|
|
if(choice.checked) add(index)
|
2019-03-06 10:49:02 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2020-01-07 09:03:32 +01:00
|
|
|
|
}.toPostRequestBuilder()
|
2019-03-06 10:49:02 +01:00
|
|
|
|
)?.also { result ->
|
|
|
|
|
val data = result.jsonObject
|
|
|
|
|
if(data != null) {
|
2019-04-14 05:41:29 +02:00
|
|
|
|
newPoll = TootPolls.parse(
|
2019-03-06 10:49:02 +01:00
|
|
|
|
TootParser(activity, accessInfo),
|
|
|
|
|
status,
|
|
|
|
|
status.media_attachments,
|
|
|
|
|
data,
|
2019-04-14 05:41:29 +02:00
|
|
|
|
TootPollsType.Mastodon
|
2019-03-06 10:49:02 +01:00
|
|
|
|
)
|
|
|
|
|
if(newPoll == null) result.setError("response parse error")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun handleResult(result : TootApiResult?) {
|
|
|
|
|
result ?: return // cancelled.
|
|
|
|
|
|
|
|
|
|
val newPoll = this.newPoll
|
|
|
|
|
if(newPoll != null) {
|
|
|
|
|
status.enquete = newPoll
|
|
|
|
|
// 1個だけ開閉するのではなく、例えば通知TLにある複数の要素をまとめて開閉するなどある
|
|
|
|
|
list_adapter.notifyChange(reason = "onClickEnqueteChoice", reset = true)
|
|
|
|
|
} else if(result.error != null) {
|
|
|
|
|
showToast(context, true, result.error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-07 07:15:16 +02:00
|
|
|
|
private fun openFilterMenu(item : TootFilter) {
|
|
|
|
|
val ad = ActionsDialog()
|
2018-08-04 20:07:55 +02:00
|
|
|
|
ad.addAction(activity.getString(R.string.edit)) {
|
|
|
|
|
ActKeywordFilter.open(activity, access_info, item.id)
|
2018-07-07 07:15:16 +02:00
|
|
|
|
}
|
2018-08-04 20:07:55 +02:00
|
|
|
|
ad.addAction(activity.getString(R.string.delete)) {
|
|
|
|
|
Action_Filter.delete(activity, access_info, item)
|
2018-07-07 07:15:16 +02:00
|
|
|
|
}
|
2018-08-04 20:07:55 +02:00
|
|
|
|
ad.show(activity, activity.getString(R.string.filter_of, item.phrase))
|
2018-07-07 07:15:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-04 04:10:42 +02:00
|
|
|
|
internal fun getAccount() = status_account ?: boost_account ?: follow_account
|
|
|
|
|
|
2018-07-07 07:15:16 +02:00
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2018-08-21 15:31:44 +02:00
|
|
|
|
private fun inflate(activity : ActMain) = with(activity.UI {}) {
|
2018-11-15 23:08:11 +01:00
|
|
|
|
val b = Benchmark(log, "Item-Inflate", 40L)
|
|
|
|
|
val rv = verticalLayout {
|
2018-01-14 22:47:42 +01:00
|
|
|
|
// トップレベルのViewGroupのlparamsはイニシャライザ内部に置くしかないみたい
|
2019-03-06 10:49:02 +01:00
|
|
|
|
layoutParams =
|
|
|
|
|
androidx.recyclerview.widget.RecyclerView.LayoutParams(matchParent, wrapContent)
|
|
|
|
|
.apply {
|
|
|
|
|
marginStart = dip(8)
|
|
|
|
|
marginEnd = dip(8)
|
|
|
|
|
topMargin = dip(2f)
|
|
|
|
|
bottomMargin = dip(1f)
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2018-12-01 00:02:18 +01:00
|
|
|
|
setPaddingRelative(dip(4), dip(1f), dip(4), dip(2f))
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
|
|
|
|
|
|
|
|
|
llBoosted = linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent) {
|
|
|
|
|
bottomMargin = dip(6)
|
|
|
|
|
}
|
2019-02-03 17:58:37 +01:00
|
|
|
|
backgroundResource = R.drawable.btn_bg_transparent
|
2018-01-14 22:47:42 +01:00
|
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
|
|
|
|
|
ivBoosted = imageView {
|
|
|
|
|
scaleType = ImageView.ScaleType.FIT_END
|
|
|
|
|
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
|
|
|
|
|
}.lparams(dip(48), dip(32)) {
|
|
|
|
|
endMargin = dip(4)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verticalLayout {
|
|
|
|
|
lparams(dip(0), wrapContent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
tvBoostedAcct = textView {
|
|
|
|
|
ellipsize = TextUtils.TruncateAt.END
|
|
|
|
|
gravity = Gravity.END
|
|
|
|
|
maxLines = 1
|
|
|
|
|
textSize = 12f // textSize の単位はSP
|
|
|
|
|
// tools:text ="who@hoge"
|
|
|
|
|
}.lparams(dip(0), wrapContent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tvBoostedTime = textView {
|
|
|
|
|
|
|
|
|
|
startPadding = dip(2)
|
|
|
|
|
|
|
|
|
|
gravity = Gravity.END
|
|
|
|
|
textSize = 12f // textSize の単位はSP
|
|
|
|
|
// tools:ignore="RtlSymmetry"
|
|
|
|
|
// tools:text="2017-04-16 09:37:14"
|
|
|
|
|
}.lparams(wrapContent, wrapContent)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tvBoosted = textView {
|
|
|
|
|
// tools:text = "~にブーストされました"
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llFollow = linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
|
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
|
|
|
|
|
ivFollow = myNetworkImageView {
|
|
|
|
|
contentDescription = context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.FIT_END
|
|
|
|
|
}.lparams(dip(48), dip(40)) {
|
|
|
|
|
endMargin = dip(4)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verticalLayout {
|
|
|
|
|
|
|
|
|
|
lparams(dip(0), wrapContent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tvFollowerName = textView {
|
|
|
|
|
// tools:text="Follower Name"
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
tvFollowerAcct = textView {
|
|
|
|
|
setPaddingStartEnd(dip(4), dip(4))
|
|
|
|
|
textSize = 12f // SP
|
|
|
|
|
// tools:text="aaaaaaaaaaaaaaaa"
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
2019-08-29 18:16:21 +02:00
|
|
|
|
|
2019-08-30 06:02:08 +02:00
|
|
|
|
tvLastStatusAt = myTextView {
|
2019-08-29 18:16:21 +02:00
|
|
|
|
setPaddingStartEnd(dip(4), dip(4))
|
|
|
|
|
textSize = 12f // SP
|
|
|
|
|
// tools:text="aaaaaaaaaaaaaaaa"
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frameLayout {
|
|
|
|
|
lparams(dip(40), dip(40)) {
|
|
|
|
|
startMargin = dip(4)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnFollow = imageButton {
|
2018-01-17 18:39:16 +01:00
|
|
|
|
background =
|
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
contentDescription = context.getString(R.string.follow)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER
|
|
|
|
|
// tools:src="?attr/ic_follow_plus"
|
|
|
|
|
}.lparams(matchParent, matchParent)
|
|
|
|
|
|
|
|
|
|
ivFollowedBy = imageView {
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER
|
|
|
|
|
// tools:src="?attr/ic_followed_by"
|
|
|
|
|
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
|
|
|
|
|
}.lparams(matchParent, matchParent)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-23 05:46:14 +02:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
llStatus = verticalLayout {
|
|
|
|
|
lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
tvAcct = textView {
|
|
|
|
|
ellipsize = TextUtils.TruncateAt.END
|
|
|
|
|
gravity = Gravity.END
|
|
|
|
|
maxLines = 1
|
|
|
|
|
textSize = 12f // SP
|
|
|
|
|
// tools:text="who@hoge"
|
|
|
|
|
}.lparams(dip(0), wrapContent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tvTime = textView {
|
|
|
|
|
gravity = Gravity.END
|
|
|
|
|
startPadding = dip(2)
|
|
|
|
|
textSize = 12f // SP
|
|
|
|
|
// tools:ignore="RtlSymmetry"
|
|
|
|
|
// tools:text="2017-04-16 09:37:14"
|
|
|
|
|
}.lparams(wrapContent, wrapContent)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
ivThumbnail = myNetworkImageView {
|
2018-01-17 18:39:16 +01:00
|
|
|
|
background =
|
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
contentDescription = context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
}.lparams(dip(48), dip(48)) {
|
|
|
|
|
topMargin = dip(4)
|
|
|
|
|
endMargin = dip(4)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verticalLayout {
|
|
|
|
|
lparams(dip(0), wrapContent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tvName = textView {
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
|
|
|
|
|
2018-12-26 05:47:16 +01:00
|
|
|
|
llInstanceTicker = linearLayout {
|
2018-12-08 16:29:07 +01:00
|
|
|
|
lparams(matchParent, wrapContent)
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
|
|
|
|
ivInstanceTicker = myNetworkImageView {
|
|
|
|
|
}.lparams(dip(16), dip(16)) {
|
2018-12-08 16:29:07 +01:00
|
|
|
|
isBaselineAligned = false
|
|
|
|
|
}
|
2018-12-26 05:47:16 +01:00
|
|
|
|
|
|
|
|
|
tvInstanceTicker = textView {
|
|
|
|
|
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10f)
|
|
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
setPaddingStartEnd(dip(4f), dip(4f))
|
|
|
|
|
}.lparams(0, dip(16)) {
|
2018-12-08 16:29:07 +01:00
|
|
|
|
isBaselineAligned = false
|
2018-12-26 05:47:16 +01:00
|
|
|
|
weight = 1f
|
2018-12-08 16:29:07 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-23 05:46:14 +02:00
|
|
|
|
llReply = linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent) {
|
|
|
|
|
bottomMargin = dip(3)
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 14:47:40 +02:00
|
|
|
|
background =
|
2018-11-15 23:08:11 +01:00
|
|
|
|
ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.btn_bg_transparent
|
|
|
|
|
)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
|
|
|
|
|
ivReply = imageView {
|
|
|
|
|
scaleType = ImageView.ScaleType.FIT_END
|
|
|
|
|
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
|
2019-01-16 13:33:07 +01:00
|
|
|
|
padding = dip(4)
|
2018-08-23 05:46:14 +02:00
|
|
|
|
}.lparams(dip(32), dip(32)) {
|
|
|
|
|
endMargin = dip(4)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tvReply = textView {
|
|
|
|
|
}.lparams(dip(0), wrapContent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
llContentWarning = linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent) {
|
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
isBaselineAligned = false
|
|
|
|
|
}
|
|
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
|
|
|
|
|
btnContentWarning = button {
|
|
|
|
|
|
2019-01-20 22:04:57 +01:00
|
|
|
|
backgroundDrawable =
|
2018-11-18 15:29:35 +01:00
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.bg_button_cw)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
minWidthCompat = dip(40)
|
|
|
|
|
padding = dip(4)
|
|
|
|
|
//tools:text="見る"
|
|
|
|
|
}.lparams(wrapContent, dip(40)) {
|
|
|
|
|
endMargin = dip(8)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verticalLayout {
|
|
|
|
|
lparams(dip(0), wrapContent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tvMentions = myTextView {
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
tvContentWarning = myTextView {
|
|
|
|
|
}.lparams(matchParent, wrapContent) {
|
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llContents = verticalLayout {
|
|
|
|
|
lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
tvContent = myTextView {
|
|
|
|
|
setLineSpacing(lineSpacingExtra, 1.1f)
|
|
|
|
|
// tools:text="Contents\nContents"
|
|
|
|
|
}.lparams(matchParent, wrapContent) {
|
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-21 16:39:10 +01:00
|
|
|
|
val actMain = activity as? ActMain
|
2018-11-15 23:08:11 +01:00
|
|
|
|
val thumbnailHeight =
|
|
|
|
|
actMain?.app_state?.media_thumb_height ?: dip(64)
|
2018-04-05 20:04:45 +02:00
|
|
|
|
val verticalArrangeThumbnails = Pref.bpVerticalArrangeThumbnails(
|
|
|
|
|
actMain?.pref ?: Pref.pref(context)
|
|
|
|
|
)
|
2018-03-21 16:39:10 +01:00
|
|
|
|
|
2018-04-05 20:04:45 +02:00
|
|
|
|
flMedia = if(verticalArrangeThumbnails) {
|
2018-03-21 16:39:10 +01:00
|
|
|
|
frameLayout {
|
2019-07-24 22:20:16 +02:00
|
|
|
|
lparams(matchParent, wrapContent) {
|
2018-03-21 16:39:10 +01:00
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
}
|
|
|
|
|
llMedia = verticalLayout {
|
|
|
|
|
lparams(matchParent, matchParent)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2018-03-21 16:39:10 +01:00
|
|
|
|
btnHideMedia = imageButton {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.btn_bg_transparent
|
|
|
|
|
)
|
2020-01-27 06:45:16 +01:00
|
|
|
|
contentDescription = context.getString(R.string.hide)
|
2019-01-16 13:33:07 +01:00
|
|
|
|
imageResource = R.drawable.ic_close
|
2018-04-05 20:04:45 +02:00
|
|
|
|
}.lparams(dip(32), dip(32)) {
|
2018-03-21 16:39:10 +01:00
|
|
|
|
gravity = Gravity.END
|
|
|
|
|
}
|
2018-03-06 23:28:41 +01:00
|
|
|
|
|
2018-03-21 16:39:10 +01:00
|
|
|
|
ivMedia1 = myNetworkImageView {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.bg_thumbnail
|
|
|
|
|
)
|
|
|
|
|
contentDescription =
|
|
|
|
|
context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
|
|
|
|
|
}.lparams(matchParent, thumbnailHeight) {
|
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2018-03-21 16:39:10 +01:00
|
|
|
|
ivMedia2 = myNetworkImageView {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.bg_thumbnail
|
|
|
|
|
)
|
|
|
|
|
contentDescription =
|
|
|
|
|
context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
|
|
|
|
|
}.lparams(matchParent, thumbnailHeight) {
|
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2018-03-21 16:39:10 +01:00
|
|
|
|
ivMedia3 = myNetworkImageView {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.bg_thumbnail
|
|
|
|
|
)
|
|
|
|
|
contentDescription =
|
|
|
|
|
context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
|
|
|
|
|
}.lparams(matchParent, thumbnailHeight) {
|
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2018-03-21 16:39:10 +01:00
|
|
|
|
ivMedia4 = myNetworkImageView {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.bg_thumbnail
|
|
|
|
|
)
|
|
|
|
|
contentDescription =
|
|
|
|
|
context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
|
|
|
|
|
}.lparams(matchParent, thumbnailHeight) {
|
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 10:59:07 +02:00
|
|
|
|
btnShowMedia = blurhashView {
|
2019-07-19 11:21:21 +02:00
|
|
|
|
|
2019-07-24 10:59:07 +02:00
|
|
|
|
errorColor = getAttributeColor(
|
|
|
|
|
context,
|
|
|
|
|
R.attr.colorShowMediaBackground
|
|
|
|
|
)
|
|
|
|
|
gravity = Gravity.CENTER
|
2019-07-19 11:21:21 +02:00
|
|
|
|
|
2019-07-24 10:59:07 +02:00
|
|
|
|
textColor = getAttributeColor(
|
|
|
|
|
context,
|
|
|
|
|
R.attr.colorShowMediaText
|
|
|
|
|
)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2019-07-24 10:59:07 +02:00
|
|
|
|
minHeightCompat = dip(48)
|
2019-07-19 11:21:21 +02:00
|
|
|
|
|
2019-08-23 01:49:20 +02:00
|
|
|
|
}.lparams(matchParent, thumbnailHeight)
|
2019-05-05 06:41:13 +02:00
|
|
|
|
|
2018-03-21 16:39:10 +01:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
frameLayout {
|
|
|
|
|
lparams(matchParent, thumbnailHeight) {
|
|
|
|
|
topMargin = dip(3)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
}
|
2018-03-21 16:39:10 +01:00
|
|
|
|
llMedia = linearLayout {
|
|
|
|
|
lparams(matchParent, matchParent)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2018-03-21 16:39:10 +01:00
|
|
|
|
ivMedia1 = myNetworkImageView {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.bg_thumbnail
|
|
|
|
|
)
|
|
|
|
|
contentDescription =
|
|
|
|
|
context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
|
|
|
|
|
}.lparams(0, matchParent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ivMedia2 = myNetworkImageView {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.bg_thumbnail
|
|
|
|
|
)
|
|
|
|
|
contentDescription =
|
|
|
|
|
context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
|
|
|
|
|
}.lparams(0, matchParent) {
|
|
|
|
|
startMargin = dip(8)
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ivMedia3 = myNetworkImageView {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.bg_thumbnail
|
|
|
|
|
)
|
|
|
|
|
contentDescription =
|
|
|
|
|
context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
|
|
|
|
|
}.lparams(0, matchParent) {
|
|
|
|
|
startMargin = dip(8)
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ivMedia4 = myNetworkImageView {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.bg_thumbnail
|
|
|
|
|
)
|
|
|
|
|
contentDescription =
|
|
|
|
|
context.getString(R.string.thumbnail)
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
|
|
|
|
|
}.lparams(0, matchParent) {
|
|
|
|
|
startMargin = dip(8)
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2018-03-21 16:39:10 +01:00
|
|
|
|
btnHideMedia = imageButton {
|
|
|
|
|
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.btn_bg_transparent
|
|
|
|
|
)
|
2020-01-29 06:15:32 +01:00
|
|
|
|
contentDescription = context.getString(R.string.hide)
|
2019-01-16 13:33:07 +01:00
|
|
|
|
imageResource = R.drawable.ic_close
|
2018-03-21 16:39:10 +01:00
|
|
|
|
}.lparams(dip(32), matchParent) {
|
|
|
|
|
startMargin = dip(8)
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-05 06:41:13 +02:00
|
|
|
|
btnShowMedia = blurhashView {
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
2019-05-05 06:41:13 +02:00
|
|
|
|
errorColor = getAttributeColor(
|
2018-01-17 18:39:16 +01:00
|
|
|
|
context,
|
2018-03-21 16:39:10 +01:00
|
|
|
|
R.attr.colorShowMediaBackground
|
2018-01-17 18:39:16 +01:00
|
|
|
|
)
|
2018-03-21 16:39:10 +01:00
|
|
|
|
gravity = Gravity.CENTER
|
2019-05-05 06:41:13 +02:00
|
|
|
|
|
2019-01-16 13:33:07 +01:00
|
|
|
|
textColor = getAttributeColor(
|
|
|
|
|
context,
|
|
|
|
|
R.attr.colorShowMediaText
|
|
|
|
|
)
|
2018-03-21 16:39:10 +01:00
|
|
|
|
|
|
|
|
|
}.lparams(matchParent, matchParent)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
tvMediaDescription = textView {}.lparams(matchParent, wrapContent)
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
llCardOuter = verticalLayout {
|
|
|
|
|
lparams(matchParent, wrapContent) {
|
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
startMargin = dip(12)
|
|
|
|
|
endMargin = dip(6)
|
|
|
|
|
}
|
|
|
|
|
padding = dip(3)
|
|
|
|
|
bottomPadding = dip(6)
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
background = PreviewCardBorder()
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
2018-11-17 22:01:06 +01:00
|
|
|
|
tvCardText = myTextView {
|
2018-11-12 18:19:57 +01:00
|
|
|
|
}.lparams(matchParent, wrapContent) {
|
|
|
|
|
}
|
2018-11-11 11:43:20 +01:00
|
|
|
|
|
2020-01-29 06:15:32 +01:00
|
|
|
|
flCardImage = frameLayout {
|
|
|
|
|
lparams(matchParent, activity.app_state.media_thumb_height) {
|
|
|
|
|
topMargin = dip(3)
|
|
|
|
|
}
|
2018-11-12 18:19:57 +01:00
|
|
|
|
|
2020-01-29 06:15:32 +01:00
|
|
|
|
llCardImage = linearLayout {
|
|
|
|
|
lparams(matchParent, matchParent)
|
|
|
|
|
|
|
|
|
|
ivCardImage = myNetworkImageView {
|
|
|
|
|
|
|
|
|
|
contentDescription =
|
|
|
|
|
context.getString(R.string.thumbnail)
|
|
|
|
|
|
|
|
|
|
scaleType = if(Pref.bpDontCropMediaThumb(App1.pref))
|
|
|
|
|
ImageView.ScaleType.FIT_CENTER
|
|
|
|
|
else
|
|
|
|
|
ImageView.ScaleType.CENTER_CROP
|
|
|
|
|
|
|
|
|
|
}.lparams(0, matchParent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
btnCardImageHide = imageButton {
|
|
|
|
|
background = ContextCompat.getDrawable(
|
|
|
|
|
context,
|
|
|
|
|
R.drawable.btn_bg_transparent
|
|
|
|
|
)
|
|
|
|
|
contentDescription = context.getString(R.string.hide)
|
|
|
|
|
imageResource = R.drawable.ic_close
|
|
|
|
|
}.lparams(dip(32), matchParent) {
|
|
|
|
|
startMargin = dip(4)
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-12 18:19:57 +01:00
|
|
|
|
|
2020-01-29 06:15:32 +01:00
|
|
|
|
btnCardImageShow = button {
|
|
|
|
|
|
|
|
|
|
backgroundColor = getAttributeColor(
|
|
|
|
|
context,
|
|
|
|
|
R.attr.colorShowMediaBackground
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
gravity = Gravity.CENTER
|
|
|
|
|
|
|
|
|
|
textColor = getAttributeColor(
|
|
|
|
|
context,
|
|
|
|
|
R.attr.colorShowMediaText
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
}.lparams(matchParent, matchParent)
|
2018-11-12 18:19:57 +01:00
|
|
|
|
}
|
2020-01-29 06:15:32 +01:00
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
}
|
2018-03-21 16:39:10 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
|
|
|
|
llExtra = verticalLayout {
|
|
|
|
|
lparams(matchParent, wrapContent) {
|
|
|
|
|
topMargin = dip(0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// button bar
|
2018-08-21 15:31:44 +02:00
|
|
|
|
statusButtonsViewHolder = StatusButtonsViewHolder(
|
|
|
|
|
activity
|
|
|
|
|
, matchParent
|
|
|
|
|
, 3f
|
2018-08-22 15:54:44 +02:00
|
|
|
|
, justifyContent = when(Pref.ipBoostButtonJustify(App1.pref)) {
|
|
|
|
|
0 -> JustifyContent.FLEX_START
|
|
|
|
|
1 -> JustifyContent.CENTER
|
|
|
|
|
else -> JustifyContent.FLEX_END
|
|
|
|
|
}
|
2018-08-21 15:31:44 +02:00
|
|
|
|
)
|
|
|
|
|
llButtonBar = statusButtonsViewHolder.viewRoot
|
|
|
|
|
addView(llButtonBar)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
|
|
|
|
|
tvApplication = textView {
|
|
|
|
|
gravity = Gravity.END
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
|
|
|
|
}
|
2018-08-22 15:54:44 +02:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-11 11:43:20 +01:00
|
|
|
|
llConversationIcons = linearLayout {
|
|
|
|
|
lparams(matchParent, dip(40))
|
|
|
|
|
|
|
|
|
|
isBaselineAligned = false
|
|
|
|
|
gravity = Gravity.START or Gravity.CENTER_VERTICAL
|
|
|
|
|
|
|
|
|
|
tvConversationParticipants = textView {
|
|
|
|
|
text = context.getString(R.string.participants)
|
2018-11-12 18:19:57 +01:00
|
|
|
|
}.lparams(wrapContent, wrapContent) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
endMargin = dip(3)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ivConversationIcon1 = myNetworkImageView {
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
2018-11-12 18:19:57 +01:00
|
|
|
|
}.lparams(dip(24), dip(24)) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
endMargin = dip(3)
|
|
|
|
|
}
|
|
|
|
|
ivConversationIcon2 = myNetworkImageView {
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
2018-11-12 18:19:57 +01:00
|
|
|
|
}.lparams(dip(24), dip(24)) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
endMargin = dip(3)
|
|
|
|
|
}
|
|
|
|
|
ivConversationIcon3 = myNetworkImageView {
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
2018-11-12 18:19:57 +01:00
|
|
|
|
}.lparams(dip(24), dip(24)) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
endMargin = dip(3)
|
|
|
|
|
}
|
|
|
|
|
ivConversationIcon4 = myNetworkImageView {
|
|
|
|
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
2018-11-12 18:19:57 +01:00
|
|
|
|
}.lparams(dip(24), dip(24)) {
|
2018-11-11 11:43:20 +01:00
|
|
|
|
endMargin = dip(3)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tvConversationIconsMore = textView {
|
|
|
|
|
|
2018-11-12 18:19:57 +01:00
|
|
|
|
}.lparams(wrapContent, wrapContent)
|
2018-11-11 11:43:20 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
llSearchTag = linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
btnSearchTag = button {
|
2018-11-15 23:08:11 +01:00
|
|
|
|
background =
|
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
allCaps = false
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-30 07:18:45 +02:00
|
|
|
|
llTrendTag = linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent)
|
|
|
|
|
|
|
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
background = ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
|
|
|
|
|
|
|
|
|
verticalLayout {
|
|
|
|
|
lparams(0, wrapContent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
tvTrendTagName = textView {
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
2018-11-18 03:38:52 +01:00
|
|
|
|
|
2018-05-30 07:18:45 +02:00
|
|
|
|
tvTrendTagDesc = textView {
|
|
|
|
|
textSize = 12f // SP
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
|
|
|
|
}
|
|
|
|
|
tvTrendTagCount = textView {
|
|
|
|
|
|
|
|
|
|
}.lparams(wrapContent, wrapContent) {
|
|
|
|
|
startMargin = dip(6)
|
|
|
|
|
endMargin = dip(6)
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-13 17:49:19 +02:00
|
|
|
|
cvTagHistory = trendTagHistoryView {
|
2018-05-30 07:18:45 +02:00
|
|
|
|
|
|
|
|
|
}.lparams(dip(64), dip(32))
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
llList = linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent)
|
|
|
|
|
|
2019-01-20 10:27:29 +01:00
|
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
isBaselineAligned = false
|
|
|
|
|
minimumHeight = dip(40)
|
2019-01-20 22:04:57 +01:00
|
|
|
|
|
2018-01-14 22:47:42 +01:00
|
|
|
|
btnListTL = button {
|
2018-11-15 23:08:11 +01:00
|
|
|
|
background =
|
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
2018-01-14 22:47:42 +01:00
|
|
|
|
allCaps = false
|
|
|
|
|
}.lparams(0, wrapContent) {
|
|
|
|
|
weight = 1f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnListMore = imageButton {
|
|
|
|
|
|
2018-11-15 23:08:11 +01:00
|
|
|
|
background =
|
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
2019-01-16 13:33:07 +01:00
|
|
|
|
imageResource = R.drawable.ic_more
|
2018-01-14 22:47:42 +01:00
|
|
|
|
contentDescription = context.getString(R.string.more)
|
2019-01-20 10:27:29 +01:00
|
|
|
|
}.lparams(dip(40), matchParent) {
|
2018-01-14 22:47:42 +01:00
|
|
|
|
startMargin = dip(4)
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-17 18:29:50 +02:00
|
|
|
|
|
2018-05-24 18:33:09 +02:00
|
|
|
|
tvMessageHolder = textView {
|
|
|
|
|
padding = dip(4)
|
2018-05-20 00:31:59 +02:00
|
|
|
|
}.lparams(matchParent, wrapContent)
|
|
|
|
|
|
2018-04-17 18:29:50 +02:00
|
|
|
|
llFollowRequest = linearLayout {
|
|
|
|
|
lparams(matchParent, wrapContent) {
|
|
|
|
|
topMargin = dip(6)
|
|
|
|
|
}
|
|
|
|
|
gravity = Gravity.END
|
|
|
|
|
|
|
|
|
|
btnFollowRequestAccept = imageButton {
|
2018-11-15 23:08:11 +01:00
|
|
|
|
background =
|
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
2018-04-17 18:29:50 +02:00
|
|
|
|
contentDescription = context.getString(R.string.follow_accept)
|
2019-01-16 13:33:07 +01:00
|
|
|
|
imageResource = R.drawable.ic_check
|
2018-05-08 10:55:08 +02:00
|
|
|
|
setPadding(0, 0, 0, 0)
|
|
|
|
|
}.lparams(dip(48f), dip(32f))
|
2018-04-17 18:29:50 +02:00
|
|
|
|
|
|
|
|
|
btnFollowRequestDeny = imageButton {
|
2018-11-15 23:08:11 +01:00
|
|
|
|
background =
|
|
|
|
|
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
|
2018-04-17 18:29:50 +02:00
|
|
|
|
contentDescription = context.getString(R.string.follow_deny)
|
2019-01-16 13:33:07 +01:00
|
|
|
|
imageResource = R.drawable.ic_close
|
2018-05-08 10:55:08 +02:00
|
|
|
|
setPadding(0, 0, 0, 0)
|
|
|
|
|
}.lparams(dip(48f), dip(32f)) {
|
2018-04-17 18:29:50 +02:00
|
|
|
|
startMargin = dip(4)
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-07 07:15:16 +02:00
|
|
|
|
|
|
|
|
|
llFilter = verticalLayout {
|
|
|
|
|
lparams(matchParent, wrapContent) {
|
|
|
|
|
}
|
|
|
|
|
minimumHeight = dip(40)
|
2018-08-04 20:07:55 +02:00
|
|
|
|
|
|
|
|
|
tvFilterPhrase = textView {
|
2018-07-07 07:15:16 +02:00
|
|
|
|
typeface = Typeface.DEFAULT_BOLD
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
2018-08-04 20:07:55 +02:00
|
|
|
|
|
|
|
|
|
tvFilterDetail = textView {
|
2018-07-07 07:15:16 +02:00
|
|
|
|
textSize = 12f // SP
|
|
|
|
|
}.lparams(matchParent, wrapContent)
|
|
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
}
|
2018-11-15 23:08:11 +01:00
|
|
|
|
b.report()
|
|
|
|
|
rv
|
2018-01-14 22:47:42 +01:00
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|