イベント背景色は投稿全部の背景を変更する。公開範囲の背景色より優先度が高い。

This commit is contained in:
tateisu 2019-02-04 13:19:57 +09:00
parent 1932209e2d
commit 33f94c163e
4 changed files with 57 additions and 59 deletions

View File

@ -460,24 +460,25 @@ internal class ItemViewHolder(
item.hasAnyContent() -> { item.hasAnyContent() -> {
// 引用Renote // 引用Renote
val colorBg = Pref.ipEventBgColorBoost(activity.pref)
showReply( showReply(
R.drawable.ic_repeat, R.drawable.ic_repeat,
R.string.renote_to, R.string.renote_to,
reblog reblog
) )
showStatus(item) showStatus(item, colorBg)
} }
else -> { else -> {
// 引用なしブースト // 引用なしブースト
val colorBg = Pref.ipEventBgColorBoost(activity.pref)
showBoost( showBoost(
item.accountRef, item.accountRef,
item.time_created_at, item.time_created_at,
R.drawable.ic_repeat, R.drawable.ic_repeat,
R.string.display_name_boosted_by, R.string.display_name_boosted_by
colorBg = Pref.ipEventBgColorBoost(activity.pref)
) )
showStatusOrReply(item.reblog) showStatusOrReply(item.reblog, colorBg)
} }
} }
} }
@ -700,7 +701,7 @@ internal class ItemViewHolder(
) )
} }
private fun showStatusOrReply(item : TootStatus) { private fun showStatusOrReply(item : TootStatus, colorBg : Int = 0) {
val reply = item.reply val reply = item.reply
val in_reply_to_id = item.in_reply_to_id val in_reply_to_id = item.in_reply_to_id
val in_reply_to_account_id = item.in_reply_to_account_id val in_reply_to_account_id = item.in_reply_to_account_id
@ -720,7 +721,7 @@ internal class ItemViewHolder(
) )
} }
} }
showStatus(item) showStatus(item, colorBg)
} }
private fun showTrendTag(item : TootTrendTag) { private fun showTrendTag(item : TootTrendTag) {
@ -743,15 +744,15 @@ internal class ItemViewHolder(
val n_accountRef = n.accountRef val n_accountRef = n.accountRef
val n_account = n_accountRef?.get() val n_account = n_accountRef?.get()
fun showNotificationStatus(item : TootStatus) { fun showNotificationStatus(item : TootStatus, colorBgDefault : Int) {
val reblog = item.reblog val reblog = item.reblog
when { when {
reblog == null -> showStatusOrReply(item) reblog == null -> showStatusOrReply(item, colorBgDefault)
! item.hasAnyContent() -> { ! item.hasAnyContent() -> {
// 通常のブースト。引用なしブースト。 // 通常のブースト。引用なしブースト。
// ブースト表示は通知イベントと被るのでしない // ブースト表示は通知イベントと被るのでしない
showStatusOrReply(reblog) showStatusOrReply(reblog, Pref.ipEventBgColorBoost(activity.pref))
} }
else -> { else -> {
@ -761,7 +762,7 @@ internal class ItemViewHolder(
R.string.renote_to, R.string.renote_to,
reblog reblog
) )
showStatus(item) showStatus(item, Pref.ipEventBgColorQuote(activity.pref))
} }
} }
} }
@ -769,74 +770,77 @@ internal class ItemViewHolder(
when(n.type) { when(n.type) {
TootNotification.TYPE_FAVOURITE -> { TootNotification.TYPE_FAVOURITE -> {
val colorBg = Pref.ipEventBgColorFavourite(activity.pref)
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
if(access_info.isNicoru(n_account)) R.drawable.ic_nicoru else R.drawable.ic_star, if(access_info.isNicoru(n_account)) R.drawable.ic_nicoru else R.drawable.ic_star,
R.string.display_name_favourited_by, R.string.display_name_favourited_by
colorBg = Pref.ipEventBgColorFavourite(activity.pref)
) )
if(n_status != null) { if(n_status != null) {
showNotificationStatus(n_status) showNotificationStatus(n_status, colorBg)
} }
} }
TootNotification.TYPE_REBLOG -> { TootNotification.TYPE_REBLOG -> {
val colorBg = Pref.ipEventBgColorBoost(activity.pref)
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_repeat, R.drawable.ic_repeat,
R.string.display_name_boosted_by, R.string.display_name_boosted_by
colorBg = Pref.ipEventBgColorBoost(activity.pref)
) )
if(n_status != null) { if(n_status != null) {
showNotificationStatus(n_status) showNotificationStatus(n_status, colorBg)
} }
} }
TootNotification.TYPE_RENOTE -> { TootNotification.TYPE_RENOTE -> {
// 引用のないreblog // 引用のないreblog
val colorBg = Pref.ipEventBgColorBoost(activity.pref)
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_repeat, R.drawable.ic_repeat,
R.string.display_name_boosted_by, R.string.display_name_boosted_by
colorBg = Pref.ipEventBgColorBoost(activity.pref)
) )
if(n_status != null) { if(n_status != null) {
showNotificationStatus(n_status) showNotificationStatus(n_status, colorBg)
} }
} }
TootNotification.TYPE_FOLLOW -> { TootNotification.TYPE_FOLLOW -> {
val colorBg = Pref.ipEventBgColorFollow(activity.pref)
if(n_account != null) { if(n_account != null) {
showBoost( showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_follow_plus, R.drawable.ic_follow_plus,
R.string.display_name_followed_by, R.string.display_name_followed_by
colorBg = Pref.ipEventBgColorFollow(activity.pref)
) )
showAccount(n_accountRef) showAccount(n_accountRef)
if(colorBg != 0) this.viewRoot.backgroundColor = colorBg
} }
} }
TootNotification.TYPE_UNFOLLOW -> { TootNotification.TYPE_UNFOLLOW -> {
val colorBg = Pref.ipEventBgColorUnfollow(activity.pref)
if(n_account != null) { if(n_account != null) {
showBoost( showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_follow_cross, R.drawable.ic_follow_cross,
R.string.display_name_unfollowed_by, R.string.display_name_unfollowed_by
colorBg = Pref.ipEventBgColorUnfollow(activity.pref)
) )
showAccount(n_accountRef) showAccount(n_accountRef)
if(colorBg != 0) this.viewRoot.backgroundColor = colorBg
} }
} }
TootNotification.TYPE_MENTION, TootNotification.TYPE_MENTION,
TootNotification.TYPE_REPLY -> { TootNotification.TYPE_REPLY -> {
val colorBg = Pref.ipEventBgColorMention(activity.pref)
if(! bSimpleList && ! access_info.isMisskey) { if(! bSimpleList && ! access_info.isMisskey) {
if(n_account != null) { if(n_account != null) {
if(n_status?.in_reply_to_id != null if(n_status?.in_reply_to_id != null
@ -850,66 +854,66 @@ internal class ItemViewHolder(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_reply, R.drawable.ic_reply,
R.string.display_name_mentioned_by, R.string.display_name_mentioned_by
colorBg = Pref.ipEventBgColorMention(activity.pref)
) )
} }
} }
} }
if(n_status != null) { if(n_status != null) {
showNotificationStatus(n_status) showNotificationStatus(n_status, colorBg)
} }
} }
TootNotification.TYPE_REACTION -> { TootNotification.TYPE_REACTION -> {
val colorBg = Pref.ipEventBgColorReaction(activity.pref)
val reaction = MisskeyReaction.shortcodeMap[n.reaction ?: ""] val reaction = MisskeyReaction.shortcodeMap[n.reaction ?: ""]
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_question, // not used R.drawable.ic_question, // not used
R.string.display_name_reaction_by, R.string.display_name_reaction_by,
colorBg = Pref.ipEventBgColorReaction(activity.pref),
reactionDrawableId = reaction?.btnDrawableId reactionDrawableId = reaction?.btnDrawableId
) )
if(n_status != null) { if(n_status != null) {
showNotificationStatus(n_status) showNotificationStatus(n_status, colorBg)
} }
} }
TootNotification.TYPE_QUOTE -> { TootNotification.TYPE_QUOTE -> {
val colorBg = Pref.ipEventBgColorQuote(activity.pref)
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_repeat, R.drawable.ic_repeat,
R.string.display_name_quoted_by, R.string.display_name_quoted_by
colorBg = Pref.ipEventBgColorQuote(activity.pref)
) )
if(n_status != null) { if(n_status != null) {
showNotificationStatus(n_status) showNotificationStatus(n_status, colorBg)
} }
} }
TootNotification.TYPE_VOTE -> { TootNotification.TYPE_VOTE -> {
val colorBg = Pref.ipEventBgColorVote(activity.pref)
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_vote, R.drawable.ic_vote,
R.string.display_name_voted_by, R.string.display_name_voted_by
colorBg = Pref.ipEventBgColorVote(activity.pref)
) )
if(n_status != null) { if(n_status != null) {
showNotificationStatus(n_status) showNotificationStatus(n_status, colorBg)
} }
} }
TootNotification.TYPE_FOLLOW_REQUEST -> { TootNotification.TYPE_FOLLOW_REQUEST -> {
val colorBg = Pref.ipEventBgColorFollowRequest(activity.pref)
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_follow_wait, R.drawable.ic_follow_wait,
R.string.display_name_follow_request_by, R.string.display_name_follow_request_by
colorBg = Pref.ipEventBgColorFollowRequest(activity.pref)
) )
viewRoot.backgroundColor = colorBg
boostedAction = { boostedAction = {
activity.addColumn( activity.addColumn(
activity.nextPosition(column) activity.nextPosition(column)
@ -920,15 +924,15 @@ internal class ItemViewHolder(
} }
else -> { else -> {
val colorBg = 0
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.drawable.ic_question, R.drawable.ic_question,
R.string.unknown_notification_from, R.string.unknown_notification_from
colorBg = 0
) )
if(n_status != null) { if(n_status != null) {
showNotificationStatus(n_status) showNotificationStatus(n_status, colorBg)
} }
tvMessageHolder.visibility = View.VISIBLE tvMessageHolder.visibility = View.VISIBLE
tvMessageHolder.text = "notification type is ${n.type}" tvMessageHolder.text = "notification type is ${n.type}"
@ -1052,7 +1056,6 @@ internal class ItemViewHolder(
time : Long, time : Long,
iconId : Int, iconId : Int,
string_id : Int, string_id : Int,
colorBg : Int,
reactionDrawableId : Int? = null reactionDrawableId : Int? = null
) { ) {
boost_account = whoRef boost_account = whoRef
@ -1078,12 +1081,6 @@ internal class ItemViewHolder(
) )
} }
if( colorBg == 0) {
llBoosted.backgroundResource = R.drawable.btn_bg_transparent
}else{
llBoosted.backgroundDrawable = getAdaptiveRippleDrawable(normalColor = colorBg, pressedColor = content_color)
}
boost_time = time boost_time = time
llBoosted.visibility = View.VISIBLE llBoosted.visibility = View.VISIBLE
showStatusTime(activity, tvBoostedTime, who, time = time) showStatusTime(activity, tvBoostedTime, who, time = time)
@ -1093,6 +1090,7 @@ internal class ItemViewHolder(
} }
private fun showAccount(whoRef : TootAccountRef) { private fun showAccount(whoRef : TootAccountRef) {
follow_account = whoRef follow_account = whoRef
val who = whoRef.get() val who = whoRef.get()
llFollow.visibility = View.VISIBLE llFollow.visibility = View.VISIBLE
@ -1126,7 +1124,7 @@ internal class ItemViewHolder(
} }
} }
private fun showStatus(status : TootStatus) { private fun showStatus(status : TootStatus, colorBg : Int = 0) {
if(status.filtered) { if(status.filtered) {
showMessageHolder(TootMessageHolder(activity.getString(R.string.filtered))) showMessageHolder(TootMessageHolder(activity.getString(R.string.filtered)))
@ -1144,15 +1142,17 @@ internal class ItemViewHolder(
) and 0xffffff) or 0x20000000 ) and 0xffffff) or 0x20000000
) )
} else { } else {
val c = when(status.getBackgroundColorType(access_info)) { val c = colorBg.notZero()
TootVisibility.UnlistedHome -> toot_color_unlisted ?: when(status.getBackgroundColorType(access_info)) {
TootVisibility.PrivateFollowers -> toot_color_follower TootVisibility.UnlistedHome -> toot_color_unlisted
TootVisibility.DirectSpecified -> toot_color_direct_user TootVisibility.PrivateFollowers -> toot_color_follower
TootVisibility.DirectPrivate -> toot_color_direct_me TootVisibility.DirectSpecified -> toot_color_direct_user
else -> 0 TootVisibility.DirectPrivate -> toot_color_direct_me
} else -> 0
}
if(c != 0) { if(c != 0) {
this.viewRoot.setBackgroundColor(c) this.viewRoot.backgroundColor = c
} }
} }
@ -1557,7 +1557,7 @@ internal class ItemViewHolder(
Pref.bpShortAcctLocalUser(App1.pref) -> "@" + (acctShort ?: "?") Pref.bpShortAcctLocalUser(App1.pref) -> "@" + (acctShort ?: "?")
else -> acctLong else -> acctLong
} }
tv.textColor = ac.color_fg.notZero() ?: this.acct_color tv.textColor = ac.color_fg.notZero() ?: this.acct_color
tv.setBackgroundColor(ac.color_bg) // may 0 tv.setBackgroundColor(ac.color_bg) // may 0
tv.setPaddingRelative(activity.acct_pad_lr, 0, activity.acct_pad_lr, 0) tv.setPaddingRelative(activity.acct_pad_lr, 0, activity.acct_pad_lr, 0)

