引用のアイコンをic_quoteにする。StatusButtonsPopupでgetLocationInWindowを使う。

This commit is contained in:
tateisu 2023-01-13 03:42:54 +09:00
parent 0700e54554
commit f182d2438c
6 changed files with 36 additions and 31 deletions

View File

@ -18,7 +18,7 @@ class TootNotification(parser: TootParser, src: JsonObject) : TimelineItem() {
// ブーストとリノート
const val TYPE_REBLOG = "reblog" // Mastodon
const val TYPE_RENOTE = "renote" // Misskey
const val TYPE_QUOTE = "quote" // Misskey 引用Renote
const val TYPE_QUOTE = "quote" // Misskeyの引用Renote, fedibirdのquote
// フォロー
const val TYPE_FOLLOW = "follow" // Mastodon,Misskey

View File

@ -206,7 +206,7 @@ fun ItemViewHolder.bind(
item.isQuoteToot -> {
// 引用Renote
val colorBg = PrefI.ipEventBgColorBoost(activity.pref)
showReply(item.account, reblog, R.drawable.ic_repeat, R.string.quote_to)
showReply(item.account, reblog, R.drawable.ic_quote, R.string.quote_to)
showStatus(item, colorBg)
}

View File

@ -319,7 +319,7 @@ private fun ItemViewHolder.showNotificationQuote(
showBoost(
it,
n.time_created_at,
R.drawable.ic_repeat,
R.drawable.ic_quote,
R.string.display_name_quoted_by
)
}
@ -394,7 +394,7 @@ private fun ItemViewHolder.showNotificationStatus(
item.isQuoteToot -> {
// 引用Renote
showReply(item.account, reblog, R.drawable.ic_repeat, R.string.quote_to)
showReply(item.account, reblog, R.drawable.ic_quote, R.string.quote_to)
showStatus(item, PrefI.ipEventBgColorQuote(activity.pref), fadeText = fadeText)
}

View File

@ -71,7 +71,8 @@ fun ItemViewHolder.showStatus(
if (status.conversation_main) {
PrefI.ipConversationMainTootBgColor(activity.pref).notZero()
?: (activity.attrColor(R.attr.colorImageButtonAccent) and 0xffffff) or 0x20000000
?: activity.attrColor(R.attr.colorImageButtonAccent)
.and(0xffffff).or(0x20000000)
} else {
colorBg.notZero() ?: when (status.bookmarked) {
true -> PrefI.ipEventBgColorBookmark()

View File

@ -16,6 +16,7 @@ import jp.juggler.subwaytooter.api.entity.TootNotification
import jp.juggler.subwaytooter.api.entity.TootStatus
import jp.juggler.subwaytooter.column.Column
import jp.juggler.util.LogCategory
import jp.juggler.util.clip
import org.jetbrains.anko.matchParent
internal class StatusButtonsPopup(
@ -30,12 +31,6 @@ internal class StatusButtonsPopup(
@Suppress("unused")
private var log = LogCategory("StatusButtonsPopup")
private fun getViewWidth(v: View): Int {
val spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
v.measure(spec, spec)
return v.measuredWidth
}
var lastPopupClose = 0L
}
@ -97,27 +92,36 @@ internal class StatusButtonsPopup(
buttonsForStatus.bind(status, notification)
buttonsForStatus.closeWindow = window
val density = activity.density
fun dip(src: Float) = (src * density + 0.5f).toInt()
val location = IntArray(2)
anchor.getLocationOnScreen(location)
val anchorLeft = location[0]
val anchorTop = location[1]
listView.getLocationOnScreen(location)
listView.getLocationInWindow(location)
val listviewLeft = location[0]
val listviewTop = location[1]
val density = activity.density
anchor.getLocationInWindow(location)
val anchorLeft = location[0]
val anchorTop = location[1]
val anchorWidth = anchor.width
val clipTop = listviewTop + (0.5f + 8f * density).toInt()
val clipBottom = listviewTop + listView.height - (0.5f + 8f * density).toInt()
// popupsize
viewRoot.measure(
View.MeasureSpec.makeMeasureSpec(listView.width, View.MeasureSpec.AT_MOST),
View.MeasureSpec.makeMeasureSpec(listView.height, View.MeasureSpec.AT_MOST)
)
val popupWidth = viewRoot.measuredWidth
val popupHeight = viewRoot.measuredHeight
val popupHeight = (0.5f + (56f + 24f) * density).toInt()
val clipTop = listviewTop+ dip(8f)
val clipBottom = listviewTop+ listView.height - dip(8f)
// ポップアップウィンドウの上端。listViewベース
var popupY = anchorTop + anchor.height / 2
if (popupY < clipTop) {
// 画面外のは画面内にする
popupY = clipTop
} else if (clipBottom - popupY < popupHeight) {
} else if (popupY + popupHeight > clipBottom) {
// 画面外のは画面内にする
if (popupY > clipBottom) popupY = clipBottom
@ -127,13 +131,13 @@ internal class StatusButtonsPopup(
popupY -= popupHeight
}
val anchorWidth = anchor.width
val popupWidth = getViewWidth(viewRoot)
var popupX = anchorLeft + anchorWidth / 2 - popupWidth / 2
if (popupX < 0) popupX = 0
val popupXMax = activity.resources.displayMetrics.widthPixels - popupWidth
if (popupX > popupXMax) popupX = popupXMax
val popupX = (anchorLeft + anchorWidth / 2 - popupWidth / 2).clip(
0,
activity.resources.displayMetrics.widthPixels - popupWidth
)
window.showAtLocation(listView, Gravity.LEFT or Gravity.TOP, popupX, popupY)
log.i("show listView=${listviewTop},${listviewLeft},${listView.width}, anchor=${anchorTop},${anchorLeft},popup=${popupY},${popupX}")
window.showAtLocation(listView, Gravity.LEFT or Gravity.TOP, popupX, popupY )
}
}

View File

@ -182,7 +182,7 @@ internal class PopupAutoCompleteAcct(
fun updatePosition() {
val location = IntArray(2)
etContent.getLocationOnScreen(location)
etContent.getLocationInWindow(location)
val textTop = location[1]
var popupTop: Int
@ -197,7 +197,7 @@ internal class PopupAutoCompleteAcct(
if (popupHeight > max) popupHeight = max
popupTop = popupBottom - popupHeight
} else {
formRoot.getLocationOnScreen(location)
formRoot.getLocationInWindow(location)
val formTop = location[1]
val formBottom = location[1] + formRoot.height