Merge "[Media] Allow a11y interactions to change seekbar position." into tm-dev am: b1b22000d6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17892724 Change-Id: I3b6a016fd9c52bd2d918b9ed22e80f9691bb2211 Ignore-AOSP-First: this is an automerge Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -151,13 +151,21 @@ class SeekBarViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event indicating that the user has moved the seek bar but hasn't yet finished the gesture.
|
* Event indicating that the user has moved the seek bar.
|
||||||
|
*
|
||||||
* @param position Current location in the track.
|
* @param position Current location in the track.
|
||||||
*/
|
*/
|
||||||
@AnyThread
|
@AnyThread
|
||||||
fun onSeekProgress(position: Long) = bgExecutor.execute {
|
fun onSeekProgress(position: Long) = bgExecutor.execute {
|
||||||
if (scrubbing) {
|
if (scrubbing) {
|
||||||
|
// The user hasn't yet finished their touch gesture, so only update the data for visual
|
||||||
|
// feedback and don't update [controller] yet.
|
||||||
_data = _data.copy(elapsedTime = position.toInt())
|
_data = _data.copy(elapsedTime = position.toInt())
|
||||||
|
} else {
|
||||||
|
// The seek progress came from an a11y action and we should immediately update to the
|
||||||
|
// new position. (a11y actions to change the seekbar position don't trigger
|
||||||
|
// SeekBar.OnSeekBarChangeListener.onStartTrackingTouch or onStopTrackingTouch.)
|
||||||
|
onSeek(position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -375,16 +375,20 @@ public class SeekBarViewModelTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onProgressChangedFromUserWithoutStartTrackingTouch() {
|
fun onProgressChangedFromUserWithoutStartTrackingTouch_transportUpdated() {
|
||||||
// WHEN user starts dragging the seek bar
|
whenever(mockController.transportControls).thenReturn(mockTransport)
|
||||||
|
viewModel.updateController(mockController)
|
||||||
val pos = 42
|
val pos = 42
|
||||||
val bar = SeekBar(context)
|
val bar = SeekBar(context)
|
||||||
|
|
||||||
|
// WHEN we get an onProgressChanged event without an onStartTrackingTouch event
|
||||||
with(viewModel.seekBarListener) {
|
with(viewModel.seekBarListener) {
|
||||||
onProgressChanged(bar, pos, true)
|
onProgressChanged(bar, pos, true)
|
||||||
}
|
}
|
||||||
fakeExecutor.runAllReady()
|
fakeExecutor.runAllReady()
|
||||||
// THEN then elapsed time should not be updated
|
|
||||||
assertThat(viewModel.progress.value!!.elapsedTime).isNull()
|
// THEN we immediately update the transport
|
||||||
|
verify(mockTransport).seekTo(pos.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user