View File

@ -265,7 +265,7 @@
<TextView <TextView
style="@style/setting_row_label_indent1" style="@style/setting_row_label_indent1"
android:text="@string/mention_not_reply" android:text="@string/reply"
/> />
<LinearLayout style="@style/setting_row_form"> <LinearLayout style="@style/setting_row_form">

View File

@ -866,7 +866,6 @@
<string name="add">追加</string> <string name="add">追加</string>
<string name="show_clear_button_in_search_bar">検索バーに消去ボタンを表示する (アプリ再起動が必要)</string> <string name="show_clear_button_in_search_bar">検索バーに消去ボタンを表示する (アプリ再起動が必要)</string>
<string name="event_background_color">イベント背景色</string> <string name="event_background_color">イベント背景色</string>
<string name="mention_not_reply">メンション(返信ではない)</string>
<string name="unfollow_misskey">フォロー解除 (Misskey)</string> <string name="unfollow_misskey">フォロー解除 (Misskey)</string>
<string name="follow_request_misskey">フォローリクエスト (Misskey)</string> <string name="follow_request_misskey">フォローリクエスト (Misskey)</string>

View File

@ -888,7 +888,6 @@
<string name="add">Add</string> <string name="add">Add</string>
<string name="show_clear_button_in_search_bar">Show clear button on search bar (app restart required)</string> <string name="show_clear_button_in_search_bar">Show clear button on search bar (app restart required)</string>
<string name="event_background_color">Event background color</string> <string name="event_background_color">Event background color</string>
<string name="mention_not_reply">Mention (not reply)</string>
<string name="unfollow_misskey">Unfollow (Misskey)</string> <string name="unfollow_misskey">Unfollow (Misskey)</string>
<string name="follow_request_misskey">Follow request (Misskey)</string> <string name="follow_request_misskey">Follow request (Misskey)</string>