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

Commit 05b3c35e authored by Matt Casey's avatar Matt Casey
Browse files

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
parent 66da6b63
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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"
+16 −1
Original line number Diff line number Diff line
@@ -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)
+3 −6
Original line number Diff line number Diff line
@@ -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 {