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

Commit 24cbd89f authored by Matt Casey's avatar Matt Casey Committed by Android (Google) Code Review
Browse files

Merge "Animate in screenshot actions." into 24D1-dev

parents 40432f26 05b3c35e
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
@@ -77,15 +77,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,
@@ -96,7 +95,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(),
@@ -104,8 +103,6 @@ class ScreenshotShelfView(context: Context, attrs: AttributeSet? = null) :
                )
            }
        }
        screenshotStatic.layoutParams = p
        screenshotStatic.requestLayout()
    }

    private fun getSwipeRegion(): Region {