Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Show unknown notification types correctly #1154

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,12 @@
<issue
id="Typos"
message="&quot;media&quot; is a common misspelling; did you mean &quot;medier&quot;?"
errorLine1=" &lt;string name=&quot;error_media_upload_permission&quot;>Pachli tenger tillatelse for å lese media.&lt;/string>"
errorLine2=" ^">
errorLine1=" &lt;string name=&quot;error_media_upload_permission&quot;>Pachli trenger tillatelse for å lese media.&lt;/string>"
errorLine2=" ^">
<location
file="src/main/res/values-nb-rNO/strings.xml"
line="8"
column="86"/>
column="87"/>
</issue>

<issue
Expand Down Expand Up @@ -1068,6 +1068,17 @@
column="27"/>
</issue>

<issue
id="VectorPath"
message="Very long vector path (952 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector."
errorLine1=" &lt;path android:fillColor=&quot;@android:color/white&quot; android:pathData=&quot;M200,840Q167,840 143.5,816.5Q120,793 120,760L120,600L200,600L200,760Q200,760 200,760Q200,760 200,760L360,760L360,840L200,840ZM760,840L600,840L600,760L760,760Q760,760 760,760Q760,760 760,760L760,600L840,600L840,760Q840,793 816.5,816.5Q793,840 760,840ZM120,200Q120,167 143.5,143.5Q167,120 200,120L360,120L360,200L200,200Q200,200 200,200Q200,200 200,200L200,360L120,360L120,200ZM840,200L840,360L760,360L760,200Q760,200 760,200Q760,200 760,200L600,200L600,120L760,120Q793,120 816.5,143.5Q840,167 840,200ZM480,720Q501,720 515.5,705.5Q530,691 530,670Q530,649 515.5,634.5Q501,620 480,620Q459,620 444.5,634.5Q430,649 430,670Q430,691 444.5,705.5Q459,720 480,720ZM444,567L517,567Q517,533 525,515Q533,497 560,470Q595,435 606.5,413.5Q618,392 618,362Q618,308 579,274Q540,240 480,240Q430,240 394,266Q358,292 342,340L408,367Q415,341 434.5,324.5Q454,308 480,308Q509,308 526.5,323.5Q544,339 544,365Q544,385 534.5,402.5Q525,420 502,439Q469,468 456.5,495Q444,522 444,567Z&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/drawable/ic_indeterminate_question_box_24.xml"
line="9"
column="70"/>
</issue>

<issue
id="Overdraw"
message="Possible overdraw: Root element paints background `@color/black` with a theme that also paints a background (inferred theme is `@style/AppTheme`)"
Expand Down Expand Up @@ -2428,17 +2439,6 @@
column="2"/>
</issue>

<issue
id="SelectableText"
message="Consider making the text value selectable by specifying `android:textIsSelectable=&quot;true&quot;`"
errorLine1="&lt;TextView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;"
errorLine2=" ~~~~~~~~">
<location
file="src/main/res/layout/simple_list_item_1.xml"
line="19"
column="2"/>
</issue>

