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:
parent
647238052b
commit
e735e4843e
44 changed files with 1076 additions and 318 deletions
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue