2019-12-19 19:09:40 +01:00
|
|
|
/* Copyright 2019 Tusky Contributors
|
|
|
|
*
|
|
|
|
* This file is a part of Tusky.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with Tusky; if not,
|
|
|
|
* see <http://www.gnu.org/licenses>. */
|
|
|
|
|
|
|
|
package com.keylesspalace.tusky.components.compose
|
|
|
|
|
|
|
|
import android.net.Uri
|
|
|
|
import android.util.Log
|
|
|
|
import androidx.core.net.toUri
|
2022-04-21 18:46:21 +02:00
|
|
|
import androidx.lifecycle.ViewModel
|
2021-06-24 21:23:29 +02:00
|
|
|
import androidx.lifecycle.viewModelScope
|
2022-05-30 20:03:40 +02:00
|
|
|
import at.connyduck.calladapter.networkresult.fold
|
2023-06-13 15:45:17 +02:00
|
|
|
import com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeKind
|
2019-12-19 19:09:40 +01:00
|
|
|
import com.keylesspalace.tusky.components.compose.ComposeActivity.QueuedMedia
|
2022-05-17 19:55:37 +02:00
|
|
|
import com.keylesspalace.tusky.components.compose.ComposeAutoCompleteAdapter.AutocompleteResult
|
2021-01-21 18:57:09 +01:00
|
|
|
import com.keylesspalace.tusky.components.drafts.DraftHelper
|
2022-04-21 18:46:21 +02:00
|
|
|
import com.keylesspalace.tusky.components.instanceinfo.InstanceInfo
|
|
|
|
import com.keylesspalace.tusky.components.instanceinfo.InstanceInfoRepository
|
2019-12-19 19:09:40 +01:00
|
|
|
import com.keylesspalace.tusky.components.search.SearchType
|
|
|
|
import com.keylesspalace.tusky.db.AccountManager
|
2021-06-28 22:04:34 +02:00
|
|
|
import com.keylesspalace.tusky.entity.Attachment
|
|
|
|
import com.keylesspalace.tusky.entity.Emoji
|
|
|
|
import com.keylesspalace.tusky.entity.NewPoll
|
2019-12-19 19:09:40 +01:00
|
|
|
import com.keylesspalace.tusky.entity.Status
|
|
|
|
import com.keylesspalace.tusky.network.MastodonApi
|
2022-12-29 19:58:23 +01:00
|
|
|
import com.keylesspalace.tusky.service.MediaToSend
|
2019-12-19 19:09:40 +01:00
|
|
|
import com.keylesspalace.tusky.service.ServiceClient
|
2022-03-20 20:21:42 +01:00
|
|
|
import com.keylesspalace.tusky.service.StatusToSend
|
2021-06-28 22:04:34 +02:00
|
|
|
import com.keylesspalace.tusky.util.randomAlphanumericString
|
2024-01-04 17:00:55 +01:00
|
|
|
import javax.inject.Inject
|
2022-04-21 18:46:21 +02:00
|
|
|
import kotlinx.coroutines.Dispatchers
|
2022-07-26 20:24:50 +02:00
|
|
|
import kotlinx.coroutines.channels.BufferOverflow
|
|
|
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
2022-05-03 19:12:35 +02:00
|
|
|
import kotlinx.coroutines.flow.MutableStateFlow
|
2022-07-26 20:24:50 +02:00
|
|
|
import kotlinx.coroutines.flow.SharedFlow
|
|
|
|
import kotlinx.coroutines.flow.SharingStarted
|
2024-03-27 11:17:42 +01:00
|
|
|
import kotlinx.coroutines.flow.StateFlow
|
2022-07-26 20:24:50 +02:00
|
|
|
import kotlinx.coroutines.flow.asFlow
|
2024-03-29 20:02:12 +01:00
|
|
|
import kotlinx.coroutines.flow.asSharedFlow
|
2024-03-27 11:17:42 +01:00
|
|
|
import kotlinx.coroutines.flow.asStateFlow
|
2022-07-26 20:24:50 +02:00
|
|
|
import kotlinx.coroutines.flow.first
|
|
|
|
import kotlinx.coroutines.flow.shareIn
|
2022-05-03 19:12:35 +02:00
|
|
|
import kotlinx.coroutines.flow.update
|
2021-06-24 21:23:29 +02:00
|
|
|
import kotlinx.coroutines.launch
|
2024-02-29 15:28:48 +01:00
|
|
|
import kotlinx.coroutines.runBlocking
|
2022-04-21 18:46:21 +02:00
|
|
|
import kotlinx.coroutines.withContext
|
2019-12-19 19:09:40 +01:00
|
|
|
|
2021-01-21 18:57:09 +01:00
|
|
|
class ComposeViewModel @Inject constructor(
|
2021-06-28 22:04:34 +02:00
|
|
|
private val api: MastodonApi,
|
|
|
|
private val accountManager: AccountManager,
|
|
|
|
private val mediaUploader: MediaUploader,
|
|
|
|
private val serviceClient: ServiceClient,
|
|
|
|
private val draftHelper: DraftHelper,
|
2022-07-26 20:24:50 +02:00
|
|
|
instanceInfoRepo: InstanceInfoRepository
|
2022-04-21 18:46:21 +02:00
|
|
|
) : ViewModel() {
|
2019-12-19 19:09:40 +01:00
|
|
|
|
|
|
|
private var replyingStatusAuthor: String? = null
|
|
|
|
private var replyingStatusContent: String? = null
|
|
|
|
internal var startingText: String? = null
|
2022-08-31 18:53:57 +02:00
|
|
|
internal var postLanguage: String? = null
|
2021-01-21 18:57:09 +01:00
|
|
|
private var draftId: Int = 0
|
|
|
|
private var scheduledTootId: String? = null
|
2020-01-29 19:15:53 +01:00
|
|
|
private var startingContentWarning: String = ""
|
2019-12-19 19:09:40 +01:00
|
|
|
private var inReplyToId: String? = null
|
2022-12-08 10:18:12 +01:00
|
|
|
private var originalStatusId: String? = null
|
2019-12-19 19:09:40 +01:00
|
|
|
private var startingVisibility: Status.Visibility = Status.Visibility.UNKNOWN
|
|
|
|
|
2020-04-18 15:06:24 +02:00
|
|
|
private var contentWarningStateChanged: Boolean = false
|
2020-10-02 18:32:46 +02:00
|
|
|
private var modifiedInitialState: Boolean = false
|
2022-07-27 21:06:51 +02:00
|
|
|
private var hasScheduledTimeChanged: Boolean = false
|
2020-04-18 15:06:24 +02:00
|
|
|
|
2024-02-23 10:27:19 +01:00
|
|
|
private var currentContent: String? = ""
|
|
|
|
private var currentContentWarning: String? = ""
|
|
|
|
|
2024-03-09 16:12:18 +01:00
|
|
|
val instanceInfo: SharedFlow<InstanceInfo> = instanceInfoRepo::getUpdatedInstanceInfoOrFallback.asFlow()
|
2022-07-26 20:24:50 +02:00
|
|
|
.shareIn(viewModelScope, SharingStarted.Eagerly, replay = 1)
|
2022-04-21 18:46:21 +02:00
|
|
|
|
2022-07-26 20:24:50 +02:00
|
|
|
val emoji: SharedFlow<List<Emoji>> = instanceInfoRepo::getEmojis.asFlow()
|
|
|
|
.shareIn(viewModelScope, SharingStarted.Eagerly, replay = 1)
|
2019-12-19 19:09:40 +01:00
|
|
|
|
2024-03-27 11:17:42 +01:00
|
|
|
private val _markMediaAsSensitive =
|
2022-07-26 20:24:50 +02:00
|
|
|
MutableStateFlow(accountManager.activeAccount?.defaultMediaSensitivity ?: false)
|
2024-03-27 11:17:42 +01:00
|
|
|
val markMediaAsSensitive: StateFlow<Boolean> = _markMediaAsSensitive.asStateFlow()
|
2022-07-26 20:24:50 +02:00
|
|
|
|
2024-03-27 11:17:42 +01:00
|
|
|
private val _statusVisibility = MutableStateFlow(Status.Visibility.UNKNOWN)
|
|
|
|
val statusVisibility: StateFlow<Status.Visibility> = _statusVisibility.asStateFlow()
|
|
|
|
|
|
|
|
private val _showContentWarning = MutableStateFlow(false)
|
|
|
|
val showContentWarning: StateFlow<Boolean> = _showContentWarning.asStateFlow()
|
|
|
|
|
|
|
|
private val _poll = MutableStateFlow(null as NewPoll?)
|
|
|
|
val poll: StateFlow<NewPoll?> = _poll.asStateFlow()
|
|
|
|
|
|
|
|
private val _scheduledAt = MutableStateFlow(null as String?)
|
|
|
|
val scheduledAt: StateFlow<String?> = _scheduledAt.asStateFlow()
|
|
|
|
|
|
|
|
private val _media = MutableStateFlow(emptyList<QueuedMedia>())
|
|
|
|
val media: StateFlow<List<QueuedMedia>> = _media.asStateFlow()
|
2019-12-19 19:09:40 +01:00
|
|
|
|
2024-03-29 20:02:12 +01:00
|
|
|
private val _uploadError = MutableSharedFlow<Throwable>(
|
|
|
|
replay = 0,
|
|
|
|
extraBufferCapacity = 1,
|
|
|
|
onBufferOverflow = BufferOverflow.DROP_OLDEST
|
|
|
|
)
|
|
|
|
val uploadError: SharedFlow<Throwable> = _uploadError.asSharedFlow()
|
2019-12-19 19:09:40 +01:00
|
|
|
|
2024-03-27 11:17:42 +01:00
|
|
|
private val _closeConfirmation = MutableStateFlow(ConfirmationKind.NONE)
|
|
|
|
val closeConfirmation: StateFlow<ConfirmationKind> = _closeConfirmation.asStateFlow()
|
2024-02-23 10:27:19 +01:00
|
|
|
|
2023-08-02 09:04:24 +02:00
|
|
|
private lateinit var composeKind: ComposeKind
|
Fix saving changes to statuses when editing (#3103)
* Fix saving changes to statuses when editing
With the previous code backing out of a status editing operation where changes
had been made (whether it was editing an existing status, a scheduled status,
or a draft) would prompt the user to save the changes as a new draft.
See https://github.com/tuskyapp/Tusky/issues/2704 and
https://github.com/tuskyapp/Tusky/issues/2705 for more detail.
The fix:
- Create an enum to represent the four different kinds of edits that can
happen
- Editing a new status (i.e., composing it for the first time)
- Editing a posted status
- Editing a draft
- Editing a scheduled status
- Store this in ComposeOptions, and set it appropriately everywhere
ComposeOptions is created.
- Check the edit kind when backing out of ComposeActivity, and use this to
show one of three different dialogs as appropriate so the user can:
- Save as new draft or discard changes
- Continue editing or discard changes
- Update existing draft or discard changes
Also fix ComposeViewModel.didChange(), which erroneously reported false if the
old text started with the new text (e.g., if the old text was "hello, world"
and it was edited to "hello", didChange() would not consider that to be a
change).
Fixes https://github.com/tuskyapp/Tusky/issues/2704,
https://github.com/tuskyapp/Tusky/issues/2705
* Use orEmpty extension function
2022-12-31 13:04:49 +01:00
|
|
|
|
2022-05-22 21:01:14 +02:00
|
|
|
// Used in ComposeActivity to pass state to result function when cropImage contract inflight
|
|
|
|
var cropImageItemOld: QueuedMedia? = null
|
|
|
|
|
2022-08-03 17:23:54 +02:00
|
|
|
private var setupComplete = false
|
|
|
|
|
2024-01-04 17:00:55 +01:00
|
|
|
suspend fun pickMedia(
|
|
|
|
mediaUri: Uri,
|
|
|
|
description: String? = null,
|
|
|
|
focus: Attachment.Focus? = null
|
|
|
|
): Result<QueuedMedia> = withContext(
|
|
|
|
Dispatchers.IO
|
|
|
|
) {
|
2022-04-21 18:46:21 +02:00
|
|
|
try {
|
2022-07-26 20:24:50 +02:00
|
|
|
val (type, uri, size) = mediaUploader.prepareMedia(mediaUri, instanceInfo.first())
|
2024-03-27 11:17:42 +01:00
|
|
|
val mediaItems = _media.value
|
2022-04-21 18:46:21 +02:00
|
|
|
if (type != QueuedMedia.Type.IMAGE &&
|
|
|
|
mediaItems.isNotEmpty() &&
|
|
|
|
mediaItems[0].type == QueuedMedia.Type.IMAGE
|
|
|
|
) {
|
|
|
|
Result.failure(VideoOrImageException())
|
|
|
|
} else {
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
val queuedMedia = addMediaToQueue(type, uri, size, description, focus)
|
2022-04-21 18:46:21 +02:00
|
|
|
Result.success(queuedMedia)
|
2021-06-28 22:04:34 +02:00
|
|
|
}
|
2022-04-21 18:46:21 +02:00
|
|
|
} catch (e: Exception) {
|
|
|
|
Result.failure(e)
|
|
|
|
}
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
2022-05-22 21:01:14 +02:00
|
|
|
suspend fun addMediaToQueue(
|
2021-06-28 22:04:34 +02:00
|
|
|
type: QueuedMedia.Type,
|
|
|
|
uri: Uri,
|
|
|
|
mediaSize: Long,
|
2022-05-22 21:01:14 +02:00
|
|
|
description: String? = null,
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
focus: Attachment.Focus? = null,
|
2022-05-22 21:01:14 +02:00
|
|
|
replaceItem: QueuedMedia? = null
|
2021-01-21 18:57:09 +01:00
|
|
|
): QueuedMedia {
|
2022-05-22 21:01:14 +02:00
|
|
|
var stashMediaItem: QueuedMedia? = null
|
|
|
|
|
2024-03-27 11:17:42 +01:00
|
|
|
_media.update { mediaList ->
|
2022-05-03 19:12:35 +02:00
|
|
|
val mediaItem = QueuedMedia(
|
2022-12-29 19:58:23 +01:00
|
|
|
localId = mediaUploader.getNewLocalMediaId(),
|
2022-05-03 19:12:35 +02:00
|
|
|
uri = uri,
|
|
|
|
type = type,
|
|
|
|
mediaSize = mediaSize,
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
description = description,
|
2022-12-29 19:58:23 +01:00
|
|
|
focus = focus,
|
|
|
|
state = QueuedMedia.State.UPLOADING
|
2022-05-03 19:12:35 +02:00
|
|
|
)
|
2022-05-22 21:01:14 +02:00
|
|
|
stashMediaItem = mediaItem
|
|
|
|
|
|
|
|
if (replaceItem != null) {
|
2022-12-29 19:58:23 +01:00
|
|
|
mediaUploader.cancelUploadScope(replaceItem.localId)
|
2023-04-24 11:48:40 +02:00
|
|
|
mediaList.map {
|
2022-05-22 21:01:14 +02:00
|
|
|
if (it.localId == replaceItem.localId) mediaItem else it
|
|
|
|
}
|
|
|
|
} else { // Append
|
2023-04-24 11:48:40 +02:00
|
|
|
mediaList + mediaItem
|
2022-05-22 21:01:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
val mediaItem = stashMediaItem!! // stashMediaItem is always non-null and uncaptured at this point, but Kotlin doesn't know that
|
|
|
|
|
2022-12-29 19:58:23 +01:00
|
|
|
viewModelScope.launch {
|
2022-04-21 18:46:21 +02:00
|
|
|
mediaUploader
|
2022-07-26 20:24:50 +02:00
|
|
|
.uploadMedia(mediaItem, instanceInfo.first())
|
2022-04-21 18:46:21 +02:00
|
|
|
.collect { event ->
|
2024-03-27 11:17:42 +01:00
|
|
|
val item = _media.value.find { it.localId == mediaItem.localId }
|
2022-04-21 18:46:21 +02:00
|
|
|
?: return@collect
|
2019-12-19 19:09:40 +01:00
|
|
|
val newMediaItem = when (event) {
|
|
|
|
is UploadEvent.ProgressEvent ->
|
|
|
|
item.copy(uploadPercent = event.percentage)
|
|
|
|
is UploadEvent.FinishedEvent ->
|
2022-12-29 19:58:23 +01:00
|
|
|
item.copy(
|
|
|
|
id = event.mediaId,
|
|
|
|
uploadPercent = -1,
|
2024-01-04 17:00:55 +01:00
|
|
|
state = if (event.processed) {
|
|
|
|
QueuedMedia.State.PROCESSED
|
|
|
|
} else {
|
|
|
|
QueuedMedia.State.UNPROCESSED
|
|
|
|
}
|
2022-12-29 19:58:23 +01:00
|
|
|
)
|
|
|
|
is UploadEvent.ErrorEvent -> {
|
2024-03-27 11:17:42 +01:00
|
|
|
_media.update { mediaList -> mediaList.filter { it.localId != mediaItem.localId } }
|
2024-03-29 20:02:12 +01:00
|
|
|
_uploadError.emit(event.error)
|
2022-12-29 19:58:23 +01:00
|
|
|
return@collect
|
|
|
|
}
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
2024-03-27 11:17:42 +01:00
|
|
|
_media.update { mediaList ->
|
2023-04-24 11:48:40 +02:00
|
|
|
mediaList.map { mediaItem ->
|
2022-05-03 19:12:35 +02:00
|
|
|
if (mediaItem.localId == newMediaItem.localId) {
|
|
|
|
newMediaItem
|
2021-06-28 22:04:34 +02:00
|
|
|
} else {
|
2022-05-03 19:12:35 +02:00
|
|
|
mediaItem
|
2021-06-28 22:04:34 +02:00
|
|
|
}
|
2022-05-03 19:12:35 +02:00
|
|
|
}
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
2021-06-28 22:04:34 +02:00
|
|
|
}
|
2022-04-21 18:46:21 +02:00
|
|
|
}
|
2024-02-23 10:27:19 +01:00
|
|
|
updateCloseConfirmation()
|
2019-12-19 19:09:40 +01:00
|
|
|
return mediaItem
|
|
|
|
}
|
|
|
|
|
2024-03-27 11:17:42 +01:00
|
|
|
fun changeStatusVisibility(visibility: Status.Visibility) {
|
|
|
|
_statusVisibility.value = visibility
|
|
|
|
}
|
|
|
|
|
2024-01-04 17:00:55 +01:00
|
|
|
private fun addUploadedMedia(
|
|
|
|
id: String,
|
|
|
|
type: QueuedMedia.Type,
|
|
|
|
uri: Uri,
|
|
|
|
description: String?,
|
|
|
|
focus: Attachment.Focus?
|
|
|
|
) {
|
2024-03-27 11:17:42 +01:00
|
|
|
_media.update { mediaList ->
|
2022-05-03 19:12:35 +02:00
|
|
|
val mediaItem = QueuedMedia(
|
2022-12-29 19:58:23 +01:00
|
|
|
localId = mediaUploader.getNewLocalMediaId(),
|
2022-05-03 19:12:35 +02:00
|
|
|
uri = uri,
|
|
|
|
type = type,
|
|
|
|
mediaSize = 0,
|
|
|
|
uploadPercent = -1,
|
|
|
|
id = id,
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
description = description,
|
2022-12-08 10:18:12 +01:00
|
|
|
focus = focus,
|
2022-12-29 19:58:23 +01:00
|
|
|
state = QueuedMedia.State.PUBLISHED
|
2022-05-03 19:12:35 +02:00
|
|
|
)
|
2023-04-24 11:48:40 +02:00
|
|
|
mediaList + mediaItem
|
2022-05-03 19:12:35 +02:00
|
|
|
}
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun removeMediaFromQueue(item: QueuedMedia) {
|
2022-12-29 19:58:23 +01:00
|
|
|
mediaUploader.cancelUploadScope(item.localId)
|
2024-03-27 11:17:42 +01:00
|
|
|
_media.update { mediaList -> mediaList.filter { it.localId != item.localId } }
|
2024-02-23 10:27:19 +01:00
|
|
|
updateCloseConfirmation()
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
2021-01-21 18:57:09 +01:00
|
|
|
fun toggleMarkSensitive() {
|
2024-03-27 11:17:42 +01:00
|
|
|
this._markMediaAsSensitive.value = this._markMediaAsSensitive.value != true
|
2021-01-21 18:57:09 +01:00
|
|
|
}
|
|
|
|
|
2024-02-23 10:27:19 +01:00
|
|
|
fun updateContent(newContent: String?) {
|
|
|
|
currentContent = newContent
|
|
|
|
updateCloseConfirmation()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun updateContentWarning(newContentWarning: String?) {
|
|
|
|
currentContentWarning = newContentWarning
|
|
|
|
updateCloseConfirmation()
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun updateCloseConfirmation() {
|
2024-03-27 11:17:42 +01:00
|
|
|
val contentWarning = if (_showContentWarning.value) {
|
2024-02-23 10:27:19 +01:00
|
|
|
currentContentWarning
|
|
|
|
} else {
|
|
|
|
""
|
|
|
|
}
|
2024-03-27 11:17:42 +01:00
|
|
|
this._closeConfirmation.value = if (didChange(currentContent, contentWarning)) {
|
2023-06-13 15:45:17 +02:00
|
|
|
when (composeKind) {
|
2024-02-23 10:27:19 +01:00
|
|
|
ComposeKind.NEW -> if (isEmpty(currentContent, contentWarning)) {
|
2023-06-13 15:45:17 +02:00
|
|
|
ConfirmationKind.NONE
|
|
|
|
} else {
|
|
|
|
ConfirmationKind.SAVE_OR_DISCARD
|
|
|
|
}
|
2024-02-23 10:27:19 +01:00
|
|
|
ComposeKind.EDIT_DRAFT -> if (isEmpty(currentContent, contentWarning)) {
|
2023-06-13 15:45:17 +02:00
|
|
|
ConfirmationKind.CONTINUE_EDITING_OR_DISCARD_DRAFT
|
|
|
|
} else {
|
|
|
|
ConfirmationKind.UPDATE_OR_DISCARD
|
|
|
|
}
|
|
|
|
ComposeKind.EDIT_POSTED -> ConfirmationKind.CONTINUE_EDITING_OR_DISCARD_CHANGES
|
|
|
|
ComposeKind.EDIT_SCHEDULED -> ConfirmationKind.CONTINUE_EDITING_OR_DISCARD_CHANGES
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ConfirmationKind.NONE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun didChange(content: String?, contentWarning: String?): Boolean {
|
Fix saving changes to statuses when editing (#3103)
* Fix saving changes to statuses when editing
With the previous code backing out of a status editing operation where changes
had been made (whether it was editing an existing status, a scheduled status,
or a draft) would prompt the user to save the changes as a new draft.
See https://github.com/tuskyapp/Tusky/issues/2704 and
https://github.com/tuskyapp/Tusky/issues/2705 for more detail.
The fix:
- Create an enum to represent the four different kinds of edits that can
happen
- Editing a new status (i.e., composing it for the first time)
- Editing a posted status
- Editing a draft
- Editing a scheduled status
- Store this in ComposeOptions, and set it appropriately everywhere
ComposeOptions is created.
- Check the edit kind when backing out of ComposeActivity, and use this to
show one of three different dialogs as appropriate so the user can:
- Save as new draft or discard changes
- Continue editing or discard changes
- Update existing draft or discard changes
Also fix ComposeViewModel.didChange(), which erroneously reported false if the
old text started with the new text (e.g., if the old text was "hello, world"
and it was edited to "hello", didChange() would not consider that to be a
change).
Fixes https://github.com/tuskyapp/Tusky/issues/2704,
https://github.com/tuskyapp/Tusky/issues/2705
* Use orEmpty extension function
2022-12-31 13:04:49 +01:00
|
|
|
val textChanged = content.orEmpty() != startingText.orEmpty()
|
|
|
|
val contentWarningChanged = contentWarning.orEmpty() != startingContentWarning
|
2024-03-27 11:17:42 +01:00
|
|
|
val mediaChanged = _media.value.isNotEmpty()
|
|
|
|
val pollChanged = _poll.value != null
|
2022-07-27 21:06:51 +02:00
|
|
|
val didScheduledTimeChange = hasScheduledTimeChanged
|
2019-12-19 19:09:40 +01:00
|
|
|
|
2022-07-27 21:06:51 +02:00
|
|
|
return modifiedInitialState || textChanged || contentWarningChanged || mediaChanged || pollChanged || didScheduledTimeChange
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
2023-06-13 15:45:17 +02:00
|
|
|
private fun isEmpty(content: String?, contentWarning: String?): Boolean {
|
2024-03-27 11:17:42 +01:00
|
|
|
return !modifiedInitialState && (content.isNullOrBlank() && contentWarning.isNullOrBlank() && _media.value.isEmpty() && _poll.value == null)
|
2023-06-13 15:45:17 +02:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:24 +02:00
|
|
|
fun contentWarningChanged(value: Boolean) {
|
2024-03-27 11:17:42 +01:00
|
|
|
_showContentWarning.value = value
|
2020-04-18 15:06:24 +02:00
|
|
|
contentWarningStateChanged = true
|
2024-02-23 10:27:19 +01:00
|
|
|
updateCloseConfirmation()
|
2020-04-18 15:06:24 +02:00
|
|
|
}
|
|
|
|
|
2019-12-19 19:09:40 +01:00
|
|
|
fun deleteDraft() {
|
2021-06-24 21:23:29 +02:00
|
|
|
viewModelScope.launch {
|
|
|
|
if (draftId != 0) {
|
|
|
|
draftHelper.deleteDraftAndAttachments(draftId)
|
|
|
|
}
|
2021-01-21 18:57:09 +01:00
|
|
|
}
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
2022-12-29 19:58:23 +01:00
|
|
|
fun stopUploads() {
|
2024-03-27 11:17:42 +01:00
|
|
|
mediaUploader.cancelUploadScope(*_media.value.map { it.localId }.toIntArray())
|
2022-12-29 19:58:23 +01:00
|
|
|
}
|
|
|
|
|
2022-05-09 19:39:43 +02:00
|
|
|
fun shouldShowSaveDraftDialog(): Boolean {
|
|
|
|
// if any of the media files need to be downloaded first it could take a while, so show a loading dialog
|
2024-03-27 11:17:42 +01:00
|
|
|
return _media.value.any { mediaValue ->
|
2022-05-09 19:39:43 +02:00
|
|
|
mediaValue.uri.scheme == "https"
|
|
|
|
}
|
|
|
|
}
|
2021-01-21 18:57:09 +01:00
|
|
|
|
2022-05-09 19:39:43 +02:00
|
|
|
suspend fun saveDraft(content: String, contentWarning: String) {
|
|
|
|
val mediaUris: MutableList<String> = mutableListOf()
|
|
|
|
val mediaDescriptions: MutableList<String?> = mutableListOf()
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
val mediaFocus: MutableList<Attachment.Focus?> = mutableListOf()
|
2024-03-27 11:17:42 +01:00
|
|
|
for (item in _media.value) {
|
2022-05-09 19:39:43 +02:00
|
|
|
mediaUris.add(item.uri.toString())
|
|
|
|
mediaDescriptions.add(item.description)
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
mediaFocus.add(item.focus)
|
2021-06-24 21:23:29 +02:00
|
|
|
}
|
2022-05-09 19:39:43 +02:00
|
|
|
|
|
|
|
draftHelper.saveDraft(
|
|
|
|
draftId = draftId,
|
|
|
|
accountId = accountManager.activeAccount?.id!!,
|
|
|
|
inReplyToId = inReplyToId,
|
|
|
|
content = content,
|
|
|
|
contentWarning = contentWarning,
|
2024-03-27 11:17:42 +01:00
|
|
|
sensitive = _markMediaAsSensitive.value,
|
|
|
|
visibility = _statusVisibility.value,
|
2022-05-09 19:39:43 +02:00
|
|
|
mediaUris = mediaUris,
|
|
|
|
mediaDescriptions = mediaDescriptions,
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
mediaFocus = mediaFocus,
|
2024-03-27 11:17:42 +01:00
|
|
|
poll = _poll.value,
|
2022-07-27 21:06:51 +02:00
|
|
|
failedToSend = false,
|
2023-01-28 12:40:36 +01:00
|
|
|
failedToSendAlert = false,
|
2024-03-27 11:17:42 +01:00
|
|
|
scheduledAt = _scheduledAt.value,
|
2022-08-31 18:53:57 +02:00
|
|
|
language = postLanguage,
|
2023-03-13 13:16:39 +01:00
|
|
|
statusId = originalStatusId
|
2022-05-09 19:39:43 +02:00
|
|
|
)
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send status to the server.
|
|
|
|
* Uses current state plus provided arguments.
|
|
|
|
*/
|
2024-01-04 17:00:55 +01:00
|
|
|
suspend fun sendStatus(content: String, spoilerText: String, accountId: Long) {
|
2022-07-26 20:24:50 +02:00
|
|
|
if (!scheduledTootId.isNullOrEmpty()) {
|
|
|
|
api.deleteScheduledStatus(scheduledTootId!!)
|
|
|
|
}
|
2020-10-25 18:41:11 +01:00
|
|
|
|
2024-03-27 11:17:42 +01:00
|
|
|
val attachedMedia = _media.value.map { item ->
|
2022-12-29 19:58:23 +01:00
|
|
|
MediaToSend(
|
|
|
|
localId = item.localId,
|
|
|
|
id = item.id,
|
|
|
|
uri = item.uri.toString(),
|
|
|
|
description = item.description,
|
|
|
|
focus = item.focus,
|
|
|
|
processed = item.state == QueuedMedia.State.PROCESSED || item.state == QueuedMedia.State.PUBLISHED
|
|
|
|
)
|
|
|
|
}
|
|
|
|
val tootToSend = StatusToSend(
|
|
|
|
text = content,
|
|
|
|
warningText = spoilerText,
|
Replace Gson library with Moshi (#4309)
**! ! Warning**: Do not merge before testing every API call and database
read involving JSON !
**Gson** is obsolete and has been superseded by **Moshi**. But more
importantly, parsing Kotlin objects using Gson is _dangerous_ because
Gson uses Java serialization and is **not Kotlin-aware**. This has two
main consequences:
- Fields of non-null types may end up null at runtime. Parsing will
succeed, but the code may crash later with a `NullPointerException` when
trying to access a field member;
- Default values of constructor parameters are always ignored. When
absent, reference types will be null, booleans will be false and
integers will be zero.
On the other hand, Kotlin-aware parsers like **Moshi** or **Kotlin
Serialization** will validate at parsing time that all received fields
comply with the Kotlin contract and avoid errors at runtime, making apps
more stable and schema mismatches easier to detect (as long as logs are
accessible):
- Receiving a null value for a non-null type will generate a parsing
error;
- Optional types are declared explicitly by adding a default value. **A
missing value with no default value declaration will generate a parsing
error.**
Migrating the entity declarations from Gson to Moshi will make the code
more robust but is not an easy task because of the semantic differences.
With Gson, both nullable and optional fields are represented with a null
value. After converting to Moshi, some nullable entities can become
non-null with a default value (if they are optional and not nullable),
others can stay nullable with no default value (if they are mandatory
and nullable), and others can become **nullable with a default value of
null** (if they are optional _or_ nullable _or_ both). That third option
is the safest bet when it's not clear if a field is optional or not,
except for lists which can usually be declared as non-null with a
default value of an empty list (I have yet to see a nullable array type
in the Mastodon API).
Fields that are currently declared as non-null present another
challenge. In theory, they should remain as-is and everything will work
fine. In practice, **because Gson is not aware of nullable types at
all**, it's possible that some non-null fields currently hold a null
value in some cases but the app does not report any error because the
field is not accessed by Kotlin code in that scenario. After migrating
to Moshi however, parsing such a field will now fail early if a null
value or no value is received.
These fields will have to be identified by heavily testing the app and
looking for parsing errors (`JsonDataException`) and/or by going through
the Mastodon documentation. A default value needs to be added for
missing optional fields, and their type could optionally be changed to
nullable, depending on the case.
Gson is also currently used to serialize and deserialize objects to and
from the local database, which is also challenging because backwards
compatibility needs to be preserved. Fortunately, by default Gson omits
writing null fields, so a field of type `List<T>?` could be replaced
with a field of type `List<T>` with a default value of `emptyList()` and
reading back the old data should still work. However, nullable lists
that are written directly (not as a field of another object) will still
be serialized to JSON as `"null"` so the deserializing code must still
be handling null properly.
Finally, changing the database schema is out of scope for this pull
request, so database entities that also happen to be serialized with
Gson will keep their original types even if they could be made non-null
as an improvement.
In the end this is all for the best, because the app will be more
reliable and errors will be easier to detect by showing up earlier with
a clear error message. Not to mention the performance benefits of using
Moshi compared to Gson.
- Replace Gson reflection with Moshi Kotlin codegen to generate all
parsers at compile time.
- Replace custom `Rfc3339DateJsonAdapter` with the one provided by
moshi-adapters.
- Replace custom `JsonDeserializer` classes for Enum types with
`EnumJsonAdapter.create(T).withUnknownFallback()` from moshi-adapters to
support fallback values.
- Replace `GuardedBooleanAdapter` with the more generic `GuardedAdapter`
which works with any type. Any nullable field may now be annotated with
`@Guarded`.
- Remove Proguard rules related to Json entities. Each Json entity needs
to be annotated with `@JsonClass` with no exception, and adding this
annotation will ensure that R8/Proguard will handle the entities
properly.
- Replace some nullable Boolean fields with non-null Boolean fields with
a default value where possible.
- Replace some nullable list fields with non-null list fields with a
default value of `emptyList()` where possible.
- Update `TimelineDao` to perform all Json conversions internally using
`Converters` so no Gson or Moshi instance has to be passed to its
methods.
- ~~Create a custom `DraftAttachmentJsonAdapter` to serialize and
deserialize `DraftAttachment` which is a special entity that supports
more than one json name per field. A custom adapter is necessary because
there is not direct equivalent of `@SerializedName(alternate = [...])`
in Moshi.~~ Remove alternate names for some `DraftAttachment` fields
which were used as a workaround to deserialize local data in 2-years old
builds of Tusky.
- Update tests to make them work with Moshi.
- Simplify a few `equals()` implementations.
- Change a few functions to `val`s
- Turn `NetworkModule` into an `object` (since it contains no abstract
methods).
Please test the app thoroughly before merging. There may be some fields
currently declared as mandatory that are actually optional.
2024-04-02 21:01:04 +02:00
|
|
|
visibility = _statusVisibility.value.serverString,
|
2024-03-27 11:17:42 +01:00
|
|
|
sensitive = attachedMedia.isNotEmpty() && (_markMediaAsSensitive.value || _showContentWarning.value),
|
2022-12-29 19:58:23 +01:00
|
|
|
media = attachedMedia,
|
2024-03-27 11:17:42 +01:00
|
|
|
scheduledAt = _scheduledAt.value,
|
2022-12-29 19:58:23 +01:00
|
|
|
inReplyToId = inReplyToId,
|
2024-03-27 11:17:42 +01:00
|
|
|
poll = _poll.value,
|
2022-12-29 19:58:23 +01:00
|
|
|
replyingStatusContent = null,
|
|
|
|
replyingStatusAuthorUsername = null,
|
2023-05-29 13:32:56 +02:00
|
|
|
accountId = accountId,
|
2022-12-29 19:58:23 +01:00
|
|
|
draftId = draftId,
|
|
|
|
idempotencyKey = randomAlphanumericString(16),
|
|
|
|
retries = 0,
|
|
|
|
language = postLanguage,
|
|
|
|
statusId = originalStatusId
|
|
|
|
)
|
|
|
|
|
|
|
|
serviceClient.sendToot(tootToSend)
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
2023-04-24 11:48:40 +02:00
|
|
|
private fun updateMediaItem(localId: Int, mutator: (QueuedMedia) -> QueuedMedia) {
|
2024-03-27 11:17:42 +01:00
|
|
|
_media.update { mediaList ->
|
2023-04-24 11:48:40 +02:00
|
|
|
mediaList.map { mediaItem ->
|
2022-05-03 19:12:35 +02:00
|
|
|
if (mediaItem.localId == localId) {
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
mutator(mediaItem)
|
2022-05-03 19:12:35 +02:00
|
|
|
} else {
|
|
|
|
mediaItem
|
|
|
|
}
|
|
|
|
}
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-24 11:48:40 +02:00
|
|
|
fun updateDescription(localId: Int, description: String) {
|
|
|
|
updateMediaItem(localId) { mediaItem ->
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
mediaItem.copy(description = description)
|
2022-12-29 19:58:23 +01:00
|
|
|
}
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
}
|
|
|
|
|
2023-04-24 11:48:40 +02:00
|
|
|
fun updateFocus(localId: Int, focus: Attachment.Focus) {
|
|
|
|
updateMediaItem(localId) { mediaItem ->
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
mediaItem.copy(focus = focus)
|
2022-12-29 19:58:23 +01:00
|
|
|
}
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
}
|
|
|
|
|
2022-05-17 19:55:37 +02:00
|
|
|
fun searchAutocompleteSuggestions(token: String): List<AutocompleteResult> {
|
2024-02-29 15:28:48 +01:00
|
|
|
return when (token[0]) {
|
|
|
|
'@' -> runBlocking {
|
|
|
|
api.searchAccounts(query = token.substring(1), limit = 10)
|
2022-05-17 19:55:37 +02:00
|
|
|
.fold({ accounts ->
|
|
|
|
accounts.map { AutocompleteResult.AccountResult(it) }
|
|
|
|
}, { e ->
|
|
|
|
Log.e(TAG, "Autocomplete search for $token failed.", e)
|
|
|
|
emptyList()
|
|
|
|
})
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
2024-02-29 15:28:48 +01:00
|
|
|
'#' -> runBlocking {
|
|
|
|
api.search(
|
2024-01-04 17:00:55 +01:00
|
|
|
query = token,
|
|
|
|
type = SearchType.Hashtag.apiParameter,
|
|
|
|
limit = 10
|
|
|
|
)
|
2022-05-17 19:55:37 +02:00
|
|
|
.fold({ searchResult ->
|
|
|
|
searchResult.hashtags.map { AutocompleteResult.HashtagResult(it.name) }
|
|
|
|
}, { e ->
|
|
|
|
Log.e(TAG, "Autocomplete search for $token failed.", e)
|
|
|
|
emptyList()
|
|
|
|
})
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
':' -> {
|
2022-07-26 20:24:50 +02:00
|
|
|
val emojiList = emoji.replayCache.firstOrNull() ?: return emptyList()
|
2022-05-17 19:55:37 +02:00
|
|
|
val incomplete = token.substring(1)
|
|
|
|
|
2024-02-29 15:28:48 +01:00
|
|
|
emojiList.filter { emoji ->
|
2022-05-17 19:55:37 +02:00
|
|
|
emoji.shortcode.contains(incomplete, ignoreCase = true)
|
|
|
|
}.sortedBy { emoji ->
|
|
|
|
emoji.shortcode.indexOf(incomplete, ignoreCase = true)
|
|
|
|
}.map { emoji ->
|
|
|
|
AutocompleteResult.EmojiResult(emoji)
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else -> {
|
|
|
|
Log.w(TAG, "Unexpected autocompletion token: $token")
|
2024-02-29 15:28:48 +01:00
|
|
|
emptyList()
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-21 18:57:09 +01:00
|
|
|
fun setup(composeOptions: ComposeActivity.ComposeOptions?) {
|
2022-08-03 17:23:54 +02:00
|
|
|
if (setupComplete) {
|
2021-01-21 18:57:09 +01:00
|
|
|
return
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
2023-06-13 15:45:17 +02:00
|
|
|
composeKind = composeOptions?.kind ?: ComposeKind.NEW
|
Fix saving changes to statuses when editing (#3103)
* Fix saving changes to statuses when editing
With the previous code backing out of a status editing operation where changes
had been made (whether it was editing an existing status, a scheduled status,
or a draft) would prompt the user to save the changes as a new draft.
See https://github.com/tuskyapp/Tusky/issues/2704 and
https://github.com/tuskyapp/Tusky/issues/2705 for more detail.
The fix:
- Create an enum to represent the four different kinds of edits that can
happen
- Editing a new status (i.e., composing it for the first time)
- Editing a posted status
- Editing a draft
- Editing a scheduled status
- Store this in ComposeOptions, and set it appropriately everywhere
ComposeOptions is created.
- Check the edit kind when backing out of ComposeActivity, and use this to
show one of three different dialogs as appropriate so the user can:
- Save as new draft or discard changes
- Continue editing or discard changes
- Update existing draft or discard changes
Also fix ComposeViewModel.didChange(), which erroneously reported false if the
old text started with the new text (e.g., if the old text was "hello, world"
and it was edited to "hello", didChange() would not consider that to be a
change).
Fixes https://github.com/tuskyapp/Tusky/issues/2704,
https://github.com/tuskyapp/Tusky/issues/2705
* Use orEmpty extension function
2022-12-31 13:04:49 +01:00
|
|
|
|
2019-12-19 19:09:40 +01:00
|
|
|
val preferredVisibility = accountManager.activeAccount!!.defaultPostPrivacy
|
|
|
|
|
|
|
|
val replyVisibility = composeOptions?.replyVisibility ?: Status.Visibility.UNKNOWN
|
|
|
|
startingVisibility = Status.Visibility.byNum(
|
2021-06-28 22:04:34 +02:00
|
|
|
preferredVisibility.num.coerceAtLeast(replyVisibility.num)
|
|
|
|
)
|
2019-12-19 19:09:40 +01:00
|
|
|
|
|
|
|
inReplyToId = composeOptions?.inReplyToId
|
2021-01-21 18:57:09 +01:00
|
|
|
|
2020-10-02 18:32:46 +02:00
|
|
|
modifiedInitialState = composeOptions?.modifiedInitialState == true
|
2019-12-19 19:09:40 +01:00
|
|
|
|
|
|
|
val contentWarning = composeOptions?.contentWarning
|
|
|
|
if (contentWarning != null) {
|
|
|
|
startingContentWarning = contentWarning
|
|
|
|
}
|
2020-04-18 15:06:24 +02:00
|
|
|
if (!contentWarningStateChanged) {
|
2024-03-27 11:17:42 +01:00
|
|
|
_showContentWarning.value = !contentWarning.isNullOrBlank()
|
2020-04-18 15:06:24 +02:00
|
|
|
}
|
2019-12-19 19:09:40 +01:00
|
|
|
|
|
|
|
// recreate media list
|
2021-01-21 18:57:09 +01:00
|
|
|
val draftAttachments = composeOptions?.draftAttachments
|
2021-05-16 19:17:56 +02:00
|
|
|
if (draftAttachments != null) {
|
2021-01-21 18:57:09 +01:00
|
|
|
// when coming from DraftActivity
|
2022-05-03 19:12:35 +02:00
|
|
|
viewModelScope.launch {
|
|
|
|
draftAttachments.forEach { attachment ->
|
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.
* Remove code duplication between 'update description' and 'update focus'
* Fix ktlint/bitrise failures
* Make updateMediaItem private
* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.
* Replace use of PointF for Focus where focus is represented, fix ktlint
* Substitute 'focus' for 'focus point' in strings
* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide
* Redraw focus after each tap
* Dark curtain where focus isn't (now looks like mastosoc)
* Correct ktlint for FocusDialog
* draft: switch to overlay for focus indicator
* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas
* Switch focus circle to path approach
* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right
* ktlint fixes and comments
* Focus indicator drawing should use device-independent pixels
* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)
* Correct max-height behavior for screens in landscape mode
* Focus attachment result is are flipped on x axis; fix this
* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)
* More focus ktlint fixes
* Fix specific case where a draft is given a focus, then deleted, then posted in that order
* Fix accidental file change in focus PR
* ktLint fix
* Fix property style warnings in focus
* Fix remaining style warnings from focus PR
Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
|
|
|
pickMedia(attachment.uri, attachment.description, attachment.focus)
|
2022-04-21 18:46:21 +02:00
|
|
|
}
|
|
|
|
}
|
2023-03-13 13:16:39 +01:00
|
|
|
} else {
|
|
|
|
composeOptions?.mediaAttachments?.forEach { a ->
|
|
|
|
// when coming from redraft or ScheduledTootActivity
|
|
|
|
val mediaType = when (a.type) {
|
|
|
|
Attachment.Type.VIDEO, Attachment.Type.GIFV -> QueuedMedia.Type.VIDEO
|
|
|
|
Attachment.Type.UNKNOWN, Attachment.Type.IMAGE -> QueuedMedia.Type.IMAGE
|
|
|
|
Attachment.Type.AUDIO -> QueuedMedia.Type.AUDIO
|
|
|
|
}
|
|
|
|
addUploadedMedia(a.id, mediaType, a.url.toUri(), a.description, a.meta?.focus)
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-21 18:57:09 +01:00
|
|
|
draftId = composeOptions?.draftId ?: 0
|
|
|
|
scheduledTootId = composeOptions?.scheduledTootId
|
2022-12-08 10:18:12 +01:00
|
|
|
originalStatusId = composeOptions?.statusId
|
2022-03-20 20:21:42 +01:00
|
|
|
startingText = composeOptions?.content
|
2022-08-31 18:53:57 +02:00
|
|
|
postLanguage = composeOptions?.language
|
2019-12-21 15:56:07 +01:00
|
|
|
|
2019-12-19 19:09:40 +01:00
|
|
|
val tootVisibility = composeOptions?.visibility ?: Status.Visibility.UNKNOWN
|
|
|
|
if (tootVisibility.num != Status.Visibility.UNKNOWN.num) {
|
|
|
|
startingVisibility = tootVisibility
|
|
|
|
}
|
2024-03-27 11:17:42 +01:00
|
|
|
_statusVisibility.value = startingVisibility
|
2019-12-19 19:09:40 +01:00
|
|
|
val mentionedUsernames = composeOptions?.mentionedUsernames
|
|
|
|
if (mentionedUsernames != null) {
|
|
|
|
val builder = StringBuilder()
|
|
|
|
for (name in mentionedUsernames) {
|
|
|
|
builder.append('@')
|
|
|
|
builder.append(name)
|
|
|
|
builder.append(' ')
|
|
|
|
}
|
|
|
|
startingText = builder.toString()
|
|
|
|
}
|
|
|
|
|
2024-03-27 11:17:42 +01:00
|
|
|
_scheduledAt.value = composeOptions?.scheduledAt
|
2019-12-19 19:09:40 +01:00
|
|
|
|
2024-03-27 11:17:42 +01:00
|
|
|
composeOptions?.sensitive?.let { _markMediaAsSensitive.value = it }
|
2019-12-19 19:09:40 +01:00
|
|
|
|
|
|
|
val poll = composeOptions?.poll
|
|
|
|
if (poll != null && composeOptions.mediaAttachments.isNullOrEmpty()) {
|
2024-03-27 11:17:42 +01:00
|
|
|
this._poll.value = poll
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
replyingStatusContent = composeOptions?.replyingStatusContent
|
|
|
|
replyingStatusAuthor = composeOptions?.replyingStatusAuthor
|
2022-08-03 17:23:54 +02:00
|
|
|
|
2024-02-23 10:27:19 +01:00
|
|
|
updateCloseConfirmation()
|
|
|
|
|
2022-08-03 17:23:54 +02:00
|
|
|
setupComplete = true
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
2024-02-23 10:27:19 +01:00
|
|
|
fun updatePoll(newPoll: NewPoll?) {
|
2024-03-27 11:17:42 +01:00
|
|
|
_poll.value = newPoll
|
2024-02-23 10:27:19 +01:00
|
|
|
updateCloseConfirmation()
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun updateScheduledAt(newScheduledAt: String?) {
|
2024-03-27 11:17:42 +01:00
|
|
|
if (newScheduledAt != _scheduledAt.value) {
|
2022-07-27 21:06:51 +02:00
|
|
|
hasScheduledTimeChanged = true
|
|
|
|
}
|
|
|
|
|
2024-03-27 11:17:42 +01:00
|
|
|
_scheduledAt.value = newScheduledAt
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:18:12 +01:00
|
|
|
val editing: Boolean
|
|
|
|
get() = !originalStatusId.isNullOrEmpty()
|
|
|
|
|
2019-12-19 19:09:40 +01:00
|
|
|
private companion object {
|
|
|
|
const val TAG = "ComposeViewModel"
|
|
|
|
}
|
2023-06-13 15:45:17 +02:00
|
|
|
|
|
|
|
enum class ConfirmationKind {
|
|
|
|
NONE, // just close
|
|
|
|
SAVE_OR_DISCARD,
|
|
|
|
UPDATE_OR_DISCARD,
|
|
|
|
CONTINUE_EDITING_OR_DISCARD_CHANGES, // editing post
|
|
|
|
CONTINUE_EDITING_OR_DISCARD_DRAFT // edit draft
|
|
|
|
}
|
2019-12-19 19:09:40 +01:00
|
|
|
}
|
|
|
|
|
2021-01-21 18:57:09 +01:00
|
|
|
/**
|
|
|
|
* Thrown when trying to add an image when video is already present or the other way around
|
|
|
|
*/
|
2021-01-31 18:58:45 +01:00
|
|
|
class VideoOrImageException : Exception()
|