fix: Don't crash on relationship severance events (#1092)
Previous code was missing the JSON name of the event, so it wasn't present when it should have been, resulting in a crash. Also, the Mastodon documentation is incorrect about the relationship count, which is instead represented as two properties, one for followers and one for following. So model that, and display them separately in the UI. Fixes #1086
This commit is contained in:
parent
710e209e34
commit
37169d96c5
|
@ -48,10 +48,16 @@ class SeveredRelationshipsViewHolder(
|
||||||
|
|
||||||
binding.datetime.text = getRelativeTimeSpanString(itemView.context, event.createdAt.time, System.currentTimeMillis())
|
binding.datetime.text = getRelativeTimeSpanString(itemView.context, event.createdAt.time, System.currentTimeMillis())
|
||||||
|
|
||||||
binding.notificationSummary.text = itemView.context.resources.getQuantityString(
|
binding.notificationFollowersCount.text = itemView.context.resources.getQuantityString(
|
||||||
R.plurals.notification_severed_relationships_summary_report_fmt,
|
R.plurals.notification_severed_relationships_summary_followers_fmt,
|
||||||
event.relationshipsCount,
|
event.followersCount,
|
||||||
event.relationshipsCount,
|
event.followersCount,
|
||||||
|
)
|
||||||
|
|
||||||
|
binding.notificationFollowingCount.text = itemView.context.resources.getQuantityString(
|
||||||
|
R.plurals.notification_severed_relationships_summary_following_fmt,
|
||||||
|
event.followingCount,
|
||||||
|
event.followingCount,
|
||||||
)
|
)
|
||||||
|
|
||||||
val resourceId = when (event.type) {
|
val resourceId = when (event.type) {
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
tools:ignore="SelectableText" />
|
tools:ignore="SelectableText" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/notification_summary"
|
android:id="@+id/notification_followers_count"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
@ -74,7 +74,22 @@
|
||||||
android:textSize="?attr/status_text_medium"
|
android:textSize="?attr/status_text_medium"
|
||||||
app:layout_constraintStart_toStartOf="@+id/notification_top_text"
|
app:layout_constraintStart_toStartOf="@+id/notification_top_text"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/notification_top_text"
|
app:layout_constraintTop_toBottomOf="@+id/notification_top_text"
|
||||||
tools:text="2 relationships"
|
tools:text="2 followers"
|
||||||
|
tools:ignore="SelectableText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/notification_following_count"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:hyphenationFrequency="full"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
android:lineSpacingMultiplier="1.1"
|
||||||
|
android:textColor="?android:textColorTertiary"
|
||||||
|
android:textSize="?attr/status_text_medium"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/notification_top_text"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/notification_followers_count"
|
||||||
|
tools:text="2 following"
|
||||||
tools:ignore="SelectableText" />
|
tools:ignore="SelectableText" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -88,8 +103,8 @@
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
android:textColor="?android:textColorTertiary"
|
android:textColor="?android:textColorTertiary"
|
||||||
android:textSize="?attr/status_text_medium"
|
android:textSize="?attr/status_text_medium"
|
||||||
app:layout_constraintStart_toStartOf="@+id/notification_summary"
|
app:layout_constraintStart_toStartOf="@+id/notification_top_text"
|
||||||
app:layout_constraintTop_toBottomOf="@id/notification_summary"
|
app:layout_constraintTop_toBottomOf="@id/notification_following_count"
|
||||||
tools:text="@string/notification_severed_relationships_domain_block_body"
|
tools:text="@string/notification_severed_relationships_domain_block_body"
|
||||||
tools:ignore="SelectableText" />
|
tools:ignore="SelectableText" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
|
@ -625,11 +625,6 @@
|
||||||
<string name="notification_severed_relationships_account_suspension_body">Un moderador suspendió la cuenta</string>
|
<string name="notification_severed_relationships_account_suspension_body">Un moderador suspendió la cuenta</string>
|
||||||
<string name="notification_severed_relationships_unknown_body">Motivo desconocido</string>
|
<string name="notification_severed_relationships_unknown_body">Motivo desconocido</string>
|
||||||
<string name="notification_severed_relationships_format">Se rompió la relación con <b>%1$s</b></string>
|
<string name="notification_severed_relationships_format">Se rompió la relación con <b>%1$s</b></string>
|
||||||
<plurals name="notification_severed_relationships_summary_report_fmt">
|
|
||||||
<item quantity="one">Se rompió %1$d relación</item>
|
|
||||||
<item quantity="many">Se rompieron %1$d relaciones</item>
|
|
||||||
<item quantity="other">Se rompieron %1$d relaciones</item>
|
|
||||||
</plurals>
|
|
||||||
<string name="notification_severed_relationships_name">Relaciones rotas</string>
|
<string name="notification_severed_relationships_name">Relaciones rotas</string>
|
||||||
<string name="notification_severed_relationships_description">Notificaciones de relaciones rotas</string>
|
<string name="notification_severed_relationships_description">Notificaciones de relaciones rotas</string>
|
||||||
<string name="poll_show_votes">Mostrar votos</string>
|
<string name="poll_show_votes">Mostrar votos</string>
|
||||||
|
|
|
@ -613,10 +613,6 @@
|
||||||
<string name="notification_severed_relationships_user_domain_block_body">Estit verkkotunnuksen</string>
|
<string name="notification_severed_relationships_user_domain_block_body">Estit verkkotunnuksen</string>
|
||||||
<string name="notification_severed_relationships_account_suspension_body">Moderaattori esti tilin</string>
|
<string name="notification_severed_relationships_account_suspension_body">Moderaattori esti tilin</string>
|
||||||
<string name="notification_severed_relationships_unknown_body">Tuntematon syy</string>
|
<string name="notification_severed_relationships_unknown_body">Tuntematon syy</string>
|
||||||
<plurals name="notification_severed_relationships_summary_report_fmt">
|
|
||||||
<item quantity="one">%1$d yhteys katkaistu</item>
|
|
||||||
<item quantity="other">%1$d yhteyttä katkaistu</item>
|
|
||||||
</plurals>
|
|
||||||
<string name="error_filter_missing_keyword">Tarvitaan vähintään yksi avainsana tai lauseke</string>
|
<string name="error_filter_missing_keyword">Tarvitaan vähintään yksi avainsana tai lauseke</string>
|
||||||
<string name="error_filter_missing_context">Tarvitaan vähintään yksi suodatettava asia</string>
|
<string name="error_filter_missing_context">Tarvitaan vähintään yksi suodatettava asia</string>
|
||||||
<string name="error_filter_missing_title">Otsikko vaaditaan</string>
|
<string name="error_filter_missing_title">Otsikko vaaditaan</string>
|
||||||
|
|
|
@ -604,10 +604,6 @@
|
||||||
<string name="translation_provider_fmt">%1$s</string>
|
<string name="translation_provider_fmt">%1$s</string>
|
||||||
<string name="update_dialog_neutral">Non avisarme para esta versión</string>
|
<string name="update_dialog_neutral">Non avisarme para esta versión</string>
|
||||||
<string name="translating">Traducindo…</string>
|
<string name="translating">Traducindo…</string>
|
||||||
<plurals name="notification_severed_relationships_summary_report_fmt">
|
|
||||||
<item quantity="one">%1$d relación perdida</item>
|
|
||||||
<item quantity="other">%1$d relacións perdidas</item>
|
|
||||||
</plurals>
|
|
||||||
<string name="announcement_date">%1$s %2$s</string>
|
<string name="announcement_date">%1$s %2$s</string>
|
||||||
<string name="load_newest_statuses">Cargar as publicacións máis recentes</string>
|
<string name="load_newest_statuses">Cargar as publicacións máis recentes</string>
|
||||||
<string name="pref_update_notification_frequency_never">Nunca</string>
|
<string name="pref_update_notification_frequency_never">Nunca</string>
|
||||||
|
|
|
@ -607,10 +607,6 @@
|
||||||
<string name="title_tab_public_trending_statuses">Innlegg</string>
|
<string name="title_tab_public_trending_statuses">Innlegg</string>
|
||||||
<string name="notification_severed_relationships_format">Brøt forholdet med <b>%1$s</b></string>
|
<string name="notification_severed_relationships_format">Brøt forholdet med <b>%1$s</b></string>
|
||||||
<string name="notification_severed_relationships_unknown_body">Ukjent årsak</string>
|
<string name="notification_severed_relationships_unknown_body">Ukjent årsak</string>
|
||||||
<plurals name="notification_severed_relationships_summary_report_fmt">
|
|
||||||
<item quantity="one">%1$d forhold brøt</item>
|
|
||||||
<item quantity="other">%1$d forhold brøt</item>
|
|
||||||
</plurals>
|
|
||||||
<string name="label_image">Bild</string>
|
<string name="label_image">Bild</string>
|
||||||
<string name="pref_title_font_family">Skriftfamilie</string>
|
<string name="pref_title_font_family">Skriftfamilie</string>
|
||||||
<string name="notification_severed_relationships_name">Brutte forhold</string>
|
<string name="notification_severed_relationships_name">Brutte forhold</string>
|
||||||
|
|
|
@ -92,9 +92,13 @@
|
||||||
<string name="notification_severed_relationships_user_domain_block_body">You blocked the domain</string>
|
<string name="notification_severed_relationships_user_domain_block_body">You blocked the domain</string>
|
||||||
<string name="notification_severed_relationships_account_suspension_body">A moderator suspended the account</string>
|
<string name="notification_severed_relationships_account_suspension_body">A moderator suspended the account</string>
|
||||||
<string name="notification_severed_relationships_unknown_body">Unknown reason</string>
|
<string name="notification_severed_relationships_unknown_body">Unknown reason</string>
|
||||||
<plurals name="notification_severed_relationships_summary_report_fmt">
|
<plurals name="notification_severed_relationships_summary_followers_fmt">
|
||||||
<item quantity="one">%1$d relationship severed</item>
|
<item quantity="one">%1$s follower removed</item>
|
||||||
<item quantity="other">%1$d relationships severed</item>
|
<item quantity="other">%1$s followers removed</item>
|
||||||
|
</plurals>
|
||||||
|
<plurals name="notification_severed_relationships_summary_following_fmt">
|
||||||
|
<item quantity="one">%1$s account you follow removed</item>
|
||||||
|
<item quantity="other">%1$s accounts you follow removed</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="notification_header_report_format">%s reported %s</string>
|
<string name="notification_header_report_format">%s reported %s</string>
|
||||||
<string name="notification_summary_report_format">%s · %d posts attached</string>
|
<string name="notification_summary_report_format">%s · %d posts attached</string>
|
||||||
|
|
|
@ -31,6 +31,7 @@ data class Notification(
|
||||||
val account: TimelineAccount,
|
val account: TimelineAccount,
|
||||||
val status: Status?,
|
val status: Status?,
|
||||||
val report: Report?,
|
val report: Report?,
|
||||||
|
@Json(name = "event")
|
||||||
val relationshipSeveranceEvent: RelationshipSeveranceEvent? = null,
|
val relationshipSeveranceEvent: RelationshipSeveranceEvent? = null,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,17 @@ data class RelationshipSeveranceEvent(
|
||||||
*/
|
*/
|
||||||
@Json(name = "target_name")
|
@Json(name = "target_name")
|
||||||
val targetName: String,
|
val targetName: String,
|
||||||
/** Number of follow relationships (in either direction) that were severed. */
|
|
||||||
@Json(name = "relationships_count")
|
// Documentation is wrong: https://github.com/mastodon/documentation/issues/1556
|
||||||
val relationshipsCount: Int = 0,
|
/** Number of follower accounts removed. */
|
||||||
|
@Json(name = "followers_count")
|
||||||
|
val followersCount: Int = 0,
|
||||||
|
|
||||||
|
// Documentation is wrong: https://github.com/mastodon/documentation/issues/1556
|
||||||
|
/** Number of followed accounts removed. */
|
||||||
|
@Json(name = "following_count")
|
||||||
|
val followingCount: Int = 0,
|
||||||
|
|
||||||
/** When the event took place. */
|
/** When the event took place. */
|
||||||
@Json(name = "created_at")
|
@Json(name = "created_at")
|
||||||
val createdAt: Date,
|
val createdAt: Date,
|
||||||
|
|
Loading…
Reference in New Issue