Apply 150ms delay to story chrome fadeout.
This commit is contained in:
parent
28e10dbb43
commit
d64aa3bc43
4 changed files with 22 additions and 2 deletions
|
@ -51,6 +51,8 @@ class StoryViewerViewModel(
|
|||
var hasConsumedInitialState = false
|
||||
private set
|
||||
|
||||
val isChildScrolling: Observable<Boolean> = childScrollStatePublisher.distinctUntilChanged()
|
||||
|
||||
init {
|
||||
refresh()
|
||||
}
|
||||
|
|
|
@ -235,6 +235,7 @@ class StoryViewerPageFragment :
|
|||
if ((canCloseFromHorizontalSlide || canCloseFromVerticalSlide) && event.actionMasked == MotionEvent.ACTION_UP) {
|
||||
requireActivity().onBackPressed()
|
||||
} else {
|
||||
sharedViewModel.setIsChildScrolling(false)
|
||||
requireView().animate()
|
||||
.setInterpolator(StoryGestureListener.INTERPOLATOR)
|
||||
.setDuration(100)
|
||||
|
@ -294,6 +295,10 @@ class StoryViewerPageFragment :
|
|||
viewModel.setIsUserScrollingParent(isScrolling)
|
||||
}
|
||||
|
||||
lifecycleDisposable += sharedViewModel.isChildScrolling.subscribe {
|
||||
viewModel.setIsUserScrollingChild(it)
|
||||
}
|
||||
|
||||
lifecycleDisposable += storyVolumeViewModel.state.distinctUntilChanged().observeOn(AndroidSchedulers.mainThread()).subscribe { volumeState ->
|
||||
if (volumeState.isMuted) {
|
||||
videoControlsDelegate.mute()
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
|||
import org.thoughtcrime.securesms.util.livedata.Store
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
|
@ -32,6 +33,7 @@ class StoryViewerPageViewModel(
|
|||
private val store = RxStore(StoryViewerPageState(isReceiptsEnabled = repository.isReadReceiptsEnabled()))
|
||||
private val disposables = CompositeDisposable()
|
||||
private val storyViewerDialogSubject: Subject<Optional<StoryViewerDialog>> = PublishSubject.create()
|
||||
private val storyLongPressSubject: Subject<Boolean> = PublishSubject.create()
|
||||
|
||||
private val storyViewerPlaybackStore = Store(StoryViewerPlaybackState())
|
||||
|
||||
|
@ -88,6 +90,10 @@ class StoryViewerPageViewModel(
|
|||
.map { it.attachment }
|
||||
)
|
||||
}
|
||||
|
||||
disposables += storyLongPressSubject.debounce(150, TimeUnit.MILLISECONDS).subscribe { isLongPress ->
|
||||
storyViewerPlaybackStore.update { it.copy(isUserLongTouching = isLongPress) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
|
@ -183,6 +189,10 @@ class StoryViewerPageViewModel(
|
|||
storyViewerPlaybackStore.update { it.copy(isUserScrollingParent = isUserScrollingParent) }
|
||||
}
|
||||
|
||||
fun setIsUserScrollingChild(isUserScrollingChild: Boolean) {
|
||||
storyViewerPlaybackStore.update { it.copy(isUserScrollingChild = isUserScrollingChild) }
|
||||
}
|
||||
|
||||
fun setIsDisplayingSlate(isDisplayingSlate: Boolean) {
|
||||
storyViewerPlaybackStore.update { it.copy(isDisplayingSlate = isDisplayingSlate) }
|
||||
}
|
||||
|
@ -225,6 +235,7 @@ class StoryViewerPageViewModel(
|
|||
|
||||
fun setIsUserTouching(isUserTouching: Boolean) {
|
||||
storyViewerPlaybackStore.update { it.copy(isUserTouching = isUserTouching) }
|
||||
storyLongPressSubject.onNext(isUserTouching)
|
||||
}
|
||||
|
||||
fun setAreSegmentsInitialized(areSegmentsInitialized: Boolean) {
|
||||
|
|
|
@ -17,11 +17,13 @@ data class StoryViewerPlaybackState(
|
|||
val isDisplayingReactionAnimation: Boolean = false,
|
||||
val isRunningSharedElementAnimation: Boolean = false,
|
||||
val isDisplayingFirstTimeNavigation: Boolean = false,
|
||||
val isDisplayingInfoDialog: Boolean = false
|
||||
val isDisplayingInfoDialog: Boolean = false,
|
||||
val isUserLongTouching: Boolean = false,
|
||||
val isUserScrollingChild: Boolean = false
|
||||
) {
|
||||
val hideChromeImmediate: Boolean = isRunningSharedElementAnimation
|
||||
|
||||
val hideChrome: Boolean = isRunningSharedElementAnimation || isUserTouching
|
||||
val hideChrome: Boolean = isRunningSharedElementAnimation || isUserLongTouching || isUserScrollingChild
|
||||
|
||||
val isPaused: Boolean = !areSegmentsInitialized ||
|
||||
isUserTouching ||
|
||||
|
|
Loading…
Add table
Reference in a new issue