返信アイコンの図柄変更。カスタムシェアのクリップボードコピーの色調整。ブーストやお気に入りした人のアイコンを表示。

This commit is contained in:
tateisu 2023-01-07 22:37:33 +09:00
parent 47aac575fb
commit 06bd49b659
6 changed files with 82 additions and 23 deletions

View File

@ -34,6 +34,7 @@ import jp.juggler.util.LogCategory
import jp.juggler.util.applyAlphaMultiplier
import jp.juggler.util.attrColor
import org.jetbrains.anko.*
import kotlin.math.min
class ItemViewHolder(
val activity: ActMain,
@ -58,12 +59,14 @@ class ItemViewHolder(
internal lateinit var listAdapter: ItemListAdapter
lateinit var llBoosted: View
lateinit var ivBoostAvatar: MyNetworkImageView
lateinit var ivBoosted: ImageView
lateinit var tvBoosted: MyTextView
lateinit var tvBoostedAcct: MyTextView
lateinit var tvBoostedTime: MyTextView
lateinit var llReply: View
lateinit var ivReplyAvatar: MyNetworkImageView
lateinit var ivReply: ImageView
lateinit var tvReply: MyTextView
@ -306,10 +309,17 @@ class ItemViewHolder(
s = ActMain.replyIconSize + (activity.density * 8).toInt()
ivReply.layoutParams.width = s
ivReply.layoutParams.height = s
ivReplyAvatar.layoutParams.width = s
ivReplyAvatar.layoutParams.height = s
s = activity.notificationTlIconSize
ivBoosted.layoutParams.height = s
min(activity.notificationTlIconSize, activity.avatarIconSize).let {
ivBoostAvatar.layoutParams.width = it
ivBoostAvatar.layoutParams.height = it
}
this.contentInvalidator = NetworkEmojiInvalidator(activity.handler, tvContent)
this.spoilerInvalidator = NetworkEmojiInvalidator(activity.handler, tvContentWarning)
this.boostInvalidator = NetworkEmojiInvalidator(activity.handler, tvBoosted)
@ -395,9 +405,24 @@ class ItemViewHolder(
}.lparams(wrapContent, wrapContent)
}
tvBoosted = myTextView {
// tools:text = "~にブーストされました"
}.lparams(matchParent, wrapContent)
linearLayout {
lparams(matchParent, wrapContent)
ivBoostAvatar = myNetworkImageView {
scaleType = ImageView.ScaleType.FIT_END
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
padding = dip(4)
}.lparams(dip(32), dip(32)) {
gravity = Gravity.CENTER_VERTICAL
}
tvBoosted = myTextView {
// tools:text = "~にブーストされました"
}.lparams(matchParent, wrapContent){
endMargin = dip(2)
gravity = Gravity.CENTER_VERTICAL
}
}
}
}
}
@ -599,6 +624,14 @@ class ItemViewHolder(
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent_round6dp)
gravity = Gravity.CENTER_VERTICAL
ivReplyAvatar = myNetworkImageView {
scaleType = ImageView.ScaleType.FIT_END
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
padding = dip(4)
}.lparams(dip(32), dip(32)) {
endMargin = dip(1)
}
ivReply = imageView {
scaleType = ImageView.ScaleType.FIT_END
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
@ -668,11 +701,12 @@ class ItemViewHolder(
repeat(MEDIA_VIEW_COUNT) {
tvMediaDescriptions.add(
button {
gravity=Gravity.START
allCaps= false
gravity = Gravity.START
allCaps = false
background =
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent_round6dp)
padding=dip(4)
ContextCompat.getDrawable(context,
R.drawable.btn_bg_transparent_round6dp)
padding = dip(4)
}.lparams(matchParent, wrapContent)
)
}

View File

@ -206,7 +206,7 @@ fun ItemViewHolder.bind(
item.isQuoteToot -> {
// 引用Renote
val colorBg = PrefI.ipEventBgColorBoost(activity.pref)
showReply(reblog, R.drawable.ic_repeat, R.string.quote_to)
showReply(item.account, reblog, R.drawable.ic_repeat, R.string.quote_to)
showStatus(item, colorBg)
}
@ -321,6 +321,8 @@ fun ItemViewHolder.showBoost(
) {
boostAccount = whoRef
val who = whoRef.get()
setIconDrawableId(
activity,
ivBoosted,
@ -329,7 +331,13 @@ fun ItemViewHolder.showBoost(
alphaMultiplier = Styler.boostAlpha
)
val who = whoRef.get()
ivBoostAvatar.let { v ->
v.setImageUrl(
Styler.calcIconRound(v.layoutParams),
accessInfo.supplyBaseUrl(who.avatar_static),
accessInfo.supplyBaseUrl(who.avatar)
)
}
// フォローの場合 decoded_display_name が2箇所で表示に使われるのを避ける必要がある
val text: Spannable = if (reaction != null) {
@ -465,8 +473,14 @@ fun ItemViewHolder.showSearchGap(item: TootSearchGap) {
)
}
fun ItemViewHolder.showReply(iconId: Int, text: Spannable) {
fun ItemViewHolder.showReply(
// 返信した人
replyer: TootAccount?,
// 返信された人
target: TootAccount?,
iconId: Int,
text: Spannable,
) {
llReply.visibility = View.VISIBLE
setIconDrawableId(
@ -477,19 +491,29 @@ fun ItemViewHolder.showReply(iconId: Int, text: Spannable) {
alphaMultiplier = Styler.boostAlpha
)
ivReplyAvatar.vg(target != null && target.avatar != replyer?.avatar)?.let { v ->
v.setImageUrl(
Styler.calcIconRound(v.layoutParams),
accessInfo.supplyBaseUrl(target!!.avatar_static),
accessInfo.supplyBaseUrl(target.avatar)
)
}
tvReply.text = text
replyInvalidator.register(text)
}
fun ItemViewHolder.showReply(reply: TootStatus, iconId: Int, stringId: Int) {
fun ItemViewHolder.showReply(replyer: TootAccount?, reply: TootStatus, iconId: Int, stringId: Int) {
statusReply = reply
showReply(
replyer = replyer,
target = reply.accountRef.get(),
iconId,
reply.accountRef.decoded_display_name.intoStringResource(activity, stringId)
)
}
fun ItemViewHolder.showReply(reply: TootStatus, accountId: EntityId) {
fun ItemViewHolder.showReply(replyer: TootAccount?, reply: TootStatus, accountId: EntityId) {
val name = if (accountId == reply.account.id) {
// 自己レスなら
AcctColor.getNicknameWithColor(accessInfo, reply.account)
@ -503,7 +527,7 @@ fun ItemViewHolder.showReply(reply: TootStatus, accountId: EntityId) {
}
val text = name.intoStringResource(activity, R.string.reply_to)
showReply(R.drawable.ic_reply, text)
showReply(replyer = replyer, target = null, R.drawable.ic_reply, text)
// tootsearchはreplyオブジェクトがなくin_reply_toだけが提供される場合があるが
// tootsearchではどのタンスから読んだか分からないのでin_reply_toのIDも信用できない

View File

@ -127,6 +127,7 @@ private fun ItemViewHolder.showNotificationSignup(
showAccount(it)
}
}
private fun ItemViewHolder.showNotificationFollowRequest(
n: TootNotification,
nAccountRef: TootAccountRef?,
@ -393,7 +394,7 @@ private fun ItemViewHolder.showNotificationStatus(
item.isQuoteToot -> {
// 引用Renote
showReply(reblog, R.drawable.ic_repeat, R.string.quote_to)
showReply(item.account, reblog, R.drawable.ic_repeat, R.string.quote_to)
showStatus(item, PrefI.ipEventBgColorQuote(activity.pref), fadeText = fadeText)
}

View File

@ -34,12 +34,12 @@ fun ItemViewHolder.showStatusOrReply(
val inReplyToAccountId = item.in_reply_to_account_id
when {
reply != null -> {
showReply(reply, R.drawable.ic_reply, R.string.reply_to)
showReply(item.account, reply, R.drawable.ic_reply, R.string.reply_to)
if (colorBgArg == 0) colorBg = PrefI.ipEventBgColorMention(activity.pref)
}
inReplyToId != null && inReplyToAccountId != null -> {
showReply(item, inReplyToAccountId)
showReply(null, item, inReplyToAccountId)
if (colorBgArg == 0) colorBg = PrefI.ipEventBgColorMention(activity.pref)
}
}

View File

@ -66,7 +66,7 @@ object CustomShare {
label =
"${context.getString(R.string.copy_to_clipboard)}(${context.getString(R.string.app_name)})"
icon = ContextCompat.getDrawable(context, R.drawable.ic_copy)?.mutate()?.apply {
setTint(context.attrColor(R.attr.colorVectorDrawable))
setTint(context.attrColor(R.attr.colorContentText))
setTintMode(PorterDuff.Mode.SRC_IN)
}
} else {

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#FF000000"
android:pathData="M10,9V5l-7,7 7,7v-4.1c5,0 8.5,1.6 11,5.1 -1,-5 -4,-10 -11,-11z"/>
android:pathData="M8,9.8V10.7L9.7,11C12.3,11.4 14.2,12.4 15.6,13.7C13.9,13.2 12.1,12.9 10,12.9H8V14.2L5.8,12L8,9.8M10,5L3,12L10,19V14.9C15,14.9 18.5,16.5 21,20C20,15 17,10 10,9" />
</vector>