ComposeActivity: add unlimited attachments support again

main
Alibek Omarov 5 years ago
parent 2e2ab4ed6a
commit 5e9bd26f24
  1. 14
      app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt

@ -290,6 +290,14 @@ class ComposeActivity : BaseActivity(),
composeEditField.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
}
}
private fun reenableAttachments() {
// in case of we already had disabled attachments
// but got information about extension later
enableButton(composeAddMediaButton, true, true)
if(viewModel.poll == null)
enablePollButton(true)
}
private fun subscribeToUpdates(mediaAdapter: MediaPreviewAdapter) {
withLifecycleContext {
@ -298,6 +306,8 @@ class ComposeActivity : BaseActivity(),
updateVisibleCharactersLeft()
composeScheduleButton.visible(instanceData.supportsScheduled)
composeMarkdownButton.visible(instanceData.supportsFormatting)
if(instanceData.hasNoAttachmentLimits)
reenableAttachments()
}
viewModel.emoji.observe { emoji -> setEmojiList(emoji) }
combineLiveData(viewModel.markMediaAsSensitive, viewModel.showContentWarning) { markSensitive, showContentWarning ->
@ -325,9 +335,9 @@ class ComposeActivity : BaseActivity(),
updateScheduleButton()
}
combineOptionalLiveData(viewModel.media, viewModel.poll) { media, poll ->
val active = poll == null
val active = viewModel.instanceParams.value!!.hasNoAttachmentLimits || (poll == null
&& media!!.size != 4
&& media.firstOrNull()?.type != QueuedMedia.Type.VIDEO
&& media.firstOrNull()?.type != QueuedMedia.Type.VIDEO)
enableButton(composeAddMediaButton, active, active)
enablePollButton(media.isNullOrEmpty())
}.subscribe()

Loading…
Cancel
Save