引用のアイコンをic_quoteにする。StatusButtonsPopupでgetLocationInWindowを使う。
This commit is contained in:
parent
0700e54554
commit
f182d2438c
|
@ -18,7 +18,7 @@ class TootNotification(parser: TootParser, src: JsonObject) : TimelineItem() {
|
||||||
// ブーストとリノート
|
// ブーストとリノート
|
||||||
const val TYPE_REBLOG = "reblog" // Mastodon
|
const val TYPE_REBLOG = "reblog" // Mastodon
|
||||||
const val TYPE_RENOTE = "renote" // Misskey
|
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
|
const val TYPE_FOLLOW = "follow" // Mastodon,Misskey
|
||||||
|
|
|
@ -206,7 +206,7 @@ fun ItemViewHolder.bind(
|
||||||
item.isQuoteToot -> {
|
item.isQuoteToot -> {
|
||||||
// 引用Renote
|
// 引用Renote
|
||||||
val colorBg = PrefI.ipEventBgColorBoost(activity.pref)
|
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)
|
showStatus(item, colorBg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -319,7 +319,7 @@ private fun ItemViewHolder.showNotificationQuote(
|
||||||
showBoost(
|
showBoost(
|
||||||
it,
|
it,
|
||||||
n.time_created_at,
|
n.time_created_at,
|
||||||
R.drawable.ic_repeat,
|
R.drawable.ic_quote,
|
||||||
R.string.display_name_quoted_by
|
R.string.display_name_quoted_by
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ private fun ItemViewHolder.showNotificationStatus(
|
||||||
|
|
||||||
item.isQuoteToot -> {
|
item.isQuoteToot -> {
|
||||||
// 引用Renote
|
// 引用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)
|
showStatus(item, PrefI.ipEventBgColorQuote(activity.pref), fadeText = fadeText)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,8 @@ fun ItemViewHolder.showStatus(
|
||||||
|
|
||||||
if (status.conversation_main) {
|
if (status.conversation_main) {
|
||||||
PrefI.ipConversationMainTootBgColor(activity.pref).notZero()
|
PrefI.ipConversationMainTootBgColor(activity.pref).notZero()
|
||||||
?: (activity.attrColor(R.attr.colorImageButtonAccent) and 0xffffff) or 0x20000000
|
?: activity.attrColor(R.attr.colorImageButtonAccent)
|
||||||
|
.and(0xffffff).or(0x20000000)
|
||||||
} else {
|
} else {
|
||||||
colorBg.notZero() ?: when (status.bookmarked) {
|
colorBg.notZero() ?: when (status.bookmarked) {
|
||||||
true -> PrefI.ipEventBgColorBookmark()
|
true -> PrefI.ipEventBgColorBookmark()
|
||||||
|
|
|
@ -16,6 +16,7 @@ import jp.juggler.subwaytooter.api.entity.TootNotification
|
||||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||||
import jp.juggler.subwaytooter.column.Column
|
import jp.juggler.subwaytooter.column.Column
|
||||||
import jp.juggler.util.LogCategory
|
import jp.juggler.util.LogCategory
|
||||||
|
import jp.juggler.util.clip
|
||||||
import org.jetbrains.anko.matchParent
|
import org.jetbrains.anko.matchParent
|
||||||
|
|
||||||
internal class StatusButtonsPopup(
|
internal class StatusButtonsPopup(
|
||||||
|
@ -30,12 +31,6 @@ internal class StatusButtonsPopup(
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
private var log = LogCategory("StatusButtonsPopup")
|
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
|
var lastPopupClose = 0L
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,27 +92,36 @@ internal class StatusButtonsPopup(
|
||||||
buttonsForStatus.bind(status, notification)
|
buttonsForStatus.bind(status, notification)
|
||||||
buttonsForStatus.closeWindow = window
|
buttonsForStatus.closeWindow = window
|
||||||
|
|
||||||
|
val density = activity.density
|
||||||
|
fun dip(src: Float) = (src * density + 0.5f).toInt()
|
||||||
|
|
||||||
val location = IntArray(2)
|
val location = IntArray(2)
|
||||||
|
|
||||||
anchor.getLocationOnScreen(location)
|
listView.getLocationInWindow(location)
|
||||||
val anchorLeft = location[0]
|
val listviewLeft = location[0]
|
||||||
val anchorTop = location[1]
|
|
||||||
|
|
||||||
listView.getLocationOnScreen(location)
|
|
||||||
val listviewTop = location[1]
|
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()
|
// popupsize
|
||||||
val clipBottom = listviewTop + listView.height - (0.5f + 8f * density).toInt()
|
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
|
var popupY = anchorTop + anchor.height / 2
|
||||||
|
|
||||||
if (popupY < clipTop) {
|
if (popupY < clipTop) {
|
||||||
// 画面外のは画面内にする
|
// 画面外のは画面内にする
|
||||||
popupY = clipTop
|
popupY = clipTop
|
||||||
} else if (clipBottom - popupY < popupHeight) {
|
} else if (popupY + popupHeight > clipBottom) {
|
||||||
// 画面外のは画面内にする
|
// 画面外のは画面内にする
|
||||||
if (popupY > clipBottom) popupY = clipBottom
|
if (popupY > clipBottom) popupY = clipBottom
|
||||||
|
|
||||||
|
@ -127,13 +131,13 @@ internal class StatusButtonsPopup(
|
||||||
popupY -= popupHeight
|
popupY -= popupHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
val anchorWidth = anchor.width
|
val popupX = (anchorLeft + anchorWidth / 2 - popupWidth / 2).clip(
|
||||||
val popupWidth = getViewWidth(viewRoot)
|
0,
|
||||||
var popupX = anchorLeft + anchorWidth / 2 - popupWidth / 2
|
activity.resources.displayMetrics.widthPixels - popupWidth
|
||||||
if (popupX < 0) popupX = 0
|
)
|
||||||
val popupXMax = activity.resources.displayMetrics.widthPixels - popupWidth
|
|
||||||
if (popupX > popupXMax) popupX = popupXMax
|
|
||||||
|
|
||||||
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 )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ internal class PopupAutoCompleteAcct(
|
||||||
fun updatePosition() {
|
fun updatePosition() {
|
||||||
|
|
||||||
val location = IntArray(2)
|
val location = IntArray(2)
|
||||||
etContent.getLocationOnScreen(location)
|
etContent.getLocationInWindow(location)
|
||||||
val textTop = location[1]
|
val textTop = location[1]
|
||||||
|
|
||||||
var popupTop: Int
|
var popupTop: Int
|
||||||
|
@ -197,7 +197,7 @@ internal class PopupAutoCompleteAcct(
|
||||||
if (popupHeight > max) popupHeight = max
|
if (popupHeight > max) popupHeight = max
|
||||||
popupTop = popupBottom - popupHeight
|
popupTop = popupBottom - popupHeight
|
||||||
} else {
|
} else {
|
||||||
formRoot.getLocationOnScreen(location)
|
formRoot.getLocationInWindow(location)
|
||||||
val formTop = location[1]
|
val formTop = location[1]
|
||||||
val formBottom = location[1] + formRoot.height
|
val formBottom = location[1] + formRoot.height
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue