トゥート時刻表示と内蔵メディアビューアの軽いリファクタ
This commit is contained in:
parent
b54920cb7f
commit
2b824c3431
1
.idea/dictionaries/tateisu.xml
generated
1
.idea/dictionaries/tateisu.xml
generated
@ -61,6 +61,7 @@
|
|||||||
<w>thru</w>
|
<w>thru</w>
|
||||||
<w>timelines</w>
|
<w>timelines</w>
|
||||||
<w>tootsearch</w>
|
<w>tootsearch</w>
|
||||||
|
<w>unarist</w>
|
||||||
<w>unfavourite</w>
|
<w>unfavourite</w>
|
||||||
<w>unfollow</w>
|
<w>unfollow</w>
|
||||||
<w>unmute</w>
|
<w>unmute</w>
|
||||||
|
@ -457,7 +457,7 @@ internal class ItemViewHolder(
|
|||||||
boost_time = time
|
boost_time = time
|
||||||
llBoosted.visibility = View.VISIBLE
|
llBoosted.visibility = View.VISIBLE
|
||||||
ivBoosted.setImageResource(Styler.getAttributeResourceId(activity, icon_attr_id))
|
ivBoosted.setImageResource(Styler.getAttributeResourceId(activity, icon_attr_id))
|
||||||
tvBoostedTime.text = TootStatus.formatTime(tvBoostedTime.context, time, true)
|
showStatusTime(activity, tvBoostedTime, who, time = time)
|
||||||
tvBoosted.text = text
|
tvBoosted.text = text
|
||||||
boost_invalidator.register(text)
|
boost_invalidator.register(text)
|
||||||
setAcct(tvBoostedAcct, access_info.getFullAcct(who), who.acct)
|
setAcct(tvBoostedAcct, access_info.getFullAcct(who), who.acct)
|
||||||
@ -484,7 +484,7 @@ internal class ItemViewHolder(
|
|||||||
this.status_showing = status
|
this.status_showing = status
|
||||||
llStatus.visibility = View.VISIBLE
|
llStatus.visibility = View.VISIBLE
|
||||||
|
|
||||||
showStatusTime(activity, status)
|
showStatusTime(activity, tvTime, who = status.account, status = status)
|
||||||
|
|
||||||
val who = status.account
|
val who = status.account
|
||||||
this.status_account = who
|
this.status_account = who
|
||||||
@ -623,62 +623,95 @@ internal class ItemViewHolder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showStatusTime(activity : ActMain, status : TootStatus) {
|
private fun showStatusTime(
|
||||||
|
activity : ActMain,
|
||||||
|
tv : TextView,
|
||||||
|
@Suppress("UNUSED_PARAMETER") who : TootAccount,
|
||||||
|
status : TootStatus? = null,
|
||||||
|
time : Long? = null
|
||||||
|
) {
|
||||||
val sb = SpannableStringBuilder()
|
val sb = SpannableStringBuilder()
|
||||||
|
|
||||||
if(status.hasMedia() && status.sensitive) {
|
// if(access_info.getFullAcct(who) == "unarist@mstdn.maud.io") {
|
||||||
// if( sb.length() > 0 ) sb.append( ' ' );
|
// // 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
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(status != null) {
|
||||||
|
if(status.hasMedia() && status.sensitive) {
|
||||||
|
if(sb.isNotEmpty()) sb.append(' ')
|
||||||
|
|
||||||
|
val start = sb.length
|
||||||
|
sb.append("NSFW")
|
||||||
|
val end = sb.length
|
||||||
|
val icon_id = Styler.getAttributeResourceId(activity, R.attr.ic_eye_off)
|
||||||
|
sb.setSpan(
|
||||||
|
EmojiImageSpan(activity, icon_id),
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val visIconAttrId = Styler.getVisibilityIconAttr(status.visibility)
|
||||||
|
if(R.attr.ic_public != visIconAttrId) {
|
||||||
|
if(sb.isNotEmpty()) sb.append(' ')
|
||||||
|
val start = sb.length
|
||||||
|
sb.append(status.visibility)
|
||||||
|
val end = sb.length
|
||||||
|
val iconResId = Styler.getAttributeResourceId(activity, visIconAttrId)
|
||||||
|
sb.setSpan(
|
||||||
|
EmojiImageSpan(activity, iconResId),
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(status.pinned) {
|
||||||
|
if(sb.isNotEmpty()) sb.append(' ')
|
||||||
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val start = sb.length
|
|
||||||
sb.append("NSFW")
|
|
||||||
val end = sb.length
|
|
||||||
val icon_id = Styler.getAttributeResourceId(activity, R.attr.ic_eye_off)
|
|
||||||
sb.setSpan(
|
|
||||||
EmojiImageSpan(activity, icon_id),
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val visIconAttrId = Styler.getVisibilityIconAttr(status.visibility)
|
|
||||||
if(R.attr.ic_public != visIconAttrId) {
|
|
||||||
if(sb.isNotEmpty()) sb.append(' ')
|
|
||||||
val start = sb.length
|
|
||||||
sb.append(status.visibility)
|
|
||||||
val end = sb.length
|
|
||||||
val iconResId = Styler.getAttributeResourceId(activity, visIconAttrId)
|
|
||||||
sb.setSpan(
|
|
||||||
EmojiImageSpan(activity, iconResId),
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if(status.pinned) {
|
|
||||||
if(sb.isNotEmpty()) sb.append(' ')
|
|
||||||
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
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sb.isNotEmpty()) sb.append(' ')
|
if(sb.isNotEmpty()) sb.append(' ')
|
||||||
sb.append(
|
sb.append(
|
||||||
TootStatus.formatTime(
|
when {
|
||||||
activity,
|
time != null -> TootStatus.formatTime(
|
||||||
status.time_created_at,
|
activity,
|
||||||
column.column_type != Column.TYPE_CONVERSATION
|
time,
|
||||||
)
|
column.column_type != Column.TYPE_CONVERSATION
|
||||||
|
)
|
||||||
|
status != null -> TootStatus.formatTime(
|
||||||
|
activity,
|
||||||
|
status.time_created_at,
|
||||||
|
column.column_type != Column.TYPE_CONVERSATION
|
||||||
|
)
|
||||||
|
else -> "?"
|
||||||
|
}
|
||||||
)
|
)
|
||||||
tvTime.text = sb
|
|
||||||
|
tv.text = sb
|
||||||
}
|
}
|
||||||
|
|
||||||
// fun updateRelativeTime() {
|
// fun updateRelativeTime() {
|
||||||
@ -1456,11 +1489,13 @@ internal class ItemViewHolder(
|
|||||||
|
|
||||||
val actMain = activity as? ActMain
|
val actMain = activity as? ActMain
|
||||||
val thumbnailHeight = actMain?.app_state?.media_thumb_height ?: dip(64)
|
val thumbnailHeight = actMain?.app_state?.media_thumb_height ?: dip(64)
|
||||||
val verticalArrangeThumbnails = Pref.bpVerticalArrangeThumbnails( actMain?.pref ?: Pref.pref(context))
|
val verticalArrangeThumbnails = Pref.bpVerticalArrangeThumbnails(
|
||||||
|
actMain?.pref ?: Pref.pref(context)
|
||||||
|
)
|
||||||
|
|
||||||
flMedia = if(verticalArrangeThumbnails ) {
|
flMedia = if(verticalArrangeThumbnails) {
|
||||||
frameLayout {
|
frameLayout {
|
||||||
lparams(matchParent, wrapContent ) {
|
lparams(matchParent, wrapContent) {
|
||||||
topMargin = dip(3)
|
topMargin = dip(3)
|
||||||
}
|
}
|
||||||
llMedia = verticalLayout {
|
llMedia = verticalLayout {
|
||||||
@ -1478,7 +1513,7 @@ internal class ItemViewHolder(
|
|||||||
context,
|
context,
|
||||||
R.attr.btn_close
|
R.attr.btn_close
|
||||||
)
|
)
|
||||||
}.lparams(dip(32),dip(32)) {
|
}.lparams(dip(32), dip(32)) {
|
||||||
gravity = Gravity.END
|
gravity = Gravity.END
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1548,8 +1583,11 @@ internal class ItemViewHolder(
|
|||||||
gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
||||||
text = context.getString(R.string.tap_to_show)
|
text = context.getString(R.string.tap_to_show)
|
||||||
textColor =
|
textColor =
|
||||||
Styler.getAttributeColor(context, R.attr.colorShowMediaText)
|
Styler.getAttributeColor(
|
||||||
endPadding=dip(4)
|
context,
|
||||||
|
R.attr.colorShowMediaText
|
||||||
|
)
|
||||||
|
endPadding = dip(4)
|
||||||
minHeightCompat = dip(32)
|
minHeightCompat = dip(32)
|
||||||
}.lparams(matchParent, matchParent)
|
}.lparams(matchParent, matchParent)
|
||||||
}
|
}
|
||||||
@ -1646,13 +1684,16 @@ internal class ItemViewHolder(
|
|||||||
gravity = Gravity.CENTER
|
gravity = Gravity.CENTER
|
||||||
text = context.getString(R.string.tap_to_show)
|
text = context.getString(R.string.tap_to_show)
|
||||||
textColor =
|
textColor =
|
||||||
Styler.getAttributeColor(context, R.attr.colorShowMediaText)
|
Styler.getAttributeColor(
|
||||||
|
context,
|
||||||
|
R.attr.colorShowMediaText
|
||||||
|
)
|
||||||
|
|
||||||
}.lparams(matchParent, matchParent)
|
}.lparams(matchParent, matchParent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
llExtra = verticalLayout {
|
llExtra = verticalLayout {
|
||||||
|
@ -172,10 +172,14 @@ class PinchBitmapView(context : Context, attrs : AttributeSet?, defStyle : Int)
|
|||||||
|
|
||||||
override fun performClick() : Boolean {
|
override fun performClick() : Boolean {
|
||||||
super.performClick()
|
super.performClick()
|
||||||
|
|
||||||
initializeScale()
|
initializeScale()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var defaultScale :Float = 1f
|
||||||
|
|
||||||
// 表示位置の初期化
|
// 表示位置の初期化
|
||||||
// 呼ばれるのは、ビットマップを変更した時、ビューのサイズが変わった時、画像をクリックした時
|
// 呼ばれるのは、ビットマップを変更した時、ビューのサイズが変わった時、画像をクリックした時
|
||||||
private fun initializeScale() {
|
private fun initializeScale() {
|
||||||
@ -186,23 +190,37 @@ class PinchBitmapView(context : Context, attrs : AttributeSet?, defStyle : Int)
|
|||||||
bitmap_h = Math.max(1f, bitmap.height.toFloat())
|
bitmap_h = Math.max(1f, bitmap.height.toFloat())
|
||||||
bitmap_aspect = bitmap_w / bitmap_h
|
bitmap_aspect = bitmap_w / bitmap_h
|
||||||
|
|
||||||
current_scale = if(view_aspect > bitmap_aspect) {
|
if(view_aspect > bitmap_aspect) {
|
||||||
|
scale_min = view_h / bitmap_h / 2f
|
||||||
|
scale_max = view_w / bitmap_w * 8f
|
||||||
|
} else {
|
||||||
|
scale_min = view_w / bitmap_w / 2f
|
||||||
|
scale_max = view_h / bitmap_h * 8f
|
||||||
|
}
|
||||||
|
if(scale_max < scale_min) scale_max = scale_min * 16f
|
||||||
|
|
||||||
|
defaultScale = if(view_aspect > bitmap_aspect) {
|
||||||
view_h / bitmap_h
|
view_h / bitmap_h
|
||||||
} else {
|
} else {
|
||||||
view_w / bitmap_w
|
view_w / bitmap_w
|
||||||
}
|
}
|
||||||
|
|
||||||
val draw_w = bitmap_w * current_scale
|
val draw_w = bitmap_w * defaultScale
|
||||||
val draw_h = bitmap_h * current_scale
|
val draw_h = bitmap_h * defaultScale
|
||||||
|
|
||||||
|
current_scale = defaultScale
|
||||||
current_trans_x = (view_w - draw_w) / 2f
|
current_trans_x = (view_w - draw_w) / 2f
|
||||||
current_trans_y = (view_h - draw_h) / 2f
|
current_trans_y = (view_h - draw_h) / 2f
|
||||||
|
|
||||||
callback?.onMove(bitmap_w, bitmap_h, current_trans_x, current_trans_y, current_scale)
|
callback?.onMove(bitmap_w, bitmap_h, current_trans_x, current_trans_y, current_scale)
|
||||||
} else {
|
} else {
|
||||||
|
defaultScale = 1f
|
||||||
|
scale_min = 1f
|
||||||
|
scale_max = 1f
|
||||||
|
|
||||||
|
current_scale = defaultScale
|
||||||
current_trans_y = 0f
|
current_trans_y = 0f
|
||||||
current_trans_x = current_trans_y
|
current_trans_x = 0f
|
||||||
current_scale = 1f
|
|
||||||
|
|
||||||
callback?.onMove(0f, 0f, current_trans_x, current_trans_y, current_scale)
|
callback?.onMove(0f, 0f, current_trans_x, current_trans_y, current_scale)
|
||||||
}
|
}
|
||||||
@ -388,14 +406,7 @@ class PinchBitmapView(context : Context, attrs : AttributeSet?, defStyle : Int)
|
|||||||
start_image_trans_y = current_trans_y
|
start_image_trans_y = current_trans_y
|
||||||
start_image_scale = current_scale
|
start_image_scale = current_scale
|
||||||
|
|
||||||
if(view_aspect > bitmap_aspect) {
|
|
||||||
scale_min = view_h / bitmap_h / 2f
|
|
||||||
scale_max = view_w / bitmap_w * 8f
|
|
||||||
} else {
|
|
||||||
scale_min = view_w / bitmap_w / 2f
|
|
||||||
scale_max = view_h / bitmap_h * 8f
|
|
||||||
}
|
|
||||||
if(scale_max < scale_min) scale_max = scale_min * 16f
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 画面上の指の位置から画像中の指の位置を調べる
|
// 画面上の指の位置から画像中の指の位置を調べる
|
||||||
|
Loading…
x
Reference in New Issue
Block a user