From 5556d66fdd1e1ff78b03de799ca1170f7a7852f9 Mon Sep 17 00:00:00 2001 From: mcc Date: Wed, 26 Jul 2023 14:53:15 -0400 Subject: [PATCH 1/4] Comment fields in ConversationEntity related to expanding and collapsing content --- .../tusky/components/conversation/ConversationEntity.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt index f830b5bd98..149edd9d17 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt @@ -87,14 +87,20 @@ data class ConversationStatusEntity( val repliesCount: Int, val favourited: Boolean, val bookmarked: Boolean, + // If true, attachments have been marked as sensitive. val sensitive: Boolean, + // If nonempty, post text has a spoiler/content warning. val spoilerText: String, val attachments: List, val mentions: List, val tags: List?, + // If sensitive is true, then this is true when the user has chosen to expose the attachments. val showingHiddenContent: Boolean, + // If spoilerText is nonempty, then this is true when the user has chosen to show the text. val expanded: Boolean, + // If content is long (see shouldTrimStatus()), then this is *false* when the user has chosen to show all content. val collapsed: Boolean, + // If true, the user has chosen not to see further notifications for this status. val muted: Boolean, val poll: Poll?, val language: String? From 98bac23431ae3ebc23a8a0212e468329edc90574 Mon Sep 17 00:00:00 2001 From: mcc Date: Wed, 26 Jul 2023 15:54:56 -0400 Subject: [PATCH 2/4] More explanatory comments of expanded, collapsed, muted, filtered, details in all Status-representing classes. --- .../conversation/ConversationEntity.kt | 15 +++++---- .../com/keylesspalace/tusky/entity/Status.kt | 6 ++++ .../tusky/viewdata/StatusViewData.kt | 33 +++++++++++++++---- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt index 149edd9d17..2771bfcd02 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationEntity.kt @@ -29,6 +29,7 @@ import com.keylesspalace.tusky.entity.TimelineAccount import com.keylesspalace.tusky.viewdata.StatusViewData import java.util.Date +/** A reply-tree of statuses which have been saved to disk. */ @Entity(primaryKeys = ["id", "accountId"]) @TypeConverters(Converters::class) data class ConversationEntity( @@ -50,6 +51,7 @@ data class ConversationEntity( } } +/** The account information associated with a status saved to disk. */ data class ConversationAccountEntity( val id: String, val localUsername: String, @@ -72,6 +74,7 @@ data class ConversationAccountEntity( } } +/** A previously-displayed status which has been saved to disk. */ @TypeConverters(Converters::class) data class ConversationStatusEntity( val id: String, @@ -87,20 +90,20 @@ data class ConversationStatusEntity( val repliesCount: Int, val favourited: Boolean, val bookmarked: Boolean, - // If true, attachments have been marked as sensitive. + /** If true, post attachments are marked as sensitive content. */ val sensitive: Boolean, - // If nonempty, post text has a spoiler/content warning. + /** If nonempty, post text has a spoiler/content warning. */ val spoilerText: String, val attachments: List, val mentions: List, val tags: List?, - // If sensitive is true, then this is true when the user has chosen to expose the attachments. + /** If sensitive is true, then this is true when the user has chosen to expose the attachments. */ val showingHiddenContent: Boolean, - // If spoilerText is nonempty, then this is true when the user has chosen to show the text. + /** If spoilerText is nonempty, then this is true when the user has chosen to show the text. */ val expanded: Boolean, - // If content is long (see shouldTrimStatus()), then this is *false* when the user has chosen to show all content. + /** If content is long (see shouldTrimStatus()), then this is *false* when the user has chosen to show all content. */ val collapsed: Boolean, - // If true, the user has chosen not to see further notifications for this status. + /** If true, the user has chosen not to see further notifications for this status. */ val muted: Boolean, val poll: Poll?, val language: String? diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt index 0b9a0796d5..55fe9b26ea 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt @@ -21,6 +21,7 @@ import com.google.gson.annotations.SerializedName import com.keylesspalace.tusky.util.parseAsMastodonHtml import java.util.Date +/** A Mastodon status as the server sees it. (Distinct from ConversationStatusEntity or StatusViewData.Concrete). */ data class Status( val id: String, val url: String?, // not present if it's reblog @@ -38,7 +39,9 @@ data class Status( val reblogged: Boolean, val favourited: Boolean, val bookmarked: Boolean, + /** If true, post attachments are marked as sensitive content. */ val sensitive: Boolean, + /** If nonempty, post text has a spoiler/content warning. */ @SerializedName("spoiler_text") val spoilerText: String, val visibility: Visibility, @SerializedName("media_attachments") val attachments: List, @@ -46,16 +49,19 @@ data class Status( val tags: List?, val application: Application?, val pinned: Boolean?, + /** If true, the user has chosen not to see further notifications for this status. */ val muted: Boolean?, val poll: Poll?, val card: Card?, val language: String?, + /** If true, the server reports a user-custom content filter applies to the status. */ val filtered: List? ) { val actionableId: String get() = reblog?.id ?: id + /** If status is a reblog, the "true" status, otherwise self. */ val actionableStatus: Status get() = reblog ?: this diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt index 5ef3ef3730..76b5131390 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt @@ -25,24 +25,40 @@ import com.keylesspalace.tusky.util.shouldTrimStatus /** * Created by charlag on 11/07/2017. * - * Class to represent data required to display either a notification or a placeholder. + * Class to represent data required to display either a status or a placeholder ("Load More" bar). * It is either a [StatusViewData.Concrete] or a [StatusViewData.Placeholder]. + * Can be created either from a ConversationStatusEntity, or by helpers in ViewDataUtils. */ sealed class StatusViewData { abstract val id: String var filterAction: Filter.Action = Filter.Action.NONE data class Concrete( + /** The Mastodon-API level information about the status. */ val status: Status, + /** + * If StatusViewData spoilerText is nonempty, specifies whether the text content of this post + * is currently hidden. + * + * @return If true, post is shown. If false, it is hidden. + */ val isExpanded: Boolean, + /** + * Specifies whether attachments are currently hidden as sensitive. + * + * @return If true, attachments are shown. If false, they is hidden. + */ val isShowingContent: Boolean, /** - * Specifies whether the content of this post is currently limited in visibility to the first - * 500 characters or not. + * If StatusViewData isCollapsible, specifies whether the content of this post is currently + * limited in visibility to the first characters or not. * - * @return Whether the post is collapsed or fully expanded. + * @return If true, post is collapsed. If false, it is fully expanded. */ val isCollapsed: Boolean, + /** + * If true, the status is "big" (has been selected by the user for detailed display). + */ val isDetailed: Boolean = false ) : StatusViewData() { override val id: String @@ -50,16 +66,21 @@ sealed class StatusViewData { /** * Specifies whether the content of this post is long enough to be automatically - * collapsed or if it should show all content regardless. + * collapsed or if it should show all content regardless. (See shouldTrimStatus()) * * @return Whether the post is collapsible or never collapsed. */ val isCollapsible: Boolean - val content: Spanned + /** + * @return If nonempty, the spoiler/content warning text. If empty, there is no warning. + */ val spoilerText: String val username: String + /** + * @return The "true" status (same as status unless this is a reblog) + */ val actionable: Status get() = status.actionableStatus From be4573b55416a096128ea0601a53b527df415be3 Mon Sep 17 00:00:00 2001 From: mcc Date: Wed, 26 Jul 2023 16:07:20 -0400 Subject: [PATCH 3/4] ktLint fixes --- .../java/com/keylesspalace/tusky/viewdata/StatusViewData.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt index 76b5131390..51dadffdfb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt @@ -72,13 +72,13 @@ sealed class StatusViewData { */ val isCollapsible: Boolean val content: Spanned - /** + /** * @return If nonempty, the spoiler/content warning text. If empty, there is no warning. */ val spoilerText: String val username: String - /** + /** * @return The "true" status (same as status unless this is a reblog) */ val actionable: Status From 2629b2f550cf8b2d3ab39656e43578fad974b9de Mon Sep 17 00:00:00 2001 From: mcc Date: Wed, 26 Jul 2023 16:30:53 -0400 Subject: [PATCH 4/4] ktLint fixes (2) --- .../main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt index 51dadffdfb..1b1690875c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.kt @@ -72,6 +72,7 @@ sealed class StatusViewData { */ val isCollapsible: Boolean val content: Spanned + /** * @return If nonempty, the spoiler/content warning text. If empty, there is no warning. */