mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-02-04 04:37:40 +01:00
リアクションカラム。
This commit is contained in:
parent
eaed84d8a4
commit
c0411f4e06
@ -688,6 +688,36 @@ enum class ColumnType(
|
||||
gapDirection = gapDirectionMastodonWorkaround,
|
||||
),
|
||||
|
||||
|
||||
REACTIONS(
|
||||
42,
|
||||
iconId = { R.drawable.ic_face },
|
||||
name1 = { it.getString(R.string.reactions) },
|
||||
bAllowPseudo = false,
|
||||
bAllowMisskey = false,
|
||||
|
||||
loading = { client ->
|
||||
if (isMisskey) {
|
||||
TootApiResult("misskey has no api to list your reactions")
|
||||
} else {
|
||||
getStatusList(client, ApiPath.PATH_REACTIONS)
|
||||
}
|
||||
},
|
||||
|
||||
refresh = { client ->
|
||||
getStatusList(client, ApiPath.PATH_REACTIONS)
|
||||
},
|
||||
|
||||
gap = { client ->
|
||||
getStatusList(
|
||||
client,
|
||||
ApiPath.PATH_REACTIONS,
|
||||
mastodonFilterByIdRange = false
|
||||
)
|
||||
},
|
||||
gapDirection = gapDirectionMastodonWorkaround,
|
||||
),
|
||||
|
||||
BOOKMARKS(
|
||||
37,
|
||||
iconId = { R.drawable.ic_bookmark },
|
||||
|
@ -22,14 +22,15 @@ import androidx.drawerlayout.widget.DrawerLayout
|
||||
import jp.juggler.subwaytooter.action.Action_Account
|
||||
import jp.juggler.subwaytooter.action.Action_App
|
||||
import jp.juggler.subwaytooter.action.Action_Instance
|
||||
import jp.juggler.subwaytooter.api.TootApiCallback
|
||||
import jp.juggler.subwaytooter.api.TootApiClient
|
||||
import jp.juggler.subwaytooter.api.entity.TootInstance
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.subwaytooter.util.VersionString
|
||||
import jp.juggler.subwaytooter.util.openBrowser
|
||||
import jp.juggler.util.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.*
|
||||
import org.jetbrains.anko.backgroundColor
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
@ -265,6 +266,26 @@ class SideMenuAdapter(
|
||||
Item(icon = R.drawable.ic_bookmark, title = R.string.bookmarks) {
|
||||
Action_Account.timeline(this, defaultInsertPosition, ColumnType.BOOKMARKS)
|
||||
},
|
||||
Item(icon = R.drawable.ic_face, title = R.string.fedibird_reactions) {
|
||||
Action_Account.timelineWithFilter(this, defaultInsertPosition, ColumnType.REACTIONS){
|
||||
var cancelled = false
|
||||
try {
|
||||
val client = TootApiClient(context = this, callback = object:TootApiCallback{
|
||||
override val isApiCancelled: Boolean
|
||||
get() = cancelled
|
||||
})
|
||||
withTimeout(5) {
|
||||
client.account = it
|
||||
val (ti, _) = TootInstance.get(client)
|
||||
ti?.fedibird_capabilities?.contains("emoji_reaction") == true
|
||||
}
|
||||
}catch(ex:Throwable){
|
||||
cancelled = true
|
||||
ActMain.log.e("${it.apiHost}")
|
||||
false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Item(icon = R.drawable.ic_account_box, title = R.string.profile) {
|
||||
Action_Account.timeline(this, defaultInsertPosition, ColumnType.PROFILE)
|
||||
|
@ -13,6 +13,9 @@ import jp.juggler.subwaytooter.table.UserRelation
|
||||
import jp.juggler.subwaytooter.util.LinkHelper
|
||||
import jp.juggler.subwaytooter.util.openBrowser
|
||||
import jp.juggler.util.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
object Action_Account {
|
||||
|
||||
@ -215,6 +218,49 @@ object Action_Account {
|
||||
) { ai -> ActAccountSetting.open(activity, ai, ActMain.REQUEST_CODE_ACCOUNT_SETTING) }
|
||||
}
|
||||
|
||||
// アカウントを選んでタイムラインカラムを追加
|
||||
fun timelineWithFilter(
|
||||
activity: ActMain,
|
||||
pos: Int,
|
||||
type: ColumnType,
|
||||
args: Array<out Any> = emptyArray(),
|
||||
filter: suspend(SavedAccount)->Boolean
|
||||
) {
|
||||
activity.launch{
|
||||
val accountList = withContext(Dispatchers.IO){
|
||||
SavedAccount.loadAccountList(activity)
|
||||
.filter{
|
||||
if( it.isPseudo && !type.bAllowPseudo) false
|
||||
else if( it.isMisskey && !type.bAllowMisskey) false
|
||||
else if( it.isMastodon && !type.bAllowMastodon) false
|
||||
else filter(it)
|
||||
}
|
||||
}.toMutableList()
|
||||
AccountPicker.pick(
|
||||
activity,
|
||||
accountListArg = accountList,
|
||||
bAuto = true,
|
||||
message = activity.getString(
|
||||
R.string.account_picker_add_timeline_of,
|
||||
type.name1(activity)
|
||||
)
|
||||
) { ai ->
|
||||
when (type) {
|
||||
|
||||
ColumnType.PROFILE -> {
|
||||
val id = ai.loginAccount?.id
|
||||
if (id != null) activity.addColumn(pos, ai, type, id)
|
||||
}
|
||||
|
||||
ColumnType.PROFILE_DIRECTORY ->
|
||||
activity.addColumn(pos, ai, type, ai.apiHost)
|
||||
|
||||
else -> activity.addColumn(pos, ai, type, *args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// アカウントを選んでタイムラインカラムを追加
|
||||
fun timeline(
|
||||
activity: ActMain,
|
||||
|
@ -8,6 +8,7 @@ object ApiPath {
|
||||
|
||||
const val PATH_FAVOURITES = "/api/v1/favourites?limit=$READ_LIMIT"
|
||||
const val PATH_BOOKMARKS = "/api/v1/bookmarks?limit=$READ_LIMIT"
|
||||
const val PATH_REACTIONS = "/api/v1/emoji_reactions?limit=$READ_LIMIT"
|
||||
|
||||
// アカウントのリストを返すAPI
|
||||
const val PATH_ACCOUNT_FOLLOWING =
|
||||
|
@ -33,7 +33,7 @@ object AccountPicker {
|
||||
bAllowMastodon: Boolean = true,
|
||||
bAuto: Boolean = false,
|
||||
message: String? = null,
|
||||
accountListArg: ArrayList<SavedAccount>? = null,
|
||||
accountListArg: MutableList<SavedAccount>? = null,
|
||||
dismiss_callback: DialogInterfaceCallback? = null,
|
||||
extra_callback: (LinearLayout, Int, Int) -> Unit = { _, _, _ -> },
|
||||
callback: SavedAccountCallback
|
||||
|
@ -41,7 +41,7 @@ class PushSubscriptionHelper(
|
||||
account.notification_favourite.booleanToInt(2) +
|
||||
account.notification_follow.booleanToInt(4) +
|
||||
account.notification_mention.booleanToInt(8) +
|
||||
(account.isMisskey && account.notification_reaction).booleanToInt(16) +
|
||||
account.notification_reaction.booleanToInt(16) +
|
||||
account.notification_vote.booleanToInt(32) +
|
||||
account.notification_follow_request.booleanToInt(64) +
|
||||
account.notification_post.booleanToInt(128)
|
||||
@ -480,7 +480,7 @@ class PushSubscriptionHelper(
|
||||
})
|
||||
put("data", JsonObject().apply {
|
||||
put("alerts", newAlerts)
|
||||
account.push_policy?.let{ put("policy",it )}
|
||||
account.push_policy?.let { put("policy", it) }
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1079,5 +1079,7 @@
|
||||
<string name="confirm_mail_description">確認メールの再送を要求した後の手順:\n- あなたのメーラーで新着メールが届くのを確認する。\n- メール中の確認リンクを開く。\n- このダイアログを閉じてカラムをリロードする。</string>
|
||||
<string name="push_notification_filter">プッシュ通知フィルタ(Mastodon 3.4.0以降。プッシュ通知の更新が必要)</string>
|
||||
<string name="no_one">誰もいない</string>
|
||||
<string name="fedibird_reactions">リアクション (Fedibird)</string>
|
||||
<string name="reactions">リアクション</string>
|
||||
|
||||
</resources>
|
||||
|
@ -1093,4 +1093,6 @@
|
||||
<string name="confirm_mail_description">After requesting resending confirm E-mail,\n- please check the mail on your mailer.\n- open confirm link in the mail.\n- close this dialog and reload column.</string>
|
||||
<string name="push_notification_filter">Push notification filter (Mastodon 3.4.0+, requires update push subscription)</string>
|
||||
<string name="no_one">No one</string>
|
||||
<string name="fedibird_reactions">Reactions (Fedibird)</string>
|
||||
<string name="reactions">Reactions</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user