(Mastodon開発版)フォローリクエスト通知に対応
This commit is contained in:
parent
223197e5a2
commit
cddb24677a
|
@ -105,6 +105,7 @@ class ActAccountSetting
|
|||
private lateinit var cbNotificationBoost : CheckBox
|
||||
private lateinit var cbNotificationFavourite : CheckBox
|
||||
private lateinit var cbNotificationFollow : CheckBox
|
||||
private lateinit var cbNotificationFollowRequest : CheckBox
|
||||
private lateinit var cbNotificationReaction : CheckBox
|
||||
private lateinit var cbNotificationVote : CheckBox
|
||||
|
||||
|
@ -280,6 +281,8 @@ class ActAccountSetting
|
|||
cbNotificationBoost = findViewById(R.id.cbNotificationBoost)
|
||||
cbNotificationFavourite = findViewById(R.id.cbNotificationFavourite)
|
||||
cbNotificationFollow = findViewById(R.id.cbNotificationFollow)
|
||||
cbNotificationFollowRequest= findViewById(R.id.cbNotificationFollowRequest)
|
||||
|
||||
cbNotificationReaction = findViewById(R.id.cbNotificationReaction)
|
||||
cbNotificationVote = findViewById(R.id.cbNotificationVote)
|
||||
|
||||
|
@ -345,6 +348,7 @@ class ActAccountSetting
|
|||
cbNotificationBoost.setOnCheckedChangeListener(this)
|
||||
cbNotificationFavourite.setOnCheckedChangeListener(this)
|
||||
cbNotificationFollow.setOnCheckedChangeListener(this)
|
||||
cbNotificationFollowRequest.setOnCheckedChangeListener(this)
|
||||
cbNotificationReaction.setOnCheckedChangeListener(this)
|
||||
cbNotificationVote.setOnCheckedChangeListener(this)
|
||||
cbLocked.setOnCheckedChangeListener(this)
|
||||
|
@ -458,6 +462,7 @@ class ActAccountSetting
|
|||
cbNotificationBoost.isChecked = a.notification_boost
|
||||
cbNotificationFavourite.isChecked = a.notification_favourite
|
||||
cbNotificationFollow.isChecked = a.notification_follow
|
||||
cbNotificationFollowRequest.isChecked = a.notification_follow_request
|
||||
cbNotificationReaction.isChecked = a.notification_reaction
|
||||
cbNotificationVote.isChecked = a.notification_vote
|
||||
|
||||
|
@ -494,6 +499,7 @@ class ActAccountSetting
|
|||
cbNotificationBoost.isEnabled = enabled
|
||||
cbNotificationFavourite.isEnabled = enabled
|
||||
cbNotificationFollow.isEnabled = enabled
|
||||
cbNotificationFollowRequest.isEnabled = enabled
|
||||
cbNotificationReaction.isEnabled = enabled
|
||||
cbNotificationVote.isEnabled = enabled
|
||||
|
||||
|
@ -534,6 +540,7 @@ class ActAccountSetting
|
|||
account.notification_boost = cbNotificationBoost.isChecked
|
||||
account.notification_favourite = cbNotificationFavourite.isChecked
|
||||
account.notification_follow = cbNotificationFollow.isChecked
|
||||
account.notification_follow_request = cbNotificationFollowRequest.isChecked
|
||||
account.notification_reaction = cbNotificationReaction.isChecked
|
||||
account.notification_vote = cbNotificationVote.isChecked
|
||||
|
||||
|
|
|
@ -128,8 +128,9 @@ class App1 : Application() {
|
|||
// 2019/10/22 40 => 41 NotificationCache テーブルに項目追加。
|
||||
// 2019/10/23 41=> 42 SavedAccount テーブルに項目追加。
|
||||
// 2019/11/15 42=> 43 HighlightWord テーブルに項目追加。
|
||||
// 2019/12/17 43=> 44 SavedAccount テーブルに項目追加。
|
||||
|
||||
internal const val DB_VERSION = 43
|
||||
internal const val DB_VERSION = 44
|
||||
|
||||
private val tableList = arrayOf(
|
||||
LogData,
|
||||
|
|
|
@ -555,7 +555,7 @@ class Column(
|
|||
|| dont_show_reply
|
||||
|| dont_show_reaction
|
||||
|| dont_show_vote
|
||||
|| (language_filter?.length()?:0) >0
|
||||
|| (language_filter?.length() ?: 0) > 0
|
||||
)
|
||||
|
||||
@Volatile
|
||||
|
@ -813,7 +813,7 @@ class Column(
|
|||
dst.put(KEY_REGEX_TEXT, regex_text)
|
||||
|
||||
val ov = language_filter
|
||||
if( ov != null) dst.put(KEY_LANGUAGE_FILTER,ov)
|
||||
if(ov != null) dst.put(KEY_LANGUAGE_FILTER, ov)
|
||||
|
||||
dst.put(KEY_HEADER_BACKGROUND_COLOR, header_bg_color)
|
||||
dst.put(KEY_HEADER_TEXT_COLOR, header_fg_color)
|
||||
|
@ -1482,7 +1482,7 @@ class Column(
|
|||
if(column_regex_filter(reblog?.decoded_content)) return true
|
||||
if(column_regex_filter(status.decoded_spoiler_text)) return true
|
||||
if(column_regex_filter(reblog?.decoded_spoiler_text)) return true
|
||||
|
||||
|
||||
if(checkLanguageFilter(status)) return true
|
||||
|
||||
if(access_info.isPseudo) {
|
||||
|
@ -1499,14 +1499,16 @@ class Column(
|
|||
|
||||
// true if the status will be hidden
|
||||
private fun checkLanguageFilter(status : TootStatus?) : Boolean {
|
||||
status?:return false
|
||||
status ?: return false
|
||||
val languageFilter = language_filter ?: return false
|
||||
|
||||
val allow = languageFilter.parseBoolean(status.language ?: status.reblog?.language ?:TootStatus.LANGUAGE_CODE_UNKNOWN)
|
||||
val allow = languageFilter.parseBoolean(
|
||||
status.language ?: status.reblog?.language ?: TootStatus.LANGUAGE_CODE_UNKNOWN
|
||||
)
|
||||
?: languageFilter.parseBoolean(TootStatus.LANGUAGE_CODE_DEFAULT)
|
||||
?: true
|
||||
|
||||
return !allow
|
||||
|
||||
return ! allow
|
||||
|
||||
}
|
||||
|
||||
|
@ -1520,8 +1522,10 @@ class Column(
|
|||
TootNotification.TYPE_RENOTE,
|
||||
TootNotification.TYPE_QUOTE -> dont_show_boost
|
||||
|
||||
TootNotification.TYPE_FOLLOW,
|
||||
TootNotification.TYPE_UNFOLLOW,
|
||||
TootNotification.TYPE_FOLLOW_REQUEST,
|
||||
TootNotification.TYPE_FOLLOW -> dont_show_follow
|
||||
TootNotification.TYPE_FOLLOW_REQUEST_MISSKEY -> dont_show_follow
|
||||
|
||||
TootNotification.TYPE_MENTION,
|
||||
TootNotification.TYPE_REPLY -> dont_show_reply
|
||||
|
@ -1538,8 +1542,12 @@ class Column(
|
|||
TootNotification.TYPE_REBLOG,
|
||||
TootNotification.TYPE_RENOTE,
|
||||
TootNotification.TYPE_QUOTE -> quick_filter != QUICK_FILTER_BOOST
|
||||
|
||||
TootNotification.TYPE_FOLLOW,
|
||||
TootNotification.TYPE_UNFOLLOW,
|
||||
TootNotification.TYPE_FOLLOW_REQUEST,
|
||||
TootNotification.TYPE_FOLLOW -> quick_filter != QUICK_FILTER_FOLLOW
|
||||
TootNotification.TYPE_FOLLOW_REQUEST_MISSKEY -> quick_filter != QUICK_FILTER_FOLLOW
|
||||
|
||||
TootNotification.TYPE_MENTION,
|
||||
TootNotification.TYPE_REPLY -> quick_filter != QUICK_FILTER_MENTION
|
||||
TootNotification.TYPE_REACTION -> quick_filter != QUICK_FILTER_REACTION
|
||||
|
@ -1563,8 +1571,8 @@ class Column(
|
|||
// just update _filtered flag for reversible filter
|
||||
status.updateKeywordFilteredFlag(access_info, filterTrees)
|
||||
}
|
||||
if( checkLanguageFilter(status) )return true
|
||||
|
||||
if(checkLanguageFilter(status)) return true
|
||||
|
||||
if(status?.checkMuted() == true) {
|
||||
log.d("isFiltered: status muted by in-app muted words.")
|
||||
return true
|
||||
|
@ -1578,7 +1586,9 @@ class Column(
|
|||
TootNotification.TYPE_FAVOURITE,
|
||||
TootNotification.TYPE_REACTION,
|
||||
TootNotification.TYPE_VOTE,
|
||||
TootNotification.TYPE_FOLLOW -> {
|
||||
TootNotification.TYPE_FOLLOW ,
|
||||
TootNotification.TYPE_FOLLOW_REQUEST,
|
||||
TootNotification.TYPE_FOLLOW_REQUEST_MISSKEY -> {
|
||||
val who = item.account
|
||||
if(who != null && favMuteSet?.contains(access_info.getFullAcct(who)) == true) {
|
||||
log.d("%s is in favMuteSet.", access_info.getFullAcct(who))
|
||||
|
@ -2231,7 +2241,7 @@ class Column(
|
|||
ColumnType.HOME, ColumnType.LIST_TL, ColumnType.MISSKEY_HYBRID -> TootFilter.CONTEXT_HOME
|
||||
ColumnType.NOTIFICATIONS, ColumnType.NOTIFICATION_FROM_ACCT -> TootFilter.CONTEXT_NOTIFICATIONS
|
||||
ColumnType.CONVERSATION -> TootFilter.CONTEXT_THREAD
|
||||
ColumnType.LOCAL, ColumnType.DOMAIN_TIMELINE, ColumnType.FEDERATE, ColumnType.HASHTAG, ColumnType.HASHTAG_FROM_ACCT, ColumnType.PROFILE, ColumnType.SEARCH -> TootFilter.CONTEXT_PUBLIC
|
||||
ColumnType.LOCAL, ColumnType.DOMAIN_TIMELINE, ColumnType.FEDERATE, ColumnType.HASHTAG, ColumnType.HASHTAG_FROM_ACCT, ColumnType.PROFILE, ColumnType.SEARCH -> TootFilter.CONTEXT_PUBLIC
|
||||
ColumnType.DIRECT_MESSAGES -> TootFilter.CONTEXT_PUBLIC
|
||||
else -> TootFilter.CONTEXT_NONE
|
||||
// ColumnType.MISSKEY_HYBRID はHOMEでもPUBLICでもある… Misskeyだし関係ないが、NONEにするとアプリ内で完結するフィルタも働かなくなる
|
||||
|
@ -3031,7 +3041,6 @@ class Column(
|
|||
getHeaderNameColor()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// fun findListIndexByTimelineId(orderId : EntityId) : Int? {
|
||||
// list_data.forEachIndexed { i, v ->
|
||||
|
|
|
@ -930,7 +930,8 @@ internal class ItemViewHolder(
|
|||
}
|
||||
}
|
||||
|
||||
TootNotification.TYPE_FOLLOW_REQUEST -> {
|
||||
TootNotification.TYPE_FOLLOW_REQUEST,
|
||||
TootNotification.TYPE_FOLLOW_REQUEST_MISSKEY -> {
|
||||
val colorBg = Pref.ipEventBgColorFollowRequest(activity.pref)
|
||||
if(n_account != null) showBoost(
|
||||
n_accountRef,
|
||||
|
|
|
@ -1186,7 +1186,9 @@ class PollingWorker private constructor(contextArg : Context) {
|
|||
when(notification.type) {
|
||||
TootNotification.TYPE_REBLOG,
|
||||
TootNotification.TYPE_FAVOURITE,
|
||||
TootNotification.TYPE_FOLLOW -> {
|
||||
TootNotification.TYPE_FOLLOW,
|
||||
TootNotification.TYPE_FOLLOW_REQUEST,
|
||||
TootNotification.TYPE_FOLLOW_REQUEST_MISSKEY -> {
|
||||
val who = notification.account
|
||||
if(who != null && favMuteSet.contains(account.getFullAcct(who))) {
|
||||
log.d("${account.getFullAcct(who)} is in favMuteSet.")
|
||||
|
@ -1432,7 +1434,8 @@ class PollingWorker private constructor(contextArg : Context) {
|
|||
TootNotification.TYPE_VOTE ->
|
||||
"- " + context.getString(R.string.display_name_voted_by, name)
|
||||
|
||||
TootNotification.TYPE_FOLLOW_REQUEST ->
|
||||
TootNotification.TYPE_FOLLOW_REQUEST,
|
||||
TootNotification.TYPE_FOLLOW_REQUEST_MISSKEY ->
|
||||
"- " + context.getString(
|
||||
R.string.display_name_follow_request_by,
|
||||
name
|
||||
|
|
|
@ -70,6 +70,7 @@ internal fun addPseudoAccount(
|
|||
throw RuntimeException("loadAccount returns null.")
|
||||
}
|
||||
account.notification_follow = false
|
||||
account.notification_follow_request = false
|
||||
account.notification_favourite = false
|
||||
account.notification_boost = false
|
||||
account.notification_mention = false
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package jp.juggler.subwaytooter.api.entity
|
||||
|
||||
import jp.juggler.subwaytooter.api.TootParser
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.notEmptyOrThrow
|
||||
import jp.juggler.util.parseString
|
||||
import org.json.JSONObject
|
||||
|
@ -8,6 +9,8 @@ import org.json.JSONObject
|
|||
class TootNotification(parser : TootParser, src : JSONObject) : TimelineItem() {
|
||||
|
||||
companion object {
|
||||
private val log = LogCategory("TootNotification")
|
||||
|
||||
// 言及と返信
|
||||
const val TYPE_MENTION = "mention" // Mastodon,Misskey
|
||||
const val TYPE_REPLY = "reply" // Misskey (メンションとReplyは別の物らしい
|
||||
|
@ -23,10 +26,12 @@ class TootNotification(parser : TootParser, src : JSONObject) : TimelineItem() {
|
|||
|
||||
const val TYPE_FAVOURITE = "favourite"
|
||||
const val TYPE_REACTION = "reaction"
|
||||
|
||||
|
||||
const val TYPE_FOLLOW_REQUEST = "follow_request"
|
||||
const val TYPE_FOLLOW_REQUEST_MISSKEY = "receiveFollowRequest"
|
||||
|
||||
// 投票
|
||||
const val TYPE_VOTE = "poll_vote"
|
||||
const val TYPE_FOLLOW_REQUEST = "receiveFollowRequest"
|
||||
|
||||
// (Mastodon 2.8)投票完了
|
||||
const val TYPE_POLL = "poll"
|
||||
|
@ -71,6 +76,7 @@ class TootNotification(parser : TootParser, src : JSONObject) : TimelineItem() {
|
|||
id = EntityId.mayDefault(src.parseString("id"))
|
||||
|
||||
type = src.notEmptyOrThrow("type")
|
||||
|
||||
created_at = src.parseString("created_at")
|
||||
time_created_at = TootStatus.parseTime(created_at)
|
||||
accountRef = TootAccountRef.mayNull(parser, parser.account(src.optJSONObject("account")))
|
||||
|
|
|
@ -46,6 +46,7 @@ class SavedAccount(
|
|||
var notification_boost : Boolean = false
|
||||
var notification_favourite : Boolean = false
|
||||
var notification_follow : Boolean = false
|
||||
var notification_follow_request : Boolean = false
|
||||
var notification_reaction : Boolean = false
|
||||
var notification_vote : Boolean = false
|
||||
var sound_uri = ""
|
||||
|
@ -119,6 +120,7 @@ class SavedAccount(
|
|||
this.notification_boost = cursor.getBoolean(COL_NOTIFICATION_BOOST)
|
||||
this.notification_favourite = cursor.getBoolean(COL_NOTIFICATION_FAVOURITE)
|
||||
this.notification_follow = cursor.getBoolean(COL_NOTIFICATION_FOLLOW)
|
||||
this.notification_follow_request = cursor.getBoolean(COL_NOTIFICATION_FOLLOW_REQUEST)
|
||||
this.notification_reaction = cursor.getBoolean(COL_NOTIFICATION_REACTION)
|
||||
this.notification_vote = cursor.getBoolean(COL_NOTIFICATION_VOTE)
|
||||
|
||||
|
@ -189,6 +191,7 @@ class SavedAccount(
|
|||
cv.put(COL_NOTIFICATION_BOOST, notification_boost.b2i())
|
||||
cv.put(COL_NOTIFICATION_FAVOURITE, notification_favourite.b2i())
|
||||
cv.put(COL_NOTIFICATION_FOLLOW, notification_follow.b2i())
|
||||
cv.put(COL_NOTIFICATION_FOLLOW_REQUEST, notification_follow_request.b2i())
|
||||
cv.put(COL_NOTIFICATION_REACTION, notification_reaction.b2i())
|
||||
cv.put(COL_NOTIFICATION_VOTE, notification_vote.b2i())
|
||||
|
||||
|
@ -254,6 +257,7 @@ class SavedAccount(
|
|||
this.notification_boost = b.notification_boost
|
||||
this.notification_favourite = b.notification_favourite
|
||||
this.notification_follow = b.notification_follow
|
||||
this.notification_follow_request = b.notification_follow_request
|
||||
this.notification_reaction = b.notification_reaction
|
||||
this.notification_vote = b.notification_vote
|
||||
this.notification_tag = b.notification_tag
|
||||
|
@ -419,6 +423,10 @@ class SavedAccount(
|
|||
// スキーマ42から
|
||||
private const val COL_LAST_NOTIFICATION_ERROR = "last_notification_error"
|
||||
|
||||
// スキーマ44から
|
||||
private const val COL_NOTIFICATION_FOLLOW_REQUEST = "notification_follow_request"
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// login information
|
||||
const val INVALID_DB_ID = - 1L
|
||||
|
@ -496,6 +504,9 @@ class SavedAccount(
|
|||
// スキーマ42から
|
||||
+ ",$COL_LAST_NOTIFICATION_ERROR text"
|
||||
|
||||
// スキーマ44から
|
||||
+ ",$COL_NOTIFICATION_FOLLOW_REQUEST integer default 1"
|
||||
|
||||
+ ")"
|
||||
)
|
||||
db.execSQL("create index if not exists ${table}_user on ${table}(u)")
|
||||
|
@ -672,6 +683,14 @@ class SavedAccount(
|
|||
log.trace(ex)
|
||||
}
|
||||
}
|
||||
|
||||
if(oldVersion < 44 && newVersion >= 44) {
|
||||
try {
|
||||
db.execSQL("alter table $table add column $COL_NOTIFICATION_FOLLOW_REQUEST integer default 1")
|
||||
} catch(ex : Throwable) {
|
||||
log.trace(ex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 横断検索用の、何とも紐ついていないアカウント
|
||||
|
@ -679,6 +698,7 @@ class SavedAccount(
|
|||
val na : SavedAccount by lazy {
|
||||
val dst = SavedAccount(- 1L, "?@?")
|
||||
dst.notification_follow = false
|
||||
dst.notification_follow_request = false
|
||||
dst.notification_favourite = false
|
||||
dst.notification_boost = false
|
||||
dst.notification_mention = false
|
||||
|
@ -997,10 +1017,13 @@ class SavedAccount(
|
|||
|
||||
TootNotification.TYPE_FAVOURITE -> notification_favourite
|
||||
|
||||
TootNotification.TYPE_FOLLOW_REQUEST,
|
||||
|
||||
TootNotification.TYPE_FOLLOW,
|
||||
TootNotification.TYPE_UNFOLLOW -> notification_follow
|
||||
|
||||
TootNotification.TYPE_FOLLOW_REQUEST,
|
||||
TootNotification.TYPE_FOLLOW_REQUEST_MISSKEY ->notification_follow_request
|
||||
|
||||
TootNotification.TYPE_REACTION -> notification_reaction
|
||||
|
||||
TootNotification.TYPE_VOTE, TootNotification.TYPE_POLL -> notification_vote
|
||||
|
|
|
@ -49,6 +49,7 @@ class PushSubscriptionHelper(
|
|||
if(account.notification_mention) n += 8
|
||||
if(account.isMisskey && account.notification_reaction) n += 16
|
||||
if(account.notification_vote) n += 32
|
||||
if(account.notification_follow_request) n += 64
|
||||
this.flags = n
|
||||
}
|
||||
|
||||
|
@ -373,6 +374,7 @@ class PushSubscriptionHelper(
|
|||
put("reblog", account.notification_boost)
|
||||
put("mention", account.notification_mention)
|
||||
put("poll", account.notification_vote)
|
||||
put( "follow_request",account.notification_follow_request)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -568,6 +568,14 @@
|
|||
android:text="@string/follow" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/setting_row_form">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbNotificationFollowRequest"
|
||||
style="@style/setting_horizontal_stretch"
|
||||
android:text="@string/follow_request" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/setting_row_form">
|
||||
|
||||
<CheckBox
|
||||
|
|
|
@ -997,5 +997,6 @@
|
|||
<string name="language_is">言語: %1$s</string>
|
||||
<string name="always_show_language">常に言語を表示する</string>
|
||||
<string name="justify_window_content_portrait">ウィンドウ内容を揃える(縦画面)(アプリ再起動が必要)</string>
|
||||
<string name="follow_request">フォローリクエスト</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -993,4 +993,5 @@
|
|||
<string name="drawable_list" translatable="false">Drawable list</string>
|
||||
<string name="developer_options" translatable="false">Developer options</string>
|
||||
<string name="justify_window_content_portrait">Justify window content (Portrait)(app restart required)</string>
|
||||
<string name="follow_request">Follow request</string>
|
||||
</resources>
|
Loading…
Reference in New Issue