diff --git a/app/src/main/java/io/github/akiomik/seiun/model/app/bsky/notification/NotificationRecord.kt b/app/src/main/java/io/github/akiomik/seiun/model/app/bsky/notification/NotificationRecord.kt index cfd1b76..072e6e1 100644 --- a/app/src/main/java/io/github/akiomik/seiun/model/app/bsky/notification/NotificationRecord.kt +++ b/app/src/main/java/io/github/akiomik/seiun/model/app/bsky/notification/NotificationRecord.kt @@ -3,9 +3,13 @@ package io.github.akiomik.seiun.model.app.bsky.notification import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import io.github.akiomik.seiun.model.app.bsky.feed.PostReplyRef +import io.github.akiomik.seiun.model.com.atproto.repo.StrongRef import java.util.* -// NOTE: app.bsky.graph.follow or app.bsky.feed.vote or app.bsky.feed.repost +// app.bsky.graph.follow (subject, createdAt) or +// app.bsky.feed.like (subject, createdAt) or +// app.bsky.feed.repost (subject, createdAt) or +// app.bsky.feed.post (text, reply, createdAt) @JsonClass(generateAdapter = true) data class NotificationRecord( @Json(name = "\$type") @@ -13,6 +17,5 @@ data class NotificationRecord( val createdAt: Date, val text: String? = null, val reply: PostReplyRef? = null, -// val direction: VoteDirection? = null, - val subject: NotificationSubject? = null + val subject: StrongRef? = null ) diff --git a/app/src/main/java/io/github/akiomik/seiun/model/app/bsky/notification/NotificationSubject.kt b/app/src/main/java/io/github/akiomik/seiun/model/app/bsky/notification/NotificationSubject.kt deleted file mode 100644 index c5cf725..0000000 --- a/app/src/main/java/io/github/akiomik/seiun/model/app/bsky/notification/NotificationSubject.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.github.akiomik.seiun.model.app.bsky.notification - -import com.squareup.moshi.JsonClass - -// app.bsky.feed.repost or app.bsky.feed.vote or -@JsonClass(generateAdapter = true) -data class NotificationSubject( - val uri: String? = null, - val cid: String? = null, - val did: String? = null, - val declarationCid: String? = null -) diff --git a/app/src/main/java/io/github/akiomik/seiun/ui/feed/FeedPost.kt b/app/src/main/java/io/github/akiomik/seiun/ui/feed/FeedPost.kt index 957c837..d89de89 100644 --- a/app/src/main/java/io/github/akiomik/seiun/ui/feed/FeedPost.kt +++ b/app/src/main/java/io/github/akiomik/seiun/ui/feed/FeedPost.kt @@ -215,15 +215,15 @@ private fun RepostIndicator(viewPost: FeedViewPost) { } @Composable -private fun UpvoteIndicator(viewPost: FeedViewPost) { +private fun LikeIndicator(viewPost: FeedViewPost) { val viewModel: PostViewModel = viewModel() - val upvoted = viewPost.post.viewer?.like != null - val color = if (upvoted) { + val liked = viewPost.post.viewer?.like != null + val color = if (liked) { Red700 } else { Color.Gray } - val icon = if (upvoted) { + val icon = if (liked) { Icons.Sharp.Favorite } else { Icons.Sharp.FavoriteBorder @@ -232,12 +232,12 @@ private fun UpvoteIndicator(viewPost: FeedViewPost) { TextButton( onClick = { - if (upvoted) { - viewModel.cancelVote(feedPost = viewPost, onError = { + if (liked) { + viewModel.cancelLike(feedPost = viewPost, onError = { Toast.makeText(context, it.toString(), Toast.LENGTH_LONG).show() }) } else { - viewModel.upvote(feedPost = viewPost, onError = { + viewModel.like(feedPost = viewPost, onError = { Toast.makeText(context, it.toString(), Toast.LENGTH_LONG).show() }) } @@ -369,7 +369,7 @@ private fun FeedPostContent(viewPost: FeedViewPost) { ) { ReplyIndicator(viewPost = viewPost) RepostIndicator(viewPost = viewPost) - UpvoteIndicator(viewPost = viewPost) + LikeIndicator(viewPost = viewPost) MenuButton(viewPost = viewPost) } Text( diff --git a/app/src/main/java/io/github/akiomik/seiun/ui/notification/NoficationListItem.kt b/app/src/main/java/io/github/akiomik/seiun/ui/notification/NoficationListItem.kt index 7327ea5..29e2879 100644 --- a/app/src/main/java/io/github/akiomik/seiun/ui/notification/NoficationListItem.kt +++ b/app/src/main/java/io/github/akiomik/seiun/ui/notification/NoficationListItem.kt @@ -37,7 +37,7 @@ private fun Avatar(notification: Notification, onClicked: (String) -> Unit) { } @Composable -private fun VoteItem(notification: Notification, onProfileClick: (String) -> Unit) { +private fun LikeItem(notification: Notification, onProfileClick: (String) -> Unit) { val createdAt = DateFormat.format( DATETIME_FORMAT, notification.record.createdAt.toInstant().toEpochMilli() @@ -118,7 +118,7 @@ private fun FollowItem(notification: Notification, onProfileClick: (String) -> U } @Composable -private fun InviteItem(notification: Notification, onProfileClick: (String) -> Unit) { +private fun MentionItem(notification: Notification, onProfileClick: (String) -> Unit) { val createdAt = DateFormat.format( DATETIME_FORMAT, notification.record.createdAt.toInstant().toEpochMilli() @@ -129,7 +129,7 @@ private fun InviteItem(notification: Notification, onProfileClick: (String) -> U headlineContent = { Text( stringResource( - R.string.notification_invited, + R.string.notification_mentioned, notification.author.displayName ?: notification.author.handle ) ) @@ -145,7 +145,7 @@ private fun InviteItem(notification: Notification, onProfileClick: (String) -> U } @Composable -private fun MentionItem(notification: Notification, onProfileClick: (String) -> Unit) { +private fun ReplyItem(notification: Notification, onProfileClick: (String) -> Unit) { val createdAt = DateFormat.format( DATETIME_FORMAT, notification.record.createdAt.toInstant().toEpochMilli() @@ -156,7 +156,7 @@ private fun MentionItem(notification: Notification, onProfileClick: (String) -> headlineContent = { Text( stringResource( - R.string.notification_mentioned, + R.string.notification_replied, notification.author.displayName ?: notification.author.handle ) ) @@ -172,7 +172,7 @@ private fun MentionItem(notification: Notification, onProfileClick: (String) -> } @Composable -private fun ReplyItem(notification: Notification, onProfileClick: (String) -> Unit) { +private fun QuoteItem(notification: Notification, onProfileClick: (String) -> Unit) { val createdAt = DateFormat.format( DATETIME_FORMAT, notification.record.createdAt.toInstant().toEpochMilli() @@ -183,7 +183,7 @@ private fun ReplyItem(notification: Notification, onProfileClick: (String) -> Un headlineContent = { Text( stringResource( - R.string.notification_replied, + R.string.notification_quoted, notification.author.displayName ?: notification.author.handle ) ) @@ -210,13 +210,13 @@ fun NotificationListItem(notification: Notification, onProfileClick: (String) -> .fillMaxWidth() ) { when (notification.reason) { - "vote" -> VoteItem(notification = notification, onProfileClick = onProfileClick) + "like" -> LikeItem(notification = notification, onProfileClick = onProfileClick) "repost" -> RepostItem(notification = notification, onProfileClick = onProfileClick) "follow" -> FollowItem(notification = notification, onProfileClick = onProfileClick) - "invite" -> InviteItem(notification = notification, onProfileClick = onProfileClick) "mention" -> MentionItem(notification = notification, onProfileClick = onProfileClick) "reply" -> ReplyItem(notification = notification, onProfileClick = onProfileClick) + "quote" -> QuoteItem(notification = notification, onProfileClick = onProfileClick) else -> {} } } diff --git a/app/src/main/java/io/github/akiomik/seiun/viewmodels/PostViewModel.kt b/app/src/main/java/io/github/akiomik/seiun/viewmodels/PostViewModel.kt index 2a9da60..33ce7bd 100644 --- a/app/src/main/java/io/github/akiomik/seiun/viewmodels/PostViewModel.kt +++ b/app/src/main/java/io/github/akiomik/seiun/viewmodels/PostViewModel.kt @@ -11,7 +11,7 @@ class PostViewModel : ApplicationViewModel() { private val userRepository = SeiunApplication.instance!!.userRepository private val postFeedRepository = SeiunApplication.instance!!.postFeedRepository - fun upvote( + fun like( feedPost: FeedViewPost, onSuccess: () -> Unit = {}, onError: (Throwable) -> Unit = {} @@ -23,7 +23,7 @@ class PostViewModel : ApplicationViewModel() { ) } - fun cancelVote( + fun cancelLike( feedPost: FeedViewPost, onSuccess: () -> Unit = {}, onError: (Throwable) -> Unit = {} diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 048b5ee..c888b1f 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -45,7 +45,7 @@ %1$s があなたの投稿にいいねしました %1$s があなたの投稿をリポストしました %1$s があなたをフォローしました - %1$s があなたを招待しました + %1$s があなたを投稿を引用しました %1$s があなたにメンションしました %1$s があなたに返信しました 投稿しました diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5132275..da10dec 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -44,7 +44,7 @@ %1$s liked your post %1$s reposted your post %1$s is followed you - %1$s invited you + %1$s quoted your post %1$s mentioned you %1$s replied to you Your post has been published