Create polls (#1452)

* add AddPollDialog

* add support for pleroma poll options

* add PollPreviewView

* add Poll support to drafts

* add license header, cleanup

* rename drawable files to correct size

* fix tests

* fix bug with Poll having wrong duration after delete&redraft

* add input validation

* grey out poll button when its disabled

* code cleanup & small improvements
This commit is contained in:
Konrad Pozniak 2019-08-22 20:30:08 +02:00 committed by GitHub
commit 51c6852492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 1540 additions and 76 deletions

View file

@ -22,6 +22,8 @@ import com.keylesspalace.tusky.db.AccountEntity
import com.keylesspalace.tusky.db.AccountManager
import com.keylesspalace.tusky.db.AppDatabase
import com.keylesspalace.tusky.di.Injectable
import com.keylesspalace.tusky.entity.NewPoll
import com.keylesspalace.tusky.entity.NewStatus
import com.keylesspalace.tusky.entity.Status
import com.keylesspalace.tusky.network.MastodonApi
import com.keylesspalace.tusky.util.SaveTootHelper
@ -131,16 +133,21 @@ class SendTootService : Service(), Injectable {
tootToSend.retries++
val sendCall = mastodonApi.createStatus(
"Bearer " + account.accessToken,
account.domain,
val newStatus = NewStatus(
tootToSend.text,
tootToSend.inReplyToId,
tootToSend.warningText,
tootToSend.inReplyToId,
tootToSend.visibility,
tootToSend.sensitive,
tootToSend.mediaIds,
tootToSend.idempotencyKey
tootToSend.poll
)
val sendCall = mastodonApi.createStatus(
"Bearer " + account.accessToken,
account.domain,
tootToSend.idempotencyKey,
newStatus
)
@ -243,7 +250,8 @@ class SendTootService : Service(), Injectable {
toot.inReplyToId,
toot.replyingStatusContent,
toot.replyingStatusAuthorUsername,
Status.Visibility.byString(toot.visibility))
Status.Visibility.byString(toot.visibility),
toot.poll)
}
private fun cancelSendingIntent(tootId: Int): PendingIntent {
@ -277,6 +285,7 @@ class SendTootService : Service(), Injectable {
mediaUris: List<Uri>,
mediaDescriptions: List<String>,
inReplyToId: String?,
poll: NewPoll?,
replyingStatusContent: String?,
replyingStatusAuthorUsername: String?,
savedJsonUrls: String?,
@ -295,6 +304,7 @@ class SendTootService : Service(), Injectable {
mediaUris.map { it.toString() },
mediaDescriptions,
inReplyToId,
poll,
replyingStatusContent,
replyingStatusAuthorUsername,
savedJsonUrls,
@ -337,6 +347,7 @@ data class TootToSend(val text: String,
val mediaUris: List<String>,
val mediaDescriptions: List<String>,
val inReplyToId: String?,
val poll: NewPoll?,
val replyingStatusContent: String?,
val replyingStatusAuthorUsername: String?,
val savedJsonUrls: String?,