<issue
id="SelectableText"
message="Consider making the text value selectable by specifying `android:textIsSelectable=&quot;true&quot;`"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.view.ViewGroup
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import app.pachli.R
import app.pachli.adapter.FollowRequestViewHolder
import app.pachli.adapter.ReportNotificationViewHolder
import app.pachli.core.common.util.AbsoluteTimeFormatter
Expand All @@ -37,7 +38,7 @@ import app.pachli.databinding.ItemSeveredRelationshipsBinding
import app.pachli.databinding.ItemStatusBinding
import app.pachli.databinding.ItemStatusNotificationBinding
import app.pachli.databinding.ItemStatusWrapperBinding
import app.pachli.databinding.SimpleListItem1Binding
import app.pachli.databinding.ItemUnknownNotificationBinding
import app.pachli.interfaces.AccountActionListener
import app.pachli.interfaces.StatusActionListener
import app.pachli.viewdata.NotificationViewData
Expand Down Expand Up @@ -75,7 +76,6 @@ enum class NotificationViewKind {
return when (kind) {
Notification.Type.MENTION,
Notification.Type.POLL,
Notification.Type.UNKNOWN,
-> STATUS
Notification.Type.FAVOURITE,
Notification.Type.REBLOG,
Expand All @@ -88,6 +88,7 @@ enum class NotificationViewKind {
Notification.Type.FOLLOW_REQUEST -> FOLLOW_REQUEST
Notification.Type.REPORT -> REPORT
Notification.Type.SEVERED_RELATIONSHIPS -> SEVERED_RELATIONSHIPS
Notification.Type.UNKNOWN -> UNKNOWN
null -> UNKNOWN
}
}
Expand Down Expand Up @@ -177,7 +178,7 @@ class NotificationsPagingAdapter(
return NotificationViewKind.ACCOUNT_FILTERED.ordinal
}

return NotificationViewKind.from(getItem(position)?.type).ordinal
return NotificationViewKind.from(item?.type).ordinal
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
Expand Down Expand Up @@ -240,7 +241,7 @@ class NotificationsPagingAdapter(
}
else -> {
FallbackNotificationViewHolder(
SimpleListItem1Binding.inflate(inflater, parent, false),
ItemUnknownNotificationBinding.inflate(inflater, parent, false),
)
}
}
Expand Down Expand Up @@ -272,15 +273,15 @@ class NotificationsPagingAdapter(
* be used, but is useful when migrating code.
*/
private class FallbackNotificationViewHolder(
val binding: SimpleListItem1Binding,
val binding: ItemUnknownNotificationBinding,
) : ViewHolder, RecyclerView.ViewHolder(binding.root) {
override fun bind(
pachliAccountId: Long,
viewData: NotificationViewData,
payloads: List<*>?,
statusDisplayOptions: StatusDisplayOptions,
) {
binding.text1.text = viewData.statusViewData?.content
binding.text1.text = binding.root.context.getString(R.string.notification_unknown)
}
}
}
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_indeterminate_question_box_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:autoMirrored="true"
android:height="24dp"
android:tint="?attr/colorPrimary"
android:viewportHeight="960"
android:viewportWidth="960"
android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,600L200,600L200,760Q200,760 200,760Q200,760 200,760L360,760L360,840L200,840ZM760,840L600,840L600,760L760,760Q760,760 760,760Q760,760 760,760L760,600L840,600L840,760Q840,793 816.5,816.5Q793,840 760,840ZM120,200Q120,167 143.5,143.5Q167,120 200,120L360,120L360,200L200,200Q200,200 200,200Q200,200 200,200L200,360L120,360L120,200ZM840,200L840,360L760,360L760,200Q760,200 760,200Q760,200 760,200L600,200L600,120L760,120Q793,120 816.5,143.5Q840,167 840,200ZM480,720Q501,720 515.5,705.5Q530,691 530,670Q530,649 515.5,634.5Q501,620 480,620Q459,620 444.5,634.5Q430,649 430,670Q430,691 444.5,705.5Q459,720 480,720ZM444,567L517,567Q517,533 525,515Q533,497 560,470Q595,435 606.5,413.5Q618,392 618,362Q618,308 579,274Q540,240 480,240Q430,240 394,266Q358,292 342,340L408,367Q415,341 434.5,324.5Q454,308 480,308Q509,308 526.5,323.5Q544,339 544,365Q544,385 534.5,402.5Q525,420 502,439Q469,468 456.5,495Q444,522 444,567Z"/>
Fixed Show fixed Hide fixed

</vector>
36 changes: 36 additions & 0 deletions app/src/main/res/layout/item_unknown_notification.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ Copyright 2024 Pachli Association
~
~ This file is a part of Pachli.
~
~ This program is free software; you can redistribute it and/or modify it under the terms of the
~ GNU General Public License as published by the Free Software Foundation; either version 3 of the
~ License, or (at your option) any later version.
~
~ Pachli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
~ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
~ Public License for more details.
~
~ You should have received a copy of the GNU General Public License along with Pachli; if not,
~ see <http://www.gnu.org/licenses>.
-->

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
Fixed Show fixed Hide fixed
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:drawablePadding="10dp"
android:paddingStart="42dp"
android:textColor="?android:textColorSecondary"
android:textSize="?attr/status_text_medium"
android:gravity="center_vertical"
app:drawableStartCompat="@drawable/ic_indeterminate_question_box_24"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
tools:ignore="SelectableText" />
27 changes: 0 additions & 27 deletions app/src/main/res/layout/simple_list_item_1.xml

This file was deleted.

1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<item quantity="one">%1$s account you follow removed</item>
<item quantity="other">%1$s accounts you follow removed</item>
</plurals>
<string name="notification_unknown">Unknown notification type</string>
<string name="notification_header_report_format">%s reported %s</string>
<string name="notification_summary_report_format">%s · %d posts attached</string>
<string name="report_username_format">Report @%s</string>
Expand Down
Loading