mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +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,
|
CLEARED_CHAT,
|
||||||
REACTION,
|
REACTION,
|
||||||
REACTION_DELETED,
|
REACTION_DELETED,
|
||||||
REACTION_REVOKED
|
REACTION_REVOKED,
|
||||||
|
POLL_VOTED
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
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.OBJECT_SHARED
|
||||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.PASSWORD_REMOVED
|
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.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
|
||||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.REACTION_DELETED
|
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.REACTION_DELETED
|
||||||
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.REACTION_REVOKED
|
import com.nextcloud.talk.models.json.chat.ChatMessage.SystemMessageType.REACTION_REVOKED
|
||||||
@ -167,6 +168,7 @@ class EnumSystemMessageTypeConverter : StringBasedTypeConverter<ChatMessage.Syst
|
|||||||
"reaction" -> REACTION
|
"reaction" -> REACTION
|
||||||
"reaction_deleted" -> REACTION_DELETED
|
"reaction_deleted" -> REACTION_DELETED
|
||||||
"reaction_revoked" -> REACTION_REVOKED
|
"reaction_revoked" -> REACTION_REVOKED
|
||||||
|
"poll_voted" -> POLL_VOTED
|
||||||
else -> DUMMY
|
else -> DUMMY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,6 +226,7 @@ class EnumSystemMessageTypeConverter : StringBasedTypeConverter<ChatMessage.Syst
|
|||||||
REACTION -> return "reaction"
|
REACTION -> return "reaction"
|
||||||
REACTION_DELETED -> return "reaction_deleted"
|
REACTION_DELETED -> return "reaction_deleted"
|
||||||
REACTION_REVOKED -> return "reaction_revoked"
|
REACTION_REVOKED -> return "reaction_revoked"
|
||||||
|
POLL_VOTED -> return "poll_voted"
|
||||||
else -> return ""
|
else -> return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,13 @@ class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvid
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun createPoll(
|
override fun createPoll(
|
||||||
roomToken: String, question: String, options: List<String>, resultMode: Int, maxVotes:
|
roomToken: String,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
resultMode: Int,
|
||||||
|
maxVotes:
|
||||||
Int
|
Int
|
||||||
):
|
): Observable<Poll>? {
|
||||||
Observable<Poll>? {
|
|
||||||
return ncApi.createPoll(
|
return ncApi.createPoll(
|
||||||
credentials,
|
credentials,
|
||||||
ApiUtils.getUrlForPoll(
|
ApiUtils.getUrlForPoll(
|
||||||
|
@ -94,14 +94,13 @@ class PollResultsFragment(
|
|||||||
) {
|
) {
|
||||||
Log.d(TAG, "show results also if self never voted")
|
Log.d(TAG, "show results also if self never voted")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initPollResults(poll: Poll) {
|
private fun initPollResults(poll: Poll) {
|
||||||
if (poll.details != null) {
|
if (poll.details != null) {
|
||||||
val votersAmount = poll.details.size
|
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 ->
|
poll.options?.forEachIndexed { index, option ->
|
||||||
val votersForThisOption = poll.details.filter { it.optionId == index }.size
|
val votersForThisOption = poll.details.filter { it.optionId == index }.size
|
||||||
|
Loading…
Reference in New Issue
Block a user