Attempt to fix the Preview behavior

This fix should fix the behavior where the Preview view does not close
properly when the button is pressed again.

Fixes: https://todo.sr.ht/~captainepoch/husky/29
This commit is contained in:
Adolfo Santiago 2022-05-21 12:30:56 +02:00
parent da32a9f66b
commit 2959f2aa9c
No known key found for this signature in database
GPG key ID: 244D6F9A317B4A65

View file

@ -1100,8 +1100,12 @@ class ComposeActivity : BaseActivity(),
}
private fun onSendClicked(preview: Boolean) {
if(preview && previewBehavior.state != BottomSheetBehavior.STATE_HIDDEN) {
if(preview && previewBehavior.state != BottomSheetBehavior.STATE_HIDDEN
&& previewBehavior.state != BottomSheetBehavior.STATE_COLLAPSED
) {
previewBehavior.state = BottomSheetBehavior.STATE_HIDDEN
return
}
if(verifyScheduledTime()) {
@ -1113,7 +1117,9 @@ class ComposeActivity : BaseActivity(),
private fun onStatusPreviewReady(status: Status) {
enableButtons(true)
if(previewBehavior.state != BottomSheetBehavior.STATE_HIDDEN) {
if(previewBehavior.state != BottomSheetBehavior.STATE_HIDDEN
&& previewBehavior.state != BottomSheetBehavior.STATE_COLLAPSED
) {
previewBehavior.state = BottomSheetBehavior.STATE_HIDDEN
} else {
binding.previewView.setupWithStatus(status)