Merge "Set seekbar listening when UMO is visible to user" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
213d6640a9
@@ -164,13 +164,13 @@ constructor(
|
|||||||
mediaCarouselScrollHandler.scrollToStart()
|
mediaCarouselScrollHandler.scrollToStart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private var currentlyExpanded = true
|
|
||||||
|
@VisibleForTesting
|
||||||
|
var currentlyExpanded = true
|
||||||
set(value) {
|
set(value) {
|
||||||
if (field != value) {
|
if (field != value) {
|
||||||
field = value
|
field = value
|
||||||
for (player in MediaPlayerData.players()) {
|
updateSeekbarListening(mediaCarouselScrollHandler.visibleToUser)
|
||||||
player.setListening(field)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +259,7 @@ constructor(
|
|||||||
executor,
|
executor,
|
||||||
this::onSwipeToDismiss,
|
this::onSwipeToDismiss,
|
||||||
this::updatePageIndicatorLocation,
|
this::updatePageIndicatorLocation,
|
||||||
|
this::updateSeekbarListening,
|
||||||
this::closeGuts,
|
this::closeGuts,
|
||||||
falsingCollector,
|
falsingCollector,
|
||||||
falsingManager,
|
falsingManager,
|
||||||
@@ -629,7 +630,9 @@ constructor(
|
|||||||
)
|
)
|
||||||
newPlayer.mediaViewHolder?.player?.setLayoutParams(lp)
|
newPlayer.mediaViewHolder?.player?.setLayoutParams(lp)
|
||||||
newPlayer.bindPlayer(data, key)
|
newPlayer.bindPlayer(data, key)
|
||||||
newPlayer.setListening(currentlyExpanded)
|
newPlayer.setListening(
|
||||||
|
mediaCarouselScrollHandler.visibleToUser && currentlyExpanded
|
||||||
|
)
|
||||||
MediaPlayerData.addMediaPlayer(
|
MediaPlayerData.addMediaPlayer(
|
||||||
key,
|
key,
|
||||||
data,
|
data,
|
||||||
@@ -914,6 +917,13 @@ constructor(
|
|||||||
.toFloat()
|
.toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Update listening to seekbar. */
|
||||||
|
private fun updateSeekbarListening(visibleToUser: Boolean) {
|
||||||
|
for (player in MediaPlayerData.players()) {
|
||||||
|
player.setListening(visibleToUser && currentlyExpanded)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Update the dimension of this carousel. */
|
/** Update the dimension of this carousel. */
|
||||||
private fun updateCarouselDimensions() {
|
private fun updateCarouselDimensions() {
|
||||||
var width = 0
|
var width = 0
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class MediaCarouselScrollHandler(
|
|||||||
private val mainExecutor: DelayableExecutor,
|
private val mainExecutor: DelayableExecutor,
|
||||||
val dismissCallback: () -> Unit,
|
val dismissCallback: () -> Unit,
|
||||||
private var translationChangedListener: () -> Unit,
|
private var translationChangedListener: () -> Unit,
|
||||||
|
private var seekBarUpdateListener: (visibleToUser: Boolean) -> Unit,
|
||||||
private val closeGuts: (immediate: Boolean) -> Unit,
|
private val closeGuts: (immediate: Boolean) -> Unit,
|
||||||
private val falsingCollector: FalsingCollector,
|
private val falsingCollector: FalsingCollector,
|
||||||
private val falsingManager: FalsingManager,
|
private val falsingManager: FalsingManager,
|
||||||
@@ -177,6 +178,12 @@ class MediaCarouselScrollHandler(
|
|||||||
|
|
||||||
/** Whether the media card is visible to user if any */
|
/** Whether the media card is visible to user if any */
|
||||||
var visibleToUser: Boolean = false
|
var visibleToUser: Boolean = false
|
||||||
|
set(value) {
|
||||||
|
if (field != value) {
|
||||||
|
field = value
|
||||||
|
seekBarUpdateListener.invoke(field)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Whether the quick setting is expanded or not */
|
/** Whether the quick setting is expanded or not */
|
||||||
var qsExpanded: Boolean = false
|
var qsExpanded: Boolean = false
|
||||||
|
|||||||
@@ -346,6 +346,11 @@ public class MediaControlPanel {
|
|||||||
mSeekBarViewModel.setListening(listening);
|
mSeekBarViewModel.setListening(listening);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public boolean getListening() {
|
||||||
|
return mSeekBarViewModel.getListening();
|
||||||
|
}
|
||||||
|
|
||||||
/** Sets whether the user is touching the seek bar to change the track position. */
|
/** Sets whether the user is touching the seek bar to change the track position. */
|
||||||
private void setIsScrubbing(boolean isScrubbing) {
|
private void setIsScrubbing(boolean isScrubbing) {
|
||||||
if (mMediaData == null || mMediaData.getSemanticActions() == null) {
|
if (mMediaData == null || mMediaData.getSemanticActions() == null) {
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ import org.mockito.Captor
|
|||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.floatThat
|
import org.mockito.Mockito.floatThat
|
||||||
import org.mockito.Mockito.mock
|
import org.mockito.Mockito.mock
|
||||||
|
import org.mockito.Mockito.reset
|
||||||
|
import org.mockito.Mockito.times
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.Mockito.`when` as whenever
|
import org.mockito.Mockito.`when` as whenever
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
@@ -775,4 +777,59 @@ class MediaCarouselControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testInvisibleToUserAndExpanded_playersNotListening() {
|
||||||
|
// Add players to carousel.
|
||||||
|
testPlayerOrdering()
|
||||||
|
|
||||||
|
// Make the carousel visible to user in expanded layout.
|
||||||
|
mediaCarouselController.currentlyExpanded = true
|
||||||
|
mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = true
|
||||||
|
|
||||||
|
// panel is the player for each MediaPlayerData.
|
||||||
|
// Verify that seekbar listening attribute in media control panel is set to true.
|
||||||
|
verify(panel, times(MediaPlayerData.players().size)).listening = true
|
||||||
|
|
||||||
|
// Make the carousel invisible to user.
|
||||||
|
mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = false
|
||||||
|
|
||||||
|
// panel is the player for each MediaPlayerData.
|
||||||
|
// Verify that seekbar listening attribute in media control panel is set to false.
|
||||||
|
verify(panel, times(MediaPlayerData.players().size)).listening = false
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testVisibleToUserAndExpanded_playersListening() {
|
||||||
|
// Add players to carousel.
|
||||||
|
testPlayerOrdering()
|
||||||
|
|
||||||
|
// Make the carousel visible to user in expanded layout.
|
||||||
|
mediaCarouselController.currentlyExpanded = true
|
||||||
|
mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = true
|
||||||
|
|
||||||
|
// panel is the player for each MediaPlayerData.
|
||||||
|
// Verify that seekbar listening attribute in media control panel is set to true.
|
||||||
|
verify(panel, times(MediaPlayerData.players().size)).listening = true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testUMOCollapsed_playersNotListening() {
|
||||||
|
// Add players to carousel.
|
||||||
|
testPlayerOrdering()
|
||||||
|
|
||||||
|
// Make the carousel in collapsed layout.
|
||||||
|
mediaCarouselController.currentlyExpanded = false
|
||||||
|
|
||||||
|
// panel is the player for each MediaPlayerData.
|
||||||
|
// Verify that seekbar listening attribute in media control panel is set to false.
|
||||||
|
verify(panel, times(MediaPlayerData.players().size)).listening = false
|
||||||
|
|
||||||
|
// Make the carousel visible to user.
|
||||||
|
reset(panel)
|
||||||
|
mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = true
|
||||||
|
|
||||||
|
// Verify that seekbar listening attribute in media control panel is set to false.
|
||||||
|
verify(panel, times(MediaPlayerData.players().size)).listening = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user