fedibird.com beta の 投稿の参照 通知を正しく表示する。ただしプッシュ購読は未対応。

This commit is contained in:
tateisu 2022-03-19 23:42:20 +09:00
parent a3f58e5a55
commit 59ffc0895f
13 changed files with 89 additions and 18 deletions

View File

@ -429,6 +429,7 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener,
cbNotificationVote.isChecked = a.notification_vote
cbNotificationPost.isChecked = a.notification_post
cbNotificationUpdate.isChecked = a.notification_update
cbNotificationStatusReference.isChecked = a.notification_status_reference
cbConfirmFollow.isChecked = a.confirm_follow
cbConfirmFollowLockedUser.isChecked = a.confirm_follow_locked
@ -502,6 +503,7 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener,
cbNotificationVote,
cbNotificationPost,
cbNotificationUpdate,
cbNotificationStatusReference,
cbConfirmFollow,
cbConfirmFollowLockedUser,
cbConfirmUnfollow,
@ -563,6 +565,7 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener,
account.notification_vote = cbNotificationVote.isChecked
account.notification_post = cbNotificationPost.isChecked
account.notification_update = cbNotificationUpdate.isChecked
account.notification_status_reference = cbNotificationStatusReference.isChecked
account.confirm_follow = cbConfirmFollow.isChecked
account.confirm_follow_locked = cbConfirmFollowLockedUser.isChecked

View File

@ -45,6 +45,9 @@ class TootNotification(parser: TootParser, src: JsonObject) : TimelineItem() {
// (Mastodon 3.5.0rc1)
const val TYPE_UPDATE = "update"
// (Fedibird beta)
const val TYPE_STATUS_REFERENCE = "status_reference"
}
val json: JsonObject

View File

