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