mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
add poll system message, klint fixes
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
9f90e9c4c6
commit
8148bfaa65
@ -490,7 +490,8 @@ data class ChatMessage(
|
||||
CLEARED_CHAT,
|
||||
REACTION,
|
||||
REACTION_DELETED,
|
||||
REACTION_REVOKED
|
||||
REACTION_REVOKED,
|
||||
POLL_VOTED
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -65,6 +65,7 @@ import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.MODERAT
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.OBJECT_SHARED
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.PASSWORD_REMOVED
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.PASSWORD_SET
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.POLL_VOTED
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.REACTION
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.REACTION_DELETED
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.REACTION_REVOKED
|
||||
@ -167,6 +168,7 @@ class EnumSystemMessageTypeConverter : StringBasedTypeConverter<ChatMessage.Syst
|
||||
"reaction" -> REACTION
|
||||
"reaction_deleted" -> REACTION_DELETED
|
||||
"reaction_revoked" -> REACTION_REVOKED
|
||||
"poll_voted" -> POLL_VOTED
|
||||
else -> DUMMY
|
||||
}
|
||||
}
|
||||
@ -224,6 +226,7 @@ class EnumSystemMessageTypeConverter : StringBasedTypeConverter<ChatMessage.Syst
|
||||
REACTION -> return "reaction"
|
||||
REACTION_DELETED -> return "reaction_deleted"
|
||||
REACTION_REVOKED -> return "reaction_revoked"
|
||||
POLL_VOTED -> return "poll_voted"
|
||||
else -> return ""
|
||||
}
|
||||
}
|
||||
|
@ -39,10 +39,13 @@ class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvid
|
||||
)
|
||||
|
||||
override fun createPoll(
|
||||
roomToken: String, question: String, options: List<String>, resultMode: Int, maxVotes:
|
||||
roomToken: String,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
resultMode: Int,
|
||||
maxVotes:
|
||||
Int
|
||||
):
|
||||
Observable<Poll>? {
|
||||
): Observable<Poll>? {
|
||||
return ncApi.createPoll(
|
||||
credentials,
|
||||
ApiUtils.getUrlForPoll(
|
||||
|
@ -94,14 +94,13 @@ class PollResultsFragment(
|
||||
) {
|
||||
Log.d(TAG, "show results also if self never voted")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun initPollResults(poll: Poll) {
|
||||
if (poll.details != null) {
|
||||
val votersAmount = poll.details.size
|
||||
val oneVoteInPercent = 100 / votersAmount // TODO: poll.numVoters when fixed on api
|
||||
val oneVoteInPercent = 100 / votersAmount // TODO: poll.numVoters when fixed on api
|
||||
|
||||
poll.options?.forEachIndexed { index, option ->
|
||||
val votersForThisOption = poll.details.filter { it.optionId == index }.size
|
||||
|
Loading…
Reference in New Issue
Block a user