From 22b03fca5463edd638e995b9f51d271dac54b4bc Mon Sep 17 00:00:00 2001 From: Matthieu <24-artectrex@users.noreply.shinice.net> Date: Sun, 1 Nov 2020 19:57:56 +0100 Subject: [PATCH] add poll to prevent crashes with mastodon --- .../fragments/feeds/NotificationsFragment.kt | 13 +++++++------ .../java/com/h/pixeldroid/objects/Notification.kt | 2 +- app/src/main/res/drawable-night/poll.xml | 9 +++++++++ app/src/main/res/drawable/poll.xml | 9 +++++++++ app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable-night/poll.xml create mode 100644 app/src/main/res/drawable/poll.xml diff --git a/app/src/main/java/com/h/pixeldroid/fragments/feeds/NotificationsFragment.kt b/app/src/main/java/com/h/pixeldroid/fragments/feeds/NotificationsFragment.kt index f2c0a019..18544008 100644 --- a/app/src/main/java/com/h/pixeldroid/fragments/feeds/NotificationsFragment.kt +++ b/app/src/main/java/com/h/pixeldroid/fragments/feeds/NotificationsFragment.kt @@ -156,7 +156,7 @@ class NotificationsFragment : FeedFragment() { } } - private fun openPostFromNotifcation(notification: Notification) : Intent { + private fun openPostFromNotification(notification: Notification) : Intent { val intent = Intent(context, PostActivity::class.java) intent.putExtra(Status.POST_TAG, notification.status) return intent @@ -165,11 +165,9 @@ class NotificationsFragment : FeedFragment() { private fun openActivity(notification: Notification){ val intent: Intent when (notification.type){ - Notification.NotificationType.mention, Notification.NotificationType.favourite-> { - intent = openPostFromNotifcation(notification) - } - Notification.NotificationType.reblog-> { - intent = openPostFromNotifcation(notification) + Notification.NotificationType.mention, Notification.NotificationType.favourite, + Notification.NotificationType.poll, Notification.NotificationType.reblog -> { + intent = openPostFromNotification(notification) } Notification.NotificationType.follow -> { intent = Intent(context, ProfileActivity::class.java) @@ -237,6 +235,9 @@ class NotificationsFragment : FeedFragment() { Notification.NotificationType.favourite -> { setNotificationTypeTextView(context, R.string.liked_notification, R.drawable.ic_like_full) } + Notification.NotificationType.poll -> { + setNotificationTypeTextView(context, R.string.poll_notification, R.drawable.poll) + } } textView.text = format.format(username) textView.setCompoundDrawablesWithIntrinsicBounds( diff --git a/app/src/main/java/com/h/pixeldroid/objects/Notification.kt b/app/src/main/java/com/h/pixeldroid/objects/Notification.kt index 821881e4..d35026b1 100644 --- a/app/src/main/java/com/h/pixeldroid/objects/Notification.kt +++ b/app/src/main/java/com/h/pixeldroid/objects/Notification.kt @@ -16,6 +16,6 @@ data class Notification( val status: Status? = null ): FeedContent() { enum class NotificationType { - follow, mention, reblog, favourite + follow, mention, reblog, favourite, poll } } \ No newline at end of file diff --git a/app/src/main/res/drawable-night/poll.xml b/app/src/main/res/drawable-night/poll.xml new file mode 100644 index 00000000..7d6bd4bc --- /dev/null +++ b/app/src/main/res/drawable-night/poll.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/poll.xml b/app/src/main/res/drawable/poll.xml new file mode 100644 index 00000000..950547d6 --- /dev/null +++ b/app/src/main/res/drawable/poll.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7e768525..89db4d72 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,6 +23,8 @@ %1$s mentioned you %1$s shared your post %1$s liked your post + "%1$s's poll has ended" + "What's an instance?" Domain of your instance