@ -801,6 +801,7 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
colorAlpha(PrefI.ipEventBgColorVote, R.string.vote_polls)
colorAlpha(PrefI.ipEventBgColorStatus, R.string.status)
colorAlpha(PrefI.ipEventBgColorUpdate, R.string.notification_type_update)
colorAlpha(PrefI.ipEventBgColorStatusReference, R.string.notification_type_status_reference)
colorAlpha(
PrefI.ipConversationMainTootBgColor,

View File

@ -277,6 +277,7 @@ fun Column.isFiltered(item: TootNotification): Boolean {
TootNotification.TYPE_STATUS,
TootNotification.TYPE_UPDATE,
TootNotification.TYPE_STATUS_REFERENCE,
-> dontShowNormalToot
else -> false
@ -312,6 +313,7 @@ fun Column.isFiltered(item: TootNotification): Boolean {
TootNotification.TYPE_STATUS,
TootNotification.TYPE_UPDATE,
TootNotification.TYPE_STATUS_REFERENCE,
-> quickFilter != Column.QUICK_FILTER_POST
else -> true

View File

@ -52,6 +52,9 @@ fun ItemViewHolder.showNotification(n: TootNotification) {
TootNotification.TYPE_UPDATE ->
showNotificationUpdate(n, nAccountRef, nStatus)
TootNotification.TYPE_STATUS_REFERENCE ->
showNotificationStatusReference(n, nAccountRef, nStatus)
TootNotification.TYPE_FOLLOW_REQUEST,
TootNotification.TYPE_FOLLOW_REQUEST_MISSKEY,
-> showNotificationFollowRequest(n, nAccountRef)
@ -73,7 +76,7 @@ fun ItemViewHolder.showNotification(n: TootNotification) {
private fun ItemViewHolder.showNotificationFollow(
n: TootNotification,
nAccountRef: TootAccountRef?
nAccountRef: TootAccountRef?,
) {
val colorBg = PrefI.ipEventBgColorFollow(activity.pref)
colorBg.notZero()?.let { viewRoot.backgroundColor = it }
@ -90,7 +93,7 @@ private fun ItemViewHolder.showNotificationFollow(
private fun ItemViewHolder.showNotificationUnfollow(
n: TootNotification,
nAccountRef: TootAccountRef?
nAccountRef: TootAccountRef?,
) {
val colorBg = PrefI.ipEventBgColorUnfollow(activity.pref)
colorBg.notZero()?.let { viewRoot.backgroundColor = it }
@ -107,7 +110,7 @@ private fun ItemViewHolder.showNotificationUnfollow(
private fun ItemViewHolder.showNotificationFollowRequest(
n: TootNotification,
nAccountRef: TootAccountRef?
nAccountRef: TootAccountRef?,
) {
val colorBg = PrefI.ipEventBgColorFollowRequest(activity.pref)
colorBg.notZero()?.let { viewRoot.backgroundColor = it }
@ -127,7 +130,7 @@ private fun ItemViewHolder.showNotificationFollowRequest(
private fun ItemViewHolder.showNotificationFollowRequestAccepted(
n: TootNotification,
nAccountRef: TootAccountRef?
nAccountRef: TootAccountRef?,
) {
val colorBg = PrefI.ipEventBgColorFollow(activity.pref)
colorBg.notZero()?.let { viewRoot.backgroundColor = it }
@ -145,7 +148,7 @@ private fun ItemViewHolder.showNotificationFollowRequestAccepted(
private fun ItemViewHolder.showNotificationPost(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
val colorBg = PrefI.ipEventBgColorStatus(activity.pref)
val iconId = when (nStatus) {
@ -159,18 +162,39 @@ private fun ItemViewHolder.showNotificationPost(
private fun ItemViewHolder.showNotificationUpdate(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
val colorBg = PrefI.ipEventBgColorUpdate(activity.pref)
val iconId = R.drawable.ic_history
nAccountRef?.let { showBoost(it, n.time_created_at, iconId, R.string.display_name_updates_post) }
nAccountRef?.let {
showBoost(it,
n.time_created_at,
iconId,
R.string.display_name_updates_post)
}
nStatus?.let { showNotificationStatus(it, colorBg) }
}
private fun ItemViewHolder.showNotificationStatusReference(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?,
) {
val colorBg = PrefI.ipEventBgColorStatusReference(activity.pref)
val iconId = R.drawable.ic_link_variant
nAccountRef?.let {
showBoost(it,
n.time_created_at,
iconId,
R.string.display_name_references_post)
}
nStatus?.let { showNotificationStatus(it, colorBg) }
}
private fun ItemViewHolder.showNotificationReaction(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
val colorBg = PrefI.ipEventBgColorReaction(activity.pref)
nAccountRef?.let {
@ -188,7 +212,7 @@ private fun ItemViewHolder.showNotificationReaction(
private fun ItemViewHolder.showNotificationFavourite(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
nAccountRef?.let {
val iconId = if (accessInfo.isNicoru(it.get())) R.drawable.ic_nicoru else R.drawable.ic_star
@ -201,7 +225,7 @@ private fun ItemViewHolder.showNotificationFavourite(
private fun ItemViewHolder.showNotificationReblog(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
nAccountRef?.let {
showBoost(
@ -220,7 +244,7 @@ private fun ItemViewHolder.showNotificationReblog(
private fun ItemViewHolder.showNotificationRenote(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
// 引用のないreblog
nAccountRef?.let {
@ -239,7 +263,7 @@ private fun ItemViewHolder.showNotificationRenote(
private fun ItemViewHolder.showNotificationMention(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
// メンション通知に「~~からの返信」を表示するカラムなのかどうか
fun willShowReplyInfo(status: TootStatus?): Boolean = when {
@ -269,7 +293,7 @@ private fun ItemViewHolder.showNotificationMention(
private fun ItemViewHolder.showNotificationQuote(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
nAccountRef?.let {
showBoost(
@ -287,7 +311,7 @@ private fun ItemViewHolder.showNotificationQuote(
private fun ItemViewHolder.showNotificationVote(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
nAccountRef?.let {
showBoost(
@ -304,7 +328,7 @@ private fun ItemViewHolder.showNotificationVote(
private fun ItemViewHolder.showNotificationPoll(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
nAccountRef?.let {
showBoost(
@ -321,7 +345,7 @@ private fun ItemViewHolder.showNotificationPoll(
private fun ItemViewHolder.showNotificationUnknown(
n: TootNotification,
nAccountRef: TootAccountRef?,
nStatus: TootStatus?
nStatus: TootStatus?,
) {
nAccountRef?.let {
showBoost(
@ -342,7 +366,7 @@ private fun ItemViewHolder.showNotificationUnknown(
private fun ItemViewHolder.showNotificationStatus(
item: TootStatus,
colorBgDefault: Int,
fadeText: Boolean = false
fadeText: Boolean = false,
) {
val reblog = item.reblog
when {

View File

@ -143,6 +143,9 @@ class TaskRunner(
TootNotification.TYPE_UPDATE ->
context.getString(R.string.display_name_updates_post, name)
TootNotification.TYPE_STATUS_REFERENCE ->
context.getString(R.string.display_name_references_post, name)
TootNotification.TYPE_FOLLOW ->
context.getString(R.string.display_name_followed_by, name)

View File

@ -96,6 +96,7 @@ object PrefI {
val ipEventBgColorFollowRequest = IntPref("EventBgColorFollowRequest", 0)
val ipEventBgColorStatus = IntPref("EventBgColorStatus", 0)
val ipEventBgColorUpdate = IntPref("EventBgColorUpdate", 0)
val ipEventBgColorStatusReference = IntPref("EventBgColorStatusReference", 0)
val ipEventBgColorGap = IntPref("EventBgColorGap", 0)

View File

@ -111,6 +111,11 @@ class SavedAccount(
"lang",
"")
var notification_status_reference : Boolean by JsonProperty(
extraJson,
"notification_status_reference",
true)
init {
val tmpAcct = Acct.parse(acctArg)
this.username = tmpAcct.username
@ -336,6 +341,7 @@ class SavedAccount(
this.notification_vote = b.notification_vote
this.notification_post = b.notification_post
this.notification_update = b.notification_update
this.notification_status_reference = b.notification_status_reference
this.notification_tag = b.notification_tag
this.default_text = b.default_text
@ -895,6 +901,8 @@ class SavedAccount(
TootNotification.TYPE_UPDATE -> notification_update
TootNotification.TYPE_STATUS_REFERENCE -> notification_status_reference
else -> false
}

View File

@ -23,3 +23,10 @@ operator fun JsonProperty<Int>.getValue(thisRef: Any?, property: KProperty<*>):
operator fun JsonProperty<Int>.setValue(thisRef: Any?, property: KProperty<*>, value: Int) {
src[key] = value
}
operator fun JsonProperty<Boolean>.getValue(thisRef: Any?, property: KProperty<*>): Boolean {
return src.boolean(key) ?: defVal
}
operator fun JsonProperty<Boolean>.setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) {
src[key] = value
}

View File

@ -0,0 +1,8 @@
<!-- drawable/link_variant.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#000" android:pathData="M10.59,13.41C11,13.8 11,14.44 10.59,14.83C10.2,15.22 9.56,15.22 9.17,14.83C7.22,12.88 7.22,9.71 9.17,7.76V7.76L12.71,4.22C14.66,2.27 17.83,2.27 19.78,4.22C21.73,6.17 21.73,9.34 19.78,11.29L18.29,12.78C18.3,11.96 18.17,11.14 17.89,10.36L18.36,9.88C19.54,8.71 19.54,6.81 18.36,5.64C17.19,4.46 15.29,4.46 14.12,5.64L10.59,9.17C9.41,10.34 9.41,12.24 10.59,13.41M13.41,9.17C13.8,8.78 14.44,8.78 14.83,9.17C16.78,11.12 16.78,14.29 14.83,16.24V16.24L11.29,19.78C9.34,21.73 6.17,21.73 4.22,19.78C2.27,17.83 2.27,14.66 4.22,12.71L5.71,11.22C5.7,12.04 5.83,12.86 6.11,13.65L5.64,14.12C4.46,15.29 4.46,17.19 5.64,18.36C6.81,19.54 8.71,19.54 9.88,18.36L13.41,14.83C14.59,13.66 14.59,11.76 13.41,10.59C13,10.2 13,9.56 13.41,9.17Z" />
</vector>

View File

@ -574,6 +574,12 @@
android:id="@+id/cbNotificationUpdate"
style="@style/setting_row_form"
android:text="@string/notification_type_update" />
<CheckBox
android:id="@+id/cbNotificationStatusReference"
style="@style/setting_row_form"
android:text="@string/notification_type_status_reference_fedibird" />
<TextView
style="@style/setting_row_form"
android:layout_marginTop="12dp"

View File

@ -208,6 +208,7 @@
<string name="display_name_quoted_by">%1$sが引用しました</string>
<string name="display_name_posted_by">%1$sが投稿しました</string>
<string name="display_name_updates_post">%1$sが投稿を更新しました</string>
<string name="display_name_references_post">%1$sがあなたの投稿を参照しました</string>
<string name="display_name_reaction_by">%1$sがリアクション</string>
<string name="display_name_replied_by">%1$sからの返信</string>
<string name="display_name_mentioned_by">%1$sからのメンション</string>
@ -504,6 +505,8 @@
<string name="notification_type_vote">投票</string>
<string name="notification_type_post">投稿</string>
<string name="notification_type_update">投稿の更新</string>
<string name="notification_type_status_reference">投稿の参照</string>
<string name="notification_type_status_reference_fedibird">投稿の参照 (fedibird.com)</string>
<string name="notifications">通知</string>
<string name="nsfw">NSFW</string>
<string name="ok">OK</string>

View File

@ -92,6 +92,7 @@
<string name="display_name_quoted_by">%1$s quoted</string>
<string name="display_name_posted_by">%1$s posted</string>
<string name="display_name_updates_post">%1$s updates the post</string>
<string name="display_name_references_post">%1$s references your post</string>
<string name="display_name_reaction_by">%1$s reactioned</string>
<string name="display_name_followed_by">%1$s is following you</string>
<string name="display_name_unfollowed_by">%1$s unfollowed you</string>
@ -639,7 +640,8 @@
<string name="notification_type_vote">vote</string>
<string name="notification_type_post">post</string>
<string name="notification_type_update">post update</string>
<string name="notification_type_status_reference">post referenced</string>
<string name="notification_type_status_reference_fedibird">post referenced (fedibird.com)</string>
<string name="dont_show_normal_toot">Don\'t show normal toot</string>
<string name="dont_show_non_public_toot">Don\'t show non-public toot</string>
<string name="set_focus_point">set focus point (Mastodon 2.3+)</string>