diff options
| author | 2024-05-03 15:13:05 +0000 | |
|---|---|---|
| committer | 2024-05-03 15:16:11 +0000 | |
| commit | 05b3c35ef048edbc1b0404fd9f16f7a0fe4e17cf (patch) | |
| tree | bac9074ef56cab8e473d754be9c8a66c720925a5 | |
| parent | 66da6b637e976e098205fe26c1c911ab44c30bb6 (diff) | |
Animate in screenshot actions.
Switch container insets to padding instead of margin, allow drawing
outside.
Translate up the actions container during the screenshot UI entrance.
Bug: 329659738
Test: Manual inspection with slowed-down animations
Flag: ACONFIG com.android.sysui.screenshot_shelf_ui2 TRUNKFOOD
Change-Id: I96ef8a57b917be9635a059415898c9f56d3f436c
3 files changed, 22 insertions, 8 deletions
diff --git a/packages/SystemUI/res/layout/screenshot_shelf.xml b/packages/SystemUI/res/layout/screenshot_shelf.xml index 7adfa6ca1c29..b4eb0f2dfb3b 100644 --- a/packages/SystemUI/res/layout/screenshot_shelf.xml +++ b/packages/SystemUI/res/layout/screenshot_shelf.xml @@ -23,7 +23,9 @@ <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/screenshot_static" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:clipChildren="false" + android:clipToPadding="false"> <FrameLayout android:id="@+id/actions_container_background" android:visibility="gone" diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotAnimationController.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotAnimationController.kt index 4eceb176fcd2..da268300e8c4 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotAnimationController.kt @@ -43,7 +43,6 @@ class ScreenshotAnimationController(private val view: ScreenshotShelfView) { private val staticUI = listOf<View>( view.requireViewById(R.id.screenshot_preview_border), - view.requireViewById(R.id.actions_container_background), view.requireViewById(R.id.screenshot_badge), view.requireViewById(R.id.screenshot_dismiss_button) ) @@ -71,6 +70,8 @@ class ScreenshotAnimationController(private val view: ScreenshotShelfView) { entranceAnimation.doOnStart { screenshotPreview.visibility = View.INVISIBLE } } + entranceAnimation.play(getActionsAnimator()).with(previewAnimator) + val fadeInAnimator = ValueAnimator.ofFloat(0f, 1f) fadeInAnimator.addUpdateListener { for (child in staticUI) { @@ -123,6 +124,20 @@ class ScreenshotAnimationController(private val view: ScreenshotShelfView) { animator?.cancel() } + private fun getActionsAnimator(): Animator { + val startingOffset = view.height - actionContainer.top + val actionsYAnimator = + ValueAnimator.ofFloat(startingOffset.toFloat(), 0f).apply { + duration = PREVIEW_Y_ANIMATION_DURATION_MS + interpolator = fastOutSlowIn + } + actionsYAnimator.addUpdateListener { + actionContainer.translationY = it.animatedValue as Float + } + actionContainer.translationY = startingOffset.toFloat() + return actionsYAnimator + } + private fun getPreviewAnimator(bounds: Rect): Animator { val targetPosition = Rect() screenshotPreview.getHitRect(targetPosition) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotShelfView.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotShelfView.kt index 4437bf533353..2dd1ca090299 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotShelfView.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ui/ScreenshotShelfView.kt @@ -75,15 +75,14 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) : fun updateInsets(insets: WindowInsets) { val orientation = mContext.resources.configuration.orientation val inPortrait = orientation == Configuration.ORIENTATION_PORTRAIT - val p = screenshotStatic.layoutParams as LayoutParams val cutout = insets.displayCutout val navBarInsets = insets.getInsets(WindowInsets.Type.navigationBars()) if (cutout == null) { - p.setMargins(0, 0, 0, navBarInsets.bottom) + screenshotStatic.setPadding(0, 0, 0, navBarInsets.bottom) } else { val waterfall = cutout.waterfallInsets if (inPortrait) { - p.setMargins( + screenshotStatic.setPadding( waterfall.left, max(cutout.safeInsetTop.toDouble(), waterfall.top.toDouble()).toInt(), waterfall.right, @@ -94,7 +93,7 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) : .toInt() ) } else { - p.setMargins( + screenshotStatic.setPadding( max(cutout.safeInsetLeft.toDouble(), waterfall.left.toDouble()).toInt(), waterfall.top, max(cutout.safeInsetRight.toDouble(), waterfall.right.toDouble()).toInt(), @@ -102,8 +101,6 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) : ) } } - screenshotStatic.layoutParams = p - screenshotStatic.requestLayout() } private fun getSwipeRegion(): Region { |