summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/media/controls/ui/composable/MediaCarouselStateLoader.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt8
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt57
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaViewController.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaControlViewModel.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaRecommendationsViewModel.kt4
6 files changed, 51 insertions, 42 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/media/controls/ui/composable/MediaCarouselStateLoader.kt b/packages/SystemUI/compose/features/src/com/android/systemui/media/controls/ui/composable/MediaCarouselStateLoader.kt
index b43a5b80b1b6..4a0136c40c14 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/media/controls/ui/composable/MediaCarouselStateLoader.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/media/controls/ui/composable/MediaCarouselStateLoader.kt
@@ -49,7 +49,7 @@ object MediaCarouselStateLoader {
Scenes.Shade -> MediaHierarchyManager.LOCATION_QQS
Scenes.Lockscreen -> MediaHierarchyManager.LOCATION_LOCKSCREEN
Scenes.Communal -> MediaHierarchyManager.LOCATION_COMMUNAL_HUB
- else -> -1
+ else -> MediaHierarchyManager.LOCATION_UNKNOWN
}
}
@@ -59,7 +59,7 @@ object MediaCarouselStateLoader {
return when (content) {
Overlays.QuickSettingsShade -> MediaHierarchyManager.LOCATION_QS
Overlays.NotificationsShade -> MediaHierarchyManager.LOCATION_QQS
- else -> -1
+ else -> MediaHierarchyManager.LOCATION_UNKNOWN
}
}
@@ -75,8 +75,8 @@ object MediaCarouselStateLoader {
data object Gone : State {
override val transitionProgress: Float = 1.0F
override val squishFraction: () -> Float = { 1.0F }
- override val endLocation: Int = -1
- override val startLocation: Int = -1
+ override val endLocation: Int = MediaHierarchyManager.LOCATION_UNKNOWN
+ override val startLocation: Int = MediaHierarchyManager.LOCATION_UNKNOWN
}
/** State when media carousel is moving from one media location to another */
@@ -91,7 +91,7 @@ object MediaCarouselStateLoader {
/** State when media carousel reached the end location. */
data class Idle(override val endLocation: Int) : State {
override val transitionProgress = 1.0F
- override val startLocation = -1
+ override val startLocation = MediaHierarchyManager.LOCATION_UNKNOWN
override val squishFraction = { 1.0F }
}
}
@@ -120,7 +120,7 @@ object MediaCarouselStateLoader {
} else if (MediaContentPicker.contents.contains(toScene)) {
State.InProgress(
transitionProgress = 1.0F,
- startLocation = -1,
+ startLocation = MediaHierarchyManager.LOCATION_UNKNOWN,
getMediaLocation(toScene),
)
} else {
@@ -141,7 +141,7 @@ object MediaCarouselStateLoader {
} else if (MediaContentPicker.contents.contains(toContent)) {
State.InProgress(
transitionProgress = 1.0F,
- startLocation = -1,
+ startLocation = MediaHierarchyManager.LOCATION_UNKNOWN,
getMediaLocation(toContent),
)
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt
index c1e28b356ce0..a0fb0bf25c7b 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt
@@ -175,19 +175,21 @@ constructor(
* The desired location where we'll be at the end of the transformation. Usually this matches
* the end location, except when we're still waiting on a state update call.
*/
- @MediaLocation private var desiredLocation: Int = -1
+ @MediaLocation private var desiredLocation: Int = MediaHierarchyManager.LOCATION_UNKNOWN
/**
* The ending location of the view where it ends when all animations and transitions have
* finished
*/
- @MediaLocation @VisibleForTesting var currentEndLocation: Int = -1
+ @MediaLocation
+ @VisibleForTesting
+ var currentEndLocation: Int = MediaHierarchyManager.LOCATION_UNKNOWN
/**
* The ending location of the view where it ends when all animations and transitions have
* finished
*/
- @MediaLocation private var currentStartLocation: Int = -1
+ @MediaLocation private var currentStartLocation: Int = MediaHierarchyManager.LOCATION_UNKNOWN
/** The progress of the transition or 1.0 if there is no transition happening */
private var currentTransitionProgress: Float = 1.0f
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
index 38cea5b23f78..745ab12c27d6 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
@@ -64,7 +64,6 @@ import com.android.systemui.util.settings.SecureSettings
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
@@ -161,10 +160,10 @@ constructor(
private var animationStartAlpha = 0.0f
/** The starting location of the cross fade if an animation is running right now. */
- @MediaLocation private var crossFadeAnimationStartLocation = -1
+ @MediaLocation private var crossFadeAnimationStartLocation = LOCATION_UNKNOWN
/** The end location of the cross fade if an animation is running right now. */
- @MediaLocation private var crossFadeAnimationEndLocation = -1
+ @MediaLocation private var crossFadeAnimationEndLocation = LOCATION_UNKNOWN
private var targetBounds: Rect = Rect()
private val mediaFrame
get() = mediaCarouselController.mediaFrame
@@ -191,7 +190,7 @@ constructor(
animationStartBounds,
targetBounds,
boundsProgress,
- result = currentBounds
+ result = currentBounds,
)
resolveClipping(currentClipping)
applyState(currentBounds, currentAlpha, clipBounds = currentClipping)
@@ -233,16 +232,16 @@ constructor(
* The last location where this view was at before going to the desired location. This is useful
* for guided transitions.
*/
- @MediaLocation private var previousLocation = -1
+ @MediaLocation private var previousLocation = LOCATION_UNKNOWN
/** The desired location where the view will be at the end of the transition. */
- @MediaLocation private var desiredLocation = -1
+ @MediaLocation private var desiredLocation = LOCATION_UNKNOWN
/**
* The current attachment location where the view is currently attached. Usually this matches
* the desired location except for animations whenever a view moves to the new desired location,
* during which it is in [IN_OVERLAY].
*/
- @MediaLocation private var currentAttachmentLocation = -1
+ @MediaLocation private var currentAttachmentLocation = LOCATION_UNKNOWN
private var inSplitShade = false
@@ -627,7 +626,7 @@ constructor(
secureSettings.getBoolForUser(
Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN,
true,
- UserHandle.USER_CURRENT
+ UserHandle.USER_CURRENT,
)
}
}
@@ -635,7 +634,7 @@ constructor(
secureSettings.registerContentObserverForUserSync(
Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN,
settingsObserver,
- UserHandle.USER_ALL
+ UserHandle.USER_ALL,
)
// Listen to the communal UI state. Make sure that communal UI is showing and hub itself is
@@ -651,7 +650,7 @@ constructor(
shadeInteractor.shadeExpansion
.mapLatest { it < EXPANSION_THRESHOLD }
.distinctUntilChanged(),
- ::Triple
+ ::Triple,
)
.collectLatest { (communalShowing, isDreaming, isShadeExpanding) ->
isCommunalShowing = communalShowing
@@ -689,10 +688,10 @@ constructor(
if (mediaObject.location == desiredLocation) {
// In case we are overriding a view that is already visible, make sure we attach it
// to this new host view in the below call
- desiredLocation = -1
+ desiredLocation = LOCATION_UNKNOWN
}
if (mediaObject.location == currentAttachmentLocation) {
- currentAttachmentLocation = -1
+ currentAttachmentLocation = LOCATION_UNKNOWN
}
updateDesiredLocation()
return viewHost
@@ -734,7 +733,7 @@ constructor(
*/
private fun updateDesiredLocation(
forceNoAnimation: Boolean = false,
- forceStateUpdate: Boolean = false
+ forceStateUpdate: Boolean = false,
) =
traceSection("MediaHierarchyManager#updateDesiredLocation") {
val desiredLocation = calculateLocation()
@@ -758,7 +757,7 @@ constructor(
previousLocation = LOCATION_QQS
}
}
- val isNewView = this.desiredLocation == -1
+ val isNewView = this.desiredLocation == LOCATION_UNKNOWN
this.desiredLocation = desiredLocation
// Let's perform a transition
val animate =
@@ -774,7 +773,7 @@ constructor(
host,
animate,
animDuration,
- delay
+ delay,
)
}
performTransitionToNewLocation(isNewView, animate)
@@ -868,7 +867,7 @@ constructor(
private fun shouldAnimateTransition(
@MediaLocation currentLocation: Int,
- @MediaLocation previousLocation: Int
+ @MediaLocation previousLocation: Int,
): Boolean {
if (isCurrentlyInGuidedTransformation()) {
return false
@@ -990,7 +989,7 @@ constructor(
startBounds: Rect,
endBounds: Rect,
progress: Float,
- result: Rect? = null
+ result: Rect? = null,
): Rect {
val left =
MathUtils.lerp(startBounds.left.toFloat(), endBounds.left.toFloat(), progress).toInt()
@@ -1014,7 +1013,7 @@ constructor(
}
private fun hasValidStartAndEndLocations(): Boolean {
- return previousLocation != -1 && desiredLocation != -1
+ return previousLocation != LOCATION_UNKNOWN && desiredLocation != LOCATION_UNKNOWN
}
/** Calculate the transformation type for the current animation */
@@ -1099,21 +1098,21 @@ constructor(
bounds: Rect,
alpha: Float,
immediately: Boolean = false,
- clipBounds: Rect = EMPTY_RECT
+ clipBounds: Rect = EMPTY_RECT,
) =
traceSection("MediaHierarchyManager#applyState") {
currentBounds.set(bounds)
currentClipping = clipBounds
carouselAlpha = if (isCurrentlyFading()) alpha else 1.0f
val onlyUseEndState = !isCurrentlyInGuidedTransformation() || isCurrentlyFading()
- val startLocation = if (onlyUseEndState) -1 else previousLocation
+ val startLocation = if (onlyUseEndState) LOCATION_UNKNOWN else previousLocation
val progress = if (onlyUseEndState) 1.0f else getTransformationProgress()
val endLocation = resolveLocationForFading()
mediaCarouselController.setCurrentState(
startLocation,
endLocation,
progress,
- immediately
+ immediately,
)
updateHostAttachment()
if (currentAttachmentLocation == IN_OVERLAY) {
@@ -1125,7 +1124,7 @@ constructor(
currentBounds.left,
currentBounds.top,
currentBounds.right,
- currentBounds.bottom
+ currentBounds.bottom,
)
}
}
@@ -1186,7 +1185,7 @@ constructor(
mediaCarouselController.onDesiredLocationChanged(
newLocation,
getHost(newLocation),
- animate = false
+ animate = false,
)
}
}
@@ -1201,7 +1200,7 @@ constructor(
if (isCrossFadeAnimatorRunning) {
// When animating between two hosts with a fade, let's keep ourselves in the old
// location for the first half, and then switch over to the end location
- if (animationCrossFadeProgress > 0.5 || previousLocation == -1) {
+ if (animationCrossFadeProgress > 0.5 || previousLocation == LOCATION_UNKNOWN) {
return crossFadeAnimationEndLocation
} else {
return crossFadeAnimationStartLocation
@@ -1364,6 +1363,9 @@ constructor(
/** Attached at the root of the hierarchy in an overlay */
const val IN_OVERLAY = -1000
+ /** Not attached to any view */
+ const val LOCATION_UNKNOWN = -1
+
/**
* The default transformation type where the hosts transform into each other using a direct
* transition
@@ -1388,8 +1390,8 @@ private val EMPTY_RECT = Rect()
value =
[
MediaHierarchyManager.TRANSFORMATION_TYPE_TRANSITION,
- MediaHierarchyManager.TRANSFORMATION_TYPE_FADE
- ]
+ MediaHierarchyManager.TRANSFORMATION_TYPE_FADE,
+ ],
)
@Retention(AnnotationRetention.SOURCE)
private annotation class TransformationType
@@ -1403,7 +1405,8 @@ private annotation class TransformationType
MediaHierarchyManager.LOCATION_LOCKSCREEN,
MediaHierarchyManager.LOCATION_DREAM_OVERLAY,
MediaHierarchyManager.LOCATION_COMMUNAL_HUB,
- ]
+ MediaHierarchyManager.LOCATION_UNKNOWN,
+ ],
)
@Retention(AnnotationRetention.SOURCE)
annotation class MediaLocation
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaViewController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaViewController.kt
index 4d4a5a9780b7..3928a711f840 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaViewController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaViewController.kt
@@ -120,7 +120,7 @@ constructor(
* finished
*/
@MediaLocation
- var currentEndLocation: Int = -1
+ var currentEndLocation: Int = MediaHierarchyManager.LOCATION_UNKNOWN
set(value) {
if (field != value) {
field = value
@@ -130,7 +130,7 @@ constructor(
}
/** The starting location of the view where it starts for all animations and transitions */
- @MediaLocation private var currentStartLocation: Int = -1
+ @MediaLocation private var currentStartLocation: Int = MediaHierarchyManager.LOCATION_UNKNOWN
/** The progress of the transition or 1.0 if there is no transition happening */
private var currentTransitionProgress: Float = 1.0f
@@ -653,7 +653,7 @@ constructor(
logger.logMediaLocation("attach $type", currentStartLocation, currentEndLocation)
this.transitionLayout = transitionLayout
layoutController.attach(transitionLayout)
- if (currentEndLocation == -1) {
+ if (currentEndLocation == MediaHierarchyManager.LOCATION_UNKNOWN) {
return
}
// Set the previously set state immediately to the view, now that it's finally attached
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaControlViewModel.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaControlViewModel.kt
index f07f2de08537..4173d2aa272e 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaControlViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaControlViewModel.kt
@@ -33,6 +33,8 @@ import com.android.systemui.media.controls.domain.pipeline.interactor.MediaContr
import com.android.systemui.media.controls.shared.model.MediaAction
import com.android.systemui.media.controls.shared.model.MediaButton
import com.android.systemui.media.controls.shared.model.MediaControlModel
+import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager
+import com.android.systemui.media.controls.ui.controller.MediaLocation
import com.android.systemui.media.controls.util.MediaSmartspaceLogger.Companion.SMARTSPACE_CARD_CLICK_EVENT
import com.android.systemui.media.controls.util.MediaSmartspaceLogger.Companion.SMARTSPACE_CARD_DISMISS_EVENT
import com.android.systemui.media.controls.util.MediaUiEventLogger
@@ -70,7 +72,7 @@ class MediaControlViewModel(
private var isPlaying = false
private var isAnyButtonClicked = false
- private var location = -1
+ @MediaLocation private var location = MediaHierarchyManager.LOCATION_UNKNOWN
private var playerViewModel: MediaPlayerViewModel? = null
fun isNewPlayer(viewModel: MediaPlayerViewModel): Boolean {
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaRecommendationsViewModel.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaRecommendationsViewModel.kt
index a7bce7772270..6bc6b10a1dfd 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaRecommendationsViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/MediaRecommendationsViewModel.kt
@@ -31,6 +31,8 @@ import com.android.systemui.media.controls.domain.pipeline.interactor.MediaRecom
import com.android.systemui.media.controls.shared.model.MediaRecModel
import com.android.systemui.media.controls.shared.model.MediaRecommendationsModel
import com.android.systemui.media.controls.shared.model.NUM_REQUIRED_RECOMMENDATIONS
+import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager
+import com.android.systemui.media.controls.ui.controller.MediaLocation
import com.android.systemui.media.controls.ui.controller.MediaViewController.Companion.GUTS_ANIMATION_DURATION
import com.android.systemui.media.controls.util.MediaDataUtils
import com.android.systemui.media.controls.util.MediaSmartspaceLogger.Companion.SMARTSPACE_CARD_CLICK_EVENT
@@ -66,7 +68,7 @@ constructor(
.distinctUntilChanged()
.flowOn(backgroundDispatcher)
- private var location = -1
+ @MediaLocation private var location = MediaHierarchyManager.LOCATION_UNKNOWN
/**
* Called whenever the recommendation has been expired or removed by the user. This method