Poll notifications (#1229)

* show poll notifications in the app

* show poll notifications in the app

* allow filtering poll notifications in the poll fragment

* show poll notifications in system notifications
This commit is contained in:
Konrad Pozniak 2019-05-02 19:44:35 +02:00 committed by GitHub
commit e735e4843e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 1076 additions and 318 deletions

View file

@ -30,7 +30,8 @@ data class Notification(
MENTION("mention"),
REBLOG("reblog"),
FAVOURITE("favourite"),
FOLLOW("follow");
FOLLOW("follow"),
POLL("poll");
companion object {
@ -42,7 +43,7 @@ data class Notification(
}
return UNKNOWN
}
val asList = listOf(MENTION,REBLOG,FAVOURITE,FOLLOW)
val asList = listOf(MENTION, REBLOG, FAVOURITE, FOLLOW, POLL)
}
override fun toString(): String {

View file

@ -2,6 +2,7 @@ package com.keylesspalace.tusky.entity
import com.google.gson.annotations.SerializedName
import java.util.*
import kotlin.math.roundToInt
data class Poll(
val id: String,
@ -30,4 +31,12 @@ data class Poll(
data class PollOption(
val title: String,
@SerializedName("votes_count") val votesCount: Int
)
) {
fun getPercent(totalVotes: Int): Int {
return if (votesCount == 0) {
0
} else {
(votesCount / totalVotes.toDouble() * 100).roundToInt()
}
}
}