Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3fa5f047 authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

Close guts during transitions

- Animate close when swiping between players in carousel
- Close when long pressing on the guts
- Close when screen turns off
- If media only shows in QS, close after going to QQS or lockscreen

Fixes: 184535725
Fixes: 182292357
Test: visual
Test: atest com.android.systemui.media
Change-Id: I596d8dc30d714098cb84f0f0779c2e233fffcf0e
parent 0e05cb9d
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -520,12 +520,20 @@ class MediaCarouselController @Inject constructor(
            this.desiredLocation = desiredLocation
            this.desiredLocation = desiredLocation
            this.desiredHostState = it
            this.desiredHostState = it
            currentlyExpanded = it.expansion > 0
            currentlyExpanded = it.expansion > 0

            val shouldCloseGuts = !currentlyExpanded && !mediaManager.hasActiveMedia() &&
                    desiredHostState.showsOnlyActiveMedia

            for (mediaPlayer in MediaPlayerData.players()) {
            for (mediaPlayer in MediaPlayerData.players()) {
                if (animate) {
                if (animate) {
                    mediaPlayer.mediaViewController.animatePendingStateChange(
                    mediaPlayer.mediaViewController.animatePendingStateChange(
                            duration = duration,
                            duration = duration,
                            delay = startDelay)
                            delay = startDelay)
                }
                }
                if (shouldCloseGuts && mediaPlayer.mediaViewController.isGutsVisible) {
                    mediaPlayer.closeGuts(!animate)
                }

                mediaPlayer.mediaViewController.onLocationPreChange(desiredLocation)
                mediaPlayer.mediaViewController.onLocationPreChange(desiredLocation)
            }
            }
            mediaCarouselScrollHandler.showsSettingsButton = !it.showsOnlyActiveMedia
            mediaCarouselScrollHandler.showsSettingsButton = !it.showsOnlyActiveMedia
@@ -541,9 +549,9 @@ class MediaCarouselController @Inject constructor(
        }
        }
    }
    }


    fun closeGuts() {
    fun closeGuts(immediate: Boolean = true) {
        MediaPlayerData.players().forEach {
        MediaPlayerData.players().forEach {
            it.closeGuts(true)
            it.closeGuts(immediate)
        }
        }
    }
    }


+2 −2
Original line number Original line Diff line number Diff line
@@ -59,7 +59,7 @@ class MediaCarouselScrollHandler(
    private val mainExecutor: DelayableExecutor,
    private val mainExecutor: DelayableExecutor,
    private val dismissCallback: () -> Unit,
    private val dismissCallback: () -> Unit,
    private var translationChangedListener: () -> Unit,
    private var translationChangedListener: () -> Unit,
    private val closeGuts: () -> Unit,
    private val closeGuts: (immediate: Boolean) -> Unit,
    private val falsingCollector: FalsingCollector,
    private val falsingCollector: FalsingCollector,
    private val falsingManager: FalsingManager,
    private val falsingManager: FalsingManager,
    private val logSmartspaceImpression: () -> Unit
    private val logSmartspaceImpression: () -> Unit
@@ -473,7 +473,7 @@ class MediaCarouselScrollHandler(
            if (oldIndex != visibleMediaIndex && visibleToUser) {
            if (oldIndex != visibleMediaIndex && visibleToUser) {
                logSmartspaceImpression()
                logSmartspaceImpression()
            }
            }
            closeGuts()
            closeGuts(false)
            updatePlayerVisibilities()
            updatePlayerVisibilities()
        }
        }
        val relativeLocation = visibleMediaIndex.toFloat() + if (playerWidthPlusPadding > 0)
        val relativeLocation = visibleMediaIndex.toFloat() + if (playerWidthPlusPadding > 0)
+2 −1
Original line number Original line Diff line number Diff line
@@ -212,7 +212,8 @@ public class MediaControlPanel {
                mMediaViewController.openGuts();
                mMediaViewController.openGuts();
                return true;
                return true;
            } else {
            } else {
                return false;
                closeGuts();
                return true;
            }
            }
        });
        });
        mPlayerViewHolder.getCancel().setOnClickListener(v -> {
        mPlayerViewHolder.getCancel().setOnClickListener(v -> {
+1 −0
Original line number Original line Diff line number Diff line
@@ -273,6 +273,7 @@ class MediaHierarchyManager @Inject constructor(
                } else {
                } else {
                    updateDesiredLocation()
                    updateDesiredLocation()
                    qsExpanded = false
                    qsExpanded = false
                    closeGuts()
                }
                }
                mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = isVisibleToUser()
                mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = isVisibleToUser()
            }
            }
+1 −0
Original line number Original line Diff line number Diff line
@@ -289,6 +289,7 @@ public class MediaControlPanelTest : SysuiTestCase() {


        captor.value.onLongClick(holder.player)
        captor.value.onLongClick(holder.player)
        verify(mediaViewController, never()).openGuts()
        verify(mediaViewController, never()).openGuts()
        verify(mediaViewController).closeGuts(false)
    }
    }


    @Test
    @Test
Loading