Polls part 1 - displaying in timelines and voting (#1200)

* add entity classes

* change data models and add database migration

* add polls to StatusViewData

* show poll results

* add methods for vote handling

* add voting interface

* enable voting in TimelineFragment

* update polls immediately

* enable custom emojis for poll options

* enable voting from search fragment

* add voting layout to detailed statuses

* fix tests

* enable voting in ViewThreadFragment

* enable voting in ConversationsFragment

* small refactor for StatusBaseViewHolder
This commit is contained in:
Konrad Pozniak 2019-04-22 10:11:00 +02:00 committed by GitHub
commit fd7471f2ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 1637 additions and 68 deletions

View file

@ -4,9 +4,7 @@ import android.text.SpannedString
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.keylesspalace.tusky.db.*
import com.keylesspalace.tusky.entity.Account
import com.keylesspalace.tusky.entity.Attachment
import com.keylesspalace.tusky.entity.Emoji
import com.keylesspalace.tusky.entity.*
import com.keylesspalace.tusky.entity.Status
import com.keylesspalace.tusky.network.MastodonApi
import com.keylesspalace.tusky.repository.TimelineRequestMode.DISK
@ -202,6 +200,7 @@ class TimelineRepositoryImpl(
val application = gson.fromJson(status.application, Status.Application::class.java)
val emojis: List<Emoji> = gson.fromJson(status.emojis,
object : TypeToken<List<Emoji>>() {}.type) ?: listOf()
val poll: Poll? = gson.fromJson(status.poll, Poll::class.java)
val reblog = status.reblogServerId?.let { id ->
Status(
@ -224,8 +223,8 @@ class TimelineRepositoryImpl(
attachments = attachments,
mentions = mentions,
application = application,
pinned = false
pinned = false,
poll = poll
)
}
val status = if (reblog != null) {
@ -249,7 +248,8 @@ class TimelineRepositoryImpl(
attachments = ArrayList(),
mentions = arrayOf(),
application = null,
pinned = false
pinned = false,
poll = null
)
} else {
Status(
@ -272,7 +272,8 @@ class TimelineRepositoryImpl(
attachments = attachments,
mentions = mentions,
application = application,
pinned = false
pinned = false,
poll = poll
)
}
return Either.Right(status)
@ -339,8 +340,8 @@ fun Placeholder.toEntity(timelineUserId: Long): TimelineStatusEntity {
mentions = null,
application = null,
reblogServerId = null,
reblogAccountId = null
reblogAccountId = null,
poll = null
)
}
@ -369,7 +370,8 @@ fun Status.toEntity(timelineUserId: Long,
mentions = actionable.mentions.let(gson::toJson),
application = actionable.let(gson::toJson),
reblogServerId = reblog?.id,
reblogAccountId = reblog?.let { this.account.id }
reblogAccountId = reblog?.let { this.account.id },
poll = actionable.poll.let(gson::toJson)
)
}