From cddb24677a12495b97270e97658c4a32821b9eb6 Mon Sep 17 00:00:00 2001 From: tateisu Date: Tue, 17 Dec 2019 00:56:27 +0900 Subject: [PATCH] =?UTF-8?q?(Mastodon=E9=96=8B=E7=99=BA=E7=89=88)=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=AD=E3=83=BC=E3=83=AA=E3=82=AF=E3=82=A8=E3=82=B9?= =?UTF-8?q?=E3=83=88=E9=80=9A=E7=9F=A5=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../juggler/subwaytooter/ActAccountSetting.kt | 7 ++++ .../main/java/jp/juggler/subwaytooter/App1.kt | 3 +- .../java/jp/juggler/subwaytooter/Column.kt | 37 ++++++++++++------- .../jp/juggler/subwaytooter/ItemViewHolder.kt | 3 +- .../jp/juggler/subwaytooter/PollingWorker.kt | 7 +++- .../subwaytooter/action/ActionUtils.kt | 1 + .../api/entity/TootNotification.kt | 10 ++++- .../subwaytooter/table/SavedAccount.kt | 25 ++++++++++++- .../util/PushSubscriptionHelper.kt | 2 + .../main/res/layout/act_account_setting.xml | 8 ++++ app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 12 files changed, 84 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/jp/juggler/subwaytooter/ActAccountSetting.kt b/app/src/main/java/jp/juggler/subwaytooter/ActAccountSetting.kt index 0c3c4abf..4ee5d0b5 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ActAccountSetting.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/ActAccountSetting.kt @@ -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 diff --git a/app/src/main/java/jp/juggler/subwaytooter/App1.kt b/app/src/main/java/jp/juggler/subwaytooter/App1.kt index 44f02efc..940aeec6 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/App1.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/App1.kt @@ -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, diff --git a/app/src/main/java/jp/juggler/subwaytooter/Column.kt b/app/src/main/java/jp/juggler/subwaytooter/Column.kt index a169c76d..a5e62451 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/Column.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/Column.kt @@ -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 -> diff --git a/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.kt b/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.kt index 1011d517..7ede22f1 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.kt @@ -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, diff --git a/app/src/main/java/jp/juggler/subwaytooter/PollingWorker.kt b/app/src/main/java/jp/juggler/subwaytooter/PollingWorker.kt index 6454ebcf..64e6a4f6 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/PollingWorker.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/PollingWorker.kt @@ -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 diff --git a/app/src/main/java/jp/juggler/subwaytooter/action/ActionUtils.kt b/app/src/main/java/jp/juggler/subwaytooter/action/ActionUtils.kt index 559f2242..d66e3b21 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/action/ActionUtils.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/action/ActionUtils.kt @@ -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 diff --git a/app/src/main/java/jp/juggler/subwaytooter/api/entity/TootNotification.kt b/app/src/main/java/jp/juggler/subwaytooter/api/entity/TootNotification.kt index 0f4edc79..da1957ee 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/api/entity/TootNotification.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/api/entity/TootNotification.kt @@ -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"))) diff --git a/app/src/main/java/jp/juggler/subwaytooter/table/SavedAccount.kt b/app/src/main/java/jp/juggler/subwaytooter/table/SavedAccount.kt index 2873c298..8baea2ae 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/table/SavedAccount.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/table/SavedAccount.kt @@ -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 diff --git a/app/src/main/java/jp/juggler/subwaytooter/util/PushSubscriptionHelper.kt b/app/src/main/java/jp/juggler/subwaytooter/util/PushSubscriptionHelper.kt index 26d4d420..e47377e1 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/util/PushSubscriptionHelper.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/util/PushSubscriptionHelper.kt @@ -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) }) }) } diff --git a/app/src/main/res/layout/act_account_setting.xml b/app/src/main/res/layout/act_account_setting.xml index b95646ef..1a23936a 100644 --- a/app/src/main/res/layout/act_account_setting.xml +++ b/app/src/main/res/layout/act_account_setting.xml @@ -568,6 +568,14 @@ android:text="@string/follow" /> + + + + + 言語: %1$s 常に言語を表示する ウィンドウ内容を揃える(縦画面)(アプリ再起動が必要) + フォローリクエスト diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e6aedd72..30bcc54a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -993,4 +993,5 @@ Drawable list Developer options Justify window content (Portrait)(app restart required) + Follow request \ No newline at end of file