Refactor notifications to Kotlin & paging (#4026)

This refactors the NotificationsFragment and related classes to Kotlin &
paging.
While trying to preserve as much of the original behavior as possible,
this adds the following improvements as well:
- The "show notifications filter" preference was added again
- The "load more" button now has a background ripple effect when clicked
- The "legal" report category of Mastodon 4.2 is now supported in report
notifications
- Unknown notifications now display "unknown notification type" instead
of an empty line

Other code quality improvements:
- All views from xml layouts are now referenced via ViewBindings
- the classes responsible for showing system notifications were moved to
a new package `systemnotifications` while the classes from this
refactoring are in `notifications`
- the id of the local Tusky account is now called `tuskyAccountId` in
all places I could find

closes https://github.com/tuskyapp/Tusky/issues/3429

---------

Co-authored-by: Zongle Wang <wangzongler@gmail.com>
This commit is contained in:
Konrad Pozniak 2024-05-03 18:27:10 +02:00 committed by GitHub
commit b2c0b18c8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
121 changed files with 6992 additions and 4654 deletions

View file

@ -75,7 +75,6 @@ data class Notification(
REPORT("admin.report", R.string.notification_report_name);
companion object {
@JvmStatic
fun byString(s: String): Type {
return entries.firstOrNull { it.presentation == s } ?: UNKNOWN
}
@ -85,25 +84,9 @@ data class Notification(
listOf(MENTION, REBLOG, FAVOURITE, FOLLOW, FOLLOW_REQUEST, POLL, STATUS, SIGN_UP, UPDATE, REPORT)
}
override fun toString(): String {
return presentation
}
override fun toString() = presentation
}
override fun hashCode(): Int {
return id.hashCode()
}
override fun equals(other: Any?): Boolean {
if (other !is Notification) {
return false
}
return other.id == this.id
}
/** Helper for Java */
fun copyWithStatus(status: Status?): Notification = copy(status = status)
// for Pleroma compatibility that uses Mention type
fun rewriteToStatusTypeIfNeeded(accountId: String): Notification {
if (type == Type.MENTION && status != null) {

View file

@ -47,7 +47,7 @@ data class Status(
@Json(name = "media_attachments") val attachments: List<Attachment>,
val mentions: List<Mention>,
// Use null to mark the absence of tags because of semantic differences in LinkHelper
val tags: List<HashTag>? = null,
val tags: List<HashTag> = emptyList(),
val application: Application? = null,
val pinned: Boolean = false,
val muted: Boolean = false,
@ -66,13 +66,6 @@ data class Status(
val actionableStatus: Status
get() = reblog ?: this
/** Helpers for Java */
fun copyWithFavourited(favourited: Boolean): Status = copy(favourited = favourited)
fun copyWithReblogged(reblogged: Boolean): Status = copy(reblogged = reblogged)
fun copyWithBookmarked(bookmarked: Boolean): Status = copy(bookmarked = bookmarked)
fun copyWithPoll(poll: Poll?): Status = copy(poll = poll)
fun copyWithPinned(pinned: Boolean): Status = copy(pinned = pinned)
@JsonClass(generateAdapter = false)
enum class Visibility(val num: Int) {
UNKNOWN(0),