Release polls behind feature flag.

This commit is contained in:
Michelle Tang
2025-10-01 12:46:37 -04:00
parent 67a693107e
commit b8e4ffb5ae
84 changed files with 4164 additions and 102 deletions

View File

@@ -0,0 +1,41 @@
package org.thoughtcrime.securesms.polls
import android.os.Bundle
import android.os.Parcelable
import androidx.core.os.bundleOf
import kotlinx.parcelize.Parcelize
/**
* Class to represent a poll when it's being created but not yet saved to the database
*/
@Parcelize
data class Poll(
val question: String,
val allowMultipleVotes: Boolean,
val pollOptions: List<String>,
val authorId: Long = -1
) : Parcelable {
companion object {
const val KEY_QUESTION = "question"
const val KEY_ALLOW_MULTIPLE = "allow_multiple"
const val KEY_OPTIONS = "options"
@JvmStatic
fun fromBundle(bundle: Bundle): Poll {
return Poll(
bundle.getString(KEY_QUESTION)!!,
bundle.getBoolean(KEY_ALLOW_MULTIPLE),
bundle.getStringArrayList(KEY_OPTIONS)!!
)
}
}
fun toBundle(): Bundle {
return bundleOf(
KEY_QUESTION to question,
KEY_ALLOW_MULTIPLE to allowMultipleVotes,
KEY_OPTIONS to ArrayList(pollOptions.toList())
)
}
}

View File

@@ -0,0 +1,16 @@
package org.thoughtcrime.securesms.polls
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
/**
* Represents a poll option and a list of recipients who have voted for that option
*/
@Parcelize
data class PollOption(
val id: Long,
val text: String,
val voterIds: List<Long>,
val isSelected: Boolean = false,
val isPending: Boolean = false
) : Parcelable

View File

@@ -0,0 +1,18 @@
package org.thoughtcrime.securesms.polls
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
/**
* Data class representing a poll entry in the db, its options, and any voting
*/
@Parcelize
data class PollRecord(
val id: Long,
val question: String,
val pollOptions: List<PollOption>,
val allowMultipleVotes: Boolean,
val hasEnded: Boolean,
val authorId: Long,
val messageId: Long
) : Parcelable

View File

@@ -0,0 +1,18 @@
/*
* Copyright 2025 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.polls
import org.thoughtcrime.securesms.recipients.RecipientId
/**
* Tracks general information of a poll vote including who they are and what poll they voted in. Primarily used in notifications.
*/
data class PollVote(
val pollId: Long,
val voterId: RecipientId,
val question: String,
val dateReceived: Long = 0
)