Scheduled toot (#1004)

* Scheduled toot

* Hide scheduled toot button if version < 2.7.0

* Fix timeline reloading after toot

* Add edit icon to ComposeScheduleView

* Add button to reset scheduled toot

* Close bottom sheet and change button color after time a was selected

* Fix edit icon's size

* List of scheduled toots

* Fix instance version check

* Use MaterialDatePicker

* Set date and time consecutively

* Add licenses
This commit is contained in:
kyori19 2019-10-03 04:28:12 +09:00 committed by Konrad Pozniak
commit 9e4c19a47e
23 changed files with 933 additions and 56 deletions

View file

@ -18,6 +18,7 @@ import androidx.core.content.ContextCompat
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.appstore.EventHub
import com.keylesspalace.tusky.appstore.StatusComposedEvent
import com.keylesspalace.tusky.appstore.StatusScheduledEvent
import com.keylesspalace.tusky.db.AccountEntity
import com.keylesspalace.tusky.db.AccountManager
import com.keylesspalace.tusky.db.AppDatabase
@ -140,6 +141,7 @@ class SendTootService : Service(), Injectable {
tootToSend.visibility,
tootToSend.sensitive,
tootToSend.mediaIds,
tootToSend.scheduledAt,
tootToSend.poll
)
@ -156,6 +158,7 @@ class SendTootService : Service(), Injectable {
val callback = object : Callback<Status> {
override fun onResponse(call: Call<Status>, response: Response<Status>) {
val scheduled = !tootToSend.scheduledAt.isNullOrEmpty()
tootsToSend.remove(tootId)
if (response.isSuccessful) {
@ -164,7 +167,11 @@ class SendTootService : Service(), Injectable {
saveTootHelper.deleteDraft(tootToSend.savedTootUid)
}
response.body()?.let(::StatusComposedEvent)?.let(eventHub::dispatch)
if (scheduled) {
response.body()?.let(::StatusScheduledEvent)?.let(eventHub::dispatch)
} else {
response.body()?.let(::StatusComposedEvent)?.let(eventHub::dispatch)
}
notificationManager.cancel(tootId)
@ -284,6 +291,7 @@ class SendTootService : Service(), Injectable {
mediaIds: List<String>,
mediaUris: List<Uri>,
mediaDescriptions: List<String>,
scheduledAt: String?,
inReplyToId: String?,
poll: NewPoll?,
replyingStatusContent: String?,
@ -303,6 +311,7 @@ class SendTootService : Service(), Injectable {
mediaIds,
mediaUris.map { it.toString() },
mediaDescriptions,
scheduledAt,
inReplyToId,
poll,
replyingStatusContent,
@ -346,6 +355,7 @@ data class TootToSend(val text: String,
val mediaIds: List<String>,
val mediaUris: List<String>,
val mediaDescriptions: List<String>,
val scheduledAt: String?,
val inReplyToId: String?,
val poll: NewPoll?,
val replyingStatusContent: String?,